[vlc-commits] [Git][videolan/vlc][master] qml: prefer explicit types to 'var'

Hugo Beauzée-Luyssen (@chouquette) gitlab at videolan.org
Thu Jan 6 09:18:45 UTC 2022



Hugo Beauzée-Luyssen pushed to branch master at VideoLAN / VLC


Commits:
c4edf973 by Fatih Uzunoglu at 2022-01-06T08:59:05+00:00
qml: prefer explicit types to 'var'

- - - - -


29 changed files:

- modules/gui/qt/dialogs/dialogs/qml/Dialogs.qml
- modules/gui/qt/dialogs/dialogs/qml/ModalDialog.qml
- modules/gui/qt/dialogs/toolbar/qml/EditorDNDDelegate.qml
- modules/gui/qt/dialogs/toolbar/qml/ToolbarEditor.qml
- modules/gui/qt/maininterface/mainui.cpp
- modules/gui/qt/maininterface/qml/MainDisplay.qml
- modules/gui/qt/maininterface/qml/MainInterface.qml
- modules/gui/qt/medialibrary/qml/MediaGroupDisplay.qml
- modules/gui/qt/medialibrary/qml/MusicAlbums.qml
- modules/gui/qt/medialibrary/qml/MusicArtist.qml
- modules/gui/qt/medialibrary/qml/MusicArtistDelegate.qml
- modules/gui/qt/medialibrary/qml/MusicArtistsDisplay.qml
- modules/gui/qt/medialibrary/qml/MusicDisplay.qml
- modules/gui/qt/medialibrary/qml/MusicGenres.qml
- modules/gui/qt/medialibrary/qml/PlaylistMedia.qml
- modules/gui/qt/medialibrary/qml/PlaylistMediaDisplay.qml
- modules/gui/qt/medialibrary/qml/VideoAll.qml
- modules/gui/qt/medialibrary/qml/VideoDisplay.qml
- modules/gui/qt/network/qml/DiscoverDisplay.qml
- modules/gui/qt/network/qml/NetworkThumbnailItem.qml
- modules/gui/qt/player/qml/PlayerControlLayout.qml
- modules/gui/qt/player/qml/PlayerMenu.qml
- modules/gui/qt/player/qml/PlayerMenuItem.qml
- modules/gui/qt/playlist/qml/PlaylistDetachedWindow.qml
- modules/gui/qt/widgets/qml/ExpandGridView.qml
- modules/gui/qt/widgets/qml/GridItem.qml
- modules/gui/qt/widgets/qml/KeyNavigableTableView.qml
- modules/gui/qt/widgets/qml/MLDragItem.qml
- modules/gui/qt/widgets/qml/SortControl.qml


Changes:

=====================================
modules/gui/qt/dialogs/dialogs/qml/Dialogs.qml
=====================================
@@ -32,12 +32,12 @@ Item {
     // Properties
     //---------------------------------------------------------------------------------------------
 
-    property var bgContent: undefined
+    property Item bgContent: null
 
     //---------------------------------------------------------------------------------------------
     // Private
 
-    property var _model: DialogModel.model
+    readonly property DialogErrorModel _model: DialogModel.model
 
     //---------------------------------------------------------------------------------------------
     // Signal
@@ -52,12 +52,12 @@ Item {
     Component.onCompleted: if (_model.count) errorPopup.state = "visible"
 
     Component.onDestruction: {
-        if (questionDialog.dialogId !== undefined) {
+        if (questionDialog.dialogId !== null) {
             DialogModel.dismiss(questionDialog.dialogId)
-            questionDialog.dialogId = undefined
-        } if (loginDialog.dialogId !== undefined) {
+            questionDialog.dialogId = null
+        } if (loginDialog.dialogId !== null) {
             DialogModel.dismiss(loginDialog.dialogId)
-            loginDialog.dialogId = undefined
+            loginDialog.dialogId = null
         }
     }
 
@@ -105,11 +105,11 @@ Item {
         onCancelled: {
             if (questionDialog.dialogId === dialogId) {
                 questionDialog.close()
-                questionDialog.dialogId = undefined
+                questionDialog.dialogId = null
                 DialogModel.dismiss(dialogId)
             } else if (loginDialog.dialogId === dialogId)  {
                 loginDialog.close()
-                loginDialog.dialogId = undefined
+                loginDialog.dialogId = null
                 DialogModel.dismiss(dialogId)
             } else {
                 DialogModel.dismiss(dialogId)
@@ -189,7 +189,7 @@ Item {
 
     ModalDialog {
         id: loginDialog
-        property var dialogId: undefined
+        property DialogId dialogId: null
         property string defaultUsername: ""
 
         onAboutToHide: restoreFocus()
@@ -302,15 +302,15 @@ Item {
         }
 
         onAccepted: {
-            if (loginDialog.dialogId !== undefined) {
+            if (loginDialog.dialogId !== null) {
                 DialogModel.post_login(loginDialog.dialogId, username.text, password.text, savePassword.checked)
-                loginDialog.dialogId = undefined
+                loginDialog.dialogId = null
             }
         }
         onRejected: {
-            if (loginDialog.dialogId !== undefined) {
+            if (loginDialog.dialogId !== null) {
                 DialogModel.dismiss(loginDialog.dialogId)
-                loginDialog.dialogId = undefined
+                loginDialog.dialogId = null
             }
         }
     }
@@ -318,7 +318,7 @@ Item {
     ModalDialog {
         id: questionDialog
 
-        property var dialogId: undefined
+        property DialogId dialogId: null
         property alias text: content.text
         property alias cancelTxt: cancel.text
         property alias action1Txt: action1.text
@@ -364,7 +364,7 @@ Item {
 
                         onClicked: {
                             DialogModel.dismiss(questionDialog.dialogId)
-                            questionDialog.dialogId = undefined
+                            questionDialog.dialogId = null
                             questionDialog.close()
                         }
                     }
@@ -383,7 +383,7 @@ Item {
 
                         onClicked: {
                             DialogModel.post_action1(questionDialog.dialogId)
-                            questionDialog.dialogId = undefined
+                            questionDialog.dialogId = null
                             questionDialog.close()
                         }
                     }
@@ -400,7 +400,7 @@ Item {
 
                         onClicked: {
                             DialogModel.post_action2(questionDialog.dialogId)
-                            questionDialog.dialogId = undefined
+                            questionDialog.dialogId = null
                             questionDialog.close()
                         }
                     }


=====================================
modules/gui/qt/dialogs/dialogs/qml/ModalDialog.qml
=====================================
@@ -27,7 +27,7 @@ import "qrc:///style/"
 Dialog {
     id: control
 
-    property var rootWindow: undefined
+    property Item rootWindow: null
 
     focus: true
     modal: true


=====================================
modules/gui/qt/dialogs/toolbar/qml/EditorDNDDelegate.qml
=====================================
@@ -32,7 +32,7 @@ Control {
     padding: background.border.width
 
     readonly property int controlId: model.id
-    property var dndView: null
+    property ListView dndView: null
 
     readonly property bool dragActive: loader.Drag.active
     property alias dropArea: dropArea


=====================================
modules/gui/qt/dialogs/toolbar/qml/ToolbarEditor.qml
=====================================
@@ -33,7 +33,7 @@ Rectangle{
 
     property alias removeInfoRectVisible: buttonList.removeInfoRectVisible
 
-    property var _viewThatContainsDrag: undefined
+    property EditorDNDView _viewThatContainsDrag: null
 
     signal dragStarted(int controlId)
     signal dragStopped(int controlId)
@@ -107,11 +107,11 @@ Rectangle{
                     visible: root.dragActive || (bar.currentIdentifier === identifier)
 
                     readonly property int identifier: modelData.identifier
-                    readonly property var model: {
+                    readonly property PlayerControlbarModel model: {
                         if (!!MainCtx.controlbarProfileModel.currentModel)
                             return MainCtx.controlbarProfileModel.currentModel.getModel(identifier)
                         else
-                            return undefined
+                            return null
                     }
 
                     spacing: VLCStyle.margin_small


=====================================
modules/gui/qt/maininterface/mainui.cpp
=====================================
@@ -238,6 +238,9 @@ void MainUI::registerQMLTypes()
         qmlRegisterSingletonType<DialogModel>(uri, versionMajor, versionMinor, "DialogModel", SingletonRegisterHelper<DialogModel>::getCallback(m_intf));
         qmlRegisterSingletonType<QmlKeyHelper>(uri, versionMajor, versionMinor, "KeyHelper", SingletonRegisterHelper<QmlKeyHelper>::getCallback());
 
+        qmlRegisterUncreatableType<QAbstractItemModel>(uri, versionMajor, versionMinor, "QtAbstractItemModel", "");
+        qmlRegisterUncreatableType<QWindow>(uri, versionMajor, versionMinor, "QtWindow", "");
+
         qRegisterMetaType<VLCTick>();
         qmlRegisterUncreatableType<VLCTick>(uri, versionMajor, versionMinor, "VLCTick", "");
         qmlRegisterUncreatableType<ColorSchemeModel>(uri, versionMajor, versionMinor, "ColorSchemeModel", "");
@@ -269,7 +272,7 @@ void MainUI::registerQMLTypes()
         qmlRegisterType<AboutModel>( uri, versionMajor, versionMinor, "AboutModel" );
 
         qmlRegisterUncreatableType<DialogErrorModel>( uri, versionMajor, versionMinor, "DialogErrorModel", "");
-        qRegisterMetaType<DialogId>();
+        qmlRegisterUncreatableType<DialogId>( uri, versionMajor, versionMinor, "DialogId", "");
 
         qmlRegisterType<ItemKeyEventFilter>( uri, versionMajor, versionMinor, "KeyEventFilter" );
         qmlRegisterType<MouseEventFilter>( uri, versionMajor, versionMinor, "MouseEventFilter" );
@@ -313,7 +316,8 @@ void MainUI::registerQMLTypes()
 
         qmlRegisterSingletonType<MediaLib>(uri, versionMajor, versionMinor, "MediaLib", SingletonRegisterHelper<MediaLib>::callback);
 
-        qRegisterMetaType<MLItemId>();
+        qmlRegisterUncreatableType<MLItemId>( uri, versionMajor, versionMinor, "MLItemId", "");
+        qmlRegisterUncreatableType<MLBaseModel>( uri, versionMajor, versionMinor, "MLModel", "ML Base Model is uncreatable." );
         qmlRegisterType<MLAlbumModel>( uri, versionMajor, versionMinor, "MLAlbumModel" );
         qmlRegisterType<MLArtistModel>( uri, versionMajor, versionMinor, "MLArtistModel" );
         qmlRegisterType<MLAlbumTrackModel>( uri, versionMajor, versionMinor, "MLAlbumTrackModel" );


=====================================
modules/gui/qt/maininterface/qml/MainDisplay.qml
=====================================
@@ -141,7 +141,7 @@ FocusScope {
     ]
 
 
-    property var tabModel: ListModel {
+    property ListModel tabModel: ListModel {
         id: tabModelid
         Component.onCompleted: {
             pageModel.forEach(function(e) {


=====================================
modules/gui/qt/maininterface/qml/MainInterface.qml
=====================================
@@ -36,7 +36,7 @@ Rectangle {
     property bool _playlistReady: false
 
     property alias g_root: root
-    property var g_dialogs: dialogsLoader.item
+    property QtObject g_dialogs: dialogsLoader.item
 
     Binding {
         target: VLCStyle.self


=====================================
modules/gui/qt/medialibrary/qml/MediaGroupDisplay.qml
=====================================
@@ -33,7 +33,7 @@ VideoAll {
     //---------------------------------------------------------------------------------------------
 
     property int    initialIndex: 0
-    property var    initialId
+    property MLItemId    initialId
     property string initialName
 
     //---------------------------------------------------------------------------------------------


=====================================
modules/gui/qt/medialibrary/qml/MusicAlbums.qml
=====================================
@@ -41,12 +41,12 @@ FocusScope {
     property alias parentId: albumModelId.parentId
     readonly property var currentIndex: _currentView.currentIndex
     //the index to "go to" when the view is loaded
-    property var initialIndex: 0
+    property int initialIndex: 0
     property int gridViewMarginTop: VLCStyle.margin_large
     property var gridViewRowX: MainCtx.gridView ? _currentView.rowX : undefined
 
     property Component header: Item{}
-    readonly property var headerItem: _currentView ? _currentView.headerItem : undefined
+    readonly property Item headerItem: _currentView ? _currentView.headerItem : null
 
     property alias _currentView: view.currentItem
 


=====================================
modules/gui/qt/medialibrary/qml/MusicArtist.qml
=====================================
@@ -34,7 +34,7 @@ FocusScope {
     property var artist: ({})
 
     //the index to "go to" when the view is loaded
-    property var initialIndex: 0
+    property int initialIndex: 0
 
     property Item headerItem: _currentView ? _currentView.headerItem : null
 


=====================================
modules/gui/qt/medialibrary/qml/MusicArtistDelegate.qml
=====================================
@@ -34,7 +34,7 @@ T.Control {
 
     // Properties
 
-    /* required */ property var mlModel
+    /* required */ property MLModel mlModel
 
     property bool isCurrent: false
 
@@ -45,9 +45,9 @@ T.Control {
 
     // Signals
 
-    signal itemClicked(variant mouse)
+    signal itemClicked(var mouse)
 
-    signal itemDoubleClicked(variant mouse)
+    signal itemDoubleClicked(var mouse)
 
     // Settings
 


=====================================
modules/gui/qt/medialibrary/qml/MusicArtistsDisplay.qml
=====================================
@@ -32,7 +32,7 @@ import "qrc:///style/"
 Widgets.PageLoader {
     id: root
 
-    property var model
+    property MLModel model
 
     defaultPage: "all"
     pageModel: [{


=====================================
modules/gui/qt/medialibrary/qml/MusicDisplay.qml
=====================================
@@ -67,7 +67,7 @@ Widgets.PageLoader {
         History.push(["mc", "music", root.pageModel[index].name])
     }
 
-    property var tabModel: ListModel {
+    property ListModel tabModel: ListModel {
         Component.onCompleted: {
             pageModel.forEach(function(e) {
                 append({


=====================================
modules/gui/qt/medialibrary/qml/MusicGenres.qml
=====================================
@@ -36,7 +36,7 @@ FocusScope {
 
     readonly property var currentIndex: _currentView.currentIndex
     //the index to "go to" when the view is loaded
-    property var initialIndex: 0
+    property int initialIndex: 0
 
     property alias _currentView: view.currentItem
 


=====================================
modules/gui/qt/medialibrary/qml/PlaylistMedia.qml
=====================================
@@ -40,7 +40,7 @@ MainInterface.MainTableView {
     //---------------------------------------------------------------------------------------------
     // Private
 
-    property var _item: null
+    property Item _item: null
 
     property bool _before: true
 


=====================================
modules/gui/qt/medialibrary/qml/PlaylistMediaDisplay.qml
=====================================
@@ -39,7 +39,7 @@ FocusScope {
     readonly property int currentIndex: view.currentIndex
 
     property int     initialIndex: 0
-    property var initialId
+    property MLItemId initialId
     property string  initialName
 
     // NOTE: Specify an optionnal header for the view.


=====================================
modules/gui/qt/medialibrary/qml/VideoAll.qml
=====================================
@@ -47,7 +47,7 @@ FocusScope {
 
     property int initialIndex: 0
 
-    property var model: MLVideoModel { ml: MediaLib }
+    property MLVideoModel model: MLVideoModel { ml: MediaLib }
 
     property var sortModel: [
         { text: I18n.qtr("Alphabetic"), criteria: "title"    },


=====================================
modules/gui/qt/medialibrary/qml/VideoDisplay.qml
=====================================
@@ -39,7 +39,7 @@ Widgets.PageLoader {
     property var contentModel
     property var sortModel
 
-    property var tabModel: ListModel {
+    property ListModel tabModel: ListModel {
         Component.onCompleted: {
             pageModel.forEach(function(e) {
                 append({


=====================================
modules/gui/qt/network/qml/DiscoverDisplay.qml
=====================================
@@ -60,7 +60,7 @@ Widgets.PageLoader {
     }
 
 
-    property var tabModel: ListModel {
+    property ListModel tabModel: ListModel {
         Component.onCompleted: {
             pageModel.forEach(function(e) {
                 append({


=====================================
modules/gui/qt/network/qml/NetworkThumbnailItem.qml
=====================================
@@ -35,7 +35,7 @@ Item {
     readonly property bool containsMouse: parent.containsMouse
     readonly property int index: parent.index
 
-    signal playClicked(var index)
+    signal playClicked(int index)
 
     Widgets.ListCoverShadow {
         anchors.fill: artwork.visible ? artwork : background


=====================================
modules/gui/qt/player/qml/PlayerControlLayout.qml
=====================================
@@ -29,19 +29,19 @@ FocusScope {
     implicitWidth: layoutLoader_left.implicitWidth + layoutLoader_center.implicitWidth + layoutLoader_right.implicitWidth + 2 * layoutSpacing
     implicitHeight: VLCStyle.maxControlbarControlHeight
 
-    property var colors: undefined
+    property VLCColors colors: null
 
-    property var defaultSize: VLCStyle.icon_normal // default size for IconToolButton based controls
+    property real defaultSize: VLCStyle.icon_normal // default size for IconToolButton based controls
 
     property real spacing: VLCStyle.margin_normal // spacing between controls
     property real layoutSpacing: VLCStyle.margin_xxlarge // spacing between layouts (left, center, and right)
 
     property int identifier: -1
-    readonly property var model: {
+    readonly property PlayerControlbarModel model: {
         if (!!MainCtx.controlbarProfileModel.currentModel)
             MainCtx.controlbarProfileModel.currentModel.getModel(identifier)
         else
-            undefined
+            null
     }
 
     signal requestLockUnlockAutoHide(bool lock, var source)


=====================================
modules/gui/qt/player/qml/PlayerMenu.qml
=====================================
@@ -30,7 +30,7 @@ import "qrc:///widgets/" as Widgets
 T.Menu {
     id: control
 
-    property var parentMenu: undefined
+    property Item parentMenu: null
     property bool _emitMenuClose: true
     signal menuClosed()
 


=====================================
modules/gui/qt/player/qml/PlayerMenuItem.qml
=====================================
@@ -46,7 +46,7 @@ T.MenuItem {
 
     leftPadding: VLCStyle.applicationHorizontalMargin
 
-    property var parentMenu: undefined
+    property Item parentMenu: null
 
     //workaround QTBUG-7018 for Qt < 5.12.2
     activeFocusOnTab: control.enabled


=====================================
modules/gui/qt/playlist/qml/PlaylistDetachedWindow.qml
=====================================
@@ -27,7 +27,7 @@ import "qrc:///style/"
 Window {
     visible: true
 
-    property var window: IntfWindow
+    property QtWindow window: IntfWindow
 
     width: 350
     minimumWidth: playlistView.minimumWidth
@@ -55,6 +55,6 @@ Window {
         focus: true
         anchors.fill: parent
 
-        readonly property var g_root: playlistView
+        readonly property PlaylistListView g_root: playlistView
     }
 }


=====================================
modules/gui/qt/widgets/qml/ExpandGridView.qml
=====================================
@@ -59,8 +59,8 @@ FocusScope {
                                                              /
                                                              _effectiveCellWidth), 1)
 
-    property var delegateModel
-    property var model
+    property Util.SelectableDelegateModel delegateModel
+    property QtAbstractItemModel model
 
     property int currentIndex: 0
 


=====================================
modules/gui/qt/widgets/qml/GridItem.qml
=====================================
@@ -66,7 +66,7 @@ T.Control {
     signal addToPlaylistClicked
     signal itemClicked(Item menuParent, int key, int modifier)
     signal itemDoubleClicked(Item menuParent, int keys, int modifier)
-    signal contextMenuButtonClicked(Item menuParent, var globalMousePos)
+    signal contextMenuButtonClicked(Item menuParent, point globalMousePos)
 
     // Settings
 


=====================================
modules/gui/qt/widgets/qml/KeyNavigableTableView.qml
=====================================
@@ -55,11 +55,11 @@ FocusScope {
     }
 
     property Component header: Item{}
-    property var headerItem: view.headerItem.loadedHeader
+    property Item headerItem: view.headerItem.loadedHeader
     property color headerColor
     property int headerTopPadding: 0
 
-    property var selectionDelegateModel
+    property Util.SelectableDelegateModel selectionDelegateModel
     property real rowHeight: VLCStyle.tableRow_height
     readonly property int _contextButtonHorizontalSpace: VLCStyle.icon_normal
     property int horizontalSpacing: VLCStyle.column_margin_width
@@ -110,8 +110,8 @@ FocusScope {
 
     //forwarded from subview
     signal actionForSelection( var selection )
-    signal contextMenuButtonClicked(Item menuParent, var menuModel, var globalMousePos)
-    signal rightClick(Item menuParent, var menuModel, var globalMousePos)
+    signal contextMenuButtonClicked(Item menuParent, var menuModel, point globalMousePos)
+    signal rightClick(Item menuParent, var menuModel, point globalMousePos)
     signal itemDoubleClicked(var index, var model)
 
     // Settings


=====================================
modules/gui/qt/widgets/qml/MLDragItem.qml
=====================================
@@ -26,7 +26,7 @@ import org.videolan.medialib 0.1
 DragItem {
     id: root
 
-    /* required */ property var mlModel: null
+    /* required */ property MLModel mlModel: null
 
     // string => role for medialib id, data[id] will be pass to Medialib::mlInputItem for QmlInputItem
     property string mlIDRole: "id"


=====================================
modules/gui/qt/widgets/qml/SortControl.qml
=====================================
@@ -58,8 +58,8 @@ FocusScope {
     // sortSelected is triggered with new sorting key when a different sorting key is selected
     // sortOrderSelected is triggered with Qt.AscendingOrder when different sorting key is selected
     // sortOrderSelected is triggered with Qt.AscendingOrder or Qt.DescendingOrder when the same sorting key is selected
-    signal sortSelected(var type)
-    signal sortOrderSelected(var type)
+    signal sortSelected(int type)
+    signal sortOrderSelected(int type)
 
     onVisibleChanged: {
         if (!visible)



View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/c4edf973406e042ea1d1c74ec14987727bb137d3

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




More information about the vlc-commits mailing list