diff --git a/gui/uis/columns/left_column.ui b/gui/uis/columns/left_column.ui index 63bf588..e51b83f 100644 --- a/gui/uis/columns/left_column.ui +++ b/gui/uis/columns/left_column.ui @@ -32,7 +32,7 @@ - 1 + 0 diff --git a/gui/uis/columns/right_column.ui b/gui/uis/columns/right_column.ui index 7bc15e2..4b2c8c7 100644 --- a/gui/uis/columns/right_column.ui +++ b/gui/uis/columns/right_column.ui @@ -32,7 +32,7 @@ - 1 + 0 diff --git a/gui/uis/pages/main_pages.ui b/gui/uis/pages/main_pages.ui index 44e31fa..c0da5c7 100644 --- a/gui/uis/pages/main_pages.ui +++ b/gui/uis/pages/main_pages.ui @@ -32,7 +32,7 @@ - 2 + 0 diff --git a/gui/uis/windows/main_window/functions_main_window.py b/gui/uis/windows/main_window/functions_main_window.py index 2fb25ee..ad7d970 100644 --- a/gui/uis/windows/main_window/functions_main_window.py +++ b/gui/uis/windows/main_window/functions_main_window.py @@ -51,7 +51,7 @@ class MainFunctions(): ): self.ui.left_column.menus.pages.setCurrentWidget(menu) self.ui.left_column.title_label.setText(title) - self.ui.left_column.icon.load(icon_path) + self.ui.left_column.icon.set_icon(icon_path) # RETURN IF LEFT COLUMN IS VISIBLE # /////////////////////////////////////////////////////////////// diff --git a/gui/uis/windows/main_window/setup_main_window.py b/gui/uis/windows/main_window/setup_main_window.py index 1b04edf..c3c6a9e 100644 --- a/gui/uis/windows/main_window/setup_main_window.py +++ b/gui/uis/windows/main_window/setup_main_window.py @@ -100,6 +100,14 @@ class SetupMainWindow: "show_top" : True, "is_active" : False }, + { + "btn_icon" : "icon_widgets.svg", + "btn_id" : "btn_info", + "btn_text" : "Information", + "btn_tooltip" : "Open informations", + "show_top" : False, + "is_active" : False + }, { "btn_icon" : "icon_settings.svg", "btn_id" : "btn_settings", diff --git a/gui/widgets/py_left_column/py_icon.py b/gui/widgets/py_left_column/py_icon.py new file mode 100644 index 0000000..53055c1 --- /dev/null +++ b/gui/widgets/py_left_column/py_icon.py @@ -0,0 +1,70 @@ +# /////////////////////////////////////////////////////////////// +# +# BY: WANDERSON M.PIMENTA +# PROJECT MADE WITH: Qt Designer and PySide6 +# V: 1.0.0 +# +# This project can be used freely for all uses, as long as they maintain the +# respective credits only in the Python scripts, any information in the visual +# interface (GUI) can be modified without any implication. +# +# There are limitations on Qt licenses if you want to use your products +# commercially, I recommend reading them on the official website: +# https://doc.qt.io/qtforpython/licenses.html +# +# /////////////////////////////////////////////////////////////// + +# IMPORT QT CORE +# /////////////////////////////////////////////////////////////// +from qt_core import * + +# PY ICON WITH CUSTOM COLORS +# /////////////////////////////////////////////////////////////// +class PyIcon(QWidget): + def __init__( + self, + icon_path, + icon_color + ): + super().__init__() + + # PROPERTIES + self._icon_path = icon_path + self._icon_color = icon_color + + # SETUP UI + self.setup_ui() + + def setup_ui(self): + # LAYOUT + self.layout = QVBoxLayout(self) + self.layout.setContentsMargins(0,0,0,0) + + # LABEL + self.icon = QLabel() + self.icon.setAlignment(Qt.AlignCenter) + + # PAINTER + self.set_icon(self._icon_path, self._icon_color) + + # ADD TO LAYOUT + self.layout.addWidget(self.icon) + + def set_icon(self, icon_path, icon_color = None): + # GET COLOR + color = "" + if icon_color != None: + color = icon_color + else: + color = self._icon_color + + # PAINTER / PIXMAP + icon = QPixmap(icon_path) + painter = QPainter(icon) + painter.setCompositionMode(QPainter.CompositionMode_SourceIn) + painter.fillRect(icon.rect(), color) + painter.end() + + # SET PIXMAP + self.icon.setPixmap(icon) + diff --git a/gui/widgets/py_left_column/py_left_column.py b/gui/widgets/py_left_column/py_left_column.py index 20b0f83..ae6a07a 100644 --- a/gui/widgets/py_left_column/py_left_column.py +++ b/gui/widgets/py_left_column/py_left_column.py @@ -22,6 +22,10 @@ from qt_core import * # /////////////////////////////////////////////////////////////// from . py_left_button import * +# IMPORT ICON +# /////////////////////////////////////////////////////////////// +from . py_icon import * + # IMPORT LEFT COLUMN # /////////////////////////////////////////////////////////////// from gui.uis.columns.ui_left_column import Ui_LeftColumn @@ -120,6 +124,7 @@ class PyLeftColumn(QWidget): # LAYOUT TITLE BG self.title_bg_layout = QHBoxLayout(self.title_bg_frame) self.title_bg_layout.setContentsMargins(5,5,5,5) + self.title_bg_layout.setSpacing(3) # ICON self.icon_frame = QFrame() @@ -128,7 +133,7 @@ class PyLeftColumn(QWidget): self.icon_layout = QVBoxLayout(self.icon_frame) self.icon_layout.setContentsMargins(0,0,0,0) self.icon_layout.setSpacing(5) - self.icon = QSvgWidget(self._icon_path) + self.icon = PyIcon(self._icon_path, self._icon_color) self.icon_layout.addWidget(self.icon, Qt.AlignCenter, Qt.AlignCenter) # LABEL diff --git a/gui/widgets/py_left_menu/py_left_menu.py b/gui/widgets/py_left_menu/py_left_menu.py index 6f117a3..017a2e3 100644 --- a/gui/widgets/py_left_menu/py_left_menu.py +++ b/gui/widgets/py_left_menu/py_left_menu.py @@ -202,12 +202,27 @@ class PyLeftMenu(QWidget): else: btn.set_active(False) + # SELECT ONLY ONE TAB BTN + # /////////////////////////////////////////////////////////////// + def select_only_one_tab(self, widget: str): + for btn in self.findChildren(QPushButton): + if btn.objectName() == widget: + btn.set_active_tab(True) + else: + btn.set_active_tab(False) + # DESELECT ALL BTNs # /////////////////////////////////////////////////////////////// def deselect_all(self): for btn in self.findChildren(QPushButton): btn.set_active(False) + # DESELECT ALL TAB BTNs + # /////////////////////////////////////////////////////////////// + def deselect_all_tab(self): + for btn in self.findChildren(QPushButton): + btn.set_active_tab(False) + # SETUP APP # /////////////////////////////////////////////////////////////// def setup_ui(self): diff --git a/gui/widgets/py_left_menu/py_left_menu_button.py b/gui/widgets/py_left_menu/py_left_menu_button.py index 3651aff..1595284 100644 --- a/gui/widgets/py_left_menu/py_left_menu_button.py +++ b/gui/widgets/py_left_menu/py_left_menu_button.py @@ -50,6 +50,7 @@ class PyLeftMenuButton(QPushButton): icon_path = "icon_add_user.svg", icon_active_menu = "active_menu.svg", is_active = False, + is_active_tab = False, is_toggle_active = False ): super().__init__() @@ -80,6 +81,7 @@ class PyLeftMenuButton(QPushButton): self._set_text_active = text_active self._parent = app_parent self._is_active = is_active + self._is_active_tab = is_active_tab self._is_toggle_active = is_toggle_active # TOOLTIP @@ -134,6 +136,29 @@ class PyLeftMenuButton(QPushButton): # DRAW ICONS self.icon_paint(p, self._icon_path, rect_icon, self._set_icon_color) + elif self._is_active_tab: + # DRAW BG BLUE + p.setBrush(QColor(self._dark_four)) + p.drawRoundedRect(rect_blue, 8, 8) + + # BG INSIDE + p.setBrush(QColor(self._bg_one)) + p.drawRoundedRect(rect_inside_active, 8, 8) + + # DRAW ACTIVE + icon_path = self._icon_active_menu + app_path = os.path.abspath(os.getcwd()) + icon_path = os.path.normpath(os.path.join(app_path, icon_path)) + self._set_icon_color = self._icon_color_active + self.icon_active(p, icon_path, self.width()) + + # DRAW TEXT + p.setPen(QColor(self._set_text_active)) + p.drawText(rect_text, Qt.AlignVCenter, self.text()) + + # DRAW ICONS + self.icon_paint(p, self._icon_path, rect_icon, self._set_icon_color) + # NORMAL BG else: if self._is_toggle_active: @@ -170,14 +195,29 @@ class PyLeftMenuButton(QPushButton): self._is_active = is_active if not is_active: self._set_icon_color = self._icon_color - if not is_active: self._set_bg_color = self._dark_one + + self.repaint() + + # SET ACTIVE TAB MENU + # /////////////////////////////////////////////////////////////// + def set_active_tab(self, is_active): + self._is_active_tab = is_active + if not is_active: + self._set_icon_color = self._icon_color + self._set_bg_color = self._dark_one + self.repaint() # RETURN IF IS ACTIVE MENU # /////////////////////////////////////////////////////////////// def is_active(self): return self._is_active + + # RETURN IF IS ACTIVE TAB MENU + # /////////////////////////////////////////////////////////////// + def is_active_tab(self): + return self._is_active_tab # SET ACTIVE TOGGLE # /////////////////////////////////////////////////////////////// diff --git a/main.py b/main.py index 5040653..6fe162b 100644 --- a/main.py +++ b/main.py @@ -115,6 +115,14 @@ class MainWindow(QMainWindow): # GET BT CLICKED btn = SetupMainWindow.setup_btns(self) + # Remove Selection If Clicked By "btn_close_left_column" + if btn.objectName() != "btn_settings": + self.ui.left_menu.deselect_all_tab() + + # Get Title Bar Btn And Reset Active + top_settings = MainFunctions.get_title_bar_btn(self, "btn_top_settings") + top_settings.set_active(False) + # LEFT MENU # /////////////////////////////////////////////////////////////// @@ -143,44 +151,54 @@ class MainWindow(QMainWindow): # Load Page 3 MainFunctions.set_page(self, self.ui.load_pages.page_3) + # Load Information + if btn.objectName() == "btn_info": + # CHECK IF LEFT COLUMN IS VISIBLE + if not MainFunctions.left_column_is_visible(self): + self.ui.left_menu.select_only_one_tab(btn.objectName()) + + # Show / Hide + MainFunctions.toggle_left_column(self) + self.ui.left_menu.select_only_one_tab(btn.objectName()) + else: + if btn.objectName() == "btn_close_left_column": + self.ui.left_menu.deselect_all_tab() + # Show / Hide + MainFunctions.toggle_left_column(self) + + self.ui.left_menu.select_only_one_tab(btn.objectName()) + # Change Left Column Menu - MainFunctions.set_left_column_menu( - self, - menu = self.ui.left_column.menus.menu_2, - title = "Add Users", - icon_path = Functions.set_svg_icon("icon_settings.svg") - ) + if btn.objectName() != "btn_close_left_column": + MainFunctions.set_left_column_menu( + self, + menu = self.ui.left_column.menus.menu_2, + title = "Add Users", + icon_path = Functions.set_svg_icon("icon_home.svg") + ) # Settings Left if btn.objectName() == "btn_settings" or btn.objectName() == "btn_close_left_column": - # Toogle Active + # CHECK IF LEFT COLUMN IS VISIBLE if not MainFunctions.left_column_is_visible(self): - btn.set_active(True) - # Show / Hide MainFunctions.toggle_left_column(self) + self.ui.left_menu.select_only_one_tab(btn.objectName()) else: - btn.set_active(False) - - # Show / Hide - MainFunctions.toggle_left_column(self) - - # Remove Selection If Clicked By "btn_close_left_column" - if btn.objectName() != "btn_settings": - btn_settings = MainFunctions.get_left_menu_btn(self, "btn_settings") - btn_settings.set_active(False) - - # Get Title Bar Btn - top_settings = MainFunctions.get_title_bar_btn(self, "btn_top_settings") - top_settings.set_active(False) + if btn.objectName() == "btn_close_left_column": + self.ui.left_menu.deselect_all_tab() + # Show / Hide + MainFunctions.toggle_left_column(self) + self.ui.left_menu.select_only_one_tab(btn.objectName()) # Change Left Column Menu - MainFunctions.set_left_column_menu( - self, - menu = self.ui.left_column.menus.menu_1, - title = "Settings Left Column", - icon_path = Functions.set_svg_icon("icon_settings.svg") - ) + if btn.objectName() != "btn_close_left_column": + MainFunctions.set_left_column_menu( + self, + menu = self.ui.left_column.menus.menu_1, + title = "Settings Left Column", + icon_path = Functions.set_svg_icon("icon_settings.svg") + ) # TITLE BAR MENU # /////////////////////////////////////////////////////////////// @@ -199,9 +217,7 @@ class MainWindow(QMainWindow): # Get Left Menu Btn top_settings = MainFunctions.get_left_menu_btn(self, "btn_settings") - top_settings.set_active(False) - - + top_settings.set_active_tab(False) # DEBUG