mirror of
https://github.com/spalencsar/bearhub.git
synced 2026-07-08 14:24:15 +02:00
[view] improvement: settings window size rules moved to stylesheet files
This commit is contained in:
@@ -852,7 +852,6 @@ class AppImageManager(SoftwareManager, SettingsController):
|
||||
|
||||
def get_settings(self) -> Optional[Generator[SettingsView, None, None]]:
|
||||
config_ = self.configman.get_config()
|
||||
max_width = 50
|
||||
|
||||
comps = [
|
||||
TextInputComponent(label=self.i18n['appimage.config.database.expiration'],
|
||||
@@ -860,14 +859,12 @@ class AppImageManager(SoftwareManager, SettingsController):
|
||||
config_['database']['expiration'], int) else '',
|
||||
tooltip=self.i18n['appimage.config.database.expiration.tip'],
|
||||
only_int=True,
|
||||
max_width=max_width,
|
||||
id_='appim_db_exp'),
|
||||
TextInputComponent(label=self.i18n['appimage.config.suggestions.expiration'],
|
||||
value=int(config_['suggestions']['expiration']) if isinstance(
|
||||
config_['suggestions']['expiration'], int) else '',
|
||||
tooltip=self.i18n['appimage.config.suggestions.expiration.tip'],
|
||||
only_int=True,
|
||||
max_width=max_width,
|
||||
id_='appim_sugs_exp')
|
||||
]
|
||||
|
||||
|
||||
@@ -2805,8 +2805,11 @@ class ArchManager(SoftwareManager, SettingsController):
|
||||
final_cmd = pkg.command.replace('%U', '')
|
||||
subprocess.Popen(final_cmd, shell=True)
|
||||
|
||||
def _gen_bool_selector(self, id_: str, label_key: str, tooltip_key: str, value: bool, max_width: int,
|
||||
capitalize_label: bool = True, label_params: Optional[list] = None, tooltip_params: Optional[list] = None) -> SingleSelectComponent:
|
||||
def _gen_bool_selector(self, id_: str, label_key: str, tooltip_key: str, value: bool,
|
||||
max_width: Optional[int] = None, capitalize_label: bool = True,
|
||||
label_params: Optional[list] = None, tooltip_params: Optional[list] = None) \
|
||||
-> SingleSelectComponent:
|
||||
|
||||
opts = [InputOption(label=self.i18n['yes'].capitalize(), value=True),
|
||||
InputOption(label=self.i18n['no'].capitalize(), value=False)]
|
||||
|
||||
@@ -2830,12 +2833,11 @@ class ArchManager(SoftwareManager, SettingsController):
|
||||
id_=id_,
|
||||
capitalize_label=capitalize_label)
|
||||
|
||||
def _get_general_settings(self, arch_config: dict, max_width: int) -> SettingsView:
|
||||
def _get_general_settings(self, arch_config: dict) -> SettingsView:
|
||||
db_sync_start = self._gen_bool_selector(id_='sync_dbs_start',
|
||||
label_key='arch.config.sync_dbs',
|
||||
tooltip_key='arch.config.sync_dbs_start.tip',
|
||||
value=bool(arch_config['sync_databases_startup']),
|
||||
max_width=max_width)
|
||||
value=bool(arch_config['sync_databases_startup']))
|
||||
|
||||
db_sync_start.label += f" ({self.i18n['initialization'].capitalize()})"
|
||||
|
||||
@@ -2843,67 +2845,55 @@ class ArchManager(SoftwareManager, SettingsController):
|
||||
self._gen_bool_selector(id_='repos',
|
||||
label_key='arch.config.repos',
|
||||
tooltip_key='arch.config.repos.tip',
|
||||
value=bool(arch_config['repositories']),
|
||||
max_width=max_width),
|
||||
value=bool(arch_config['repositories'])),
|
||||
self._gen_bool_selector(id_='autoprovs',
|
||||
label_key='arch.config.automatch_providers',
|
||||
tooltip_key='arch.config.automatch_providers.tip',
|
||||
value=bool(arch_config['automatch_providers']),
|
||||
max_width=max_width),
|
||||
value=bool(arch_config['automatch_providers'])),
|
||||
self._gen_bool_selector(id_='prefer_repo_provider',
|
||||
label_key='arch.config.prefer_repository_provider',
|
||||
tooltip_key='arch.config.prefer_repository_provider.tip',
|
||||
value=bool(arch_config['prefer_repository_provider']),
|
||||
max_width=max_width,
|
||||
tooltip_params=['AUR']),
|
||||
self._gen_bool_selector(id_='check_dependency_breakage',
|
||||
label_key='arch.config.check_dependency_breakage',
|
||||
tooltip_key='arch.config.check_dependency_breakage.tip',
|
||||
value=bool(arch_config['check_dependency_breakage']),
|
||||
max_width=max_width),
|
||||
value=bool(arch_config['check_dependency_breakage'])),
|
||||
self._gen_bool_selector(id_='mthread_download',
|
||||
label_key='arch.config.pacman_mthread_download',
|
||||
tooltip_key='arch.config.pacman_mthread_download.tip',
|
||||
value=arch_config['repositories_mthread_download'],
|
||||
max_width=max_width,
|
||||
capitalize_label=True),
|
||||
self._gen_bool_selector(id_='sync_dbs',
|
||||
label_key='arch.config.sync_dbs',
|
||||
tooltip_key='arch.config.sync_dbs.tip',
|
||||
value=bool(arch_config['sync_databases']),
|
||||
max_width=max_width),
|
||||
value=bool(arch_config['sync_databases'])),
|
||||
db_sync_start,
|
||||
self._gen_bool_selector(id_='clean_cached',
|
||||
label_key='arch.config.clean_cache',
|
||||
tooltip_key='arch.config.clean_cache.tip',
|
||||
value=bool(arch_config['clean_cached']),
|
||||
max_width=max_width),
|
||||
value=bool(arch_config['clean_cached'])),
|
||||
self._gen_bool_selector(id_='suggest_unneeded_uninstall',
|
||||
label_key='arch.config.suggest_unneeded_uninstall',
|
||||
tooltip_params=['"{}"'.format(self.i18n['arch.config.suggest_optdep_uninstall'])],
|
||||
tooltip_key='arch.config.suggest_unneeded_uninstall.tip',
|
||||
value=bool(arch_config['suggest_unneeded_uninstall']),
|
||||
max_width=max_width),
|
||||
value=bool(arch_config['suggest_unneeded_uninstall'])),
|
||||
self._gen_bool_selector(id_='suggest_optdep_uninstall',
|
||||
label_key='arch.config.suggest_optdep_uninstall',
|
||||
tooltip_key='arch.config.suggest_optdep_uninstall.tip',
|
||||
value=bool(arch_config['suggest_optdep_uninstall']),
|
||||
max_width=max_width),
|
||||
value=bool(arch_config['suggest_optdep_uninstall'])),
|
||||
self._gen_bool_selector(id_='ref_mirs',
|
||||
label_key='arch.config.refresh_mirrors',
|
||||
tooltip_key='arch.config.refresh_mirrors.tip',
|
||||
value=bool(arch_config['refresh_mirrors_startup']),
|
||||
max_width=max_width),
|
||||
value=bool(arch_config['refresh_mirrors_startup'])),
|
||||
TextInputComponent(id_='mirrors_sort_limit',
|
||||
label=self.i18n['arch.config.mirrors_sort_limit'],
|
||||
tooltip=self.i18n['arch.config.mirrors_sort_limit.tip'],
|
||||
only_int=True,
|
||||
max_width=50,
|
||||
value=arch_config['mirrors_sort_limit'] if isinstance(arch_config['mirrors_sort_limit'], int) else ''),
|
||||
TextInputComponent(id_='arch_cats_exp',
|
||||
label=self.i18n['arch.config.categories_exp'],
|
||||
tooltip=self.i18n['arch.config.categories_exp.tip'],
|
||||
max_width=50,
|
||||
only_int=True,
|
||||
capitalize_label=False,
|
||||
value=arch_config['categories_exp'] if isinstance(arch_config['categories_exp'], int) else ''),
|
||||
@@ -2911,27 +2901,24 @@ class ArchManager(SoftwareManager, SettingsController):
|
||||
|
||||
return SettingsView(self, PanelComponent([FormComponent(fields, spaces=False)], id_="repo"), icon_path=get_repo_icon_path())
|
||||
|
||||
def _get_aur_settings(self, arch_config: dict, max_width: int) -> SettingsView:
|
||||
def _get_aur_settings(self, arch_config: dict) -> SettingsView:
|
||||
fields = [
|
||||
self._gen_bool_selector(id_='aur',
|
||||
label_key='arch.config.aur',
|
||||
tooltip_key='arch.config.aur.tip',
|
||||
value=arch_config['aur'],
|
||||
max_width=max_width,
|
||||
capitalize_label=False),
|
||||
self._gen_bool_selector(id_='opts',
|
||||
label_key='arch.config.optimize',
|
||||
tooltip_key='arch.config.optimize.tip',
|
||||
value=bool(arch_config['optimize']),
|
||||
capitalize_label=False,
|
||||
max_width=max_width),
|
||||
capitalize_label=False),
|
||||
self._gen_bool_selector(id_='rebuild_detector',
|
||||
label_key='arch.config.aur_rebuild_detector',
|
||||
tooltip_key='arch.config.aur_rebuild_detector.tip',
|
||||
value=bool(arch_config['aur_rebuild_detector']),
|
||||
tooltip_params=["'rebuild-detector'"],
|
||||
capitalize_label=False,
|
||||
max_width=max_width),
|
||||
capitalize_label=False),
|
||||
self._gen_bool_selector(id_='rebuild_detector_no_bin',
|
||||
label_key='arch.config.aur_rebuild_detector_no_bin',
|
||||
label_params=['rebuild-detector'],
|
||||
@@ -2939,8 +2926,7 @@ class ArchManager(SoftwareManager, SettingsController):
|
||||
tooltip_params=['rebuild-detector',
|
||||
self.i18n['arch.config.aur_rebuild_detector'].format('')],
|
||||
value=bool(arch_config['aur_rebuild_detector_no_bin']),
|
||||
capitalize_label=False,
|
||||
max_width=max_width),
|
||||
capitalize_label=False),
|
||||
new_select(id_='aur_build_only_chosen',
|
||||
label=self.i18n['arch.config.aur_build_only_chosen'],
|
||||
tip=self.i18n['arch.config.aur_build_only_chosen.tip'],
|
||||
@@ -2949,7 +2935,6 @@ class ArchManager(SoftwareManager, SettingsController):
|
||||
(self.i18n['ask'].capitalize(), None, None),
|
||||
],
|
||||
value=arch_config['aur_build_only_chosen'],
|
||||
max_width=max_width,
|
||||
type_=SelectViewType.RADIO,
|
||||
capitalize_label=False),
|
||||
new_select(label=self.i18n['arch.config.edit_aur_pkgbuild'],
|
||||
@@ -2960,27 +2945,23 @@ class ArchManager(SoftwareManager, SettingsController):
|
||||
(self.i18n['ask'].capitalize(), None, None),
|
||||
],
|
||||
value=arch_config['edit_aur_pkgbuild'],
|
||||
max_width=max_width,
|
||||
type_=SelectViewType.RADIO,
|
||||
capitalize_label=False),
|
||||
self._gen_bool_selector(id_='aur_remove_build_dir',
|
||||
label_key='arch.config.aur_remove_build_dir',
|
||||
tooltip_key='arch.config.aur_remove_build_dir.tip',
|
||||
value=bool(arch_config['aur_remove_build_dir']),
|
||||
max_width=max_width,
|
||||
capitalize_label=False),
|
||||
FileChooserComponent(id_='aur_build_dir',
|
||||
label=self.i18n['arch.config.aur_build_dir'],
|
||||
tooltip=self.i18n['arch.config.aur_build_dir.tip'].format(
|
||||
get_build_dir(arch_config, self.pkgbuilder_user)),
|
||||
max_width=round(max_width * 0.65),
|
||||
file_path=arch_config['aur_build_dir'],
|
||||
capitalize_label=False,
|
||||
directory=True),
|
||||
TextInputComponent(id_='aur_idx_exp',
|
||||
label=self.i18n['arch.config.aur_idx_exp'],
|
||||
tooltip=self.i18n['arch.config.aur_idx_exp.tip'],
|
||||
max_width=50,
|
||||
only_int=True,
|
||||
capitalize_label=False,
|
||||
value=arch_config['aur_idx_exp'] if isinstance(arch_config['aur_idx_exp'], int) else '')
|
||||
@@ -2992,9 +2973,8 @@ class ArchManager(SoftwareManager, SettingsController):
|
||||
|
||||
def get_settings(self) -> Optional[Generator[SettingsView, None, None]]:
|
||||
arch_config = self.configman.get_config()
|
||||
max_width = floor(self.context.screen_width * 0.25)
|
||||
yield self._get_general_settings(arch_config, max_width)
|
||||
yield self._get_aur_settings(arch_config, max_width)
|
||||
yield self._get_general_settings(arch_config)
|
||||
yield self._get_aur_settings(arch_config)
|
||||
|
||||
@staticmethod
|
||||
def fill_general_settings(arch_config: dict, form: FormComponent):
|
||||
|
||||
@@ -16,7 +16,7 @@ from bauh.api.abstract.handler import TaskManager, ProcessWatcher
|
||||
from bauh.api.abstract.model import SoftwarePackage, PackageSuggestion, PackageUpdate, PackageHistory, \
|
||||
CustomSoftwareAction
|
||||
from bauh.api.abstract.view import TextInputComponent, PanelComponent, FormComponent, MessageType, \
|
||||
SingleSelectComponent, InputOption, SelectViewType
|
||||
SingleSelectComponent, InputOption, SelectViewType, ViewComponentAlignment
|
||||
from bauh.api.paths import CONFIG_DIR
|
||||
from bauh.commons.html import bold
|
||||
from bauh.commons.system import ProcessHandler
|
||||
@@ -603,7 +603,6 @@ class DebianPackageManager(SoftwareManager, SettingsController):
|
||||
options=purge_opts,
|
||||
default_option=purge_current,
|
||||
type_=SelectViewType.RADIO,
|
||||
max_width=200,
|
||||
max_per_line=2)
|
||||
|
||||
sources_app = config_.get('pkg_sources.app')
|
||||
@@ -623,8 +622,8 @@ class DebianPackageManager(SoftwareManager, SettingsController):
|
||||
tooltip=source_auto_tip,
|
||||
options=source_opts,
|
||||
default_option=next(o for o in source_opts if o.value == sources_app),
|
||||
type_=SelectViewType.COMBO,
|
||||
max_width=200)
|
||||
alignment=ViewComponentAlignment.CENTER,
|
||||
type_=SelectViewType.COMBO)
|
||||
|
||||
try:
|
||||
app_cache_exp = int(config_.get('index_apps.exp', 0))
|
||||
@@ -636,8 +635,7 @@ class DebianPackageManager(SoftwareManager, SettingsController):
|
||||
ti_index_apps_exp = TextInputComponent(id_='index_apps.exp',
|
||||
label=self._i18n['debian.config.index_apps.exp'],
|
||||
tooltip=self._i18n['debian.config.index_apps.exp.tip'],
|
||||
value=str(app_cache_exp), only_int=True,
|
||||
max_width=60)
|
||||
value=str(app_cache_exp), only_int=True)
|
||||
|
||||
try:
|
||||
sync_pkgs_time = int(config_.get('sync_pkgs.time', 0))
|
||||
@@ -649,8 +647,7 @@ class DebianPackageManager(SoftwareManager, SettingsController):
|
||||
ti_sync_pkgs = TextInputComponent(id_='sync_pkgs.time',
|
||||
label=self._i18n['debian.config.sync_pkgs.time'],
|
||||
tooltip=self._i18n['debian.config.sync_pkgs.time.tip'],
|
||||
value=str(sync_pkgs_time), only_int=True,
|
||||
max_width=60)
|
||||
value=str(sync_pkgs_time), only_int=True)
|
||||
|
||||
try:
|
||||
suggestions_exp = int(config_.get('suggestions.exp', 0))
|
||||
@@ -662,8 +659,7 @@ class DebianPackageManager(SoftwareManager, SettingsController):
|
||||
ti_suggestions_exp = TextInputComponent(id_='suggestions.exp',
|
||||
label=self._i18n['debian.config.suggestions.exp'],
|
||||
tooltip=self._i18n['debian.config.suggestions.exp.tip'],
|
||||
value=str(suggestions_exp), only_int=True,
|
||||
max_width=60)
|
||||
value=str(suggestions_exp), only_int=True)
|
||||
|
||||
panel = PanelComponent([FormComponent([input_sources, sel_purge, ti_sync_pkgs, ti_index_apps_exp,
|
||||
ti_suggestions_exp])])
|
||||
|
||||
@@ -18,7 +18,7 @@ from bauh.api.abstract.handler import ProcessWatcher, TaskManager
|
||||
from bauh.api.abstract.model import PackageHistory, PackageUpdate, SoftwarePackage, PackageSuggestion, \
|
||||
SuggestionPriority, PackageStatus, CustomSoftwareAction
|
||||
from bauh.api.abstract.view import MessageType, FormComponent, SingleSelectComponent, InputOption, SelectViewType, \
|
||||
PanelComponent
|
||||
PanelComponent, ViewComponentAlignment
|
||||
from bauh.commons.boot import CreateConfigFile
|
||||
from bauh.commons.html import strip_html, bold
|
||||
from bauh.commons.system import ProcessHandler
|
||||
@@ -668,8 +668,8 @@ class FlatpakManager(SoftwareManager, SettingsController):
|
||||
options=install_opts,
|
||||
default_option=[o for o in install_opts if o.value == flatpak_config['installation_level']][0],
|
||||
max_per_line=len(install_opts),
|
||||
max_width=160,
|
||||
type_=SelectViewType.COMBO,
|
||||
alignment=ViewComponentAlignment.CENTER,
|
||||
id_='install'))
|
||||
|
||||
yield SettingsView(self, PanelComponent([FormComponent(fields, self.i18n['installation'].capitalize())]))
|
||||
|
||||
@@ -435,13 +435,11 @@ class SnapManager(SoftwareManager, SettingsController):
|
||||
(self.i18n['no'].capitalize(), False, None)],
|
||||
value=bool(snap_config['install_channel']),
|
||||
id_='snap_install_channel',
|
||||
max_width=200,
|
||||
tip=self.i18n['snap.config.install_channel.tip'])
|
||||
|
||||
cat_exp_val = snap_config['categories_exp'] if isinstance(snap_config['categories_exp'], int) else ''
|
||||
categories_exp = TextInputComponent(id_='snap_cat_exp',
|
||||
value=cat_exp_val,
|
||||
max_width=60,
|
||||
only_int=True,
|
||||
label=self.i18n['snap.config.categories_exp'],
|
||||
tooltip=self.i18n['snap.config.categories_exp.tip'])
|
||||
|
||||
@@ -25,7 +25,7 @@ from bauh.api.abstract.model import SoftwarePackage, CustomSoftwareAction, Packa
|
||||
PackageHistory, \
|
||||
SuggestionPriority, PackageStatus
|
||||
from bauh.api.abstract.view import MessageType, MultipleSelectComponent, InputOption, SingleSelectComponent, \
|
||||
SelectViewType, TextInputComponent, FormComponent, FileChooserComponent, PanelComponent
|
||||
SelectViewType, TextInputComponent, FormComponent, FileChooserComponent, PanelComponent, ViewComponentAlignment
|
||||
from bauh.api.paths import DESKTOP_ENTRIES_DIR
|
||||
from bauh.commons import resource
|
||||
from bauh.commons.boot import CreateConfigFile
|
||||
@@ -1137,7 +1137,6 @@ class WebApplicationManager(SoftwareManager, SettingsController):
|
||||
value=web_config['environment']['electron']['version'],
|
||||
tooltip=self.i18n['web.settings.electron.version.tooltip'],
|
||||
placeholder='{}: 7.1.0'.format(self.i18n['example.short']),
|
||||
max_width=150,
|
||||
id_='electron_branch')
|
||||
|
||||
native_opts = [
|
||||
@@ -1150,7 +1149,7 @@ class WebApplicationManager(SoftwareManager, SettingsController):
|
||||
default_option=[o for o in native_opts if o.value == web_config['environment']['system']][0],
|
||||
type_=SelectViewType.COMBO,
|
||||
tooltip=self.i18n['web.settings.nativefier.tip'],
|
||||
max_width=150,
|
||||
alignment=ViewComponentAlignment.CENTER,
|
||||
id_='nativefier')
|
||||
|
||||
env_settings_exp = TextInputComponent(label=self.i18n['web.settings.cache_exp'],
|
||||
@@ -1158,7 +1157,6 @@ class WebApplicationManager(SoftwareManager, SettingsController):
|
||||
capitalize_label=False,
|
||||
value=int(web_config['environment']['cache_exp']) if isinstance(web_config['environment']['cache_exp'], int) else '',
|
||||
only_int=True,
|
||||
max_width=60,
|
||||
id_='web_cache_exp')
|
||||
|
||||
sugs_exp = TextInputComponent(label=self.i18n['web.settings.suggestions.cache_exp'],
|
||||
@@ -1167,7 +1165,6 @@ class WebApplicationManager(SoftwareManager, SettingsController):
|
||||
value=int(web_config['suggestions']['cache_exp']) if isinstance(
|
||||
web_config['suggestions']['cache_exp'], int) else '',
|
||||
only_int=True,
|
||||
max_width=60,
|
||||
id_='web_sugs_exp')
|
||||
|
||||
form_env = FormComponent(label=self.i18n['web.settings.nativefier.env'].capitalize(),
|
||||
|
||||
Reference in New Issue
Block a user