initialstart: Port to FormCard

This commit is contained in:
Carl Schwan 2023-09-21 21:02:47 +02:00
parent c039bcef86
commit d8f3146de5
No known key found for this signature in database
GPG key ID: 02325448204E452A
7 changed files with 167 additions and 205 deletions

View file

@ -8,7 +8,7 @@
import QtQuick import QtQuick
import QtQuick.Layouts 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.plasma.networkmanagement 0.2 as PlasmaNM
import org.kde.kirigami as Kirigami import org.kde.kirigami as Kirigami
@ -37,10 +37,9 @@ Kirigami.Icon {
} }
// implementation // implementation
source: icon source: icon
PlasmaComponents.BusyIndicator { QQC2.BusyIndicator {
id: connectingIndicator id: connectingIndicator
anchors.fill: parent anchors.fill: parent

View file

@ -53,10 +53,10 @@ int main(int argc, char *argv[])
aboutData.addAuthor(i18n("Devin Lin"), QString(), QStringLiteral("devin@kde.org")); aboutData.addAuthor(i18n("Devin Lin"), QString(), QStringLiteral("devin@kde.org"));
KAboutData::setApplicationData(aboutData); KAboutData::setApplicationData(aboutData);
QQmlApplicationEngine *engine = new QQmlApplicationEngine; QQmlApplicationEngine engine;
engine->rootContext()->setContextObject(new KLocalizedContext{engine}); engine.rootContext()->setContextObject(new KLocalizedContext{&engine});
Wizard *wizard = new Wizard{nullptr, engine}; Wizard *wizard = new Wizard{nullptr, &engine};
wizard->setTestingMode(testWizard); wizard->setTestingMode(testWizard);
wizard->load(); wizard->load();
@ -64,7 +64,7 @@ int main(int argc, char *argv[])
return wizard; 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"))); app.setWindowIcon(QIcon::fromTheme(QStringLiteral("start-here-symbolic")));

View file

@ -1,13 +1,13 @@
// SPDX-FileCopyrightText: 2023 Devin Lin <devin@kde.org> // SPDX-FileCopyrightText: 2023 Devin Lin <devin@kde.org>
// SPDX-License-Identifier: GPL-2.0-or-later // SPDX-License-Identifier: GPL-2.0-or-later
import QtQuick 2.15 import QtQuick
import QtQuick.Controls 2.15 import QtQuick.Controls
import QtQuick.Layouts 1.15 import QtQuick.Layouts
import org.kde.kirigami 2.20 as Kirigami import org.kde.kirigami as Kirigami
import org.kde.kirigamiaddons.labs.mobileform 0.1 as MobileForm import org.kde.kirigamiaddons.formcard 1 as FormCard
import org.kde.plasma.mm 1.0 as PlasmaMM import org.kde.plasma.mm 1 as PlasmaMM
Item { Item {
id: root id: root
@ -61,92 +61,79 @@ Item {
} }
} }
MobileForm.FormCard { FormCard.FormCard {
visible: PlasmaMM.SignalIndicator.modemAvailable && PlasmaMM.SignalIndicator.mobileDataSupported visible: PlasmaMM.SignalIndicator.modemAvailable && PlasmaMM.SignalIndicator.mobileDataSupported
maximumWidth: root.cardWidth maximumWidth: root.cardWidth
Layout.alignment: Qt.AlignTop | Qt.AlignHCenter Layout.alignment: Qt.AlignTop | Qt.AlignHCenter
Layout.fillWidth: true
contentItem: ColumnLayout { FormCard.FormSwitchDelegate {
spacing: 0 text: i18n("Mobile Data")
checked: PlasmaMM.SignalIndicator.mobileDataEnabled
MobileForm.FormSwitchDelegate { onCheckedChanged: {
Layout.fillWidth: true if (checked !== PlasmaMM.SignalIndicator.mobileDataEnabled) {
text: i18n("Mobile Data") root.toggleMobileData();
checked: PlasmaMM.SignalIndicator.mobileDataEnabled
onCheckedChanged: {
if (checked !== PlasmaMM.SignalIndicator.mobileDataEnabled) {
root.toggleMobileData();
}
} }
} }
} }
} }
MobileForm.FormCard { FormCard.FormCard {
visible: PlasmaMM.SignalIndicator.modemAvailable && !PlasmaMM.SignalIndicator.simEmpty visible: PlasmaMM.SignalIndicator.modemAvailable && !PlasmaMM.SignalIndicator.simEmpty
maximumWidth: root.cardWidth maximumWidth: root.cardWidth
Layout.fillHeight: true Layout.fillHeight: true
Layout.alignment: Qt.AlignTop | Qt.AlignHCenter Layout.alignment: Qt.AlignTop | Qt.AlignHCenter
Layout.fillWidth: true
contentItem: ColumnLayout { ListView {
spacing: 0 id: listView
currentIndex: -1
clip: true
ListView { Layout.fillWidth: true
id: listView Layout.fillHeight: true
currentIndex: -1
clip: true
Layout.fillWidth: true model: PlasmaMM.SignalIndicator.profiles
Layout.fillHeight: true
model: PlasmaMM.SignalIndicator.profiles delegate: FormCard.FormRadioDelegate {
width: listView.width
text: modelData.name
description: modelData.apn
checked: modem.activeConnectionUni == modelData.connectionUni
delegate: MobileForm.FormRadioDelegate { onCheckedChanged: {
width: listView.width if (checked) {
text: modelData.name PlasmaMM.SignalIndicator.activateProfile(modelData.connectionUni);
description: modelData.apn checked = Qt.binding(() => { return modem.activeConnectionUni == modelData.connectionUni });
checked: modem.activeConnectionUni == modelData.connectionUni }
}
onCheckedChanged: { trailing: RowLayout {
if (checked) { ToolButton {
PlasmaMM.SignalIndicator.activateProfile(modelData.connectionUni); icon.name: "entry-edit"
checked = Qt.binding(() => { return modem.activeConnectionUni == modelData.connectionUni }); text: i18n("Edit")
onClicked: {
profileDialog.profile = modelData;
profileDialog.open();
} }
} }
ToolButton {
trailing: RowLayout { icon.name: "delete"
ToolButton { text: i18n("Delete")
icon.name: "entry-edit" onClicked: PlasmaMM.SignalIndicator.removeProfile(modelData.connectionUni)
text: i18n("Edit")
onClicked: {
profileDialog.profile = modelData;
profileDialog.open();
}
}
ToolButton {
icon.name: "delete"
text: i18n("Delete")
onClicked: PlasmaMM.SignalIndicator.removeProfile(modelData.connectionUni)
}
} }
} }
} }
}
MobileForm.FormButtonDelegate { FormCard.FormButtonDelegate {
icon.name: "list-add" icon.name: "list-add"
text: i18n("Add APN") text: i18n("Add APN")
onClicked: { onClicked: {
profileDialog.profile = null; profileDialog.profile = null;
profileDialog.open(); profileDialog.open();
}
} }
} }
} }
} }
} }

View file

@ -6,7 +6,7 @@ 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.plasma.mobileinitialstart.prepare 1.0 as Prepare import org.kde.plasma.mobileinitialstart.prepare 1.0 as Prepare
import org.kde.plasma.plasma5support 2.0 as P5Support 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.") text: i18n("Adjust the screen brightness to be comfortable for the installation process.")
} }
MobileForm.FormCard { FormCard.FormCard {
maximumWidth: root.cardWidth maximumWidth: root.cardWidth
Layout.alignment: Qt.AlignTop | Qt.AlignHCenter Layout.alignment: Qt.AlignTop | Qt.AlignHCenter
Layout.fillWidth: true
contentItem: ColumnLayout { FormCard.AbstractFormDelegate {
spacing: 0 background: null
MobileForm.AbstractFormDelegate { contentItem: RowLayout {
Layout.fillWidth: true spacing: Kirigami.Units.gridUnit
background: Item {} Kirigami.Icon {
implicitWidth: Kirigami.Units.iconSizes.smallMedium
implicitHeight: Kirigami.Units.iconSizes.smallMedium
source: "brightness-low"
}
contentItem: RowLayout { Slider {
spacing: Kirigami.Units.gridUnit id: brightnessSlider
Layout.fillWidth: true
from: 1
to: root.maximumScreenBrightness
value: root.screenBrightness
onMoved: root.screenBrightness = value;
}
Kirigami.Icon { Kirigami.Icon {
implicitWidth: Kirigami.Units.iconSizes.smallMedium implicitWidth: Kirigami.Units.iconSizes.smallMedium
implicitHeight: Kirigami.Units.iconSizes.smallMedium implicitHeight: Kirigami.Units.iconSizes.smallMedium
source: "brightness-low" source: "brightness-high"
}
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"
}
} }
} }
} }
@ -135,26 +128,20 @@ Item {
text: i18n("Adjust the size of elements on the screen.") text: i18n("Adjust the size of elements on the screen.")
} }
MobileForm.FormCard { FormCard.FormCard {
maximumWidth: root.cardWidth maximumWidth: root.cardWidth
Layout.alignment: Qt.AlignTop | Qt.AlignHCenter Layout.alignment: Qt.AlignTop | Qt.AlignHCenter
Layout.fillWidth: true
contentItem: ColumnLayout { FormCard.FormComboBoxDelegate {
spacing: 0 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 { // remove % suffix
id: displayScaling onCurrentValueChanged: Prepare.PrepareUtil.scaling = parseInt(currentValue.substring(0, currentValue.length - 1));
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));
}
} }
} }
} }

View file

@ -6,7 +6,7 @@ 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.plasma.mobileinitialstart.time 1.0 as Time import org.kde.plasma.mobileinitialstart.time 1.0 as Time
Item { Item {
@ -36,80 +36,73 @@ Item {
text: i18n("Select your time zone and preferred time format.") text: i18n("Select your time zone and preferred time format.")
} }
MobileForm.FormCard { FormCard.FormCard {
maximumWidth: root.cardWidth maximumWidth: root.cardWidth
Layout.alignment: Qt.AlignTop | Qt.AlignHCenter Layout.alignment: Qt.AlignTop | Qt.AlignHCenter
Layout.fillWidth: true Layout.fillWidth: true
contentItem: ColumnLayout { FormCard.FormSwitchDelegate {
spacing: 0 Layout.fillWidth: true
text: i18n("24-Hour Format")
MobileForm.FormSwitchDelegate { checked: Time.TimeUtil.is24HourTime
Layout.fillWidth: true onCheckedChanged: {
text: i18n("24-Hour Format") if (checked !== Time.TimeUtil.is24HourTime) {
checked: Time.TimeUtil.is24HourTime Time.TimeUtil.is24HourTime = checked;
onCheckedChanged: {
if (checked !== Time.TimeUtil.is24HourTime) {
Time.TimeUtil.is24HourTime = checked;
}
} }
} }
} }
} }
MobileForm.FormCard { FormCard.FormCard {
maximumWidth: root.cardWidth maximumWidth: root.cardWidth
Layout.fillHeight: true Layout.fillHeight: true
Layout.alignment: Qt.AlignTop | Qt.AlignHCenter Layout.alignment: Qt.AlignTop | Qt.AlignHCenter
Layout.fillWidth: true Layout.fillWidth: true
contentItem: ColumnLayout { ListView {
spacing: 0 id: listView
ListView { clip: true
clip: true Layout.fillWidth: true
id: listView Layout.fillHeight: true
Layout.fillWidth: true model: Time.TimeUtil.timeZones
Layout.fillHeight: true
model: Time.TimeUtil.timeZones
header: Control { header: Control {
width: listView.width width: listView.width
leftPadding: Kirigami.Units.gridUnit leftPadding: Kirigami.Units.gridUnit
rightPadding: Kirigami.Units.gridUnit rightPadding: Kirigami.Units.gridUnit
topPadding: Kirigami.Units.gridUnit topPadding: Kirigami.Units.gridUnit
bottomPadding: Kirigami.Units.gridUnit bottomPadding: Kirigami.Units.gridUnit
contentItem: Kirigami.SearchField { contentItem: Kirigami.SearchField {
id: searchField id: searchField
onTextChanged: { onTextChanged: {
Time.TimeUtil.timeZones.filterString = text; Time.TimeUtil.timeZones.filterString = text;
// HACK: search field seems to lose focus every time the text changes // HACK: search field seems to lose focus every time the text changes
focusTimer.restart(); focusTimer.restart();
} }
Timer { Timer {
id: focusTimer id: focusTimer
interval: 1 interval: 1
onTriggered: searchField.forceActiveFocus() onTriggered: searchField.forceActiveFocus()
}
} }
} }
}
delegate: MobileForm.FormRadioDelegate { delegate: FormCard.FormRadioDelegate {
required property string timeZoneId required property string timeZoneId
width: ListView.view.width width: ListView.view.width
text: timeZoneId text: timeZoneId
checked: Time.TimeUtil.currentTimeZone === timeZoneId checked: Time.TimeUtil.currentTimeZone === timeZoneId
onCheckedChanged: { onCheckedChanged: {
if (checked && timeZoneId !== Time.TimeUtil.currentTimeZone) { if (checked && timeZoneId !== Time.TimeUtil.currentTimeZone) {
Time.TimeUtil.currentTimeZone = model.timeZoneId; Time.TimeUtil.currentTimeZone = model.timeZoneId;
checked = Qt.binding(() => Time.TimeUtil.currentTimeZone === timeZoneId); checked = Qt.binding(() => Time.TimeUtil.currentTimeZone === timeZoneId);
}
} }
} }
} }

View file

@ -8,10 +8,10 @@ import QtQuick.Controls 2.15 as Controls
import org.kde.plasma.networkmanagement 0.2 as PlasmaNM import org.kde.plasma.networkmanagement 0.2 as PlasmaNM
import org.kde.kirigami 2.2 as Kirigami 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 import org.kde.ksvg 1.0 as KSvg
MobileForm.AbstractFormDelegate { FormCard.AbstractFormDelegate {
topPadding: Kirigami.Units.smallSpacing topPadding: Kirigami.Units.smallSpacing
bottomPadding: Kirigami.Units.smallSpacing bottomPadding: Kirigami.Units.smallSpacing

View file

@ -2,12 +2,12 @@
// SPDX-FileCopyrightText: 2023 Devin Lin <devin@kde.org> // SPDX-FileCopyrightText: 2023 Devin Lin <devin@kde.org>
// SPDX-License-Identifier: GPL-2.0-or-later // SPDX-License-Identifier: GPL-2.0-or-later
import QtQuick 2.15 import QtQuick
import QtQuick.Controls 2.15 import QtQuick.Controls
import QtQuick.Layouts 1.15 import QtQuick.Layouts
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.plasma.networkmanagement 0.2 as PlasmaNM import org.kde.plasma.networkmanagement 0.2 as PlasmaNM
import org.kde.plasma.mobileinitialstart.wifi 1.0 as WiFi 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.") text: i18n("Connect to a WiFi network for network access.")
} }
MobileForm.FormCard { FormCard.FormCard {
maximumWidth: root.cardWidth maximumWidth: root.cardWidth
Layout.fillHeight: true Layout.fillHeight: true
Layout.alignment: Qt.AlignTop | Qt.AlignHCenter Layout.alignment: Qt.AlignTop | Qt.AlignHCenter
Layout.fillWidth: true Layout.fillWidth: true
contentItem: ColumnLayout { ListView {
spacing: 0 id: listView
currentIndex: -1
clip: true
Layout.fillWidth: true
Layout.fillHeight: true
ListView { section.property: "Section"
id: listView section.delegate: Kirigami.ListSectionHeader {
currentIndex: -1 text: section
clip: true }
Layout.fillWidth: true
Layout.fillHeight: true
section.property: "Section" model: mobileProxyModel
section.delegate: Kirigami.ListSectionHeader {
text: section 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 delegate: ConnectionItemDelegate {
width: listView.width
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
}
} }
} }
} }