aboutsummaryrefslogtreecommitdiffstats
path: root/examples/quickcontrols2
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@qt.io>2017-03-13 11:08:07 +0100
committerJ-P Nurmi <jpnurmi@qt.io>2017-03-13 10:19:30 +0000
commit7e382538fad487204885025f43409e265d58788c (patch)
treee433b3d47e8c2dbede434a72dee5b7eb82723d31 /examples/quickcontrols2
parentf722caec667342b0579aa894858ad553c70e55e0 (diff)
Wearable: cleanup SettingsPage
Replace the SettingsData (Item) type with QML Settings from Qt.labs.settings, and get rid of an unnecessary wrapper items and hard-coded image sizes. Change-Id: If41fbef5247c1648b881a97cbb94d4378b334f85 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'examples/quickcontrols2')
-rw-r--r--examples/quickcontrols2/wearable/qml/Settings/SettingsData.qml84
-rw-r--r--examples/quickcontrols2/wearable/qml/Settings/SettingsPage.qml164
-rw-r--r--examples/quickcontrols2/wearable/wearable.qrc1
3 files changed, 77 insertions, 172 deletions
diff --git a/examples/quickcontrols2/wearable/qml/Settings/SettingsData.qml b/examples/quickcontrols2/wearable/qml/Settings/SettingsData.qml
deleted file mode 100644
index 282bb772..00000000
--- a/examples/quickcontrols2/wearable/qml/Settings/SettingsData.qml
+++ /dev/null
@@ -1,84 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** 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 https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.7
-
-Item {
- property alias brightness: brightnessSettings
- property alias contrast: contrastSettings
- property alias wireless: wirelessSettings
- property alias bluetooth: bluetoothSettings
-
- QtObject {
- id: brightnessSettings
- property int value: 2
- property int min: 0
- property int max: 5
- property int steps: 1
- }
-
- QtObject {
- id: contrastSettings
- property int value: 6
- property int min: 0
- property int max: 10
- property int steps: 1
- }
-
- QtObject {
- id: wirelessSettings
- property bool state: false
- }
-
- QtObject {
- id: bluetoothSettings
- property bool state: true
- }
-}
diff --git a/examples/quickcontrols2/wearable/qml/Settings/SettingsPage.qml b/examples/quickcontrols2/wearable/qml/Settings/SettingsPage.qml
index 5b1c94e3..fa04f38f 100644
--- a/examples/quickcontrols2/wearable/qml/Settings/SettingsPage.qml
+++ b/examples/quickcontrols2/wearable/qml/Settings/SettingsPage.qml
@@ -50,118 +50,108 @@
import QtQuick 2.7
import QtQuick.Controls 2.0 as QQC2
+import Qt.labs.settings 1.0
import "../Style"
Item {
- Item {
- anchors.centerIn: parent
- width: UIStyle.visibleDiameter
- height: UIStyle.visibleRectHeight
-
- SettingsData {
- id: settingsData
- }
+ Settings {
+ id: settings
+ property alias wireless: wirelessSwitch.checked
+ property alias bluetooth: bluetoothSwitch.checked
+ property alias contrast: contrastSlider.value
+ property alias brightness: brightnessSlider.value
+ }
- QQC2.SwipeView {
- id: svSettingsContainer
+ QQC2.SwipeView {
+ id: svSettingsContainer
- anchors.fill: parent
+ anchors.fill: parent
- clip: true
- currentIndex: 0
+ currentIndex: 0
- Item {
- id: settingsPage1
+ Item {
+ id: settingsPage1
- Column {
- anchors.centerIn: parent
- spacing: 25
+ Column {
+ anchors.centerIn: parent
+ spacing: 25
- Row {
- spacing: 50
- Image {
- anchors.verticalCenter: parent.verticalCenter
- height: 64
- width: 64
- source: "../../images/settings/bluetooth.png"
- }
- QQC2.Switch {
- id: bluetoothSwitch
- anchors.verticalCenter: parent.verticalCenter
- checked: settingsData.bluetooth.state
- }
+ Row {
+ spacing: 50
+ Image {
+ anchors.verticalCenter: parent.verticalCenter
+ source: "../../images/settings/bluetooth.png"
}
- Row {
- spacing: 50
- Image {
- anchors.verticalCenter: parent.verticalCenter
- height: 64
- width: 64
- source: "../../images/settings/wifi.png"
- }
- QQC2.Switch {
- id: wirelessSwitch
- anchors.verticalCenter: parent.verticalCenter
- checked: settingsData.wireless.state
- }
+ QQC2.Switch {
+ id: bluetoothSwitch
+ anchors.verticalCenter: parent.verticalCenter
+ checked: settings.bluetooth
+ }
+ }
+ Row {
+ spacing: 50
+ Image {
+ anchors.verticalCenter: parent.verticalCenter
+ source: "../../images/settings/wifi.png"
+ }
+ QQC2.Switch {
+ id: wirelessSwitch
+ anchors.verticalCenter: parent.verticalCenter
+ checked: settings.wireless
}
}
}
+ }
- Item {
- id: settingsPage2
+ Item {
+ id: settingsPage2
+ Column {
+ anchors.centerIn: parent
+ spacing: 2
+
+ Column {
+ Image {
+ anchors.horizontalCenter: parent.horizontalCenter
+ source: "../../images/settings/brightness.png"
+ }
+ QQC2.Slider {
+ id: brightnessSlider
+ anchors.horizontalCenter: parent.horizontalCenter
+ from: 0
+ to: 5
+ stepSize: 1
+ value: settings.brightness
+ }
+ }
Column {
- anchors.centerIn: parent
spacing: 2
-
- Column {
- Image {
- anchors.horizontalCenter: parent.horizontalCenter
- height: 64
- width: 64
- source: "../../images/settings/brightness.png"
- }
- QQC2.Slider {
- id: brightnessSlider
- anchors.horizontalCenter: parent.horizontalCenter
- value: settingsData.brightness.value
- from: settingsData.brightness.min
- to: settingsData.brightness.max
- stepSize: settingsData.brightness.steps
- }
+ Image {
+ anchors.horizontalCenter: parent.horizontalCenter
+ source: "../../images/settings/contrast.png"
}
- Column {
- spacing: 2
- Image {
- anchors.horizontalCenter: parent.horizontalCenter
- height: 64
- width: 64
- source: "../../images/settings/contrast.png"
- }
- QQC2.Slider {
- id: contrastSlider
- anchors.horizontalCenter: parent.horizontalCenter
- value: settingsData.contrast.value
- from: settingsData.contrast.min
- to: settingsData.contrast.max
- stepSize: settingsData.contrast.steps
- }
+ QQC2.Slider {
+ id: contrastSlider
+ anchors.horizontalCenter: parent.horizontalCenter
+ from: 0
+ to: 10
+ stepSize: 1
+ value: settings.contrast
}
}
}
}
+ }
- QQC2.PageIndicator {
- id: pgSettingsIndicator
+ QQC2.PageIndicator {
+ id: pgSettingsIndicator
- anchors.bottom: svSettingsContainer.bottom
- anchors.bottomMargin: 1
- anchors.horizontalCenter: parent.horizontalCenter
+ anchors.bottom: svSettingsContainer.bottom
+ anchors.bottomMargin: 1
+ anchors.horizontalCenter: parent.horizontalCenter
- count: svSettingsContainer.count
- currentIndex: svSettingsContainer.currentIndex
- }
+ count: svSettingsContainer.count
+ currentIndex: svSettingsContainer.currentIndex
}
}
diff --git a/examples/quickcontrols2/wearable/wearable.qrc b/examples/quickcontrols2/wearable/wearable.qrc
index eee722c6..6d605fd0 100644
--- a/examples/quickcontrols2/wearable/wearable.qrc
+++ b/examples/quickcontrols2/wearable/wearable.qrc
@@ -13,7 +13,6 @@
<file>qml/Navigation/walk_route.json</file>
<file>qml/Notifications/notifications.js</file>
<file>qml/Notifications/NotificationsPage.qml</file>
- <file>qml/Settings/SettingsData.qml</file>
<file>qml/Settings/SettingsPage.qml</file>
<file>qml/Style/qmldir</file>
<file>qml/Style/PageIndicator.qml</file>