From a30ddc3fb6406a3f94870ea54ba1a2bbfd2a301a Mon Sep 17 00:00:00 2001 From: S4NKALP Date: Mon, 6 Jul 2026 20:22:51 +0545 Subject: [PATCH] refactor(src/window/osd/components): remove deprecated OSD capslock and keyboard layout components --- src/window/osd/components/capslock.py | 56 -------------------- src/window/osd/components/keyboard_layout.py | 48 ----------------- 2 files changed, 104 deletions(-) delete mode 100644 src/window/osd/components/capslock.py delete mode 100644 src/window/osd/components/keyboard_layout.py diff --git a/src/window/osd/components/capslock.py b/src/window/osd/components/capslock.py deleted file mode 100644 index 8e38113..0000000 --- a/src/window/osd/components/capslock.py +++ /dev/null @@ -1,56 +0,0 @@ -from fabric.utils import logger -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() - - def destroy(self): - """Disconnect signals from CapsLock service""" - try: - self.capslock.disconnect_by_func(self._on_caps_lock_state_changed) - except Exception as e: - logger.error(f"An error occurred: {e}") - super().destroy() diff --git a/src/window/osd/components/keyboard_layout.py b/src/window/osd/components/keyboard_layout.py deleted file mode 100644 index 0c2ec7a..0000000 --- a/src/window/osd/components/keyboard_layout.py +++ /dev/null @@ -1,48 +0,0 @@ -from fabric.utils import logger -from fabric.widgets.label import Label -from utils.utils import svg_file -from .base import BaseOSDContainer -from services.keyboard_layout import KeyboardLayout - - -class KeyboardLayoutOSDContainer(BaseOSDContainer): - def __init__(self, window, **kwargs): - super().__init__(window, **kwargs) - self.keyboard_layout = KeyboardLayout.get_initial() - self._setup_specific_components() - self._connect_specific_signals() - - def _setup_specific_components(self): - self.osd_image = svg_file( - "misc/keyboard-layout.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.add(self.label) - self.label.set_text(self.keyboard_layout.current_layout) - - def _connect_specific_signals(self): - self.keyboard_layout.connect("layout_changed", self._on_layout_changed) - - def _on_layout_changed(self, service, layout: str): - if not self.is_hovered(): - self.label.set_text(layout) - self.update() - - def update(self, *_): - self.label.set_text(self.keyboard_layout.current_layout) - super().update() - - def destroy(self): - """Disconnect signals from KeyboardLayout service""" - try: - self.keyboard_layout.disconnect_by_func(self._on_layout_changed) - except Exception as e: - logger.error(f"An error occurred: {e}") - super().destroy()