[view] improvement: new 'installed' filter

This commit is contained in:
Vinicius Moreira
2022-03-11 12:40:12 -03:00
parent 508e9169c2
commit 36f0bf507a
12 changed files with 57 additions and 17 deletions

View File

@@ -61,7 +61,10 @@ def sum_updates_displayed(info: dict) -> int:
def is_package_hidden(pkg: PackageView, filters: dict) -> bool:
hidden = filters['only_apps'] and pkg.model.installed and not pkg.model.is_application()
hidden = filters['only_installed'] and not pkg.model.installed
if not hidden and filters['only_apps']:
hidden = pkg.model.installed and not pkg.model.is_application()
if not hidden and filters['updates']:
hidden = not pkg.model.update or pkg.model.is_update_ignored()

View File

@@ -69,16 +69,17 @@ BT_INSTALLED = 2
BT_REFRESH = 3
BT_SUGGESTIONS = 4
BT_UPGRADE = 5
CHECK_UPDATES = 6
CHECK_APPS = 7
COMBO_TYPES = 8
COMBO_CATEGORIES = 9
INP_NAME = 10
CHECK_DETAILS = 11
BT_SETTINGS = 12
BT_CUSTOM_ACTIONS = 13
BT_ABOUT = 14
BT_THEMES = 15
CHECK_INSTALLED = 6
CHECK_UPDATES = 7
CHECK_APPS = 8
COMBO_TYPES = 9
COMBO_CATEGORIES = 10
INP_NAME = 11
CHECK_DETAILS = 12
BT_SETTINGS = 13
BT_CUSTOM_ACTIONS = 14
BT_ABOUT = 15
BT_THEMES = 16
# component groups ids
GROUP_FILTERS = 1
@@ -153,6 +154,16 @@ class ManageWindow(QWidget):
self.toolbar_filters.layout().addWidget(self.check_updates)
self.comp_manager.register_component(CHECK_UPDATES, self.check_updates)
self.check_installed = QCheckBox()
self.check_installed.setObjectName('check_installed')
self.check_installed.setCursor(QCursor(Qt.PointingHandCursor))
self.check_installed.setText(self.i18n['manage_window.checkbox.only_installed'])
self.check_installed.setChecked(False)
self.check_installed.stateChanged.connect(self._handle_filter_only_installed)
self.check_installed.sizePolicy().setRetainSizeWhenHidden(True)
self.toolbar_filters.layout().addWidget(self.check_installed)
self.comp_manager.register_component(CHECK_INSTALLED, self.check_installed)
self.check_apps = QCheckBox()
self.check_apps.setObjectName('check_apps')
self.check_apps.setCursor(QCursor(Qt.PointingHandCursor))
@@ -421,6 +432,7 @@ class ManageWindow(QWidget):
self.type_filter = self.any_type_filter
self.category_filter = self.any_category_filter
self.filter_updates = False
self.filter_installed = False
self._maximized = False
self.progress_controll_enabled = True
self.recent_uninstall = False
@@ -445,16 +457,16 @@ class ManageWindow(QWidget):
self._register_groups()
def _register_groups(self):
filters = (CHECK_APPS, CHECK_UPDATES, COMBO_CATEGORIES, COMBO_TYPES, INP_NAME)
self.comp_manager.register_group(GROUP_FILTERS, False, *filters)
common_filters = (CHECK_APPS, CHECK_UPDATES, COMBO_CATEGORIES, COMBO_TYPES, INP_NAME)
self.comp_manager.register_group(GROUP_FILTERS, False, CHECK_INSTALLED, *common_filters)
self.comp_manager.register_group(GROUP_VIEW_SEARCH, False,
COMBO_CATEGORIES, COMBO_TYPES, INP_NAME, # filters
BT_INSTALLED, BT_SUGGESTIONS) # buttons
BT_INSTALLED, BT_SUGGESTIONS, CHECK_INSTALLED) # buttons
self.comp_manager.register_group(GROUP_VIEW_INSTALLED, False,
BT_REFRESH, BT_UPGRADE, # buttons
*filters)
*common_filters)
self.comp_manager.register_group(GROUP_UPPER_BAR, False,
CHECK_APPS, CHECK_UPDATES, COMBO_CATEGORIES, COMBO_TYPES, INP_NAME,
@@ -626,6 +638,10 @@ class ManageWindow(QWidget):
self.filter_only_apps = status == 2
self.begin_apply_filters()
def _handle_filter_only_installed(self, status: int):
self.filter_installed = status == 2
self.begin_apply_filters()
def _handle_type_filter(self, idx: int):
self.type_filter = self.combo_filter_type.itemData(idx)
self.combo_filter_type.adjustSize()
@@ -906,7 +922,8 @@ class ManageWindow(QWidget):
'category': self.category_filter,
'updates': False if ignore_updates else self.filter_updates,
'name': self.input_name.text().lower() if self.input_name.text() else None,
'display_limit': None if self.filter_updates else self.display_limit
'display_limit': None if self.filter_updates else self.display_limit,
'only_installed': self.filter_installed
}
def update_pkgs(self, new_pkgs: Optional[List[SoftwarePackage]], as_installed: bool, types: Optional[Set[type]] = None, ignore_updates: bool = False, keep_filters: bool = False) -> bool:
@@ -914,6 +931,9 @@ class ManageWindow(QWidget):
pkgs_info = commons.new_pkgs_info()
filters = self._gen_filters(ignore_updates=ignore_updates)
if not keep_filters:
self._change_checkbox(self.check_installed, False, 'filter_installed', trigger=False)
if new_pkgs is not None:
old_installed = None
@@ -949,6 +969,7 @@ class ManageWindow(QWidget):
if not keep_filters:
self._change_checkbox(self.check_apps, False, 'filter_only_apps', trigger=False)
self.check_apps.setCheckable(False)
else:
if not keep_filters:
self.check_apps.setCheckable(True)
@@ -1287,6 +1308,7 @@ class ManageWindow(QWidget):
def _begin_search(self, word, action_id: int = None):
self.filter_updates = False
self.filter_installed = False
self._begin_action('{} {}'.format(self.i18n['manage_window.status.searching'], word if word else ''), action_id=action_id)
def search(self):

View File

@@ -335,6 +335,7 @@ manage_window.bt_settings.tooltip=Feu clic aquí per mostrar la configuració
manage_window.bt_themes.tip=Click here to choose a theme
manage_window.bt_themes.option.invalid=Invalid
manage_window.checkbox.only_apps=Aplicacions
manage_window.checkbox.only_installed=Instal·lats
manage_window.checkbox.show_details=Mostra detalls
manage_window.columns.installed=Installed
manage_window.columns.latest_version=Versió més recent

View File

@@ -334,6 +334,7 @@ manage_window.bt_settings.tooltip=Einstellungen anpassen
manage_window.bt_themes.tip=Click here to choose a theme
manage_window.bt_themes.option.invalid=Invalid
manage_window.checkbox.only_apps=Apps
manage_window.checkbox.only_installed=Installierten
manage_window.checkbox.show_details=Details anzeigen
manage_window.columns.installed=Installed
manage_window.columns.latest_version=Neueste Version

View File

@@ -337,6 +337,7 @@ manage_window.bt_settings.tooltip=Click here to display the settings
manage_window.bt_themes.tip=Click here to choose a theme
manage_window.bt_themes.option.invalid=Invalid
manage_window.checkbox.only_apps=Apps
manage_window.checkbox.only_installed=Installed
manage_window.checkbox.show_details=Show details
manage_window.columns.installed=Installed
manage_window.columns.latest_version=Latest Version

View File

@@ -336,6 +336,7 @@ manage_window.bt_settings.tooltip=Pulse aquí para exhibir las configuraciones
manage_window.bt_themes.tip=Pulse aquí para elegir un tema
manage_window.bt_themes.option.invalid=Inválido
manage_window.checkbox.only_apps=Aplicaciones
manage_window.checkbox.only_installed=Instalados
manage_window.checkbox.show_details=Mostrar detalles
manage_window.columns.installed=Instaladas
manage_window.columns.latest_version=Versión más reciente

View File

@@ -333,6 +333,7 @@ manage_window.bt_settings.tooltip=Cliquez ici pour afficher les paramètres
manage_window.bt_themes.tip=Click here to choose a theme
manage_window.bt_themes.option.invalid=Invalid
manage_window.checkbox.only_apps=Apps
manage_window.checkbox.only_installed=Installées
manage_window.checkbox.show_details=Détails
manage_window.columns.installed=Installé
manage_window.columns.latest_version=Dernière Version

View File

@@ -336,6 +336,7 @@ manage_window.bt_settings.tooltip=Fai clic qui per visualizzare le impostazioni
manage_window.bt_themes.tip=Click here to choose a theme
manage_window.bt_themes.option.invalid=Invalid
manage_window.checkbox.only_apps=Apps
manage_window.checkbox.only_installed=Installate
manage_window.checkbox.show_details=Mostra dettagli
manage_window.columns.installed=Installed
manage_window.columns.latest_version=Ultima Versione

View File

@@ -335,6 +335,7 @@ manage_window.bt_settings.tooltip=Clique aqui para exibir as configurações
manage_window.bt_themes.tip=Clique aqui para escolher um tema
manage_window.bt_themes.option.invalid=Inválido
manage_window.checkbox.only_apps=Aplicativos
manage_window.checkbox.only_installed=Instalados
manage_window.checkbox.show_details=Mostrar detalhes
manage_window.columns.installed=Instalado
manage_window.columns.latest_version=Última Versão

View File

@@ -334,6 +334,7 @@ manage_window.bt_settings.tooltip=Нажмите здесь, чтобы отоб
manage_window.bt_themes.tip=Click here to choose a theme
manage_window.bt_themes.option.invalid=Invalid
manage_window.checkbox.only_apps=Приложения
manage_window.checkbox.only_installed=Установленные
manage_window.checkbox.show_details=Показать детали
manage_window.columns.installed=Installed
manage_window.columns.latest_version=Последняя версия

View File

@@ -334,6 +334,7 @@ manage_window.bt_settings.tooltip=Görünüm ayarları için burayı tıkla
manage_window.bt_themes.tip=Click here to choose a theme
manage_window.bt_themes.option.invalid=Invalid
manage_window.checkbox.only_apps=Uygulamalar
manage_window.checkbox.only_installed=Yüklü
manage_window.checkbox.show_details=Detayları göster
manage_window.columns.installed=Yüklü
manage_window.columns.latest_version=Son sürüm