Exemplo n.º 1
0
    def __init__(
        self,
        jobs_ctx: QtToTrioJobScheduler,
        event_bus: EventBus,
        config: CoreConfig,
        minimize_on_close: bool = False,
        **kwargs: object,
    ):
        super().__init__(**kwargs)
        self.setupUi(self)

        self.setMenuBar(None)
        self.jobs_ctx = jobs_ctx
        self.event_bus = event_bus
        self.config = config
        self.minimize_on_close = minimize_on_close
        # Explain only once that the app stays in background
        self.minimize_on_close_notif_already_send = False
        self.force_close = False
        self.need_close = False
        self.event_bus.connect(
            CoreEvent.GUI_CONFIG_CHANGED, cast(EventCallback, self.on_config_updated)
        )
        self.setWindowTitle(_("TEXT_PARSEC_WINDOW_TITLE_version").format(version=PARSEC_VERSION))
        self.foreground_needed.connect(self._on_foreground_needed)
        self.new_instance_needed.connect(self._on_new_instance_needed)
        self.tab_center.tabCloseRequested.connect(self.close_tab)

        self.menu_button = Button()
        self.menu_button.setCursor(Qt.PointingHandCursor)
        self.menu_button.setIcon(QIcon(":/icons/images/material/menu.svg"))
        self.menu_button.setIconSize(QSize(24, 24))
        self.menu_button.setText(_("ACTION_MAIN_MENU_SHOW"))
        self.menu_button.setObjectName("MenuButton")
        self.menu_button.setProperty("color", QColor(0x00, 0x92, 0xFF))
        self.menu_button.setProperty("hover_color", QColor(0x00, 0x70, 0xDD))
        self.menu_button.setStyleSheet(
            "#MenuButton {background: none; border: none; color: #0092FF;}"
            "#MenuButton:hover {color: #0070DD;}"
        )
        self.menu_button.apply_style()
        self.menu_button.clicked.connect(self._show_menu)
        self.tab_center.setCornerWidget(self.menu_button, Qt.TopRightCorner)

        self.add_tab_button = Button()
        self.add_tab_button.setCursor(Qt.PointingHandCursor)
        self.add_tab_button.setIcon(QIcon(":/icons/images/material/add.svg"))
        self.add_tab_button.setIconSize(QSize(24, 24))
        self.add_tab_button.setProperty("color", QColor(0x00, 0x92, 0xFF))
        self.add_tab_button.setProperty("hover_color", QColor(0x00, 0x70, 0xDD))
        self.add_tab_button.setStyleSheet("background: none; border: none;")
        self.add_tab_button.apply_style()
        self.add_tab_button.clicked.connect(self._on_add_instance_clicked)
        self.tab_center.setCornerWidget(self.add_tab_button, Qt.TopLeftCorner)

        self.tab_center.currentChanged.connect(self.on_current_tab_changed)
        self._define_shortcuts()
        self.ensurePolished()
Exemplo n.º 2
0
    def __init__(self,
                 jobs_ctx,
                 event_bus,
                 config,
                 minimize_on_close: bool = False,
                 **kwargs):
        super().__init__(**kwargs)
        self.setupUi(self)

        self.setMenuBar(None)
        self.jobs_ctx = jobs_ctx
        self.event_bus = event_bus
        self.config = config
        self.minimize_on_close = minimize_on_close
        self.force_close = False
        self.need_close = False
        self.event_bus.connect("gui.config.changed", self.on_config_updated)
        self.setWindowTitle(
            _("TEXT_PARSEC_WINDOW_TITLE_version").format(
                version=PARSEC_VERSION))
        self.foreground_needed.connect(self._on_foreground_needed)
        self.new_instance_needed.connect(self._on_new_instance_needed)
        self.tab_center.tabCloseRequested.connect(self.close_tab)
        # self.button_send_feedback = QPushButton(_("ACTION_FEEDBACK_SEND"))
        # self.button_send_feedback.clicked.connect(self._on_send_feedback_clicked)
        # self.button_send_feedback.setStyleSheet("border: 0; border-radius: 0px;")
        # self.tab_center.setCornerWidget(self.button_send_feedback, Qt.TopRightCorner)

        self.menu_button = Button()
        self.menu_button.setCursor(Qt.PointingHandCursor)
        self.menu_button.setIcon(QIcon(":/icons/images/material/menu.svg"))
        self.menu_button.setIconSize(QSize(24, 24))
        self.menu_button.setText(_("ACTION_MAIN_MENU_SHOW"))
        self.menu_button.setObjectName("MenuButton")
        self.menu_button.setProperty("color", QColor(0x00, 0x92, 0xFF))
        self.menu_button.setProperty("hover_color", QColor(0x00, 0x70, 0xDD))
        self.menu_button.setStyleSheet(
            "#MenuButton {background: none; border: none; color: #0092FF;}"
            "#MenuButton:hover {color: #0070DD;}")
        self.menu_button.apply_style()
        self.menu_button.clicked.connect(self._show_menu)
        self.tab_center.setCornerWidget(self.menu_button, Qt.TopRightCorner)

        self.add_tab_button = Button()
        self.add_tab_button.setCursor(Qt.PointingHandCursor)
        self.add_tab_button.setIcon(QIcon(":/icons/images/material/add.svg"))
        self.add_tab_button.setIconSize(QSize(24, 24))
        self.add_tab_button.setProperty("color", QColor(0x00, 0x92, 0xFF))
        self.add_tab_button.setProperty("hover_color",
                                        QColor(0x00, 0x70, 0xDD))
        self.add_tab_button.setStyleSheet("background: none; border: none;")
        self.add_tab_button.apply_style()
        self.add_tab_button.clicked.connect(self._on_add_instance_clicked)
        self.tab_center.setCornerWidget(self.add_tab_button, Qt.TopLeftCorner)

        self.tab_center.currentChanged.connect(self.on_current_tab_changed)
        self._define_shortcuts()
        self.ensurePolished()
Exemplo n.º 3
0
    def __init__(self,
                 message,
                 button_texts,
                 radio_mode=False,
                 oriented_question=False,
                 dangerous_yes=False):
        super().__init__()
        self.setupUi(self)
        self.status = None
        self.dialog = None
        self.label_message.setText(message)

        if oriented_question:
            yes_text, no_text = button_texts
            assert not radio_mode

            # Add "no" button
            b = Button(no_text)
            b.clicked_self.connect(self._on_button_clicked)
            b.setCursor(Qt.PointingHandCursor)
            b.setStyleSheet(
                "QPushButton {background-color: darkgrey;} QPushButton:hover {background-color: grey;}"
            )
            self.layout_buttons.addWidget(b)

            # Add "yes" button
            b = Button(yes_text)
            b.clicked_self.connect(self._on_button_clicked)
            b.setCursor(Qt.PointingHandCursor)
            if dangerous_yes:
                b.setStyleSheet(
                    "QPushButton {background-color: red;} QPushButton:hover {background-color: darkred;}"
                )
            self.layout_buttons.addWidget(b)

        else:
            assert not dangerous_yes
            for text in button_texts:
                b = Button(text)
                b.clicked_self.connect(self._on_button_clicked)
                b.setCursor(Qt.PointingHandCursor)
                if radio_mode:
                    self.layout_radios.addWidget(b)
                else:
                    self.layout_buttons.insertWidget(1, b)
Exemplo n.º 4
0
 def __init__(self, message, button_texts):
     super().__init__()
     self.setupUi(self)
     self.status = None
     self.dialog = None
     self.label_message.setText(message)
     for text in button_texts:
         b = Button(text)
         b.clicked_self.connect(self._on_button_clicked)
         b.setCursor(Qt.PointingHandCursor)
         self.layout_buttons.insertWidget(1, b)