diff --git a/CHANGELOG.md b/CHANGELOG.md index a1b1563d..6d5ef2f1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Ignoring no related updates ( there are some scenarios the updates are not listed due to warnings / suggestions related to some specific runtimes if the param **--no-related** is not informed ) - AUR - Removing repeated **prepare** step that was delaying the build and preventing some packages to install (e.g: xdman ) + +### UI +- AUR + - Textual dependencies replaced by read-only checkboxes on Required Dependencies confirmation dialog + - Optional Dependencies installation dialog now has a type icon beside the dependency name ## [0.7.2] 2019-11-01 ### Improvements diff --git a/bauh/api/abstract/view.py b/bauh/api/abstract/view.py index 3caf1dc1..3cf6103c 100644 --- a/bauh/api/abstract/view.py +++ b/bauh/api/abstract/view.py @@ -28,7 +28,7 @@ class InputOption: Represents a select component option. """ - def __init__(self, label: str, value: object, tooltip: str = None, icon_path: str = None): + def __init__(self, label: str, value: object, tooltip: str = None, icon_path: str = None, read_only: bool = False): """ :param label: the string that will be shown to the user :param value: the option value (not shown) @@ -45,6 +45,7 @@ class InputOption: self.value = value self.tooltip = tooltip self.icon_path = icon_path + self.read_only = read_only def __hash__(self): return hash(self.label) + hash(self.value) diff --git a/bauh/gems/arch/confirmation.py b/bauh/gems/arch/confirmation.py index dd114388..d88653b7 100644 --- a/bauh/gems/arch/confirmation.py +++ b/bauh/gems/arch/confirmation.py @@ -2,15 +2,28 @@ from typing import Set from bauh.api.abstract.handler import ProcessWatcher from bauh.api.abstract.view import MultipleSelectComponent, InputOption +from bauh.commons import resource from bauh.commons.html import bold +from bauh.gems.arch import ROOT_DIR from bauh.view.util.translation import I18n +def _get_mirror_icon(mirror: str): + return resource.get_path('img/{}.png'.format('arch' if mirror == 'aur' else 'mirror'), ROOT_DIR) + + def request_optional_deps(pkgname: str, pkg_mirrors: dict, watcher: ProcessWatcher, i18n: I18n) -> Set[str]: - opts = [InputOption('{}{} ( {} )'.format(p, ': ' + d['desc'] if d['desc'] else '', d['mirror'].upper()), p) for p, d in pkg_mirrors.items()] + opts = [] + + for p, d in pkg_mirrors.items(): + op = InputOption('{}{} ( {} )'.format(p, ': ' + d['desc'] if d['desc'] else '', d['mirror'].upper()), p) + op.icon_path = _get_mirror_icon(d['mirror']) + opts.append(op) + view_opts = MultipleSelectComponent(label='', options=opts, default_options=None) + install = watcher.request_confirmation(title=i18n['arch.install.optdeps.request.title'], body='
{}
'.format(i18n['arch.install.optdeps.request.body'].format(bold(pkgname)) + ':'), components=[view_opts], @@ -22,8 +35,17 @@ def request_optional_deps(pkgname: str, pkg_mirrors: dict, watcher: ProcessWatch def request_install_missing_deps(pkgname: str, pkg_mirrors: dict, watcher: ProcessWatcher, i18n: I18n) -> bool: - deps_str = ''.join(['{}
'.format(i18n['arch.missing_deps.body'].format(bold(pkgname)) + ':{}
'.format(i18n['arch.missing_deps.body'].format(bold(pkgname)) + ':') - return watcher.request_confirmation(i18n['arch.missing_deps.title'], msg) + opts = [] + for p, m in pkg_mirrors.items(): + op = InputOption('{} ( {} )'.format(p, m), p) + op.read_only = True + op.icon_path = _get_mirror_icon(m) + opts.append(op) + + comps = [ + MultipleSelectComponent(label='', options=opts, default_options=set(opts)) + ] + + return watcher.request_confirmation(i18n['arch.missing_deps.title'], msg, comps, confirmation_label=i18n['continue'].capitalize()) diff --git a/bauh/gems/arch/resources/img/mirror.png b/bauh/gems/arch/resources/img/mirror.png new file mode 100755 index 00000000..b4d85c0d Binary files /dev/null and b/bauh/gems/arch/resources/img/mirror.png differ diff --git a/bauh/view/qt/components.py b/bauh/view/qt/components.py index 7175d8a7..c2cdf05b 100644 --- a/bauh/view/qt/components.py +++ b/bauh/view/qt/components.py @@ -15,6 +15,10 @@ class RadioButtonQt(QRadioButton): self.model_parent = model_parent self.toggled.connect(self._set_checked) + if self.model.read_only: + self.setAttribute(Qt.WA_TransparentForMouseEvents) + self.setFocusPolicy(Qt.NoFocus) + def _set_checked(self, checked: bool): if checked: self.model_parent.value = self.model @@ -34,6 +38,10 @@ class CheckboxQt(QCheckBox): if model.icon_path: self.setIcon(QIcon(model.icon_path)) + if model.read_only: + self.setAttribute(Qt.WA_TransparentForMouseEvents) + self.setFocusPolicy(Qt.NoFocus) + def _set_checked(self, state): checked = state == 2