diff options
author | Shrikant Dhumal <shrikant.dhumal@qt.io> | 2016-12-16 19:20:45 -0800 |
---|---|---|
committer | J-P Nurmi <jpnurmi@qt.io> | 2017-03-13 07:29:41 +0000 |
commit | 7d0a2a1e55b615ae96766eefe8b066c2b7015140 (patch) | |
tree | 06e61dc25239cacef211ae09be9b8ce91813a5fe | |
parent | 5461df158c6076d3c3ed037e3051778018da7762 (diff) |
Add Wearable demo
Change-Id: I3e287b85517c04803964c068e32bf8b6bcae5cb6
Reviewed-by: J-P Nurmi <jpnurmi@qt.io>
75 files changed, 3279 insertions, 1 deletions
diff --git a/.gitignore b/.gitignore index 541fb64b12..b60a0dbb22 100644 --- a/.gitignore +++ b/.gitignore @@ -24,6 +24,7 @@ /examples/quickcontrols2/sidepanel/sidepanel /examples/quickcontrols2/swipetoremove/swipetoremove /examples/quickcontrols2/texteditor/texteditor +/examples/quickcontrols2/wearable/wearable /tests/auto/accessibility/tst_accessibility /tests/auto/applicationwindow/tst_applicationwindow diff --git a/examples/quickcontrols2/quickcontrols2.pro b/examples/quickcontrols2/quickcontrols2.pro index 3e145a41e8..858759fb9e 100644 --- a/examples/quickcontrols2/quickcontrols2.pro +++ b/examples/quickcontrols2/quickcontrols2.pro @@ -6,4 +6,5 @@ SUBDIRS += \ contactlist \ sidepanel \ swipetoremove \ - flatstyle + flatstyle \ + wearable diff --git a/examples/quickcontrols2/wearable/doc/images/qtquickcontrols2-wearable.png b/examples/quickcontrols2/wearable/doc/images/qtquickcontrols2-wearable.png Binary files differnew file mode 100644 index 0000000000..e01b3687b3 --- /dev/null +++ b/examples/quickcontrols2/wearable/doc/images/qtquickcontrols2-wearable.png diff --git a/examples/quickcontrols2/wearable/doc/src/qtquickcontrols2-wearable.qdoc b/examples/quickcontrols2/wearable/doc/src/qtquickcontrols2-wearable.qdoc new file mode 100644 index 0000000000..4ae3233c3a --- /dev/null +++ b/examples/quickcontrols2/wearable/doc/src/qtquickcontrols2-wearable.qdoc @@ -0,0 +1,162 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:FDL$ +** 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. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \example wearable + \title Qt Quick Controls 2 - Wearable Demo + \ingroup qtquickcontrols2-examples + \brief A QML app using Qt Quick Controls 2 and demonstrating how to create a + collection of wearable sub-apps using custom QML screens. + + \image qtquickcontrols2-wearable.png + + The \e {Wearable} demo is a collection of sub-apps. Each sub-app is + contained within its own .qml file, and integrated into \c LauncherMain.qml. + The app demonstrates following \l {Qt Quick} features: + + \list + \li Using custom types to create screens and screen controls. + \li Using Qt Quick Controls 2 with namespace. + \li Using layout components such as \l [QML] Column and \l [QML] Row + \li Using XMLHttpRequest to load data from local files. + \li Using PathView, \l [QML] Path, PathAttribute, and PathLine types to + lay out UI elements. + \endlist + + \section1 Creating the Main Window + + In \c wearable.qml, we use an ApplicationWindow to create the main application + window: + + \quotefromfile wearable/wearable.qml + \skipto import "qml/Common" + \printuntil visible + + This ApplicationWindow embeds a container that uses StackView for holding + the launch screen for sub-apps. \c LauncherMain is an initial item on + the stack view that represents Launcher sub-app. This \c MainContainer also + has functionality to navigate back to home screen which is enabled when + additional app screens are loaded in the StackView + + \quotefromfile wearable/qml/MainContainer.qml + \skipto QQC2.StackView { + \printuntil initialItem: LauncherMain { + + In LauncherMain, we use a ListModel type with \l ListElement types defined + explicitly to hold information about the sub-apps: + List elements are defined like other QML types except that they contain a + collection of \e role definitions instead of properties. Roles define both + how the data is accessed and include the data itself. For each list element, + we use the \c icon role to specify the launch icon for the feature. + + \quotefromfile wearable/qml/LauncherMain.qml + \skipto ListModel + \printuntil page: "Settings/SettingsMain.qml" + \printuntil } + + \section1 Using Custom Types + + In the app, we use the following custom types that are each defined in a + separate .qml file: + + \list + \li \c WSlider.qml + \li \c WSwitch.qml + \endlist + + In each \c .qml file that uses the custom types, we add an import statement + to include a directory called \e Common where the types are located: + + \quotefromfile wearable/qml/Settings/SettingsMain.qml + \skipto Common + \printuntil " + + \section1 Main Screens for Sub-apps + + In the demo, we use the following custom screen types that are each + defined in a separate .qml file: + + \list + \li \c AlarmsMain.qml + \li \c FitnessMain.qml + \li \c NavigationMain.qml + \li \c NotificationsMain.qml + \li \c SettingsMain.qml + \li \c WatchFaceMain.qml + \li \c WeatherMain.qml + \li \c LauncherMain.qml + \endlist + + Each sub-app also has its own JavaScript functions file that contains + routines to help acquire data to be displayed on the screen. It also + contains functions to help manipulate or convert the data. In some sub-apps + data acquisition is implemented using XMLHttpRequest to read from local + files. These files were generated by storing responses from remote servers + in JSON format. This code can be easily modified to acquire data from remote + servers. + Sub-apps are implemented with an assumption of lack of any input capabilities + of the device and they can be further enhanced based on what input methods + or communication means are offered by the wearable device under consideration. + Sub-apps use SwipeView as a container to display a set of pages within the + app. + + \section1 Navigation App + + This sub-app displays a walking route from source to destination. This route + is obtained as a response by invoking an API provided by + \l {http://www.openstreetmap.org/}. The response is in JSON format and the + corresponding JavaScript file associated with the app helps interpret the + response. Currently, it is not possible to specify the source and destination + from within the app but it can be easily added based on the device's + capabilities. For example, user input could be implemented as screens with + input fields, or can be communicated over Bluetooth/Wifi from a paired app + running on another device such as a smart phone or PC. + + \section1 Weather App + + This sub-app displays weather information for a day including temperature, + sunrise-sunset info, air pressure, and so on. This information is obtained + as a response to invoking \l {https://openweathermap.org/}. The response is + in JSON format and the corresponding JavaScript file associated + with the app helps interpret the response. As with the Navigation sub-app + this app can be modified by adding screens to accept location information to + obtain weather data for a given location. + + \section1 WatchFace App + + This sub-app displays a world clock for different cities. As of now, the list + of cities is hard-coded in the app but that can be changed based on the + input capabilities of the device. + + \section1 Other Sub-apps + + Remaining sub-apps are implemented to return static data for now but they + can be easily modified to process response data obtained from respective + services. + + \include examples-run.qdocinc +*/ diff --git a/examples/quickcontrols2/wearable/images/alarms/alarms.png b/examples/quickcontrols2/wearable/images/alarms/alarms.png Binary files differnew file mode 100644 index 0000000000..00ec663e2f --- /dev/null +++ b/examples/quickcontrols2/wearable/images/alarms/alarms.png diff --git a/examples/quickcontrols2/wearable/images/back.png b/examples/quickcontrols2/wearable/images/back.png Binary files differnew file mode 100644 index 0000000000..153162e7ce --- /dev/null +++ b/examples/quickcontrols2/wearable/images/back.png diff --git a/examples/quickcontrols2/wearable/images/background/HomeBackground.png b/examples/quickcontrols2/wearable/images/background/HomeBackground.png Binary files differnew file mode 100644 index 0000000000..1c6920e67f --- /dev/null +++ b/examples/quickcontrols2/wearable/images/background/HomeBackground.png diff --git a/examples/quickcontrols2/wearable/images/fitness/fitness.png b/examples/quickcontrols2/wearable/images/fitness/fitness.png Binary files differnew file mode 100644 index 0000000000..a8789a618d --- /dev/null +++ b/examples/quickcontrols2/wearable/images/fitness/fitness.png diff --git a/examples/quickcontrols2/wearable/images/fitness/man-running.png b/examples/quickcontrols2/wearable/images/fitness/man-running.png Binary files differnew file mode 100644 index 0000000000..5efab6e251 --- /dev/null +++ b/examples/quickcontrols2/wearable/images/fitness/man-running.png diff --git a/examples/quickcontrols2/wearable/images/fitness/man-walking.png b/examples/quickcontrols2/wearable/images/fitness/man-walking.png Binary files differnew file mode 100644 index 0000000000..01add53472 --- /dev/null +++ b/examples/quickcontrols2/wearable/images/fitness/man-walking.png diff --git a/examples/quickcontrols2/wearable/images/home.png b/examples/quickcontrols2/wearable/images/home.png Binary files differnew file mode 100644 index 0000000000..0d02f696b4 --- /dev/null +++ b/examples/quickcontrols2/wearable/images/home.png diff --git a/examples/quickcontrols2/wearable/images/navigation/end.png b/examples/quickcontrols2/wearable/images/navigation/end.png Binary files differnew file mode 100644 index 0000000000..3006c0f37d --- /dev/null +++ b/examples/quickcontrols2/wearable/images/navigation/end.png diff --git a/examples/quickcontrols2/wearable/images/navigation/leftturn.png b/examples/quickcontrols2/wearable/images/navigation/leftturn.png Binary files differnew file mode 100644 index 0000000000..3c416304f4 --- /dev/null +++ b/examples/quickcontrols2/wearable/images/navigation/leftturn.png diff --git a/examples/quickcontrols2/wearable/images/navigation/marker.png b/examples/quickcontrols2/wearable/images/navigation/marker.png Binary files differnew file mode 100644 index 0000000000..3006c0f37d --- /dev/null +++ b/examples/quickcontrols2/wearable/images/navigation/marker.png diff --git a/examples/quickcontrols2/wearable/images/navigation/rightturn.png b/examples/quickcontrols2/wearable/images/navigation/rightturn.png Binary files differnew file mode 100644 index 0000000000..a29ec6948d --- /dev/null +++ b/examples/quickcontrols2/wearable/images/navigation/rightturn.png diff --git a/examples/quickcontrols2/wearable/images/navigation/route.png b/examples/quickcontrols2/wearable/images/navigation/route.png Binary files differnew file mode 100644 index 0000000000..b8ac9d7ed2 --- /dev/null +++ b/examples/quickcontrols2/wearable/images/navigation/route.png diff --git a/examples/quickcontrols2/wearable/images/navigation/start.png b/examples/quickcontrols2/wearable/images/navigation/start.png Binary files differnew file mode 100644 index 0000000000..1adf0ac8d4 --- /dev/null +++ b/examples/quickcontrols2/wearable/images/navigation/start.png diff --git a/examples/quickcontrols2/wearable/images/navigation/straight.png b/examples/quickcontrols2/wearable/images/navigation/straight.png Binary files differnew file mode 100644 index 0000000000..e3c5bb5cc1 --- /dev/null +++ b/examples/quickcontrols2/wearable/images/navigation/straight.png diff --git a/examples/quickcontrols2/wearable/images/navigation/uturn.png b/examples/quickcontrols2/wearable/images/navigation/uturn.png Binary files differnew file mode 100644 index 0000000000..b6917f672a --- /dev/null +++ b/examples/quickcontrols2/wearable/images/navigation/uturn.png diff --git a/examples/quickcontrols2/wearable/images/notifications/avatarf.png b/examples/quickcontrols2/wearable/images/notifications/avatarf.png Binary files differnew file mode 100644 index 0000000000..c88edc60f5 --- /dev/null +++ b/examples/quickcontrols2/wearable/images/notifications/avatarf.png diff --git a/examples/quickcontrols2/wearable/images/notifications/avatarm.png b/examples/quickcontrols2/wearable/images/notifications/avatarm.png Binary files differnew file mode 100644 index 0000000000..f7abb4c9fc --- /dev/null +++ b/examples/quickcontrols2/wearable/images/notifications/avatarm.png diff --git a/examples/quickcontrols2/wearable/images/notifications/missedcall.png b/examples/quickcontrols2/wearable/images/notifications/missedcall.png Binary files differnew file mode 100644 index 0000000000..d05f17b35b --- /dev/null +++ b/examples/quickcontrols2/wearable/images/notifications/missedcall.png diff --git a/examples/quickcontrols2/wearable/images/notifications/notifications.png b/examples/quickcontrols2/wearable/images/notifications/notifications.png Binary files differnew file mode 100644 index 0000000000..c5c3ffb2b3 --- /dev/null +++ b/examples/quickcontrols2/wearable/images/notifications/notifications.png diff --git a/examples/quickcontrols2/wearable/images/settings/bluetooth.png b/examples/quickcontrols2/wearable/images/settings/bluetooth.png Binary files differnew file mode 100644 index 0000000000..2b2d0e7e35 --- /dev/null +++ b/examples/quickcontrols2/wearable/images/settings/bluetooth.png diff --git a/examples/quickcontrols2/wearable/images/settings/brightness.png b/examples/quickcontrols2/wearable/images/settings/brightness.png Binary files differnew file mode 100644 index 0000000000..846a896cd6 --- /dev/null +++ b/examples/quickcontrols2/wearable/images/settings/brightness.png diff --git a/examples/quickcontrols2/wearable/images/settings/contrast.png b/examples/quickcontrols2/wearable/images/settings/contrast.png Binary files differnew file mode 100644 index 0000000000..eb528eb8ba --- /dev/null +++ b/examples/quickcontrols2/wearable/images/settings/contrast.png diff --git a/examples/quickcontrols2/wearable/images/settings/settings.png b/examples/quickcontrols2/wearable/images/settings/settings.png Binary files differnew file mode 100644 index 0000000000..c42f7dc668 --- /dev/null +++ b/examples/quickcontrols2/wearable/images/settings/settings.png diff --git a/examples/quickcontrols2/wearable/images/settings/wifi.png b/examples/quickcontrols2/wearable/images/settings/wifi.png Binary files differnew file mode 100644 index 0000000000..42c92516d6 --- /dev/null +++ b/examples/quickcontrols2/wearable/images/settings/wifi.png diff --git a/examples/quickcontrols2/wearable/images/watchface/center.png b/examples/quickcontrols2/wearable/images/watchface/center.png Binary files differnew file mode 100644 index 0000000000..7fbd802a44 --- /dev/null +++ b/examples/quickcontrols2/wearable/images/watchface/center.png diff --git a/examples/quickcontrols2/wearable/images/watchface/clock-night.png b/examples/quickcontrols2/wearable/images/watchface/clock-night.png Binary files differnew file mode 100644 index 0000000000..698f57a5fb --- /dev/null +++ b/examples/quickcontrols2/wearable/images/watchface/clock-night.png diff --git a/examples/quickcontrols2/wearable/images/watchface/clock.png b/examples/quickcontrols2/wearable/images/watchface/clock.png Binary files differnew file mode 100644 index 0000000000..6e1c6eedc1 --- /dev/null +++ b/examples/quickcontrols2/wearable/images/watchface/clock.png diff --git a/examples/quickcontrols2/wearable/images/watchface/second.png b/examples/quickcontrols2/wearable/images/watchface/second.png Binary files differnew file mode 100644 index 0000000000..eee07efb50 --- /dev/null +++ b/examples/quickcontrols2/wearable/images/watchface/second.png diff --git a/examples/quickcontrols2/wearable/images/watchface/swissdaydial.png b/examples/quickcontrols2/wearable/images/watchface/swissdaydial.png Binary files differnew file mode 100644 index 0000000000..64136618c1 --- /dev/null +++ b/examples/quickcontrols2/wearable/images/watchface/swissdaydial.png diff --git a/examples/quickcontrols2/wearable/images/watchface/swissdayhour.png b/examples/quickcontrols2/wearable/images/watchface/swissdayhour.png Binary files differnew file mode 100644 index 0000000000..255985d2cb --- /dev/null +++ b/examples/quickcontrols2/wearable/images/watchface/swissdayhour.png diff --git a/examples/quickcontrols2/wearable/images/watchface/swissdayminute.png b/examples/quickcontrols2/wearable/images/watchface/swissdayminute.png Binary files differnew file mode 100644 index 0000000000..bc6992f849 --- /dev/null +++ b/examples/quickcontrols2/wearable/images/watchface/swissdayminute.png diff --git a/examples/quickcontrols2/wearable/images/watchface/swissnightdial.png b/examples/quickcontrols2/wearable/images/watchface/swissnightdial.png Binary files differnew file mode 100644 index 0000000000..e2590af4a3 --- /dev/null +++ b/examples/quickcontrols2/wearable/images/watchface/swissnightdial.png diff --git a/examples/quickcontrols2/wearable/images/watchface/swissnighthour.png b/examples/quickcontrols2/wearable/images/watchface/swissnighthour.png Binary files differnew file mode 100644 index 0000000000..1c6a61314c --- /dev/null +++ b/examples/quickcontrols2/wearable/images/watchface/swissnighthour.png diff --git a/examples/quickcontrols2/wearable/images/watchface/swissnightminute.png b/examples/quickcontrols2/wearable/images/watchface/swissnightminute.png Binary files differnew file mode 100644 index 0000000000..3353ba2cdd --- /dev/null +++ b/examples/quickcontrols2/wearable/images/watchface/swissnightminute.png diff --git a/examples/quickcontrols2/wearable/images/watchface/swissseconds.png b/examples/quickcontrols2/wearable/images/watchface/swissseconds.png Binary files differnew file mode 100644 index 0000000000..66b4f3fa55 --- /dev/null +++ b/examples/quickcontrols2/wearable/images/watchface/swissseconds.png diff --git a/examples/quickcontrols2/wearable/images/watchface/watch.png b/examples/quickcontrols2/wearable/images/watchface/watch.png Binary files differnew file mode 100644 index 0000000000..299858b78b --- /dev/null +++ b/examples/quickcontrols2/wearable/images/watchface/watch.png diff --git a/examples/quickcontrols2/wearable/images/weather/humidity.png b/examples/quickcontrols2/wearable/images/weather/humidity.png Binary files differnew file mode 100644 index 0000000000..ef9ed9dea8 --- /dev/null +++ b/examples/quickcontrols2/wearable/images/weather/humidity.png diff --git a/examples/quickcontrols2/wearable/images/weather/pressure.png b/examples/quickcontrols2/wearable/images/weather/pressure.png Binary files differnew file mode 100644 index 0000000000..7850609ed7 --- /dev/null +++ b/examples/quickcontrols2/wearable/images/weather/pressure.png diff --git a/examples/quickcontrols2/wearable/images/weather/sunrise.png b/examples/quickcontrols2/wearable/images/weather/sunrise.png Binary files differnew file mode 100644 index 0000000000..70a9a969e6 --- /dev/null +++ b/examples/quickcontrols2/wearable/images/weather/sunrise.png diff --git a/examples/quickcontrols2/wearable/images/weather/sunset.png b/examples/quickcontrols2/wearable/images/weather/sunset.png Binary files differnew file mode 100644 index 0000000000..01bb9ec897 --- /dev/null +++ b/examples/quickcontrols2/wearable/images/weather/sunset.png diff --git a/examples/quickcontrols2/wearable/images/weather/temperature.png b/examples/quickcontrols2/wearable/images/weather/temperature.png Binary files differnew file mode 100644 index 0000000000..5d7faa9984 --- /dev/null +++ b/examples/quickcontrols2/wearable/images/weather/temperature.png diff --git a/examples/quickcontrols2/wearable/images/weather/weather.png b/examples/quickcontrols2/wearable/images/weather/weather.png Binary files differnew file mode 100644 index 0000000000..0530d47b60 --- /dev/null +++ b/examples/quickcontrols2/wearable/images/weather/weather.png diff --git a/examples/quickcontrols2/wearable/images/weather/wind.png b/examples/quickcontrols2/wearable/images/weather/wind.png Binary files differnew file mode 100644 index 0000000000..c728fcc0f1 --- /dev/null +++ b/examples/quickcontrols2/wearable/images/weather/wind.png diff --git a/examples/quickcontrols2/wearable/qml/Alarms/AlarmsMain.qml b/examples/quickcontrols2/wearable/qml/Alarms/AlarmsMain.qml new file mode 100644 index 0000000000..64d4764856 --- /dev/null +++ b/examples/quickcontrols2/wearable/qml/Alarms/AlarmsMain.qml @@ -0,0 +1,188 @@ +/**************************************************************************** +** +** 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 +import QtQuick.Controls 2.0 as QQC2 +import "../Common" +import "alarms.js" as AlarmData + +PageContainer { + Rectangle { + anchors.centerIn: parent + + width: UIStyle.visibleDiameter + height: width + + radius: width / 2 + + color: "transparent" + + QQC2.SwipeView { + id: svAlarmsContainer + + anchors.fill: parent + anchors.bottomMargin: 50 + + clip: true + currentIndex: 0 + + Item { + id: alarmsPage1 + + Column { + anchors.centerIn: parent + width: parent.width + spacing: 30 + + Row { + anchors.right: parent.right + anchors.rightMargin: 40 + height: 30 + WSwitch { + id: alarmsPage1State + checked: AlarmData.weekdaysAlarmDefaultState() + } + } + + Text { + anchors.horizontalCenter: parent.horizontalCenter + height: 30 + text: AlarmData.weekdaysAlarm() + font.bold: alarmsPage1State.checked + font.pixelSize: alarmsPage1State.checked ? + UIStyle.fontSizeXL : UIStyle.fontSizeL + font.letterSpacing: 4 + color: UIStyle.colorQtGray1 + } + + Text { + anchors.horizontalCenter: parent.horizontalCenter + height: 30 + text: qsTr("Week Days") + font.pixelSize: UIStyle.fontSizeS + font.italic: true + font.bold: true + font.letterSpacing: 1 + color: UIStyle.colorQtGray2 + } + } + } + + Item { + id: alarmsPage2 + + Column { + anchors.centerIn: parent + width: parent.width + spacing: 30 + + Row { + anchors.right: parent.right + anchors.rightMargin: 40 + height: 30 + WSwitch { + id: alarmsPage2State + checked: AlarmData.weekendAlarmDefaultState() + } + } + + Text { + anchors.horizontalCenter: parent.horizontalCenter + height: 30 + text: AlarmData.weekendAlarm() + font.bold: alarmsPage2State.checked + font.pixelSize: alarmsPage2State.checked ? + UIStyle.fontSizeXL : UIStyle.fontSizeL + font.letterSpacing: 4 + color: UIStyle.colorQtGray1 + } + + Text { + anchors.horizontalCenter: parent.horizontalCenter + height: 30 + text: qsTr("Week Ends") + font.pixelSize: UIStyle.fontSizeS + font.italic: true + font.bold: true + font.letterSpacing: 1 + color: UIStyle.colorQtGray2 + } + } + } + } + + QQC2.PageIndicator { + id: pgAlarmsIndicator + + anchors.bottom: svAlarmsContainer.bottom + anchors.bottomMargin: 1 + anchors.horizontalCenter: parent.horizontalCenter + + count: svAlarmsContainer.count + currentIndex: svAlarmsContainer.currentIndex + + delegate: Rectangle { + implicitWidth: 8 + implicitHeight: 8 + + radius: width / 2 + color: UIStyle.colorQtGray3 + + opacity: index === pgAlarmsIndicator.currentIndex ? 1.0 : 0.35 + + Behavior on opacity { + OpacityAnimator { + duration: 100 + } + } + } + } + } +} diff --git a/examples/quickcontrols2/wearable/qml/Alarms/alarms.js b/examples/quickcontrols2/wearable/qml/Alarms/alarms.js new file mode 100644 index 0000000000..7e81b18381 --- /dev/null +++ b/examples/quickcontrols2/wearable/qml/Alarms/alarms.js @@ -0,0 +1,65 @@ +/**************************************************************************** +** +** 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$ +** +****************************************************************************/ + +function weekendAlarm() { + return "07:30 AM"; +} + +function weekendAlarmDefaultState() { + return false; +} + +function weekdaysAlarm() { + return "06:00 AM"; +} + +function weekdaysAlarmDefaultState() { + return true; +} diff --git a/examples/quickcontrols2/wearable/qml/Common/PageContainer.qml b/examples/quickcontrols2/wearable/qml/Common/PageContainer.qml new file mode 100644 index 0000000000..19bff97438 --- /dev/null +++ b/examples/quickcontrols2/wearable/qml/Common/PageContainer.qml @@ -0,0 +1,59 @@ +/**************************************************************************** +** +** 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 { + signal done() + + function init() { + + } +} diff --git a/examples/quickcontrols2/wearable/qml/Common/UIStyle.qml b/examples/quickcontrols2/wearable/qml/Common/UIStyle.qml new file mode 100644 index 0000000000..e6ff6f6b43 --- /dev/null +++ b/examples/quickcontrols2/wearable/qml/Common/UIStyle.qml @@ -0,0 +1,95 @@ +/**************************************************************************** +** +** 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 + +pragma Singleton + +QtObject { + id: uiStyle + + // Font Sizes + readonly property int fontSizeXXS: 10 + readonly property int fontSizeXS: 15 + readonly property int fontSizeS: 20 + readonly property int fontSizeM: 25 + readonly property int fontSizeL: 30 + readonly property int fontSizeXL: 35 + readonly property int fontSizeXXL: 40 + + // Display Dimensions + readonly property int displayWidth: 320 + readonly property int displayHeight: 320 + + readonly property int containerWidth: 250 + readonly property int containerHeight: 250 + + readonly property int visibleRectWidth: 223 + readonly property int visibleRectHeight: 223 + readonly property int visibleDiameter: 316 + + // Color Scheme + // Green + readonly property color colorQtPrimGreen: "#41cd52" + readonly property color colorQtAuxGreen1: "#21be2b" + readonly property color colorQtAuxGreen2: "#17a81a" + + // Gray + readonly property color colorQtGray1: "#09102b" + readonly property color colorQtGray2: "#222840" + readonly property color colorQtGray3: "#3a4055" + readonly property color colorQtGray4: "#53586b" + readonly property color colorQtGray5: "#53586b" + readonly property color colorQtGray6: "#848895" + readonly property color colorQtGray7: "#9d9faa" + readonly property color colorQtGray8: "#b5b7bf" + readonly property color colorQtGray9: "#cecfd5" + readonly property color colorQtGray10: "#f3f3f4" +} diff --git a/examples/quickcontrols2/wearable/qml/Common/WSlider.qml b/examples/quickcontrols2/wearable/qml/Common/WSlider.qml new file mode 100644 index 0000000000..d8eae3b051 --- /dev/null +++ b/examples/quickcontrols2/wearable/qml/Common/WSlider.qml @@ -0,0 +1,87 @@ +/**************************************************************************** +** +** 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 +import QtQuick.Controls 2.0 +import "." + +Slider { + id: control + + background: Rectangle { + x: control.leftPadding + y: control.topPadding + control.availableHeight / 2 - height / 2 + implicitWidth: 200 + implicitHeight: 4 + width: control.availableWidth + height: implicitHeight + radius: 2 + color: UIStyle.colorQtGray3 + + Rectangle { + width: control.visualPosition * parent.width + height: parent.height + color: UIStyle.colorQtAuxGreen2 + radius: 2 + } + } + + handle: Rectangle { + x: control.leftPadding + + control.visualPosition + * (control.availableWidth - width) + y: control.topPadding + control.availableHeight / 2 - height / 2 + implicitWidth: 20 + implicitHeight: 15 + radius: 5 + color: control.pressed ? "#f0f0f0" : "#f6f6f6" + border.color: UIStyle.colorQtGray7 + } +} diff --git a/examples/quickcontrols2/wearable/qml/Common/WSwitch.qml b/examples/quickcontrols2/wearable/qml/Common/WSwitch.qml new file mode 100644 index 0000000000..33a2c15b72 --- /dev/null +++ b/examples/quickcontrols2/wearable/qml/Common/WSwitch.qml @@ -0,0 +1,82 @@ +/**************************************************************************** +** +** 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 +import QtQuick.Controls 2.0 +import "." + +Switch { + id: control + + indicator: Rectangle { + implicitWidth: 48 + implicitHeight: 26 + x: control.leftPadding + y: parent.height / 2 - height / 2 + radius: 13 + color: control.checked ? UIStyle.colorQtAuxGreen2 : "#E6173D" + border.color: control.checked ? + UIStyle.colorQtAuxGreen2 + : UIStyle.colorQtGray6 + + Rectangle { + x: control.checked ? parent.width - width : 0 + width: 26 + height: 26 + radius: 13 + color: control.down ? UIStyle.colorQtGray6 : UIStyle.colorQtGray10 + border.color: + control.checked ? + (control.down ? UIStyle.colorQtAuxGreen2 + : UIStyle.colorQtAuxGreen1) + : "#999999" + } + } +} diff --git a/examples/quickcontrols2/wearable/qml/Common/qmldir b/examples/quickcontrols2/wearable/qml/Common/qmldir new file mode 100644 index 0000000000..6563bd8cb1 --- /dev/null +++ b/examples/quickcontrols2/wearable/qml/Common/qmldir @@ -0,0 +1,4 @@ +singleton UIStyle 1.0 UIStyle.qml +WSlider 1.0 WSlider.qml +WSwitch 1.0 WSwitch.qml +PageContainer 1.0 PageContainer.qml diff --git a/examples/quickcontrols2/wearable/qml/Fitness/FitnessMain.qml b/examples/quickcontrols2/wearable/qml/Fitness/FitnessMain.qml new file mode 100644 index 0000000000..f3f9f5ff3e --- /dev/null +++ b/examples/quickcontrols2/wearable/qml/Fitness/FitnessMain.qml @@ -0,0 +1,165 @@ +/**************************************************************************** +** +** 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 +import QtQuick.Controls 2.0 as QQ2 +import "../Common" +import "fitness.js" as FitnessData + +PageContainer { + Rectangle { + anchors.centerIn: parent + + width: UIStyle.visibleDiameter + height: UIStyle.visibleRectHeight + + color: "transparent" + + QQ2.SwipeView { + id: svFitnessContainer + + anchors.fill: parent + + clip: true + currentIndex: 0 + + Item { + id: fitnessPage1 + + Column { + anchors.centerIn: parent + spacing: 15 + + Text { + anchors.horizontalCenter: parent.horizontalCenter + text: qsTr("Steps: ") + FitnessData.getSteps() + font.italic: true + font.pixelSize: UIStyle.fontSizeM + color: UIStyle.colorQtGray1 + } + Image { + anchors.horizontalCenter: parent.horizontalCenter + height: 64 + width: 64 + source: "../../images/fitness/man-walking.png" + } + Text { + anchors.horizontalCenter: parent.horizontalCenter + text: qsTr("Calories: ") + FitnessData.getCalories() + font.pixelSize: UIStyle.fontSizeS + font.italic: true + color: UIStyle.colorQtGray3 + } + } + } + + Item { + id: fitnessPage2 + + Column { + anchors.centerIn: parent + spacing: 15 + + Text { + anchors.horizontalCenter: parent.horizontalCenter + text: qsTr("Distance: ") + + FitnessData.getDistance() + + qsTr(" miles") + font.italic: true + font.pixelSize: UIStyle.fontSizeM + color: UIStyle.colorQtGray1 + } + Image { + anchors.horizontalCenter: parent.horizontalCenter + height: 64 + width: 64 + source: "../../images/fitness/man-running.png" + } + Text { + anchors.horizontalCenter: parent.horizontalCenter + text: qsTr("Time: ") + + FitnessData.getTime() + + qsTr(" mins") + font.pixelSize: UIStyle.fontSizeS + font.italic: true + color: UIStyle.colorQtGray3 + } + } + } + } + + QQ2.PageIndicator { + id: pgFitnessIndicator + + anchors.bottom: svFitnessContainer.bottom + anchors.bottomMargin: 1 + anchors.horizontalCenter: parent.horizontalCenter + + count: svFitnessContainer.count + currentIndex: svFitnessContainer.currentIndex + + delegate: Rectangle { + implicitWidth: 8 + implicitHeight: 8 + + radius: width / 2 + color: UIStyle.colorQtGray3 + + opacity: index === pgFitnessIndicator.currentIndex ? 1.0 : 0.35 + + Behavior on opacity { + OpacityAnimator { + duration: 100 + } + } + } + } + } +} diff --git a/examples/quickcontrols2/wearable/qml/Fitness/fitness.js b/examples/quickcontrols2/wearable/qml/Fitness/fitness.js new file mode 100644 index 0000000000..7e159e2aaf --- /dev/null +++ b/examples/quickcontrols2/wearable/qml/Fitness/fitness.js @@ -0,0 +1,65 @@ +/**************************************************************************** +** +** 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$ +** +****************************************************************************/ + +function getSteps() { + return 105; +} + +function getCalories() { + return 150; +} + +function getDistance() { + return 10; +} + +function getTime() { + return "00:30"; +} diff --git a/examples/quickcontrols2/wearable/qml/LauncherMain.qml b/examples/quickcontrols2/wearable/qml/LauncherMain.qml new file mode 100644 index 0000000000..53fb350a04 --- /dev/null +++ b/examples/quickcontrols2/wearable/qml/LauncherMain.qml @@ -0,0 +1,230 @@ +/**************************************************************************** +** +** 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 +import "WatchFace" +import "Fitness" +import "Navigation" +import "Common" + +PageContainer { + Item { + anchors.centerIn: parent + + width: UIStyle.visibleDiameter + height: UIStyle.visibleDiameter + + ListModel { + id: viewModel + + ListElement { // 0 + title: qsTr("World Clock") + icon: "../images/watchface/watch.png" + page: "WatchFace/WatchFaceMain.qml" + background: "../images/background/HomeBackground.png" + } + ListElement { // 1 + title: qsTr("Navigation") + icon: "../images/navigation/route.png" + page: "Navigation/NavigationMain.qml" + background: "../images/background/HomeBackground.png" + } + ListElement { // 2 + title: qsTr("Weather") + icon: "../images/weather/weather.png" + page: "Weather/WeatherMain.qml" + background: "../images/background/HomeBackground.png" + } + ListElement { // 3 + title: qsTr("Fitness") + icon: "../images/fitness/fitness.png" + page: "Fitness/FitnessMain.qml" + background: "../images/background/HomeBackground.png" + } + ListElement { // 4 + title: qsTr("Notifications") + icon: "../images/notifications/notifications.png" + page: "Notifications/NotificationsMain.qml" + background: "../images/background/HomeBackground.png" + } + ListElement { // 5 + title: qsTr("Alarm") + icon: "../images/alarms/alarms.png" + page: "Alarms/AlarmsMain.qml" + background: "../images/background/HomeBackground.png" + } + ListElement { // 6 + title: qsTr("Settings") + icon: "../images/settings/settings.png" + page: "Settings/SettingsMain.qml" + background: "../images/background/HomeBackground.png" + } + } + + PathView { + id: circularView + property int objSize: 60 + property int cX: parent.width / 2 + property int cY: parent.height / 2 + + currentIndex: 0 + + anchors.fill: parent + model: viewModel + delegate: pathDelegate + snapMode: PathView.SnapToItem + + path: Path { + startX: circularView.cX + startY: circularView.cY + PathAttribute { + name: "itemOpacity" + value: 1.0 + } + PathLine { + x: circularView.width - circularView.objSize + y: circularView.cY + } + PathAttribute { + name: "itemOpacity" + value: 0.7 + } + PathArc { + x: circularView.objSize + y: circularView.cY + radiusX: circularView.cX - circularView.objSize + radiusY: circularView.cY - circularView.objSize + useLargeArc: true + direction: PathArc.Clockwise + } + PathAttribute { + name: "itemOpacity" + value: 0.5 + } + PathArc { + x: circularView.width - circularView.objSize + y: circularView.cY + radiusX: circularView.cX - circularView.objSize + radiusY: circularView.cY - circularView.objSize + useLargeArc: true + direction: PathArc.Clockwise + } + PathAttribute { + name: "itemOpacity" + value: 0.3 + } + } + } + + Component { + id: pathDelegate + + Item { + id: wrapper + + width: childrenRect.width + height: childrenRect.height + + Column { + opacity: wrapper.PathView.itemOpacity + Item { + anchors.horizontalCenter: parent.horizontalCenter + height: wrapper.PathView.view.objSize + width: wrapper.PathView.view.objSize + + Image { + anchors.fill: parent + source: icon + } + Rectangle { + anchors.fill: parent + radius: width / 2 + color: "transparent" + + border.width: 3 + border.color: wrapper.PathView.isCurrentItem ? + "transparent" + : UIStyle.colorQtGray4 + } + } + + Text { + id: appTitle + + opacity: wrapper.PathView.isCurrentItem + && (wrapper.PathView.itemOpacity === 1.0) + + anchors.horizontalCenter: parent.horizontalCenter + font.bold: true + font.pixelSize: UIStyle.fontSizeS + font.letterSpacing: 1 + color: UIStyle.colorQtGray1 + text: title + } + } + + MouseArea { + id: pathItemMouseArea + anchors.fill: parent + onClicked: { + if (circularView.currentIndex === index) + loadPage() + else + circularView.currentIndex = index + } + } + function loadPage() { + appBackgroundImg.source = background + stackView.push(Qt.resolvedUrl(page)) + } + } + } + } +} diff --git a/examples/quickcontrols2/wearable/qml/MainContainer.qml b/examples/quickcontrols2/wearable/qml/MainContainer.qml new file mode 100644 index 0000000000..1408bdc743 --- /dev/null +++ b/examples/quickcontrols2/wearable/qml/MainContainer.qml @@ -0,0 +1,222 @@ +/**************************************************************************** +** +** 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 +import QtQuick.Layouts 1.3 +import QtQuick.Controls 2.0 as QQC2 +import QtQml.StateMachine 1.0 as DeclSM +import "WatchFace" +import "Fitness" +import "Navigation" +import "Common" + +Item { + Image { + id: appBackgroundImg + anchors.fill: parent + source: "../images/background/HomeBackground.png" + } + + Item { + id: homeCntrl + + z: 2 + + anchors.top: parent.top + anchors.left: parent.left + anchors.right: parent.right + + height: 40 + + states: State { + name: "slideOut" + + AnchorChanges { + target: homeButton + anchors.bottom: homeCntrl.bottom + } + } + + transitions: Transition { + AnchorAnimation { + duration: 250 + } + } + + state: (stackView.depth > 1) ? "slideOut" : "" + + Item { + id: homeButton + + anchors.horizontalCenter: parent.horizontalCenter + anchors.bottom: parent.top + + height: parent.height + + Rectangle { + height: parent.height * 4 + width: height + radius: width / 2 + + anchors.horizontalCenter: parent.horizontalCenter + anchors.verticalCenter: parent.top + anchors.verticalCenterOffset: -height / 4 + + color: UIStyle.colorQtGray2 + } + + Image { + height: parent.height + width: height + + anchors.horizontalCenter: parent.horizontalCenter + + source: "../images/home.png" + } + } + + MouseArea { + id: homeCntrlMArea + anchors.fill: parent + onClicked: { + homeCntrl.homeKeyPressed() + } + } + + function homeKeyPressed() { + stackView.pop() + } + } + + QQC2.StackView { + id: stackView + + anchors.top: homeCntrl.bottom + anchors.bottom: backCntrl.top + + width: parent.width + + focus: true + + initialItem: LauncherMain { + } + } + + Item { + id: backCntrl + + z: 2 + + anchors.bottom: parent.bottom + anchors.left: parent.left + anchors.right: parent.right + + height: 40 + + states: State { + name: "slideOut" + + AnchorChanges { + target: backButton + anchors.top: backCntrl.top + } + } + + transitions: Transition { + AnchorAnimation { + duration: 250 + } + } + + state: (stackView.depth > 1) ? "slideOut" : "" + + Item { + id: backButton + + anchors.horizontalCenter: parent.horizontalCenter + anchors.top: parent.bottom + + height: parent.height + + Rectangle { + height: parent.height * 4 + width: height + radius: width / 2 + + anchors.horizontalCenter: parent.horizontalCenter + anchors.verticalCenter: parent.bottom + anchors.verticalCenterOffset: height / 4 + + color: UIStyle.colorQtGray2 + } + + Image { + height: parent.height + width: height + + anchors.horizontalCenter: parent.horizontalCenter + + source: "../images/back.png" + } + } + + MouseArea { + id: backCntrlMArea + anchors.fill: parent + onClicked: { + backCntrl.backKeyPressed() + } + } + + function backKeyPressed() { + stackView.pop() + } + } +} diff --git a/examples/quickcontrols2/wearable/qml/Navigation/NavigationMain.qml b/examples/quickcontrols2/wearable/qml/Navigation/NavigationMain.qml new file mode 100644 index 0000000000..989c04aeca --- /dev/null +++ b/examples/quickcontrols2/wearable/qml/Navigation/NavigationMain.qml @@ -0,0 +1,126 @@ +/**************************************************************************** +** +** 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 +import QtQuick.Layouts 1.3 +import "../Common" +import "navigation.js" as NavigationData + +PageContainer { + Item { + anchors.centerIn: parent + + width: UIStyle.visibleDiameter + height: UIStyle.visibleRectHeight + + Column { + anchors.fill: parent + spacing: 2 + + Rectangle { + id: titleRowCntr + + anchors.horizontalCenter: parent.horizontalCenter + width: parent.width + height: 64 + + color: UIStyle.colorQtGray9 + + Row { + spacing: 10 + anchors.centerIn: parent + + Image { + anchors.verticalCenter: parent.verticalCenter + height: 64 + width: 64 + source: "../../images/navigation/route.png" + fillMode: Image.PreserveAspectCrop + } + Text { + anchors.verticalCenter: parent.verticalCenter + text: qsTr("Walking") + font.pixelSize: UIStyle.fontSizeM + font.letterSpacing: 2 + color: UIStyle.colorQtGray2 + } + } + } + + ListModel { + id: routeModel + } + + ListView { + id: routeView + + width: parent.width + height: UIStyle.visibleRectHeight - titleRowCntr.height + property var imageList: ["straight.png", + "leftturn.png", + "rightturn.png", + "uturn.png", + "start.png", + "end.png"] + + clip: true + focus: true + boundsBehavior: Flickable.StopAtBounds + snapMode: ListView.SnapToItem + currentIndex: 0 + model: routeModel + delegate: RouteElement {} + } + } + } + Component.onCompleted: { + NavigationData.requestNavigationRoute(routeModel) + } +} diff --git a/examples/quickcontrols2/wearable/qml/Navigation/RouteElement.qml b/examples/quickcontrols2/wearable/qml/Navigation/RouteElement.qml new file mode 100644 index 0000000000..2b15cd968e --- /dev/null +++ b/examples/quickcontrols2/wearable/qml/Navigation/RouteElement.qml @@ -0,0 +1,103 @@ +/**************************************************************************** +** +** 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 +import "../Common" + +Rectangle { + color: UIStyle.colorQtGray8 + + width: UIStyle.visibleDiameter + height: UIStyle.visibleRectHeight - titleRowCntr.height + + Row { + anchors.centerIn: parent + width: UIStyle.visibleRectWidth + height: parent.height + + spacing: 5 + + Image { + id: img + anchors.verticalCenter: parent.verticalCenter + height: 64 + width: 64 + source: "../../images/navigation/" + navImage + fillMode: Image.PreserveAspectFit + } + + Column { + height: parent.height + width: parent.width - img.width + + anchors.verticalCenter: parent.verticalCenter + spacing: 5 + + Text { + width: parent.width + wrapMode: Text.WordWrap + text: navInstruction + font.pixelSize: UIStyle.fontSizeS + verticalAlignment: Text.AlignVCenter + padding: 1 + color: UIStyle.colorQtGray1 + } + Text { + width: parent.width + wrapMode: Text.WordWrap + text: navAuxInfo + font.pixelSize: UIStyle.fontSizeXS + verticalAlignment: Text.AlignVCenter + padding: 1 + color: UIStyle.colorQtGray2 + } + } + } +} diff --git a/examples/quickcontrols2/wearable/qml/Navigation/navigation.js b/examples/quickcontrols2/wearable/qml/Navigation/navigation.js new file mode 100644 index 0000000000..0414731d47 --- /dev/null +++ b/examples/quickcontrols2/wearable/qml/Navigation/navigation.js @@ -0,0 +1,131 @@ +/**************************************************************************** +** +** 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$ +** +****************************************************************************/ + +function requestNavigationRoute(rModel) { + var xhr = new XMLHttpRequest; + xhr.open("GET", "walk_route.json"); + xhr.onreadystatechange = function () { + if (xhr.readyState === XMLHttpRequest.DONE) { + var a = JSON.parse(xhr.responseText); + var steps = a.routes[0].legs[0].steps; + + for (var step in steps) { + var maneuver = steps[step].maneuver; + var duration = steps[step].duration; + var distance = steps[step].distance; + + rModel.append({ + navInstruction: maneuver.instruction, + navImage: getNavigationImage( + maneuver.type, + maneuver.modifier, + routeView.imageList), + navAuxInfo: getAuxInfo(distance, + duration) + }); + } + } + } + xhr.send(); +} + +function getNavigationImage(maneuverType, maneuverModifier, imageList) { + var imageToReturn; + if (maneuverType === "depart") { + imageToReturn = imageList[4]; + } else if (maneuverType === "arrive") { + imageToReturn = imageList[5]; + } else if (maneuverType === "turn") { + if (maneuverModifier.search("left") >= 0) + imageToReturn = imageList[1]; + else if (maneuverModifier.search("right") >= 0) + imageToReturn = imageList[2]; + else + imageToReturn = imageList[0]; + } else { + if (maneuverModifier === "uturn") { + imageToReturn = imageList[3]; + } else { + imageToReturn = imageList[0]; + } + } + + return imageToReturn; +} + +function getAuxInfo(distInMeters, timeInSecs) { + var distance = convertDistance(distInMeters); + if (distance.length > 0) + return "Distance: " + distance + "\nTime: " + formatSeconds( + timeInSecs); + else + return ""; +} + +function convertDistance(meter) { + var dist = ""; + var feet = (meter * 0.3048).toPrecision(6); + var miles = (meter * 0.000621371).toPrecision(6); + + if (Math.floor(miles) > 1) { + dist += Math.floor(miles) + " mi"; + feet = ((miles - Math.floor(miles)) * 0.3048).toPrecision(6); + } + if (Math.floor(feet) > 1) + dist += Math.floor(feet) + " ft"; + + return dist +} + +function formatSeconds(seconds) { + var date = new Date(1970, 0, 1); + date.setSeconds(seconds); + return date.toTimeString().replace(/.*(\d{2}:\d{2}:\d{2}).*/, "$1"); +} diff --git a/examples/quickcontrols2/wearable/qml/Navigation/walk_route.json b/examples/quickcontrols2/wearable/qml/Navigation/walk_route.json new file mode 100644 index 0000000000..e69b5cc187 --- /dev/null +++ b/examples/quickcontrols2/wearable/qml/Navigation/walk_route.json @@ -0,0 +1 @@ +{"routes":[{"legs":[{"steps":[{"intersections":[{"out":0,"entry":[true],"bearings":[144],"location":[-122.394553,37.795984]},{"out":1,"location":[-122.393896,37.795268],"bearings":[60,150,225,330],"entry":[true,true,true,false],"in":3},{"out":1,"location":[-122.393179,37.79453],"bearings":[60,135,180,225,315],"entry":[true,true,true,true,false],"in":4},{"out":1,"location":[-122.393072,37.79443],"bearings":[45,135,225,315],"entry":[true,true,true,false],"in":3},{"out":1,"location":[-122.392787,37.79415],"bearings":[60,135,315],"entry":[true,true,false],"in":2},{"out":1,"location":[-122.392537,37.793915],"bearings":[45,135,225,315],"entry":[true,true,true,false],"in":3},{"out":0,"location":[-122.392448,37.793831],"bearings":[135,225,315],"entry":[true,true,false],"in":2}],"geometry":"{_ueF|d`jVRQdB}ARQh@g@XUVWVW^a@RUv@w@l@q@PQNQ","maneuver":{"bearing_after":144,"location":[-122.394553,37.795984],"bearing_before":0,"type":"depart","instruction":"Head southeast on The Embarcadero"},"duration":230.8,"distance":314.8,"name":"The Embarcadero","mode":"walking"},{"intersections":[{"out":2,"location":[-122.392361,37.793748],"bearings":[45,135,225,315],"entry":[true,true,true,false],"in":3}],"geometry":"}qteFfw_jVHJBDHJ","maneuver":{"bearing_after":225,"type":"turn","modifier":"right","bearing_before":140,"location":[-122.392361,37.793748],"instruction":"Turn right"},"duration":13.2,"distance":18.5,"name":"","mode":"walking"},{"intersections":[{"out":1,"location":[-122.39251,37.793631],"bearings":[45,135,225,315],"entry":[false,true,true,true],"in":0},{"out":1,"location":[-122.391284,37.792459],"bearings":[45,150,225,330],"entry":[true,true,true,false],"in":3},{"out":1,"location":[-122.391217,37.792342],"bearings":[45,165,225,330],"entry":[true,true,true,false],"in":3},{"out":1,"location":[-122.391165,37.792231],"bearings":[45,165,225,345],"entry":[true,true,true,false],"in":3},{"out":0,"location":[-122.390884,37.791536],"bearings":[150,285,345],"entry":[true,true,false],"in":2},{"out":1,"location":[-122.390254,37.790827],"bearings":[45,135,210,315],"entry":[true,true,true,false],"in":3},{"out":1,"location":[-122.390144,37.790745],"bearings":[45,135,225,315],"entry":[true,true,true,false],"in":3},{"out":1,"location":[-122.390038,37.790665],"bearings":[45,135,240,315],"entry":[true,true,true,false],"in":3},{"out":0,"location":[-122.389245,37.790036],"bearings":[135,225,315],"entry":[true,true,false],"in":2},{"out":1,"location":[-122.38871,37.789596],"bearings":[45,150,210,315],"entry":[true,true,true,false],"in":3},{"out":1,"location":[-122.388618,37.789494],"bearings":[45,150,225,330],"entry":[true,true,true,false],"in":3},{"out":1,"location":[-122.388527,37.789394],"bearings":[45,150,225,330],"entry":[true,true,true,false],"in":3},{"out":1,"location":[-122.388005,37.787907],"bearings":[0,180,270],"entry":[false,true,true],"in":0},{"out":1,"location":[-122.387985,37.787622],"bearings":[0,180,240],"entry":[false,true,true],"in":0},{"out":2,"location":[-122.388005,37.787197],"bearings":[0,90,180,270],"entry":[false,true,true,true],"in":0},{"out":2,"location":[-122.388015,37.787093],"bearings":[0,90,180,270],"entry":[false,true,true,true],"in":0},{"out":2,"location":[-122.388022,37.786994],"bearings":[0,90,180,285],"entry":[false,true,true,true],"in":0},{"out":1,"location":[-122.388163,37.785186],"bearings":[0,180,315],"entry":[false,true,true],"in":0},{"out":1,"location":[-122.388184,37.784944],"bearings":[0,180,315],"entry":[false,true,true],"in":0},{"out":2,"location":[-122.388191,37.784855],"bearings":[0,90,180,270],"entry":[false,true,true,true],"in":0},{"out":2,"location":[-122.388198,37.784748],"bearings":[0,90,180,270],"entry":[false,true,true,true],"in":0},{"out":2,"location":[-122.388207,37.784633],"bearings":[0,90,180,270],"entry":[false,true,true,true],"in":0},{"out":2,"location":[-122.388309,37.783373],"bearings":[0,60,180,270],"entry":[false,true,true,true],"in":0},{"out":1,"location":[-122.388376,37.782545],"bearings":[0,180,315],"entry":[false,true,true],"in":0},{"out":1,"location":[-122.388394,37.782316],"bearings":[0,180,315],"entry":[false,true,true],"in":0}],"geometry":"eqteFdx_jVf@k@\\a@|@iAV[FGJMPOTOPKDAPITItAa@r@WXOXQXSTUTWRYNUNS|B}CdAwAPSTQRQ\\W^Q\\KZIrB]^EPCH?\\CZ?Z?\\?XBT@R?~IZF?H@f@@N@T@V@zFRbDLl@@pADV@","maneuver":{"bearing_after":139,"type":"turn","modifier":"left","bearing_before":226,"location":[-122.39251,37.793631],"instruction":"Turn left onto The Embarcadero"},"duration":1055.9,"distance":1450.3,"name":"The Embarcadero","mode":"walking"},{"intersections":[{"out":2,"location":[-122.388431,37.781791],"bearings":[0,90,180,285],"entry":[false,true,true,true],"in":0},{"out":2,"location":[-122.389672,37.779922],"bearings":[45,135,225,315],"entry":[false,true,true,true],"in":0},{"out":1,"location":[-122.390803,37.77905],"bearings":[45,225,315],"entry":[false,true,true],"in":0},{"out":2,"location":[-122.391916,37.778155],"bearings":[45,135,225,315],"entry":[false,true,true,true],"in":0},{"out":2,"location":[-122.393073,37.777251],"bearings":[45,75,225,315],"entry":[false,true,true,true],"in":0}],"geometry":"egreFt~~iVR@bABXDVDXHVNXNXVVZp@|@z@hAnCvDLRNTHLFJbArAzApBdB`CTZZb@\\b@@@pCvD","maneuver":{"bearing_after":183,"type":"new name","modifier":"straight","bearing_before":183,"location":[-122.388431,37.781791],"instruction":"Continue straight onto King Street"},"duration":567.4,"distance":782.5,"name":"King Street","mode":"walking"},{"intersections":[{"out":3,"location":[-122.394003,37.776513],"bearings":[45,135,225,300],"entry":[false,true,true,true],"in":0},{"out":2,"location":[-122.394218,37.776486],"bearings":[45,135,225,315],"entry":[false,true,true,true],"in":0}],"geometry":"efqeFna`jVGJ?NJNNR","maneuver":{"bearing_after":313,"type":"turn","modifier":"straight","bearing_before":225,"location":[-122.394003,37.776513],"instruction":"Go straight"},"duration":26.1,"distance":36.2,"name":"","mode":"walking"},{"intersections":[{"out":2,"location":[-122.394321,37.776405],"bearings":[45,180,315],"entry":[false,true,true],"in":0},{"out":1,"location":[-122.394729,37.776487],"bearings":[45,180],"entry":[false,true],"in":0}],"geometry":"qeqeFnc`jVe@p@A@V\\DF","maneuver":{"bearing_after":315,"type":"turn","modifier":"right","bearing_before":225,"location":[-122.394321,37.776405],"instruction":"Turn right"},"duration":39.9,"distance":55.6,"name":"","mode":"walking"},{"intersections":[{"in":0,"entry":[true],"bearings":[45],"location":[-122.394768,37.776455]}],"geometry":"{eqeFhf`jV","maneuver":{"bearing_after":0,"type":"arrive","modifier":"straight","bearing_before":225,"location":[-122.394729,37.776487],"instruction":"You have arrived at your destination, straight ahead"},"duration":0,"distance":0,"name":"","mode":"walking"}],"summary":"The Embarcadero, King Street","duration":1933.3,"distance":2657.8}],"geometry":"{_ueF|d`jV|LuLV\\`EyElHaD~I_LvB_AdGk@he@|AbBd@bZl`@R~@g@r@\\d@","duration":1933.3,"distance":2657.8}],"waypoints":[{"name":"The Embarcadero","location":[-122.394553,37.795984]},{"name":"","location":[-122.394768,37.776455]}],"code":"Ok"} diff --git a/examples/quickcontrols2/wearable/qml/Notifications/NotificationsMain.qml b/examples/quickcontrols2/wearable/qml/Notifications/NotificationsMain.qml new file mode 100644 index 0000000000..9b72f53bd7 --- /dev/null +++ b/examples/quickcontrols2/wearable/qml/Notifications/NotificationsMain.qml @@ -0,0 +1,179 @@ +/**************************************************************************** +** +** 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 +import QtQuick.Controls 2.0 as QQC2 +import "../Common" +import "notifications.js" as NotificationData + +PageContainer { + Rectangle { + anchors.centerIn: parent + + width: UIStyle.visibleDiameter + height: UIStyle.visibleRectHeight + + color: "transparent" + + QQC2.SwipeView { + id: svNotificationsContainer + + anchors.fill: parent + + clip: true + currentIndex: 0 + + Item { + id: notificationsPage1 + + ListModel { + id: missedCallsList + } + + Row { + anchors.fill: parent + leftPadding: 30 + spacing: 2 + + Image { + id: missedCallIcon + anchors.verticalCenter: parent.verticalCenter + height: 64 + width: 64 + source: "../../images/notifications/missedcall.png" + } + + ListView { + id: missedCallsView + width: parent.width - missedCallIcon.width + height: parent.height + + clip: true + focus: true + boundsBehavior: Flickable.StopAtBounds + snapMode: ListView.SnapToItem + + model: missedCallsList + + delegate: Rectangle { + radius: 10 + color: "transparent" + height: missedCallsView.height + width: missedCallsView.width + Column { + anchors.fill: parent + spacing: 15 + topPadding: 35 + Image { + anchors.horizontalCenter: + parent.horizontalCenter + height: 64 + width: 64 + source: (gender == "m") ? + "../../images/notifications/avatarm.png" + :"../../images/notifications/avatarf.png" + } + + Text { + anchors.horizontalCenter: + parent.horizontalCenter + text: name + font.bold: true + font.pixelSize: UIStyle.fontSizeS + color: UIStyle.colorQtGray1 + } + Text { + anchors.horizontalCenter: + parent.horizontalCenter + text: date + " " + time + font.pixelSize: UIStyle.fontSizeXS + font.italic: true + color: UIStyle.colorQtGray2 + } + } + } + } + } + } + } + + QQC2.PageIndicator { + id: pgNotificationsIndicator + + anchors.bottom: svNotificationsContainer.bottom + anchors.bottomMargin: 1 + anchors.horizontalCenter: parent.horizontalCenter + + count: svNotificationsContainer.count + currentIndex: svNotificationsContainer.currentIndex + + delegate: Rectangle { + implicitWidth: 8 + implicitHeight: 8 + + radius: width / 2 + color: UIStyle.colorQtGray3 + + opacity: index === pgNotificationsIndicator.currentIndex + ? 1.0 : 0.35 + + Behavior on opacity { + OpacityAnimator { + duration: 100 + } + } + } + } + + Component.onCompleted: { + NotificationData.populateData(missedCallsList) + } + } +} diff --git a/examples/quickcontrols2/wearable/qml/Notifications/notifications.js b/examples/quickcontrols2/wearable/qml/Notifications/notifications.js new file mode 100644 index 0000000000..8716c56f05 --- /dev/null +++ b/examples/quickcontrols2/wearable/qml/Notifications/notifications.js @@ -0,0 +1,72 @@ +/**************************************************************************** +** +** 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$ +** +****************************************************************************/ + +function populateData(listData) { + listData.append({ + name: "John Doe", + gender: "m", + date: "02/15/2017", + time: "09:20 am" + }); + + listData.append({ + name: "Jane Worldege", + gender: "f", + date: "02/06/2017", + time: "10:15 am" + }); + + listData.append({ + name: "Jennifer Wang", + gender: "f", + date: "02/03/2017", + time: "05:16 pm" + }); +} diff --git a/examples/quickcontrols2/wearable/qml/Settings/SettingsData.qml b/examples/quickcontrols2/wearable/qml/Settings/SettingsData.qml new file mode 100644 index 0000000000..282bb772ed --- /dev/null +++ b/examples/quickcontrols2/wearable/qml/Settings/SettingsData.qml @@ -0,0 +1,84 @@ +/**************************************************************************** +** +** 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/SettingsMain.qml b/examples/quickcontrols2/wearable/qml/Settings/SettingsMain.qml new file mode 100644 index 0000000000..afacdeeb3f --- /dev/null +++ b/examples/quickcontrols2/wearable/qml/Settings/SettingsMain.qml @@ -0,0 +1,185 @@ +/**************************************************************************** +** +** 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 +import QtQuick.Controls 2.0 as QQC2 +import "../Common" + +PageContainer { + Rectangle { + anchors.centerIn: parent + + width: UIStyle.visibleDiameter + height: UIStyle.visibleRectHeight + + color: "transparent" + + SettingsData { + id: settingsData + } + + QQC2.SwipeView { + id: svSettingsContainer + + anchors.fill: parent + + clip: true + currentIndex: 0 + + Item { + id: settingsPage1 + + Column { + anchors.centerIn: parent + spacing: 25 + + Row { + spacing: 50 + Image { + anchors.verticalCenter: parent.verticalCenter + height: 64 + width: 64 + source: "../../images/settings/bluetooth.png" + } + WSwitch { + id: bluetoothSwitch + anchors.verticalCenter: parent.verticalCenter + checked: settingsData.bluetooth.state + } + } + Row { + spacing: 50 + Image { + anchors.verticalCenter: parent.verticalCenter + height: 64 + width: 64 + source: "../../images/settings/wifi.png" + } + WSwitch { + id: wirelessSwitch + anchors.verticalCenter: parent.verticalCenter + checked: settingsData.wireless.state + } + } + } + } + + Item { + id: settingsPage2 + + Column { + anchors.centerIn: parent + spacing: 2 + + Column { + Image { + anchors.horizontalCenter: parent.horizontalCenter + height: 64 + width: 64 + source: "../../images/settings/brightness.png" + } + WSlider { + id: brightnessSlider + anchors.horizontalCenter: parent.horizontalCenter + value: settingsData.brightness.value + from: settingsData.brightness.min + to: settingsData.brightness.max + stepSize: settingsData.brightness.steps + } + } + Column { + spacing: 2 + Image { + anchors.horizontalCenter: parent.horizontalCenter + height: 64 + width: 64 + source: "../../images/settings/contrast.png" + } + WSlider { + id: contrastSlider + anchors.horizontalCenter: parent.horizontalCenter + value: settingsData.contrast.value + from: settingsData.contrast.min + to: settingsData.contrast.max + stepSize: settingsData.contrast.steps + } + } + } + } + } + + QQC2.PageIndicator { + id: pgSettingsIndicator + + anchors.bottom: svSettingsContainer.bottom + anchors.bottomMargin: 1 + anchors.horizontalCenter: parent.horizontalCenter + + count: svSettingsContainer.count + currentIndex: svSettingsContainer.currentIndex + + delegate: Rectangle { + implicitWidth: 8 + implicitHeight: 8 + + radius: width / 2 + color: UIStyle.colorQtGray3 + + opacity: index === pgSettingsIndicator.currentIndex ? 1.0 : 0.35 + + Behavior on opacity { + OpacityAnimator { + duration: 100 + } + } + } + } + } +} diff --git a/examples/quickcontrols2/wearable/qml/WatchFace/Clock.qml b/examples/quickcontrols2/wearable/qml/WatchFace/Clock.qml new file mode 100644 index 0000000000..064465538c --- /dev/null +++ b/examples/quickcontrols2/wearable/qml/WatchFace/Clock.qml @@ -0,0 +1,191 @@ +/**************************************************************************** +** +** 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 +import "../Common" + +Item { + id: clock + + width: UIStyle.visibleDiameter + height: UIStyle.visibleDiameter + + property int hours + property int minutes + property int seconds + property real shift: timeShift + property bool night: false + property bool internationalTime: true //Unset for local time + + function getWatchFaceImage(imageName) { + return "../../images/watchface/" + imageName + } + + function timeChanged() { + var date = new Date + hours = internationalTime ? date.getUTCHours() + Math.floor( + clock.shift) : date.getHours() + night = (hours < 7 || hours > 19) + minutes = internationalTime ? + date.getUTCMinutes() + ((clock.shift % 1) * 60) : date.getMinutes() + seconds = date.getUTCSeconds() + } + + Timer { + interval: 100 + running: true + repeat: true + onTriggered: clock.timeChanged() + } + + Item { + anchors.horizontalCenter: parent.horizontalCenter + anchors.top: parent.top + anchors.topMargin: 2 + + width: 200 + height: 220 + + Rectangle { + color: clock.night ? UIStyle.colorQtGray1 : UIStyle.colorQtGray10 + radius: width / 2 + width: parent.width + height: parent.width + } + + Image { + id: background + source: getWatchFaceImage("swissdaydial.png") + visible: clock.night == false + } + Image { + source: getWatchFaceImage("swissnightdial.png") + visible: clock.night == true + } + + Image { + x: 92.5 + y: 27 + source: getWatchFaceImage(clock.night ? + "swissnighthour.png" + : "swissdayhour.png") + transform: Rotation { + id: hourRotation + origin.x: 7.5 + origin.y: 73 + angle: (clock.hours * 30) + (clock.minutes * 0.5) + Behavior on angle { + SpringAnimation { + spring: 2 + damping: 0.2 + modulus: 360 + } + } + } + } + + Image { + x: 93.5 + y: 17 + source: getWatchFaceImage(clock.night ? + "swissnightminute.png" + : "swissdayminute.png") + transform: Rotation { + id: minuteRotation + origin.x: 6.5 + origin.y: 83 + angle: clock.minutes * 6 + Behavior on angle { + SpringAnimation { + spring: 2 + damping: 0.2 + modulus: 360 + } + } + } + } + + Image { + x: 97.5 + y: 20 + source: getWatchFaceImage("second.png") + transform: Rotation { + id: secondRotation + origin.x: 2.5 + origin.y: 80 + angle: clock.seconds * 6 + Behavior on angle { + SpringAnimation { + spring: 2 + damping: 0.2 + modulus: 360 + } + } + } + } + + Image { + anchors.centerIn: background + source: getWatchFaceImage("center.png") + } + + Text { + id: cityLabel + anchors.bottom: parent.bottom + anchors.bottomMargin: 2 + anchors.horizontalCenter: parent.horizontalCenter + + text: cityName + color: UIStyle.colorQtGray1 + font.pixelSize: UIStyle.fontSizeXS + font.letterSpacing: 2 + } + } +} diff --git a/examples/quickcontrols2/wearable/qml/WatchFace/WatchFaceMain.qml b/examples/quickcontrols2/wearable/qml/WatchFace/WatchFaceMain.qml new file mode 100644 index 0000000000..6916e156a8 --- /dev/null +++ b/examples/quickcontrols2/wearable/qml/WatchFace/WatchFaceMain.qml @@ -0,0 +1,127 @@ +/**************************************************************************** +** +** 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 +import QtQuick.Controls 2.0 as QQC2 +import "../Common" + +PageContainer { + QQC2.SwipeView { + id: svWatchContainer + + anchors.fill: parent + currentIndex: 0 + + ListModel { + id: placesList + ListElement { + cityName: "New York" + timeShift: -4 + } + ListElement { + cityName: "London" + timeShift: 0 + } + ListElement { + cityName: "Oslo" + timeShift: 1 + } + ListElement { + cityName: "Mumbai" + timeShift: 5.5 + } + ListElement { + cityName: "Tokyo" + timeShift: 9 + } + ListElement { + cityName: "Brisbane" + timeShift: 10 + } + ListElement { + cityName: "Los Angeles" + timeShift: -8 + } + } + + Repeater { + model: placesList + delegate: Clock { + } + } + } + + QQC2.PageIndicator { + id: pgWatchIndicator + + anchors.bottom: svWatchContainer.bottom + anchors.bottomMargin: 1 + anchors.horizontalCenter: parent.horizontalCenter + + count: svWatchContainer.count + currentIndex: svWatchContainer.currentIndex + + delegate: Rectangle { + implicitWidth: 8 + implicitHeight: 8 + + radius: width / 2 + color: UIStyle.colorQtGray3 + + opacity: index === pgWatchIndicator.currentIndex ? 1.0 : 0.35 + + Behavior on opacity { + OpacityAnimator { + duration: 100 + } + } + } + } +} diff --git a/examples/quickcontrols2/wearable/qml/Weather/WeatherMain.qml b/examples/quickcontrols2/wearable/qml/Weather/WeatherMain.qml new file mode 100644 index 0000000000..94f5dff68d --- /dev/null +++ b/examples/quickcontrols2/wearable/qml/Weather/WeatherMain.qml @@ -0,0 +1,361 @@ +/**************************************************************************** +** +** 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 +import QtQuick.Controls 2.0 as QQC2 +import "../Common" +import "weather.js" as WeatherData + +PageContainer { + Rectangle { + id: weatherCntr + anchors.centerIn: parent + + width: UIStyle.visibleDiameter + height: UIStyle.visibleRectHeight + + color: "transparent" + + QQC2.SwipeView { + id: svWeatherContainer + + anchors.fill: parent + currentIndex: 0 + + Item { + id: weatherPage1 + + Row { + anchors.centerIn: parent + width: UIStyle.visibleDiameter + height: UIStyle.visibleRectHeight + padding: 20 + spacing: 2 + + Image { + anchors.verticalCenter: parent.verticalCenter + height: 64 + width: 64 + source: "../../images/weather/temperature.png" + } + + Column { + anchors.verticalCenter: parent.verticalCenter + height: parent.height + topPadding: 20 + spacing: 40 + + Text { + text: (wDataCntr.weatherData + && wDataCntr.weatherData.main + && wDataCntr.weatherData.main.temp) ? + qsTr("Avg: ") + + String(wDataCntr.weatherData.main.temp) + + " °F" : "N/A" + font.pixelSize: UIStyle.fontSizeM + font.letterSpacing: 1 + color: UIStyle.colorQtGray1 + } + Text { + text: (wDataCntr.weatherData + && wDataCntr.weatherData.main + && wDataCntr.weatherData.main.temp_min) ? + qsTr("Min: ") + + String(wDataCntr.weatherData.main.temp_min) + + " °F" : "N/A" + font.pixelSize: UIStyle.fontSizeM + font.letterSpacing: 1 + color: UIStyle.colorQtGray1 + } + Text { + text: (wDataCntr.weatherData + && wDataCntr.weatherData.main + && wDataCntr.weatherData.main.temp_max) ? + qsTr("Max: ") + + String(wDataCntr.weatherData.main.temp_max) + + " °F " : "N/A" + font.pixelSize: UIStyle.fontSizeM + font.letterSpacing: 1 + color: UIStyle.colorQtGray1 + } + } + } + } + + Item { + id: weatherPage2 + + Column { + anchors.centerIn: parent + width: UIStyle.visibleRectWidth + height: UIStyle.visibleRectHeight + + Item { + anchors.horizontalCenter: parent.horizontalCenter + height: parent.height / 2 + width: parent.width + + Image { + id: wImg + anchors.left: parent.left + anchors.verticalCenter: parent.verticalCenter + height: 64 + width: 64 + source: "../../images/weather/wind.png" + } + + Text { + anchors.left: wImg.right + leftPadding: 20 + anchors.verticalCenter: parent.verticalCenter + text: (wDataCntr.weatherData + && wDataCntr.weatherData.wind + && wDataCntr.weatherData.wind.speed) ? + String(wDataCntr.weatherData.wind.speed) + + " mph" : "N/A" + font.pixelSize: UIStyle.fontSizeM + font.letterSpacing: 1 + color: UIStyle.colorQtGray1 + } + } + Item { + anchors.horizontalCenter: parent.horizontalCenter + height: parent.height / 2 + width: parent.width + + Image { + id: hImg + anchors.left: parent.left + anchors.verticalCenter: parent.verticalCenter + height: 64 + width: 64 + source: "../../images/weather/humidity.png" + } + Text { + anchors.left: hImg.right + leftPadding: 20 + anchors.verticalCenter: parent.verticalCenter + text: (wDataCntr.weatherData + && wDataCntr.weatherData.main + && wDataCntr.weatherData.main.humidity) ? + String(wDataCntr.weatherData.main.humidity) + + " %" : "N/A" + font.pixelSize: UIStyle.fontSizeM + font.letterSpacing: 1 + color: UIStyle.colorQtGray1 + } + } + } + } + + Item { + id: weatherPage3 + + Row { + anchors.centerIn: parent + width: UIStyle.visibleRectWidth + height: UIStyle.visibleRectHeight + spacing: 10 + + Image { + anchors.verticalCenter: parent.verticalCenter + height: 64 + width: 64 + source: "../../images/weather/pressure.png" + } + + Column { + anchors.verticalCenter: parent.verticalCenter + height: parent.height + topPadding: 25 + spacing: 40 + + Text { + anchors.horizontalCenter: parent.horizontalCenter + text: (wDataCntr.weatherData + && wDataCntr.weatherData.main + && wDataCntr.weatherData.main.pressure) ? + String(wDataCntr.weatherData.main.pressure) + + " hPa" : "N/A" + font.pixelSize: UIStyle.fontSizeM + font.letterSpacing: 1 + color: UIStyle.colorQtGray1 + } + Text { + anchors.horizontalCenter: parent.horizontalCenter + text: (wDataCntr.weatherData + && wDataCntr.weatherData.main + && wDataCntr.weatherData.main.sea_level) ? + String(wDataCntr.weatherData.main.sea_level) + + " hPa" : "N/A" + font.pixelSize: UIStyle.fontSizeM + font.letterSpacing: 1 + color: UIStyle.colorQtGray1 + } + Text { + anchors.horizontalCenter: parent.horizontalCenter + text: (wDataCntr.weatherData + && wDataCntr.weatherData.main + && wDataCntr.weatherData.main.grnd_level) ? + String(wDataCntr.weatherData.main.grnd_level) + + " hPa" : "N/A" + font.pixelSize: UIStyle.fontSizeM + font.letterSpacing: 1 + color: UIStyle.colorQtGray1 + } + } + } + } + + Item { + id: weatherPage4 + + Column { + anchors.centerIn: parent + width: UIStyle.visibleDiameter + height: UIStyle.visibleRectHeight + + Item { + anchors.horizontalCenter: parent.horizontalCenter + height: parent.height / 2 + width: parent.width + + Image { + anchors.left: parent.left + anchors.leftMargin: 30 + anchors.verticalCenter: parent.verticalCenter + height: 64 + width: 64 + source: "../../images/weather/sunrise.png" + } + + Text { + anchors.right: parent.right + anchors.rightMargin: 30 + anchors.verticalCenter: parent.verticalCenter + text: (wDataCntr.weatherData + && wDataCntr.weatherData.sys + && wDataCntr.weatherData.sys.sunrise) ? + WeatherData.getTimeHMS(wDataCntr.weatherData.sys.sunrise) + : "N/A" + font.pixelSize: UIStyle.fontSizeM + font.letterSpacing: 1 + color: UIStyle.colorQtGray1 + } + } + + Item { + anchors.horizontalCenter: parent.horizontalCenter + height: parent.height / 2 + width: parent.width + + Image { + anchors.left: parent.left + anchors.leftMargin: 30 + anchors.verticalCenter: parent.verticalCenter + height: 64 + width: 64 + source: "../../images/weather/sunset.png" + } + + Text { + anchors.right: parent.right + anchors.rightMargin: 30 + anchors.verticalCenter: parent.verticalCenter + text: (wDataCntr.weatherData + && wDataCntr.weatherData.sys + && wDataCntr.weatherData.sys.sunset) ? + WeatherData.getTimeHMS(wDataCntr.weatherData.sys.sunset) + : "N/A" + font.pixelSize: UIStyle.fontSizeM + font.letterSpacing: 1 + color: UIStyle.colorQtGray1 + } + } + } + } + } + + QtObject { + id: wDataCntr + property var weatherData + } + + QQC2.PageIndicator { + id: pgWeatherIndicator + + anchors.bottom: svWeatherContainer.bottom + anchors.bottomMargin: 1 + anchors.horizontalCenter: parent.horizontalCenter + + count: svWeatherContainer.count + currentIndex: svWeatherContainer.currentIndex + + delegate: Rectangle { + implicitWidth: 8 + implicitHeight: 8 + + radius: width / 2 + color: UIStyle.colorQtGray3 + + opacity: index === pgWeatherIndicator.currentIndex ? 1.0 : 0.35 + + Behavior on opacity { + OpacityAnimator { + duration: 100 + } + } + } + } + Component.onCompleted: { + WeatherData.requestWeatherData(wDataCntr) + } + } +} diff --git a/examples/quickcontrols2/wearable/qml/Weather/weather.js b/examples/quickcontrols2/wearable/qml/Weather/weather.js new file mode 100644 index 0000000000..b3bf446568 --- /dev/null +++ b/examples/quickcontrols2/wearable/qml/Weather/weather.js @@ -0,0 +1,77 @@ +/**************************************************************************** +** +** 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$ +** +****************************************************************************/ + +function requestWeatherData(cntr) { + var xhr = new XMLHttpRequest; + xhr.open("GET", "weather.json"); + xhr.onreadystatechange = function () { + if (xhr.readyState === XMLHttpRequest.DONE) { + cntr.weatherData = JSON.parse(xhr.responseText) + } + } + xhr.send(); +} + +function getTimeHMS(utcTime) { + var date = new Date(utcTime * 1000); + // Hours part from the timestamp + var hours = date.getHours(); + var ampm = Math.floor((hours / 12)) ? " PM" : " AM"; + hours = (hours % 12); + + // Minutes part from the timestamp + var minutes = "0" + date.getMinutes(); + // Seconds part from the timestamp + var seconds = "0" + date.getSeconds(); + + // Will display time in 10:30:23 format + return hours % 12 + ':' + minutes.substr(-2) + ':' + seconds.substr(-2) + + ampm; +} diff --git a/examples/quickcontrols2/wearable/qml/Weather/weather.json b/examples/quickcontrols2/wearable/qml/Weather/weather.json new file mode 100644 index 0000000000..2cce95c60b --- /dev/null +++ b/examples/quickcontrols2/wearable/qml/Weather/weather.json @@ -0,0 +1 @@ +{"coord":{"lon":-122.42,"lat":37.77},"weather":[{"id":803,"main":"Clouds","description":"broken clouds","icon":"04n"}],"base":"stations","main":{"temp":45.22,"pressure":1020.17,"humidity":88,"temp_min":36.92,"temp_max":58.92,"sea_level":1028.19,"grnd_level":1020.17},"wind":{"speed":6.73,"deg":201.002},"clouds":{"all":68},"dt":1476412232,"sys":{"message":0.012,"country":"US","sunrise":1476454666,"sunset":1476495156},"id":5391959,"name":"San Francisco","cod":200} diff --git a/examples/quickcontrols2/wearable/wearable.cpp b/examples/quickcontrols2/wearable/wearable.cpp new file mode 100644 index 0000000000..dec6e9c2b5 --- /dev/null +++ b/examples/quickcontrols2/wearable/wearable.cpp @@ -0,0 +1,62 @@ +/**************************************************************************** +** +** 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$ +** +****************************************************************************/ + +#include <QGuiApplication> +#include <QQmlApplicationEngine> + +int main(int argc, char *argv[]) +{ + QGuiApplication app(argc, argv); + + QQmlApplicationEngine engine; + engine.load(QUrl(QStringLiteral("qrc:/wearable.qml"))); + + return app.exec(); +} diff --git a/examples/quickcontrols2/wearable/wearable.pro b/examples/quickcontrols2/wearable/wearable.pro new file mode 100644 index 0000000000..8d55e44eaa --- /dev/null +++ b/examples/quickcontrols2/wearable/wearable.pro @@ -0,0 +1,12 @@ +TEMPLATE = app +TARGET = wearable +QT += quick quickcontrols2 + +SOURCES += \ + wearable.cpp + +RESOURCES += \ + wearable.qrc + +target.path = $$[QT_INSTALL_EXAMPLES]/quickcontrols2/wearable +INSTALLS += target diff --git a/examples/quickcontrols2/wearable/wearable.qml b/examples/quickcontrols2/wearable/wearable.qml new file mode 100644 index 0000000000..95916ebc94 --- /dev/null +++ b/examples/quickcontrols2/wearable/wearable.qml @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** 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 +import QtQuick.Window 2.0 +import "qml" +import "qml/Common" + +Window { + id: rootWindow + + visible: true + + width: UIStyle.displayWidth + height: UIStyle.displayHeight + + color: UIStyle.colorQtGray1 + + title: qsTr("Wearable") + + MainContainer { + anchors.fill: parent + } +} diff --git a/examples/quickcontrols2/wearable/wearable.qrc b/examples/quickcontrols2/wearable/wearable.qrc new file mode 100644 index 0000000000..b4aa762cb1 --- /dev/null +++ b/examples/quickcontrols2/wearable/wearable.qrc @@ -0,0 +1,69 @@ +<RCC> + <qresource prefix="/"> + <file>wearable.qml</file> + <file>qml/Alarms/alarms.js</file> + <file>qml/Alarms/AlarmsMain.qml</file> + <file>qml/Common/PageContainer.qml</file> + <file>qml/Common/qmldir</file> + <file>qml/Common/UIStyle.qml</file> + <file>qml/Common/WSlider.qml</file> + <file>qml/Common/WSwitch.qml</file> + <file>qml/Fitness/fitness.js</file> + <file>qml/Fitness/FitnessMain.qml</file> + <file>qml/LauncherMain.qml</file> + <file>qml/MainContainer.qml</file> + <file>qml/Navigation/navigation.js</file> + <file>qml/Navigation/NavigationMain.qml</file> + <file>qml/Navigation/RouteElement.qml</file> + <file>qml/Navigation/walk_route.json</file> + <file>qml/Notifications/notifications.js</file> + <file>qml/Notifications/NotificationsMain.qml</file> + <file>qml/Settings/SettingsData.qml</file> + <file>qml/Settings/SettingsMain.qml</file> + <file>qml/WatchFace/Clock.qml</file> + <file>qml/WatchFace/WatchFaceMain.qml</file> + <file>qml/Weather/weather.js</file> + <file>qml/Weather/weather.json</file> + <file>qml/Weather/WeatherMain.qml</file> + <file>images/alarms/alarms.png</file> + <file>images/background/HomeBackground.png</file> + <file>images/back.png</file> + <file>images/fitness/fitness.png</file> + <file>images/fitness/man-running.png</file> + <file>images/fitness/man-walking.png</file> + <file>images/home.png</file> + <file>images/navigation/end.png</file> + <file>images/navigation/leftturn.png</file> + <file>images/navigation/marker.png</file> + <file>images/navigation/rightturn.png</file> + <file>images/navigation/route.png</file> + <file>images/navigation/start.png</file> + <file>images/navigation/straight.png</file> + <file>images/navigation/uturn.png</file> + <file>images/notifications/avatarf.png</file> + <file>images/notifications/avatarm.png</file> + <file>images/notifications/missedcall.png</file> + <file>images/notifications/notifications.png</file> + <file>images/settings/bluetooth.png</file> + <file>images/settings/brightness.png</file> + <file>images/settings/contrast.png</file> + <file>images/settings/settings.png</file> + <file>images/settings/wifi.png</file> + <file>images/watchface/center.png</file> + <file>images/watchface/second.png</file> + <file>images/watchface/swissdaydial.png</file> + <file>images/watchface/swissdayhour.png</file> + <file>images/watchface/swissdayminute.png</file> + <file>images/watchface/swissnightdial.png</file> + <file>images/watchface/swissnighthour.png</file> + <file>images/watchface/swissnightminute.png</file> + <file>images/watchface/watch.png</file> + <file>images/weather/humidity.png</file> + <file>images/weather/pressure.png</file> + <file>images/weather/sunrise.png</file> + <file>images/weather/sunset.png</file> + <file>images/weather/temperature.png</file> + <file>images/weather/weather.png</file> + <file>images/weather/wind.png</file> + </qresource> +</RCC> |