diff options
Diffstat (limited to 'src/settingsui/timedate/TimeDate.qml')
-rw-r--r-- | src/settingsui/timedate/TimeDate.qml | 180 |
1 files changed, 111 insertions, 69 deletions
diff --git a/src/settingsui/timedate/TimeDate.qml b/src/settingsui/timedate/TimeDate.qml index e269fa5..fccda46 100644 --- a/src/settingsui/timedate/TimeDate.qml +++ b/src/settingsui/timedate/TimeDate.qml @@ -30,92 +30,134 @@ import QtQuick 2.6 import QtQuick.Layouts 1.3 import QtQuick.Controls 2.0 import QtDeviceUtilities.TimeDateSettings 1.0 +import QtDeviceUtilities.LocaleSettings 1.0 +import QtDeviceUtilities.QtButtonImageProvider 1.0 Item { id: root - property string title: qsTr("Time and Date settings") + property int margin: root.width * 0.05 - Flickable { - id: flickable - anchors.margins: 20 - anchors.fill: parent - contentHeight: content.height - contentWidth: width - interactive: !clock.handPressed + Column { + spacing: pluginMain.spacing + anchors.top: parent.top - ColumnLayout { - id: content - spacing: 20 - width: parent.width + // Display current date + Text { + color: "white" + text: qsTr("Current date") + font.pixelSize: pluginMain.subTitleFontSize + font.family: appFont + } - GroupBox { - width: parent.width - title: qsTr("Time Settings") - Layout.fillWidth: true + Text { + id: dateText + leftPadding: pluginMain.margin + color: "white" + font.pixelSize: pluginMain.valueFontSize + font.family: appFont + Timer { + id: dateTimer + interval: 1000 + running: true + repeat: true + triggeredOnStart: true + onTriggered: { + var date = new Date(); + // QTBUG-63598: dateText.text = date.toLocaleString(Qt.locale(LocaleManager.locale), Locale.LongFormat) + dateText.text = date.toLocaleString(Qt.locale("en_EN"), Locale.LongFormat) + } + } + } - ColumnLayout { - spacing: 10 - width: parent.width - Layout.fillWidth: true + // Set date automatically / manually + Text { + color: "white" + text: qsTr("Set Date & Time") + font.pixelSize: pluginMain.subTitleFontSize + font.family: appFont + } - RadioButton { - id: automatic - text: qsTr("Automatic time set") - checked: TimeManager.ntp - onCheckedChanged: if (checked) updateTimer.restart() + Row { + spacing: pluginMain.spacing + leftPadding: pluginMain.margin + QtButton { + id: automaticButton + height: pluginMain.buttonHeight + text: qsTr("AUTOMATICALLY") + onClicked: TimeManager.ntp = true + } + QtButton { + id: manualButton + height: pluginMain.buttonHeight + fillColor: viewSettings.buttonGrayColor + borderColor: "transparent" + text: qsTr("MANUALLY") + onClicked: { + settingsLoader.source = "qrc:/timedate/ManualTime.qml" + } + } + } - Timer { - id: updateTimer - interval: 300 - onTriggered: calendar.updateDate() - } - } - RadioButton { - id: custom - text: qsTr("Manual") - checked: !TimeManager.ntp - onCheckedChanged: TimeManager.ntp = !checked - } - RowLayout - { - id: layout - spacing: 10 + // Select timezone + Text { + color: "white" + text: qsTr("Time Zone") + font.pixelSize: pluginMain.subTitleFontSize + font.family: appFont + } - CustomCalendar { - id: calendar - width: height - } - AnalogClock { - id: clock - height: calendar.height - width: height - editMode: !automatic.checked - } - } - Component { - id: zoneselect - TimezonesView { } + Row { + leftPadding: pluginMain.margin + CustomComboBox { + id: timeZoneBox + width: automaticButton.width + manualButton.width + pluginMain.spacing + height: pluginMain.buttonHeight + textRole: "id" + itemsVisible: 7 + model: TimezonesFilter + delegate: ItemDelegate { + id: timeZoneDelegate + height: timeZoneBox.height + width: timeZoneBox.width + // QTBUG-49224: contentItem: Item {} + Text { + anchors.left: timeZoneDelegate.left + anchors.leftMargin: pluginMain.margin + text: modelData["id"] + color: timeZoneBox.currentIndex == index ? viewSettings.buttonGreenColor : "white" + elide: Text.ElideRight + verticalAlignment: Text.AlignVCenter + font.pixelSize: pluginMain.valueFontSize + font.family: appFont + font.styleName: "Regular" } } - } - GroupBox { - title: qsTr("Timezone Settings") - Layout.fillWidth: true - width: parent.width - visible: true - RowLayout { - spacing: 10 - Label { - text: TimeManager.timeZone - Layout.alignment: Qt.AlignVCenter + Component.onCompleted: { + var n = TimezonesFilter.indexForTimezone(TimeManager.timeZone) + timeZoneBox.currentIndex = n + } + + Connections { + target: TimezonesFilter.sourceModel + onReady: { + var n = TimezonesFilter.indexForTimezone(TimeManager.timeZone) + timeZoneBox.currentIndex = n } - Button { - text: qsTr("Change") - onClicked : stackView.push(zoneselect) + } + + onCurrentIndexChanged: { + var val = TimezonesFilter.itemFromRow(currentIndex); + if (val && val !== "") { + TimeManager.timeZone = val } } } } + + Component { + id: zoneselect + TimezonesView {} + } } } |