[vlc-commits] [Git][videolan/vlc][master] 5 commits: qt: protect registered qml modules

Rémi Denis-Courmont (@Courmisch) gitlab at videolan.org
Thu Feb 3 21:38:10 UTC 2022



Rémi Denis-Courmont pushed to branch master at VideoLAN / VLC


Commits:
5125e9a4 by Fatih Uzunoglu at 2022-02-03T21:19:29+00:00
qt: protect registered qml modules

- - - - -
ff363540 by Fatih Uzunoglu at 2022-02-03T21:19:29+00:00
qml: add BindingRev8.qml and BindingRev14.qml

- - - - -
d36ddb09 by Fatih Uzunoglu at 2022-02-03T21:19:29+00:00
qt: register qml compatibility module

- - - - -
fc587f09 by Fatih Uzunoglu at 2022-02-03T21:19:29+00:00
qml: use BindingCompat instead of Binding

- - - - -
d2e9f04e by Fatih Uzunoglu at 2022-02-03T21:19:29+00:00
qml: remove unnecessary check

- - - - -


12 changed files:

- modules/gui/qt/Makefile.am
- modules/gui/qt/dialogs/toolbar/qml/EditorDNDDelegate.qml
- modules/gui/qt/dialogs/toolbar/qml/EditorDNDView.qml
- modules/gui/qt/maininterface/mainui.cpp
- modules/gui/qt/maininterface/qml/BannerSources.qml
- modules/gui/qt/maininterface/qml/MainInterface.qml
- modules/gui/qt/player/qml/ControlLayout.qml
- modules/gui/qt/style/AcrylicController.qml
- + modules/gui/qt/util/qml/BindingRev14.qml
- + modules/gui/qt/util/qml/BindingRev8.qml
- modules/gui/qt/util/qml/MultipleBinding.qml
- modules/gui/qt/vlc.qrc


Changes:

=====================================
modules/gui/qt/Makefile.am
=====================================
@@ -853,6 +853,8 @@ libqt_plugin_la_QML = \
 	gui/qt/util/qml/MultipleBinding.qml \
 	gui/qt/util/qml/FlickableScrollHandler.qml \
 	gui/qt/util/qml/ViewDragAutoScrollHandler.qml \
+	gui/qt/util/qml/BindingRev8.qml \
+	gui/qt/util/qml/BindingRev14.qml \
 	gui/qt/widgets/qml/ActionButtonOverlay.qml \
 	gui/qt/widgets/qml/ActionButtonPrimary.qml \
 	gui/qt/widgets/qml/BannerTabButton.qml \


=====================================
modules/gui/qt/dialogs/toolbar/qml/EditorDNDDelegate.qml
=====================================
@@ -21,6 +21,7 @@ import QtQuick.Controls 2.4
 import QtQml.Models 2.11
 
 import org.videolan.vlc 0.1
+import org.videolan.compat 0.1
 
 import "qrc:///player/"
 import "qrc:///widgets/" as Widgets
@@ -104,7 +105,7 @@ Control {
         }
     }
 
-    Binding {
+    BindingCompat {
         when: dragActive
         value: true
 


=====================================
modules/gui/qt/dialogs/toolbar/qml/EditorDNDView.qml
=====================================
@@ -20,6 +20,7 @@ import QtQuick.Controls 2.4
 import QtQml.Models 2.11
 
 import org.videolan.vlc 0.1
+import org.videolan.compat 0.1
 
 import "qrc:///style/"
 import "qrc:///util/" as Util
@@ -159,7 +160,7 @@ ListView {
 
         dndView: playerBtnDND
 
-        Binding {
+        BindingCompat {
             when: dropArea.containsDrag
             value: true
 


=====================================
modules/gui/qt/maininterface/mainui.cpp
=====================================
@@ -194,7 +194,6 @@ QQuickItem* MainUI::createRootItem()
     return m_rootItem;
 }
 
-
 void MainUI::registerQMLTypes()
 {
     {
@@ -271,6 +270,25 @@ void MainUI::registerQMLTypes()
         qRegisterMetaType<QList<QQmlError>>("QList<QQmlError>");
 
         qmlRegisterUncreatableType<NavigationAttached>( uri, versionMajor, versionMinor, "Navigation", "Navigation is only available via attached properties");
+
+
+        qmlProtectModule(uri, versionMajor);
+    }
+
+    {
+        const char* const uri = "org.videolan.compat";
+        const int versionMajor = 0;
+        const int versionMinor = 1;
+
+        qmlRegisterModule(uri, versionMajor, versionMinor);
+
+#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
+        qmlRegisterType(QUrl("qrc:///util/BindingRev14.qml"), uri, versionMajor, versionMinor, "BindingCompat");
+#else
+        qmlRegisterType(QUrl("qrc:///util/BindingRev8.qml"), uri, versionMajor, versionMinor, "BindingCompat");
+#endif
+
+        qmlProtectModule(uri, versionMajor);
     }
 
     {
@@ -281,6 +299,9 @@ void MainUI::registerQMLTypes()
         const int versionMinor = 1;
 
         qmlRegisterType<RoundImage>( uri, versionMajor, versionMinor, "RoundImage" );
+
+
+        qmlProtectModule(uri, versionMajor);
     }
 
     if (m_mainCtx->hasMediaLibrary())
@@ -327,6 +348,9 @@ void MainUI::registerQMLTypes()
         qmlRegisterType<GroupListContextMenu>( uri, versionMajor, versionMinor, "GroupListContextMenu" );
         qmlRegisterType<PlaylistListContextMenu>( uri, versionMajor, versionMinor, "PlaylistListContextMenu" );
         qmlRegisterType<PlaylistMediaContextMenu>( uri, versionMajor, versionMinor, "PlaylistMediaContextMenu" );
+
+
+        qmlProtectModule(uri, versionMajor);
     }
 }
 


=====================================
modules/gui/qt/maininterface/qml/BannerSources.qml
=====================================
@@ -21,9 +21,11 @@ import QtQuick.Controls 2.4
 import QtQuick.Templates 2.4 as T
 import QtQuick.Layouts 1.11
 import QtGraphicalEffects 1.0
-import org.videolan.vlc 0.1
 import QtQml.Models 2.11
 
+import org.videolan.vlc 0.1
+import org.videolan.compat 0.1
+
 import "qrc:///style/"
 import "qrc:///widgets/" as Widgets
 import "qrc:///menus/" as Menus
@@ -61,7 +63,7 @@ FocusScope {
         searchBox.state = "expanded"
     }
 
-    Binding {
+    BindingCompat {
         property: "searchPattern"
         value: searchBox.searchPattern
         when: !!contentModel


=====================================
modules/gui/qt/maininterface/qml/MainInterface.qml
=====================================
@@ -22,6 +22,7 @@ import QtQuick.Controls 2.4
 import QtQuick.Window 2.11
 
 import org.videolan.vlc 0.1
+import org.videolan.compat 0.1
 
 import "qrc:///widgets/" as Widgets
 import "qrc:///style/"
@@ -38,13 +39,13 @@ Rectangle {
     property alias g_root: root
     property QtObject g_dialogs: dialogsLoader.item
 
-    Binding {
+    BindingCompat {
         target: VLCStyle.self
         property: "appWidth"
         value: root.width
     }
 
-    Binding {
+    BindingCompat {
         target: VLCStyle.self
         property: "appHeight"
         value: root.height


=====================================
modules/gui/qt/player/qml/ControlLayout.qml
=====================================
@@ -21,6 +21,7 @@ import QtQuick.Layouts 1.11
 import QtQml.Models 2.11
 
 import org.videolan.vlc 0.1
+import org.videolan.compat 0.1
 
 import "qrc:///style/"
 import "qrc:///widgets/" as Widgets
@@ -121,7 +122,7 @@ FocusScope {
                 readonly property real minimumWidth: (expandable ? item.minimumWidth : item.implicitWidth)
                 readonly property bool expandable: (item.minimumWidth !== undefined)
 
-                Binding {
+                BindingCompat {
                     delayed: true // this is important
                     target: loader
                     property: "visible"


=====================================
modules/gui/qt/style/AcrylicController.qml
=====================================
@@ -21,6 +21,7 @@ pragma Singleton
 import QtQuick 2.11
 
 import org.videolan.vlc 0.1
+import org.videolan.compat 0.1
 
 Item {
     id: root
@@ -36,16 +37,10 @@ Item {
         }
     }
 
-    Binding {
+    BindingCompat {
         when: root.enabled
         target: MainCtx
         property: "acrylicActive"
         value: root.uiTransluency != 0
-
-        Component.onCompleted: {
-            // restoreMode is only available in Qt >= 5.14
-            if ("restoreMode" in this)
-                this.restoreMode = Binding.RestoreBindingOrValue
-        }
     }
 }


=====================================
modules/gui/qt/util/qml/BindingRev14.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.14
+import QtQml 2.14
+
+Binding {
+    // Binding Revision 14
+    restoreMode: Binding.RestoreBindingOrValue
+}


=====================================
modules/gui/qt/util/qml/BindingRev8.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.8
+import QtQml 2.8
+
+Binding {
+    // Binding Revision 8
+    // Only restores previous value if it was a binding
+}


=====================================
modules/gui/qt/util/qml/MultipleBinding.qml
=====================================
@@ -20,6 +20,8 @@ import QtQuick 2.11
 import QtQml 2.11
 import QtQml.Models 2.11
 
+import org.videolan.compat 0.1
+
 QtObject {
     id: root
 
@@ -36,7 +38,7 @@ QtObject {
 
         model: root.model
 
-        delegate: Binding {
+        delegate: BindingCompat {
             target: model.target ? model.target
                                  : root.target
             when: model.when !== undefined ? model.when


=====================================
modules/gui/qt/vlc.qrc
=====================================
@@ -29,6 +29,8 @@
         <file alias="MultipleBinding.qml">util/qml/MultipleBinding.qml</file>
         <file alias="FlickableScrollHandler.qml">util/qml/FlickableScrollHandler.qml</file>
         <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>
     </qresource>
     <qresource prefix="/toolbar">
         <file alias="faster.svg">pixmaps/faster.svg</file>



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/d89a4e99cd17989c690297beaa3933fd62b9148f...d2e9f04ee4ba121095ae16e98231da8c3431c80e

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/d89a4e99cd17989c690297beaa3933fd62b9148f...d2e9f04ee4ba121095ae16e98231da8c3431c80e
You're receiving this email because of your account on code.videolan.org.




More information about the vlc-commits mailing list