From 0c07ef410c2fabf2878f3b5495d056f874eb8edc Mon Sep 17 00:00:00 2001 From: Vinicius Moreira Date: Tue, 17 May 2022 10:37:45 -0300 Subject: [PATCH] [view] improvement: only displaying both the installed and latest versions on the 'version' column if its width is no more than 20% of the primary screen width --- CHANGELOG.md | 2 +- bauh/view/qt/apps_table.py | 11 ++++++++--- bauh/view/qt/window.py | 4 +++- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 411514f9..d666d654 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,7 +16,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - table columns width for maximized window - 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 20% of the primary screen width (otherwise just the latest version will be displayed) ### Fixes - Flatpak diff --git a/bauh/view/qt/apps_table.py b/bauh/view/qt/apps_table.py index 1d80e4df..4eb6525c 100644 --- a/bauh/view/qt/apps_table.py +++ b/bauh/view/qt/apps_table.py @@ -72,8 +72,9 @@ class PackagesTable(QTableWidget): COL_NUMBER = 9 DEFAULT_ICON_SIZE = QSize(16, 16) - def __init__(self, parent: QWidget, icon_cache: MemoryCache, download_icons: bool): + def __init__(self, parent: QWidget, icon_cache: MemoryCache, download_icons: bool, screen_width: int): super(PackagesTable, self).__init__() + self.screen_width = screen_width self.setObjectName('table_packages') self.setParent(parent) self.window = parent @@ -382,8 +383,12 @@ class PackagesTable(QTableWidget): tooltip = self.i18n['version.updates_ignored'] if pkg.model.installed and pkg.model.update and not pkg.model.is_update_ignored() and pkg.model.version and pkg.model.latest_version and pkg.model.version != pkg.model.latest_version: - tooltip = '{}. {}: {}'.format(tooltip, self.i18n['version.latest'], pkg.model.latest_version) - label_version.setText(label_version.text() + ' > {}'.format(pkg.model.latest_version)) + tooltip = f"{tooltip} ({self.i18n['version.installed']}: {pkg.model.version} | " \ + f"{self.i18n['version.latest']}: {pkg.model.latest_version})" + label_version.setText(f"{label_version.text()} > {pkg.model.latest_version}") + + if label_version.sizeHint().width() / self.screen_width > 0.20: + label_version.setText(pkg.model.latest_version) item.setToolTip(tooltip) self.setCellWidget(pkg.table_index, col, item) diff --git a/bauh/view/qt/window.py b/bauh/view/qt/window.py index 77bb21d9..db96405f 100755 --- a/bauh/view/qt/window.py +++ b/bauh/view/qt/window.py @@ -277,7 +277,9 @@ class ManageWindow(QWidget): self.table_container.setLayout(QVBoxLayout()) self.table_container.layout().setContentsMargins(0, 0, 0, 0) - self.table_apps = PackagesTable(self, self.icon_cache, download_icons=bool(self.config['download']['icons'])) + self.table_apps = PackagesTable(self, self.icon_cache, + download_icons=bool(self.config['download']['icons']), + screen_width=int(screen_size.width())) self.table_apps.change_headers_policy() self.table_container.layout().addWidget(self.table_apps)