[vlc-commits] [Git][videolan/vlc][master] qml: use function for signal handlers

Jean-Baptiste Kempf (@jbk) gitlab at videolan.org
Sun May 5 16:23:20 UTC 2024



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


Commits:
65e0e215 by Pierre Lamot at 2024-05-05T16:02:59+00:00
qml: use function for signal handlers

qt will warn about parameter injection otherwise

- - - - -


21 changed files:

- modules/gui/qt/dialogs/dialogs/qml/WindowDialog.qml
- modules/gui/qt/dialogs/toolbar/qml/ToolbarEditorDialog.qml
- modules/gui/qt/maininterface/qml/BannerSources.qml
- modules/gui/qt/medialibrary/qml/MusicAlbums.qml
- modules/gui/qt/medialibrary/qml/MusicArtist.qml
- modules/gui/qt/medialibrary/qml/MusicGenres.qml
- modules/gui/qt/medialibrary/qml/PlaylistMedia.qml
- modules/gui/qt/medialibrary/qml/VideoAll.qml
- modules/gui/qt/medialibrary/qml/VideoAllSubDisplay.qml
- modules/gui/qt/medialibrary/qml/VideoGridDisplay.qml
- modules/gui/qt/medialibrary/qml/VideoRecentVideos.qml
- modules/gui/qt/network/qml/BrowseDeviceView.qml
- modules/gui/qt/network/qml/BrowseDisplay.qml
- modules/gui/qt/network/qml/BrowseTreeDisplay.qml
- modules/gui/qt/player/qml/Player.qml
- modules/gui/qt/player/qml/TopBar.qml
- modules/gui/qt/playlist/qml/PlaylistDelegate.qml
- modules/gui/qt/playlist/qml/PlaylistToolbar.qml
- modules/gui/qt/widgets/qml/CSDTitlebarTapNDrapHandler.qml
- modules/gui/qt/widgets/qml/GridItem.qml
- modules/gui/qt/widgets/qml/SortControl.qml


Changes:

=====================================
modules/gui/qt/dialogs/dialogs/qml/WindowDialog.qml
=====================================
@@ -49,7 +49,10 @@ Window {
     signal reset()
 
     onAccepted: hide()
-    onRejected: if (byButton) hide()
+    onRejected: (byButton) => {
+        if (byButton)
+            hide()
+    }
     onApplied: hide()
     onDiscarded: hide()
     onReset: hide()


=====================================
modules/gui/qt/dialogs/toolbar/qml/ToolbarEditorDialog.qml
=====================================
@@ -49,7 +49,7 @@ WindowDialog {
         unload()
     }
 
-    onRejected: {
+    onRejected: (byButton) => {
         // Load saved to discard the changes
         MainCtx.controlbarProfileModel.reload()
         unload()


=====================================
modules/gui/qt/maininterface/qml/BannerSources.qml
=====================================
@@ -287,10 +287,12 @@ T.ToolBar {
                                 sortKey:  MainCtx.sort.criteria
                                 sortOrder: MainCtx.sort.order
 
-                                onSortSelected: {
+                                onSortSelected: (key) => {
                                     MainCtx.sort.criteria = key
                                 }
-                                onSortOrderSelected: MainCtx.sort.order = type
+                                onSortOrderSelected: (type) => {
+                                    MainCtx.sort.order = type
+                                }
                             }
                         }
 


=====================================
modules/gui/qt/medialibrary/qml/MusicAlbums.qml
=====================================
@@ -233,7 +233,7 @@ MainInterface.MainViewLoader {
 
             model: albumModelId
             selectionModel: root.selectionModel
-            onActionForSelection: _actionAtIndex(selection[0]);
+            onActionForSelection: (selection) => _actionAtIndex(selection[0])
             Navigation.parentItem: root
             section.property: "title_first_symbol"
             header: root.header


=====================================
modules/gui/qt/medialibrary/qml/MusicArtist.qml
=====================================
@@ -433,7 +433,7 @@ FocusScope {
             clip: true // content may overflow if not enough space is provided
             model: trackModel
 
-            onActionForSelection: {
+            onActionForSelection: (selection) => {
                 model.addAndPlay(selection)
             }
 


=====================================
modules/gui/qt/medialibrary/qml/MusicGenres.qml
=====================================
@@ -270,7 +270,7 @@ MainInterface.MainViewLoader {
 
             selectionModel: root.selectionModel
             focus: true
-            onActionForSelection: _actionAtIndex(selection)
+            onActionForSelection: (selection) => _actionAtIndex(selection)
             Navigation.parentItem: root
             dragItem: genreDragItem
             rowHeight: VLCStyle.tableCoverRow_height


=====================================
modules/gui/qt/medialibrary/qml/PlaylistMedia.qml
=====================================
@@ -122,8 +122,8 @@ MainInterface.MainTableView {
     // Events
     //---------------------------------------------------------------------------------------------
 
-    onActionForSelection: model.addAndPlay( selection )
-    onItemDoubleClicked: MediaLib.addAndPlay(model.id)
+    onActionForSelection: (selection) => model.addAndPlay( selection )
+    onItemDoubleClicked: (index, model) => MediaLib.addAndPlay(model.id)
 
 
     onDropEntered: (delegate, index, drag, before) => {


=====================================
modules/gui/qt/medialibrary/qml/VideoAll.qml
=====================================
@@ -170,7 +170,7 @@ MainInterface.MainViewLoader {
 
             onActionAtIndex: root.onAction(selectionModel.selectedIndexes)
 
-            onItemDoubleClicked: root.onDoubleClick(model)
+            onItemDoubleClicked: model => root.onDoubleClick(model)
         }
     }
 


=====================================
modules/gui/qt/medialibrary/qml/VideoAllSubDisplay.qml
=====================================
@@ -37,7 +37,7 @@ VideoAll {
     property SortMenuVideo sortMenu: SortMenuVideo {
         ctx: MainCtx
 
-        onGrouping: MainCtx.grouping = grouping
+        onGrouping: (groupping) => { MainCtx.grouping = grouping }
     }
 
     // Private


=====================================
modules/gui/qt/medialibrary/qml/VideoGridDisplay.qml
=====================================
@@ -108,7 +108,7 @@ MainInterface.MainGridView {
 
         onItemClicked: (_,_, modifier) => { gridView.leftClickOnItem(modifier, index) }
 
-        onItemDoubleClicked: gridView.itemDoubleClicked(model)
+        onItemDoubleClicked: model => gridView.itemDoubleClicked(model)
 
         onContextMenuButtonClicked: (_, globalMousePos) => {
             gridView.rightClickOnItem(index);


=====================================
modules/gui/qt/medialibrary/qml/VideoRecentVideos.qml
=====================================
@@ -99,7 +99,7 @@ FocusScope {
 
             text: qsTr("Continue Watching")
 
-            onSeeAllButtonClicked: History.push(["mc", "video", "all", "recentVideos"]);
+            onSeeAllButtonClicked: reason => History.push(["mc", "video", "all", "recentVideos"])
 
             Navigation.parentItem: root
 


=====================================
modules/gui/qt/network/qml/BrowseDeviceView.qml
=====================================
@@ -66,7 +66,7 @@ FocusScope {
             view.setCurrentItemFocus(Qt.TabFocusReason)
         }
 
-        onSeeAllButtonClicked: root.seeAll(reason)
+        onSeeAllButtonClicked: reason => root.seeAll(reason)
     }
 
     property string title
@@ -301,9 +301,9 @@ FocusScope {
 
             Navigation.upItem: headerItem
 
-            onActionForSelection: root.onAction(selection[0].row)
+            onActionForSelection: selection => root.onAction(selection[0].row)
 
-            onItemDoubleClicked: root.onDoubleClicked(model, index)
+            onItemDoubleClicked: (index, model) => root.onDoubleClicked(model, index)
 
             Component {
                 id: artworkHeader
@@ -329,7 +329,7 @@ FocusScope {
             Component {
                 id: artworkColumn
 
-                NetworkThumbnailItem { onPlayClicked: root.playAt(index) }
+                NetworkThumbnailItem { onPlayClicked: index => root.playAt(index) }
             }
 
             Component {


=====================================
modules/gui/qt/network/qml/BrowseDisplay.qml
=====================================
@@ -188,7 +188,7 @@ Widgets.PageLoader {
         NetworkAddressbar {
             path: root.pageName === "browse" ? root.currentItem.model.path : []
 
-            onHomeButtonClicked: root._showHome(reason)
+            onHomeButtonClicked: reason => root._showHome(reason)
 
             onBrowse:  (tree, reason) => { root._showBrowseNode(tree, reason) }
         }


=====================================
modules/gui/qt/network/qml/BrowseTreeDisplay.qml
=====================================
@@ -219,7 +219,7 @@ MainInterface.MainViewLoader {
             }
 
             property Component thumbnailColumn: NetworkThumbnailItem {
-                onPlayClicked: playAt(index)
+                onPlayClicked: index => playAt(index)
             }
 
             property var _modelSmall: [{


=====================================
modules/gui/qt/player/qml/Player.qml
=====================================
@@ -729,7 +729,7 @@ FocusScope {
         dragYMin: 0
         dragYMax: rootPlayer.height - navBox.height
 
-        Drag.onDragStarted: {
+        Drag.onDragStarted: (controlId) => {
             navBox.x = drag.x
             navBox.y = drag.y
         }


=====================================
modules/gui/qt/player/qml/TopBar.qml
=====================================
@@ -209,8 +209,8 @@ FocusScope{
         visible: root.showToolbar
         enabled: root.showToolbar
 
-        onHoveredChanged: root.requestLockUnlockAutoHide(hovered)
-        onMenuOpenedChanged: root.requestLockUnlockAutoHide(menuOpened)
+        onHoveredChanged: menu => root.requestLockUnlockAutoHide(hovered)
+        onMenuOpenedChanged: menu => root.requestLockUnlockAutoHide(menuOpened)
     }
 
     Item {


=====================================
modules/gui/qt/playlist/qml/PlaylistDelegate.qml
=====================================
@@ -293,7 +293,7 @@ T.ItemDelegate {
                 MainPlaylistController.goTo(index, true)
             }
 
-            onLongPressed: {
+            onLongPressed: (eventPoint, button) => {
                 if (contextMenu)
                     contextMenu.popup(index, point.scenePosition)
             }


=====================================
modules/gui/qt/playlist/qml/PlaylistToolbar.qml
=====================================
@@ -105,11 +105,11 @@ RowLayout {
 
             model: MainPlaylistController.sortKeyTitleList
 
-            onSortSelected: {
+            onSortSelected: key => {
                 MainPlaylistController.sortKey = key
             }
 
-            onSortOrderSelected: {
+            onSortOrderSelected: type => {
                 if (type === Qt.AscendingOrder)
                     MainPlaylistController.sortOrder = PlaylistController.SORT_ORDER_ASC
                 else if (type === Qt.DescendingOrder)


=====================================
modules/gui/qt/widgets/qml/CSDTitlebarTapNDrapHandler.qml
=====================================
@@ -26,8 +26,8 @@ Item {
     TapHandler {
         acceptedButtons: Qt.LeftButton | Qt.RightButton
 
-        onSingleTapped: {
-            if (eventPoint.event.button & Qt.RightButton) {
+        onSingleTapped: (eventPoint, button) => {
+            if (button & Qt.RightButton) {
                 const systemButton = MainCtx.csdButtonModel.systemMenuButton
                 if (systemButton) {
                     systemButton.showSystemMenu(eventPoint.position)
@@ -35,8 +35,8 @@ Item {
             }
         }
 
-        onDoubleTapped: {
-            if (!(eventPoint.event.button & Qt.LeftButton))
+        onDoubleTapped: (eventpoint, button) => {
+            if (!(button & Qt.LeftButton))
                 return
 
             // handle left button click


=====================================
modules/gui/qt/widgets/qml/GridItem.qml
=====================================
@@ -219,7 +219,7 @@ T.ItemDelegate {
         TapHandler {
             acceptedDevices: PointerDevice.TouchScreen
 
-            onTapped: {
+            onTapped: (eventPoint, button) => {
                 root.itemClicked(picture, Qt.LeftButton, Qt.NoModifier)
                 root.itemDoubleClicked(picture, Qt.LeftButton, Qt.NoModifier)
             }


=====================================
modules/gui/qt/widgets/qml/SortControl.qml
=====================================
@@ -81,7 +81,7 @@ Widgets.IconToolButton {
     Connections {
         target: (_menu) ? _menu : null
 
-        function onSelected() {
+        function onSelected(index: int) {
             const selectedSortKey = root.model[index].criteria
 
             if (root.sortKey !== selectedSortKey) {



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

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/65e0e215a51451fc0d90fc2957037fc20bc83da8
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