| @@ -47,6 +47,29 @@ FEATURED_THEMES = [ |
| 47 | 47 | "maestro", "companion", "fresca", "leipzig", "chessnut", "python-chess", |
| 48 | 48 | ] |
| 49 | 49 | |
| 50 | +# Übersicht für den Reiter „Tastenkürzel“ in den Einstellungen |
| 51 | +SHORTCUTS = [ |
| 52 | + ("Partie", [ |
| 53 | + ("Neue Partie", "<Control>n"), ("Zug zurücknehmen", "<Control>z"), |
| 54 | + ("Hinweis", "h"), ("Drohung zeigen", "b"), ("Neues Rätsel", "r"), |
| 55 | + ]), |
| 56 | + ("Ansicht", [ |
| 57 | + ("Brett drehen", "f"), ("Zugliste und Bewertung", "a"), |
| 58 | + ("Zurück zur aktuellen Stellung", "Escape"), |
| 59 | + ]), |
| 60 | + ("Spielstände", [ |
| 61 | + ("Spielstand speichern", "<Control>s"), ("Spielstände öffnen", "<Control>o"), |
| 62 | + ("Exportieren (PGN, Bild, PDF, HTML …)", "<Control><Shift>s"), |
| 63 | + ]), |
| 64 | + ("Zwischenablage", [ |
| 65 | + ("Partie als PGN kopieren", "<Control>c"), |
| 66 | + ("Stellung als FEN kopieren", "<Control><Shift>c"), |
| 67 | + ("Partie, Stellung oder Lichess-Link einfügen", "<Control>v"), |
| 68 | + ]), |
| 69 | + ("Allgemein", [("Einstellungen", "<Control>comma"), ("Tastenkürzel", "<Control>question")]), |
| 70 | +] |
| 71 | +ICON_DIR = os.path.join(os.path.dirname(__file__), "icons") |
| 72 | + |
| 50 | 73 | SETTINGS_PATH = os.path.join(GLib.get_user_config_dir(), "schach", "settings.json") |
| 51 | 74 | DEFAULTS = { |
| 52 | 75 | "elo": 1200, "color": "white", "theme": "cburnett", "puzzle_difficulty": "normal", |
| @@ -232,7 +255,8 @@ class Window(OnlineMixin, PuzzleMixin, O |
| 232 | 255 | sources.append(label, f"win.threat-source::{key}") |
| 233 | 256 | helper_menu = Gio.Menu() |
| 234 | 257 | helper_menu.append_section("Hinweis von", helpers) |
| 235 | | - helper_menu.append_section("Drohung von", sources) |
| 258 | + threat_menu = Gio.Menu() |
| 259 | + threat_menu.append_section("Drohung von", sources) |
| 236 | 260 | self.helper_menu = helper_menu |
| 237 | 261 | self.hint_content = Adw.ButtonContent(icon_name="dialog-information-symbolic", label="Hinweis") |
| 238 | 262 | self.hint_btn = Adw.SplitButton( |
| @@ -241,7 +265,9 @@ class Window(OnlineMixin, PuzzleMixin, O |
| 241 | 265 | self.hint_btn.set_action_name("win.hint") |
| 242 | 266 | self.help_box = Gtk.Box(spacing=6) |
| 243 | 267 | self.help_box.append(self.hint_btn) |
| 244 | | - self.threat_btn = Gtk.Button(icon_name="dialog-warning-symbolic") |
| 268 | + self.threat_btn = Adw.SplitButton( |
| 269 | + icon_name="schach-threat-symbolic", menu_model=threat_menu, dropdown_tooltip="Wer droht?", |
| 270 | + ) |
| 245 | 271 | self.threat_btn.set_action_name("win.threat") |
| 246 | 272 | self.help_box.append(self.threat_btn) |
| 247 | 273 | self.help_box.append(self._build_duo_button()) |
| @@ -1373,16 +1399,20 @@ class Window(OnlineMixin, PuzzleMixin, O |
| 1373 | 1399 | self.movelist.notation = self._notation() |
| 1374 | 1400 | self._refresh() |
| 1375 | 1401 | |
| 1376 | | - def _preferences_dialog(self, *_): |
| 1402 | + def _preferences_dialog(self, *_, page=None): |
| 1377 | 1403 | if self.prefs_dialog is not None: |
| 1404 | + if page: |
| 1405 | + self.prefs_dialog.show_page(page) |
| 1378 | 1406 | return |
| 1379 | 1407 | installed = set(available_themes()) |
| 1380 | 1408 | themes = [ |
| 1381 | 1409 | (name, "Eingebaut" if name == "python-chess" else name.capitalize()) |
| 1382 | 1410 | for name in FEATURED_THEMES if name in installed |
| 1383 | 1411 | ] |
| 1384 | | - dialog = self.prefs_dialog = Preferences(self, themes) |
| 1412 | + dialog = self.prefs_dialog = Preferences(self, themes, SHORTCUTS) |
| 1385 | 1413 | dialog.connect("closed", lambda *_: setattr(self, "prefs_dialog", None)) |
| 1414 | + if page: |
| 1415 | + dialog.show_page(page) |
| 1386 | 1416 | dialog.present(self) |
| 1387 | 1417 | |
| 1388 | 1418 | # --- Dialoge ----------------------------------------------------------- |
| @@ -1452,32 +1482,8 @@ class Window(OnlineMixin, PuzzleMixin, O |
| 1452 | 1482 | Gtk.UriLauncher.new(f"https://lichess.org/{self.online_id}").launch(self, None, None, None) |
| 1453 | 1483 | |
| 1454 | 1484 | def _shortcuts_dialog(self, *_): |
| 1455 | | - dialog = Adw.ShortcutsDialog() |
| 1456 | | - for title, items in [ |
| 1457 | | - ("Partie", [ |
| 1458 | | - ("Neue Partie", "<Control>n"), ("Zug zurücknehmen", "<Control>z"), |
| 1459 | | - ("Hinweis", "h"), ("Drohung zeigen", "b"), ("Neues Rätsel", "r"), |
| 1460 | | - ]), |
| 1461 | | - ("Ansicht", [ |
| 1462 | | - ("Brett drehen", "f"), ("Zugliste und Bewertung", "a"), |
| 1463 | | - ("Zurück zur aktuellen Stellung", "Escape"), |
| 1464 | | - ]), |
| 1465 | | - ("Spielstände", [ |
| 1466 | | - ("Spielstand speichern", "<Control>s"), ("Spielstände öffnen", "<Control>o"), |
| 1467 | | - ("Exportieren (PGN, Bild, PDF, HTML …)", "<Control><Shift>s"), |
| 1468 | | - ]), |
| 1469 | | - ("Zwischenablage", [ |
| 1470 | | - ("Partie als PGN kopieren", "<Control>c"), |
| 1471 | | - ("Stellung als FEN kopieren", "<Control><Shift>c"), |
| 1472 | | - ("Partie, Stellung oder Lichess-Link einfügen", "<Control>v"), |
| 1473 | | - ]), |
| 1474 | | - ("Allgemein", [("Einstellungen", "<Control>comma"), ("Tastenkürzel", "<Control>question")]), |
| 1475 | | - ]: |
| 1476 | | - section = Adw.ShortcutsSection(title=title) |
| 1477 | | - for label, accel in items: |
| 1478 | | - section.add(Adw.ShortcutsItem.new(label, accel)) |
| 1479 | | - dialog.add(section) |
| 1480 | | - dialog.present(self) |
| 1485 | + """Tastenkürzel stehen als eigener Reiter in den Einstellungen.""" |
| 1486 | + self._preferences_dialog(page="shortcuts") |
| 1481 | 1487 | |
| 1482 | 1488 | def _about_dialog(self, *_): |
| 1483 | 1489 | about = Adw.AboutDialog( |
| @@ -1721,6 +1727,8 @@ class SchachApp(Adw.Application): |
| 1721 | 1727 | |
| 1722 | 1728 | def do_startup(self): |
| 1723 | 1729 | Adw.Application.do_startup(self) |
| 1730 | + # eigene Symbole (z. B. das Schwert für Drohungen), eingefärbt wie die GNOME-Symbole |
| 1731 | + Gtk.IconTheme.get_for_display(Gdk.Display.get_default()).add_search_path(ICON_DIR) |
| 1724 | 1732 | self.maia = EngineWorker(MAIA_CMD, on_ready=self._on_maia_ready) |
| 1725 | 1733 | self.stockfish = EngineWorker( |
| 1726 | 1734 | STOCKFISH_CMD, options={"Threads": min(8, os.cpu_count() or 2), "Hash": 256} |