[vlc-commits] [Git][videolan/vlc][master] 4 commits: qml: make the shortcut opening modal window WindowShortcut
Felix Paul Kühne (@fkuehne)
gitlab at videolan.org
Fri Apr 22 07:40:14 UTC 2022
Felix Paul Kühne pushed to branch master at VideoLAN / VLC
Commits:
3fb8366e by Pierre Lamot at 2022-04-22T07:19:08+00:00
qml: make the shortcut opening modal window WindowShortcut
the shortcut should open the dialog only when triggered from the main view. The
other shortcuts are kept as application shortcut as triggering the shortcut will
close the associated dialog
- - - - -
99f697cf by Pierre Lamot at 2022-04-22T07:19:08+00:00
qml: add a property do enable/disable global shortcuts
- - - - -
a99c6754 by Pierre Lamot at 2022-04-22T07:19:08+00:00
qml: disable global shortcuts when the user has the active focus on a textedit field
this allows to prioritize common shortcuts (Ctrl+C/Ctrl+V for instance) over vlc
custom shortcuts (resp. open media/open url). ideally we would use qt mechanism
onShortcutOverride but this is buggy before 5.13
fix: #26150
- - - - -
69e22f29 by Pierre Lamot at 2022-04-22T07:19:08+00:00
qml: enable global shortcuts in detached playlist
- - - - -
11 changed files:
- modules/gui/qt/Makefile.am
- modules/gui/qt/maininterface/mainctx.cpp
- modules/gui/qt/maininterface/mainctx.hpp
- modules/gui/qt/menus/qml/GlobalShortcuts.qml
- modules/gui/qt/menus/qml/GlobalShortcutsMedialib.qml
- + modules/gui/qt/menus/qml/ShortcutExt.qml
- modules/gui/qt/network/qml/DiscoverUrlDisplay.qml
- modules/gui/qt/playlist/qml/PlaylistDetachedWindow.qml
- modules/gui/qt/vlc.qrc
- modules/gui/qt/widgets/qml/SearchBox.qml
- modules/gui/qt/widgets/qml/SpinBoxExt.qml
Changes:
=====================================
modules/gui/qt/Makefile.am
=====================================
@@ -789,6 +789,7 @@ libqt_plugin_la_QML = \
gui/qt/menus/qml/GlobalShortcuts.qml \
gui/qt/menus/qml/GlobalShortcutsMedialib.qml \
gui/qt/menus/qml/Menubar.qml \
+ gui/qt/menus/qml/ShortcutExt.qml \
gui/qt/network/qml/AddressbarButton.qml \
gui/qt/network/qml/DiscoverDisplay.qml \
gui/qt/network/qml/DiscoverUrlDisplay.qml \
=====================================
modules/gui/qt/maininterface/mainctx.cpp
=====================================
@@ -246,6 +246,14 @@ bool MainCtx::hasFirstrun() const {
return config_GetInt( "qt-privacy-ask" );
}
+void MainCtx::setUseGlobalShortcuts( bool useShortcuts )
+{
+ if (m_useGlobalShortcuts == useShortcuts)
+ return;
+ m_useGlobalShortcuts = useShortcuts;
+ emit useGlobalShortcutsChanged(m_useGlobalShortcuts);
+}
+
/*****************************
* Main UI handling *
*****************************/
=====================================
modules/gui/qt/maininterface/mainctx.hpp
=====================================
@@ -173,6 +173,7 @@ class MainCtx : public QObject
Q_PROPERTY(bool smoothScroll READ smoothScroll NOTIFY smoothScrollChanged FINAL)
Q_PROPERTY(QWindow* intfMainWindow READ intfMainWindow CONSTANT FINAL)
Q_PROPERTY(QScreen* screen READ screen NOTIFY screenChanged)
+ Q_PROPERTY(bool useGlobalShortcuts READ getUseGlobalShortcuts WRITE setUseGlobalShortcuts NOTIFY useGlobalShortcutsChanged FINAL)
// This Property only works if hasAcrylicSurface is set
Q_PROPERTY(bool acrylicActive READ acrylicActive WRITE setAcrylicActive NOTIFY acrylicActiveChanged FINAL)
@@ -252,6 +253,8 @@ public:
inline bool hasAcrylicSurface() const { return m_hasAcrylicSurface; }
inline void reloadFromSettings() { loadFromSettingsImpl(true); }
inline QScreen* screen() const { return intfMainWindow()->screen(); }
+ inline bool getUseGlobalShortcuts() const { return m_useGlobalShortcuts; }
+ void setUseGlobalShortcuts(bool useGlobalShortcuts );
bool hasEmbededVideo() const;
VideoSurfaceProvider* getVideoSurfaceProvider() const;
@@ -333,6 +336,7 @@ protected:
bool m_hasToolbarMenu = false;
bool m_canShowVideoPIP = false;
bool m_pinVideoControls = false;
+ bool m_useGlobalShortcuts = true;
QUrl m_dialogFilepath; /* Last path used in dialogs */
/* States */
@@ -428,6 +432,8 @@ signals:
void screenChanged();
+ void useGlobalShortcutsChanged( bool );
+
private:
void loadPrefs(bool callSignals);
void loadFromSettingsImpl(bool callSignals);
=====================================
modules/gui/qt/menus/qml/GlobalShortcuts.qml
=====================================
@@ -15,35 +15,35 @@
* 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.vlc 0.1
Item {
- Shortcut{ context: Qt.ApplicationShortcut; sequence:"Ctrl+O"; onActivated: { enabled = false; DialogsProvider.simpleOpenDialog(); enabled = true } }
- Shortcut{ context: Qt.ApplicationShortcut; sequence:"Ctrl+Shift+O"; onActivated: DialogsProvider.openFileDialog(); }
- Shortcut{ context: Qt.ApplicationShortcut; sequence:"Ctrl+F"; onActivated: { enabled = false; DialogsProvider.PLOpenDir(); enabled = true; } }
- Shortcut{ context: Qt.ApplicationShortcut; sequence:"Ctrl+D"; onActivated: DialogsProvider.openDiscDialog(); }
- Shortcut{ context: Qt.ApplicationShortcut; sequence:"Ctrl+N"; onActivated: DialogsProvider.openNetDialog(); }
- Shortcut{ context: Qt.ApplicationShortcut; sequence:"Ctrl+C"; onActivated: DialogsProvider.openCaptureDialog(); }
- Shortcut{ context: Qt.ApplicationShortcut; sequence:"Ctrl+V"; onActivated: DialogsProvider.openUrlDialog(); }
- Shortcut{ context: Qt.ApplicationShortcut; sequence:"Ctrl+Y"; onActivated: { enabled = false; DialogsProvider.savePlayingToPlaylist(); enabled = true; } }
- Shortcut{ context: Qt.ApplicationShortcut; sequence:"Ctrl+R"; onActivated: DialogsProvider.openAndTranscodingDialogs(); }
- Shortcut{ context: Qt.ApplicationShortcut; sequence:"Ctrl+S"; onActivated: DialogsProvider.openAndStreamingDialogs(); }
- Shortcut{ context: Qt.ApplicationShortcut; sequence:"Ctrl+Q"; onActivated: DialogsProvider.quit(); }
- Shortcut{ context: Qt.ApplicationShortcut; sequence:"Ctrl+E"; onActivated: DialogsProvider.extendedDialog(); }
- Shortcut{ context: Qt.ApplicationShortcut; sequence:"Ctrl+I"; onActivated: DialogsProvider.mediaInfoDialog(); }
- Shortcut{ context: Qt.ApplicationShortcut; sequence:"Ctrl+J"; onActivated: DialogsProvider.mediaCodecDialog(); }
- Shortcut{ context: Qt.ApplicationShortcut; sequence:"Ctrl+M"; onActivated: DialogsProvider.messagesDialog(); }
- Shortcut{ context: Qt.ApplicationShortcut; sequence:"Ctrl+P"; onActivated: DialogsProvider.prefsDialog(); }
- Shortcut{ context: Qt.ApplicationShortcut; sequence:"Ctrl+T"; onActivated: DialogsProvider.gotoTimeDialog(); }
- Shortcut{ context: Qt.ApplicationShortcut; sequence:"F1"; onActivated: DialogsProvider.helpDialog(); }
- Shortcut{ context: Qt.ApplicationShortcut; sequence:"Ctrl+Shift+W"; onActivated: DialogsProvider.vlmDialog(); enabled: MainCtx.hasVLM; }
+ ShortcutExt{ context: Qt.WindowShortcut; sequence:"Ctrl+O"; onActivated: DialogsProvider.simpleOpenDialog(); }
+ ShortcutExt{ sequence:"Ctrl+Shift+O"; onActivated: DialogsProvider.openFileDialog(); }
+ ShortcutExt{ context: Qt.WindowShortcut; sequence:"Ctrl+F"; onActivated: DialogsProvider.PLOpenDir(); }
+ ShortcutExt{ sequence:"Ctrl+D"; onActivated: DialogsProvider.openDiscDialog(); }
+ ShortcutExt{ sequence:"Ctrl+N"; onActivated: DialogsProvider.openNetDialog(); }
+ ShortcutExt{ sequence:"Ctrl+C"; onActivated: DialogsProvider.openCaptureDialog(); }
+ ShortcutExt{ sequence:"Ctrl+V"; onActivated: DialogsProvider.openUrlDialog(); }
+ ShortcutExt{ context: Qt.WindowShortcut; sequence:"Ctrl+Y"; onActivated: DialogsProvider.savePlayingToPlaylist(); }
+ ShortcutExt{ sequence:"Ctrl+R"; onActivated: DialogsProvider.openAndTranscodingDialogs(); }
+ ShortcutExt{ sequence:"Ctrl+S"; onActivated: DialogsProvider.openAndStreamingDialogs(); }
+ ShortcutExt{ sequence:"Ctrl+Q"; onActivated: DialogsProvider.quit(); }
+ ShortcutExt{ sequence:"Ctrl+E"; onActivated: DialogsProvider.extendedDialog(); }
+ ShortcutExt{ sequence:"Ctrl+I"; onActivated: DialogsProvider.mediaInfoDialog(); }
+ ShortcutExt{ sequence:"Ctrl+J"; onActivated: DialogsProvider.mediaCodecDialog(); }
+ ShortcutExt{ sequence:"Ctrl+M"; onActivated: DialogsProvider.messagesDialog(); }
+ ShortcutExt{ sequence:"Ctrl+P"; onActivated: DialogsProvider.prefsDialog(); }
+ ShortcutExt{ sequence:"Ctrl+T"; onActivated: DialogsProvider.gotoTimeDialog(); }
+ ShortcutExt{ sequence:"F1"; onActivated: DialogsProvider.helpDialog(); }
+
+ ShortcutExt{ sequence:"Ctrl+Shift+W"; onActivated: DialogsProvider.vlmDialog(); }
- Shortcut{ context: Qt.ApplicationShortcut; sequence:"Ctrl+L"; onActivated: MainCtx.playlistVisible = !MainCtx.playlistVisible; }
- Shortcut{ context: Qt.ApplicationShortcut; sequence:"F11"; onActivated: MainCtx.toggleInterfaceFullScreen(); }
+ ShortcutExt{ sequence:"Ctrl+L"; onActivated: MainCtx.playlistVisible = !MainCtx.playlistVisible; }
+ ShortcutExt{ sequence:"F11"; onActivated: MainCtx.toggleInterfaceFullScreen(); }
Loader {
active: MainCtx.mediaLibraryAvailable
=====================================
modules/gui/qt/menus/qml/GlobalShortcutsMedialib.qml
=====================================
@@ -21,7 +21,7 @@ import org.videolan.vlc 0.1
import org.videolan.medialib 0.1
Item {
- Shortcut{ context: Qt.ApplicationShortcut; sequence:"Ctrl+B"; onActivated: DialogsProvider.bookmarksDialog(); }
+ ShortcutExt{ sequence:"Ctrl+B"; onActivated: DialogsProvider.bookmarksDialog() }
MLRecentModel {
id: recentModel
@@ -34,7 +34,7 @@ Item {
model: 10
Item {
- Shortcut {
+ ShortcutExt {
sequence: "Ctrl+" + ((index + 1) % 10)
onActivated: {
if (index < recentModel.count)
@@ -45,7 +45,6 @@ Item {
MediaLib.addAndPlay([trackId])
}
}
- context: Qt.ApplicationShortcut
}
}
}
=====================================
modules/gui/qt/menus/qml/ShortcutExt.qml
=====================================
@@ -0,0 +1,25 @@
+/*****************************************************************************
+ * Copyright (C) 2022 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.vlc 0.1
+
+Shortcut {
+ context: Qt.WindowShortcut
+ enabled: MainCtx.useGlobalShortcuts
+}
=====================================
modules/gui/qt/network/qml/DiscoverUrlDisplay.qml
=====================================
@@ -95,6 +95,15 @@ FocusScope {
Keys.priority: Keys.AfterItem
Keys.onPressed: searchFieldContainer.Navigation.defaultKeyAction(event)
+
+ //ideally we should use Keys.onShortcutOverride but it doesn't
+ //work with TextField before 5.13 see QTBUG-68711
+ onActiveFocusChanged: {
+ if (activeFocus)
+ MainCtx.useGlobalShortcuts = false
+ else
+ MainCtx.useGlobalShortcuts = true
+ }
}
}
=====================================
modules/gui/qt/playlist/qml/PlaylistDetachedWindow.qml
=====================================
@@ -36,6 +36,11 @@ Window {
title: I18n.qtr("Playlist")
color: VLCStyle.colors.bg
+ Loader {
+ asynchronous: true
+ source: "qrc:///menus/GlobalShortcuts.qml"
+ }
+
Component.onCompleted: {
if (!!parentWindow) {
height = parentWindow.height
=====================================
modules/gui/qt/vlc.qrc
=====================================
@@ -335,6 +335,7 @@
<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>
+ <file alias="ShortcutExt.qml">menus/qml/ShortcutExt.qml</file>
</qresource>
<qresource prefix="/player">
<file alias="qmldir">player/qml/qmldir</file>
=====================================
modules/gui/qt/widgets/qml/SearchBox.qml
=====================================
@@ -130,6 +130,15 @@ FocusScope {
Navigation.rightItem: clearButton.visible ? clearButton : iconButton
Navigation.cancelAction: function() { root.state = "" }
+ //ideally we should use Keys.onShortcutOverride but it doesn't
+ //work with TextField before 5.13 see QTBUG-68711
+ onActiveFocusChanged: {
+ if (activeFocus)
+ MainCtx.useGlobalShortcuts = false
+ else
+ MainCtx.useGlobalShortcuts = true
+ }
+
Keys.priority: Keys.AfterItem
Keys.onPressed: {
//we don't want Navigation.cancelAction to match Backspace
=====================================
modules/gui/qt/widgets/qml/SpinBoxExt.qml
=====================================
@@ -34,6 +34,15 @@ SpinBox{
Keys.priority: Keys.AfterItem
Keys.onPressed: Navigation.defaultKeyAction(event)
+ //ideally we should use Keys.onShortcutOverride but it doesn't
+ //work with TextField before 5.13 see QTBUG-68711
+ onActiveFocusChanged: {
+ if (activeFocus)
+ MainCtx.useGlobalShortcuts = false
+ else
+ MainCtx.useGlobalShortcuts = true
+ }
+
background: Rectangle {
implicitWidth: VLCStyle.dp(4, VLCStyle.scale)
implicitHeight: VLCStyle.dp(32, VLCStyle.scale)
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/1e7d9e4e1a7b17ab459d2737da07e3b9568a957f...69e22f2906fdc8ca0798758bc992e98e8b22a2b2
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/1e7d9e4e1a7b17ab459d2737da07e3b9568a957f...69e22f2906fdc8ca0798758bc992e98e8b22a2b2
You're receiving this email because of your account on code.videolan.org.
VideoLAN code repository instance
More information about the vlc-commits
mailing list