summaryrefslogtreecommitdiffstats
path: root/src/settingsui/timedate
diff options
context:
space:
mode:
Diffstat (limited to 'src/settingsui/timedate')
-rw-r--r--src/settingsui/timedate/AnalogClock.qml124
-rw-r--r--src/settingsui/timedate/CustomCalendar.qml221
-rw-r--r--src/settingsui/timedate/TimeDate.qml143
-rw-r--r--src/settingsui/timedate/TimezonesView.qml52
4 files changed, 351 insertions, 189 deletions
diff --git a/src/settingsui/timedate/AnalogClock.qml b/src/settingsui/timedate/AnalogClock.qml
index 9f871ed..eb46852 100644
--- a/src/settingsui/timedate/AnalogClock.qml
+++ b/src/settingsui/timedate/AnalogClock.qml
@@ -33,8 +33,10 @@
** $QT_END_LICENSE$
**
****************************************************************************/
-import QtQuick 2.5
-import "../common"
+import QtQuick 2.6
+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 {
@@ -59,18 +61,16 @@ Item {
onTimeChanged : newTime.setSeconds(currentTime.getSeconds())
onTimeZoneChanged : Date.timeZoneUpdated()
}
-
- TextLabel {
+ Label {
anchors.horizontalCenter: parent.horizontalCenter
anchors.topMargin: 10
anchors.top: parent.top
text: editMode ? newTime.toTimeString() : currentTime.toTimeString()
}
-
Rectangle {
id: root
anchors.fill: parent
- anchors.margins: Math.round(40 * Flat.FlatStyle.scaleFactor)
+ anchors.margins: 40
color: "white"
border.color: editMode ? "#d6d6d6" : "#5caa15"
border.width: Math.round(root.width * 0.120)
@@ -96,7 +96,6 @@ Item {
}
}
}
-
Rectangle {
id: hours
x: Math.round(root.height / 2 - width / 2)
@@ -115,7 +114,6 @@ Item {
}
}
}
-
Rectangle {
id: seconds
x: root.height / 2 - width / 2
@@ -136,59 +134,56 @@ Item {
}
}
}
-
Component {
- id: editor
-
- Rectangle {
- id: rect
- property var angle: mouseArea.drag ? mouseArea.angle : defaultAngle
- property var defaultAngle: angleBinding
- x: Math.round(Math.cos((-90+ angle)*Math.PI/180) *
- (pos - root.handOffset - width /2 + radius) + root.width / 2 - width / 2)
- y: Math.round(Math.sin((-90+ angle)*Math.PI/180) *
- (pos - root.handOffset - width /2 + radius) + root.height / 2 - width / 2)
- color: "#5caa15"
- width: size
- radius: width / 2
- height: width
- antialiasing: true
-
- function calcAngle(mouse) {
- var mouseGlobal = mapToItem(root, mouse.x, mouse.y)
- var origin = root.width/2
- var angle = (90+Math.atan2((mouseGlobal.y-origin), (mouseGlobal.x-origin))*180/Math.PI)
- if (angle < 0)
- angle += 360;
- updateAngle(angle);
- return angle;
- }
-
- MouseArea {
- id: mouseArea
- anchors.fill: parent
- property int startX: 0
- property int startY: 0
- property bool drag: false
- property var angle: 0.0
- preventStealing: true
-
- onPressed: {
- var mouseGlobal = mapToItem(root, mouse.x, mouse.y);
- startX = mouseGlobal.x;
- startY = mouseGlobal.y;
- angle = calcAngle(mouse);
- drag = true;
- }
- onReleased: {
- drag = false;
- ready(angle)
- }
- onMouseXChanged: if (drag) angle = calcAngle(mouse)
- }
- }
- }
-
+ id: editor
+
+ Rectangle {
+ id: rect
+ property var angle: mouseArea.drag ? mouseArea.angle : defaultAngle
+ property var defaultAngle: angleBinding
+ x: Math.round(Math.cos((-90+ angle)*Math.PI/180) *
+ (pos - root.handOffset - width /2 + radius) + root.width / 2 - width / 2)
+ y: Math.round(Math.sin((-90+ angle)*Math.PI/180) *
+ (pos - root.handOffset - width /2 + radius) + root.height / 2 - width / 2)
+ color: "#5caa15"
+ width: size
+ radius: width / 2
+ height: width
+ antialiasing: true
+
+ function calcAngle(mouse) {
+ var mouseGlobal = mapToItem(root, mouse.x, mouse.y)
+ var origin = root.width/2
+ var angle = (90+Math.atan2((mouseGlobal.y-origin), (mouseGlobal.x-origin))*180/Math.PI)
+ if (angle < 0)
+ angle += 360;
+ updateAngle(angle);
+ return angle;
+ }
+ MouseArea {
+ id: mouseArea
+ anchors.fill: parent
+ property int startX: 0
+ property int startY: 0
+ property bool drag: false
+ property var angle: 0.0
+ preventStealing: true
+
+ onPressed: {
+ var mouseGlobal = mapToItem(root, mouse.x, mouse.y);
+ startX = mouseGlobal.x;
+ startY = mouseGlobal.y;
+ angle = calcAngle(mouse);
+ drag = true;
+ }
+ onReleased: {
+ drag = false;
+ ready(angle)
+ }
+ onMouseXChanged: if (drag) angle = calcAngle(mouse)
+ }
+ }
+ }
Loader {
property var angleBinding: (currentTime.getHours() * 30) + (currentTime.getMinutes() * 0.5)
property int size: Math.round(root.width * 0.120)
@@ -213,11 +208,9 @@ Item {
else if (preHour == 12 && newHour == 11) {
pm = false;
}
-
if (pm == true) {
newHour += 12;
}
-
newTime.setHours(newHour);
}
@@ -228,13 +221,12 @@ Item {
}
sourceComponent: editor
}
-
Loader {
+ visible: editMode
+ sourceComponent: editor
property var angleBinding: currentTime.getMinutes() * 6
property int size: Math.round(root.width * 0.120)
property int pos: minutes.height
- visible: editMode
- sourceComponent: editor
function updateAngle(angle) {
var newMin = Math.round(angle / 6);
@@ -242,7 +234,6 @@ Item {
newTime.setMinutes(newMin);
newTime.setHours(hours);
}
-
function ready(val) {
var newmins = Math.round(val / 6);
currentTime.setMinutes(newmins);
@@ -252,4 +243,3 @@ Item {
}
}
}
-
diff --git a/src/settingsui/timedate/CustomCalendar.qml b/src/settingsui/timedate/CustomCalendar.qml
new file mode 100644
index 0000000..09d4e3e
--- /dev/null
+++ b/src/settingsui/timedate/CustomCalendar.qml
@@ -0,0 +1,221 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Device Utilities module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+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 Qt.labs.calendar 1.0
+import QtQml 2.2
+import com.theqtcompany.settings.timedate 1.0
+
+Rectangle {
+ id: root
+ border.color: "#bdbebf"
+ border.width: 1
+ color: "white"
+ height: cal.height
+
+ function updateDate() {
+ var date = new Date()
+ grid.month = date.getMonth()
+ grid.date = date.getDate()
+ grid.year = date.getFullYear()
+ }
+
+ ColumnLayout {
+ id: cal
+ width: root.width
+ spacing: 10
+ enabled: !automatic.checked
+
+ RowLayout {
+ spacing: 0
+ Layout.alignment: Qt.AlignTop
+
+ Button {
+ id: previousMonth
+ Layout.preferredWidth: height
+ visible: enabled
+ label: Rectangle {
+ anchors.fill: parent
+ color: "#d6d6d6"
+
+ Image {
+ anchors.centerIn: parent
+ source: "../icons/Chevron-left_black_1x.png"
+ }
+ }
+ onClicked: {
+ if (grid.month === Calendar.January) {
+ grid.year--
+ grid.month = Calendar.December
+ return;
+ }
+ grid.month--
+ }
+ }
+ Rectangle {
+ Layout.fillWidth: true
+ color: enabled ? "#d6d6d6" : "#80c342"
+ height: previousMonth.height
+
+ Label {
+ id: title
+ text: Qt.locale().monthName(grid.month, Locale.LongFormat) + " " + grid.year
+ anchors.fill: parent
+ horizontalAlignment: Text.AlignHCenter
+ verticalAlignment: Text.AlignVCenter
+ }
+ }
+ Button {
+ id: nextMonth
+ Layout.preferredWidth: height
+ visible: enabled
+ label: Rectangle {
+ anchors.fill: parent
+ color: "#d6d6d6"
+
+ Image {
+ anchors.centerIn: parent
+ source: "../icons/Chevron-left_black_1x.png"
+ mirror: true
+ }
+ }
+ onClicked: {
+ if (grid.month === Calendar.December) {
+ grid.year++
+ grid.month = Calendar.January
+ }
+ grid.month++
+ }
+ }
+ }
+ DayOfWeekRow {
+ locale: grid.locale
+ Layout.column: 1
+ Layout.fillWidth: true
+ Layout.alignment: Qt.AlignTop
+ delegate: Text {
+ text: model.narrowName.charAt(0)
+ font.bold: true
+ horizontalAlignment: Text.AlignHCenter
+ verticalAlignment: Text.AlignVCenter
+ }
+ }
+ MonthGrid {
+ id: grid
+ Layout.alignment: Qt.AlignTop
+ Layout.fillWidth: true
+ property int date: -1
+ property Item currentItem: null
+ delegate: Label {
+ id: gridDelegate
+ objectName: "gridDelegate"
+ text: delegateDay
+ opacity: model.month === grid.month ? 1 : .2
+ horizontalAlignment: Text.AlignHCenter
+ verticalAlignment: Text.AlignVCenter
+ font.bold: delegateDay === grid.date && delegateMonth === grid.month
+ color: delegateDay === grid.date && delegateMonth === grid.month && enabled ? "white" : "black"
+ property int delegateDay: model.day
+ property int delegateMonth: model.month
+ }
+ Component.onCompleted: updateDate()
+
+ Rectangle {
+ z: -1
+ id: highlight
+ x: grid.currentItem ? grid.currentItem.x + grid.currentItem.width / 2 - width / 2: 0
+ y: grid.currentItem ? grid.currentItem.y + grid.currentItem.height / 2- height / 2: 0
+ width: grid.currentItem ? grid.currentItem.width : 0
+ visible: grid.currentItem
+ height: width
+ color: enabled? "#80c342" : "#d6d6d6"
+ radius: width / 2
+ }
+
+ onMonthChanged: updateHighlightPosition()
+ onYearChanged: updateHighlightPosition()
+ onDateChanged: updateHighlightPosition()
+
+ function updateHighlightPosition() {
+ var date = new Date()
+
+ date.setFullYear(grid.year)
+ date.setMonth(grid.month)
+ date.setDate(grid.date)
+
+ var index = grid.source.indexOf(date)
+ var delegate = grid.contentItem.children[index]
+
+ if (delegate)
+ grid.currentItem = delegate
+ }
+
+ MouseArea {
+ anchors.fill: parent
+
+ onClicked: {
+ var item = grid.contentItem.childAt(mouse.x, mouse.y)
+
+ if (item) {
+ if (item.objectName !== "gridDelegate")
+ item = grid.contentItem.children[0]
+
+ if (!item)
+ return;
+
+ grid.currentItem = item
+ grid.date = item.delegateDay
+ grid.month = item.delegateMonth
+
+ var currentTime = TimeManager.time;
+ var newDate = new Date();
+
+ newDate.setFullYear(grid.year)
+ newDate.setMonth(grid.month)
+ newDate.setDate(grid.date)
+ newDate.setHours(currentTime.getHours());
+ newDate.setMinutes(currentTime.getMinutes());
+ newDate.setSeconds(currentTime.getSeconds());
+ TimeManager.time = newDate;
+ }
+ }
+ }
+ }
+ }
+}
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)
+ }
}
}
}
diff --git a/src/settingsui/timedate/TimezonesView.qml b/src/settingsui/timedate/TimezonesView.qml
index 4e09350..16ac10e 100644
--- a/src/settingsui/timedate/TimezonesView.qml
+++ b/src/settingsui/timedate/TimezonesView.qml
@@ -33,57 +33,45 @@
** $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
-
+import "../common"
Item {
id: root
+ property string title: qsTr("Timezone settings")
Component.onCompleted: timezone.text = TimezonesFilter.filter
- Column {
+ ColumnLayout {
id: content
anchors.fill: parent
- anchors.margins: Math.round(20 * Flat.FlatStyle.scaleFactor)
- spacing: Math.round(10 * Flat.FlatStyle.scaleFactor)
- Row {
- spacing: Math.round(10 * Flat.FlatStyle.scaleFactor)
+ anchors.margins: 20
+ spacing: 10
- TextLabel {
+ RowLayout {
+ spacing: 10
+
+ Label {
text: qsTr("Search area: ")
+ Layout.alignment: Qt.AlignVCenter
}
-
TextField {
id: timezone
text: ""
onTextChanged: TimezonesFilter.filter = timezone.text
+ Layout.alignment: Qt.AlignVCenter
}
}
-
- TableView {
- width: parent.width
- height: Math.round(parent.height - 40 * Flat.FlatStyle.scaleFactor)
- Layout.fillWidth: true
+ CustomTableView {
+ headerTexts: [qsTr("Timezone"), qsTr("Country")]
+ roleNames: ["id", "country"]
model: TimezonesFilter
- headerVisible: true
-
- TableViewColumn {
- role: "name"
- title: qsTr("Timezone")
- width: Math.round(parent.width * 0.66)
- }
- TableViewColumn {
- role: "country"
- title: qsTr("Country")
- width: Math.round(parent.width * 0.33)
- }
-
onClicked: {
- var val = model.itemFromRow(row);
+ var val = model.itemFromRow(index);
if (val !== "") {
TimeManager.timeZone = val;
stackView.pop();