[vlc-commits] [Git][videolan/vlc][master] 2 commits: qml: compat for touchscreen handlers

Jean-Baptiste Kempf (@jbk) gitlab at videolan.org
Mon Dec 19 13:24:36 UTC 2022



Jean-Baptiste Kempf pushed to branch master at VideoLAN / VLC


Commits:
a8593310 by Yann Lochet at 2022-12-19T13:02:49+00:00
qml: compat for touchscreen handlers

- - - - -
fd552813 by Yann Lochet at 2022-12-19T13:02:49+00:00
qml: better touchscreen navigation

In some views, it makes more sense to trigger the action of a double
click with a single tap on screen

- - - - -


8 changed files:

- modules/gui/qt/Makefile.am
- modules/gui/qt/maininterface/mainui.cpp
- modules/gui/qt/playlist/qml/PlaylistDelegate.qml
- + modules/gui/qt/util/qml/TouchScreenTapHandlerRev11.qml
- + modules/gui/qt/util/qml/TouchScreenTapHandlerRev12.qml
- modules/gui/qt/vlc.qrc
- modules/gui/qt/widgets/qml/GridItem.qml
- modules/gui/qt/widgets/qml/TableViewDelegate.qml


Changes:

=====================================
modules/gui/qt/Makefile.am
=====================================
@@ -967,6 +967,8 @@ libqt_plugin_la_QML = \
 	gui/qt/util/qml/ViewDragAutoScrollHandler.qml \
 	gui/qt/util/qml/BindingRev8.qml \
 	gui/qt/util/qml/BindingRev14.qml \
+	gui/qt/util/qml/TouchScreenTapHandlerRev11.qml \
+	gui/qt/util/qml/TouchScreenTapHandlerRev12.qml \
 	gui/qt/util/qml/VanillaObject.qml \
 	gui/qt/util/qml/NativeMenu.qml \
 	gui/qt/util/qml/MLContextMenu.qml \


=====================================
modules/gui/qt/maininterface/mainui.cpp
=====================================
@@ -325,6 +325,12 @@ void MainUI::registerQMLTypes()
         qmlRegisterType(QUrl("qrc:///util/BindingRev8.qml"), uri, versionMajor, versionMinor, "BindingCompat");
 #endif
 
+#if (QT_VERSION >= QT_VERSION_CHECK(5, 12, 0))
+        qmlRegisterType(QUrl("qrc:///util/TouchScreenTapHandlerRev12.qml"), uri, versionMajor, versionMinor, "TouchScreenTapHandlerCompat");
+#else
+        qmlRegisterType(QUrl("qrc:///util/TouchScreenTapHandlerRev11.qml"), uri, versionMajor, versionMinor, "TouchScreenTapHandlerCompat");
+#endif
+
         qmlProtectModule(uri, versionMajor);
     }
 


=====================================
modules/gui/qt/playlist/qml/PlaylistDelegate.qml
=====================================
@@ -22,6 +22,7 @@ import QtQuick.Templates 2.4 as T
 import QtQuick.Layouts 1.11
 
 import org.videolan.vlc 0.1
+import org.videolan.compat 0.1
 
 import "qrc:///widgets/" as Widgets
 import "qrc:///style/"
@@ -75,6 +76,19 @@ T.Control {
 
     // Functions
 
+    function moveSelected() {
+        var selectedIndexes = root.model.getSelection()
+        if (selectedIndexes.length === 0)
+            return
+        var preTarget = index
+        /* move to _above_ the clicked item if move up, but
+         * _below_ the clicked item if move down */
+        if (preTarget > selectedIndexes[0])
+            preTarget++
+        listView.currentIndex = selectedIndexes[0]
+        root.model.moveItemsPre(selectedIndexes, preTarget)
+    }
+
     // Childs
 
     background: Widgets.AnimatedBackground {
@@ -204,16 +218,7 @@ T.Control {
             /* to receive keys events */
             listView.forceActiveFocus()
             if (root.mode === PlaylistListView.Mode.Move) {
-                var selectedIndexes = root.model.getSelection()
-                if (selectedIndexes.length === 0)
-                    return
-                var preTarget = index
-                /* move to _above_ the clicked item if move up, but
-                 * _below_ the clicked item if move down */
-                if (preTarget > selectedIndexes[0])
-                    preTarget++
-                listView.currentIndex = selectedIndexes[0]
-                root.model.moveItemsPre(selectedIndexes, preTarget)
+                moveSelected()
                 return
             } else if (root.mode === PlaylistListView.Mode.Select) {
             } else if (!(root.model.isSelected(index) && mouse.button === Qt.RightButton)) {
@@ -261,6 +266,16 @@ T.Control {
                 dragItem.y = pos.y
             }
         }
+
+        TouchScreenTapHandlerCompat {
+            onTapped: {
+                if (root.mode === PlaylistListView.Mode.Normal) {
+                    mainPlaylistController.goTo(index, true)
+                } else if (root.mode === PlaylistListView.Mode.Move) {
+                    moveSelected()
+                }
+            }
+        }
     }
 
     ColumnLayout {


=====================================
modules/gui/qt/util/qml/TouchScreenTapHandlerRev11.qml
=====================================
@@ -0,0 +1,24 @@
+/*****************************************************************************
+ * 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
+
+Item {
+    //mock, TapHandler is present in QtQuick >= 2.12
+    signal tapped()
+}


=====================================
modules/gui/qt/util/qml/TouchScreenTapHandlerRev12.qml
=====================================
@@ -0,0 +1,23 @@
+/*****************************************************************************
+ * 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.12
+
+TapHandler {
+    acceptedDevices: PointerDevice.TouchScreen
+}


=====================================
modules/gui/qt/vlc.qrc
=====================================
@@ -76,6 +76,8 @@
         <file alias="ViewDragAutoScrollHandler.qml">util/qml/ViewDragAutoScrollHandler.qml</file>
         <file alias="BindingRev8.qml">util/qml/BindingRev8.qml</file>
         <file alias="BindingRev14.qml">util/qml/BindingRev14.qml</file>
+        <file alias="TouchScreenTapHandlerRev11.qml">util/qml/TouchScreenTapHandlerRev11.qml</file>
+        <file alias="TouchScreenTapHandlerRev12.qml">util/qml/TouchScreenTapHandlerRev12.qml</file>
         <file alias="VanillaObject.qml">util/qml/VanillaObject.qml</file>
         <file alias="NativeMenu.qml">util/qml/NativeMenu.qml</file>
         <file alias="MLContextMenu.qml">util/qml/MLContextMenu.qml</file>


=====================================
modules/gui/qt/widgets/qml/GridItem.qml
=====================================
@@ -22,6 +22,7 @@ import QtQuick.Layouts 1.11
 import QtQml.Models 2.2
 
 import org.videolan.vlc 0.1
+import org.videolan.compat 0.1
 
 import "qrc:///widgets/" as Widgets
 import "qrc:///util/Helpers.js" as Helpers
@@ -211,6 +212,13 @@ T.Control {
             root.dragItem.Drag.active = drag.active
         }
 
+        TouchScreenTapHandlerCompat {
+            onTapped: {
+                root.itemClicked(picture, Qt.LeftButton, Qt.NoModifier)
+                root.itemDoubleClicked(picture, Qt.LeftButton, Qt.NoModifier)
+            }
+        }
+
         ColumnLayout {
             id: layout
 


=====================================
modules/gui/qt/widgets/qml/TableViewDelegate.qml
=====================================
@@ -20,6 +20,8 @@ import QtQuick 2.11
 import QtQuick.Templates 2.4 as T
 import QtQuick.Layouts 1.3
 
+import org.videolan.compat 0.1
+
 import "qrc:///widgets/" as Widgets
 import "qrc:///style/"
 
@@ -155,6 +157,13 @@ T.Control {
 
                 delegate.dragItem.Drag.active = drag.active
             }
+
+            TouchScreenTapHandlerCompat {
+                onTapped: {
+                    delegate.selectAndFocus(Qt.NoModifier, Qt.MouseFocusReason)
+                    delegate.itemDoubleClicked(delegate._index, delegate.rowModel)
+                }
+            }
         }
     }
 



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/8a69270b0abc50283e70d5cb8268e10b335ceae0...fd552813de71c6026ee21b26d538cdd29bc04928

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/8a69270b0abc50283e70d5cb8268e10b335ceae0...fd552813de71c6026ee21b26d538cdd29bc04928
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