WCAG: Add reduce_motion config, bridge property, OS detection
Config default, reduceMotion Q_PROPERTY on UIBridge, Windows SystemParametersInfo detection for prefers-reduced-motion.
This commit is contained in:
15
main.py
15
main.py
@@ -80,6 +80,21 @@ try:
|
|||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
# Detect Windows "Reduce Motion" preference
|
||||||
|
try:
|
||||||
|
import ctypes
|
||||||
|
SPI_GETCLIENTAREAANIMATION = 0x1042
|
||||||
|
animation_enabled = ctypes.c_bool(True)
|
||||||
|
ctypes.windll.user32.SystemParametersInfoW(
|
||||||
|
SPI_GETCLIENTAREAANIMATION, 0,
|
||||||
|
ctypes.byref(animation_enabled), 0
|
||||||
|
)
|
||||||
|
if not animation_enabled.value:
|
||||||
|
ConfigManager().data["reduce_motion"] = True
|
||||||
|
ConfigManager().save()
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
|
||||||
# Configure Logging
|
# Configure Logging
|
||||||
class QmlLoggingHandler(logging.Handler, QObject):
|
class QmlLoggingHandler(logging.Handler, QObject):
|
||||||
sig_log = Signal(str)
|
sig_log = Signal(str)
|
||||||
|
|||||||
@@ -58,7 +58,10 @@ DEFAULT_SETTINGS = {
|
|||||||
|
|
||||||
|
|
||||||
# Low VRAM Mode
|
# Low VRAM Mode
|
||||||
"unload_models_after_use": False # If True, models are unloaded immediately to free VRAM
|
"unload_models_after_use": False, # If True, models are unloaded immediately to free VRAM
|
||||||
|
|
||||||
|
# Accessibility
|
||||||
|
"reduce_motion": False # Disable animations for WCAG 2.3.3
|
||||||
}
|
}
|
||||||
|
|
||||||
class ConfigManager:
|
class ConfigManager:
|
||||||
|
|||||||
@@ -111,6 +111,7 @@ class UIBridge(QObject):
|
|||||||
settingChanged = Signal(str, 'QVariant')
|
settingChanged = Signal(str, 'QVariant')
|
||||||
modelStatesChanged = Signal() # Notify UI to re-check isModelDownloaded
|
modelStatesChanged = Signal() # Notify UI to re-check isModelDownloaded
|
||||||
llmDownloadRequested = Signal()
|
llmDownloadRequested = Signal()
|
||||||
|
reduceMotionChanged = Signal(bool)
|
||||||
|
|
||||||
def __init__(self, parent=None):
|
def __init__(self, parent=None):
|
||||||
super().__init__(parent)
|
super().__init__(parent)
|
||||||
@@ -130,6 +131,7 @@ class UIBridge(QObject):
|
|||||||
self._app_vram_mb = 0.0
|
self._app_vram_mb = 0.0
|
||||||
self._app_vram_percent = 0.0
|
self._app_vram_percent = 0.0
|
||||||
self._is_destroyed = False
|
self._is_destroyed = False
|
||||||
|
self._reduce_motion = bool(ConfigManager().get("reduce_motion"))
|
||||||
|
|
||||||
# Start QThread Stats Worker
|
# Start QThread Stats Worker
|
||||||
self.stats_worker = StatsWorker()
|
self.stats_worker = StatsWorker()
|
||||||
@@ -277,6 +279,8 @@ class UIBridge(QObject):
|
|||||||
ConfigManager().set(key, value)
|
ConfigManager().set(key, value)
|
||||||
if key == "ui_scale":
|
if key == "ui_scale":
|
||||||
self.uiScale = float(value)
|
self.uiScale = float(value)
|
||||||
|
if key == "reduce_motion":
|
||||||
|
self.reduceMotion = bool(value)
|
||||||
self.settingChanged.emit(key, value) # Notify listeners (e.g. Overlay)
|
self.settingChanged.emit(key, value) # Notify listeners (e.g. Overlay)
|
||||||
|
|
||||||
@Property(float, notify=uiScaleChanged)
|
@Property(float, notify=uiScaleChanged)
|
||||||
@@ -288,6 +292,15 @@ class UIBridge(QObject):
|
|||||||
self._ui_scale = val
|
self._ui_scale = val
|
||||||
self.uiScaleChanged.emit(val)
|
self.uiScaleChanged.emit(val)
|
||||||
|
|
||||||
|
@Property(bool, notify=reduceMotionChanged)
|
||||||
|
def reduceMotion(self): return self._reduce_motion
|
||||||
|
|
||||||
|
@reduceMotion.setter
|
||||||
|
def reduceMotion(self, val):
|
||||||
|
if self._reduce_motion != val:
|
||||||
|
self._reduce_motion = val
|
||||||
|
self.reduceMotionChanged.emit(val)
|
||||||
|
|
||||||
@Property(float, notify=appCpuChanged)
|
@Property(float, notify=appCpuChanged)
|
||||||
def appCpu(self): return self._app_cpu
|
def appCpu(self): return self._app_cpu
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user