Source code for controllers.control_main_ui_apps
from PyQt6 import QtCore
[docs]
class ControlApps:
def __init__(self, main_ui):
self.ui = main_ui
[docs]
def button_about_us(self, enable, theme):
"""Animate the "About Us" button and expand the right-hand additional frame.
Args:
enable (bool): True to enable the animation and expand the frame, False to disable.
theme (str): The current theme ("light" or "dark").
Returns:
None
"""
if enable:
# GET WIDTH
width = self.ui.frame_additional_right.width()
widthLeftBox = self.ui.frame_additional_left.width()
standard = 0
style = self.ui.btn_setting.styleSheet()
# SET MAX WIDTH
if widthLeftBox != 0:
color = "background-color: rgb(238, 238, 236);"
color_dark = "background-color: rgb(33, 37, 43);"
self.ui.btn_setting.setStyleSheet(style + color)
if theme == "dark":
self.ui.btn_setting.setStyleSheet(style + color_dark)
self.start_box_animation(widthLeftBox, width, "right")
[docs]
def start_box_animation(self, left_box_width, right_box_width, direction):
"""Animate the left and right boxes to slide in or out.
Args:
left_box_width (int): The current width of the left box.
right_box_width (int): The current width of the right box.
direction (str): The direction in which to animate the boxes, either "left" or "right".
Returns:
None
"""
# Check values
if left_box_width == 0 and direction == "left":
left_width = 240
else:
left_width = 0
# Check values
if right_box_width == 0 and direction == "right":
right_width = 240
else:
right_width = 0
# ANIMATION LEFT BOX
left_box = QtCore.QPropertyAnimation(self.ui.frame_additional_left, b"minimumWidth")
left_box.setDuration(500)
left_box.setStartValue(left_box_width)
left_box.setEndValue(left_width)
left_box.setEasingCurve(QtCore.QEasingCurve.Type.InOutQuart)
# # ANIMATION RIGHT BOX
right_box = QtCore.QPropertyAnimation(self.ui.frame_additional_right, b"minimumWidth")
right_box.setDuration(500)
right_box.setStartValue(right_box_width)
right_box.setEndValue(right_width)
right_box.setEasingCurve(QtCore.QEasingCurve.Type.InOutQuart)
# GROUP ANIMATION
self.group = QtCore.QParallelAnimationGroup()
self.group.addAnimation(left_box)
self.group.addAnimation(right_box)
self.group.start()