From 640b63fcf0ac02a0988953938eb138674f07dd1e Mon Sep 17 00:00:00 2001 From: VFX - Visual Effects Date: Sun, 23 May 2021 09:00:26 -0300 Subject: [PATCH] 23/05/2021 --- .../windows/main_window/setup_main_window.py | 4 +-- gui/widgets/py_title_bar/py_title_button.py | 25 ++++++++++++++++--- main.py | 9 ++++++- 3 files changed, 32 insertions(+), 6 deletions(-) diff --git a/gui/uis/windows/main_window/setup_main_window.py b/gui/uis/windows/main_window/setup_main_window.py index a2aec45..65e933a 100644 --- a/gui/uis/windows/main_window/setup_main_window.py +++ b/gui/uis/windows/main_window/setup_main_window.py @@ -109,10 +109,10 @@ class SetupMainWindow: "is_active" : False }, { - "btn_icon" : "icon_more_options.svg", + "btn_icon" : "icon_settings.svg", "btn_id" : "btn_top_settings", "btn_tooltip" : "Top settings", - "is_active" : False + "is_active" : True } ] diff --git a/gui/widgets/py_title_bar/py_title_button.py b/gui/widgets/py_title_bar/py_title_button.py index 57a55f5..9d4202c 100644 --- a/gui/widgets/py_title_bar/py_title_button.py +++ b/gui/widgets/py_title_bar/py_title_button.py @@ -60,6 +60,7 @@ class PyTitleButton(QPushButton): self._icon_color_active = icon_color_active self._context_color = context_color self._top_margin = self.height() + 6 + self._is_active = is_active # Set Parameters self._set_bg_color = bg_color self._set_icon_path = icon_path @@ -80,6 +81,17 @@ class PyTitleButton(QPushButton): ) self._tooltip.hide() + # SET ACTIVE MENU + # /////////////////////////////////////////////////////////////// + def set_active(self, is_active): + self._is_active = is_active + self.repaint() + + # RETURN IF IS ACTIVE MENU + # /////////////////////////////////////////////////////////////// + def is_active(self): + return self._is_active + # PAINT EVENT # painting the button and the icon # /////////////////////////////////////////////////////////////// @@ -89,8 +101,12 @@ class PyTitleButton(QPushButton): paint.begin(self) paint.setRenderHint(QPainter.RenderHint.Antialiasing) - # BRUSH - brush = QBrush(QColor(self._set_bg_color)) + if self._is_active: + # BRUSH + brush = QBrush(QColor(self._bg_color_pressed)) + else: + # BRUSH + brush = QBrush(QColor(self._set_bg_color)) # CREATE RECTANGLE rect = QRect(0, 0, self.width(), self.height()) @@ -171,7 +187,10 @@ class PyTitleButton(QPushButton): icon = QPixmap(image) painter = QPainter(icon) painter.setCompositionMode(QPainter.CompositionMode_SourceIn) - painter.fillRect(icon.rect(), self._set_icon_color) + if self._is_active: + painter.fillRect(icon.rect(), self._context_color) + else: + painter.fillRect(icon.rect(), self._set_icon_color) qp.drawPixmap( (rect.width() - icon.width()) / 2, (rect.height() - icon.height()) / 2, diff --git a/main.py b/main.py index 2442d95..25965da 100644 --- a/main.py +++ b/main.py @@ -85,7 +85,6 @@ class MainWindow(QMainWindow): self.ui.title_bar.set_title(self.settings["app_name"]) else: self.ui.title_bar.set_title("Welcome to PyOneDark") - # SHOW MAIN WINDOW @@ -100,12 +99,20 @@ class MainWindow(QMainWindow): # GET BT CLICKED btn = SetupMainWindow.setup_btns(self) + # LEFT MENU # SELECT / DESELECT BTN HOME if btn.objectName() == "btn_home": if btn.is_active(): btn.set_active(False) else: btn.set_active(True) + + # TITLE BAR MENU + if btn.objectName() == "btn_top_settings": + if btn.is_active(): + btn.set_active(False) + else: + btn.set_active(True) # DEBUG print(f"Button {btn.objectName()}, clicked!")