[vlc-commits] qml: add recent global shortcuts
Pierre Lamot
git at videolan.org
Thu Oct 29 09:08:37 CET 2020
vlc | branch: master | Pierre Lamot <pierre at videolabs.io> | Wed Oct 14 17:44:36 2020 +0200| [292156a34ed7c2dd4d44420f6137f2479c910eae] | committer: Pierre Lamot
qml: add recent global shortcuts
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=292156a34ed7c2dd4d44420f6137f2479c910eae
---
modules/gui/qt/Makefile.am | 1 +
modules/gui/qt/menus/qml/GlobalShortcuts.qml | 6 ++-
.../gui/qt/menus/qml/GlobalShortcutsMedialib.qml | 50 ++++++++++++++++++++++
modules/gui/qt/vlc.qrc | 1 +
4 files changed, 56 insertions(+), 2 deletions(-)
diff --git a/modules/gui/qt/Makefile.am b/modules/gui/qt/Makefile.am
index f65b3ca6c5..f61025ff01 100644
--- a/modules/gui/qt/Makefile.am
+++ b/modules/gui/qt/Makefile.am
@@ -635,6 +635,7 @@ libqt_plugin_la_QML = \
gui/qt/medialibrary/qml/VideoInfoExpandPanel.qml \
gui/qt/medialibrary/qml/VideoListDisplay.qml \
gui/qt/menus/qml/GlobalShortcuts.qml \
+ gui/qt/menus/qml/GlobalShortcutsMedialib.qml \
gui/qt/menus/qml/Menubar.qml \
gui/qt/network/qml/DiscoverDisplay.qml \
gui/qt/network/qml/DiscoverUrlDisplay.qml \
diff --git a/modules/gui/qt/menus/qml/GlobalShortcuts.qml b/modules/gui/qt/menus/qml/GlobalShortcuts.qml
index fc1f9f5519..97358c52d3 100644
--- a/modules/gui/qt/menus/qml/GlobalShortcuts.qml
+++ b/modules/gui/qt/menus/qml/GlobalShortcuts.qml
@@ -35,7 +35,6 @@ Item {
Shortcut{ context: Qt.ApplicationShortcut; sequence:"Ctrl+J"; onActivated: dialogProvider.mediaCodecDialog(); }
Shortcut{ context: Qt.ApplicationShortcut; sequence:"Ctrl+M"; onActivated: dialogProvider.messagesDialog(); }
Shortcut{ context: Qt.ApplicationShortcut; sequence:"Ctrl+P"; onActivated: dialogProvider.prefsDialog(); }
- Shortcut{ context: Qt.ApplicationShortcut; sequence:"Ctrl+B"; onActivated: dialogProvider.bookmarksDialog(); enabled: !!medialib}
Shortcut{ context: Qt.ApplicationShortcut; sequence:"Ctrl+T"; onActivated: dialogProvider.gotoTimeDialog(); }
Shortcut{ context: Qt.ApplicationShortcut; sequence:"F1"; onActivated: dialogProvider.helpDialog(); }
@@ -44,5 +43,8 @@ Item {
Shortcut{ context: Qt.ApplicationShortcut; sequence:"Ctrl+L"; onActivated: mainInterface.playlistVisible = !mainInterface.playlistVisible; }
Shortcut{ context: Qt.ApplicationShortcut; sequence:"F11"; onActivated: mainInterface.toggleInterfaceFullScreen(); }
-
+ Loader {
+ active: !!medialib
+ source: "qrc:///menus/GlobalShortcutsMedialib.qml"
+ }
}
diff --git a/modules/gui/qt/menus/qml/GlobalShortcutsMedialib.qml b/modules/gui/qt/menus/qml/GlobalShortcutsMedialib.qml
new file mode 100644
index 0000000000..89ccc2dea6
--- /dev/null
+++ b/modules/gui/qt/menus/qml/GlobalShortcutsMedialib.qml
@@ -0,0 +1,50 @@
+/*****************************************************************************
+ * Copyright (C) 2020 VLC authors and VideoLAN
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * ( at your option ) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+import QtQuick 2.11
+import org.videolan.medialib 0.1
+
+Item {
+ Shortcut{ context: Qt.ApplicationShortcut; sequence:"Ctrl+B"; onActivated: dialogProvider.bookmarksDialog(); }
+
+ MLRecentModel {
+ id: recentModel
+ numberOfItemsToShow: 10
+ ml: medialib
+ }
+
+ //build all the shortcuts everytime, it seems that they can't be added/removed dynamically
+ Repeater {
+ model: 10
+
+ Item {
+ Shortcut {
+ sequence: "Ctrl+" + ((index + 1) % 10)
+ onActivated: {
+ if (index < recentModel.count)
+ {
+
+ var trackId = recentModel.data(recentModel.index(index, 0), MLRecentModel.RECENT_MEDIA_ID)
+ if (!!trackId)
+ medialib.addAndPlay([trackId])
+ }
+ }
+ context: Qt.ApplicationShortcut
+ }
+ }
+ }
+}
diff --git a/modules/gui/qt/vlc.qrc b/modules/gui/qt/vlc.qrc
index 50d0bfd478..55b26e0b63 100644
--- a/modules/gui/qt/vlc.qrc
+++ b/modules/gui/qt/vlc.qrc
@@ -283,6 +283,7 @@
<qresource prefix="/menus">
<file alias="Menubar.qml">menus/qml/Menubar.qml</file>
<file alias="GlobalShortcuts.qml">menus/qml/GlobalShortcuts.qml</file>
+ <file alias="GlobalShortcutsMedialib.qml">menus/qml/GlobalShortcutsMedialib.qml</file>
</qresource>
<qresource prefix="/player">
<file alias="Player.qml">player/qml/Player.qml</file>
More information about the vlc-commits
mailing list