From 9f0956d29ee4116d3305941cff9e74b52c54c55e Mon Sep 17 00:00:00 2001 From: Vinicius Moreira Date: Tue, 17 May 2022 11:27:56 -0300 Subject: [PATCH] [view] improvement: the app publisher displayed on the management window will be cut based on a percentage over the primary screen width (12%) --- CHANGELOG.md | 1 + bauh/view/qt/apps_table.py | 18 +++++++++++------- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c2c64c5c..83dc7b62 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - 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 name displayed on the management window will be cut based on a percentage over the primary screen width (15%) - the app description displayed on the management window will be cut based on a percentage over the primary screen width (18%) + - the app publisher displayed on the management window will be cut based on a percentage over the primary screen width (12%) ### Fixes - Flatpak diff --git a/bauh/view/qt/apps_table.py b/bauh/view/qt/apps_table.py index 7b8e9d73..87dfe125 100644 --- a/bauh/view/qt/apps_table.py +++ b/bauh/view/qt/apps_table.py @@ -18,8 +18,6 @@ from bauh.view.qt.dialog import ConfirmationDialog from bauh.view.qt.view_model import PackageView from bauh.view.util.translation import I18n -PUBLISHER_MAX_SIZE = 25 - class UpgradeToggleButton(QToolButton): @@ -487,15 +485,21 @@ class PackagesTable(QTableWidget): publisher = pkg.model.get_publisher() full_publisher = None + lb_name = QLabel() + lb_name.setObjectName('app_publisher') + if publisher: publisher = publisher.strip() full_publisher = publisher - if len(publisher) > PUBLISHER_MAX_SIZE: - publisher = full_publisher[0: PUBLISHER_MAX_SIZE - 3] + '...' + if publisher: + lb_name.setText(publisher) + screen_perc = lb_name.sizeHint().width() / self.screen_width - lb_name = QLabel() - lb_name.setObjectName('app_publisher') + if screen_perc > 0.12: + max_chars = int(len(publisher) * 0.12 / screen_perc) - 3 + publisher = publisher[0: max_chars] + '...' + lb_name.setText(publisher) if not publisher: if not pkg.model.installed: @@ -503,7 +507,7 @@ class PackagesTable(QTableWidget): publisher = self.i18n['unknown'] - lb_name.setText(' {}'.format(publisher)) + lb_name.setText(f' {publisher}') item.addWidget(lb_name) if publisher and full_publisher: