]> git.mar77i.info Git - zenbook_gui/commitdiff
Offer fixing xkb layout in the menu. Clean up muted attribute and rename settings...
authormar77i <mar77i@protonmail.ch>
Wed, 17 Sep 2025 22:46:56 +0000 (00:46 +0200)
committermar77i <mar77i@protonmail.ch>
Wed, 17 Sep 2025 22:46:56 +0000 (00:46 +0200)
keyboard/keyboard.py
keyboard/menu.py [moved from keyboard/settings.py with 69% similarity]

index 1ca36f3fec4393e009e3f22462c0439f6257ed84..50c8ee1dee1052ea10856c655aef34cd93dba66c 100644 (file)
@@ -10,7 +10,7 @@ from ui import BaseRoot, FPSWidget
 from .clock import ClockWidget
 from .key import KEYBOARD, get_keyboard_keys
 from .mousepad import MousePadWidget
-from .settings import SettingsModal
+from .menu import MenuModal
 
 # add a launcher symbol
 
@@ -32,10 +32,9 @@ class Root(BaseRoot):
         self.mouse_fingers = {}
         self.display = self.keyboard._display
         self.led_mask = self.display.get_keyboard_control().led_mask
-        self.muted = False
         FPSWidget(self)
         size = self.surf.get_size()
-        self.settings_modal = SettingsModal(
+        self.settings_modal = MenuModal(
             self,
             pygame.Rect((size[0] // 4, size[1] // 4), (size[0] // 2, size[1] // 2)),
         )
@@ -112,8 +111,6 @@ class Root(BaseRoot):
         if led_mask != self.led_mask:
             self.led_mask = led_mask
             self.dirty = True
-#        if self.mouse_frame:
-#            self.move_mouse()
 
     def run(self):
         try:
@@ -122,3 +119,7 @@ class Root(BaseRoot):
         finally:
             for key in self.pushed:
                 (self.mouse if isinstance(key, Button) else self.keyboard).release(key)
+
+    @property
+    def muted(self):
+        return self.settings_modal.muted
similarity index 69%
rename from keyboard/settings.py
rename to keyboard/menu.py
index 430c438d7190832d73e4bf823cb5dbb68d54aeab..c21861d7f22132239827bc6ca6364dd13af74227 100644 (file)
@@ -2,6 +2,7 @@ import os
 import sys
 from functools import partial
 from pathlib import Path
+from subprocess import run
 
 import pygame
 
@@ -19,32 +20,39 @@ from .layout import LayoutModal
 #   - three available widgets: touchpad mouse, number keypad, cursor and navkeys
 
 
-class SettingsModal(QuittableModal):
+class MenuModal(QuittableModal):
     def __init__(self, parent, rect):
         super().__init__(parent)
         self.rect = rect
-        Rect(self, rect, "black", "gray")
-        width = rect.width * 2 / 3
-        height = rect.height / 7
-        left = rect.left + (rect.width - width) / 2 + 8
-        y = rect.top + height + 8
-        rect_size = (width - 16, height - 16)
         self.layout_modal = LayoutModal(parent)
-        for args in (
-            ("Mute", None, self.root.muted),
+        self.muted = False
+        Rect(self, rect, "black", "gray")
+        buttons_args = (
+            ("Mute", None, self.muted),
             ("Layout...", self.layout_modal.activate),
+            ("Fix Xkb layout", self.fix_xkb_layout),
             ("Restart", self.restart),
             ("Exit", self.root.handle_quit),
             ("Back", self.deactivate),
-        ):
-            button = TouchButton(self, pygame.Rect((left, y), rect_size), *args)
+        )
+        width = rect.width * 2 / 3
+        height = rect.height / len(buttons_args)
+        left = rect.left + (rect.width - width) / 2 + 8
+        y = rect.top + 8
+        for args in buttons_args:
+            button = TouchButton(
+                self, pygame.Rect((left, y), (width - 16, height - 16)), *args
+            )
             if args[0] == "Mute":
                 button.callback = partial(self.mute, button)
             y += height
 
     def mute(self, button):
-        self.root.muted ^= True
-        button.highlight = self.root.muted
+        self.muted ^= True
+        button.highlight = self.muted
+
+    def fix_xkb_layout(self):
+        run(["setxkbmap", "-synch"])
 
     def restart(self):
         executable = Path(sys.executable).name