From 85897fcdc3018c1a473648ec857ad44b3d376216 Mon Sep 17 00:00:00 2001 From: Carl Schwan Date: Wed, 13 Sep 2023 16:45:15 +0200 Subject: [PATCH] Port to FormCard This is the successor for MobileForm --- .kde-ci.yml | 2 ++ CMakeLists.txt | 6 ++++ app/qml/Settings.qml | 68 +++++++++++++++++++++----------------------- smsapp/main.cpp | 5 +++- smsapp/qml/main.qml | 7 +++-- 5 files changed, 50 insertions(+), 38 deletions(-) diff --git a/.kde-ci.yml b/.kde-ci.yml index 7337e690e..83c467445 100644 --- a/.kde-ci.yml +++ b/.kde-ci.yml @@ -21,6 +21,7 @@ Dependencies: 'frameworks/kpeople': '@stable' 'frameworks/kwindowsystem': '@stable' 'frameworks/qqc2-desktop-style': '@stable' + 'libraries/kirigami-addons': '@latest' - 'on': ['Linux/Qt5', 'FreeBSD/Qt5'] 'require': 'frameworks/kpackage': '@stable' @@ -49,6 +50,7 @@ Dependencies: 'frameworks/kpeople': '@latest-kf6' 'frameworks/kwindowsystem': '@latest-kf6' 'frameworks/qqc2-desktop-style': '@latest-kf6' + 'libraries/kirigami-addons': '@latest-kf6' - 'on': ['Linux/Qt6', 'FreeBSD/Qt6'] 'require': 'frameworks/kpackage': '@latest-kf6' diff --git a/CMakeLists.txt b/CMakeLists.txt index 69a4402f2..27e989075 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -66,6 +66,12 @@ set_package_properties(KF${QT_MAJOR_VERSION}Kirigami2 PROPERTIES TYPE RUNTIME ) +find_package(KF${QT_MAJOR_VERSION}KirigamiAddons 0.11 REQUIRED) +set_package_properties(KF${QT_MAJOR_VERSION}KirigamiAddons PROPERTIES + TYPE REQUIRED + PURPOSE "Required runtime dependency (all the modules are required)" +) + if(UNIX AND NOT APPLE) option(WITH_X11 "Build with X11 support" ON) option(WITH_PULSEAUDIO "Build with Pulseaudio support" ON) diff --git a/app/qml/Settings.qml b/app/qml/Settings.qml index 713eeb5dd..3f9bd3c70 100644 --- a/app/qml/Settings.qml +++ b/app/qml/Settings.qml @@ -5,53 +5,51 @@ import QtQuick 2.15 import QtQuick.Controls 2.15 import QtQuick.Layouts 1.15 import org.kde.kirigami 2.20 as Kirigami -import org.kde.kirigamiaddons.labs.mobileform 0.1 as MobileForm +import org.kde.kirigamiaddons.formcard 1.0 as FormCard import org.kde.kdeconnect 1.0 import org.kde.kdeconnect.app 1.0 -Kirigami.ScrollablePage { +FormCard.FormCardPage { title: i18nc("@title:window", "Settings") - leftPadding: 0 - rightPadding: 0 + FormCard.FormCard { + Layout.topMargin: Kirigami.Units.gridUnit - ColumnLayout { - MobileForm.FormCard { - Layout.topMargin: Kirigami.Units.largeSpacing - Layout.fillWidth: true - contentItem: ColumnLayout { - spacing: 0 + FormCard.FormTextFieldDelegate { + text: announcedNameProperty.value + onAccepted: DaemonDbusInterface.setAnnouncedName(text); + label: i18n("Device name") - DBusProperty { - id: announcedNameProperty - object: DaemonDbusInterface - read: "announcedName" - defaultValue: "" - } + DBusProperty { + id: announcedNameProperty + object: DaemonDbusInterface + read: "announcedName" + defaultValue: "" + } + } + } - MobileForm.FormTextFieldDelegate { - text: announcedNameProperty.value - onAccepted: DaemonDbusInterface.setAnnouncedName(text); - label: i18n("Device name") + FormCard.FormCard { + Layout.topMargin: Kirigami.Units.gridUnit + + FormCard.FormButtonDelegate { + text: i18n("About KDE Connect") + onClicked: applicationWindow().pageStack.layers.push(aboutPage) + Component { + id: aboutPage + FormCard.AboutPage { + aboutData: About } } } - MobileForm.FormCard { - Layout.topMargin: Kirigami.Units.largeSpacing - Layout.fillWidth: true - contentItem: ColumnLayout { - spacing: 0 - Component { - id: aboutPage - MobileForm.AboutPage { - aboutData: About - } - } - MobileForm.FormButtonDelegate { - text: i18n("About KDE Connect") - onClicked: applicationWindow().pageStack.layers.push(aboutPage) - } + FormCard.FormButtonDelegate { + text: i18n("About KDE") + onClicked: applicationWindow().pageStack.layers.push(aboutKDE) + + Component { + id: aboutKDE + FormCard.AboutKDE {} } } } diff --git a/smsapp/main.cpp b/smsapp/main.cpp index d8c3c8a3b..312dc1bb4 100644 --- a/smsapp/main.cpp +++ b/smsapp/main.cpp @@ -101,10 +101,13 @@ int main(int argc, char *argv[]) qmlRegisterSingletonInstance("org.kde.kdeconnect.sms", 1, 0, "AppData", &data); + qmlRegisterSingletonType("org.kde.kdeconnect.sms", 1, 0, "About", [](QQmlEngine *engine, QJSEngine *) -> QJSValue { + return engine->toScriptValue(KAboutData::applicationData()); + }); + QQmlApplicationEngine engine; engine.rootContext()->setContextObject(new KLocalizedContext(&engine)); engine.addImageProvider(QStringLiteral("thumbnailsProvider"), new ThumbnailsProvider); - engine.rootContext()->setContextProperties({{QStringLiteral("aboutData"), QVariant::fromValue(KAboutData::applicationData())}}); engine.load(QUrl(QStringLiteral("qrc:/qml/main.qml"))); return app.exec(); diff --git a/smsapp/qml/main.qml b/smsapp/qml/main.qml index d8d192c38..3fea71b2a 100644 --- a/smsapp/qml/main.qml +++ b/smsapp/qml/main.qml @@ -10,6 +10,7 @@ import QtQuick 2.1 import org.kde.kirigami 2.6 as Kirigami import org.kde.kdeconnect 1.0 import org.kde.kdeconnect.sms 1.0 +import org.kde.kirigamiaddons.formcard 1.0 as FormCard Kirigami.ApplicationWindow { @@ -70,7 +71,9 @@ Kirigami.ApplicationWindow Component { id: aboutPageComponent - Kirigami.AboutPage {} + FormCard.AboutPage { + aboutData: About + } } globalDrawer: Kirigami.GlobalDrawer { @@ -96,7 +99,7 @@ Kirigami.ApplicationWindow icon.name: "help-about" onTriggered: { if (applicationWindow().pageStack.layers.depth < 2) { - applicationWindow().pageStack.layers.push(aboutPageComponent, { aboutData: aboutData }) + applicationWindow().pageStack.layers.push(aboutPageComponent) } } }