feat(ui): icon-only help buttons, Backspace undoes
public
feat(ui): icon-only help buttons, Backspace undoes - Hint and threat split buttons without labels; second hint step named in the tooltip instead - Backspace as second undo key via bubble-phase controller, not an app accel, so text fields keep it Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
| Changeset | 447ade111494cb23613b64282a5dd743a0397d6e |
|---|---|
| Author (claimed) | Timo Stolz <timo.stolz@nullachtvierzehn.de>, |
| Parents | 2253b73de93a |
| Children | dbcddca5f6c7 |
| Pushlog | by timo via ssh by timo via ssh |
modified README.md +1 −1
| @@ -97,7 +97,7 @@ Ins App-Menü aufnehmen: | ||
| 97 | 97 | | Taste | Aktion | |
| 98 | 98 | |---|---| |
| 99 | 99 | | Strg+N | Neue Partie | |
| 100 | -| Strg+Z | Zug zurücknehmen | | |
| 100 | +| Strg+Z oder Rücktaste | Zug zurücknehmen | | |
| 101 | 101 | | H | Hinweis | |
| 102 | 102 | | B | Drohung zeigen | |
| 103 | 103 | | F | Brett drehen | |
modified schach/app.py +17 −4
| @@ -50,7 +50,7 @@ FEATURED_THEMES = [ | ||
| 50 | 50 | # Übersicht für den Reiter „Tastenkürzel“ in den Einstellungen |
| 51 | 51 | SHORTCUTS = [ |
| 52 | 52 | ("Partie", [ |
| 53 | - ("Neue Partie", "<Control>n"), ("Zug zurücknehmen", "<Control>z"), | |
| 53 | + ("Neue Partie", "<Control>n"), ("Zug zurücknehmen", "<Control>z BackSpace"), | |
| 54 | 54 | ("Hinweis", "h"), ("Drohung zeigen", "b"), ("Neues Rätsel", "r"), |
| 55 | 55 | ]), |
| 56 | 56 | ("Ansicht", [ |
| @@ -258,9 +258,8 @@ class Window(OnlineMixin, PuzzleMixin, O | ||
| 258 | 258 | threat_menu = Gio.Menu() |
| 259 | 259 | threat_menu.append_section("Drohung von", sources) |
| 260 | 260 | self.helper_menu = helper_menu |
| 261 | - self.hint_content = Adw.ButtonContent(icon_name="dialog-information-symbolic", label="Hinweis") | |
| 262 | 261 | self.hint_btn = Adw.SplitButton( |
| 263 | - child=self.hint_content, menu_model=helper_menu, dropdown_tooltip="Wer hilft?", | |
| 262 | + icon_name="dialog-information-symbolic", menu_model=helper_menu, dropdown_tooltip="Wer hilft?", | |
| 264 | 263 | ) |
| 265 | 264 | self.hint_btn.set_action_name("win.hint") |
| 266 | 265 | self.help_box = Gtk.Box(spacing=6) |
| @@ -337,6 +336,14 @@ class Window(OnlineMixin, PuzzleMixin, O | ||
| 337 | 336 | self.view.set_focusable(True) |
| 338 | 337 | self.set_focus(self.view) |
| 339 | 338 | |
| 339 | + # Rücktaste nimmt auch zurück – aber nicht als App-Kürzel, sonst fehlt sie in Textfeldern | |
| 340 | + backspace = Gtk.ShortcutController(propagation_phase=Gtk.PropagationPhase.BUBBLE) | |
| 341 | + backspace.add_shortcut(Gtk.Shortcut( | |
| 342 | + trigger=Gtk.ShortcutTrigger.parse_string("BackSpace"), | |
| 343 | + action=Gtk.CallbackAction.new(self._backspace_undo), | |
| 344 | + )) | |
| 345 | + self.add_controller(backspace) | |
| 346 | + | |
| 340 | 347 | self.set_size_request(360, 480) |
| 341 | 348 | breakpoint = Adw.Breakpoint.new(Adw.BreakpointCondition.parse("max-width: 560sp")) |
| 342 | 349 | breakpoint.connect("apply", lambda *_: self._set_narrow(True)) |
| @@ -614,10 +621,10 @@ class Window(OnlineMixin, PuzzleMixin, O | ||
| 614 | 621 | self._action("duo-draw").set_enabled(self.mode == "duo" and not self._over()) |
| 615 | 622 | self._action("duo-resign").set_enabled(self.mode == "duo" and not self._over()) |
| 616 | 623 | self._action("hint").set_enabled(can_hint) |
| 617 | - self.hint_content.set_label("Zug zeigen" if self.hint_level == 1 else "Hinweis") | |
| 618 | 624 | self.hint_btn.set_tooltip_text( |
| 619 | 625 | "Hinweis (H) – das Rätsel zählt dann nicht als gelöst" if self.mode == "puzzle" |
| 620 | 626 | else "Kurszug zeigen (H)" if self.mode == "opening" |
| 627 | + else f"Zug zeigen (H) – von {HELPERS[self._helper()][0]}" if self.hint_level == 1 | |
| 621 | 628 | else f"Hinweis von {HELPERS[self._helper()][0]} (H)" |
| 622 | 629 | ) |
| 623 | 630 | self._action("hint-helper").set_enabled(self.mode in ("maia", "duo")) # Rätsel: Hinweis = Lösung |
| @@ -940,6 +947,12 @@ class Window(OnlineMixin, PuzzleMixin, O | ||
| 940 | 947 | self.maia_ready = True |
| 941 | 948 | self._refresh() |
| 942 | 949 | |
| 950 | + def _backspace_undo(self, *_): | |
| 951 | + if isinstance(self.get_focus(), Gtk.Editable) or not self._action("undo").get_enabled(): | |
| 952 | + return False | |
| 953 | + self.activate_action("win.undo", None) | |
| 954 | + return True | |
| 955 | + | |
| 943 | 956 | def undo(self, *_): |
| 944 | 957 | if self.mode == "online": |
| 945 | 958 | self._takeback_request() |