summaryrefslogtreecommitdiffstats
path: root/src/settingsui
diff options
context:
space:
mode:
authorSami Nurmenniemi <sami.nurmenniemi@qt.io>2017-11-10 09:27:12 +0200
committerSami Nurmenniemi <sami.nurmenniemi@qt.io>2017-11-22 10:42:19 +0000
commit368871a8d0b80e9e8f2eb0de414209dc0a23ab58 (patch)
tree0bc9150079262e430327e12cb907f299aa3fad4a /src/settingsui
parente1ed6a4e35b03aded27f8c505aa2f6ee9f94098b (diff)
Fix manual date & time setting
- Set button now returns back to general date & time settings - Manual date initial values are taken from current date - Cleaned up error prints Task-number: QTBUG-60082 Change-Id: I2787c41378a1534cf96a4ef60910a3fc2a45c24e Reviewed-by: Kari Oikarinen <kari.oikarinen@qt.io> Reviewed-by: Teemu Holappa <teemu.holappa@qt.io>
Diffstat (limited to 'src/settingsui')
-rw-r--r--src/settingsui/timedate/ManualTime.qml65
-rw-r--r--src/settingsui/timedate/TimeDate.qml6
2 files changed, 36 insertions, 35 deletions
diff --git a/src/settingsui/timedate/ManualTime.qml b/src/settingsui/timedate/ManualTime.qml
index bdb82cd..1438565 100644
--- a/src/settingsui/timedate/ManualTime.qml
+++ b/src/settingsui/timedate/ManualTime.qml
@@ -34,7 +34,7 @@ import QtDeviceUtilities.TimeDateSettings 1.0
Item {
id: root
property int margin: root.width * 0.05
-
+ property var selectedDate: new Date()
property int firstYear: 2017
function zeroPadTime(timeToPad) {
@@ -61,15 +61,16 @@ Item {
width: root.width * 0.15
height: pluginMain.buttonHeight
displayText: currentIndex + 1
- property var date: new Date(firstYear, 1, 0)
model: 31
itemsVisible: 10
+ currentIndex: selectedDate.getDate() - 1
delegate: ItemDelegate {
id: dayDelegate
height: dayBox.height
- contentItem: Text {
+ // QTBUG-49224: contentItem: Item {}
+ Text {
anchors.left: dayDelegate.left
anchors.leftMargin: pluginMain.margin
text: modelData + 1
@@ -82,15 +83,7 @@ Item {
}
}
- property int month: monthBox.currentIndex + 1
- onMonthChanged: updateDate()
-
- property int year: yearBox.currentIndex + firstYear
- onYearChanged: updateDate()
-
- function updateDate() {
- date = new Date(year, month, 0)
- }
+ onCurrentIndexChanged: selectedDate.setDate(currentIndex + 1)
}
CustomComboBox {
@@ -98,11 +91,14 @@ Item {
width: root.width * 0.35
height: pluginMain.buttonHeight
model: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]
+ currentIndex: selectedDate.getMonth()
+
itemsVisible: 12
delegate: ItemDelegate {
id: monthDelegate
height: monthBox.height
- contentItem: Text {
+ // QTBUG-49224: contentItem: Item {}
+ Text {
anchors.left: monthDelegate.left
anchors.leftMargin: pluginMain.margin
color: monthBox.currentIndex == index ? viewSettings.buttonGreenColor : "white"
@@ -115,20 +111,25 @@ Item {
}
}
+ onCurrentIndexChanged: selectedDate.setMonth(currentIndex)
}
+
CustomComboBox {
id: yearBox
width: root.width * 0.2
height: pluginMain.buttonHeight
- displayText: yearBox.currentIndex + date.getFullYear()
- property var date: new Date()
+ displayText: currentIndex + firstYear
model: 50
itemsVisible: 8
+ currentIndex: (selectedDate.getFullYear() >= firstYear) ?
+ selectedDate.getFullYear() - firstYear : 0
+
delegate: ItemDelegate {
id: yearDelegate
height: yearBox.height
- contentItem: Text {
+ // QTBUG-49224: contentItem: Item {}
+ Text {
anchors.left: yearDelegate.left
anchors.leftMargin: pluginMain.margin
text: index + firstYear
@@ -140,6 +141,7 @@ Item {
font.styleName: "Regular"
}
}
+ onCurrentIndexChanged: selectedDate.setFullYear(currentIndex + firstYear)
}
} // Row of date comboboxes
@@ -159,16 +161,17 @@ Item {
id: hourBox
width: root.width * 0.15
height: pluginMain.buttonHeight
- displayText: zeroPadTime(hour)
- property int hour: currentIndex
+ displayText: zeroPadTime(currentIndex)
model: 24
itemsVisible: 8
+ currentIndex: selectedDate.getHours()
delegate: ItemDelegate {
id: hourDelegate
height: hourBox.height
- contentItem: Text {
+ // QTBUG-49224: contentItem: Item {}
+ Text {
anchors.left: hourDelegate.left
anchors.leftMargin: pluginMain.margin
text: zeroPadTime(parseInt(modelData))
@@ -180,21 +183,23 @@ Item {
font.styleName: "Regular"
}
}
+ onCurrentIndexChanged: selectedDate.setHours(currentIndex)
}
CustomComboBox {
id: minuteBox
width: root.width * 0.15
height: pluginMain.buttonHeight
- displayText: zeroPadTime(minute)
- property int minute: currentIndex
+ displayText: zeroPadTime(currentIndex)
model: 60
itemsVisible: 8
+ currentIndex: selectedDate.getMinutes()
delegate: ItemDelegate {
id: minuteDelegate
height: minuteBox.height
- contentItem: Text {
+ // QTBUG-49224: contentItem: Item {}
+ Text {
anchors.left: minuteDelegate.left
anchors.leftMargin: pluginMain.margin
text: zeroPadTime(parseInt(modelData))
@@ -206,6 +211,7 @@ Item {
font.styleName: "Regular"
}
}
+ onCurrentIndexChanged: selectedDate.setMinutes(currentIndex)
}
} // Row of time comboboxes
@@ -219,19 +225,12 @@ Item {
text: qsTr("SET")
onClicked: {
- var currentTime = TimeManager.time;
- var newDate = new Date();
-
- newDate.setFullYear(dayBox.year)
- newDate.setMonth(dayBox.month - 1)
- newDate.setDate(dayBox.currentIndex+1)
- newDate.setHours(hourBox.hour)
- newDate.setMinutes(minuteBox.minute)
- newDate.setSeconds(currentTime.getSeconds())
+ selectedDate.setSeconds(0);
TimeManager.ntp = false
- TimeManager.time = newDate;
- console.log("newDate: " + newDate)
+ TimeManager.time = selectedDate;
+ console.log("Set date to: " + selectedDate)
console.log("TimeManager.time: " + TimeManager.time)
+ settingsLoader.source = "qrc:/timedate/TimeDate.qml"
}
}
QtButton {
diff --git a/src/settingsui/timedate/TimeDate.qml b/src/settingsui/timedate/TimeDate.qml
index 2104c75..fccda46 100644
--- a/src/settingsui/timedate/TimeDate.qml
+++ b/src/settingsui/timedate/TimeDate.qml
@@ -118,7 +118,9 @@ Item {
delegate: ItemDelegate {
id: timeZoneDelegate
height: timeZoneBox.height
- contentItem: Text {
+ width: timeZoneBox.width
+ // QTBUG-49224: contentItem: Item {}
+ Text {
anchors.left: timeZoneDelegate.left
anchors.leftMargin: pluginMain.margin
text: modelData["id"]
@@ -146,7 +148,7 @@ Item {
onCurrentIndexChanged: {
var val = TimezonesFilter.itemFromRow(currentIndex);
- if (val !== "") {
+ if (val && val !== "") {
TimeManager.timeZone = val
}
}