2023-04-01 07:09:57 +00:00
|
|
|
// 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 org.kde.kirigami 2.20 as Kirigami
|
2023-09-21 19:02:47 +00:00
|
|
|
import org.kde.kirigamiaddons.formcard 1.0 as FormCard
|
2023-04-01 07:09:57 +00:00
|
|
|
import org.kde.plasma.mobileinitialstart.time 1.0 as Time
|
|
|
|
|
|
2024-11-07 06:07:50 +00:00
|
|
|
import org.kde.plasma.mobileinitialstart.initialstart
|
2023-04-01 07:09:57 +00:00
|
|
|
|
2024-11-07 06:07:50 +00:00
|
|
|
InitialStartModule {
|
2024-11-10 06:35:06 +00:00
|
|
|
name: i18n("Time and Date")
|
2024-11-07 06:07:50 +00:00
|
|
|
contentItem: Item {
|
|
|
|
|
id: root
|
2023-04-01 07:09:57 +00:00
|
|
|
|
2024-11-07 06:07:50 +00:00
|
|
|
readonly property real cardWidth: Math.min(Kirigami.Units.gridUnit * 30, root.width - Kirigami.Units.gridUnit * 2)
|
2023-04-01 07:09:57 +00:00
|
|
|
|
2024-11-07 06:07:50 +00:00
|
|
|
ColumnLayout {
|
|
|
|
|
anchors {
|
|
|
|
|
fill: parent
|
|
|
|
|
topMargin: Kirigami.Units.gridUnit
|
|
|
|
|
bottomMargin: Kirigami.Units.largeSpacing
|
|
|
|
|
}
|
2023-04-01 07:09:57 +00:00
|
|
|
|
2024-11-07 06:07:50 +00:00
|
|
|
width: root.width
|
|
|
|
|
spacing: Kirigami.Units.gridUnit
|
2023-04-01 07:09:57 +00:00
|
|
|
|
2024-11-07 06:07:50 +00:00
|
|
|
Label {
|
|
|
|
|
Layout.leftMargin: Kirigami.Units.gridUnit
|
|
|
|
|
Layout.rightMargin: Kirigami.Units.gridUnit
|
|
|
|
|
Layout.alignment: Qt.AlignTop
|
|
|
|
|
Layout.fillWidth: true
|
2023-04-01 07:09:57 +00:00
|
|
|
|
2024-11-07 06:07:50 +00:00
|
|
|
wrapMode: Text.Wrap
|
|
|
|
|
horizontalAlignment: Text.AlignHCenter
|
|
|
|
|
text: i18n("Select your time zone and preferred time format.")
|
|
|
|
|
}
|
2023-04-01 07:09:57 +00:00
|
|
|
|
2024-11-07 06:07:50 +00:00
|
|
|
FormCard.FormCard {
|
|
|
|
|
maximumWidth: root.cardWidth
|
2023-04-01 07:09:57 +00:00
|
|
|
|
2024-11-07 06:07:50 +00:00
|
|
|
Layout.alignment: Qt.AlignTop | Qt.AlignHCenter
|
2023-09-21 19:02:47 +00:00
|
|
|
Layout.fillWidth: true
|
2024-11-07 06:07:50 +00:00
|
|
|
|
|
|
|
|
FormCard.FormSwitchDelegate {
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
text: i18n("24-Hour Format")
|
|
|
|
|
checked: Time.TimeUtil.is24HourTime
|
|
|
|
|
onCheckedChanged: {
|
|
|
|
|
if (checked !== Time.TimeUtil.is24HourTime) {
|
|
|
|
|
Time.TimeUtil.is24HourTime = checked;
|
|
|
|
|
}
|
2023-04-01 07:09:57 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-11-07 06:07:50 +00:00
|
|
|
FormCard.FormCard {
|
|
|
|
|
maximumWidth: root.cardWidth
|
2023-04-01 07:09:57 +00:00
|
|
|
|
2024-11-07 06:07:50 +00:00
|
|
|
Layout.fillHeight: true
|
|
|
|
|
Layout.alignment: Qt.AlignTop | Qt.AlignHCenter
|
|
|
|
|
Layout.fillWidth: true
|
2023-04-01 07:09:57 +00:00
|
|
|
|
2024-11-07 06:07:50 +00:00
|
|
|
ListView {
|
|
|
|
|
id: listView
|
2023-09-21 19:02:47 +00:00
|
|
|
|
2024-11-07 06:07:50 +00:00
|
|
|
clip: true
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
Layout.fillHeight: true
|
|
|
|
|
model: Time.TimeUtil.timeZones
|
|
|
|
|
currentIndex: -1 // ensure focus is not on the listview
|
2023-09-21 19:02:47 +00:00
|
|
|
|
2024-11-07 06:07:50 +00:00
|
|
|
header: Control {
|
|
|
|
|
width: listView.width
|
|
|
|
|
leftPadding: Kirigami.Units.largeSpacing
|
|
|
|
|
rightPadding: Kirigami.Units.largeSpacing
|
|
|
|
|
topPadding: Kirigami.Units.largeSpacing
|
|
|
|
|
bottomPadding: Kirigami.Units.largeSpacing
|
2023-09-21 19:02:47 +00:00
|
|
|
|
2024-11-07 06:07:50 +00:00
|
|
|
contentItem: Kirigami.SearchField {
|
|
|
|
|
id: searchField
|
2023-09-21 19:02:47 +00:00
|
|
|
|
2024-11-07 06:07:50 +00:00
|
|
|
onTextChanged: {
|
|
|
|
|
Time.TimeUtil.timeZones.filterString = text;
|
|
|
|
|
}
|
2023-04-01 07:09:57 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-11-07 06:07:50 +00:00
|
|
|
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 = timeZoneId;
|
|
|
|
|
checked = Qt.binding(() => Time.TimeUtil.currentTimeZone === timeZoneId);
|
|
|
|
|
}
|
2023-04-01 07:09:57 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|