From da17ede1ec910e2afb3412e97d0d92d8328c64da Mon Sep 17 00:00:00 2001 From: Vinicius Moreira Date: Wed, 18 Sep 2019 11:42:13 -0300 Subject: [PATCH] Arch gem is not enabled by default --- CHANGELOG.md | 2 ++ README.md | 9 +++++++++ bauh/api/abstract/controller.py | 6 ++++++ bauh/app.py | 4 ++++ bauh/app_args.py | 2 +- bauh/gems/arch/controller.py | 3 +++ bauh/gems/arch/resources/locale/en | 1 + bauh/gems/arch/resources/locale/es | 1 + bauh/gems/arch/resources/locale/pt | 1 + bauh/gems/flatpak/controller.py | 3 +++ bauh/gems/snap/controller.py | 3 +++ bauh/view/core/controller.py | 3 +++ bauh/view/core/gems.py | 6 ++++-- bauh/view/qt/components.py | 24 ++++++++++++++++++++++-- bauh/view/qt/gem_selector.py | 15 +++++++++++---- bauh/view/resources/img/help.png | Bin 0 -> 782 bytes 16 files changed, 74 insertions(+), 9 deletions(-) create mode 100644 bauh/view/resources/img/help.png diff --git a/CHANGELOG.md b/CHANGELOG.md index b8f0b92a..c0e94c93 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -44,6 +44,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Code was internally modularized as: **api** (conceptual classes used to create custom software managers), **gems** (software managers), **commons** (common classes shared between the **view** and **gems**), **view** (UI code) - **api** allows custom operations, so the **gems** can provide actions that the current GUI does not support (Snap "refresh" was refactored as a custom operation) +### Comments +- the application settings are stored in **/home/$USER/.config/bauh/config.json** ## [0.5.2] 2019-09-06 ### Features diff --git a/README.md b/README.md index c0bcde94..332b7c3d 100644 --- a/README.md +++ b/README.md @@ -72,11 +72,20 @@ You can change some application settings via environment variables or arguments - **BAUH_SUGGESTIONS**: If application suggestions should be displayed if no packaged considered as an application is installed (runtimes / libraries do not count as applications). Use **0** (disable) or **1** (enable, default). - **BAUH_MAX_DISPLAYED**: Maximum number of displayed packages in the management panel table. Default: 50. + +The application settings are stored in **/home/$USER/.config/bauh/config.json** + + +### Disk cache +- **bauh** stores some data about your installed applications by **default** in **/home/$USER/.cache/bauh** to load them faster. + ### How to improve **bauh** performance - If you don't care about a specific packaging technology and don't want **bauh** to deal with it, just disable it via the graphical interface. - If you don't care about restarting the app every time a new supported packaging technology is installed, set "check-packaging-once=1" (**bauh --check-packaging-once=1**). This can reduce the application response time up in some scenarios, since it won't need to recheck if the packaging type is available for every action you request. - If you don't mind to see the applications icons, you can set "download-icons=0" (**bauh --download-icons=0**). The application may have a slight response improvement, since it will reduce the parallelism within it. - If you don't mind app suggestions, disable it (**bauh --sugs=0**) +- Let the disk cache always enabled so **bauh** does not need to dynamically retrieve some data every time you launch it. + ### Code structure #### Modules diff --git a/bauh/api/abstract/controller.py b/bauh/api/abstract/controller.py index 47459b2f..e44bac7b 100644 --- a/bauh/api/abstract/controller.py +++ b/bauh/api/abstract/controller.py @@ -226,3 +226,9 @@ class SoftwareManager(ABC): :return: if the action resulted in success """ pass + + @abstractmethod + def is_default_enabled(self) -> bool: + """ + :return: if the instance is enabled by default when there is no user settings defining which gems are enabled. + """ diff --git a/bauh/app.py b/bauh/app.py index 43f808fc..0ba26cdd 100755 --- a/bauh/app.py +++ b/bauh/app.py @@ -81,3 +81,7 @@ def main(): cache_cleaner.start() sys.exit(app.exec_()) + + +if __name__ == '__main__': + main() diff --git a/bauh/app_args.py b/bauh/app_args.py index 2504e8ff..e5b4b163 100644 --- a/bauh/app_args.py +++ b/bauh/app_args.py @@ -7,7 +7,7 @@ from bauh import __app_name__, __version__ def read() -> Namespace: - parser = argparse.ArgumentParser(prog=__app_name__, description="GUI for Linux packages management") + parser = argparse.ArgumentParser(prog=__app_name__, description="GUI for Linux package management") parser.add_argument('-v', '--version', action='version', version='%(prog)s {}'.format(__version__)) parser.add_argument('-e', '--cache-exp', action="store", default=int(os.getenv('BAUH_CACHE_EXPIRATION', 60 * 60)), type=int, diff --git a/bauh/gems/arch/controller.py b/bauh/gems/arch/controller.py index 2dc022a8..f2f1be62 100644 --- a/bauh/gems/arch/controller.py +++ b/bauh/gems/arch/controller.py @@ -577,3 +577,6 @@ class ArchManager(SoftwareManager): res.append(PackageSuggestion(self.mapper.map_api_data(pkg, {}), suggestions.ALL.get(pkg['Name']))) return res + + def is_default_enabled(self) -> bool: + return False diff --git a/bauh/gems/arch/resources/locale/en b/bauh/gems/arch/resources/locale/en index 34257bec..50cbead6 100644 --- a/bauh/gems/arch/resources/locale/en +++ b/bauh/gems/arch/resources/locale/en @@ -1,4 +1,5 @@ gem.arch.label=Arch ( AUR ) +gem.arch.info=AUR packages are maintained by an independent user community. There is no warranty that they will work or not harm you system. arch.install.conflict.popup.title=Conflict detected arch.install.conflict.popup.body=The applications {} are in conflict. You must uninstall one to install the other. Continue ? arch.missing_deps.title=Missing dependencies diff --git a/bauh/gems/arch/resources/locale/es b/bauh/gems/arch/resources/locale/es index 6ca204d7..a961d463 100644 --- a/bauh/gems/arch/resources/locale/es +++ b/bauh/gems/arch/resources/locale/es @@ -1,4 +1,5 @@ gem.arch.label=Arch ( AUR ) +gem.arch.info=Los paquetes AUR son mantenidos por una comunidad de usuarios independiente. No hay garantía de que funcionen o que no dañen su sistema. aur.info.architecture=arquitectura aur.info.architecture.any=cualquier aur.info.build date=fecha de construcción diff --git a/bauh/gems/arch/resources/locale/pt b/bauh/gems/arch/resources/locale/pt index 95a8d348..59d9c91e 100644 --- a/bauh/gems/arch/resources/locale/pt +++ b/bauh/gems/arch/resources/locale/pt @@ -1,4 +1,5 @@ gem.arch.label=Arch ( AUR ) +gem.arch.info=Pacotes do AUR são mantidos por uma comunidade de usuários independente. Não há garantia que funcionarão ou que não prejudicarão o seus sistema. aur.info.architecture=arquitetura aur.info.architecture.any=qualquer aur.info.build date=data de construção diff --git a/bauh/gems/flatpak/controller.py b/bauh/gems/flatpak/controller.py index feeffe39..409ddc76 100644 --- a/bauh/gems/flatpak/controller.py +++ b/bauh/gems/flatpak/controller.py @@ -206,3 +206,6 @@ class FlatpakManager(SoftwareManager): break return res + + def is_default_enabled(self) -> bool: + return True diff --git a/bauh/gems/snap/controller.py b/bauh/gems/snap/controller.py index 4c131455..1f9e4439 100644 --- a/bauh/gems/snap/controller.py +++ b/bauh/gems/snap/controller.py @@ -170,3 +170,6 @@ class SnapManager(SoftwareManager): t.join() return res + + def is_default_enabled(self) -> bool: + return True diff --git a/bauh/view/core/controller.py b/bauh/view/core/controller.py index a7d55690..00ca4317 100755 --- a/bauh/view/core/controller.py +++ b/bauh/view/core/controller.py @@ -313,3 +313,6 @@ class GenericSoftwareManager(SoftwareManager): if man: return exec('man.{}(pkg=pkg, root_password=root_password, watcher=watcher)'.format(action.manager_method)) + + def is_default_enabled(self) -> bool: + return True diff --git a/bauh/view/core/gems.py b/bauh/view/core/gems.py index a635de99..5d359e1e 100644 --- a/bauh/view/core/gems.py +++ b/bauh/view/core/gems.py @@ -37,8 +37,10 @@ def load_managers(locale: str, context: ApplicationContext, enabled_gems: List[s man = manager_class(context=context) - if enabled_gems is not None and f.name not in enabled_gems: - man.set_enabled(False) + if enabled_gems is None: + man.set_enabled(man.is_default_enabled()) + else: + man.set_enabled(f.name in enabled_gems) managers.append(man) diff --git a/bauh/view/qt/components.py b/bauh/view/qt/components.py index ea048b8c..d40e8b01 100644 --- a/bauh/view/qt/components.py +++ b/bauh/view/qt/components.py @@ -1,9 +1,10 @@ from PyQt5.QtCore import Qt -from PyQt5.QtGui import QIcon +from PyQt5.QtGui import QIcon, QPixmap from PyQt5.QtWidgets import QRadioButton, QGroupBox, QCheckBox, QComboBox, QGridLayout, QWidget, \ QLabel, QSizePolicy, QLineEdit, QToolButton, QHBoxLayout from bauh.api.abstract.view import SingleSelectComponent, InputOption, MultipleSelectComponent, SelectViewType +from bauh.view.util import resource class RadioButtonQt(QRadioButton): @@ -122,6 +123,15 @@ class MultipleSelectQt(QGroupBox): self.setLayout(self._layout) line, col = 0, 0 + + pixmap_help = QPixmap() + + for op in model.options: # loads the help icon if at least one option has a tooltip + if op.tooltip: + with open(resource.get_path('img/help.png'), 'rb') as f: + pixmap_help.loadFromData(f.read()) + break + for op in model.options: comp = CheckboxQt(op, model, callback) @@ -129,7 +139,17 @@ class MultipleSelectQt(QGroupBox): self.value = comp comp.setChecked(True) - self._layout.addWidget(comp, line, col) + widget = QWidget() + widget.setLayout(QHBoxLayout()) + widget.layout().addWidget(comp) + + if op.tooltip: + help_icon = QLabel() + help_icon.setPixmap(pixmap_help) + help_icon.setToolTip(op.tooltip) + widget.layout().addWidget(help_icon) + + self._layout.addWidget(widget, line, col) if col + 1 == self.model.max_per_line: line += 1 diff --git a/bauh/view/qt/gem_selector.py b/bauh/view/qt/gem_selector.py index 9c899e4d..d9ade95e 100644 --- a/bauh/view/qt/gem_selector.py +++ b/bauh/view/qt/gem_selector.py @@ -37,19 +37,26 @@ class GemSelectorPanel(QWidget): self.gem_map = {} gem_options = [] + current_enabled = set() for m in manager.managers: if m.can_work(): modname = m.__module__.split('.')[-2] - gem_options.append(InputOption(label=i18n.get('gem.{}.label'.format(modname), modname.capitalize()), - value=modname, - icon_path='{r}/gems/{n}/resources/img/{n}.png'.format(r=ROOT_DIR, n=modname))) + op = InputOption(label=i18n.get('gem.{}.label'.format(modname), modname.capitalize()), + tooltip=i18n.get('gem.{}.info'.format(modname)), + value=modname, + icon_path='{r}/gems/{n}/resources/img/{n}.png'.format(r=ROOT_DIR, n=modname)) + + gem_options.append(op) self.gem_map[modname] = m + if m.is_enabled(): + current_enabled.add(op) + if self.config.enabled_gems: default_ops = {o for o in gem_options if o.value in self.config.enabled_gems} else: - default_ops = set(gem_options) + default_ops = current_enabled self.bt_proceed.setEnabled(bool(default_ops)) diff --git a/bauh/view/resources/img/help.png b/bauh/view/resources/img/help.png new file mode 100644 index 0000000000000000000000000000000000000000..073cc0a5c26932ae62d39f066cf2dbfefb65b12c GIT binary patch literal 782 zcmV+p1M&QcP)eF+3%Q4hc7YubXh~w{V_nV|O5V9JRozdUhnD`BzTCQR zFt57KGYO?u7ytybrJ30$P4n@~^Uq@Wia<+$O#c-LzcppO_kYA%Xjblh=y&?~?1PJ@ z0D$Gz&|ocD5Fz5PLwJYhpUpB%#dR#v;JpU`6uj~9V9LAmOSSFRdJo>5IE?mSJpkZa zGL6316PR1eZi&-i{OJ_yF7K(@%y*CO$3CAMUC&3+J3NlIU_D~pZChM8M2exi&d3f? z2Y@sH6<`e@F+8(?m(y`fF0CNyuLCo~qsZH4VGFrOW{|HUK%|19jr>Tc0F*;be!M%` zjpeL~Yhz!x2{@pT%y7~mlEJK1xljS9ull;YtN8-;4v!;Y-3X^%q)mXC68U#u^NcFo^S3p;7fSs~{TD2gt zGb;S))Ca-#Du~nNS)>74(G zw!o;=02FmA`#H? M07*qoM6N<$f+%8KfB*mh literal 0 HcmV?d00001