From 6944560706c23a3f0bc39a7c6157ff07d72388ce Mon Sep 17 00:00:00 2001 From: Vinicius Moreira Date: Tue, 17 May 2022 11:17:15 -0300 Subject: [PATCH] [view] improvement: the app name displayed on the management window will be cut based on a percentage over the primary screen width (15%) --- CHANGELOG.md | 1 + bauh/view/qt/apps_table.py | 15 +++++++-------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 72545367..c2c64c5c 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 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%) ### Fixes diff --git a/bauh/view/qt/apps_table.py b/bauh/view/qt/apps_table.py index 99e3ef4f..7b8e9d73 100644 --- a/bauh/view/qt/apps_table.py +++ b/bauh/view/qt/apps_table.py @@ -18,7 +18,6 @@ from bauh.view.qt.dialog import ConfirmationDialog from bauh.view.qt.view_model import PackageView from bauh.view.util.translation import I18n -NAME_MAX_SIZE = 30 PUBLISHER_MAX_SIZE = 25 @@ -434,20 +433,20 @@ class PackagesTable(QTableWidget): col_name.setObjectName('app_name') col_name.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Preferred) - name = pkg.model.get_display_name() + name = pkg.model.get_display_name().strip() if name: col_name.setToolTip('{}: {}'.format(self.i18n['app.name'].lower(), pkg.model.get_name_tooltip())) else: name = '...' col_name.setToolTip(self.i18n['app.name'].lower()) - if len(name) > NAME_MAX_SIZE: - name = name[0:NAME_MAX_SIZE - 3] + '...' - - if len(name) < NAME_MAX_SIZE: - name = name + ' ' * (NAME_MAX_SIZE - len(name)) - col_name.setText(name) + screen_perc = col_name.sizeHint().width() / self.screen_width + + if screen_perc > 0.15: + max_chars = int(len(name) * 0.15 / screen_perc) - 3 + col_name.setText(name[0:max_chars] + '...') + self.setCellWidget(pkg.table_index, col, col_name) def _update_icon(self, label: QLabel, icon: QIcon):