qml: use function syntax in Connections objects

using implicit signal handler is deprecated since Qt5.15
This commit is contained in:
Pierre Lamot 2024-04-10 15:59:37 +02:00 committed by Steve Lhomme
parent 9e6ef484e8
commit 4ddf10e92b
33 changed files with 120 additions and 90 deletions

View File

@ -76,14 +76,14 @@ Item {
{
target: dialogModel
onLogin: (dialogId, title, text, defaultUsername, askStore) => {
function onLogin(dialogId, title, text, defaultUsername, askStore) {
loginDialog.dialogId = dialogId
loginDialog.title = title
loginDialog.defaultUsername = defaultUsername
loginDialog.open()
}
onQuestion: (dialogId, title, text, type, cancel, action1, action2) => {
function onQuestion(dialogId, title, text, type, cancel, action1, action2) {
questionDialog.dialogId = dialogId
questionDialog.title = title
questionDialog.text = text
@ -93,7 +93,7 @@ Item {
questionDialog.open()
}
onProgress: (dialogId, title, text, indeterminate, position, cancel) => {
function onProgress(dialogId, title, text, indeterminate, position, cancel) {
progressDialog.dialogId = dialogId
progressDialog.title = title
progressDialog.text = text
@ -103,7 +103,7 @@ Item {
progressDialog.open()
}
onProgressUpdated: (dialogId, position, text) => {
function onProgressUpdated(dialogId, position, text) {
if (progressDialog.dialogId !== dialogId) {
console.warn("progress event on an inexisting dialog")
return
@ -112,7 +112,7 @@ Item {
progressDialog.position = position
}
onCancelled: (dialogId) => {
function onCancelled(dialogId) {
if (questionDialog.dialogId === dialogId) {
questionDialog.close()
questionDialog.dialogId = null
@ -135,7 +135,7 @@ Item {
{
target: DialogErrorModel
onCountChanged: {
function onCountChanged() {
hideErrorPopupTimer.restart()
errorPopup.state = "visible"
}
@ -588,7 +588,7 @@ Item {
Connections {
target: toolbarEditorDialogLoader.item
onUnload: {
function onUnload() {
toolbarEditorDialogLoader.active = false
}
}
@ -596,7 +596,7 @@ Item {
Connections {
target: DialogsProvider
onShowToolbarEditorDialog: {
function onShowToolbarEditorDialog() {
toolbarEditorDialogLoader.active = true
toolbarEditorDialogLoader.item.open()
}

View File

@ -202,14 +202,14 @@ Item {
target: root
enabled: dndView.model === layout.model.center
onDragStarted: (controlId) => {
function onDragStarted(controlId) {
// extending spacer widget should not be placed in the
// central alignment view
if (controlId === ControlListModel.WIDGET_SPACER_EXTEND)
visible = false
}
onDragStopped: (controlId) => {
function onDragStopped(controlId) {
if (controlId === ControlListModel.WIDGET_SPACER_EXTEND)
visible = true
}

View File

@ -76,7 +76,9 @@ T.ToolBar {
Connections {
target: MainCtx.search
onAskShow: searchBox.expandAndFocus()
function onAskShow() {
searchBox.expandAndFocus()
}
}
background: Widgets.AcrylicBackground {

View File

@ -423,7 +423,7 @@ FocusScope {
Connections {
target: MainCtx
onPlaylistWidthFactorChanged: {
function onPlaylistWidthFactorChanged() {
resizeHandle._updateFromMainInterface()
}
}
@ -479,11 +479,11 @@ FocusScope {
//keep the player visible on resize
Connections {
target: g_mainDisplay
onWidthChanged: {
function onWidthChanged() {
if (playerPip.x > playerPip.dragXMax)
playerPip.x = playerPip.dragXMax
}
onHeightChanged: {
function onHeightChanged() {
if (playerPip.y > playerPip.dragYMax)
playerPip.y = playerPip.dragYMax
}
@ -526,7 +526,7 @@ FocusScope {
Connections {
target: Player
onHasVideoOutputChanged: {
function onHasVideoOutputChanged() {
if (Player.hasVideoOutput && MainCtx.hasEmbededVideo) {
if (!History.match(History.viewPath, ["player"]))
History.push(["player"])

View File

@ -141,13 +141,13 @@ Item {
}
Connections {
target: playlistWindowLoader.item
onClosing: MainCtx.playlistVisible = false
function onClosing() { MainCtx.playlistVisible = false }
}
Connections {
target: MainPlaylistController
onPlaylistInitialized: {
function onPlaylistInitialized() {
_playlistReady = true
if (_interfaceReady)
setInitialView()
@ -156,7 +156,7 @@ Item {
Connections {
target: History
onNavigate: (focusReason) => {
function onNavigate(focusReason) {
loadCurrentHistoryView(focusReason)
MainCtx.mediaLibraryVisible = !History.match(History.viewPath, ["player"])
}
@ -165,7 +165,7 @@ Item {
Connections {
target: MainCtx
onMediaLibraryVisibleChanged: {
function onMediaLibraryVisibleChanged() {
if (MainCtx.mediaLibraryVisible) {
if (History.match(History.viewPath, ["mc"]))
return
@ -246,7 +246,7 @@ Item {
Connections {
target: Player
onPlayingStateChanged: {
function onPlayingStateChanged() {
if (Player.playingState === Player.PLAYING_STATE_STOPPED
&& History.match(History.viewPath, ["player"]) ) {
if (History.previousEmpty)

View File

@ -131,7 +131,7 @@ Widgets.StackViewExt {
Connections {
target: model
onCountChanged: {
function onCountChanged() {
if (selectionModel.hasSelection)
return

View File

@ -165,7 +165,9 @@ MainInterface.MainViewLoader {
Connections {
target: contextMenu
onShowMediaInformation: (index) => gridView_id.switchExpandItem( index )
function onShowMediaInformation(index) {
gridView_id.switchExpandItem( index )
}
}
}
}
@ -259,7 +261,7 @@ MainInterface.MainViewLoader {
Connections {
target: albumModelId
onSortCriteriaChanged: {
function onSortCriteriaChanged() {
switch (albumModelId.sortCriteria) {
case "title":
case "main_artist":

View File

@ -198,7 +198,9 @@ FocusScope {
Connections {
target: albumsList.selectionModel
onSelectionChanged: gridItem.selected = albumsList.selectionModel.isSelected(index)
function onSelectionChanged() {
gridItem.selected = albumsList.selectionModel.isSelected(index)
}
}
function play() {
@ -342,7 +344,9 @@ FocusScope {
Connections {
target: albumModel
// selectionModel updates but doesn't trigger any signal, this forces selection update in view
onParentIdChanged: currentIndex = -1
function onParentIdChanged() {
currentIndex = -1
}
}
delegate: AudioGridItem {
@ -410,7 +414,9 @@ FocusScope {
Connections {
target: contextMenu
onShowMediaInformation: (index) => gridView_id.switchExpandItem( index )
function onShowMediaInformation(index) {
gridView_id.switchExpandItem( index )
}
}
}
@ -533,7 +539,7 @@ FocusScope {
Connections {
target: MainCtx
onGridViewChanged: {
function onGridViewChanged() {
if (MainCtx.gridView)
view.replace(gridComponent)
else

View File

@ -142,7 +142,9 @@ MainInterface.MainTableView {
target: root
// NOTE: We want to hide the drop line when scrolling so its position stays relevant.
onContentYChanged: hideLine(_item)
function onContentYChanged() {
hideLine(_item)
}
}
//---------------------------------------------------------------------------------------------

View File

@ -106,7 +106,9 @@ VideoAll {
Connections {
target: MainCtx
onGroupingChanged: root._updateMetaModel(MainCtx.grouping)
function onGroupingChanged() {
root._updateMetaModel(MainCtx.grouping)
}
}
Component.onCompleted: root._updateMetaModel(MainCtx.grouping)

View File

@ -73,7 +73,7 @@ MainInterface.MainGridView {
Connections {
target: gridView.contextMenu
onShowMediaInformation: (index) => {
function onShowMediaInformation(index) {
gridView.switchExpandItem(index)
if (gridView.focus)

View File

@ -100,7 +100,7 @@ FocusScope {
Connections {
target: MainCtx
onGridViewChanged: {
function onGridViewChanged() {
if (MainCtx.gridView) view.replace(grid)
else view.replace(list)
}

View File

@ -109,8 +109,8 @@ Repeater {
enabled: loader.status === Loader.Ready
onVisibleChanged: {
if (activeFocus && !item.visible)
function onVisibleChanged() {
if (loader.activeFocus && !item.visible)
recoverFocus()
}
}

View File

@ -50,7 +50,9 @@ Control {
Connections {
target: MainCtx
onNavBoxToggled: navigationBox.toggleVisibility()
function onNavBoxToggled() {
navigationBox.toggleVisibility()
}
}
contentItem: GridLayout {

View File

@ -44,7 +44,7 @@ Item {
Connections {
target: mouseArea.drag
onActiveChanged: {
function onActiveChanged() {
root.anchors.left = undefined;
root.anchors.right = undefined
root.anchors.top = undefined

View File

@ -151,7 +151,9 @@ ColumnLayout {
Connections {
target: Player
onRateChanged: _updateValue(Player.rate)
function onRateChanged() {
_updateValue(Player.rate)
}
}
// Children

View File

@ -123,7 +123,9 @@ FocusScope {
Connections {
target: Player
onVolumeChanged: animationVolume.restart()
function onVolumeChanged() {
animationVolume.restart()
}
}
// Functions
@ -174,9 +176,15 @@ FocusScope {
target: MainCtx
//playlist
onPlaylistDockedChanged: playlistVisibility.updatePlaylistDocked()
onPlaylistVisibleChanged: playlistVisibility.updatePlaylistVisible()
onHasEmbededVideoChanged: playlistVisibility.updateVideoEmbed()
function onPlaylistDockedChanged() {
playlistVisibility.updatePlaylistDocked()
}
function onPlaylistVisibleChanged() {
playlistVisibility.updatePlaylistVisible()
}
function onHasEmbededVideoChanged() {
playlistVisibility.updateVideoEmbed()
}
}
VideoSurface {
@ -665,7 +673,7 @@ FocusScope {
Connections {
target: MainCtx
onPlaylistWidthFactorChanged: {
function onPlaylistWidthFactorChanged() {
resizeHandle._updateFromMainCtx()
}
}
@ -729,19 +737,19 @@ FocusScope {
// NavigationBox's visibility depends on this timer
Connections {
target: MainCtx
onNavBoxToggled: toggleControlBarButtonAutoHide.restart()
function onNavBoxToggled() { toggleControlBarButtonAutoHide.restart() }
}
Connections {
target: rootPlayer
onWidthChanged: {
if (navBox.x > navBox.dragXMax)
navBox.x = navBox.dragXMax
}
onHeightChanged: {
if (navBox.y > navBox.dragYMax)
navBox.y = navBox.dragYMax
}
target: rootPlayer
function onWidthChanged() {
if (navBox.x > navBox.dragXMax)
navBox.x = navBox.dragXMax
}
function onHeightChanged() {
if (navBox.y > navBox.dragYMax)
navBox.y = navBox.dragYMax
}
}
Widgets.ButtonExt {
@ -886,7 +894,7 @@ FocusScope {
Connections {
target: MainCtx
onAskShow: {
function onAskShow() {
toolbarAutoHide.toggleForceVisible()
}
}

View File

@ -68,7 +68,7 @@ FocusScope {
Connections {
target: Player
onCanRestorePlaybackChanged: {
function onCanRestorePlaybackChanged() {
if (Player.canRestorePlayback) {
showResumePanel()
} else {

View File

@ -192,8 +192,8 @@ Slider {
Connections {
target: Player
onPositionChanged: fsm.playerUpdatePosition(Player.position)
onInputChanged: fsm.inputChanged()
function onPositionChanged() { fsm.playerUpdatePosition(Player.position) }
function onInputChanged() { fsm.inputChanged() }
}
Component.onCompleted: value = Player.position

View File

@ -275,7 +275,7 @@ FocusScope{
Connections {
target: logo.button
onSystemMenuVisibilityChanged: {
function onSystemMenuVisibilityChanged() {
root.requestLockUnlockAutoHide(visible)
}
}
@ -393,7 +393,7 @@ FocusScope{
Connections {
target: csdDecorations.item
enabled: csdDecorations.status === Loader.Ready
onButtonHoveredChanged: root.requestLockUnlockAutoHide(csdDecorations.item.buttonHovered)
function onButtonHoveredChanged() { root.requestLockUnlockAutoHide(csdDecorations.item.buttonHovered) }
}
}

View File

@ -111,7 +111,7 @@ TracksPage {
Connections {
target: Player
onAudioDelayChanged: {
function onAudioDelayChanged() {
spinBox.update = false
spinBox.value = Player.audioDelayMS

View File

@ -127,7 +127,7 @@ TracksPage {
Connections {
target: Player
onSubtitleDelayChanged: {
function onSubtitleDelayChanged() {
spinBoxA.update = false
spinBoxA.value = Player.subtitleDelayMS
@ -256,7 +256,7 @@ TracksPage {
Connections {
target: Player
onSecondarySubtitleDelayChanged: {
function onSecondarySubtitleDelayChanged() {
spinBoxB.update = false
spinBoxB.value = Player.secondarySubtitleDelayMS
@ -370,7 +370,7 @@ TracksPage {
Connections {
target: Player
onSecondarySubtitleDelayChanged: {
function onSecondarySubtitleDelayChanged() {
spinBoxC.update = false
value = Player.subtitleFPS / 10

View File

@ -39,7 +39,11 @@ Widgets.ComboBoxExt {
Connections {
target: combo.popup
onOpened: combo.requestLockUnlockAutoHide(true)
onClosed: combo.requestLockUnlockAutoHide(false)
function onOpened() {
combo.requestLockUnlockAutoHide(true)
}
function onClosed() {
combo.requestLockUnlockAutoHide(false)
}
}
}

View File

@ -156,7 +156,7 @@ T.Pane {
Connections {
target: Player
onTeletextPageChanged: {
function onTeletextPageChanged() {
telePageNumber.inhibitPageUpdate = true
telePageNumber.value = Player.teletextPage
telePageNumber.inhibitPageUpdate = false

View File

@ -182,7 +182,7 @@ T.Pane {
target: Player
enabled: !paintOnly
onVolumeChanged: volControl._syncVolumeWithPlayer()
function onVolumeChanged() { volControl._syncVolumeWithPlayer() }
}
Binding on toolTip.visible {

View File

@ -278,12 +278,12 @@ T.Pane {
Connections {
target: listView.model
onRowsInserted: {
function onRowsInserted() {
if (listView.currentIndex === -1)
listView.currentIndex = 0
}
onModelReset: {
function onModelReset() {
if (listView.currentIndex === -1 && root.model.count > 0)
listView.currentIndex = 0
}

View File

@ -53,18 +53,18 @@ Image {
target: root
// handles VLCStyle.scale changes
onXChanged: Qt.callLater(root.updateRect)
onYChanged: Qt.callLater(root.updateRect)
onWidthChanged: Qt.callLater(root.updateRect)
onHeightChanged: Qt.callLater(root.updateRect)
function onXChanged() { Qt.callLater(root.updateRect) }
function onYChanged() { Qt.callLater(root.updateRect) }
function onWidthChanged() { Qt.callLater(root.updateRect) }
function onHeightChanged() { Qt.callLater(root.updateRect) }
}
Connections {
target: VLCStyle
// handle window resize
onAppWidthChanged: Qt.callLater(root.updateRect)
onAppHeightChanged: Qt.callLater(root.updateRect)
function onAppWidthChanged() { Qt.callLater(root.updateRect) }
function onAppHeightChanged() { Qt.callLater(root.updateRect) }
}
}
}

View File

@ -112,8 +112,8 @@ Row {
target: VLCStyle
// handle window resize
onAppWidthChanged: Qt.callLater(updateRect)
onAppHeightChanged: Qt.callLater(updateRect)
function onAppWidthChanged() { Qt.callLater(updateRect) }
function onAppHeightChanged() { Qt.callLater(updateRect) }
}
function updateRect() {

View File

@ -70,7 +70,7 @@ ComboBox {
Connections {
target: control
onPressedChanged: canvas.requestPaint()
function onPressedChanged() { canvas.requestPaint() }
}
onPaint: {

View File

@ -285,7 +285,7 @@ FocusScope {
Connections {
target: model
onDataChanged: (topLeft, bottomRight, roles) => {
function onDataChanged(topLeft, bottomRight, roles) {
const iMin = topLeft.row
const iMax = bottomRight.row + 1 // [] => [)
const f_l = _currentRange
@ -296,18 +296,18 @@ FocusScope {
_refreshData(iMin, iMax)
}
}
onRowsInserted: _onModelCountChanged()
onRowsRemoved: _onModelCountChanged()
onModelReset: _onModelCountChanged()
function onRowsInserted() { _onModelCountChanged() }
function onRowsRemoved() { _onModelCountChanged() }
function onModelReset() { _onModelCountChanged() }
// NOTE: This is useful for SortFilterProxyModel(s).
onLayoutChanged: _onModelCountChanged()
function onLayoutChanged() { _onModelCountChanged() }
}
Connections {
target: selectionModel
onSelectionChanged: (selected, deselected) => {
function onSelectionChanged(selected, deselected) {
for (let i = 0; i < selected.length; ++i) {
_updateSelectedRange(selected[i].topLeft, selected[i].bottomRight, true)
}
@ -340,7 +340,7 @@ FocusScope {
Connections {
target: MainCtx
onIntfScaleFactorChanged: flickable.layout(true)
function onIntfScaleFactorChanged() { flickable.layout(true) }
}
// Animations
@ -785,11 +785,11 @@ FocusScope {
animateFlickableContentY(0)
}
onHeightChanged: {
function onHeightChanged() {
flickable.layout(true)
}
onActiveFocusChanged: {
function onActiveFocusChanged() {
// when header loads because of setting headerItem.focus == true, it will suddenly attain the active focus
// but then a queued flickable.layout() may take away it's focus and assign it to current item,
// using Qt.callLater we save unnecessary scrolling
@ -799,7 +799,7 @@ FocusScope {
Connections {
target: footerItem
onHeightChanged: {
function onHeightChanged() {
if (flickable.contentY + flickable.height > footerItemLoader.y + footerItemLoader.height)
flickable.contentY = footerItemLoader.y + footerItemLoader.height - flickable.height
flickable.layout(false)
@ -957,7 +957,7 @@ FocusScope {
Connections {
target: expandItem
onImplicitHeightChanged: {
function onImplicitHeightChanged() {
/* This is the only event we have after the expandItem height content was resized.
We can trigger here the expand animation with the right final height. */
if (root.expandIndex !== -1)

View File

@ -296,7 +296,7 @@ ListView {
// FIXME: This is probably not useful anymore.
Connections {
target: root.headerItem
onFocusChanged: {
function onFocusChanged() {
if (!headerItem.focus) {
currentItem.focus = true
}

View File

@ -413,7 +413,7 @@ FocusScope {
Connections {
target: selectionModel
onSelectionChanged: {
function onSelectionChanged() {
tableDelegate.selected = Qt.binding(function() {
return root.selectionModel.selectedIndexesFlat.includes(index)
})

View File

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