Esempio n. 1
0
    def __init__(self, manager: SoftwareManager, i18n: I18n, screen_size: QSize, tray, window: QWidget, parent: QWidget = None):
        super(SettingsWindow, self).__init__(parent=parent)
        self.setWindowTitle(i18n['settings'].capitalize())
        self.setLayout(QVBoxLayout())
        self.manager = manager
        self.i18n = i18n
        self.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Preferred)
        self.tray = tray
        self.window = window

        self.settings_model = self.manager.get_settings(screen_size.width(), screen_size.height())

        tab_group = to_widget(self.settings_model, i18n)
        tab_group.setMinimumWidth(int(screen_size.width() / 3))
        self.layout().addWidget(tab_group)

        action_bar = QToolBar()
        action_bar.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Fixed)

        bt_close = QPushButton()
        bt_close.setText(self.i18n['close'].capitalize())
        bt_close.clicked.connect(lambda: self.close())
        action_bar.addWidget(bt_close)

        action_bar.addWidget(new_spacer())

        bt_change = QPushButton()
        bt_change.setStyleSheet(css.OK_BUTTON)
        bt_change.setText(self.i18n['change'].capitalize())
        bt_change.clicked.connect(self._save_settings)
        action_bar.addWidget(bt_change)

        self.layout().addWidget(action_bar)
Esempio n. 2
0
    def __init__(self,
                 manager: SoftwareManager,
                 i18n: I18n,
                 screen_size: QSize,
                 window: QWidget,
                 parent: Optional[QWidget] = None):
        super(SettingsWindow,
              self).__init__(parent=parent,
                             flags=Qt.CustomizeWindowHint | Qt.WindowTitleHint)
        self.setWindowTitle('{} ({})'.format(i18n['settings'].capitalize(),
                                             __app_name__))
        self.setLayout(QVBoxLayout())
        self.manager = manager
        self.i18n = i18n
        self.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Preferred)
        self.window = window

        self.settings_model = self.manager.get_settings(
            screen_size.width(), screen_size.height())

        tab_group = to_widget(self.settings_model, i18n)
        tab_group.setObjectName('settings')
        self.layout().addWidget(tab_group)

        lower_container = QWidget()
        lower_container.setObjectName('lower_container')
        lower_container.setProperty('container', 'true')
        lower_container.setLayout(QHBoxLayout())
        lower_container.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Fixed)

        bt_close = QPushButton()
        bt_close.setObjectName('cancel')
        bt_close.setAutoDefault(True)
        bt_close.setCursor(QCursor(Qt.PointingHandCursor))
        bt_close.setText(self.i18n['close'].capitalize())
        bt_close.clicked.connect(lambda: self.close())
        lower_container.layout().addWidget(bt_close)

        lower_container.layout().addWidget(new_spacer())

        bt_change = QPushButton()
        bt_change.setAutoDefault(True)
        bt_change.setObjectName('ok')
        bt_change.setCursor(QCursor(Qt.PointingHandCursor))
        bt_change.setText(self.i18n['change'].capitalize())
        bt_change.clicked.connect(self._save_settings)
        lower_container.layout().addWidget(bt_change)

        self.layout().addWidget(lower_container)
Esempio n. 3
0
    def __init__(self, manager: SoftwareManager, i18n: I18n, window: QWidget, parent: Optional[QWidget] = None):
        super(SettingsWindow, self).__init__(parent=parent, flags=Qt.CustomizeWindowHint | Qt.WindowTitleHint)
        self.setWindowTitle(f"{i18n['settings'].capitalize()} ({__app_name__})")
        self.setLayout(QVBoxLayout())
        self.manager = manager
        self.i18n = i18n
        self.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Preferred)
        self.window = window

        self.settings_model = tuple(v for v in self.manager.get_settings())[0].component

        self.tab_group = to_widget(self.settings_model, i18n)
        self.tab_group.setObjectName('settings')
        self.layout().addWidget(self.tab_group)

        lower_container = QWidget()
        lower_container.setObjectName('lower_container')
        lower_container.setProperty('container', 'true')
        lower_container.setLayout(QHBoxLayout())
        lower_container.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Fixed)

        self.bt_close = QPushButton()
        self.bt_close.setObjectName('cancel')
        self.bt_close.setAutoDefault(True)
        self.bt_close.setCursor(QCursor(Qt.PointingHandCursor))
        self.bt_close.setText(self.i18n['close'].capitalize())
        self.bt_close.clicked.connect(lambda: self.close())
        lower_container.layout().addWidget(self.bt_close)

        lower_container.layout().addWidget(new_spacer())

        self.bt_change = QPushButton()
        self.bt_change.setAutoDefault(True)
        self.bt_change.setObjectName('ok')
        self.bt_change.setCursor(QCursor(Qt.PointingHandCursor))
        self.bt_change.setText(self.i18n['change'].capitalize())
        self.bt_change.clicked.connect(self._save_settings)
        lower_container.layout().addWidget(self.bt_change)

        self.layout().addWidget(lower_container)

        self.thread_reload_panel = ReloadManagePanel(manager=manager)
        self.thread_reload_panel.signal_finished.connect(self._reload_manage_panel)
Esempio n. 4
0
    def __init__(self,
                 title: str,
                 body: str,
                 i18n: I18n,
                 screen_size: QSize,
                 components: List[ViewComponent] = None,
                 confirmation_label: str = None,
                 deny_label: str = None,
                 deny_button: bool = True,
                 window_cancel: bool = True,
                 confirmation_button: bool = True):
        super(ConfirmationDialog, self).__init__()

        if not window_cancel:
            self.setWindowFlags(Qt.CustomizeWindowHint | Qt.WindowTitleHint)

        self.setWindowTitle(title)
        self.setStyleSheet('QLabel { margin-right: 25px; }')

        self.bt_yes = None
        if confirmation_button:
            self.bt_yes = self.addButton(
                i18n['popup.button.yes'] if not confirmation_label else
                confirmation_label.capitalize(), QMessageBox.YesRole)
            self.bt_yes.setCursor(QCursor(Qt.PointingHandCursor))
            self.bt_yes.setStyleSheet(css.OK_BUTTON)
            self.setDefaultButton(self.bt_yes)

        if deny_button:
            self.bt_no = self.addButton(
                i18n['popup.button.no'] if not deny_label else
                deny_label.capitalize(), QMessageBox.NoRole)
            self.bt_no.setCursor(QCursor(Qt.PointingHandCursor))

            if not confirmation_button:
                self.bt_no.setStyleSheet(css.OK_BUTTON)
                self.setDefaultButton(self.bt_no)

        label = None
        if body:
            if not components:
                self.setIcon(QMessageBox.Question)
            label = QLabel(body)
            self.layout().addWidget(label, 0, 1)

        width = 0
        if components:
            scroll = QScrollArea(self)
            scroll.setFrameShape(QFrame.NoFrame)
            scroll.setWidgetResizable(True)

            comps_container = QWidget()
            comps_container.setLayout(QVBoxLayout())
            scroll.setWidget(comps_container)

            height = 0

            for idx, comp in enumerate(components):
                inst = to_widget(comp, i18n)
                height += inst.sizeHint().height()

                if inst.sizeHint().width() > width:
                    width = inst.sizeHint().width()

                comps_container.layout().addWidget(inst)

            height = height if height < int(
                screen_size.height() / 2.5) else int(screen_size.height() /
                                                     2.5)

            scroll.setFixedHeight(height)

            self.layout().addWidget(scroll, 1 if body else 0, 1)

            if label and comps_container.sizeHint().width() > label.sizeHint(
            ).width():
                label.setText(label.text() +
                              (' ' * int(comps_container.sizeHint().width() -
                                         label.sizeHint().width())))
        if not body and width > 0:
            self.layout().addWidget(QLabel(' ' * int(width / 2)), 1, 1)

        self.exec_()