From c6b5855b446c73f8a60cc3d4427fc445e0ba400d Mon Sep 17 00:00:00 2001 From: Kimmo Ollila Date: Tue, 23 Feb 2016 09:13:21 +0200 Subject: Migrate settings UI to use Qt Quick Controls 2 Task-number: QTEE-1057 Change-Id: I389d784241d4b68384765dfde4b572e7652eb76c Reviewed-by: Teemu Holappa --- src/settingsui/timedate/TimeDate.qml | 143 +++++++++++++---------------------- 1 file changed, 53 insertions(+), 90 deletions(-) (limited to 'src/settingsui/timedate/TimeDate.qml') diff --git a/src/settingsui/timedate/TimeDate.qml b/src/settingsui/timedate/TimeDate.qml index 439e4ac..5ba8dfa 100644 --- a/src/settingsui/timedate/TimeDate.qml +++ b/src/settingsui/timedate/TimeDate.qml @@ -33,11 +33,11 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ -import QtQuick 2.5 -import QtQuick.Layouts 1.1 -import QtQuick.Controls 1.4 -import QtQuick.Controls.Styles.Flat 1.0 as Flat -import "../common" +import QtQuick 2.6 +import QtQuick.Layouts 1.3 +import Qt.labs.controls 1.0 +import Qt.labs.controls.material 1.0 +import Qt.labs.controls.universal 1.0 import com.theqtcompany.settings.timedate 1.0 Item { @@ -46,14 +46,14 @@ Item { Flickable { anchors.fill: parent - anchors.margins: Math.round(40 * Flat.FlatStyle.scaleFactor) - anchors.bottomMargin: Math.round(20 * Flat.FlatStyle.scaleFactor) + anchors.margins: 20 contentHeight: content.height contentWidth: width - Column { + ColumnLayout { id: content width: parent.width + spacing: 20 GroupBox { width: parent.width @@ -61,105 +61,68 @@ Item { Layout.fillWidth: true ColumnLayout { - spacing: Math.round(10 * Flat.FlatStyle.scaleFactor) + spacing: 10 width: parent.width Layout.fillWidth: true - ExclusiveGroup { id: exgroup } - RadioButton { id: automatic text: qsTr("Automatic time set") - exclusiveGroup: exgroup checked: TimeManager.ntp - onCheckedChanged: if (checked) calloader.reload(); + onCheckedChanged: if (checked) updateTimer.restart() + + Timer { + id: updateTimer + interval: 300 + onTriggered: calendar.updateDate() + } } RadioButton { id: custom text: qsTr("Manual") - exclusiveGroup: exgroup checked: !TimeManager.ntp onCheckedChanged: TimeManager.ntp = !checked - } - RowLayout { - spacing: Math.round(10 * Flat.FlatStyle.scaleFactor) - Layout.fillWidth: true - - Component { - id: calendar - - Item { - width: cal.width - height: cal.height - - Timer { - id: timer - } - function delay(delayTime, cb) { - timer.interval = delayTime; - timer.repeat = false; - timer.triggered.connect(cb); - timer.start(); - } - - Calendar { - id: cal - weekNumbersVisible: false - enabled: !automatic.checked - onClicked: { - var currentTime = TimeManager.time; - var newDate = date; - newDate.setHours(currentTime.getHours()); - newDate.setMinutes(currentTime.getMinutes()); - newDate.setSeconds(currentTime.getSeconds()); - TimeManager.time = newDate; - delay(100, function() { - calloader.reload(); - }); - } - } - } - } + } + RowLayout + { + id: layout + spacing: 10 - Loader { - id: calloader - sourceComponent: calendar - function reload() { - calloader.sourceComponent = undefined; - calloader.sourceComponent = calendar; - } - } + CustomCalendar { + id: calendar + width: height + } - AnalogClock { - id: clock - width: calloader.width - height: width - editMode: !automatic.checked - } - } + AnalogClock { + id: clock + height: calendar.height + width: height + editMode: !automatic.checked + } + } + Component { + id: zoneselect + TimezonesView { } + } - Component { - id: zoneselect - TimezonesView { } - } + } + } + GroupBox { + title: qsTr("Timezone Settings") + Layout.fillWidth: true + width: parent.width + visible: true - GroupBox { - title: qsTr("Timezone Settings") - Layout.fillWidth: true - width: parent.width - visible: true - flat: true - Row { - spacing: Math.round(10 * Flat.FlatStyle.scaleFactor) - TextLabel { - text: TimeManager.timeZone - } - Button { - text: "Change" - onClicked : stackView.push(zoneselect) - } - } - } + RowLayout { + spacing: 10 + Label { + text: TimeManager.timeZone + Layout.alignment: Qt.AlignVCenter + } + Button { + text: qsTr("Change") + onClicked : stackView.push(zoneselect) + } } } } -- cgit v1.2.3