Warning, /plasma/plasma-mobile/initialstart/modules/time/package/contents/ui/main.qml is written in an unsupported language. File is not indexed.
0001 // SPDX-FileCopyrightText: 2023 Devin Lin <devin@kde.org> 0002 // SPDX-License-Identifier: GPL-2.0-or-later 0003 0004 import QtQuick 2.15 0005 import QtQuick.Controls 2.15 0006 import QtQuick.Layouts 1.15 0007 0008 import org.kde.kirigami 2.20 as Kirigami 0009 import org.kde.kirigamiaddons.formcard 1.0 as FormCard 0010 import org.kde.plasma.mobileinitialstart.time 1.0 as Time 0011 0012 Item { 0013 id: root 0014 property string name: i18n("Time and Date") 0015 0016 readonly property real cardWidth: Math.min(Kirigami.Units.gridUnit * 30, root.width - Kirigami.Units.gridUnit * 2) 0017 0018 ColumnLayout { 0019 anchors { 0020 fill: parent 0021 topMargin: Kirigami.Units.gridUnit 0022 bottomMargin: Kirigami.Units.largeSpacing 0023 } 0024 0025 width: root.width 0026 spacing: Kirigami.Units.gridUnit 0027 0028 Label { 0029 Layout.leftMargin: Kirigami.Units.gridUnit 0030 Layout.rightMargin: Kirigami.Units.gridUnit 0031 Layout.alignment: Qt.AlignTop 0032 Layout.fillWidth: true 0033 0034 wrapMode: Text.Wrap 0035 horizontalAlignment: Text.AlignHCenter 0036 text: i18n("Select your time zone and preferred time format.") 0037 } 0038 0039 FormCard.FormCard { 0040 maximumWidth: root.cardWidth 0041 0042 Layout.alignment: Qt.AlignTop | Qt.AlignHCenter 0043 Layout.fillWidth: true 0044 0045 FormCard.FormSwitchDelegate { 0046 Layout.fillWidth: true 0047 text: i18n("24-Hour Format") 0048 checked: Time.TimeUtil.is24HourTime 0049 onCheckedChanged: { 0050 if (checked !== Time.TimeUtil.is24HourTime) { 0051 Time.TimeUtil.is24HourTime = checked; 0052 } 0053 } 0054 } 0055 } 0056 0057 FormCard.FormCard { 0058 maximumWidth: root.cardWidth 0059 0060 Layout.fillHeight: true 0061 Layout.alignment: Qt.AlignTop | Qt.AlignHCenter 0062 Layout.fillWidth: true 0063 0064 ListView { 0065 id: listView 0066 0067 clip: true 0068 Layout.fillWidth: true 0069 Layout.fillHeight: true 0070 model: Time.TimeUtil.timeZones 0071 0072 header: Control { 0073 width: listView.width 0074 leftPadding: Kirigami.Units.largeSpacing 0075 rightPadding: Kirigami.Units.largeSpacing 0076 topPadding: Kirigami.Units.largeSpacing 0077 bottomPadding: Kirigami.Units.largeSpacing 0078 0079 contentItem: Kirigami.SearchField { 0080 id: searchField 0081 0082 onTextChanged: { 0083 Time.TimeUtil.timeZones.filterString = text; 0084 // HACK: search field seems to lose focus every time the text changes 0085 focusTimer.restart(); 0086 } 0087 0088 Timer { 0089 id: focusTimer 0090 interval: 1 0091 onTriggered: searchField.forceActiveFocus() 0092 } 0093 } 0094 } 0095 0096 delegate: FormCard.FormRadioDelegate { 0097 required property string timeZoneId 0098 0099 width: ListView.view.width 0100 text: timeZoneId 0101 checked: Time.TimeUtil.currentTimeZone === timeZoneId 0102 onCheckedChanged: { 0103 if (checked && timeZoneId !== Time.TimeUtil.currentTimeZone) { 0104 Time.TimeUtil.currentTimeZone = model.timeZoneId; 0105 checked = Qt.binding(() => Time.TimeUtil.currentTimeZone === timeZoneId); 0106 } 0107 } 0108 } 0109 } 0110 } 0111 } 0112 } 0113