mirror of
https://github.com/Wanderson-Magalhaes/PyOneDark_Qt_Widgets_Modern_GUI.git
synced 2026-02-17 07:53:57 +00:00
20/05/2021
This commit is contained in:
60
gui/images/svg_icons/no_icon.svg
Normal file
60
gui/images/svg_icons/no_icon.svg
Normal file
@@ -0,0 +1,60 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
width="16"
|
||||
height="16"
|
||||
viewBox="0 0 4.2333332 4.2333335"
|
||||
version="1.1"
|
||||
id="svg1107"
|
||||
inkscape:version="1.0.2-2 (e86c870879, 2021-01-15)"
|
||||
sodipodi:docname="no_icon.svg">
|
||||
<defs
|
||||
id="defs1101" />
|
||||
<sodipodi:namedview
|
||||
id="base"
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1.0"
|
||||
inkscape:pageopacity="0.0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:zoom="26.156251"
|
||||
inkscape:cx="3.3352559"
|
||||
inkscape:cy="11.186469"
|
||||
inkscape:document-units="mm"
|
||||
inkscape:current-layer="layer1"
|
||||
inkscape:document-rotation="0"
|
||||
showgrid="false"
|
||||
units="px"
|
||||
inkscape:window-width="1920"
|
||||
inkscape:window-height="1027"
|
||||
inkscape:window-x="1912"
|
||||
inkscape:window-y="-8"
|
||||
inkscape:window-maximized="1" />
|
||||
<metadata
|
||||
id="metadata1104">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
<dc:title></dc:title>
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<g
|
||||
inkscape:label="Layer 1"
|
||||
inkscape:groupmode="layer"
|
||||
id="layer1">
|
||||
<path
|
||||
id="path1676"
|
||||
style="color:#000000;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:medium;line-height:normal;font-family:sans-serif;font-variant-ligatures:normal;font-variant-position:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-alternates:normal;font-variant-east-asian:normal;font-feature-settings:normal;font-variation-settings:normal;text-indent:0;text-align:start;text-decoration:none;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:#000000;letter-spacing:normal;word-spacing:normal;text-transform:none;writing-mode:lr-tb;direction:ltr;text-orientation:mixed;dominant-baseline:auto;baseline-shift:baseline;text-anchor:start;white-space:normal;shape-padding:0;shape-margin:0;inline-size:0;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;vector-effect:none;fill:#c3ccdf;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1.07085;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate;stop-color:#000000"
|
||||
d="M 1.1666666e-8,1.1666666e-8 V 0.28222226 4.2333333 H 4.2333333 V 1.1666666e-8 Z M 0.56665798,0.56665798 H 3.285952 L 0.56665798,3.285952 Z M 3.6666754,0.94738132 V 3.6666754 H 0.94738132 Z" />
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 3.1 KiB |
@@ -7,6 +7,7 @@
|
||||
"dark_four" : "#272c36",
|
||||
"bg_one" : "#2c313c",
|
||||
"bg_two" : "#343b48",
|
||||
"bg_three" : "#3c4454",
|
||||
"icon_color" : "#c3ccdf",
|
||||
"icon_hover" : "#dce1ec",
|
||||
"icon_pressed" : "#edf0f5",
|
||||
|
||||
@@ -66,6 +66,10 @@ class UI_MainWindow(object):
|
||||
# Add central widget to app
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
self.central_widget = QWidget()
|
||||
self.central_widget.setStyleSheet(f'''
|
||||
font: {self.settings["font"]["text_size"]}pt "{self.settings["font"]["family"]}";
|
||||
color: {self.themes["app_color"]["text_foreground"]};
|
||||
''')
|
||||
self.central_widget_layout = QVBoxLayout(self.central_widget)
|
||||
if self.settings["custom_title_bar"]:
|
||||
self.central_widget_layout.setContentsMargins(10,10,10,10)
|
||||
@@ -81,6 +85,7 @@ class UI_MainWindow(object):
|
||||
border_color = self.themes["app_color"]["bg_two"],
|
||||
text_color = self.themes["app_color"]["text_foreground"]
|
||||
)
|
||||
|
||||
|
||||
# If disable custom title bar
|
||||
if not self.settings["custom_title_bar"]:
|
||||
@@ -156,7 +161,11 @@ class UI_MainWindow(object):
|
||||
|
||||
# ADD CUSTOM TITLE BAR TO LAYOUT
|
||||
self.title_bar = PyTitleBar(
|
||||
parent
|
||||
parent,
|
||||
bg_color = self.themes["app_color"]["bg_two"],
|
||||
div_color = self.themes["app_color"]["bg_three"],
|
||||
font_family = self.settings["font"]["family"],
|
||||
title_size = self.settings["font"]["title_size"]
|
||||
)
|
||||
self.title_bar_layout.addWidget(self.title_bar)
|
||||
|
||||
|
||||
@@ -14,10 +14,6 @@
|
||||
#
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
|
||||
# IMPORT PACKAGES AND MODULES
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
import os
|
||||
|
||||
# IMPORT QT CORE
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
from qt_core import *
|
||||
@@ -28,7 +24,7 @@ class PyDiv(QWidget):
|
||||
def __init__(self, color):
|
||||
super(PyDiv, self).__init__()
|
||||
|
||||
self.layout = QVBoxLayout(self)
|
||||
self.layout = QHBoxLayout(self)
|
||||
self.layout.setContentsMargins(5,0,5,0)
|
||||
self.frame_line = QFrame()
|
||||
self.frame_line.setStyleSheet(f"background: {color};")
|
||||
|
||||
@@ -260,7 +260,7 @@ class PyLeftMenuButton(QPushButton):
|
||||
if event.button() == Qt.LeftButton:
|
||||
self.change_style(QEvent.MouseButtonPress)
|
||||
self.tooltip.hide()
|
||||
return self.clicked.emit()
|
||||
return self.clicked.emit()
|
||||
|
||||
# MOUSE RELEASED
|
||||
# Event triggered after the mouse button is released
|
||||
@@ -268,7 +268,7 @@ class PyLeftMenuButton(QPushButton):
|
||||
def mouseReleaseEvent(self, event):
|
||||
if event.button() == Qt.LeftButton:
|
||||
self.change_style(QEvent.MouseButtonRelease)
|
||||
return self.released.emit()
|
||||
return self.released.emit()
|
||||
|
||||
# MOVE TOOLTIP
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
|
||||
35
gui/widgets/py_title_bar/py_div.py
Normal file
35
gui/widgets/py_title_bar/py_div.py
Normal file
@@ -0,0 +1,35 @@
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
#
|
||||
# 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 *
|
||||
|
||||
# CUSTOM LEFT MENU
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
class PyDiv(QWidget):
|
||||
def __init__(self, color):
|
||||
super(PyDiv, self).__init__()
|
||||
|
||||
self.layout = QHBoxLayout(self)
|
||||
self.layout.setContentsMargins(0,5,0,5)
|
||||
self.frame_line = QFrame()
|
||||
self.frame_line.setStyleSheet(f"background: {color};")
|
||||
self.frame_line.setMaximumWidth(1)
|
||||
self.frame_line.setMinimumWidth(1)
|
||||
self.layout.addWidget(self.frame_line)
|
||||
self.setMaximumWidth(20)
|
||||
self.setMinimumWidth(20)
|
||||
@@ -26,6 +26,19 @@ from gui.core.functions import *
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
from gui.core.json_settings import Settings
|
||||
|
||||
# IMPORT DIV
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
from . py_div import PyDiv
|
||||
|
||||
# IMPORT BUTTON
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
from . py_title_button import PyTitleButton
|
||||
|
||||
# GLOBALS
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
_is_maximized = False
|
||||
_old_size = QSize()
|
||||
|
||||
# PY TITLE BAR
|
||||
# Top bar with move application, maximize, restore, minimize,
|
||||
# close buttons and extra buttons
|
||||
@@ -38,13 +51,39 @@ class PyTitleBar(QWidget):
|
||||
logo_width = 100,
|
||||
buttons = None,
|
||||
bg_color = "#343b48",
|
||||
radius = 8
|
||||
div_color = "#3c4454",
|
||||
btn_bg_color = "#343b48",
|
||||
btn_bg_color_hover = "#3c4454",
|
||||
btn_bg_color_pressed = "#2c313c",
|
||||
icon_color = "#c3ccdf",
|
||||
icon_color_hover = "#dce1ec",
|
||||
icon_color_pressed = "#edf0f5",
|
||||
icon_color_active = "#f5f6f9",
|
||||
context_color = "#6c99f4",
|
||||
radius = 8,
|
||||
font_family = "Segoe UI",
|
||||
title_size = 10
|
||||
):
|
||||
super(PyTitleBar, self).__init__()
|
||||
|
||||
settings = Settings()
|
||||
self.settings = settings.items
|
||||
|
||||
# PARAMETERS
|
||||
self._bg_color = bg_color
|
||||
self._div_color = div_color
|
||||
self._font_family = font_family
|
||||
self._title_size = title_size
|
||||
self._parent = parent
|
||||
self._btn_bg_color = btn_bg_color
|
||||
self._btn_bg_color_hover = btn_bg_color_hover
|
||||
self._btn_bg_color_pressed = btn_bg_color_pressed
|
||||
self._context_color = context_color
|
||||
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
|
||||
|
||||
# SETUP UI
|
||||
self.setup_ui()
|
||||
|
||||
@@ -60,26 +99,77 @@ class PyTitleBar(QWidget):
|
||||
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)
|
||||
if parent.isMaximized():
|
||||
self.maximize_restore()
|
||||
#self.resize(_old_size)
|
||||
curso_x = parent.pos().x()
|
||||
curso_y = event.globalPos().y() - QCursor.pos().y()
|
||||
parent.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()
|
||||
|
||||
# MOVE APP WIDGETS
|
||||
self.top_logo.mouseMoveEvent = moveWindow
|
||||
self.div_1.mouseMoveEvent = moveWindow
|
||||
self.title_label.mouseMoveEvent = moveWindow
|
||||
self.div_2.mouseMoveEvent = moveWindow
|
||||
|
||||
# MAXIMIZE / RESTORE
|
||||
self.top_logo.mouseDoubleClickEvent = self.maximize_restore
|
||||
self.div_1.mouseDoubleClickEvent = self.maximize_restore
|
||||
self.title_label.mouseDoubleClickEvent = self.maximize_restore
|
||||
self.div_2.mouseDoubleClickEvent = self.maximize_restore
|
||||
|
||||
# ADD WIDGETS TO TITLE BAR
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
self.bg_layout.addWidget(self.top_logo)
|
||||
self.bg_layout.addWidget(self.div_1)
|
||||
self.bg_layout.addWidget(self.title_label)
|
||||
self.bg_layout.addWidget(self.right_frame)
|
||||
self.bg_layout.addWidget(self.div_2)
|
||||
|
||||
# ADD BUTTONS BUTTONS
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
# Functions
|
||||
self.minimize_button.clicked.connect(lambda: parent.showMinimized())
|
||||
self.maximize_restore_button.clicked.connect(lambda: self.maximize_restore())
|
||||
self.close_button.clicked.connect(lambda: parent.close())
|
||||
# ADD Buttons
|
||||
self.bg_layout.addWidget(self.minimize_button)
|
||||
self.bg_layout.addWidget(self.maximize_restore_button)
|
||||
self.bg_layout.addWidget(self.close_button)
|
||||
|
||||
# MAXIMIZE / RESTORE
|
||||
# maximize and restore parent window
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def maximize_restore(self, e = None):
|
||||
global _is_maximized
|
||||
global _old_size
|
||||
|
||||
# CHANGE UI AND RESIZE GRIP
|
||||
def change_ui():
|
||||
if _is_maximized:
|
||||
self._parent.ui.central_widget_layout.setContentsMargins(0,0,0,0)
|
||||
self._parent.ui.window.set_stylesheet(border_radius = 0, border_size = 0)
|
||||
else:
|
||||
self._parent.ui.central_widget_layout.setContentsMargins(10,10,10,10)
|
||||
self._parent.ui.window.set_stylesheet(border_radius = 10, border_size = 2)
|
||||
|
||||
# CHECK EVENT
|
||||
if self._parent.isMaximized():
|
||||
_is_maximized = False
|
||||
self._parent.showNormal()
|
||||
change_ui()
|
||||
else:
|
||||
_is_maximized = True
|
||||
_old_size = QSize(self._parent.width(), self._parent.height())
|
||||
self._parent.showMaximized()
|
||||
change_ui()
|
||||
|
||||
# SETUP APP
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
@@ -93,21 +183,59 @@ class PyTitleBar(QWidget):
|
||||
|
||||
# ADD BG LAYOUT
|
||||
self.bg_layout = QHBoxLayout(self.bg)
|
||||
self.bg_layout.setContentsMargins(10,0,0,0)
|
||||
self.bg_layout.setContentsMargins(10,0,5,0)
|
||||
self.bg_layout.setSpacing(0)
|
||||
|
||||
# DIVS
|
||||
self.div_1 = PyDiv(self._div_color)
|
||||
self.div_2 = PyDiv(self._div_color)
|
||||
|
||||
# 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")
|
||||
self.title_label.setStyleSheet(f'font: {self._title_size}pt "{self._font_family}"')
|
||||
|
||||
# RIGHT FRAME WITH BUTTONS
|
||||
self.right_frame = QFrame()
|
||||
self.right_frame.setMinimumWidth(100)
|
||||
self.right_frame.setStyleSheet("background: #CCC")
|
||||
# MINIMIZE BUTTON
|
||||
self.minimize_button = PyTitleButton(
|
||||
tooltip_text = "Close app",
|
||||
bg_color = self._btn_bg_color,
|
||||
bg_color_hover = self._btn_bg_color_hover,
|
||||
bg_color_pressed = self._btn_bg_color_pressed,
|
||||
icon_color = self._icon_color,
|
||||
icon_color_hover = self._icon_color_hover,
|
||||
icon_color_pressed = self._icon_color_pressed,
|
||||
icon_color_active = self._icon_color_active,
|
||||
icon_path = Functions.set_svg_icon("icon_minimize.svg")
|
||||
)
|
||||
|
||||
# MAXIMIZE / RESTORE BUTTON
|
||||
self.maximize_restore_button = PyTitleButton(
|
||||
tooltip_text = "Maximize app",
|
||||
bg_color = self._btn_bg_color,
|
||||
bg_color_hover = self._btn_bg_color_hover,
|
||||
bg_color_pressed = self._btn_bg_color_pressed,
|
||||
icon_color = self._icon_color,
|
||||
icon_color_hover = self._icon_color_hover,
|
||||
icon_color_pressed = self._icon_color_pressed,
|
||||
icon_color_active = self._icon_color_active,
|
||||
icon_path = Functions.set_svg_icon("icon_maximize.svg")
|
||||
)
|
||||
|
||||
# CLOSE BUTTON
|
||||
self.close_button = PyTitleButton(
|
||||
tooltip_text = "Close app",
|
||||
bg_color = self._btn_bg_color,
|
||||
bg_color_hover = self._btn_bg_color_hover,
|
||||
bg_color_pressed = self._context_color,
|
||||
icon_color = self._icon_color,
|
||||
icon_color_hover = self._icon_color_hover,
|
||||
icon_color_pressed = self._icon_color_pressed,
|
||||
icon_color_active = self._icon_color_active,
|
||||
icon_path = Functions.set_svg_icon("icon_close.svg")
|
||||
)
|
||||
|
||||
# ADD TO LAYOUT
|
||||
self.title_bar_layout.addWidget(self.bg)
|
||||
152
gui/widgets/py_title_bar/py_title_button.py
Normal file
152
gui/widgets/py_title_bar/py_title_button.py
Normal file
@@ -0,0 +1,152 @@
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
#
|
||||
# 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 TITLE BUTTON
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
class PyTitleButton(QPushButton):
|
||||
def __init__(
|
||||
self,
|
||||
tooltip_text = "",
|
||||
width = 30,
|
||||
height = 30,
|
||||
radius = 8,
|
||||
bg_color = "#343b48",
|
||||
bg_color_hover = "#3c4454",
|
||||
bg_color_pressed = "#2c313c",
|
||||
icon_color = "#c3ccdf",
|
||||
icon_color_hover = "#dce1ec",
|
||||
icon_color_pressed = "#edf0f5",
|
||||
icon_color_active = "#f5f6f9",
|
||||
icon_path = "no_icon.svg",
|
||||
is_active = False
|
||||
):
|
||||
super(PyTitleButton, self).__init__()
|
||||
|
||||
# SET DEFAULT PARAMETERS
|
||||
self.setFixedSize(width, height)
|
||||
self.setCursor(Qt.PointingHandCursor)
|
||||
|
||||
# PROPERTIES
|
||||
self._bg_color = bg_color
|
||||
self._bg_color_hover = bg_color_hover
|
||||
self._bg_color_pressed = bg_color_pressed
|
||||
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
|
||||
# Set Parameters
|
||||
self._set_bg_color = bg_color
|
||||
self._set_icon_path = icon_path
|
||||
self._set_icon_color = icon_color
|
||||
self._set_border_radius = radius
|
||||
|
||||
# PAINT EVENT
|
||||
# painting the button and the icon
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def paintEvent(self, event):
|
||||
# PAINTER
|
||||
paint = QPainter()
|
||||
paint.begin(self)
|
||||
paint.setRenderHint(QPainter.RenderHint.Antialiasing)
|
||||
|
||||
# BRUSH
|
||||
brush = QBrush(QColor(self._set_bg_color))
|
||||
|
||||
# CREATE RECTANGLE
|
||||
rect = QRect(0, 0, self.width(), self.height())
|
||||
paint.setPen(Qt.NoPen)
|
||||
paint.setBrush(brush)
|
||||
paint.drawRoundedRect(
|
||||
rect,
|
||||
self._set_border_radius,
|
||||
self._set_border_radius
|
||||
)
|
||||
|
||||
# DRAW ICONS
|
||||
self.icon_paint(paint, self._set_icon_path, rect)
|
||||
|
||||
# END PAINTER
|
||||
paint.end()
|
||||
|
||||
# CHANGE STYLES
|
||||
# Functions with custom styles
|
||||
def change_style(self, event):
|
||||
if event == QEvent.Enter:
|
||||
self._set_bg_color = self._bg_color_hover
|
||||
self._set_icon_color = self._icon_color_hover
|
||||
self.repaint()
|
||||
elif event == QEvent.Leave:
|
||||
self._set_bg_color = self._bg_color
|
||||
self._set_icon_color = self._icon_color
|
||||
self.repaint()
|
||||
elif event == QEvent.MouseButtonPress:
|
||||
self._set_bg_color = self._bg_color_pressed
|
||||
self._set_icon_color = self._icon_color_pressed
|
||||
self.repaint()
|
||||
elif event == QEvent.MouseButtonRelease:
|
||||
self._set_bg_color = self._bg_color_hover
|
||||
self._set_icon_color = self._icon_color_hover
|
||||
self.repaint()
|
||||
|
||||
# MOUSE OVER
|
||||
# Event triggered when the mouse is over the BTN
|
||||
def enterEvent(self, event):
|
||||
self.change_style(QEvent.Enter)
|
||||
#self.move_tooltip()
|
||||
#self.tooltip.show()
|
||||
|
||||
# MOUSE LEAVE
|
||||
# Event fired when the mouse leaves the BTN
|
||||
def leaveEvent(self, event):
|
||||
self.change_style(QEvent.Leave)
|
||||
#self.move_tooltip()
|
||||
#self.tooltip.hide()
|
||||
|
||||
# MOUSE PRESS
|
||||
# Event triggered when the left button is pressed
|
||||
def mousePressEvent(self, event):
|
||||
if event.button() == Qt.LeftButton:
|
||||
self.change_style(QEvent.MouseButtonPress)
|
||||
# SET FOCUS
|
||||
self.setFocus()
|
||||
# EMIT SIGNAL
|
||||
return self.clicked.emit()
|
||||
|
||||
# MOUSE RELEASED
|
||||
# Event triggered after the mouse button is released
|
||||
def mouseReleaseEvent(self, event):
|
||||
if event.button() == Qt.LeftButton:
|
||||
self.change_style(QEvent.MouseButtonRelease)
|
||||
# EMIT SIGNAL
|
||||
return self.released.emit()
|
||||
|
||||
# DRAW ICON WITH COLORS
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
def icon_paint(self, qp, image, rect):
|
||||
icon = QPixmap(image)
|
||||
painter = QPainter(icon)
|
||||
painter.setCompositionMode(QPainter.CompositionMode_SourceIn)
|
||||
painter.fillRect(icon.rect(), self._set_icon_color)
|
||||
qp.drawPixmap(
|
||||
(rect.width() - icon.width()) / 2,
|
||||
(rect.height() - icon.height()) / 2,
|
||||
icon
|
||||
)
|
||||
painter.end()
|
||||
@@ -25,10 +25,6 @@ from qt_core import *
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
from gui.core.json_settings import Settings
|
||||
|
||||
# IMPORT PY GRIP
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
from gui.widgets.py_grips import PyGrips
|
||||
|
||||
# IMPORT STYLES
|
||||
# ///////////////////////////////////////////////////////////////
|
||||
from . styles import Styles
|
||||
|
||||
@@ -18,5 +18,10 @@
|
||||
"minimum" : 240,
|
||||
"maximum" : 240
|
||||
},
|
||||
"theme_name": "default"
|
||||
"theme_name" : "default",
|
||||
"font" : {
|
||||
"family" : "Segoe UI",
|
||||
"title_size" : 10,
|
||||
"text_size" : 9
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user