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,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

View file

@ -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")));

View file

@ -1,13 +1,13 @@
// SPDX-FileCopyrightText: 2023 Devin Lin <devin@kde.org>
// 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();
}
}
}
}
}

View file

@ -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));
}
}
}

View file

@ -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);
}
}
}

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.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

View file

@ -2,12 +2,12 @@
// SPDX-FileCopyrightText: 2023 Devin Lin <devin@kde.org>
// 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
}
}
}