mirror of
https://github.com/spalencsar/bearhub.git
synced 2026-07-09 00:34:16 +02:00
[ui][settings] more general settings and improvements
This commit is contained in:
@@ -407,7 +407,7 @@ class GenericSoftwareManager(SoftwareManager):
|
||||
return [m for m in self.managers if self._can_work(m)]
|
||||
|
||||
def _gen_settings_panel(self) -> TabComponent:
|
||||
# core_config = read_config()
|
||||
core_config = read_config()
|
||||
|
||||
current_locale = self.i18n.current_key
|
||||
locale_opts = [InputOption(label=self.i18n['locale.{}'.format(k)].capitalize(), value=k) for k in translation.get_available_keys()]
|
||||
@@ -417,7 +417,20 @@ class GenericSoftwareManager(SoftwareManager):
|
||||
type_=SelectViewType.COMBO,
|
||||
id_='locale')
|
||||
|
||||
return TabComponent(self.i18n['core.config.tab_label'].capitalize(), PanelComponent([FormComponent([select_locale])]), None, 'core')
|
||||
disk_cache = core_config['disk_cache']['enabled']
|
||||
dcache_opts = [InputOption(label=self.i18n['yes'].capitalize(), value=True),
|
||||
InputOption(label=self.i18n['no'].capitalize(), value=False)]
|
||||
|
||||
select_dcache = SingleSelectComponent(label=self.i18n['core.config.disk_cache'],
|
||||
options=dcache_opts,
|
||||
default_option=[o for o in dcache_opts if o.value == disk_cache][0],
|
||||
type_=SelectViewType.RADIO,
|
||||
tooltip=self.i18n['core.config.disk_cache.tip'].format(app=self.context.app_name),
|
||||
max_per_line=len(dcache_opts),
|
||||
id_='dcache')
|
||||
|
||||
sub_comps = [select_locale, select_dcache]
|
||||
return TabComponent(self.i18n['core.config.tab_label'].capitalize(), PanelComponent([FormComponent(sub_comps)]), None, 'core')
|
||||
|
||||
def _save_settings(self, panel: PanelComponent) -> Tuple[bool, List[str]]:
|
||||
core_config = config.read_config()
|
||||
@@ -428,6 +441,8 @@ class GenericSoftwareManager(SoftwareManager):
|
||||
if locale != self.i18n.current_key:
|
||||
core_config['locale'] = locale
|
||||
|
||||
core_config['disk_cache']['enabled'] = main_form.get_component('dcache').get_selected()
|
||||
|
||||
try:
|
||||
config.save(core_config)
|
||||
return True, None
|
||||
@@ -435,7 +450,7 @@ class GenericSoftwareManager(SoftwareManager):
|
||||
return False, [traceback.format_exc()]
|
||||
|
||||
def get_settings(self) -> ViewComponent:
|
||||
tabs = []
|
||||
tabs = list()
|
||||
|
||||
tabs.append(self._gen_settings_panel())
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
from pathlib import Path
|
||||
from typing import Tuple
|
||||
|
||||
from PyQt5.QtCore import Qt
|
||||
from PyQt5.QtCore import Qt, QSize
|
||||
from PyQt5.QtGui import QIcon, QPixmap, QIntValidator
|
||||
from PyQt5.QtWidgets import QRadioButton, QGroupBox, QCheckBox, QComboBox, QGridLayout, QWidget, \
|
||||
QLabel, QSizePolicy, QLineEdit, QToolButton, QHBoxLayout, QFormLayout, QFileDialog, QTabWidget, QVBoxLayout
|
||||
@@ -337,7 +337,19 @@ class FormQt(QGroupBox):
|
||||
label, field = self._new_text_input(c)
|
||||
self.layout().addRow(label, field)
|
||||
elif isinstance(c, SingleSelectComponent):
|
||||
label = QLabel(c.label.capitalize() if c.label else '')
|
||||
|
||||
label = QWidget()
|
||||
label.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum)
|
||||
label.setLayout(QHBoxLayout())
|
||||
label_comp = QLabel()
|
||||
label.layout().addWidget(label_comp)
|
||||
|
||||
if c.label:
|
||||
label_comp.setText(c.label.capitalize())
|
||||
|
||||
if c.tooltip:
|
||||
label.layout().addWidget(self.gen_tip_icon(c.tooltip))
|
||||
|
||||
field = ComboBoxQt(c) if c.type == SelectViewType.COMBO else RadioBoxQt(c)
|
||||
self.layout().addRow(label, field)
|
||||
elif isinstance(c, FileChooserComponent):
|
||||
@@ -350,6 +362,12 @@ class FormQt(QGroupBox):
|
||||
|
||||
self.layout().addRow(QLabel(), QLabel())
|
||||
|
||||
def gen_tip_icon(self, tip: str) -> QLabel:
|
||||
tip_icon = QLabel()
|
||||
tip_icon.setToolTip(tip.strip())
|
||||
tip_icon.setPixmap(QIcon(resource.get_path('img/about.svg')).pixmap(QSize(12, 12)))
|
||||
return tip_icon
|
||||
|
||||
def _new_text_input(self, c: TextInputComponent) -> Tuple[QLabel, QLineEdit]:
|
||||
line_edit = QLineEdit()
|
||||
|
||||
@@ -373,7 +391,21 @@ class FormQt(QGroupBox):
|
||||
c.value = text
|
||||
|
||||
line_edit.textChanged.connect(update_model)
|
||||
return QLabel(c.label.capitalize() if c.label else ''), line_edit
|
||||
|
||||
label = QWidget()
|
||||
label.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum)
|
||||
label.setLayout(QHBoxLayout())
|
||||
|
||||
label_component = QLabel()
|
||||
label.layout().addWidget(label_component)
|
||||
|
||||
if label:
|
||||
label_component.setText(c.label.capitalize())
|
||||
|
||||
if c.tooltip:
|
||||
label.layout().addWidget(self.gen_tip_icon(c.tooltip))
|
||||
|
||||
return label, line_edit
|
||||
|
||||
def _new_file_chooser(self, c: FileChooserComponent) -> Tuple[QLabel, QLineEdit]:
|
||||
chooser = QLineEdit()
|
||||
|
||||
@@ -223,6 +223,7 @@ user=usuari
|
||||
example.short=ex
|
||||
core.config.tab_label=general
|
||||
core.config.locale.label=idioma
|
||||
core.config.disk_cache=Cau em disco
|
||||
locale.en=anglès
|
||||
locale.es=castellà
|
||||
locale.pt=portuguès
|
||||
|
||||
@@ -178,6 +178,8 @@ user=Benutzer
|
||||
example.short=z.B
|
||||
core.config.tab_label=Allgemeines
|
||||
core.config.locale.label=Sprache
|
||||
core.config.disk_cache=Festplattencache
|
||||
core.config.disk_cache.tip={app} speichert einige Daten zu Ihren installierten Anwendungen auf der Festplatte, um sie bei den nächsten Initialisierungen schneller zu laden
|
||||
locale.en=englisch
|
||||
locale.es=spanisch
|
||||
locale.pt=portugiesisch
|
||||
|
||||
@@ -182,6 +182,8 @@ user=user
|
||||
example.short=e.g
|
||||
core.config.tab_label=general
|
||||
core.config.locale.label=language
|
||||
core.config.disk_cache=Disk cache
|
||||
core.config.disk_cache.tip={app} will save some data about your installed applications on the disk to load them faster in the next initializations
|
||||
locale.en=english
|
||||
locale.es=spanish
|
||||
locale.pt=portuguese
|
||||
|
||||
@@ -222,6 +222,8 @@ user=usuario
|
||||
example.short=p.ej
|
||||
core.config.tab_label=general
|
||||
core.config.locale.label=idioma
|
||||
core.config.disk_cache=Cache em disco
|
||||
core.config.disk_cache.tip={app} guardará algunos datos sobre sus aplicaciones instaladas en el disco para cargarlas más rápido en las próximas inicializaciones
|
||||
locale.es=inglés
|
||||
locale.es=español
|
||||
locale.pt=portugués
|
||||
|
||||
@@ -178,6 +178,8 @@ icon_button.tooltip.disabled=Questa azione non è disponibile
|
||||
user=utente
|
||||
core.config.tab_label=generale
|
||||
core.config.locale.label=idioma
|
||||
core.config.disk_cache=cache nel disco
|
||||
core.config.disk_cache.tip={app} salverà alcuni dati sulle applicazioni installate sul disco per caricarle più velocemente nelle successive inizializzazioni
|
||||
example.short=es
|
||||
locale.en=inglese
|
||||
locale.es=spagnolo
|
||||
|
||||
@@ -225,6 +225,8 @@ user=usuário
|
||||
example.short=ex
|
||||
core.config.tab_label=geral
|
||||
core.config.locale.label=idioma
|
||||
core.config.disk_cache=Cache em disco
|
||||
core.config.disk_cache.tip={app} gravará alguns dados sobre seus aplicativos instalados no disco para que eles sejam carregados rapidamente nas próximas inicializações
|
||||
locale.en=inglês
|
||||
locale.es=espanhol
|
||||
locale.pt=português
|
||||
|
||||
Reference in New Issue
Block a user