Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit151faca

Browse files
committed
feat(bar): add fullscreen detection and visibility toggle
- Implemented a QTimer to monitor fullscreen state and adjust the visibility of the app bar accordingly.- Updated BAR_DEFAULTS to include 'hide_on_fullscreen' flag for configuration.
1 parent6176c3b commit151faca

File tree

2 files changed

+47
-6
lines changed

2 files changed

+47
-6
lines changed

‎src/core/bar.py

Lines changed: 42 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@
22
fromsettingsimportAPP_BAR_TITLE
33
fromPyQt6.QtWidgetsimportQWidget,QHBoxLayout,QGridLayout,QFrame
44
fromPyQt6.QtGuiimportQScreen
5-
fromPyQt6.QtCoreimportQt,QRect,QEvent,QPropertyAnimation,QEasingCurve,QPoint
5+
fromPyQt6.QtCoreimportQt,QRect,QEvent,QPropertyAnimation,QEasingCurve,QPoint,QTimer
66
fromcore.utils.utilitiesimportis_valid_percentage_str,percent_to_float
77
fromcore.utils.win32.utilitiesimportget_monitor_hwnd
88
fromcore.validation.barimportBAR_DEFAULTS
99
fromcore.utils.win32.blurWindowimportBlur
10+
importwin32gui
1011

1112
try:
1213
fromcore.utils.win32importapp_bar
@@ -88,9 +89,7 @@ def __init__(
8889
self.animation_bar()
8990
self.show()
9091

91-
9292

93-
9493
@property
9594
defbar_id(self)->str:
9695
returnself._bar_id
@@ -197,8 +196,46 @@ def showEvent(self, event):
197196
self.animation.start()
198197
exceptAttributeError:
199198
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+
202239
defdetect_os_theme(self)->bool:
203240
try:
204241
importwinreg

‎src/core/validation/bar.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
'alignment': {'position':'top','center':False},
66
'blur_effect': {'enabled':False,'dark_mode':False,'acrylic':False,'round_corners':False,'round_corners_type':'normal','border_color':"System"},
77
'animation': {'enabled':True,'duration':500},
8-
'window_flags': {'always_on_top':False,'windows_app_bar':False},
8+
'window_flags': {'always_on_top':False,'windows_app_bar':False,'hide_on_fullscreen':False},
99
'dimensions': {'width':'100%','height':30},
1010
'padding': {'top':0,'left':0,'bottom':0,'right':0},
1111
'widgets': {'left': [],'center': [],'right': []}
@@ -103,6 +103,10 @@
103103
'windows_app_bar': {
104104
'type':'boolean',
105105
'default':BAR_DEFAULTS['window_flags']['windows_app_bar']
106+
},
107+
'hide_on_fullscreen': {
108+
'type':'boolean',
109+
'default':BAR_DEFAULTS['window_flags']['hide_on_fullscreen']
106110
}
107111
},
108112
'default':BAR_DEFAULTS['window_flags']

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp