19/05/2021

This commit is contained in:
VFX - Visual Effects
2021-05-19 14:29:18 -03:00
parent a5ce102b1a
commit ef930c2ad0
12 changed files with 494 additions and 89 deletions

View File

@@ -28,4 +28,8 @@ from . py_grips import PyGrips
# LEFT MENU
# ///////////////////////////////////////////////////////////////
from . py_left_menu import PyLeftMenu
from . py_left_menu import PyLeftMenu
# PY TITLE BAR
# ///////////////////////////////////////////////////////////////
from . py_title_bar import PyTitleBar

View File

@@ -23,6 +23,10 @@ from qt_core import *
from . py_left_menu_button import PyLeftMenuButton
from . py_div import PyDiv
# IMPORT FUNCTIONS
# ///////////////////////////////////////////////////////////////
from gui.core.functions import *
# PY LEFT MENU
# ///////////////////////////////////////////////////////////////
class PyLeftMenu(QWidget):
@@ -43,12 +47,14 @@ class PyLeftMenu(QWidget):
icon_color_pressed = "#edf0f5",
icon_color_active = "#f5f6f9",
context_color = "#568af2",
text_foreground = "#8a95aa",
text_active = "#dce1ec",
duration_time = 500,
radius = 8,
minimum_width = 50,
maximum_width = 240,
icon_path = "gui/images/svg_icons/icon_menu.svg",
icon_path_close = "gui/images/svg_icons/icon_menu_close.svg",
icon_path = "icon_menu.svg",
icon_path_close = "icon_menu_close.svg",
toggle_text = "Hide Menu",
toggle_tooltip = "Expand/Retract menu"
):
@@ -56,19 +62,23 @@ class PyLeftMenu(QWidget):
# PROPERTIES
# ///////////////////////////////////////////////////////////////
self._bg_dark_one = dark_one,
self._bg_one = bg_one,
self._icon_color = icon_color,
self._icon_color_hover = icon_color_hover,
self._icon_color_pressed = icon_color_pressed,
self._icon_color_active = icon_color_active,
self._dark_one = dark_one
self._dark_three = dark_three
self._dark_four = dark_four
self._bg_one = bg_one
self._icon_color = icon_color
self._icon_color_hover = icon_color_hover
self._icon_color_pressed = icon_color_pressed
self._icon_color_active = icon_color_active
self._context_color = context_color
self._text_foreground = text_foreground
self._text_active = text_active
self._duration_time = duration_time
self._radius = radius
self._minimum_width = minimum_width
self._maximum_width = maximum_width
self._icon_path = icon_path
self._icon_path_close = icon_path_close
self._icon_path = Functions.set_svg_icon(icon_path)
self._icon_path_close = Functions.set_svg_icon(icon_path_close)
# SET PARENT
self._parent = parent
@@ -86,6 +96,17 @@ class PyLeftMenu(QWidget):
app_parent,
text = toggle_text,
tooltip_text = toggle_tooltip,
dark_one = self._dark_one,
dark_three = self._dark_three,
dark_four = self._dark_four,
bg_one = self._bg_one,
icon_color = self._icon_color,
icon_color_hover = self._icon_color_active,
icon_color_pressed = self._icon_color_pressed,
icon_color_active = self._icon_color_active,
context_color = self._context_color,
text_foreground = self._text_foreground,
text_active = self._text_active,
icon_path = icon_path
)
self.toggle_button.clicked.connect(self.toggle_animation)
@@ -124,6 +145,17 @@ class PyLeftMenu(QWidget):
text = _btn_text,
btn_id = _btn_id,
tooltip_text = _btn_tooltip,
dark_one = self._dark_one,
dark_three = self._dark_three,
dark_four = self._dark_four,
bg_one = self._bg_one,
icon_color = self._icon_color,
icon_color_hover = self._icon_color_active,
icon_color_pressed = self._icon_color_pressed,
icon_color_active = self._icon_color_active,
context_color = self._context_color,
text_foreground = self._text_foreground,
text_active = self._text_active,
icon_path = _btn_icon,
is_active = _is_active
)
@@ -148,6 +180,7 @@ class PyLeftMenu(QWidget):
# EXPAND / RETRACT LEF MENU
# ///////////////////////////////////////////////////////////////
def toggle_animation(self):
# SELECT TOGGLE WHEN EXPANDED
if self.toggle_button._is_toggle_active:
self.toggle_button.set_active_toggle(False)
self.toggle_button.set_icon(self._icon_path)
@@ -155,6 +188,7 @@ class PyLeftMenu(QWidget):
self.toggle_button.set_active_toggle(True)
self.toggle_button.set_icon(self._icon_path_close)
# CREATE ANIMATION
self.animation = QPropertyAnimation(self._parent, b"minimumWidth")
self.animation.stop()
if self.width() == self._minimum_width:
@@ -168,7 +202,7 @@ class PyLeftMenu(QWidget):
self.animation.start()
# SET APP LAYOUT
# SETUP APP
# ///////////////////////////////////////////////////////////////
def setup_ui(self):
# ADD MENU LAYOUT

View File

@@ -22,6 +22,10 @@ import os
# ///////////////////////////////////////////////////////////////
from qt_core import *
# IMPORT FUNCTIONS
# ///////////////////////////////////////////////////////////////
from gui.core.functions import *
# CUSTOM LEFT MENU
# ///////////////////////////////////////////////////////////////
class PyLeftMenuButton(QPushButton):
@@ -43,8 +47,8 @@ class PyLeftMenuButton(QPushButton):
context_color = "#568af2",
text_foreground = "#8a95aa",
text_active = "#dce1ec",
icon_path = "gui/images/svg_icons/icon_add_user.svg",
icon_active_menu = "gui/images/svg_icons/active_menu.svg",
icon_path = "icon_add_user.svg",
icon_active_menu = "active_menu.svg",
is_active = False,
is_toggle_active = False
):
@@ -56,8 +60,8 @@ class PyLeftMenuButton(QPushButton):
self.setObjectName(btn_id)
# APP PATH
app_path = os.path.abspath(os.getcwd())
self._icon_path = os.path.normpath(os.path.join(app_path, icon_path))
self._icon_path = Functions.set_svg_icon(icon_path)
self._icon_active_menu = Functions.set_svg_icon(icon_active_menu)
# PROPERTIES
self._margin = margin
@@ -70,7 +74,6 @@ class PyLeftMenuButton(QPushButton):
self._icon_color_hover = icon_color_hover
self._icon_color_pressed = icon_color_pressed
self._icon_color_active = icon_color_active
self._icon_active_menu = icon_active_menu
self._set_icon_color = self._icon_color # Set icon color
self._set_bg_color = self._dark_one # Set BG color
self._set_text_foreground = text_foreground
@@ -108,10 +111,6 @@ class PyLeftMenuButton(QPushButton):
rect_inside_active = QRect(7, 5, self.width(), self.height() - 10)
rect_text = QRect(45, 0, self.width() - 50, self.height())
# DRAW DEFAULT BG
p.setBrush(QColor(self._dark_one))
p.drawRoundedRect(rect, 0, 0)
if self._is_active:
# DRAW BG BLUE
p.setBrush(QColor(self._context_color))

View File

@@ -0,0 +1,21 @@
# ///////////////////////////////////////////////////////////////
#
# 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
#
# ///////////////////////////////////////////////////////////////
# PY TITLE BAR
# Top bar with move application, maximize, restore, minimize,
# close buttons and extra buttons
# ///////////////////////////////////////////////////////////////
from . py_title_bar import PyTitleBar

View File

@@ -0,0 +1,113 @@
# ///////////////////////////////////////////////////////////////
#
# 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 *
# IMPORT FUNCTIONS
# ///////////////////////////////////////////////////////////////
from gui.core.functions import *
# IMPORT SETTINGS
# ///////////////////////////////////////////////////////////////
from gui.core.json_settings import Settings
# PY TITLE BAR
# Top bar with move application, maximize, restore, minimize,
# close buttons and extra buttons
# ///////////////////////////////////////////////////////////////
class PyTitleBar(QWidget):
def __init__(
self,
parent,
logo_image = "logo_top_100x22.svg",
logo_width = 100,
buttons = None,
bg_color = "#343b48",
radius = 8
):
super(PyTitleBar, self).__init__()
settings = Settings()
self.settings = settings.items
# SETUP UI
self.setup_ui()
# ADD BG COLOR
self.bg.setStyleSheet(f"background-color: {bg_color}; border-radius: {radius}px;")
# SET LOGO AND WIDTH
self.top_logo.setMinimumWidth(logo_width)
self.top_logo.setMaximumWidth(logo_width)
self.top_logo.setPixmap(Functions.set_svg_image(logo_image))
# ADD TITLE TEXT
self.title_label.setText(self.settings["app_name"])
# MOVE WINDOW / MAXIMIZE / RESTORE
def moveWindow(event):
# IF MAXIMIZED CHANGE TO NORMAL
# if self.isMaximized():
# UiFunctions.maximize_restore(self)
# self.resize(_old_size)
# curso_x = self.pos().x()
# curso_y = event.globalPos().y() - QCursor.pos().y()
# self.move(curso_x, curso_y)
# MOVE WINDOW
if event.buttons() == Qt.LeftButton:
parent.move(parent.pos() + event.globalPos() - parent.dragPos)
parent.dragPos = event.globalPos()
event.accept()
self.top_logo.mouseMoveEvent = moveWindow
self.title_label.mouseMoveEvent = moveWindow
# ADD WIDGETS TO TITLE BAR
self.bg_layout.addWidget(self.top_logo)
self.bg_layout.addWidget(self.title_label)
self.bg_layout.addWidget(self.right_frame)
# SETUP APP
# ///////////////////////////////////////////////////////////////
def setup_ui(self):
# ADD MENU LAYOUT
self.title_bar_layout = QVBoxLayout(self)
self.title_bar_layout.setContentsMargins(0,0,0,0)
# ADD BG
self.bg = QFrame()
# ADD BG LAYOUT
self.bg_layout = QHBoxLayout(self.bg)
self.bg_layout.setContentsMargins(10,0,0,0)
self.bg_layout.setSpacing(0)
# LEFT FRAME WITH MOVE APP
self.top_logo = QLabel()
# TITLE LABEL
self.title_label = QLabel()
self.title_label.setAlignment(Qt.AlignVCenter)
self.title_label.setStyleSheet("padding-left: 10px; font-size: 10pt")
# RIGHT FRAME WITH BUTTONS
self.right_frame = QFrame()
self.right_frame.setMinimumWidth(100)
self.right_frame.setStyleSheet("background: #CCC")
# ADD TO LAYOUT
self.title_bar_layout.addWidget(self.bg)