02/06/2021

This commit is contained in:
VFX - Visual Effects
2021-06-02 11:38:54 -03:00
parent af70f0e15d
commit 81e09b3fbd
10 changed files with 191 additions and 37 deletions

View File

@@ -32,7 +32,7 @@
<item>
<widget class="QStackedWidget" name="pages">
<property name="currentIndex">
<number>1</number>
<number>0</number>
</property>
<widget class="QWidget" name="menu_1">
<property name="styleSheet">

View File

@@ -32,7 +32,7 @@
<item>
<widget class="QStackedWidget" name="pages">
<property name="currentIndex">
<number>1</number>
<number>0</number>
</property>
<widget class="QWidget" name="menu_1">
<property name="styleSheet">

View File

@@ -32,7 +32,7 @@
<item>
<widget class="QStackedWidget" name="pages">
<property name="currentIndex">
<number>2</number>
<number>0</number>
</property>
<widget class="QWidget" name="page_1">
<property name="styleSheet">

View File

@@ -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
# ///////////////////////////////////////////////////////////////

View File

@@ -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",

View File

@@ -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)

View File

@@ -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

View File

@@ -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):

View File

@@ -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
# ///////////////////////////////////////////////////////////////

78
main.py
View File

@@ -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