From b419ed7922e12ad301cbfd18a9db22af1658ca9d Mon Sep 17 00:00:00 2001 From: Rafostar <40623528+Rafostar@users.noreply.github.com> Date: Mon, 3 May 2021 19:02:37 +0200 Subject: [PATCH] Add keyboard shortcuts window --- src/actions.js | 13 +++++ ui/clapper.ui | 8 +-- ui/help-overlay.ui | 133 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 149 insertions(+), 5 deletions(-) create mode 100644 ui/help-overlay.ui diff --git a/src/actions.js b/src/actions.js index 326e01b9..a1fa0f4d 100644 --- a/src/actions.js +++ b/src/actions.js @@ -1,10 +1,13 @@ +const { Gtk } = imports.gi; const Dialogs = imports.src.dialogs; +const Misc = imports.src.misc; var actions = { open_local: ['O'], export_playlist: ['E'], open_uri: ['U'], prefs: null, + shortcuts: ['F1', 'question'], about: null, progress_forward: ['Right'], progress_backward: ['Left'], @@ -40,6 +43,16 @@ function handleAction(action, window) case 'prefs': new Dialogs.PrefsDialog(window); break; + case 'shortcuts': + if(!window.get_help_overlay()) { + const clapperPath = Misc.getClapperPath(); + const helpBuilder = Gtk.Builder.new_from_file( + `${clapperPath}/ui/help-overlay.ui` + ); + window.set_help_overlay(helpBuilder.get_object('help_overlay')); + } + clapperWidget.activate_action('win.show-help-overlay', null); + break; case 'about': new Dialogs.AboutDialog(window); break; diff --git a/ui/clapper.ui b/ui/clapper.ui index 55119d74..756407d5 100644 --- a/ui/clapper.ui +++ b/ui/clapper.ui @@ -16,14 +16,12 @@ Preferences app.prefs - -
- +
+
About Clapper app.about diff --git a/ui/help-overlay.ui b/ui/help-overlay.ui new file mode 100644 index 00000000..0cf9b602 --- /dev/null +++ b/ui/help-overlay.ui @@ -0,0 +1,133 @@ + + + + True + + + app + + + General + + + Show shortcuts + F1 <Ctrl>question + + + + + Toggle fullscreen + F11 f + + + + + Reveal controls (fullscreen only) + Return + + + + + Quit + <Ctrl>Q Q + + + + + + + Media + + + Open Local + <Ctrl>O + + + + + Open URI + <Ctrl>U + + + + + + + Playlist + + + Next item + <Ctrl>Right + + + + + Previous item + <Ctrl>Left + + + + + Change repeat mode + <Ctrl>R + + + + + Export to file + <Ctrl>E + + + + + + + Playback + + + Toggle play + space + + + + + Volume up + Up + + + + + Volume down + Down + + + + + Seek forward + Right + + + + + Seek backward + Left + + + + + Next chapter + <Shift>Right + + + + + Previous chapter + <Shift>Left + + + + + + + +