mirror of
https://github.com/spalencsar/bearhub.git
synced 2026-07-06 22:54:16 +02:00
[ui][aur] improved Required / Optional confirmation dialogs
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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='<p>{}</p>'.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(['<br/><span style="font-weight:bold"> - {} ( {} )</span>'.format(d, m.upper()) for d, m in pkg_mirrors.items()])
|
||||
msg = '<p>{}</p>'.format(i18n['arch.missing_deps.body'].format(bold(pkgname)) + ':<br/>' + deps_str)
|
||||
msg += i18n['ask.continue']
|
||||
msg = '<p>{}</p>'.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())
|
||||
|
||||
BIN
bauh/gems/arch/resources/img/mirror.png
Executable file
BIN
bauh/gems/arch/resources/img/mirror.png
Executable file
Binary file not shown.
|
After Width: | Height: | Size: 6.4 KiB |
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user