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
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)),
)
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:
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
import sys
from functools import partial
from pathlib import Path
+from subprocess import run
import pygame
# - 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