11/05/2021

This commit is contained in:
VFX - Visual Effects
2021-05-11 13:29:36 -03:00
parent d838f3d6ef
commit 0eb4fb77fd
23 changed files with 1318 additions and 42 deletions
+33 -14
View File
@@ -40,20 +40,29 @@ class PyLeftMenu(QWidget):
def __init__(
self,
parent = None,
bg_color = "#1b1e23",
bg_color_app = "#2c313c",
dark_one = "#1b1e23",
bg_one = "#2c313c",
icon_color = "#c3ccdf",
icon_color_hover = "#dce1ec",
icon_color_pressed = "#edf0f5",
icon_color_active = "#f5f6f9",
context_color = "#568af2"
context_color = "#568af2",
duration_time = 500,
radius = 8
):
super(PyLeftMenu, self).__init__()
# LOAD THEMES
# PROPERTIES
# ///////////////////////////////////////////////////////////////
themes = Themes()
self.themes = themes.items
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._context_color = context_color
self._duration_time = duration_time
self._radius = radius
# SET PARENT
self.parent = parent
@@ -61,19 +70,30 @@ class PyLeftMenu(QWidget):
# SETUP WIDGETS
self.setup_ui()
self.button = PyLeftMenuButton("tooltip")
# SET BG COLOR
self.bg.setStyleSheet(f"background: {dark_one}; border-radius: {radius};")
self.button = PyLeftMenuButton("Add user menu")
self.button.clicked.connect(lambda: self.size_change())
self.button_2 = QPushButton("teste")
self.button_3 = PyLeftMenuButton("Teste menu", icon_path="gui/images/svg_icons/icon_settings.svg")
self.layout.addWidget(self.button)
self.layout.addWidget(self.button_2)
self.layout.addWidget(self.button_3)
self.animation = QPropertyAnimation(parent, b"minimumWidth")
self.animation.setStartValue(50)
self.animation.setEndValue(240)
def size_change(self):
self.animation = QPropertyAnimation(self.parent, b"minimumWidth")
self.animation.stop()
if self.width() == 50:
self.animation.setStartValue(self.width())
self.animation.setEndValue(240)
else:
self.animation.setStartValue(self.width())
self.animation.setEndValue(50)
self.animation.setEasingCurve(QEasingCurve.InOutCubic)
self.animation.setDuration(500)
def size_change(self):
self.animation.setDuration(self._duration_time)
self.animation.start()
# SET APP LAYOUT
@@ -84,7 +104,6 @@ class PyLeftMenu(QWidget):
# ADD BG
self.bg = QFrame(self)
self.bg.setStyleSheet("background: #CCC")
# ADD LAYOUT
self.layout = QVBoxLayout(self.bg)
+108 -15
View File
@@ -47,17 +47,37 @@ class PyLeftMenuButton(QPushButton):
self,
text,
margin = 4,
bg_one_color = "#2c313c"
dark_one = "#1b1e23",
dark_three = "#21252d",
bg_one = "#2c313c",
icon_color = "#c3ccdf",
icon_color_hover = "#dce1ec",
icon_color_pressed = "#edf0f5",
icon_color_active = "#f5f6f9",
context_color = "#568af2",
icon_path = "gui/images/svg_icons/icon_add_user.svg",
icon_active_menu = "gui/images/svg_icons/active_menu.svg"
):
super(PyLeftMenuButton, self).__init__()
self.setText(text)
self.setCursor(Qt.PointingHandCursor)
self.setMaximumHeight(40)
self.setMinimumHeight(40)
self.setMaximumHeight(50)
self.setMinimumHeight(50)
# APP PATH
app_path = os.path.abspath(os.getcwd())
self._icon_path = os.path.normpath(os.path.join(app_path, icon_path))
# PROPERTIES
self._margin = margin
self._bg_one_color = bg_one_color
self._dark_one = dark_one
self._dark_three = dark_three
self._bg_one = bg_one
self._context_color = context_color
self._icon_color = icon_color
self._icon_color_active = icon_color_active
self._icon_set_color = self._icon_color
self._icon_active_menu = icon_active_menu
def paintEvent(self, event):
# PAINTER
@@ -65,26 +85,99 @@ class PyLeftMenuButton(QPushButton):
p.begin(self)
p.setRenderHint(QPainter.Antialiasing)
p.setPen(Qt.NoPen)
font = p.font()
font.setFamily("Segoe UI")
font.setPointSize(10)
p.setFont(font)
# RECTANGLES
rect = QRect(0, 0, self.width(), self.height())
rect_inside = QRect(
self._margin,
self._margin,
self.width() - (self._margin * 2),
self.height() - (self._margin * 2)
)
rect = QRect(4, 5, self.width(), self.height() - 10)
rect_icon = QRect(0, 0, 50, self.height())
rect_blue = QRect(4, 5, 20, self.height() - 10)
rect_inside_active = QRect(7, 5, self.width(), self.height() - 10)
rect_active_bar = QRect(self.width() - 5, 0, 5, self.height() - 10)
rect_text = QRect(50, 0, self.width() - 50, self.height())
# DRAW BG
p.setBrush(QColor(self._bg_one_color))
# DRAW DEFAULT BG
p.setBrush(QColor(self._dark_one))
p.drawRoundedRect(rect, 0, 0)
# DRAW BG BLUE
p.setBrush(QColor(self._context_color))
p.drawRoundedRect(rect_blue, 8, 8)
# BG INSIDE
p.setBrush(QColor("red"))
p.drawRoundedRect(rect_inside, self._margin, self._margin)
p.setBrush(QColor(self._bg_one))
p.drawRoundedRect(rect_inside_active, 8, 8)
# BG ACTIVE
# p.setBrush(QColor(self._bg_one))
# p.drawRect(rect_active_bar)
# DRAW ICONS
self.icon_paint(p, self._icon_path, rect_icon)
# DRAW ACTIVE
# APP PATH
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.icon_active(p, icon_path, self.width())
# DRAW TEXT
p.setPen(QColor(self._context_color))
p.drawText(rect_text, Qt.AlignVCenter, self.text())
p.end()
# 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._icon_set_color)
qp.drawPixmap(
(rect.width() - icon.width()) / 2,
(rect.height() - icon.height()) / 2,
icon
)
painter.end()
# DRAW ICON WITH COLORS
def icon_active(self, qp, image, width):
icon = QPixmap(image)
painter = QPainter(icon)
painter.setCompositionMode(QPainter.CompositionMode_SourceIn)
painter.fillRect(icon.rect(), self._bg_one)
qp.drawPixmap(width - 5, 0, icon)
painter.end()
class _ActiveIcon(QLabel):
def __init__(self, parent, tooltip):
QLabel.__init__(self)
# LABEL SETUP
self.setObjectName(u"label_tooltip")
self.setStyleSheet(style_tooltip)
self.setMaximumSize(10,60)
self.setMinimumSize(10,60)
self.setParent(parent)
self.setText(tooltip)
self.adjustSize()
# SET DROP SHADOW
self.shadow = QGraphicsDropShadowEffect(self)
self.shadow.setBlurRadius(15)
self.shadow.setXOffset(0)
self.shadow.setYOffset(0)
self.shadow.setColor(QColor(0, 0, 0, 160))
self.setGraphicsEffect(self.shadow)
# SET OPACITY
self.opacity = QGraphicsOpacityEffect(self)
self.opacity.setOpacity(0.85)
self.setGraphicsEffect(self.opacity)
class _ToolTip(QLabel):
def __init__(self, parent, tooltip):
QLabel.__init__(self)
+1 -1
View File
@@ -92,7 +92,7 @@ class PyWindow(QFrame):
if self.settings["custom_title_bar"]:
if enable_shadow:
self.shadow = QGraphicsDropShadowEffect()
self.shadow.setBlurRadius(10)
self.shadow.setBlurRadius(20)
self.shadow.setXOffset(0)
self.shadow.setYOffset(0)
self.shadow.setColor(QColor(0, 0, 0, 160))