Beispiel #1
0
def request_install_missing_deps(pkgname: str, deps: List[Tuple[str, str]],
                                 watcher: ProcessWatcher, i18n: I18n) -> bool:
    msg = '<p>{}</p>'.format(i18n['arch.missing_deps.body'].format(
        name=bold(pkgname) if pkgname else '', deps=bold(str(len(deps)))))

    opts = []

    sorted_deps = [*deps]
    sorted_deps.sort(key=lambda e: e[0])

    for dep in sorted_deps:
        op = InputOption(
            '{} ( {}: {} )'.format(dep[0], i18n['repository'], dep[1].upper()),
            dep[0])
        op.read_only = True
        op.icon_path = _get_mirror_icon(dep[1])
        opts.append(op)

    comp = MultipleSelectComponent(label='',
                                   options=opts,
                                   default_options=set(opts))

    return watcher.request_confirmation(
        i18n['arch.missing_deps.title'],
        msg, [comp],
        confirmation_label=i18n['continue'].capitalize(),
        deny_label=i18n['cancel'].capitalize())
Beispiel #2
0
def request_optional_deps(pkgname: str, pkg_repos: dict, watcher: ProcessWatcher, i18n: I18n) -> Set[str]:
    opts = []

    repo_deps = [p for p, data in pkg_repos.items() if data['repository'] != 'aur']
    sizes = pacman.map_update_sizes(repo_deps) if repo_deps else {}

    for p, d in pkg_repos.items():
        size = sizes.get(p)
        label = f"{p} ({i18n['repository']}: {d['repository'].lower()}) | " \
                f"{i18n['size'].capitalize()}: {get_human_size_str(size) if size is not None else '?'}"
        op = InputOption(label=label, value=p, tooltip=d.get('desc') or None)
        op.icon_path = _get_repo_icon(d['repository'])
        opts.append(op)

    view_opts = MultipleSelectComponent(label='',
                                        options=opts,
                                        default_options=set(opts))

    msg = f"<p>{i18n['arch.install.optdeps.request.success'].format(pkg=bold(pkgname))}</p>" \
          f"<p>{i18n['arch.install.optdeps.request.body']}:</p>"

    install = watcher.request_confirmation(title=i18n['arch.install.optdeps.request.title'],
                                           body=msg,
                                           components=[view_opts],
                                           confirmation_label=i18n['install'].capitalize(),
                                           deny_label=i18n['do_not.install'].capitalize(),
                                           min_width=600,
                                           min_height=200)

    if install:
        return {o.value for o in view_opts.values}
Beispiel #3
0
def request_optional_deps(pkgname: str, pkg_mirrors: dict,
                          watcher: ProcessWatcher, i18n: I18n) -> Set[str]:
    opts = []

    for p, d in pkg_mirrors.items():
        op = InputOption(
            '{}{} ( {}: {} )'.format(p, ': ' + d['desc'] if d['desc'] else '',
                                     i18n['repository'], d['mirror'].upper()),
            p)
        op.icon_path = _get_mirror_icon(d['mirror'])
        opts.append(op)

    view_opts = MultipleSelectComponent(label='',
                                        options=opts,
                                        default_options=set(opts))

    install = watcher.request_confirmation(
        title=i18n['arch.install.optdeps.request.title'],
        body='<p>{}.</p><p>{}:</p>'.format(
            i18n['arch.install.optdeps.request.body'].format(bold(pkgname)),
            i18n['arch.install.optdeps.request.help']),
        components=[view_opts],
        confirmation_label=i18n['install'].capitalize(),
        deny_label=i18n['do_not.install'].capitalize())

    if install:
        return {o.value for o in view_opts.values}
Beispiel #4
0
def request_install_missing_deps(pkgname: str, deps: List[Tuple[str, str]],
                                 watcher: ProcessWatcher, i18n: I18n) -> bool:
    msg = '<p>{}</p>'.format(i18n['arch.missing_deps.body'].format(
        name=bold(pkgname) if pkgname else '', deps=bold(str(len(deps)))))

    opts = []

    repo_deps = [d[0] for d in deps if d[1] != 'aur']
    sizes = pacman.get_update_size(repo_deps) if repo_deps else {}

    for dep in deps:
        size = sizes.get(dep[0])
        op = InputOption(
            '{} ({}: {}) - {}: {}'.format(
                dep[0], i18n['repository'], dep[1].lower(),
                i18n['size'].capitalize(),
                get_human_size_str(size) if size else '?'), dep[0])
        op.read_only = True
        op.icon_path = _get_repo_icon(dep[1])
        opts.append(op)

    comp = MultipleSelectComponent(label='',
                                   options=opts,
                                   default_options=set(opts))
    return watcher.request_confirmation(
        i18n['arch.missing_deps.title'],
        msg, [comp],
        confirmation_label=i18n['continue'].capitalize(),
        deny_label=i18n['cancel'].capitalize())
Beispiel #5
0
def request_optional_deps(pkgname: str, pkg_repos: dict,
                          watcher: ProcessWatcher, i18n: I18n) -> Set[str]:
    opts = []

    repo_deps = [
        p for p, data in pkg_repos.items() if data['repository'] != 'aur'
    ]
    sizes = pacman.get_update_size(repo_deps) if repo_deps else {}

    for p, d in pkg_repos.items():
        size = sizes.get(p)
        op = InputOption(
            '{}{} ({}: {}) - {}: {}'.format(
                p, ': ' + d['desc'] if d['desc'] else '', i18n['repository'],
                d['repository'].lower(), i18n['size'].capitalize(),
                get_human_size_str(size) if size else '?'), p)
        op.icon_path = _get_repo_icon(d['repository'])
        opts.append(op)

    view_opts = MultipleSelectComponent(label='',
                                        options=opts,
                                        default_options=set(opts))

    install = watcher.request_confirmation(
        title=i18n['arch.install.optdeps.request.title'],
        body='<p>{}.</p><p>{}:</p>'.format(
            i18n['arch.install.optdeps.request.body'].format(bold(pkgname)),
            i18n['arch.install.optdeps.request.help']),
        components=[view_opts],
        confirmation_label=i18n['install'].capitalize(),
        deny_label=i18n['do_not.install'].capitalize())

    if install:
        return {o.value for o in view_opts.values}
Beispiel #6
0
def confirm_missing_deps(deps: Collection[Tuple[str, str]], watcher: ProcessWatcher, i18n: I18n) -> bool:
    opts = []

    total_isize, total_dsize = None, None
    pkgs_data = pacman.map_updates_data(pkgs=tuple(d[0] for d in deps if d[1] != 'aur'), description=True) or dict()

    for dep in deps:
        ver, desc, isize, dsize = None, None, None, None
        data = pkgs_data.get(dep[0])

        if data:
            desc, isize, dsize = (data.get(f) for f in ('des', 's', 'ds'))

            if isize is not None:
                if total_isize is None:
                    total_isize = 0

                total_isize += isize

            if dsize is not None:
                if total_dsize is None:
                    total_dsize = 0

                total_dsize += dsize

        label = f"{dep[0]} | " \
                f"{i18n['size'].capitalize()}: {get_human_size_str(isize) if isize is not None else '?'}" \
                f"{' ({}: {})'.format(i18n['download'].capitalize(), get_human_size_str(dsize)) if dsize else ''}"

        op = InputOption(label=label, value=dep[0], tooltip=desc)
        op.read_only = True
        op.icon_path = _get_repo_icon(dep[1])
        opts.append(op)

    comp = MultipleSelectComponent(label='', options=opts, default_options=set(opts))

    body = StringIO()
    body.write('<p>')
    body.write(i18n['arch.missing_deps.body'].format(deps=bold(str(len(deps)))))

    if total_isize is not None or total_dsize is not None:
        body.write(' (')

        if total_isize is not None:
            body.write(f"{i18n['size'].capitalize()}: {bold(get_human_size_str(total_isize))} | ")

        if total_dsize is not None:
            body.write(f"{i18n['download'].capitalize()}: {bold(get_human_size_str(total_dsize))}")

        body.write(')')

    body.write(':</p>')

    return watcher.request_confirmation(title=i18n['arch.missing_deps.title'],
                                        body=body.getvalue(),
                                        components=[comp],
                                        confirmation_label=i18n['continue'].capitalize(),
                                        deny_label=i18n['cancel'].capitalize(),
                                        min_width=625)
Beispiel #7
0
    def install_file(self, root_password: Optional[str], watcher: ProcessWatcher) -> bool:
        max_width = 350
        file_chooser = FileChooserComponent(label=self.i18n['file'].capitalize(),
                                            allowed_extensions={'AppImage', '*'},
                                            search_path=get_default_manual_installation_file_dir(),
                                            max_width=max_width)
        input_name = TextInputComponent(label=self.i18n['name'].capitalize(), max_width=max_width)
        input_version = TextInputComponent(label=self.i18n['version'].capitalize(), max_width=max_width)
        file_chooser.observers.append(ManualInstallationFileObserver(input_name, input_version))

        input_description = TextInputComponent(label=self.i18n['description'].capitalize(), max_width=max_width)

        cat_ops = [InputOption(label=self.i18n['category.none'].capitalize(), value=0)]
        cat_ops.extend([InputOption(label=self.i18n.get(f'category.{c.lower()}', c.lower()).capitalize(), value=c) for c in self.context.default_categories])
        inp_cat = SingleSelectComponent(label=self.i18n['category'], type_=SelectViewType.COMBO, options=cat_ops,
                                        default_option=cat_ops[0], max_width=max_width)

        form = FormComponent(label='', components=[file_chooser, input_name, input_version, input_description, inp_cat],
                             spaces=False)

        while True:
            if watcher.request_confirmation(title=self.i18n['appimage.custom_action.install_file.details'], body=None,
                                            components=[form],
                                            confirmation_label=self.i18n['proceed'].capitalize(),
                                            deny_label=self.i18n['cancel'].capitalize(),
                                            min_height=100, max_width=max_width + 150):
                if not file_chooser.file_path or not os.path.isfile(file_chooser.file_path) or not file_chooser.file_path.lower().strip().endswith('.appimage'):
                    watcher.request_confirmation(title=self.i18n['error'].capitalize(),
                                                 body=self.i18n['appimage.custom_action.install_file.invalid_file'],
                                                 deny_button=False)
                elif not input_name.get_value() or not input_name.get_value().strip():
                    watcher.request_confirmation(title=self.i18n['error'].capitalize(),
                                                 body=self.i18n['appimage.custom_action.install_file.invalid_name'],
                                                 deny_button=False)
                else:
                    break
            else:
                return False

        appim = AppImage(i18n=self.i18n, imported=True)
        appim.name = input_name.get_value().strip()
        appim.local_file_path = file_chooser.file_path
        appim.version = input_version.get_value()
        appim.latest_version = input_version.get_value()
        appim.description = input_description.get_value()
        appim.categories = ['Imported']

        if inp_cat.get_selected() != cat_ops[0].value:
            appim.categories.append(inp_cat.get_selected())

        res = self.install(root_password=root_password, pkg=appim, disk_loader=None, watcher=watcher).success

        if res:
            appim.installed = True
            self.cache_to_disk(appim, None, False)

        return res
Beispiel #8
0
    def _gen_bool_component(self, label: str, tooltip: str, value: bool, id_: str, max_width: int = 200) -> SingleSelectComponent:
        opts = [InputOption(label=self.i18n['yes'].capitalize(), value=True),
                InputOption(label=self.i18n['no'].capitalize(), value=False)]

        return SingleSelectComponent(label=label,
                                     options=opts,
                                     default_option=[o for o in opts if o.value == value][0],
                                     type_=SelectViewType.RADIO,
                                     tooltip=tooltip,
                                     max_per_line=len(opts),
                                     max_width=max_width,
                                     id_=id_)
Beispiel #9
0
    def _gen_ui_settings(self, core_config: dict, screen_width: int, screen_height: int) -> TabComponent:
        default_width = floor(0.11 * screen_width)

        select_hdpi = self._gen_bool_component(label=self.i18n['core.config.ui.hdpi'],
                                               tooltip=self.i18n['core.config.ui.hdpi.tip'],
                                               value=bool(core_config['ui']['hdpi']),
                                               max_width=default_width,
                                               id_='hdpi')

        select_ascale = self._gen_bool_component(label=self.i18n['core.config.ui.auto_scale'],
                                                 tooltip=self.i18n['core.config.ui.auto_scale.tip'].format('QT_AUTO_SCREEN_SCALE_FACTOR'),
                                                 value=bool(core_config['ui']['auto_scale']),
                                                 max_width=default_width,
                                                 id_='auto_scale')

        cur_style = QApplication.instance().style().objectName().lower() if not core_config['ui']['style'] else core_config['ui']['style']
        style_opts = [InputOption(label=self.i18n['core.config.ui.style.default'].capitalize(), value=None)]
        style_opts.extend([InputOption(label=s.capitalize(), value=s.lower()) for s in QStyleFactory.keys()])

        default_style = [o for o in style_opts if o.value == cur_style]

        if not default_style:
            if cur_style:
                default_style = InputOption(label=cur_style, value=cur_style)
                style_opts.append(default_style)
            else:
                default_style = style_opts[0]
        else:
            default_style = default_style[0]

        select_style = SingleSelectComponent(label=self.i18n['style'].capitalize(),
                                             options=style_opts,
                                             default_option=default_style,
                                             type_=SelectViewType.COMBO,
                                             max_width=default_width,
                                             id_="style")

        input_maxd = TextInputComponent(label=self.i18n['core.config.ui.max_displayed'].capitalize(),
                                        tooltip=self.i18n['core.config.ui.max_displayed.tip'].capitalize(),
                                        only_int=True,
                                        id_="table_max",
                                        max_width=default_width,
                                        value=str(core_config['ui']['table']['max_displayed']))

        select_dicons = self._gen_bool_component(label=self.i18n['core.config.download.icons'],
                                                 tooltip=self.i18n['core.config.download.icons.tip'],
                                                 id_="down_icons",
                                                 max_width=default_width,
                                                 value=core_config['download']['icons'])

        sub_comps = [FormComponent([select_hdpi, select_ascale, select_dicons, select_style, input_maxd], spaces=False)]
        return TabComponent(self.i18n['core.config.tab.ui'].capitalize(), PanelComponent(sub_comps), None, 'core.ui')
Beispiel #10
0
    def _req_as_option(self,
                       req: UpgradeRequirement,
                       tooltip: bool = True,
                       custom_tooltip: str = None) -> InputOption:
        if req.pkg.installed:
            icon_path = req.pkg.get_disk_icon_path()

            if not icon_path or not os.path.isfile(icon_path):
                icon_path = req.pkg.get_type_icon_path()

        else:
            icon_path = req.pkg.get_type_icon_path()

        size_str = '{}: {}'.format(
            self.i18n['size'].capitalize(), '?'
            if req.extra_size is None else get_human_size_str(req.extra_size))
        if req.extra_size != req.required_size:
            size_str += ' ( {}: {} )'.format(
                self.i18n['action.update.pkg.required_size'].capitalize(),
                '?' if req.required_size is None else get_human_size_str(
                    req.required_size))

        label = '{}{} - {}'.format(
            req.pkg.name, ' ( {} )'.format(req.pkg.latest_version)
            if req.pkg.latest_version else '', size_str)

        return InputOption(label=label,
                           value=None,
                           tooltip=custom_tooltip if custom_tooltip else
                           (req.pkg.get_name_tooltip() if tooltip else None),
                           read_only=True,
                           icon_path=icon_path)
Beispiel #11
0
def request_providers(providers_map: Dict[str, Set[str]], repo_map: Dict[str, str], watcher: ProcessWatcher, i18n: I18n) -> Set[str]:
    msg = "<p>{}.</p><p>{}.</p>".format(i18n['arch.dialog.providers.line1'],
                                        i18n['arch.dialog.providers.line2'])

    repo_icon_path = get_repo_icon_path()
    aur_icon_path = get_icon_path()

    form = FormComponent([], label='')

    for dep, providers in providers_map.items():
        opts = []

        providers_list = [*providers]
        providers_list.sort()

        for p in providers_list:
            repo = repo_map.get(p, 'aur')
            opts.append(InputOption(label=p,
                                    value=p,
                                    icon_path=aur_icon_path if repo == 'aur' else repo_icon_path,
                                    tooltip='{}: {}'.format(i18n['repository'].capitalize(), repo)))

        form.components.append(SingleSelectComponent(label=bold(dep.lower()),
                                                     options=opts,
                                                     default_option=opts[0],
                                                     type_=SelectViewType.COMBO,
                                                     max_per_line=1))

    if watcher.request_confirmation(title=i18n['arch.providers'].capitalize(),
                                    body=msg,
                                    components=[form],
                                    confirmation_label=i18n['proceed'].capitalize(),
                                    deny_label=i18n['cancel'].capitalize()):

        return {s.get_selected() for s in form.components}
Beispiel #12
0
    def _map_to_remove(
        self, pkgs: Optional[Collection[DebianPackage]]
    ) -> Optional[Tuple[List[InputOption], str]]:
        if pkgs:
            freed_space = 0

            views = []
            for p in pkgs:
                if p.transaction_size is not None:
                    size = p.transaction_size * (-1 if p.transaction_size < 0
                                                 else 1)
                    freed_space += size
                    uncompressed = get_human_size_str(size)
                else:
                    uncompressed = '?'

                views.append(
                    InputOption(
                        label=f"{p.name} (-{uncompressed})",
                        value=p.name,
                        read_only=True,
                        icon_path=DEBIAN_ICON_PATH,
                        tooltip=p.description if p.description else '?'))

            return views, f'-{get_human_size_str(freed_space)}' if freed_space > 0 else '?'
Beispiel #13
0
    def _req_as_option(self, req: UpgradeRequirement, tooltip: bool = True, custom_tooltip: str = None, required_size: bool = True, display_sizes: bool = True,
                       positive_size_symbol: bool = False) -> InputOption:
        if req.pkg.installed:
            icon_path = req.pkg.get_disk_icon_path()

            if not icon_path:
                icon_path = req.pkg.get_type_icon_path()
            elif not os.path.isfile(icon_path) or QIcon.fromTheme(icon_path).isNull():
                icon_path = req.pkg.get_type_icon_path()

        else:
            icon_path = req.pkg.get_type_icon_path()

        size_str = None
        if display_sizes:
            storage_size = '?' if req.extra_size is None else get_human_size_str(req.extra_size, positive_size_symbol)
            size_str = f"{self.i18n['action.update.storage_size']}: {storage_size}"
            if required_size and req.extra_size != req.required_size:
                download_size = '?' if req.required_size is None else get_human_size_str(req.required_size)
                size_str += f" ({self.i18n['action.update.download_size']}: {download_size})"

        label = f"{req.pkg.name} {f' ({req.pkg.latest_version})' if req.pkg.latest_version else ''}"

        if size_str:
            label += f' | {size_str}'

        return InputOption(label=label,
                           value=None,
                           tooltip=custom_tooltip if custom_tooltip else (req.pkg.get_name_tooltip() if tooltip else None),
                           read_only=True,
                           icon_path=icon_path)
Beispiel #14
0
    def _map_to_install(
        pkgs: Optional[Collection[DebianPackage]]
    ) -> Optional[Tuple[List[InputOption], str, str]]:
        if pkgs:
            download_size, install_size = 0, 0

            views = []
            for p in pkgs:
                if p.compressed_size is not None and p.compressed_size >= 0:
                    compressed = get_human_size_str(p.compressed_size)
                    download_size += p.compressed_size

                else:
                    compressed = '?'

                if p.transaction_size is not None:
                    install_size += p.transaction_size
                    uncompressed = get_human_size_str(p.transaction_size)
                else:
                    uncompressed = '?'

                views.append(
                    InputOption(
                        label=f"{p.name} ({uncompressed} | {compressed})",
                        value=p.name,
                        read_only=True,
                        icon_path=DEBIAN_ICON_PATH,
                        tooltip=p.description if p.description else '?'))

            dsize = get_human_size_str(
                download_size) if download_size > 0 else '?'
            isize = get_human_size_str(
                install_size) if install_size > 0 else '?'
            return views, isize, dsize
Beispiel #15
0
    def _gen_general_settings(self, core_config: dict, screen_width: int, screen_height: int) -> TabComponent:
        default_width = floor(0.11 * screen_width)

        locale_opts = [InputOption(label=self.i18n['locale.{}'.format(k)].capitalize(), value=k) for k in translation.get_available_keys()]

        current_locale = None

        if core_config['locale']:
            current_locale = [l for l in locale_opts if l.value == core_config['locale']]

        if not current_locale:
            if self.i18n.current_key:
                current_locale = [l for l in locale_opts if l.value == self.i18n.current_key]

            if not current_locale:
                current_locale = [l for l in locale_opts if l.value == self.i18n.default_key]

        current_locale = current_locale[0] if current_locale else None

        select_locale = SingleSelectComponent(label=self.i18n['core.config.locale.label'],
                                              options=locale_opts,
                                              default_option=current_locale,
                                              type_=SelectViewType.COMBO,
                                              max_width=default_width,
                                              id_='locale')

        select_store_pwd = self._gen_bool_component(label=self.i18n['core.config.store_password'].capitalize(),
                                                    tooltip=self.i18n['core.config.store_password.tip'].capitalize(),
                                                    id_="store_pwd",
                                                    max_width=default_width,
                                                    value=bool(core_config['store_root_password']))

        select_sysnotify = self._gen_bool_component(label=self.i18n['core.config.system.notifications'].capitalize(),
                                                    tooltip=self.i18n['core.config.system.notifications.tip'].capitalize(),
                                                    value=bool(core_config['system']['notifications']),
                                                    max_width=default_width,
                                                    id_="sys_notify")

        select_sugs = self._gen_bool_component(label=self.i18n['core.config.suggestions.activated'].capitalize(),
                                               tooltip=self.i18n['core.config.suggestions.activated.tip'].capitalize(),
                                               id_="sugs_enabled",
                                               max_width=default_width,
                                               value=bool(core_config['suggestions']['enabled']))

        inp_sugs = TextInputComponent(label=self.i18n['core.config.suggestions.by_type'],
                                      tooltip=self.i18n['core.config.suggestions.by_type.tip'],
                                      value=str(core_config['suggestions']['by_type']),
                                      only_int=True,
                                      max_width=default_width,
                                      id_="sugs_by_type")

        inp_reboot = self._gen_select(label=self.i18n['core.config.updates.reboot'],
                                      tip=self.i18n['core.config.updates.reboot.tip'],
                                      id_='ask_for_reboot',
                                      max_width=default_width,
                                      value=bool(core_config['updates']['ask_for_reboot']),
                                      opts=[(self.i18n['ask'].capitalize(), True, None), (self.i18n['no'].capitalize(), False, None)])

        sub_comps = [FormComponent([select_locale, select_store_pwd, select_sysnotify, select_sugs, inp_sugs, inp_reboot], spaces=False)]
        return TabComponent(self.i18n['core.config.tab.general'].capitalize(), PanelComponent(sub_comps), None, 'core.gen')
Beispiel #16
0
    def install(self, pkg: SnapApplication, root_password: str,
                watcher: ProcessWatcher) -> bool:
        res, output = ProcessHandler(watcher).handle_simple(
            snap.install_and_stream(pkg.name, pkg.confinement, root_password))

        if 'error:' in output:
            res = False
            if 'not available on stable' in output:
                channels = RE_AVAILABLE_CHANNELS.findall(output)

                if channels:
                    opts = [
                        InputOption(label=c[0], value=c[1]) for c in channels
                    ]
                    channel_select = SingleSelectComponent(
                        type_=SelectViewType.RADIO,
                        label='',
                        options=opts,
                        default_option=opts[0])
                    body = '<p>{}.</p>'.format(
                        self.i18n['snap.install.available_channels.message'].
                        format(bold(self.i18n['stable']), bold(pkg.name)))
                    body += '<p>{}:</p>'.format(
                        self.i18n['snap.install.available_channels.help'])

                    if watcher.request_confirmation(
                            title=self.
                            i18n['snap.install.available_channels.title'],
                            body=body,
                            components=[channel_select],
                            confirmation_label=self.i18n['continue'],
                            deny_label=self.i18n['cancel']):
                        self.logger.info(
                            "Installing '{}' with the custom command '{}'".
                            format(pkg.name, channel_select.value))
                        res = ProcessHandler(watcher).handle(
                            SystemProcess(
                                new_root_subprocess(
                                    channel_select.value.value.split(' '),
                                    root_password=root_password)))

                        if res:
                            pkg.has_apps_field = snap.has_apps_field(
                                pkg.name, self.ubuntu_distro)

                        return res
                else:
                    self.logger.error(
                        "Could not find available channels in the installation output: {}"
                        .format(output))
        else:
            pkg.has_apps_field = snap.has_apps_field(pkg.name,
                                                     self.ubuntu_distro)

        return res
Beispiel #17
0
    def get_settings(self, screen_width: int,
                     screen_height: int) -> ViewComponent:
        config = read_config()
        max_width = floor(screen_width * 0.15)

        input_electron = TextInputComponent(
            label=self.i18n['web.settings.electron.version.label'],
            value=config['environment']['electron']['version'],
            tooltip=self.i18n['web.settings.electron.version.tooltip'],
            placeholder='{}: 7.1.0'.format(self.i18n['example.short']),
            max_width=max_width,
            id_='electron_version')

        native_opts = [
            InputOption(
                label=self.i18n['web.settings.nativefier.env'].capitalize(),
                value=False,
                tooltip=self.i18n['web.settings.nativefier.env.tooltip'].
                format(app=self.context.app_name)),
            InputOption(
                label=self.i18n['web.settings.nativefier.system'].capitalize(),
                value=True,
                tooltip=self.i18n['web.settings.nativefier.system.tooltip'])
        ]

        select_nativefier = SingleSelectComponent(
            label="Nativefier",
            options=native_opts,
            default_option=[
                o for o in native_opts
                if o.value == config['environment']['system']
            ][0],
            type_=SelectViewType.COMBO,
            tooltip=self.i18n['web.settings.nativefier.tip'],
            max_width=max_width,
            id_='nativefier')

        form_env = FormComponent(
            label=self.i18n['web.settings.nativefier.env'].capitalize(),
            components=[input_electron, select_nativefier])

        return PanelComponent([form_env])
Beispiel #18
0
 def _gen_select(self, label: str, tip: str, id_: str, opts: List[tuple], value: object, max_width: int, type_: SelectViewType = SelectViewType.RADIO):
     inp_opts = [InputOption(label=o[0].capitalize(), value=o[1], tooltip=o[2]) for o in opts]
     def_opt = [o for o in inp_opts if o.value == value]
     return SingleSelectComponent(label=label,
                                  tooltip=tip,
                                  options=inp_opts,
                                  default_option=def_opt[0] if def_opt else inp_opts[0],
                                  max_per_line=len(inp_opts),
                                  max_width=max_width,
                                  type_=type_,
                                  id_=id_)
Beispiel #19
0
    def get_settings(self, screen_width: int, screen_height: int) -> ViewComponent:
        tabs = list()

        gem_opts, def_gem_opts, gem_tabs = [], set(), []

        for man in self.managers:
            if man.can_work():
                man_comp = man.get_settings(screen_width, screen_height)
                modname = man.__module__.split('.')[-2]
                icon_path = "{r}/gems/{n}/resources/img/{n}.svg".format(r=ROOT_DIR, n=modname)

                if man_comp:
                    tab_name = self.i18n.get('gem.{}.label'.format(modname), modname.capitalize())
                    gem_tabs.append(TabComponent(label=tab_name, content=man_comp, icon_path=icon_path, id_=modname))

                opt = InputOption(label=self.i18n.get('gem.{}.label'.format(modname), modname.capitalize()),
                                  tooltip=self.i18n.get('gem.{}.info'.format(modname)),
                                  value=modname,
                                  icon_path='{r}/gems/{n}/resources/img/{n}.svg'.format(r=ROOT_DIR, n=modname))
                gem_opts.append(opt)

                if man.is_enabled() and man in self.working_managers:
                    def_gem_opts.add(opt)

        core_config = read_config()

        if gem_opts:
            type_help = TextComponent(html=self.i18n['core.config.types.tip'])
            gem_opts.sort(key=lambda o: o.value)
            gem_selector = MultipleSelectComponent(label=None,
                                                   tooltip=None,
                                                   options=gem_opts,
                                                   max_width=floor(screen_width * 0.22),
                                                   default_options=def_gem_opts,
                                                   id_="gems")
            tabs.append(TabComponent(label=self.i18n['core.config.tab.types'],
                                     content=PanelComponent([type_help, FormComponent([gem_selector], spaces=False)]),
                                     id_='core.types'))

        tabs.append(self._gen_general_settings(core_config, screen_width, screen_height))
        tabs.append(self._gen_ui_settings(core_config, screen_width, screen_height))
        tabs.append(self._gen_tray_settings(core_config, screen_width, screen_height))
        tabs.append(self._gen_adv_settings(core_config, screen_width, screen_height))

        bkp_settings = self._gen_backup_settings(core_config, screen_width, screen_height)

        if bkp_settings:
            tabs.append(bkp_settings)

        for tab in gem_tabs:
            tabs.append(tab)

        return TabGroupComponent(tabs)
Beispiel #20
0
    def get_settings(self, screen_width: int, screen_height: int) -> ViewComponent:
        fields = []

        config = read_config()

        install_opts = [InputOption(label=self.i18n['flatpak.config.install_level.system'].capitalize(),
                                    value='system',
                                    tooltip=self.i18n['flatpak.config.install_level.system.tip']),
                        InputOption(label=self.i18n['flatpak.config.install_level.user'].capitalize(),
                                    value='user',
                                    tooltip=self.i18n['flatpak.config.install_level.user.tip']),
                        InputOption(label=self.i18n['ask'].capitalize(),
                                    value=None,
                                    tooltip=self.i18n['flatpak.config.install_level.ask.tip'].format(app=self.context.app_name))]
        fields.append(SingleSelectComponent(label=self.i18n['flatpak.config.install_level'],
                                            options=install_opts,
                                            default_option=[o for o in install_opts if o.value == config['installation_level']][0],
                                            max_per_line=len(install_opts),
                                            max_width=floor(screen_width * 0.22),
                                            type_=SelectViewType.RADIO))

        return PanelComponent([FormComponent(fields, self.i18n['installation'].capitalize())])
Beispiel #21
0
    def get_settings(self, screen_width: int,
                     screen_height: int) -> ViewComponent:
        config = read_config()
        max_width = floor(screen_width * 0.15)

        enabled_opts = [
            InputOption(label=self.i18n['yes'].capitalize(), value=True),
            InputOption(label=self.i18n['no'].capitalize(), value=False)
        ]

        updater_opts = [
            SingleSelectComponent(
                label=self.i18n['appimage.config.db_updates.activated'],
                options=enabled_opts,
                default_option=[
                    o for o in enabled_opts
                    if o.value == config['db_updater']['enabled']
                ][0],
                max_per_line=len(enabled_opts),
                type_=SelectViewType.RADIO,
                tooltip=self.i18n['appimage.config.db_updates.activated.tip'],
                max_width=max_width,
                id_='up_enabled'),
            TextInputComponent(
                label=self.i18n['interval'],
                value=str(config['db_updater']['interval']),
                tooltip=self.i18n['appimage.config.db_updates.interval.tip'],
                only_int=True,
                max_width=max_width,
                id_='up_int')
        ]

        return PanelComponent([
            FormComponent(updater_opts,
                          self.i18n['appimage.config.db_updates'])
        ])
Beispiel #22
0
    def get_settings(self) -> Optional[Generator[SettingsView, None, None]]:
        if not self.context.root_user:
            fields = []

            flatpak_config = self.configman.get_config()

            install_opts = [InputOption(label=self.i18n['flatpak.config.install_level.system'].capitalize(),
                                        value='system',
                                        tooltip=self.i18n['flatpak.config.install_level.system.tip']),
                            InputOption(label=self.i18n['flatpak.config.install_level.user'].capitalize(),
                                        value='user',
                                        tooltip=self.i18n['flatpak.config.install_level.user.tip']),
                            InputOption(label=self.i18n['ask'].capitalize(),
                                        value=None,
                                        tooltip=self.i18n['flatpak.config.install_level.ask.tip'].format(app=self.context.app_name))]
            fields.append(SingleSelectComponent(label=self.i18n['flatpak.config.install_level'],
                                                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),
                                                type_=SelectViewType.COMBO,
                                                alignment=ViewComponentAlignment.CENTER,
                                                id_='install'))

            yield SettingsView(self, PanelComponent([FormComponent(fields, self.i18n['installation'].capitalize())]))
Beispiel #23
0
    def confirm_removal(self, source_pkg: str,
                        dependencies: Collection[DebianPackage],
                        watcher: ProcessWatcher) -> bool:
        dep_views = []
        freed_space = 0
        for p in sorted(dependencies, key=attrgetter('name')):
            if p.transaction_size is not None:
                size = p.transaction_size * (-1
                                             if p.transaction_size < 0 else 1)
                freed_space += size
                size_str = get_human_size_str(size)
            else:
                size_str = '?'

            dep_views.append(
                InputOption(label=f"{p.name}: -{size_str}",
                            value=p.name,
                            read_only=True,
                            icon_path=DEBIAN_ICON_PATH,
                            tooltip=p.description))

        deps_container = MultipleSelectComponent(id_='deps',
                                                 label='',
                                                 options=dep_views,
                                                 default_options={*dep_views},
                                                 max_width=537)

        freed_space_str = bold('-' + get_human_size_str(freed_space))
        body_text = TextComponent(html=self._i18n['debian.remove_deps'].format(
            no=bold(str(len(dependencies))),
            pkg=bold(source_pkg),
            fspace=freed_space_str),
                                  min_width=653)

        return watcher.request_confirmation(
            title=self._i18n['debian.transaction.title'],
            components=[body_text, deps_container],
            confirmation_label=self._i18n['popup.button.continue'],
            deny_label=self._i18n['popup.button.cancel'],
            min_height=200,
            body=None)
Beispiel #24
0
    def _ask_update_permission(self, to_update: List[EnvironmentComponent],
                               watcher: ProcessWatcher) -> bool:

        icon = resource.get_path('img/web.png', ROOT_DIR)
        opts = [
            InputOption(label='{} ( {} )'.format(f.name, f.size or '?'),
                        tooltip=f.url,
                        icon_path=icon,
                        read_only=True,
                        value=f.name) for f in to_update
        ]

        comps = MultipleSelectComponent(label=None,
                                        options=opts,
                                        default_options=set(opts))

        return watcher.request_confirmation(
            title=self.i18n['web.install.env_update.title'],
            body=self.i18n['web.install.env_update.body'],
            components=[comps],
            confirmation_label=self.i18n['continue'].capitalize(),
            deny_label=self.i18n['cancel'].capitalize())
Beispiel #25
0
def request_optional_deps(pkgname: str, pkg_mirrors: dict,
                          watcher: ProcessWatcher, i18n: dict) -> Set[str]:
    opts = [
        InputOption(
            '{}{} ( {} )'.format(p, ': ' + d['desc'] if d['desc'] else '',
                                 d['mirror'].upper()), p)
        for p, d in pkg_mirrors.items()
    ]
    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],
        confirmation_label=i18n['install'],
        deny_label=i18n['cancel'])

    if install:
        return {o.value for o in view_opts.values}
Beispiel #26
0
def new_select(label: str,
               tip: Optional[str],
               id_: str,
               opts: Iterable[Tuple[Optional[str], object, Optional[str]]],
               value: object,
               max_width: Optional[int] = None,
               type_: SelectViewType = SelectViewType.RADIO,
               capitalize_label: bool = True):
    inp_opts = [
        InputOption(label=o[0].capitalize(), value=o[1], tooltip=o[2])
        for o in opts
    ]
    def_opt = [o for o in inp_opts if o.value == value]
    return SingleSelectComponent(
        label=label,
        tooltip=tip,
        options=inp_opts,
        default_option=def_opt[0] if def_opt else inp_opts[0],
        max_per_line=len(inp_opts),
        max_width=max_width,
        type_=type_,
        id_=id_,
        capitalize_label=capitalize_label)
Beispiel #27
0
    def __init__(self,
                 window: QWidget,
                 manager: GenericSoftwareManager,
                 i18n: dict,
                 config: Configuration,
                 show_panel_after_restart: bool = False):
        super(GemSelectorPanel, self).__init__()
        self.window = window
        self.manager = manager
        self.config = config
        self.setLayout(QGridLayout())
        self.setWindowIcon(QIcon(resource.get_path('img/logo.svg')))
        self.setWindowTitle(i18n['gem_selector.title'])
        self.resize(400, 400)
        self.show_panel_after_restart = show_panel_after_restart

        self.label_question = QLabel(i18n['gem_selector.question'])
        self.label_question.setStyleSheet('QLabel { font-weight: bold}')
        self.layout().addWidget(self.label_question, 0, 1, Qt.AlignHCenter)

        self.bt_proceed = QPushButton(i18n['change'].capitalize())
        self.bt_proceed.setStyleSheet(css.OK_BUTTON)
        self.bt_proceed.clicked.connect(self.save)

        self.bt_exit = QPushButton(i18n['exit'].capitalize())
        self.bt_exit.clicked.connect(self.exit)

        self.gem_map = {}
        gem_options = []
        default = set()

        for m in manager.managers:
            if m.can_work():
                modname = m.__module__.split('.')[-2]
                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() and m in manager.working_managers:
                    default.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 = default

        self.bt_proceed.setEnabled(bool(default_ops))

        self.gem_select_model = MultipleSelectComponent(
            label='',
            options=gem_options,
            default_options=default_ops,
            max_per_line=3)

        self.gem_select = MultipleSelectQt(self.gem_select_model,
                                           self.check_state)
        self.layout().addWidget(self.gem_select, 1, 1)

        self.layout().addWidget(new_spacer(), 2, 1)

        self.layout().addWidget(self.bt_proceed, 3, 1, Qt.AlignRight)
        self.layout().addWidget(self.bt_exit, 3, 1, Qt.AlignLeft)

        self.adjustSize()
        self.setFixedSize(self.size())
        qt_utils.centralize(self)
Beispiel #28
0
    def install(self, pkg: FlatpakApplication, root_password: str,
                disk_loader: DiskCacheLoader,
                watcher: ProcessWatcher) -> TransactionResult:
        flatpak_config = self.configman.get_config()

        install_level = flatpak_config['installation_level']

        if install_level is not None:
            self.logger.info(
                "Default Flaptak installation level defined: {}".format(
                    install_level))

            if install_level not in ('user', 'system'):
                watcher.show_message(
                    title=self.i18n['error'].capitalize(),
                    body=self.i18n['flatpak.install.bad_install_level.body'].
                    format(field=bold('installation_level'),
                           file=bold(CONFIG_FILE)),
                    type_=MessageType.ERROR)
                return TransactionResult(success=False,
                                         installed=[],
                                         removed=[])

            pkg.installation = install_level
        else:
            user_level = watcher.request_confirmation(
                title=self.i18n['flatpak.install.install_level.title'],
                body=self.i18n['flatpak.install.install_level.body'].format(
                    bold(pkg.name)),
                confirmation_label=self.i18n['no'].capitalize(),
                deny_label=self.i18n['yes'].capitalize())
            pkg.installation = 'user' if user_level else 'system'

        remotes = flatpak.list_remotes()

        handler = ProcessHandler(watcher)

        if pkg.installation == 'user' and not remotes['user']:
            handler.handle_simple(flatpak.set_default_remotes('user'))
        elif pkg.installation == 'system' and not remotes['system']:
            if user.is_root():
                handler.handle_simple(flatpak.set_default_remotes('system'))
            else:
                valid, user_password = watcher.request_root_password()
                if not valid:
                    watcher.print('Operation aborted')
                    return TransactionResult(success=False,
                                             installed=[],
                                             removed=[])
                else:
                    if not handler.handle_simple(
                            flatpak.set_default_remotes(
                                'system', user_password))[0]:
                        watcher.show_message(
                            title=self.i18n['error'].capitalize(),
                            body=self.
                            i18n['flatpak.remotes.system_flathub.error'],
                            type_=MessageType.ERROR)
                        watcher.print("Operation cancelled")
                        return TransactionResult(success=False,
                                                 installed=[],
                                                 removed=[])

        # retrieving all installed so it will be possible to know the additional installed runtimes after the operation succeeds
        flatpak_version = flatpak.get_version()
        installed = flatpak.list_installed(flatpak_version)
        installed_by_level = {
            '{}:{}:{}'.format(p['id'], p['name'], p['branch'])
            for p in installed if p['installation'] == pkg.installation
        } if installed else None

        if not self._make_exports_dir(handler.watcher):
            return TransactionResult(success=False, installed=[], removed=[])

        installed, output = handler.handle_simple(
            flatpak.install(str(pkg.id), pkg.origin, pkg.installation))

        if not installed and 'error: No ref chosen to resolve matches' in output:
            ref_opts = RE_INSTALL_REFS.findall(output)

            if ref_opts and len(ref_opts) > 1:
                view_opts = [
                    InputOption(label=o, value=o.strip()) for o in ref_opts
                    if o
                ]
                ref_select = SingleSelectComponent(type_=SelectViewType.RADIO,
                                                   options=view_opts,
                                                   default_option=view_opts[0],
                                                   label='')
                if watcher.request_confirmation(
                        title=self.i18n['flatpak.install.ref_choose.title'],
                        body=self.i18n['flatpak.install.ref_choose.body'].
                        format(bold(pkg.name)),
                        components=[ref_select],
                        confirmation_label=self.i18n['proceed'].capitalize(),
                        deny_label=self.i18n['cancel'].capitalize()):
                    ref = ref_select.get_selected()
                    installed, output = handler.handle_simple(
                        flatpak.install(ref, pkg.origin, pkg.installation))
                    pkg.ref = ref
                    pkg.runtime = 'runtime' in ref
                else:
                    watcher.print('Aborted by the user')
                    return TransactionResult.fail()
            else:
                return TransactionResult.fail()

        if installed:
            try:
                fields = flatpak.get_fields(str(pkg.id), pkg.branch,
                                            ['Ref', 'Branch'])

                if fields:
                    pkg.ref = fields[0]
                    pkg.branch = fields[1]
            except:
                traceback.print_exc()

        if installed:
            new_installed = [pkg]
            current_installed = flatpak.list_installed(flatpak_version)
            current_installed_by_level = [
                p for p in current_installed
                if p['installation'] == pkg.installation
            ] if current_installed else None

            if current_installed_by_level and (not installed_by_level or
                                               len(current_installed_by_level)
                                               > len(installed_by_level) + 1):
                pkg_key = '{}:{}:{}'.format(pkg.id, pkg.name, pkg.branch)
                net_available = self.context.is_internet_available()
                for p in current_installed_by_level:
                    current_key = '{}:{}:{}'.format(p['id'], p['name'],
                                                    p['branch'])
                    if current_key != pkg_key and (not installed_by_level
                                                   or current_key
                                                   not in installed_by_level):
                        new_installed.append(
                            self._map_to_model(app_json=p,
                                               installed=True,
                                               disk_loader=disk_loader,
                                               internet=net_available))

            return TransactionResult(success=installed,
                                     installed=new_installed,
                                     removed=[])
        else:
            return TransactionResult.fail()
Beispiel #29
0
    def install_file(self, root_password: str,
                     watcher: ProcessWatcher) -> bool:
        file_chooser = FileChooserComponent(
            label=self.i18n['file'].capitalize(),
            allowed_extensions={'AppImage'})
        input_name = TextInputComponent(label=self.i18n['name'].capitalize())
        input_version = TextInputComponent(
            label=self.i18n['version'].capitalize())
        input_description = TextInputComponent(
            label=self.i18n['description'].capitalize())

        cat_ops = [
            InputOption(label=self.i18n['category.none'].capitalize(), value=0)
        ]
        cat_ops.extend([
            InputOption(label=self.i18n[c.lower()].capitalize(), value=c)
            for c in self.context.default_categories
        ])
        inp_cat = SingleSelectComponent(label=self.i18n['category'],
                                        type_=SelectViewType.COMBO,
                                        options=cat_ops,
                                        default_option=cat_ops[0])

        form = FormComponent(label='',
                             components=[
                                 file_chooser, input_name, input_version,
                                 input_description, inp_cat
                             ],
                             spaces=False)

        while True:
            if watcher.request_confirmation(
                    title=self.
                    i18n['appimage.custom_action.install_file.details'],
                    body=None,
                    components=[form],
                    confirmation_label=self.i18n['proceed'].capitalize(),
                    deny_label=self.i18n['cancel'].capitalize()):
                if not file_chooser.file_path or not os.path.isfile(
                        file_chooser.file_path):
                    watcher.request_confirmation(
                        title=self.i18n['error'].capitalize(),
                        body=self.i18n[
                            'appimage.custom_action.install_file.invalid_file'],
                        deny_button=False)
                elif not input_name.get_value() or not input_name.get_value(
                ).strip():
                    watcher.request_confirmation(
                        title=self.i18n['error'].capitalize(),
                        body=self.i18n[
                            'appimage.custom_action.install_file.invalid_name'],
                        deny_button=False)
                else:
                    break
            else:
                return False

        appim = AppImage(i18n=self.i18n,
                         imported=True,
                         custom_actions=self.custom_app_actions)
        appim.name = input_name.get_value().strip()
        appim.local_file_path = file_chooser.file_path
        appim.version = input_version.get_value()
        appim.latest_version = input_version.get_value()
        appim.description = input_description.get_value()
        appim.categories = ['Imported']

        if inp_cat.get_selected() != cat_ops[0].value:
            appim.categories.append(inp_cat.get_selected())

        installed = self.install(root_password=root_password,
                                 pkg=appim,
                                 watcher=watcher)

        if installed:
            appim.installed = True
            self.cache_to_disk(appim, None, False)

        return installed
Beispiel #30
0
    def _ask_install_options(
            self, app: WebApplication,
            watcher: ProcessWatcher) -> Tuple[bool, List[str]]:
        watcher.change_substatus(self.i18n['web.install.substatus.options'])

        inp_url = TextInputComponent(label=self.i18n['address'],
                                     value=app.url,
                                     read_only=True)
        inp_name = TextInputComponent(label=self.i18n['name'], value=app.name)
        inp_desc = TextInputComponent(label=self.i18n['description'],
                                      value=app.description)

        cat_ops = [
            InputOption(label=self.i18n['web.install.option.category.none'].
                        capitalize(),
                        value=0)
        ]
        cat_ops.extend([
            InputOption(label=self.i18n[c.lower()].capitalize(), value=c)
            for c in self.context.default_categories
        ])

        def_cat = cat_ops[0]

        if app.categories:
            for opt in cat_ops:
                if opt.value == app.categories[0]:
                    def_cat = opt
                    break

        inp_cat = SingleSelectComponent(label=self.i18n['category'],
                                        type_=SelectViewType.COMBO,
                                        options=cat_ops,
                                        default_option=def_cat)

        tray_op_off = InputOption(
            id_='tray_off',
            label=self.i18n['web.install.option.tray.off.label'],
            value=0,
            tooltip=self.i18n['web.install.option.tray.off.tip'])
        tray_op_default = InputOption(
            id_='tray_def',
            label=self.i18n['web.install.option.tray.default.label'],
            value='--tray',
            tooltip=self.i18n['web.install.option.tray.default.tip'])
        tray_op_min = InputOption(
            id_='tray_min',
            label=self.i18n['web.install.option.tray.min.label'],
            value='--tray=start-in-tray',
            tooltip=self.i18n['web.install.option.tray.min.tip'])

        tray_opts = [tray_op_off, tray_op_default, tray_op_min]
        def_tray_opt = None

        if app.preset_options:
            for opt in tray_opts:
                if opt.id in app.preset_options:
                    def_tray_opt = opt
                    break

        inp_tray = SingleSelectComponent(
            type_=SelectViewType.COMBO,
            options=tray_opts,
            default_option=def_tray_opt,
            label=self.i18n['web.install.option.tray.label'])

        icon_op_ded = InputOption(
            id_='icon_ded',
            label=self.i18n['web.install.option.wicon.deducted.label'],
            value=0,
            tooltip=self.i18n['web.install.option.wicon.deducted.tip'].format(
                'Nativefier'))
        icon_op_disp = InputOption(
            id_='icon_disp',
            label=self.i18n['web.install.option.wicon.displayed.label'],
            value=1,
            tooltip=self.i18n['web.install.option.wicon.displayed.tip'])

        inp_icon = SingleSelectComponent(
            type_=SelectViewType.COMBO,
            options=[icon_op_disp, icon_op_ded],
            default_option=icon_op_disp
            if app.icon_url and app.save_icon else icon_op_ded,
            label=self.i18n['web.install.option.wicon.label'])

        icon_chooser = FileChooserComponent(
            allowed_extensions={'png', 'svg', 'ico', 'jpg', 'jpeg'},
            label=self.i18n['web.install.option.icon.label'])

        form_1 = FormComponent(
            components=[
                inp_url, inp_name, inp_desc, inp_cat, inp_icon, icon_chooser,
                inp_tray
            ],
            label=self.i18n['web.install.options.basic'].capitalize())

        op_single = InputOption(
            id_='single',
            label=self.i18n['web.install.option.single.label'],
            value="--single-instance",
            tooltip=self.i18n['web.install.option.single.tip'])
        op_max = InputOption(id_='max',
                             label=self.i18n['web.install.option.max.label'],
                             value="--maximize",
                             tooltip=self.i18n['web.install.option.max.tip'])
        op_fs = InputOption(
            id_='fullscreen',
            label=self.i18n['web.install.option.fullscreen.label'],
            value="--full-screen",
            tooltip=self.i18n['web.install.option.fullscreen.tip'])
        op_nframe = InputOption(
            id_='no_frame',
            label=self.i18n['web.install.option.noframe.label'],
            value="--hide-window-frame",
            tooltip=self.i18n['web.install.option.noframe.tip'])
        op_allow_urls = InputOption(
            id_='allow_urls',
            label=self.i18n['web.install.option.allow_urls.label'],
            value='--internal-urls=.*',
            tooltip=self.i18n['web.install.option.allow_urls.tip'])
        op_ncache = InputOption(
            id_='no_cache',
            label=self.i18n['web.install.option.nocache.label'],
            value="--clear-cache",
            tooltip=self.i18n['web.install.option.nocache.tip'])
        op_insecure = InputOption(
            id_='insecure',
            label=self.i18n['web.install.option.insecure.label'],
            value="--insecure",
            tooltip=self.i18n['web.install.option.insecure.tip'])
        op_igcert = InputOption(
            id_='ignore_certs',
            label=self.i18n['web.install.option.ignore_certificate.label'],
            value="--ignore-certificate",
            tooltip=self.i18n['web.install.option.ignore_certificate.tip'])

        adv_opts = [
            op_single, op_allow_urls, op_max, op_fs, op_nframe, op_ncache,
            op_insecure, op_igcert
        ]
        def_adv_opts = {op_single, op_allow_urls}

        if app.preset_options:
            for opt in adv_opts:
                if opt.id in app.preset_options:
                    def_adv_opts.add(opt)

        check_options = MultipleSelectComponent(
            options=adv_opts,
            default_options=def_adv_opts,
            label=self.i18n['web.install.options.advanced'].capitalize())

        res = watcher.request_confirmation(
            title=self.i18n['web.install.options_dialog.title'],
            body=None,
            components=[form_1, check_options],
            confirmation_label=self.i18n['continue'].capitalize(),
            deny_label=self.i18n['cancel'].capitalize())

        if res:
            selected = []

            if check_options.values:
                selected.extend(check_options.get_selected_values())

            tray_mode = inp_tray.get_selected()
            if tray_mode is not None and tray_mode != 0:
                selected.append(tray_mode)

            custom_name = inp_name.get_value()

            if custom_name:
                app.name = custom_name

            custom_desc = inp_desc.get_value()

            if custom_desc:
                app.description = inp_desc.get_value()

            cat = inp_cat.get_selected()

            if cat != 0:
                app.categories = [cat]

            if icon_chooser.file_path:
                app.set_custom_icon(icon_chooser.file_path)
                selected.append('--icon={}'.format(icon_chooser.file_path))

            app.save_icon = inp_icon.value == icon_op_disp

            return res, selected

        return False, []