[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

This commit is contained in:
Vinicius Moreira
2022-05-17 10:37:45 -03:00
parent 712a72edf6
commit 0c07ef410c
3 changed files with 12 additions and 5 deletions

View File

@@ -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

View File

@@ -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)

View File

@@ -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)