From 1051a4045b58cb1501d9f7bfc3cfbcfd9892a78f Mon Sep 17 00:00:00 2001 From: Konrad Materka Date: Sat, 19 Dec 2020 23:13:52 +0100 Subject: [PATCH] Fix Connections warnings Qt 5.14 introduced new syntax for defining Connections. Fix warnings like this one: QML Connections: Implicitly defined onFoo properties in Connections are deprecated. Use this syntax instead: function onFoo() { ... } --- examples/applets/notes/contents/ui/main.qml | 2 +- src/declarativeimports/CMakeLists.txt | 7 ------- .../calendar/qml/DaysCalendar.qml | 2 +- .../plasmacomponents/qml/Highlight.qml | 2 +- .../plasmacomponents/qml/ScrollBar.qml | 14 ++++++++----- .../plasmacomponents/qml/SectionScroller.qml | 2 +- .../plasmacomponents/qml/TabButton.qml | 12 +++++++---- .../plasmacomponents/qml/ToolBar.qml | 4 +++- .../qml/private/InlineDialog.qml | 2 +- .../qml/private/ScrollDecoratorDelegate.qml | 2 +- .../plasmacomponents3/Menu.qml | 7 +++---- .../plasmacomponents3/MenuItem.qml | 21 +++++++++---------- .../plasmastyle/BusyIndicatorStyle.qml | 2 +- .../plasmastyle/EditMenuTouch.qml | 12 +++++------ .../plasmastyle/ScrollViewStyle.qml | 4 +++- .../plasmastyle/ToolButtonStyle.qml | 2 +- 16 files changed, 50 insertions(+), 47 deletions(-) diff --git a/examples/applets/notes/contents/ui/main.qml b/examples/applets/notes/contents/ui/main.qml index 8ac499bd3..6bf988f13 100644 --- a/examples/applets/notes/contents/ui/main.qml +++ b/examples/applets/notes/contents/ui/main.qml @@ -18,7 +18,7 @@ PlasmaCore.SvgItem { Connections { target: plasmoid - onExternalData: { + function onExternalData(mimetype, data) { if (mimetype === "text/plain") { noteText.text = data } diff --git a/src/declarativeimports/CMakeLists.txt b/src/declarativeimports/CMakeLists.txt index 864f08444..abcea3fc8 100644 --- a/src/declarativeimports/CMakeLists.txt +++ b/src/declarativeimports/CMakeLists.txt @@ -14,13 +14,6 @@ install(DIRECTORY kirigamiplasmadesktopstyle/ DESTINATION ${KDE_INSTALL_QMLDIR}/ set(QQC2_VERSION "2.${Qt5QuickControls2_VERSION_MINOR}") -if (Qt5Qml_VERSION_STRING VERSION_GREATER_EQUAL 5.14) - set(DISABLE_UNDER_QT_5_14 "") - set(DISABLE_AT_QT_5_14 "//Disabled since Qt 5.14 ") -else() - set(DISABLE_UNDER_QT_5_14 "//Needs Qt 5.14 ") - set(DISABLE_AT_QT_5_14 "") -endif() # Find all the source qml files FILE(GLOB_RECURSE inFiles RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" diff --git a/src/declarativeimports/calendar/qml/DaysCalendar.qml b/src/declarativeimports/calendar/qml/DaysCalendar.qml index afa83fb10..c86408569 100644 --- a/src/declarativeimports/calendar/qml/DaysCalendar.qml +++ b/src/declarativeimports/calendar/qml/DaysCalendar.qml @@ -244,7 +244,7 @@ Item { Connections { target: theme - onTextColorChanged: { + function onTextColorChanged() { canvas.requestPaint(); } } diff --git a/src/declarativeimports/plasmacomponents/qml/Highlight.qml b/src/declarativeimports/plasmacomponents/qml/Highlight.qml index 5ad43647b..b9ebdb89a 100644 --- a/src/declarativeimports/plasmacomponents/qml/Highlight.qml +++ b/src/declarativeimports/plasmacomponents/qml/Highlight.qml @@ -33,7 +33,7 @@ Item { Connections { target: highlight.ListView.view - onCurrentIndexChanged: { + function onCurrentIndexChanged() { if (highlight.ListView.view.currentIndex >= 0) { background.opacity = 1 } else { diff --git a/src/declarativeimports/plasmacomponents/qml/ScrollBar.qml b/src/declarativeimports/plasmacomponents/qml/ScrollBar.qml index cb5d1a407..e4ea0e8fa 100644 --- a/src/declarativeimports/plasmacomponents/qml/ScrollBar.qml +++ b/src/declarativeimports/plasmacomponents/qml/ScrollBar.qml @@ -116,15 +116,15 @@ Item { Connections { target: flickableItem - onContentHeightChanged: { + function onContentHeightChanged() { range.value = flickableItem.contentY } - onContentYChanged: { + function onContentYChanged() { if (internalLoader.isVertical) { range.value = flickableItem.contentY } } - onContentXChanged: { + function onContentXChanged() { if (!internalLoader.isVertical) { range.value = flickableItem.contentX } @@ -132,8 +132,12 @@ Item { } Connections { target: internalLoader.item.handle - onYChanged: updateFromHandleTimer.running = true - onXChanged: updateFromHandleTimer.running = true + function onYChanged() { + updateFromHandleTimer.running = true + } + function onXChanged() { + updateFromHandleTimer.running = true + } } PlasmaComponents.RangeModel { id: range diff --git a/src/declarativeimports/plasmacomponents/qml/SectionScroller.qml b/src/declarativeimports/plasmacomponents/qml/SectionScroller.qml index 5b7c3143f..dad172498 100644 --- a/src/declarativeimports/plasmacomponents/qml/SectionScroller.qml +++ b/src/declarativeimports/plasmacomponents/qml/SectionScroller.qml @@ -40,7 +40,7 @@ Item { Connections { target: listView - onModelChanged: { + function onModelChanged() { if (listView && listView.model) { internal.initDirtyObserver() } diff --git a/src/declarativeimports/plasmacomponents/qml/TabButton.qml b/src/declarativeimports/plasmacomponents/qml/TabButton.qml index 589bed11d..8eb33cf53 100644 --- a/src/declarativeimports/plasmacomponents/qml/TabButton.qml +++ b/src/declarativeimports/plasmacomponents/qml/TabButton.qml @@ -68,20 +68,24 @@ Item { //long notation to not make it overwritten by implementations Connections { target: (root != undefined) ? root : undefined - onPressedChanged: { + function onPressedChanged() { //TabBar is the granparent internal.tabBar.currentTab = root internal.tabBar.forceActiveFocus() } - onClicked: { + function onClicked() { if (internal.tabGroup) { internal.tabGroup.currentTab = tab } //TabBar is the granparent, done here too in case of no tabgroup internal.tabBar.currentTab = root } - onVisibleChanged: root.parent.childrenChanged() - onTextChanged: root.parent.childrenChanged() + function onVisibleChanged() { + root.parent.childrenChanged() + } + function onTextChanged() { + root.parent.childrenChanged() + } } QtObject { diff --git a/src/declarativeimports/plasmacomponents/qml/ToolBar.qml b/src/declarativeimports/plasmacomponents/qml/ToolBar.qml index 2fb0eb5aa..fa86d05ed 100644 --- a/src/declarativeimports/plasmacomponents/qml/ToolBar.qml +++ b/src/declarativeimports/plasmacomponents/qml/ToolBar.qml @@ -147,7 +147,9 @@ Item{ newContainer.opacity = 1 oldContainer.opacity = 0 } - onToolsChanged: connection.internalToolsChanged() + function onToolsChanged() { + connection.internalToolsChanged() + } Component.onCompleted: connection.internalToolsChanged() } diff --git a/src/declarativeimports/plasmacomponents/qml/private/InlineDialog.qml b/src/declarativeimports/plasmacomponents/qml/private/InlineDialog.qml index 535f6be7b..761c8805e 100644 --- a/src/declarativeimports/plasmacomponents/qml/private/InlineDialog.qml +++ b/src/declarativeimports/plasmacomponents/qml/private/InlineDialog.qml @@ -64,7 +64,7 @@ Item { Connections { target: theme //fallback if inline-background doesn't work - onThemeChanged: { + function onThemeChanged() { fallbackComponent.svgPath = fallbackComponent.filePath("/dialogs/background.svgz") shadowFrame.visible = backgroundSvg.hasElement("shadow-top") } diff --git a/src/declarativeimports/plasmacomponents/qml/private/ScrollDecoratorDelegate.qml b/src/declarativeimports/plasmacomponents/qml/private/ScrollDecoratorDelegate.qml index 2a3b8ad55..298bbf4fe 100644 --- a/src/declarativeimports/plasmacomponents/qml/private/ScrollDecoratorDelegate.qml +++ b/src/declarativeimports/plasmacomponents/qml/private/ScrollDecoratorDelegate.qml @@ -87,7 +87,7 @@ PlasmaCore.FrameSvgItem { Connections { target: flickableItem - onMovingChanged: { + function onMovingChanged() { if (flickableItem.moving) { opacityTimer.running = false background.opacity = 1 diff --git a/src/declarativeimports/plasmacomponents3/Menu.qml b/src/declarativeimports/plasmacomponents3/Menu.qml index 94bbaa4e8..d4804293b 100644 --- a/src/declarativeimports/plasmacomponents3/Menu.qml +++ b/src/declarativeimports/plasmacomponents3/Menu.qml @@ -13,13 +13,13 @@ import org.kde.kirigami 2.5 as Kirigami T.Menu { id: control -@DISABLE_UNDER_QQC2_2_4@ palette: Kirigami.Theme.palette + palette: Kirigami.Theme.palette implicitWidth: Math.max(background ? background.implicitWidth : 0, contentItem ? contentItem.implicitWidth + leftPadding + rightPadding : 0) implicitHeight: Math.max(background ? background.implicitHeight : 0, contentItem ? contentItem.implicitHeight : 0) + topPadding + bottomPadding -@DISABLE_UNDER_QQC2_2_3@ delegate: MenuItem { width: parent.width; onImplicitWidthChanged: control.contentItem.contentItem.childrenChanged() } + delegate: MenuItem { width: parent.width; onImplicitWidthChanged: control.contentItem.contentItem.childrenChanged() } margins: 0 leftPadding: background.margins.left @@ -53,8 +53,7 @@ T.Menu { Connections { target: control.contentItem.contentItem -@DISABLE_AT_QT_5_14@ onChildrenChanged: { -@DISABLE_UNDER_QT_5_14@ function onChildrenChanged() { + function onChildrenChanged() { for (var i in control.contentItem.contentItem.children) { var child = control.contentItem.contentItem.children[i]; if (child.checkable) { diff --git a/src/declarativeimports/plasmacomponents3/MenuItem.qml b/src/declarativeimports/plasmacomponents3/MenuItem.qml index 9ba2f66e2..b42bedff0 100644 --- a/src/declarativeimports/plasmacomponents3/MenuItem.qml +++ b/src/declarativeimports/plasmacomponents3/MenuItem.qml @@ -13,7 +13,7 @@ import org.kde.kirigami 2.5 as Kirigami T.MenuItem { id: controlRoot - @DISABLE_UNDER_QQC2_2_4@ palette: Kirigami.Theme.palette + palette: Kirigami.Theme.palette implicitWidth: Math.max(background ? background.implicitWidth : 0, contentItem.implicitWidth + leftPadding + rightPadding + (arrow ? arrow.implicitWidth : 0)) implicitHeight: Math.max(background ? background.implicitHeight : 0, @@ -69,16 +69,15 @@ T.MenuItem { } } -//we can't use arrow: on old qqc2 releases -@DISABLE_UNDER_QQC2_2_3@ arrow: PlasmaCore.IconItem { -@DISABLE_UNDER_QQC2_2_3@ x: controlRoot.mirrored ? controlRoot.padding : controlRoot.width - width - controlRoot.padding -@DISABLE_UNDER_QQC2_2_3@ y: controlRoot.topPadding + (controlRoot.availableHeight - height) / 2 -@DISABLE_UNDER_QQC2_2_3@ source: controlRoot.mirrored ? "go-next-symbolic-rtl" : "go-next-symbolic" -@DISABLE_UNDER_QQC2_2_3@ status: controlRoot.highlighted ? PlasmaCore.Svg.Selected : PlasmaCore.Svg.Normal -@DISABLE_UNDER_QQC2_2_3@ width: Math.max(label.height, Kirigami.Units.iconSizes.small) -@DISABLE_UNDER_QQC2_2_3@ height: width -@DISABLE_UNDER_QQC2_2_3@ visible: controlRoot.subMenu -@DISABLE_UNDER_QQC2_2_3@ } + arrow: PlasmaCore.IconItem { + x: controlRoot.mirrored ? controlRoot.padding : controlRoot.width - width - controlRoot.padding + y: controlRoot.topPadding + (controlRoot.availableHeight - height) / 2 + source: controlRoot.mirrored ? "go-next-symbolic-rtl" : "go-next-symbolic" + status: controlRoot.highlighted ? PlasmaCore.Svg.Selected : PlasmaCore.Svg.Normal + width: Math.max(label.height, Kirigami.Units.iconSizes.small) + height: width + visible: controlRoot.subMenu + } indicator: Loader { x: controlRoot.mirrored ? controlRoot.width - width - controlRoot.rightPadding : controlRoot.leftPadding diff --git a/src/declarativeimports/plasmastyle/BusyIndicatorStyle.qml b/src/declarativeimports/plasmastyle/BusyIndicatorStyle.qml index 325930f5a..2babe9946 100644 --- a/src/declarativeimports/plasmastyle/BusyIndicatorStyle.qml +++ b/src/declarativeimports/plasmastyle/BusyIndicatorStyle.qml @@ -25,7 +25,7 @@ BusyIndicatorStyle { Connections { target: control - onRunningChanged: { + function onRunningChanged() { rotationAnimator.from = rotation rotationAnimator.to = rotation + 360 } diff --git a/src/declarativeimports/plasmastyle/EditMenuTouch.qml b/src/declarativeimports/plasmastyle/EditMenuTouch.qml index ea4746516..5eda20b16 100644 --- a/src/declarativeimports/plasmastyle/EditMenuTouch.qml +++ b/src/declarativeimports/plasmastyle/EditMenuTouch.qml @@ -85,7 +85,7 @@ Item { Connections { target: mouseArea - onClicked: { + function onClicked(mouse) { if (control.menu && getMenuInstance().__popupVisible) { select(input.cursorPosition, input.cursorPosition); } else { @@ -98,7 +98,7 @@ Item { } popupTimer.restart(); } - onPressAndHold: { + function onPressAndHold(mouse) { input.activate(); var pos = input.positionAt(mouseArea.mouseX, mouseArea.mouseY); input.select(pos, pos); @@ -109,14 +109,14 @@ Item { Connections { target: input - onSelectionStartChanged: popupTimer.restart() - onSelectionEndChanged: popupTimer.restart() - onActiveFocusChanged: popupTimer.restart() + function onSelectionStartChanged() {popupTimer.restart()} + function onSelectionEndChanged() {popupTimer.restart()} + function onActiveFocusChanged() {popupTimer.restart()} } Connections { target: flickable - onMovingChanged: popupTimer.restart() + function onMovingChanged() {popupTimer.restart()} } Timer { diff --git a/src/declarativeimports/plasmastyle/ScrollViewStyle.qml b/src/declarativeimports/plasmastyle/ScrollViewStyle.qml index df66e5d97..4d07c4a95 100644 --- a/src/declarativeimports/plasmastyle/ScrollViewStyle.qml +++ b/src/declarativeimports/plasmastyle/ScrollViewStyle.qml @@ -46,7 +46,9 @@ QtQuickControlStyle.ScrollViewStyle { Component.onCompleted: syncVelocity() Connections { target: control - onContentItemChanged: syncVelocity() + function onContentItemChanged() { + syncVelocity() + } } frame: Item { diff --git a/src/declarativeimports/plasmastyle/ToolButtonStyle.qml b/src/declarativeimports/plasmastyle/ToolButtonStyle.qml index 5f2072b04..b83d34975 100644 --- a/src/declarativeimports/plasmastyle/ToolButtonStyle.qml +++ b/src/declarativeimports/plasmastyle/ToolButtonStyle.qml @@ -195,7 +195,7 @@ QtQuickControlStyle.ButtonStyle { } Connections { target: control - onHoveredChanged: { + function onHoveredChanged() { if (style.controlHovered) { control.z += 2 } else {