|
2 | 2 | fromsettingsimportAPP_BAR_TITLE
|
3 | 3 | fromPyQt6.QtWidgetsimportQWidget,QHBoxLayout,QGridLayout,QFrame
|
4 | 4 | fromPyQt6.QtGuiimportQScreen
|
5 |
| -fromPyQt6.QtCoreimportQt,QRect,QEvent,QPropertyAnimation,QEasingCurve,QPoint |
| 5 | +fromPyQt6.QtCoreimportQt,QRect,QEvent,QPropertyAnimation,QEasingCurve,QPoint,QTimer |
6 | 6 | fromcore.utils.utilitiesimportis_valid_percentage_str,percent_to_float
|
7 | 7 | fromcore.utils.win32.utilitiesimportget_monitor_hwnd
|
8 | 8 | fromcore.validation.barimportBAR_DEFAULTS
|
9 | 9 | fromcore.utils.win32.blurWindowimportBlur
|
| 10 | +importwin32gui |
10 | 11 |
|
11 | 12 | try:
|
12 | 13 | fromcore.utils.win32importapp_bar
|
@@ -88,9 +89,7 @@ def __init__(
|
88 | 89 | self.animation_bar()
|
89 | 90 | self.show()
|
90 | 91 |
|
91 |
| - |
92 | 92 |
|
93 |
| - |
94 | 93 | @property
|
95 | 94 | defbar_id(self)->str:
|
96 | 95 | returnself._bar_id
|
@@ -197,8 +196,46 @@ def showEvent(self, event):
|
197 | 196 | self.animation.start()
|
198 | 197 | exceptAttributeError:
|
199 | 198 | logging.error("Animation not initialized.")
|
200 |
| - |
201 |
| - |
| 199 | +ifnothasattr(self,"_fullscreen_timer")andself._window_flags['hide_on_fullscreen']andself._window_flags['always_on_top']: |
| 200 | +self._fullscreen_timer=QTimer(self) |
| 201 | +self._fullscreen_timer.setInterval(500) |
| 202 | +self._fullscreen_timer.timeout.connect(self.is_foreground_fullscreen) |
| 203 | +self._fullscreen_timer.start() |
| 204 | + |
| 205 | + |
| 206 | +defis_foreground_fullscreen(self): |
| 207 | +# Get the active window's handle using win32gui |
| 208 | +hwnd=win32gui.GetForegroundWindow() |
| 209 | +ifnothwnd: |
| 210 | +return |
| 211 | + |
| 212 | +# Get the window rectangle: (left, top, right, bottom) then convert to (x, y, width, height) |
| 213 | +rect=win32gui.GetWindowRect(hwnd) |
| 214 | +window_rect= (rect[0],rect[1],rect[2]-rect[0],rect[3]-rect[1]) |
| 215 | + |
| 216 | +# Get the primary screen geometry |
| 217 | +screen_geometry=self.screen().geometry() |
| 218 | +screen_rect= ( |
| 219 | +screen_geometry.x(), |
| 220 | +screen_geometry.y(), |
| 221 | +screen_geometry.width(), |
| 222 | +screen_geometry.height() |
| 223 | + ) |
| 224 | +# Determine fullscreen state |
| 225 | +is_fullscreen= (window_rect==screen_rect) |
| 226 | +# Cache the previous state so we only update if it changes |
| 227 | +ifhasattr(self,"_prev_fullscreen_state")andself._prev_fullscreen_state==is_fullscreen: |
| 228 | +return |
| 229 | +self._prev_fullscreen_state=is_fullscreen |
| 230 | +# Update visibility only when necessary |
| 231 | +ifis_fullscreen: |
| 232 | +ifself.isVisible(): |
| 233 | +self.hide() |
| 234 | +else: |
| 235 | +ifnotself.isVisible(): |
| 236 | +self.show() |
| 237 | + |
| 238 | + |
202 | 239 | defdetect_os_theme(self)->bool:
|
203 | 240 | try:
|
204 | 241 | importwinreg
|
|