mirror of
https://github.com/Wanderson-Magalhaes/PyOneDark_Qt_Widgets_Modern_GUI.git
synced 2026-07-15 05:14:54 +00:00
21/05/2021
This commit is contained in:
@@ -55,7 +55,7 @@ class SetupMainWindow:
|
|||||||
"btn_text" : "Open Widgets",
|
"btn_text" : "Open Widgets",
|
||||||
"btn_tooltip" : "Show custom widgets",
|
"btn_tooltip" : "Show custom widgets",
|
||||||
"show_top" : True,
|
"show_top" : True,
|
||||||
"is_active" : False
|
"is_active" : True
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"btn_icon" : "icon_add_user.svg",
|
"btn_icon" : "icon_add_user.svg",
|
||||||
|
|||||||
@@ -162,10 +162,23 @@ class UI_MainWindow(object):
|
|||||||
# ADD CUSTOM TITLE BAR TO LAYOUT
|
# ADD CUSTOM TITLE BAR TO LAYOUT
|
||||||
self.title_bar = PyTitleBar(
|
self.title_bar = PyTitleBar(
|
||||||
parent,
|
parent,
|
||||||
|
app_parent = self.central_widget,
|
||||||
|
logo_image = "logo_top_100x22.svg",
|
||||||
bg_color = self.themes["app_color"]["bg_two"],
|
bg_color = self.themes["app_color"]["bg_two"],
|
||||||
div_color = self.themes["app_color"]["bg_three"],
|
div_color = self.themes["app_color"]["bg_three"],
|
||||||
|
btn_bg_color = self.themes["app_color"]["bg_two"],
|
||||||
|
btn_bg_color_hover = self.themes["app_color"]["bg_three"],
|
||||||
|
btn_bg_color_pressed = self.themes["app_color"]["bg_one"],
|
||||||
|
icon_color = self.themes["app_color"]["icon_color"],
|
||||||
|
icon_color_hover = self.themes["app_color"]["icon_hover"],
|
||||||
|
icon_color_pressed = self.themes["app_color"]["icon_pressed"],
|
||||||
|
icon_color_active = self.themes["app_color"]["icon_active"],
|
||||||
|
context_color = self.themes["app_color"]["context_color"],
|
||||||
|
dark_one = self.themes["app_color"]["dark_one"],
|
||||||
|
text_foreground = self.themes["app_color"]["text_foreground"],
|
||||||
|
radius = 8,
|
||||||
font_family = self.settings["font"]["family"],
|
font_family = self.settings["font"]["family"],
|
||||||
title_size = self.settings["font"]["title_size"]
|
title_size = self.settings["font"]["title_size"],
|
||||||
)
|
)
|
||||||
self.title_bar_layout.addWidget(self.title_bar)
|
self.title_bar_layout.addWidget(self.title_bar)
|
||||||
|
|
||||||
|
|||||||
@@ -30,8 +30,8 @@ from gui.core.functions import *
|
|||||||
# PY LEFT MENU
|
# PY LEFT MENU
|
||||||
# ///////////////////////////////////////////////////////////////
|
# ///////////////////////////////////////////////////////////////
|
||||||
class PyLeftMenu(QWidget):
|
class PyLeftMenu(QWidget):
|
||||||
clicked = Signal(str)
|
clicked = Signal(object)
|
||||||
released = Signal(str)
|
released = Signal(object)
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
|
|||||||
@@ -47,9 +47,11 @@ class PyTitleBar(QWidget):
|
|||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
parent,
|
parent,
|
||||||
|
app_parent,
|
||||||
logo_image = "logo_top_100x22.svg",
|
logo_image = "logo_top_100x22.svg",
|
||||||
logo_width = 100,
|
logo_width = 100,
|
||||||
buttons = None,
|
buttons = None,
|
||||||
|
dark_one = "#1b1e23",
|
||||||
bg_color = "#343b48",
|
bg_color = "#343b48",
|
||||||
div_color = "#3c4454",
|
div_color = "#3c4454",
|
||||||
btn_bg_color = "#343b48",
|
btn_bg_color = "#343b48",
|
||||||
@@ -60,6 +62,7 @@ class PyTitleBar(QWidget):
|
|||||||
icon_color_pressed = "#edf0f5",
|
icon_color_pressed = "#edf0f5",
|
||||||
icon_color_active = "#f5f6f9",
|
icon_color_active = "#f5f6f9",
|
||||||
context_color = "#6c99f4",
|
context_color = "#6c99f4",
|
||||||
|
text_foreground = "#8a95aa",
|
||||||
radius = 8,
|
radius = 8,
|
||||||
font_family = "Segoe UI",
|
font_family = "Segoe UI",
|
||||||
title_size = 10
|
title_size = 10
|
||||||
@@ -70,19 +73,22 @@ class PyTitleBar(QWidget):
|
|||||||
self.settings = settings.items
|
self.settings = settings.items
|
||||||
|
|
||||||
# PARAMETERS
|
# PARAMETERS
|
||||||
|
self._dark_one = dark_one
|
||||||
self._bg_color = bg_color
|
self._bg_color = bg_color
|
||||||
self._div_color = div_color
|
self._div_color = div_color
|
||||||
self._font_family = font_family
|
|
||||||
self._title_size = title_size
|
|
||||||
self._parent = parent
|
self._parent = parent
|
||||||
|
self._app_parent = app_parent
|
||||||
self._btn_bg_color = btn_bg_color
|
self._btn_bg_color = btn_bg_color
|
||||||
self._btn_bg_color_hover = btn_bg_color_hover
|
self._btn_bg_color_hover = btn_bg_color_hover
|
||||||
self._btn_bg_color_pressed = btn_bg_color_pressed
|
self._btn_bg_color_pressed = btn_bg_color_pressed
|
||||||
self._context_color = context_color
|
self._context_color = context_color
|
||||||
self._icon_color = icon_color
|
self._icon_color = icon_color
|
||||||
self._icon_color_hover = icon_color_hover
|
self._icon_color_hover = icon_color_hover
|
||||||
self._icon_color_pressed = icon_color_pressed
|
self._icon_color_pressed = icon_color_pressed
|
||||||
self._icon_color_active = icon_color_active
|
self._icon_color_active = icon_color_active
|
||||||
|
self._font_family = font_family
|
||||||
|
self._title_size = title_size
|
||||||
|
self._text_foreground = text_foreground
|
||||||
|
|
||||||
# SETUP UI
|
# SETUP UI
|
||||||
self.setup_ui()
|
self.setup_ui()
|
||||||
@@ -136,9 +142,9 @@ class PyTitleBar(QWidget):
|
|||||||
# ADD BUTTONS BUTTONS
|
# ADD BUTTONS BUTTONS
|
||||||
# ///////////////////////////////////////////////////////////////
|
# ///////////////////////////////////////////////////////////////
|
||||||
# Functions
|
# Functions
|
||||||
self.minimize_button.clicked.connect(lambda: parent.showMinimized())
|
self.minimize_button.released.connect(lambda: parent.showMinimized())
|
||||||
self.maximize_restore_button.clicked.connect(lambda: self.maximize_restore())
|
self.maximize_restore_button.released.connect(lambda: self.maximize_restore())
|
||||||
self.close_button.clicked.connect(lambda: parent.close())
|
self.close_button.released.connect(lambda: parent.close())
|
||||||
# ADD Buttons
|
# ADD Buttons
|
||||||
self.bg_layout.addWidget(self.minimize_button)
|
self.bg_layout.addWidget(self.minimize_button)
|
||||||
self.bg_layout.addWidget(self.maximize_restore_button)
|
self.bg_layout.addWidget(self.maximize_restore_button)
|
||||||
@@ -156,9 +162,15 @@ class PyTitleBar(QWidget):
|
|||||||
if _is_maximized:
|
if _is_maximized:
|
||||||
self._parent.ui.central_widget_layout.setContentsMargins(0,0,0,0)
|
self._parent.ui.central_widget_layout.setContentsMargins(0,0,0,0)
|
||||||
self._parent.ui.window.set_stylesheet(border_radius = 0, border_size = 0)
|
self._parent.ui.window.set_stylesheet(border_radius = 0, border_size = 0)
|
||||||
|
self.maximize_restore_button.set_icon(
|
||||||
|
Functions.set_svg_icon("icon_restore.svg")
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
self._parent.ui.central_widget_layout.setContentsMargins(10,10,10,10)
|
self._parent.ui.central_widget_layout.setContentsMargins(10,10,10,10)
|
||||||
self._parent.ui.window.set_stylesheet(border_radius = 10, border_size = 2)
|
self._parent.ui.window.set_stylesheet(border_radius = 10, border_size = 2)
|
||||||
|
self.maximize_restore_button.set_icon(
|
||||||
|
Functions.set_svg_icon("icon_maximize.svg")
|
||||||
|
)
|
||||||
|
|
||||||
# CHECK EVENT
|
# CHECK EVENT
|
||||||
if self._parent.isMaximized():
|
if self._parent.isMaximized():
|
||||||
@@ -200,7 +212,10 @@ class PyTitleBar(QWidget):
|
|||||||
|
|
||||||
# MINIMIZE BUTTON
|
# MINIMIZE BUTTON
|
||||||
self.minimize_button = PyTitleButton(
|
self.minimize_button = PyTitleButton(
|
||||||
|
self._parent,
|
||||||
|
self._app_parent,
|
||||||
tooltip_text = "Close app",
|
tooltip_text = "Close app",
|
||||||
|
dark_one = self._dark_one,
|
||||||
bg_color = self._btn_bg_color,
|
bg_color = self._btn_bg_color,
|
||||||
bg_color_hover = self._btn_bg_color_hover,
|
bg_color_hover = self._btn_bg_color_hover,
|
||||||
bg_color_pressed = self._btn_bg_color_pressed,
|
bg_color_pressed = self._btn_bg_color_pressed,
|
||||||
@@ -208,12 +223,18 @@ class PyTitleBar(QWidget):
|
|||||||
icon_color_hover = self._icon_color_hover,
|
icon_color_hover = self._icon_color_hover,
|
||||||
icon_color_pressed = self._icon_color_pressed,
|
icon_color_pressed = self._icon_color_pressed,
|
||||||
icon_color_active = self._icon_color_active,
|
icon_color_active = self._icon_color_active,
|
||||||
|
context_color = self._context_color,
|
||||||
|
text_foreground = self._text_foreground,
|
||||||
|
radius = 6,
|
||||||
icon_path = Functions.set_svg_icon("icon_minimize.svg")
|
icon_path = Functions.set_svg_icon("icon_minimize.svg")
|
||||||
)
|
)
|
||||||
|
|
||||||
# MAXIMIZE / RESTORE BUTTON
|
# MAXIMIZE / RESTORE BUTTON
|
||||||
self.maximize_restore_button = PyTitleButton(
|
self.maximize_restore_button = PyTitleButton(
|
||||||
|
self._parent,
|
||||||
|
self._app_parent,
|
||||||
tooltip_text = "Maximize app",
|
tooltip_text = "Maximize app",
|
||||||
|
dark_one = self._dark_one,
|
||||||
bg_color = self._btn_bg_color,
|
bg_color = self._btn_bg_color,
|
||||||
bg_color_hover = self._btn_bg_color_hover,
|
bg_color_hover = self._btn_bg_color_hover,
|
||||||
bg_color_pressed = self._btn_bg_color_pressed,
|
bg_color_pressed = self._btn_bg_color_pressed,
|
||||||
@@ -221,12 +242,18 @@ class PyTitleBar(QWidget):
|
|||||||
icon_color_hover = self._icon_color_hover,
|
icon_color_hover = self._icon_color_hover,
|
||||||
icon_color_pressed = self._icon_color_pressed,
|
icon_color_pressed = self._icon_color_pressed,
|
||||||
icon_color_active = self._icon_color_active,
|
icon_color_active = self._icon_color_active,
|
||||||
|
context_color = self._context_color,
|
||||||
|
text_foreground = self._text_foreground,
|
||||||
|
radius = 6,
|
||||||
icon_path = Functions.set_svg_icon("icon_maximize.svg")
|
icon_path = Functions.set_svg_icon("icon_maximize.svg")
|
||||||
)
|
)
|
||||||
|
|
||||||
# CLOSE BUTTON
|
# CLOSE BUTTON
|
||||||
self.close_button = PyTitleButton(
|
self.close_button = PyTitleButton(
|
||||||
|
self._parent,
|
||||||
|
self._app_parent,
|
||||||
tooltip_text = "Close app",
|
tooltip_text = "Close app",
|
||||||
|
dark_one = self._dark_one,
|
||||||
bg_color = self._btn_bg_color,
|
bg_color = self._btn_bg_color,
|
||||||
bg_color_hover = self._btn_bg_color_hover,
|
bg_color_hover = self._btn_bg_color_hover,
|
||||||
bg_color_pressed = self._context_color,
|
bg_color_pressed = self._context_color,
|
||||||
@@ -234,6 +261,9 @@ class PyTitleBar(QWidget):
|
|||||||
icon_color_hover = self._icon_color_hover,
|
icon_color_hover = self._icon_color_hover,
|
||||||
icon_color_pressed = self._icon_color_pressed,
|
icon_color_pressed = self._icon_color_pressed,
|
||||||
icon_color_active = self._icon_color_active,
|
icon_color_active = self._icon_color_active,
|
||||||
|
context_color = self._context_color,
|
||||||
|
text_foreground = self._text_foreground,
|
||||||
|
radius = 6,
|
||||||
icon_path = Functions.set_svg_icon("icon_close.svg")
|
icon_path = Functions.set_svg_icon("icon_close.svg")
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -23,6 +23,8 @@ from qt_core import *
|
|||||||
class PyTitleButton(QPushButton):
|
class PyTitleButton(QPushButton):
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
|
parent,
|
||||||
|
app_parent = None,
|
||||||
tooltip_text = "",
|
tooltip_text = "",
|
||||||
width = 30,
|
width = 30,
|
||||||
height = 30,
|
height = 30,
|
||||||
@@ -35,6 +37,9 @@ class PyTitleButton(QPushButton):
|
|||||||
icon_color_pressed = "#edf0f5",
|
icon_color_pressed = "#edf0f5",
|
||||||
icon_color_active = "#f5f6f9",
|
icon_color_active = "#f5f6f9",
|
||||||
icon_path = "no_icon.svg",
|
icon_path = "no_icon.svg",
|
||||||
|
dark_one = "#1b1e23",
|
||||||
|
context_color = "#568af2",
|
||||||
|
text_foreground = "#8a95aa",
|
||||||
is_active = False
|
is_active = False
|
||||||
):
|
):
|
||||||
super(PyTitleButton, self).__init__()
|
super(PyTitleButton, self).__init__()
|
||||||
@@ -51,11 +56,26 @@ class PyTitleButton(QPushButton):
|
|||||||
self._icon_color_hover = icon_color_hover
|
self._icon_color_hover = icon_color_hover
|
||||||
self._icon_color_pressed = icon_color_pressed
|
self._icon_color_pressed = icon_color_pressed
|
||||||
self._icon_color_active = icon_color_active
|
self._icon_color_active = icon_color_active
|
||||||
|
self._top_margin = self.height() + 3
|
||||||
# Set Parameters
|
# Set Parameters
|
||||||
self._set_bg_color = bg_color
|
self._set_bg_color = bg_color
|
||||||
self._set_icon_path = icon_path
|
self._set_icon_path = icon_path
|
||||||
self._set_icon_color = icon_color
|
self._set_icon_color = icon_color
|
||||||
self._set_border_radius = radius
|
self._set_border_radius = radius
|
||||||
|
# Parent
|
||||||
|
self._parent = parent
|
||||||
|
self._app_parent = app_parent
|
||||||
|
|
||||||
|
# TOOLTIP
|
||||||
|
self._tooltip_text = tooltip_text
|
||||||
|
self._tooltip = _ToolTip(
|
||||||
|
app_parent,
|
||||||
|
tooltip_text,
|
||||||
|
dark_one,
|
||||||
|
context_color,
|
||||||
|
text_foreground
|
||||||
|
)
|
||||||
|
self._tooltip.hide()
|
||||||
|
|
||||||
# PAINT EVENT
|
# PAINT EVENT
|
||||||
# painting the button and the icon
|
# painting the button and the icon
|
||||||
@@ -109,15 +129,15 @@ class PyTitleButton(QPushButton):
|
|||||||
# Event triggered when the mouse is over the BTN
|
# Event triggered when the mouse is over the BTN
|
||||||
def enterEvent(self, event):
|
def enterEvent(self, event):
|
||||||
self.change_style(QEvent.Enter)
|
self.change_style(QEvent.Enter)
|
||||||
#self.move_tooltip()
|
self.move_tooltip()
|
||||||
#self.tooltip.show()
|
self._tooltip.show()
|
||||||
|
|
||||||
# MOUSE LEAVE
|
# MOUSE LEAVE
|
||||||
# Event fired when the mouse leaves the BTN
|
# Event fired when the mouse leaves the BTN
|
||||||
def leaveEvent(self, event):
|
def leaveEvent(self, event):
|
||||||
self.change_style(QEvent.Leave)
|
self.change_style(QEvent.Leave)
|
||||||
#self.move_tooltip()
|
self.move_tooltip()
|
||||||
#self.tooltip.hide()
|
self._tooltip.hide()
|
||||||
|
|
||||||
# MOUSE PRESS
|
# MOUSE PRESS
|
||||||
# Event triggered when the left button is pressed
|
# Event triggered when the left button is pressed
|
||||||
@@ -150,3 +170,74 @@ class PyTitleButton(QPushButton):
|
|||||||
icon
|
icon
|
||||||
)
|
)
|
||||||
painter.end()
|
painter.end()
|
||||||
|
|
||||||
|
# SET ICON
|
||||||
|
# ///////////////////////////////////////////////////////////////
|
||||||
|
def set_icon(self, icon_path):
|
||||||
|
self._set_icon_path = icon_path
|
||||||
|
self.repaint()
|
||||||
|
|
||||||
|
# MOVE TOOLTIP
|
||||||
|
# ///////////////////////////////////////////////////////////////
|
||||||
|
def move_tooltip(self):
|
||||||
|
# GET MAIN WINDOW PARENT
|
||||||
|
gp = self.mapToGlobal(QPoint(0, 0))
|
||||||
|
|
||||||
|
# SET WIDGET TO GET POSTION
|
||||||
|
# Return absolute position of widget inside app
|
||||||
|
pos = self._parent.mapFromGlobal(gp)
|
||||||
|
|
||||||
|
# FORMAT POSITION
|
||||||
|
# Adjust tooltip position with offset
|
||||||
|
pos_x = (pos.x() - self._tooltip.width()) + self.width() + 5
|
||||||
|
pos_y = pos.y() + self._top_margin
|
||||||
|
|
||||||
|
# SET POSITION TO WIDGET
|
||||||
|
# Move tooltip position
|
||||||
|
self._tooltip.move(pos_x, pos_y)
|
||||||
|
|
||||||
|
class _ToolTip(QLabel):
|
||||||
|
# TOOLTIP / LABEL StyleSheet
|
||||||
|
style_tooltip = """
|
||||||
|
QLabel {{
|
||||||
|
background-color: {_dark_one};
|
||||||
|
color: {_text_foreground};
|
||||||
|
padding-left: 10px;
|
||||||
|
padding-right: 10px;
|
||||||
|
border-radius: 17px;
|
||||||
|
border: 0px solid transparent;
|
||||||
|
border-right: 3px solid {_context_color};
|
||||||
|
font: 800 9pt "Segoe UI";
|
||||||
|
}}
|
||||||
|
"""
|
||||||
|
|
||||||
|
def __init__(
|
||||||
|
self,
|
||||||
|
parent,
|
||||||
|
tooltip,
|
||||||
|
dark_one,
|
||||||
|
context_color,
|
||||||
|
text_foreground
|
||||||
|
):
|
||||||
|
QLabel.__init__(self)
|
||||||
|
|
||||||
|
# LABEL SETUP
|
||||||
|
style = self.style_tooltip.format(
|
||||||
|
_dark_one = dark_one,
|
||||||
|
_context_color = context_color,
|
||||||
|
_text_foreground = text_foreground
|
||||||
|
)
|
||||||
|
self.setObjectName(u"label_tooltip")
|
||||||
|
self.setStyleSheet(style)
|
||||||
|
self.setMinimumHeight(34)
|
||||||
|
self.setParent(parent)
|
||||||
|
self.setText(tooltip)
|
||||||
|
self.adjustSize()
|
||||||
|
|
||||||
|
# SET DROP SHADOW
|
||||||
|
self.shadow = QGraphicsDropShadowEffect(self)
|
||||||
|
self.shadow.setBlurRadius(30)
|
||||||
|
self.shadow.setXOffset(0)
|
||||||
|
self.shadow.setYOffset(0)
|
||||||
|
self.shadow.setColor(QColor(0, 0, 0, 80))
|
||||||
|
self.setGraphicsEffect(self.shadow)
|
||||||
|
|||||||
Reference in New Issue
Block a user