From d8f3146de5e9c74a9b7ec2b2479f7949b48fc3ed Mon Sep 17 00:00:00 2001 From: Carl Schwan Date: Thu, 21 Sep 2023 21:02:47 +0200 Subject: [PATCH] initialstart: Port to FormCard --- .../indicators/InternetIndicator.qml | 13 +- initialstart/main.cpp | 8 +- .../cellular/package/contents/ui/main.qml | 113 ++++++++---------- .../prepare/package/contents/ui/main.qml | 77 +++++------- .../modules/time/package/contents/ui/main.qml | 93 +++++++------- .../contents/ui/ConnectionItemDelegate.qml | 4 +- .../modules/wifi/package/contents/ui/main.qml | 64 +++++----- 7 files changed, 167 insertions(+), 205 deletions(-) diff --git a/components/mobileshell/qml/statusbar/indicators/InternetIndicator.qml b/components/mobileshell/qml/statusbar/indicators/InternetIndicator.qml index 7883048a..2d058f1b 100644 --- a/components/mobileshell/qml/statusbar/indicators/InternetIndicator.qml +++ b/components/mobileshell/qml/statusbar/indicators/InternetIndicator.qml @@ -8,18 +8,18 @@ import QtQuick import QtQuick.Layouts -import org.kde.plasma.components 3.0 as PlasmaComponents +import QtQuick.Controls as QQC2 import org.kde.plasma.networkmanagement 0.2 as PlasmaNM import org.kde.kirigami as Kirigami Kirigami.Icon { id: connectionIcon - + // data - + readonly property string icon: connectionIconProvider.connectionIcon readonly property bool indicatorRunning: connectionIconProvider.connecting - + readonly property var networkStatus: PlasmaNM.NetworkStatus { id: networkStatus } @@ -35,12 +35,11 @@ Kirigami.Icon { readonly property var connectionIcon: PlasmaNM.ConnectionIcon { id: connectionIconProvider } - + // implementation - source: icon - PlasmaComponents.BusyIndicator { + QQC2.BusyIndicator { id: connectingIndicator anchors.fill: parent diff --git a/initialstart/main.cpp b/initialstart/main.cpp index eabdbbe2..b474f46e 100644 --- a/initialstart/main.cpp +++ b/initialstart/main.cpp @@ -53,10 +53,10 @@ int main(int argc, char *argv[]) aboutData.addAuthor(i18n("Devin Lin"), QString(), QStringLiteral("devin@kde.org")); KAboutData::setApplicationData(aboutData); - QQmlApplicationEngine *engine = new QQmlApplicationEngine; - engine->rootContext()->setContextObject(new KLocalizedContext{engine}); + QQmlApplicationEngine engine; + engine.rootContext()->setContextObject(new KLocalizedContext{&engine}); - Wizard *wizard = new Wizard{nullptr, engine}; + Wizard *wizard = new Wizard{nullptr, &engine}; wizard->setTestingMode(testWizard); wizard->load(); @@ -64,7 +64,7 @@ int main(int argc, char *argv[]) return wizard; }); - engine->load(QUrl(QStringLiteral("qrc:/qml/main.qml"))); + engine.load(QUrl(QStringLiteral("qrc:/qml/main.qml"))); app.setWindowIcon(QIcon::fromTheme(QStringLiteral("start-here-symbolic"))); diff --git a/initialstart/modules/cellular/package/contents/ui/main.qml b/initialstart/modules/cellular/package/contents/ui/main.qml index c7ddbad8..ea174e61 100644 --- a/initialstart/modules/cellular/package/contents/ui/main.qml +++ b/initialstart/modules/cellular/package/contents/ui/main.qml @@ -1,13 +1,13 @@ // SPDX-FileCopyrightText: 2023 Devin Lin // SPDX-License-Identifier: GPL-2.0-or-later -import QtQuick 2.15 -import QtQuick.Controls 2.15 -import QtQuick.Layouts 1.15 +import QtQuick +import QtQuick.Controls +import QtQuick.Layouts -import org.kde.kirigami 2.20 as Kirigami -import org.kde.kirigamiaddons.labs.mobileform 0.1 as MobileForm -import org.kde.plasma.mm 1.0 as PlasmaMM +import org.kde.kirigami as Kirigami +import org.kde.kirigamiaddons.formcard 1 as FormCard +import org.kde.plasma.mm 1 as PlasmaMM Item { id: root @@ -61,92 +61,79 @@ Item { } } - MobileForm.FormCard { + FormCard.FormCard { visible: PlasmaMM.SignalIndicator.modemAvailable && PlasmaMM.SignalIndicator.mobileDataSupported maximumWidth: root.cardWidth Layout.alignment: Qt.AlignTop | Qt.AlignHCenter - Layout.fillWidth: true - contentItem: ColumnLayout { - spacing: 0 - - MobileForm.FormSwitchDelegate { - Layout.fillWidth: true - text: i18n("Mobile Data") - checked: PlasmaMM.SignalIndicator.mobileDataEnabled - onCheckedChanged: { - if (checked !== PlasmaMM.SignalIndicator.mobileDataEnabled) { - root.toggleMobileData(); - } + FormCard.FormSwitchDelegate { + text: i18n("Mobile Data") + checked: PlasmaMM.SignalIndicator.mobileDataEnabled + onCheckedChanged: { + if (checked !== PlasmaMM.SignalIndicator.mobileDataEnabled) { + root.toggleMobileData(); } } } } - MobileForm.FormCard { + FormCard.FormCard { visible: PlasmaMM.SignalIndicator.modemAvailable && !PlasmaMM.SignalIndicator.simEmpty maximumWidth: root.cardWidth Layout.fillHeight: true Layout.alignment: Qt.AlignTop | Qt.AlignHCenter - Layout.fillWidth: true - contentItem: ColumnLayout { - spacing: 0 + ListView { + id: listView + currentIndex: -1 + clip: true - ListView { - id: listView - currentIndex: -1 - clip: true + Layout.fillWidth: true + Layout.fillHeight: true - Layout.fillWidth: true - Layout.fillHeight: true + model: PlasmaMM.SignalIndicator.profiles - model: PlasmaMM.SignalIndicator.profiles + delegate: FormCard.FormRadioDelegate { + width: listView.width + text: modelData.name + description: modelData.apn + checked: modem.activeConnectionUni == modelData.connectionUni - delegate: MobileForm.FormRadioDelegate { - width: listView.width - text: modelData.name - description: modelData.apn - checked: modem.activeConnectionUni == modelData.connectionUni + onCheckedChanged: { + if (checked) { + PlasmaMM.SignalIndicator.activateProfile(modelData.connectionUni); + checked = Qt.binding(() => { return modem.activeConnectionUni == modelData.connectionUni }); + } + } - onCheckedChanged: { - if (checked) { - PlasmaMM.SignalIndicator.activateProfile(modelData.connectionUni); - checked = Qt.binding(() => { return modem.activeConnectionUni == modelData.connectionUni }); + trailing: RowLayout { + ToolButton { + icon.name: "entry-edit" + text: i18n("Edit") + onClicked: { + profileDialog.profile = modelData; + profileDialog.open(); } } - - trailing: RowLayout { - ToolButton { - icon.name: "entry-edit" - text: i18n("Edit") - onClicked: { - profileDialog.profile = modelData; - profileDialog.open(); - } - } - ToolButton { - icon.name: "delete" - text: i18n("Delete") - onClicked: PlasmaMM.SignalIndicator.removeProfile(modelData.connectionUni) - } + ToolButton { + icon.name: "delete" + text: i18n("Delete") + onClicked: PlasmaMM.SignalIndicator.removeProfile(modelData.connectionUni) } } } + } - MobileForm.FormButtonDelegate { - icon.name: "list-add" - text: i18n("Add APN") - onClicked: { - profileDialog.profile = null; - profileDialog.open(); - } + FormCard.FormButtonDelegate { + icon.name: "list-add" + text: i18n("Add APN") + onClicked: { + profileDialog.profile = null; + profileDialog.open(); } } } } } - - diff --git a/initialstart/modules/prepare/package/contents/ui/main.qml b/initialstart/modules/prepare/package/contents/ui/main.qml index be8aeaf8..40d117da 100644 --- a/initialstart/modules/prepare/package/contents/ui/main.qml +++ b/initialstart/modules/prepare/package/contents/ui/main.qml @@ -6,7 +6,7 @@ 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.plasma.mobileinitialstart.prepare 1.0 as Prepare import org.kde.plasma.plasma5support 2.0 as P5Support @@ -82,43 +82,36 @@ Item { text: i18n("Adjust the screen brightness to be comfortable for the installation process.") } - MobileForm.FormCard { + FormCard.FormCard { maximumWidth: root.cardWidth Layout.alignment: Qt.AlignTop | Qt.AlignHCenter - Layout.fillWidth: true - contentItem: ColumnLayout { - spacing: 0 + FormCard.AbstractFormDelegate { + background: null - MobileForm.AbstractFormDelegate { - Layout.fillWidth: true + contentItem: RowLayout { + spacing: Kirigami.Units.gridUnit - background: Item {} + Kirigami.Icon { + implicitWidth: Kirigami.Units.iconSizes.smallMedium + implicitHeight: Kirigami.Units.iconSizes.smallMedium + source: "brightness-low" + } - contentItem: RowLayout { - spacing: Kirigami.Units.gridUnit + Slider { + id: brightnessSlider + Layout.fillWidth: true + from: 1 + to: root.maximumScreenBrightness + value: root.screenBrightness + onMoved: root.screenBrightness = value; + } - Kirigami.Icon { - implicitWidth: Kirigami.Units.iconSizes.smallMedium - implicitHeight: Kirigami.Units.iconSizes.smallMedium - source: "brightness-low" - } - - Slider { - id: brightnessSlider - Layout.fillWidth: true - from: 1 - to: root.maximumScreenBrightness - value: root.screenBrightness - onMoved: root.screenBrightness = value; - } - - Kirigami.Icon { - implicitWidth: Kirigami.Units.iconSizes.smallMedium - implicitHeight: Kirigami.Units.iconSizes.smallMedium - source: "brightness-high" - } + Kirigami.Icon { + implicitWidth: Kirigami.Units.iconSizes.smallMedium + implicitHeight: Kirigami.Units.iconSizes.smallMedium + source: "brightness-high" } } } @@ -135,26 +128,20 @@ Item { text: i18n("Adjust the size of elements on the screen.") } - MobileForm.FormCard { + FormCard.FormCard { maximumWidth: root.cardWidth Layout.alignment: Qt.AlignTop | Qt.AlignHCenter - Layout.fillWidth: true - contentItem: ColumnLayout { - spacing: 0 + FormCard.FormComboBoxDelegate { + id: displayScaling + text: i18n("Display Scaling") + displayMode: FormCard.FormComboBoxDelegate.Dialog + currentIndex: Prepare.PrepareUtil.scalingOptions.indexOf(Prepare.PrepareUtil.scaling.toString() + "%"); + model: Prepare.PrepareUtil.scalingOptions - MobileForm.FormComboBoxDelegate { - id: displayScaling - Layout.fillWidth: true - text: i18n("Display Scaling") - displayMode: MobileForm.FormComboBoxDelegate.Dialog - currentIndex: Prepare.PrepareUtil.scalingOptions.indexOf(Prepare.PrepareUtil.scaling.toString() + "%"); - model: Prepare.PrepareUtil.scalingOptions - - // remove % suffix - onCurrentValueChanged: Prepare.PrepareUtil.scaling = parseInt(currentValue.substring(0, currentValue.length - 1)); - } + // remove % suffix + onCurrentValueChanged: Prepare.PrepareUtil.scaling = parseInt(currentValue.substring(0, currentValue.length - 1)); } } } diff --git a/initialstart/modules/time/package/contents/ui/main.qml b/initialstart/modules/time/package/contents/ui/main.qml index 05a3f752..ef1fbca5 100644 --- a/initialstart/modules/time/package/contents/ui/main.qml +++ b/initialstart/modules/time/package/contents/ui/main.qml @@ -6,7 +6,7 @@ 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.plasma.mobileinitialstart.time 1.0 as Time Item { @@ -36,80 +36,73 @@ Item { text: i18n("Select your time zone and preferred time format.") } - MobileForm.FormCard { + FormCard.FormCard { maximumWidth: root.cardWidth Layout.alignment: Qt.AlignTop | Qt.AlignHCenter Layout.fillWidth: true - contentItem: ColumnLayout { - spacing: 0 - - MobileForm.FormSwitchDelegate { - Layout.fillWidth: true - text: i18n("24-Hour Format") - checked: Time.TimeUtil.is24HourTime - onCheckedChanged: { - if (checked !== Time.TimeUtil.is24HourTime) { - Time.TimeUtil.is24HourTime = checked; - } + FormCard.FormSwitchDelegate { + Layout.fillWidth: true + text: i18n("24-Hour Format") + checked: Time.TimeUtil.is24HourTime + onCheckedChanged: { + if (checked !== Time.TimeUtil.is24HourTime) { + Time.TimeUtil.is24HourTime = checked; } } } } - MobileForm.FormCard { + FormCard.FormCard { maximumWidth: root.cardWidth Layout.fillHeight: true Layout.alignment: Qt.AlignTop | Qt.AlignHCenter Layout.fillWidth: true - contentItem: ColumnLayout { - spacing: 0 + ListView { + id: listView - ListView { - clip: true - id: listView - Layout.fillWidth: true - Layout.fillHeight: true - model: Time.TimeUtil.timeZones + clip: true + Layout.fillWidth: true + Layout.fillHeight: true + model: Time.TimeUtil.timeZones - header: Control { - width: listView.width - leftPadding: Kirigami.Units.gridUnit - rightPadding: Kirigami.Units.gridUnit - topPadding: Kirigami.Units.gridUnit - bottomPadding: Kirigami.Units.gridUnit + header: Control { + width: listView.width + leftPadding: Kirigami.Units.gridUnit + rightPadding: Kirigami.Units.gridUnit + topPadding: Kirigami.Units.gridUnit + bottomPadding: Kirigami.Units.gridUnit - contentItem: Kirigami.SearchField { - id: searchField + contentItem: Kirigami.SearchField { + id: searchField - onTextChanged: { - Time.TimeUtil.timeZones.filterString = text; - // HACK: search field seems to lose focus every time the text changes - focusTimer.restart(); - } + onTextChanged: { + Time.TimeUtil.timeZones.filterString = text; + // HACK: search field seems to lose focus every time the text changes + focusTimer.restart(); + } - Timer { - id: focusTimer - interval: 1 - onTriggered: searchField.forceActiveFocus() - } + Timer { + id: focusTimer + interval: 1 + onTriggered: searchField.forceActiveFocus() } } + } - delegate: MobileForm.FormRadioDelegate { - required property string timeZoneId + delegate: FormCard.FormRadioDelegate { + required property string timeZoneId - width: ListView.view.width - text: timeZoneId - checked: Time.TimeUtil.currentTimeZone === timeZoneId - onCheckedChanged: { - if (checked && timeZoneId !== Time.TimeUtil.currentTimeZone) { - Time.TimeUtil.currentTimeZone = model.timeZoneId; - checked = Qt.binding(() => Time.TimeUtil.currentTimeZone === timeZoneId); - } + width: ListView.view.width + text: timeZoneId + checked: Time.TimeUtil.currentTimeZone === timeZoneId + onCheckedChanged: { + if (checked && timeZoneId !== Time.TimeUtil.currentTimeZone) { + Time.TimeUtil.currentTimeZone = model.timeZoneId; + checked = Qt.binding(() => Time.TimeUtil.currentTimeZone === timeZoneId); } } } diff --git a/initialstart/modules/wifi/package/contents/ui/ConnectionItemDelegate.qml b/initialstart/modules/wifi/package/contents/ui/ConnectionItemDelegate.qml index f8a3b9ad..ad847f92 100644 --- a/initialstart/modules/wifi/package/contents/ui/ConnectionItemDelegate.qml +++ b/initialstart/modules/wifi/package/contents/ui/ConnectionItemDelegate.qml @@ -8,10 +8,10 @@ import QtQuick.Controls 2.15 as Controls import org.kde.plasma.networkmanagement 0.2 as PlasmaNM import org.kde.kirigami 2.2 as Kirigami -import org.kde.kirigamiaddons.labs.mobileform 0.1 as MobileForm +import org.kde.kirigamiaddons.formcard 1.0 as FormCard import org.kde.ksvg 1.0 as KSvg -MobileForm.AbstractFormDelegate { +FormCard.AbstractFormDelegate { topPadding: Kirigami.Units.smallSpacing bottomPadding: Kirigami.Units.smallSpacing diff --git a/initialstart/modules/wifi/package/contents/ui/main.qml b/initialstart/modules/wifi/package/contents/ui/main.qml index 7ae6af64..9fd4a0f1 100644 --- a/initialstart/modules/wifi/package/contents/ui/main.qml +++ b/initialstart/modules/wifi/package/contents/ui/main.qml @@ -2,12 +2,12 @@ // SPDX-FileCopyrightText: 2023 Devin Lin // SPDX-License-Identifier: GPL-2.0-or-later -import QtQuick 2.15 -import QtQuick.Controls 2.15 -import QtQuick.Layouts 1.15 +import QtQuick +import QtQuick.Controls +import QtQuick.Layouts 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.plasma.networkmanagement 0.2 as PlasmaNM import org.kde.plasma.mobileinitialstart.wifi 1.0 as WiFi @@ -68,46 +68,42 @@ Item { text: i18n("Connect to a WiFi network for network access.") } - MobileForm.FormCard { + FormCard.FormCard { maximumWidth: root.cardWidth Layout.fillHeight: true Layout.alignment: Qt.AlignTop | Qt.AlignHCenter Layout.fillWidth: true - contentItem: ColumnLayout { - spacing: 0 + ListView { + id: listView + currentIndex: -1 + clip: true + Layout.fillWidth: true + Layout.fillHeight: true - ListView { - id: listView - currentIndex: -1 - clip: true - Layout.fillWidth: true - Layout.fillHeight: true + section.property: "Section" + section.delegate: Kirigami.ListSectionHeader { + text: section + } - section.property: "Section" - section.delegate: Kirigami.ListSectionHeader { - text: section + model: mobileProxyModel + + Kirigami.PlaceholderMessage { + anchors.centerIn: parent + width: parent.width - (Kirigami.Units.gridUnit * 4) + visible: !enabledConnections.wirelessEnabled + text: i18n("Wi-Fi is disabled") + icon.name: "network-wireless-disconnected" + helpfulAction: Kirigami.Action { + icon.name: "network-wireless-connected" + text: i18n("Enable") + onTriggered: handler.enableWireless(true) } + } - model: mobileProxyModel - - Kirigami.PlaceholderMessage { - anchors.centerIn: parent - width: parent.width - (Kirigami.Units.gridUnit * 4) - visible: !enabledConnections.wirelessEnabled - text: i18n("Wi-Fi is disabled") - icon.name: "network-wireless-disconnected" - helpfulAction: Kirigami.Action { - icon.name: "network-wireless-connected" - text: i18n("Enable") - onTriggered: handler.enableWireless(true) - } - } - - delegate: ConnectionItemDelegate { - width: listView.width - } + delegate: ConnectionItemDelegate { + width: listView.width } } }