mirror of
https://github.com/spalencsar/bearhub.git
synced 2026-07-07 01:14:15 +02:00
display limit
This commit is contained in:
@@ -54,6 +54,7 @@ You can change some application settings via environment variables or arguments
|
|||||||
- **BAUH_CHECK_PACKAGING_ONCE**: If the available supported packaging types should be checked ONLY once. It improves the application speed if enabled, but can generate errors if you uninstall any packaging technology while using it, and every time a supported packaging type is installed it will only be available after a restart. Use **0** (disable, default) or **1** (enable).
|
- **BAUH_CHECK_PACKAGING_ONCE**: If the available supported packaging types should be checked ONLY once. It improves the application speed if enabled, but can generate errors if you uninstall any packaging technology while using it, and every time a supported packaging type is installed it will only be available after a restart. Use **0** (disable, default) or **1** (enable).
|
||||||
- **BAUH_TRAY**: If the tray icon and update-check daemon should be created. Use **0** (disable, default) or **1** (enable).
|
- **BAUH_TRAY**: If the tray icon and update-check daemon should be created. Use **0** (disable, default) or **1** (enable).
|
||||||
- **BAUH_SUGGESTIONS**: If application suggestions should be displayed if no app is installed (runtimes do not count as apps). Use **0** (disable) or **1** (enable, default).
|
- **BAUH_SUGGESTIONS**: If application suggestions should be displayed if no app is installed (runtimes do not count as apps). Use **0** (disable) or **1** (enable, default).
|
||||||
|
- **BAUH_MAX_DISPLAYED**: Maximum number of displayed packages in the management panel table. Default: 200.
|
||||||
|
|
||||||
### How to improve the application performance
|
### How to improve the application performance
|
||||||
- If you don't care about a specific packaging technology and don't want the app to deal with it, just disable it via the specific argument or environment variable. For instance, if I don't care
|
- If you don't care about a specific packaging technology and don't want the app to deal with it, just disable it via the specific argument or environment variable. For instance, if I don't care
|
||||||
|
|||||||
@@ -47,7 +47,8 @@ manage_window = ManageWindow(locale_keys=i18n,
|
|||||||
disk_cache=args.disk_cache,
|
disk_cache=args.disk_cache,
|
||||||
download_icons=bool(args.download_icons),
|
download_icons=bool(args.download_icons),
|
||||||
screen_size=app.primaryScreen().size(),
|
screen_size=app.primaryScreen().size(),
|
||||||
suggestions=args.sugs)
|
suggestions=args.sugs,
|
||||||
|
display_limit=args.max_displayed)
|
||||||
|
|
||||||
if args.tray:
|
if args.tray:
|
||||||
trayIcon = TrayIcon(locale_keys=i18n,
|
trayIcon = TrayIcon(locale_keys=i18n,
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ def read() -> Namespace:
|
|||||||
parser.add_argument('--tray', action="store", default=os.getenv('BAUH_TRAY', 0), choices=[0, 1], type=int,
|
parser.add_argument('--tray', action="store", default=os.getenv('BAUH_TRAY', 0), choices=[0, 1], type=int,
|
||||||
help='If the tray icon and update-check daemon should be created. Default: %(default)s')
|
help='If the tray icon and update-check daemon should be created. Default: %(default)s')
|
||||||
parser.add_argument('--sugs', action="store", default=os.getenv('BAUH_SUGGESTIONS', 1), choices=[0, 1], type=int, help='If app suggestions should be displayed if no application package is installed (runtimes / libraries do not count as apps). Default: %(default)s')
|
parser.add_argument('--sugs', action="store", default=os.getenv('BAUH_SUGGESTIONS', 1), choices=[0, 1], type=int, help='If app suggestions should be displayed if no application package is installed (runtimes / libraries do not count as apps). Default: %(default)s')
|
||||||
|
parser.add_argument('-md', '--max-displayed', action="store", default=os.getenv('BAUH_MAX_DISPLAYED', 200), choices=[0, 1], type=int, help='Maximum number of displayed packages in the management panel table. Default: %(default)s')
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
if args.cache_exp < 0:
|
if args.cache_exp < 0:
|
||||||
|
|||||||
@@ -117,6 +117,7 @@ class RefreshApps(AsyncAction):
|
|||||||
if app_found:
|
if app_found:
|
||||||
del res.installed[idx_found]
|
del res.installed[idx_found]
|
||||||
res.installed.insert(0, app_found)
|
res.installed.insert(0, app_found)
|
||||||
|
|
||||||
elif self.pkg_types:
|
elif self.pkg_types:
|
||||||
refreshed_types = self.pkg_types
|
refreshed_types = self.pkg_types
|
||||||
|
|
||||||
|
|||||||
@@ -38,15 +38,16 @@ class ManageWindow(QWidget):
|
|||||||
def _toolbar_button_style(self, bg: str):
|
def _toolbar_button_style(self, bg: str):
|
||||||
return 'QPushButton { color: white; font-weight: bold; background: ' + bg + '}'
|
return 'QPushButton { color: white; font-weight: bold; background: ' + bg + '}'
|
||||||
|
|
||||||
def __init__(self, locale_keys: dict, icon_cache: MemoryCache, manager: SoftwareManager, disk_cache: bool, download_icons: bool, screen_size, suggestions: bool, tray_icon=None):
|
def __init__(self, locale_keys: dict, icon_cache: MemoryCache, manager: SoftwareManager, disk_cache: bool, download_icons: bool, screen_size, suggestions: bool, display_limit: int, tray_icon=None):
|
||||||
super(ManageWindow, self).__init__()
|
super(ManageWindow, self).__init__()
|
||||||
self.locale_keys = locale_keys
|
self.locale_keys = locale_keys
|
||||||
self.manager = manager
|
self.manager = manager
|
||||||
self.tray_icon = tray_icon
|
self.tray_icon = tray_icon
|
||||||
self.working = False # restrict the number of threaded actions
|
self.working = False # restrict the number of threaded actions
|
||||||
self.pkgs = []
|
self.pkgs = [] # packages current loaded in the table
|
||||||
self.pkgs_installed = []
|
self.pkgs_available = [] # all packages loaded in memory
|
||||||
self.label_flatpak = None
|
self.pkgs_installed = [] # cached installed packages
|
||||||
|
self.display_limit = display_limit
|
||||||
self.icon_cache = icon_cache
|
self.icon_cache = icon_cache
|
||||||
self.disk_cache = disk_cache
|
self.disk_cache = disk_cache
|
||||||
self.download_icons = download_icons
|
self.download_icons = download_icons
|
||||||
@@ -442,10 +443,11 @@ class ManageWindow(QWidget):
|
|||||||
elif not self.toolbar_substatus.isVisible():
|
elif not self.toolbar_substatus.isVisible():
|
||||||
self.toolbar_substatus.show()
|
self.toolbar_substatus.show()
|
||||||
|
|
||||||
def apply_filters(self):
|
def apply_filters(self, update_check_enabled: bool = True):
|
||||||
if self.pkgs:
|
if self.pkgs_available:
|
||||||
visible_apps = len(self.pkgs)
|
pkgs_displayed = []
|
||||||
for idx, app_v in enumerate(self.pkgs):
|
displayed = 0
|
||||||
|
for idx, app_v in enumerate(self.pkgs_available):
|
||||||
hidden = self.filter_only_apps and not app_v.model.is_application()
|
hidden = self.filter_only_apps and not app_v.model.is_application()
|
||||||
|
|
||||||
if not hidden and self.type_filter is not None and self.type_filter != 'any':
|
if not hidden and self.type_filter is not None and self.type_filter != 'any':
|
||||||
@@ -454,18 +456,24 @@ class ManageWindow(QWidget):
|
|||||||
if not hidden and self.filter_updates:
|
if not hidden and self.filter_updates:
|
||||||
hidden = not app_v.model.update
|
hidden = not app_v.model.update
|
||||||
|
|
||||||
self.table_apps.setRowHidden(idx, hidden)
|
# self.table_apps.setRowHidden(idx, hidden)
|
||||||
app_v.visible = not hidden
|
app_v.visible = not hidden
|
||||||
visible_apps -= 1 if hidden else 0
|
|
||||||
|
if not hidden and displayed < self.display_limit:
|
||||||
|
pkgs_displayed.append(app_v)
|
||||||
|
displayed += 1
|
||||||
|
|
||||||
|
self.pkgs = pkgs_displayed
|
||||||
|
self.table_apps.update_apps(pkgs_displayed, update_check_enabled=update_check_enabled)
|
||||||
|
|
||||||
self.change_update_state(change_filters=False)
|
self.change_update_state(change_filters=False)
|
||||||
|
|
||||||
if not self._maximized:
|
if not self._maximized:
|
||||||
self.table_apps.change_headers_policy(QHeaderView.Stretch)
|
self.table_apps.change_headers_policy(QHeaderView.Stretch)
|
||||||
self.table_apps.change_headers_policy()
|
self.table_apps.change_headers_policy()
|
||||||
self.resize_and_center(accept_lower_width=visible_apps > 0)
|
self.resize_and_center(accept_lower_width=displayed > 0)
|
||||||
|
|
||||||
self.label_displayed.setText('{} / {}'.format(visible_apps, len(self.pkgs)))
|
self.label_displayed.setText('{} / {}'.format(displayed, len(self.pkgs_available)))
|
||||||
else:
|
else:
|
||||||
self.label_displayed.setText('')
|
self.label_displayed.setText('')
|
||||||
|
|
||||||
@@ -529,10 +537,13 @@ class ManageWindow(QWidget):
|
|||||||
def update_pkgs(self, new_pkgs: List[SoftwarePackage], as_installed: bool, update_check_enabled: bool = True, types: Set[type] = None):
|
def update_pkgs(self, new_pkgs: List[SoftwarePackage], as_installed: bool, update_check_enabled: bool = True, types: Set[type] = None):
|
||||||
|
|
||||||
pkgs_info = {'napps': 0, # number of apps (not libraries, runtimes or something else)
|
pkgs_info = {'napps': 0, # number of apps (not libraries, runtimes or something else)
|
||||||
'available_types': {}}
|
'available_types': {}, # available package types in 'new_pkgs'
|
||||||
|
'total': 0} # total packages
|
||||||
|
|
||||||
|
self.pkgs = []
|
||||||
|
self.pkgs_available = []
|
||||||
|
|
||||||
if new_pkgs is not None:
|
if new_pkgs is not None:
|
||||||
self.pkgs = []
|
|
||||||
old_installed = None
|
old_installed = None
|
||||||
|
|
||||||
if as_installed:
|
if as_installed:
|
||||||
@@ -542,25 +553,40 @@ class ManageWindow(QWidget):
|
|||||||
for pkg in new_pkgs:
|
for pkg in new_pkgs:
|
||||||
app_model = PackageView(model=pkg, visible=pkg.is_application() or not self.checkbox_only_apps.isChecked())
|
app_model = PackageView(model=pkg, visible=pkg.is_application() or not self.checkbox_only_apps.isChecked())
|
||||||
self._update_pkgs_info(app_model, pkgs_info)
|
self._update_pkgs_info(app_model, pkgs_info)
|
||||||
self.pkgs.append(app_model)
|
|
||||||
|
|
||||||
if as_installed:
|
self.pkgs_available.append(app_model)
|
||||||
self.pkgs_installed.append(app_model)
|
|
||||||
|
if pkgs_info['total'] < self.display_limit:
|
||||||
|
self.pkgs.append(app_model)
|
||||||
|
|
||||||
|
pkgs_info['total'] += 1
|
||||||
|
|
||||||
if old_installed and types:
|
if old_installed and types:
|
||||||
for pkgv in old_installed:
|
for pkgv in old_installed:
|
||||||
if not pkgv.model.__class__ in types:
|
if not pkgv.model.__class__ in types:
|
||||||
self._update_pkgs_info(pkgv, pkgs_info)
|
self._update_pkgs_info(pkgv, pkgs_info)
|
||||||
self.pkgs.append(pkgv)
|
|
||||||
|
|
||||||
if as_installed:
|
self.pkgs_available.append(pkgv)
|
||||||
self.pkgs_installed.append(pkgv)
|
|
||||||
|
if pkgs_info['total'] < self.display_limit:
|
||||||
|
self.pkgs.append(pkgv)
|
||||||
|
|
||||||
|
pkgs_info['total'] += 1
|
||||||
|
|
||||||
|
if as_installed:
|
||||||
|
self.pkgs_installed = self.pkgs_available
|
||||||
|
|
||||||
else: # use installed
|
else: # use installed
|
||||||
self.pkgs = self.pkgs_installed
|
for pkgv in self.pkgs_installed:
|
||||||
for pkgv in self.pkgs:
|
|
||||||
self._update_pkgs_info(pkgv, pkgs_info)
|
self._update_pkgs_info(pkgv, pkgs_info)
|
||||||
|
|
||||||
|
self.pkgs_available.append(pkgv)
|
||||||
|
|
||||||
|
if pkgs_info['total'] < self.display_limit:
|
||||||
|
self.pkgs.append(pkgv)
|
||||||
|
|
||||||
|
pkgs_info['total'] += 1
|
||||||
|
|
||||||
if pkgs_info['napps'] == 0:
|
if pkgs_info['napps'] == 0:
|
||||||
if self.first_refresh:
|
if self.first_refresh:
|
||||||
self._begin_search('')
|
self._begin_search('')
|
||||||
@@ -574,8 +600,7 @@ class ManageWindow(QWidget):
|
|||||||
self.checkbox_only_apps.setChecked(True)
|
self.checkbox_only_apps.setChecked(True)
|
||||||
|
|
||||||
self._update_type_filters(pkgs_info['available_types'])
|
self._update_type_filters(pkgs_info['available_types'])
|
||||||
self.table_apps.update_apps(self.pkgs, update_check_enabled=update_check_enabled)
|
self.apply_filters(update_check_enabled=update_check_enabled)
|
||||||
self.apply_filters()
|
|
||||||
self.change_update_state()
|
self.change_update_state()
|
||||||
self.resize_and_center()
|
self.resize_and_center()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user