This change adds a mechanism to refresh the todo list dynamically when the underlying service updates, improving UI responsiveness and user experience. It also updates documentation and removes deprecated files. - New Features: - Added `_refresh_todos` method to rebuild the todo list when `get_todo_service().todos` changes. - Introduced `TodoListCapture` class for mouse capture handling of the todo list window. - Enhancements: - Updated README with corrected image paths, installation tips, and manual installation commands. - Introduced `start.py` to launch the application or lock mode. - Removed deprecated `config.json` and `debug_memory.py`. - Bug Fixes: - Fixed lock screen screenshot path in README.
48 lines
1.6 KiB
Python
48 lines
1.6 KiB
Python
from fabric.widgets.label import Label
|
|
from utils.utils import svg_file
|
|
from .base import BaseOSDContainer
|
|
from services.capslock import CapsLock
|
|
|
|
|
|
class CapsLockOSDContainer(BaseOSDContainer):
|
|
def __init__(self, window, **kwargs):
|
|
super().__init__(window, **kwargs)
|
|
self.capslock = CapsLock.get_initial()
|
|
self._setup_specific_components()
|
|
self._connect_specific_signals()
|
|
|
|
def _setup_specific_components(self):
|
|
self.osd_image = svg_file(
|
|
"misc/caps-lock.svg",
|
|
size=(100, 100),
|
|
name="osd-image",
|
|
h_align="center",
|
|
v_align="center",
|
|
h_expand=True,
|
|
v_expand=True,
|
|
)
|
|
self.label = Label(name="osd-label")
|
|
self.add(self.osd_image)
|
|
self._update_display(self.capslock.is_on)
|
|
|
|
def _connect_specific_signals(self):
|
|
self.capslock.connect("state_changed", self._on_caps_lock_state_changed)
|
|
|
|
def _on_caps_lock_state_changed(self, _, is_on: bool):
|
|
self._update_display(is_on)
|
|
self.update()
|
|
|
|
def _update_display(self, is_on: bool):
|
|
icon_path = "caps-lock.svg" if is_on else "caps-lock-off.svg"
|
|
self.osd_image.set_from_file(f"misc/{icon_path}")
|
|
if is_on:
|
|
self.add_style_class("capslock-on")
|
|
self.remove_style_class("capslock-off")
|
|
else:
|
|
self.add_style_class("capslock-off")
|
|
self.remove_style_class("capslock-on")
|
|
|
|
def update(self, *_):
|
|
# We don't need a separate display update here as it's handled in the signal
|
|
super().update()
|