Port to FormCard

This is the successor for MobileForm
This commit is contained in:
Carl Schwan 2023-09-13 16:45:15 +02:00 committed by Carl Schwan
parent 07a4b30576
commit 85897fcdc3
5 changed files with 50 additions and 38 deletions

View file

@ -21,6 +21,7 @@ Dependencies:
'frameworks/kpeople': '@stable' 'frameworks/kpeople': '@stable'
'frameworks/kwindowsystem': '@stable' 'frameworks/kwindowsystem': '@stable'
'frameworks/qqc2-desktop-style': '@stable' 'frameworks/qqc2-desktop-style': '@stable'
'libraries/kirigami-addons': '@latest'
- 'on': ['Linux/Qt5', 'FreeBSD/Qt5'] - 'on': ['Linux/Qt5', 'FreeBSD/Qt5']
'require': 'require':
'frameworks/kpackage': '@stable' 'frameworks/kpackage': '@stable'
@ -49,6 +50,7 @@ Dependencies:
'frameworks/kpeople': '@latest-kf6' 'frameworks/kpeople': '@latest-kf6'
'frameworks/kwindowsystem': '@latest-kf6' 'frameworks/kwindowsystem': '@latest-kf6'
'frameworks/qqc2-desktop-style': '@latest-kf6' 'frameworks/qqc2-desktop-style': '@latest-kf6'
'libraries/kirigami-addons': '@latest-kf6'
- 'on': ['Linux/Qt6', 'FreeBSD/Qt6'] - 'on': ['Linux/Qt6', 'FreeBSD/Qt6']
'require': 'require':
'frameworks/kpackage': '@latest-kf6' 'frameworks/kpackage': '@latest-kf6'

View file

@ -66,6 +66,12 @@ set_package_properties(KF${QT_MAJOR_VERSION}Kirigami2 PROPERTIES
TYPE RUNTIME 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) if(UNIX AND NOT APPLE)
option(WITH_X11 "Build with X11 support" ON) option(WITH_X11 "Build with X11 support" ON)
option(WITH_PULSEAUDIO "Build with Pulseaudio support" ON) option(WITH_PULSEAUDIO "Build with Pulseaudio support" ON)

View file

@ -5,22 +5,20 @@ import QtQuick 2.15
import QtQuick.Controls 2.15 import QtQuick.Controls 2.15
import QtQuick.Layouts 1.15 import QtQuick.Layouts 1.15
import org.kde.kirigami 2.20 as Kirigami 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 1.0
import org.kde.kdeconnect.app 1.0 import org.kde.kdeconnect.app 1.0
Kirigami.ScrollablePage { FormCard.FormCardPage {
title: i18nc("@title:window", "Settings") title: i18nc("@title:window", "Settings")
leftPadding: 0 FormCard.FormCard {
rightPadding: 0 Layout.topMargin: Kirigami.Units.gridUnit
ColumnLayout { FormCard.FormTextFieldDelegate {
MobileForm.FormCard { text: announcedNameProperty.value
Layout.topMargin: Kirigami.Units.largeSpacing onAccepted: DaemonDbusInterface.setAnnouncedName(text);
Layout.fillWidth: true label: i18n("Device name")
contentItem: ColumnLayout {
spacing: 0
DBusProperty { DBusProperty {
id: announcedNameProperty id: announcedNameProperty
@ -28,30 +26,30 @@ Kirigami.ScrollablePage {
read: "announcedName" read: "announcedName"
defaultValue: "" defaultValue: ""
} }
MobileForm.FormTextFieldDelegate {
text: announcedNameProperty.value
onAccepted: DaemonDbusInterface.setAnnouncedName(text);
label: i18n("Device name")
}
} }
} }
MobileForm.FormCard { FormCard.FormCard {
Layout.topMargin: Kirigami.Units.largeSpacing Layout.topMargin: Kirigami.Units.gridUnit
Layout.fillWidth: true
contentItem: ColumnLayout { FormCard.FormButtonDelegate {
spacing: 0 text: i18n("About KDE Connect")
onClicked: applicationWindow().pageStack.layers.push(aboutPage)
Component { Component {
id: aboutPage id: aboutPage
MobileForm.AboutPage { FormCard.AboutPage {
aboutData: About 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 {}
} }
} }
} }

View file

@ -101,10 +101,13 @@ int main(int argc, char *argv[])
qmlRegisterSingletonInstance<AppData>("org.kde.kdeconnect.sms", 1, 0, "AppData", &data); qmlRegisterSingletonInstance<AppData>("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; QQmlApplicationEngine engine;
engine.rootContext()->setContextObject(new KLocalizedContext(&engine)); engine.rootContext()->setContextObject(new KLocalizedContext(&engine));
engine.addImageProvider(QStringLiteral("thumbnailsProvider"), new ThumbnailsProvider); engine.addImageProvider(QStringLiteral("thumbnailsProvider"), new ThumbnailsProvider);
engine.rootContext()->setContextProperties({{QStringLiteral("aboutData"), QVariant::fromValue(KAboutData::applicationData())}});
engine.load(QUrl(QStringLiteral("qrc:/qml/main.qml"))); engine.load(QUrl(QStringLiteral("qrc:/qml/main.qml")));
return app.exec(); return app.exec();

View file

@ -10,6 +10,7 @@ import QtQuick 2.1
import org.kde.kirigami 2.6 as Kirigami import org.kde.kirigami 2.6 as Kirigami
import org.kde.kdeconnect 1.0 import org.kde.kdeconnect 1.0
import org.kde.kdeconnect.sms 1.0 import org.kde.kdeconnect.sms 1.0
import org.kde.kirigamiaddons.formcard 1.0 as FormCard
Kirigami.ApplicationWindow Kirigami.ApplicationWindow
{ {
@ -70,7 +71,9 @@ Kirigami.ApplicationWindow
Component { Component {
id: aboutPageComponent id: aboutPageComponent
Kirigami.AboutPage {} FormCard.AboutPage {
aboutData: About
}
} }
globalDrawer: Kirigami.GlobalDrawer { globalDrawer: Kirigami.GlobalDrawer {
@ -96,7 +99,7 @@ Kirigami.ApplicationWindow
icon.name: "help-about" icon.name: "help-about"
onTriggered: { onTriggered: {
if (applicationWindow().pageStack.layers.depth < 2) { if (applicationWindow().pageStack.layers.depth < 2) {
applicationWindow().pageStack.layers.push(aboutPageComponent, { aboutData: aboutData }) applicationWindow().pageStack.layers.push(aboutPageComponent)
} }
} }
} }