From 9e6d9feaaf35c74d57ff7ebdbbd3353facd4846e Mon Sep 17 00:00:00 2001 From: Vinicius Moreira Date: Tue, 17 May 2022 11:06:44 -0300 Subject: [PATCH] [view] improvement: the app description displayed on the management window will be cut based on a percentage over the primary screen width (18%) --- CHANGELOG.md | 1 + bauh/view/qt/apps_table.py | 11 ++++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7adb912a..72545367 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - settings window size rules moved to stylesheet files - enforcing maximum width and height for the management window based on the primary screen resolution [#261](https://github.com/vinifmor/bauh/issues/261) - updates: only displaying both the installed and latest versions on the "version" column if its width is no more than 22% of the primary screen width (otherwise just the latest version will be displayed) + - the app description displayed on the management window will be cut based on a percentage over the primary screen width (18%) ### Fixes - Flatpak diff --git a/bauh/view/qt/apps_table.py b/bauh/view/qt/apps_table.py index abd09c1c..99e3ef4f 100644 --- a/bauh/view/qt/apps_table.py +++ b/bauh/view/qt/apps_table.py @@ -19,7 +19,6 @@ from bauh.view.qt.view_model import PackageView from bauh.view.util.translation import I18n NAME_MAX_SIZE = 30 -DESC_MAX_SIZE = 40 PUBLISHER_MAX_SIZE = 25 @@ -467,11 +466,17 @@ class PackagesTable(QTableWidget): else: desc = '...' - if desc and desc != '...' and len(desc) > DESC_MAX_SIZE: - desc = strip_html(desc[0: DESC_MAX_SIZE - 1]) + '...' + if desc and desc != '...': + desc = strip_html(desc) item.setText(desc) + current_width_perc = item.sizeHint().width() / self.screen_width + if current_width_perc > 0.18: + max_width = int(len(desc) * 0.18 / current_width_perc) - 3 + desc = desc[0:max_width] + '...' + item.setText(desc) + if pkg.model.description: item.setToolTip(pkg.model.description)