From f57d59e605b6a6836dabc6d3908479288282a657 Mon Sep 17 00:00:00 2001 From: Alexander Lohnau Date: Sat, 29 Apr 2023 15:55:49 +0200 Subject: [PATCH] Fix runtime issues with Qt6 To have the code bits reusable, they are defined as cmake variables. In order to make the relative paths work and avoid touching every line from the QRC, the resulting file is put into the source dir. --- .gitignore | 1 + CMakeLists.txt | 12 ++++++++++++ app/CMakeLists.txt | 7 ++++++- app/qml/DevicePage.qml | 14 +++++++------- app/qml/FindDevicesPage.qml | 2 +- app/qml/main.qml | 6 +++--- app/{resources.qrc => resources.qrc.in} | 6 +++--- 7 files changed, 33 insertions(+), 15 deletions(-) rename app/{resources.qrc => resources.qrc.in} (61%) diff --git a/.gitignore b/.gitignore index 9769e9ee2..17f1d3b31 100644 --- a/.gitignore +++ b/.gitignore @@ -33,3 +33,4 @@ CMakeLists.txt.user .idea /cmake-build* .clang-format +app/resources.generated.qrc diff --git a/CMakeLists.txt b/CMakeLists.txt index 9ec132e1e..8a1e19f97 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -42,6 +42,18 @@ ecm_setup_version(${RELEASE_SERVICE_VERSION} VERSION_HEADER ${CMAKE_CURRENT_BINARY_DIR}/kdeconnect-version.h ) +if(QT_MAJOR_VERSION STREQUAL "6") + set(KIRIGAMI_ICON "icon.name") + set(KIRIGAMI_PAGE_ACTIONS "actions") + set(QTQUICK_FILEDIALOG_FOLDER "currentFolder") +else() + set(QTQUICK_DIALOGS_IMPORT_VERSION 1.0) + set(KIRIGAMI_ICON "icon") + set(KIRIGAMI_PAGE_ACTIONS "contextualActions") + set(QTQUICK_FILEDIALOG_FOLDER "folder") +endif() + + # Make the version header available by linking against kdeconnectversion add_library(kdeconnectversion INTERFACE) target_include_directories(kdeconnectversion INTERFACE ${CMAKE_CURRENT_BINARY_DIR}) diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt index c34279603..76f936434 100644 --- a/app/CMakeLists.txt +++ b/app/CMakeLists.txt @@ -1,4 +1,9 @@ -qt_add_resources(kdeconnect_SRCS resources.qrc) +configure_file(qml/main.qml ${CMAKE_CURRENT_BINARY_DIR}/qml/main.qml) +configure_file(qml/DevicePage.qml ${CMAKE_CURRENT_BINARY_DIR}/qml/DevicePage.qml) +configure_file(qml/FindDevicesPage.qml ${CMAKE_CURRENT_BINARY_DIR}/qml/FindDevicesPage.qml) +configure_file(resources.qrc.in ${CMAKE_CURRENT_SOURCE_DIR}/resources.generated.qrc) + +qt_add_resources(kdeconnect_SRCS resources.generated.qrc) qt_add_resources(kdeconnect_custom_icons_SRCS ${CMAKE_SOURCE_DIR}/icons/custom_icons.qrc) diff --git a/app/qml/DevicePage.qml b/app/qml/DevicePage.qml index f7e796852..c43ad708c 100644 --- a/app/qml/DevicePage.qml +++ b/app/qml/DevicePage.qml @@ -7,7 +7,7 @@ import QtQuick 2.15 import QtQuick.Controls 2.15 as QQC2 import QtQuick.Layouts 1.15 -import QtQuick.Dialogs 1.0 +import QtQuick.Dialogs @QTQUICK_DIALOGS_IMPORT_VERSION@ import org.kde.kirigami 2.20 as Kirigami import org.kde.kdeconnect 1.0 @@ -16,15 +16,15 @@ Kirigami.ScrollablePage { property QtObject currentDevice title: currentDevice.name - actions.contextualActions: [ + @KIRIGAMI_PAGE_ACTIONS@: [ Kirigami.Action { - iconName:"network-disconnect" + icon.name: "network-disconnect" onTriggered: root.currentDevice.unpair() text: i18nd("kdeconnect-app", "Unpair") visible: root.currentDevice.isPaired }, Kirigami.Action { - iconName:"hands-free" + icon.name: "hands-free" text: i18nd("kdeconnect-app", "Send Ping") visible: root.currentDevice.isPaired && root.currentDevice.isReachable onTriggered: { @@ -32,7 +32,7 @@ Kirigami.ScrollablePage { } }, Kirigami.Action { - iconName: "settings-configure" + icon.name: "settings-configure" text: i18n("Plugin Settings") visible: root.currentDevice.isPaired && root.currentDevice.isReachable onTriggered: { @@ -48,7 +48,7 @@ Kirigami.ScrollablePage { model: plugins delegate: Kirigami.BasicListItem { label: name - icon: iconName + @KIRIGAMI_ICON@: iconName highlighted: false iconColor: "transparent" visible: loaded @@ -171,7 +171,7 @@ Kirigami.ScrollablePage { id: fileDialog readonly property var shareIface: root.currentDevice ? ShareDbusInterfaceFactory.create(root.currentDevice.id()) : null title: i18nd("kdeconnect-app", "Please choose a file") - folder: shortcuts.home + @QTQUICK_FILEDIALOG_FOLDER@: shortcuts.home onAccepted: shareIface.shareUrl(fileDialog.fileUrl) } } diff --git a/app/qml/FindDevicesPage.qml b/app/qml/FindDevicesPage.qml index 018d07401..62dbf2655 100644 --- a/app/qml/FindDevicesPage.qml +++ b/app/qml/FindDevicesPage.qml @@ -61,7 +61,7 @@ Kirigami.ScrollablePage sourceModel: DevicesModel {} } delegate: Kirigami.BasicListItem { - icon: iconName + @KIRIGAMI_ICON@: iconName iconColor: "transparent" label: model.name subtitle: toolTip diff --git a/app/qml/main.qml b/app/qml/main.qml index 442b55ba3..05eac8aab 100644 --- a/app/qml/main.qml +++ b/app/qml/main.qml @@ -74,7 +74,7 @@ Kirigami.ApplicationWindow { Kirigami.BasicListItem { id: findDevicesAction text: i18nd("kdeconnect-app", "Find devices...") - icon: "list-add" + @KIRIGAMI_ICON@: "list-add" checked: pageStack.currentItem && pageStack.currentItem.objectName == "FindDevices" Layout.fillWidth: true @@ -100,7 +100,7 @@ Kirigami.ApplicationWindow { text: model.name + "\n" + toolTip enabled: status & DevicesModel.Reachable checked: pageStack.currentItem && pageStack.currentItem.currentDevice == device - icon: model.iconName + @KIRIGAMI_ICON@: model.iconName iconColor: "transparent" onClicked: { root.pageStack.clear() @@ -119,7 +119,7 @@ Kirigami.ApplicationWindow { Kirigami.BasicListItem { text: i18n("Settings") - icon: "settings-configure" + @KIRIGAMI_ICON@: "settings-configure" onClicked: pageStack.pushDialogLayer('qrc:/qml/Settings.qml', {}, { title: i18n("Settings"), }); diff --git a/app/resources.qrc b/app/resources.qrc.in similarity index 61% rename from app/resources.qrc rename to app/resources.qrc.in index 5fd968a08..2761215b4 100644 --- a/app/resources.qrc +++ b/app/resources.qrc.in @@ -1,13 +1,13 @@ - qml/main.qml + @CMAKE_CURRENT_BINARY_DIR@/qml/main.qml qml/mpris.qml qml/mousepad.qml qml/presentationRemote.qml qml/PluginItem.qml - qml/DevicePage.qml - qml/FindDevicesPage.qml + @CMAKE_CURRENT_BINARY_DIR@/qml/DevicePage.qml + @CMAKE_CURRENT_BINARY_DIR@/qml/FindDevicesPage.qml qml/runcommand.qml qml/volume.qml qml/MprisSlider.qml