"""
Module for controlling the theme of the application.
This module contains the ControlThemeApps class, which provides methods for initializing the UI with
the current theme and for changing the theme between light and dark modes.
Class:
ControlThemeApps: A class for controlling the theme of the application.
"""
from PyQt6 import QtGui, QtCore
[docs]
class ControlThemeApps:
"""
Class for controlling the theme of the application.
Attributes:
_controller: The controller object.
_ui_object: The UI object.
_model: The model object.
Methods:
__init__(self, controller): Initializes the ControlThemeApps object.
init_ui(self): Initializes the UI with the current theme.
onclick_change_theme_apps(self): Changes the theme between light and dark modes.
"""
[docs]
def __init__(self, controller):
"""
Initialize the ControlThemeApps object.
Arg:
controller: The controller object.
Return:
None
"""
self._controller = controller
self._ui_object = controller.ui_object
self._model = controller.model
self.init_ui()
[docs]
def init_ui(self):
"""
Initialize the UI with the current theme.
Return:
None
"""
self._ui_object.label_result.setMinimumSize(QtCore.QSize(0, 0))
self._ui_object.label_result.setMaximumSize(QtCore.QSize(700, 170))
self._ui_object.label_result.setPixmap(QtGui.QPixmap("icons:moilapp.png"))
self._ui_object.label_result.setScaledContents(True)
self._ui_object.frame_image_original.setMinimumSize(QtCore.QSize(0, 200))
self._ui_object.label_image_original.setMinimumSize(QtCore.QSize(0, 0))
self._ui_object.label_image_original.setMaximumSize(QtCore.QSize(200, 50))
self._ui_object.label_image_original.setPixmap(QtGui.QPixmap("icons:moilapp.png"))
self._ui_object.label_image_original.setScaledContents(True)
[docs]
def onclick_change_theme_apps(self):
"""
Change the theme between light and dark modes.
"""
if self._model.debug_mode:
self._model.activity_logger.info("ControlThemeApps: onclick_change_theme_apps(), "
"Click change theme App")
icon = QtGui.QIcon()
if self._controller.model.theme_mode == "light":
color = "background-color: rgb(255, 255, 255); color: rgb(0, 0, 0);"
self._controller.setStyleSheet(self._controller.model.style_light_mode)
icon.addPixmap(QtGui.QPixmap("icons:sun.svg"), QtGui.QIcon.Mode.Normal, QtGui.QIcon.State.Off)
self._controller.model.theme_mode = "dark"
else:
color = "background-color: rgb(44, 49, 58); color: rgb(255, 255, 255);"
self._controller.setStyleSheet(self._controller.model.style_dark_mode)
icon.addPixmap(QtGui.QPixmap("icons:light/moon.svg"), QtGui.QIcon.Mode.Normal, QtGui.QIcon.State.Off)
self._controller.model.theme_mode = "light"
self._controller.ui_object.statusBar.setStyleSheet(color)
self._controller.ui_object.btn_change_theme.setIcon(icon)
if self._controller.model.image_original is not None:
if self._controller.model.mode_view == "FisheyeView":
self._controller.ui_object.btn_fisheye_view.setStyleSheet(
self._controller.ctrl_stylesheet.set_style_selected_menu())
elif self._controller.model.mode_view == "AnypointView":
self._controller.ui_object.btn_anypoint_view.setStyleSheet(
self._controller.ctrl_stylesheet.set_style_selected_menu())
elif self._controller.model.mode_view == "PanoramaView":
self._controller.ui_object.btn_panorama_view.setStyleSheet(
self._controller.ctrl_stylesheet.set_style_selected_menu())