mirror of
https://github.com/spalencsar/bearhub.git
synced 2026-07-10 00:44:16 +02:00
[wgem] allow internal URLs installation option
This commit is contained in:
@@ -97,3 +97,19 @@ class TextComponent(ViewComponent):
|
|||||||
def __init__(self, html: str, id_: str = None):
|
def __init__(self, html: str, id_: str = None):
|
||||||
super(TextComponent, self).__init__(id_=id_)
|
super(TextComponent, self).__init__(id_=id_)
|
||||||
self.value = html
|
self.value = html
|
||||||
|
|
||||||
|
|
||||||
|
class TextInputComponent(ViewComponent):
|
||||||
|
|
||||||
|
def __init__(self, label: str, value: str = '', placeholder: str = None, tooltip: str = None, id_: str = None):
|
||||||
|
super(TextInputComponent, self).__init__(id_=id_)
|
||||||
|
self.label = label
|
||||||
|
self.value = value
|
||||||
|
self.tooltip = tooltip
|
||||||
|
self.placeholder = placeholder
|
||||||
|
|
||||||
|
def get_value(self) -> str:
|
||||||
|
if self.value is not None:
|
||||||
|
return self.value.strip()
|
||||||
|
else:
|
||||||
|
return ''
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ from bauh.api.abstract.disk import DiskCacheLoader
|
|||||||
from bauh.api.abstract.handler import ProcessWatcher
|
from bauh.api.abstract.handler import ProcessWatcher
|
||||||
from bauh.api.abstract.model import SoftwarePackage, PackageAction, PackageSuggestion, PackageUpdate, PackageHistory
|
from bauh.api.abstract.model import SoftwarePackage, PackageAction, PackageSuggestion, PackageUpdate, PackageHistory
|
||||||
from bauh.api.abstract.view import MessageType, MultipleSelectComponent, InputOption, SingleSelectComponent, \
|
from bauh.api.abstract.view import MessageType, MultipleSelectComponent, InputOption, SingleSelectComponent, \
|
||||||
SelectViewType
|
SelectViewType, TextInputComponent
|
||||||
from bauh.commons.html import bold
|
from bauh.commons.html import bold
|
||||||
from bauh.commons.system import ProcessHandler, get_dir_size, get_human_size_str
|
from bauh.commons.system import ProcessHandler, get_dir_size, get_human_size_str
|
||||||
from bauh.gems.web import INSTALLED_PATH, nativefier, DESKTOP_ENTRY_PATH_PATTERN
|
from bauh.gems.web import INSTALLED_PATH, nativefier, DESKTOP_ENTRY_PATH_PATTERN
|
||||||
@@ -179,6 +179,7 @@ class WebApplicationManager(SoftwareManager):
|
|||||||
op_max = InputOption(label=self.i18n['web.install.option.max.label'], value="--maximize", tooltip=self.i18n['web.install.option.max.tip'])
|
op_max = InputOption(label=self.i18n['web.install.option.max.label'], value="--maximize", tooltip=self.i18n['web.install.option.max.tip'])
|
||||||
op_fs = InputOption(label=self.i18n['web.install.option.fullscreen.label'], value="--full-screen", tooltip=self.i18n['web.install.option.fullscreen.tip'])
|
op_fs = InputOption(label=self.i18n['web.install.option.fullscreen.label'], value="--full-screen", tooltip=self.i18n['web.install.option.fullscreen.tip'])
|
||||||
op_nframe = InputOption(label=self.i18n['web.install.option.noframe.label'], value="--hide-window-frame", tooltip=self.i18n['web.install.option.noframe.tip'])
|
op_nframe = InputOption(label=self.i18n['web.install.option.noframe.label'], value="--hide-window-frame", tooltip=self.i18n['web.install.option.noframe.tip'])
|
||||||
|
op_allow_urls = InputOption(label=self.i18n['web.install.option.allow_urls.label'], value='--internal-urls=.*', tooltip=self.i18n['web.install.option.allow_urls.tip'])
|
||||||
op_ncache = InputOption(label=self.i18n['web.install.option.nocache.label'], value="--clear-cache", tooltip=self.i18n['web.install.option.nocache.tip'])
|
op_ncache = InputOption(label=self.i18n['web.install.option.nocache.label'], value="--clear-cache", tooltip=self.i18n['web.install.option.nocache.tip'])
|
||||||
op_insecure = InputOption(label=self.i18n['web.install.option.insecure.label'], value="--insecure", tooltip=self.i18n['web.install.option.insecure.tip'])
|
op_insecure = InputOption(label=self.i18n['web.install.option.insecure.label'], value="--insecure", tooltip=self.i18n['web.install.option.insecure.tip'])
|
||||||
op_igcert = InputOption(label=self.i18n['web.install.option.ignore_certificate.label'], value="--ignore-certificate", tooltip=self.i18n['web.install.option.ignore_certificate.tip'])
|
op_igcert = InputOption(label=self.i18n['web.install.option.ignore_certificate.label'], value="--ignore-certificate", tooltip=self.i18n['web.install.option.ignore_certificate.tip'])
|
||||||
@@ -187,10 +188,9 @@ class WebApplicationManager(SoftwareManager):
|
|||||||
tray_op_default = InputOption(label=self.i18n['web.install.option.tray.default.label'], value='--tray', tooltip=self.i18n['web.install.option.tray.default.tip'])
|
tray_op_default = InputOption(label=self.i18n['web.install.option.tray.default.label'], value='--tray', tooltip=self.i18n['web.install.option.tray.default.tip'])
|
||||||
tray_op_min = InputOption(label=self.i18n['web.install.option.tray.min.label'], value='--tray=start-in-tray', tooltip=self.i18n['web.install.option.tray.min.tip'])
|
tray_op_min = InputOption(label=self.i18n['web.install.option.tray.min.label'], value='--tray=start-in-tray', tooltip=self.i18n['web.install.option.tray.min.tip'])
|
||||||
|
|
||||||
check_options = MultipleSelectComponent(options=[op_single, op_max, op_fs, op_nframe, op_ncache, op_insecure, op_igcert], default_options={op_single}, label='')
|
check_options = MultipleSelectComponent(options=[op_single, op_allow_urls, op_max, op_fs, op_nframe, op_ncache, op_insecure, op_igcert], default_options={op_single}, label='')
|
||||||
input_tray = SingleSelectComponent(type_=SelectViewType.COMBO, options=[tray_op_off, tray_op_default, tray_op_min], label=self.i18n['web.install.option.tray.label'])
|
input_tray = SingleSelectComponent(type_=SelectViewType.COMBO, options=[tray_op_off, tray_op_default, tray_op_min], label=self.i18n['web.install.option.tray.label'])
|
||||||
|
|
||||||
# input_internal_urls = TextInput()
|
|
||||||
res = watcher.request_confirmation(title=self.i18n['web.install.options_dialog.title'],
|
res = watcher.request_confirmation(title=self.i18n['web.install.options_dialog.title'],
|
||||||
body=self.i18n['web.install.options_dialog.body'].format(bold(bt_continue)),
|
body=self.i18n['web.install.options_dialog.body'].format(bold(bt_continue)),
|
||||||
components=[check_options, input_tray],
|
components=[check_options, input_tray],
|
||||||
@@ -203,8 +203,9 @@ class WebApplicationManager(SoftwareManager):
|
|||||||
if check_options.values:
|
if check_options.values:
|
||||||
selected.extend(check_options.get_selected_values())
|
selected.extend(check_options.get_selected_values())
|
||||||
|
|
||||||
if input_tray.value:
|
tray_mode = input_tray.get_selected_value()
|
||||||
selected.append(input_tray.get_selected_value())
|
if tray_mode is not None and tray_mode != 0:
|
||||||
|
selected.append(tray_mode)
|
||||||
|
|
||||||
return res, selected
|
return res, selected
|
||||||
|
|
||||||
|
|||||||
@@ -25,6 +25,8 @@ web.install.option.insecure.label=Allow insecure content
|
|||||||
web.install.option.insecure.tip=It allows the execution of insecure content within the application
|
web.install.option.insecure.tip=It allows the execution of insecure content within the application
|
||||||
web.install.option.ignore_certificate.label=Ignore certificate errors
|
web.install.option.ignore_certificate.label=Ignore certificate errors
|
||||||
web.install.option.ignore_certificate.tip=Certificate related errors will be ignored by the app
|
web.install.option.ignore_certificate.tip=Certificate related errors will be ignored by the app
|
||||||
|
web.install.option.allow_urls.label=Allow internal URLs
|
||||||
|
web.install.option.allow_urls.tip=It allows the application to internally open addresses / URLs outside its domain. e.g: outlook.live.com would be able to open account.microsoft.com
|
||||||
web.install.option.tray.label=Tray mode
|
web.install.option.tray.label=Tray mode
|
||||||
web.install.option.tray.off.label=Off
|
web.install.option.tray.off.label=Off
|
||||||
web.install.option.tray.off.tip=Off
|
web.install.option.tray.off.tip=Off
|
||||||
|
|||||||
@@ -25,6 +25,8 @@ web.install.option.insecure.label=Permitir conteúdo não confiável
|
|||||||
web.install.option.insecure.tip=Permite a execução de conteúdo não confiável dentro do aplicativo
|
web.install.option.insecure.tip=Permite a execução de conteúdo não confiável dentro do aplicativo
|
||||||
web.install.option.ignore_certificate.label=Ignorar erros de certificado
|
web.install.option.ignore_certificate.label=Ignorar erros de certificado
|
||||||
web.install.option.ignore_certificate.tip=Erros associados a certificados serão ignorados pelo aplicativo
|
web.install.option.ignore_certificate.tip=Erros associados a certificados serão ignorados pelo aplicativo
|
||||||
|
web.install.option.allow_urls.label=Permitir URLs internas
|
||||||
|
web.install.option.allow_urls.tip=Permite que o aplicativo abra internamente endereços / URLs fora do seu domínio. Exemplo: outlook.live.com conseguiria abrir account.microsoft.com
|
||||||
web.install.option.tray.label=Modo bandeja
|
web.install.option.tray.label=Modo bandeja
|
||||||
web.install.option.tray.off.label=Desligado
|
web.install.option.tray.off.label=Desligado
|
||||||
web.install.option.tray.off.tip=Desligado
|
web.install.option.tray.off.tip=Desligado
|
||||||
|
|||||||
@@ -3,7 +3,8 @@ from PyQt5.QtGui import QIcon, QPixmap
|
|||||||
from PyQt5.QtWidgets import QRadioButton, QGroupBox, QCheckBox, QComboBox, QGridLayout, QWidget, \
|
from PyQt5.QtWidgets import QRadioButton, QGroupBox, QCheckBox, QComboBox, QGridLayout, QWidget, \
|
||||||
QLabel, QSizePolicy, QLineEdit, QToolButton, QHBoxLayout
|
QLabel, QSizePolicy, QLineEdit, QToolButton, QHBoxLayout
|
||||||
|
|
||||||
from bauh.api.abstract.view import SingleSelectComponent, InputOption, MultipleSelectComponent, SelectViewType
|
from bauh.api.abstract.view import SingleSelectComponent, InputOption, MultipleSelectComponent, SelectViewType, \
|
||||||
|
TextInputComponent
|
||||||
from bauh.view.util import resource
|
from bauh.view.util import resource
|
||||||
|
|
||||||
|
|
||||||
@@ -114,6 +115,31 @@ class ComboSelectQt(QGroupBox):
|
|||||||
self.layout().addWidget(QLabel(model.label + ' :'), 0, 0)
|
self.layout().addWidget(QLabel(model.label + ' :'), 0, 0)
|
||||||
self.layout().addWidget(ComboBoxQt(model), 0, 1)
|
self.layout().addWidget(ComboBoxQt(model), 0, 1)
|
||||||
|
|
||||||
|
|
||||||
|
class TextInputQt(QGroupBox):
|
||||||
|
|
||||||
|
def __init__(self, model: TextInputComponent):
|
||||||
|
super(TextInputQt, self).__init__()
|
||||||
|
self.model = model
|
||||||
|
self.setLayout(QGridLayout())
|
||||||
|
self.setStyleSheet('QGridLayout {margin-left: 0} QLabel { font-weight: bold}')
|
||||||
|
self.layout().addWidget(QLabel(model.label + ' :'), 0, 0)
|
||||||
|
|
||||||
|
self.text_input = QLineEdit()
|
||||||
|
|
||||||
|
if model.placeholder:
|
||||||
|
self.text_input.setPlaceholderText(model.placeholder)
|
||||||
|
|
||||||
|
if model.tooltip:
|
||||||
|
self.text_input.setToolTip(model.tooltip)
|
||||||
|
|
||||||
|
self.text_input.textChanged.connect(self._update_model)
|
||||||
|
|
||||||
|
self.layout().addWidget(self.text_input, 0, 1)
|
||||||
|
|
||||||
|
def _update_model(self, text: str):
|
||||||
|
self.model.value = text
|
||||||
|
|
||||||
# class ComboSelectQt(QGroupBox):
|
# class ComboSelectQt(QGroupBox):
|
||||||
#
|
#
|
||||||
# def __init__(self, model: SingleSelectComponent):
|
# def __init__(self, model: SingleSelectComponent):
|
||||||
|
|||||||
@@ -3,9 +3,9 @@ from typing import List
|
|||||||
from PyQt5.QtCore import QSize
|
from PyQt5.QtCore import QSize
|
||||||
from PyQt5.QtWidgets import QMessageBox, QVBoxLayout, QLabel, QWidget, QScrollArea, QFrame
|
from PyQt5.QtWidgets import QMessageBox, QVBoxLayout, QLabel, QWidget, QScrollArea, QFrame
|
||||||
|
|
||||||
from bauh.api.abstract.view import ViewComponent, SingleSelectComponent, MultipleSelectComponent
|
from bauh.api.abstract.view import ViewComponent, SingleSelectComponent, MultipleSelectComponent, TextInputComponent
|
||||||
from bauh.view.qt import css
|
from bauh.view.qt import css
|
||||||
from bauh.view.qt.components import MultipleSelectQt, new_single_select
|
from bauh.view.qt.components import MultipleSelectQt, new_single_select, TextInputQt
|
||||||
from bauh.view.util.translation import I18n
|
from bauh.view.util.translation import I18n
|
||||||
|
|
||||||
|
|
||||||
@@ -43,6 +43,8 @@ class ConfirmationDialog(QMessageBox):
|
|||||||
inst = new_single_select(comp)
|
inst = new_single_select(comp)
|
||||||
elif isinstance(comp, MultipleSelectComponent):
|
elif isinstance(comp, MultipleSelectComponent):
|
||||||
inst = MultipleSelectQt(comp, None)
|
inst = MultipleSelectQt(comp, None)
|
||||||
|
elif isinstance(comp, TextInputComponent):
|
||||||
|
inst = TextInputQt(comp)
|
||||||
else:
|
else:
|
||||||
raise Exception("Cannot render instances of " + comp.__class__.__name__)
|
raise Exception("Cannot render instances of " + comp.__class__.__name__)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user