YouTubeDownloader v1.1.2
YouTube content downloader
Loading...
Searching...
No Matches
monitor.py
Go to the documentation of this file.
1"""!
2********************************************************************************
3@file monitor.py
4@brief handle windows size and scale factor and update items
5********************************************************************************
6"""
7
8import logging
9from typing import Optional, TYPE_CHECKING
10import customtkinter
11import darkdetect
12
13from Source.version import __title__
14from Source.Util.app_data import ETheme
15
16if TYPE_CHECKING:
17 from Source.Controller.main_window import MainWindow
18
19log = logging.getLogger(__title__)
20
21
23 """!
24 @brief Class to scale text and item positions.
25 @param ui : main window object
26 """
27
28 def __init__(self, ui: "MainWindow"):
29 self.ui = ui
30 self.e_style = ETheme.SYSTEM # set theme here
31 self.e_actual_theme = ETheme.LIGHT
33
34 def check_for_style_change(self, e_style: Optional[ETheme] = None) -> None:
35 """!
36 @brief Check for style change
37 @param e_style : style to set
38 """
39 if e_style is None:
40 e_style = self.e_style
41 old_style = self.e_actual_theme
42 match e_style:
43 case ETheme.LIGHT:
44 self.e_actual_theme = ETheme.LIGHT
45 case ETheme.DARK:
46 self.e_actual_theme = ETheme.DARK
47 case ETheme.SYSTEM:
48 self.e_actual_theme = ETheme.LIGHT if darkdetect.isLight() else ETheme.DARK
49 case _:
50 log.warning("Invalid theme change: %s", e_style)
51 if old_style != self.e_actual_theme:
52 self.set_dialog_style()
53
54 def update_darkmode_status(self, e_style: ETheme) -> None:
55 """!
56 @brief Update dark mode status.
57 @param e_style : select theme mode
58 """
59 self.e_style = e_style
61 self.set_dialog_style()
62
63 def set_dialog_style(self) -> None:
64 """!
65 @brief Set dialog theme style.
66 """
67 match self.e_actual_theme:
68 case ETheme.LIGHT:
69 customtkinter.set_appearance_mode("light")
70 case ETheme.DARK:
71 customtkinter.set_appearance_mode("dark")
72 case _:
73 log.warning("Invalid actual theme: %s", self.e_actual_theme)
74
75 def is_light_theme(self) -> bool:
76 """!
77 @brief get status for active light theme (or classic -> not dark).
78 @return status if theme is light
79 """
80 light_status = bool(self.e_actual_theme != ETheme.DARK)
81 return light_status
Class to scale text and item positions.
Definition monitor.py:22
bool is_light_theme(self)
get status for active light theme (or classic -> not dark).
Definition monitor.py:75
None update_darkmode_status(self, ETheme e_style)
Update dark mode status.
Definition monitor.py:54
__init__(self, "MainWindow" ui)
Definition monitor.py:28
None check_for_style_change(self, Optional[ETheme] e_style=None)
Check for style change.
Definition monitor.py:34
None set_dialog_style(self)
Set dialog theme style.
Definition monitor.py:63