/**************************************************************************** ** ** 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 \keyword Qt Quick Controls - Wearable Demo \title Qt Quick Controls - Wearable Demo \keyword Qt Quick Controls 2 - Wearable Demo \ingroup qtquickcontrols2-examples \brief Demonstrates an application launcher designed for wearable devices. \image qtquickcontrols2-wearable.png The \e {Wearable Demo} consists of an application launcher and a collection of small and simple example applications aimed at wearable devices. \section1 Structure The main .qml file, \c wearable.qml, consists of an ApplicationWindow, a StackView for a stack-based navigation model, and buttons for interactive navigation. \quotefromfile wearable/wearable.qml \skipuntil import "qml/Style" \printuntil id: window \dots \skipto header \printuntil id: homeButton \dots 8 \skipto onClicked \printuntil } \printuntil id: backButton \dots 8 \skipto onClicked \printuntil id: stackView \dots 8 \skipuntil initialItem \printuntil /^\}/ \section1 Styling The demo uses a custom \l {Styling Qt Quick Controls 2}{Qt Quick Controls 2 style} embedded into the demo's resources. The custom style is implemented for a few controls only, as it is specific to this particular demo. It uses a singleton type for various styling attributes, such as fonts and colors. \list \li \c qml/Style/PageIndicator.qml \li \c qml/Style/Slider.qml \li \c qml/Style/Switch.qml \li \c qml/Style/UIStyle.qml \endlist The style is applied in \c main() in \c wearable.cpp: \snippet wearable/wearable.cpp style The main benefit of using the built-in styling system is that the style selection is fully transparent to the application code. There is no need to import a specific folder that contains the styled controls. This way, the application can be run with other styles too. \section1 Custom Type The demo application contains a custom button type implemented in \c qml/NaviButton.qml. The navigation button is used as a home and back button in \c wearable.qml. \c NaviButton extends the AbstractButton type with properties that control the slide in and slide out transitions and the button image. \quotefromfile wearable/qml/NaviButton.qml \skipuntil import "Style" \printuntil id: image \dots 8 \skipuntil } \printuntil background: \dots 8 \skipto } \printuntil /^\}/ \section1 Icons The demo ships a custom icon theme. The icons are bundled into the \c :/icons folder in the application's resources. The \c index.theme file lists the contents of the icon theme: \quotefile wearable/icons/wearable/index.theme Finally, the icon theme is selected in \c main(): \snippet wearable/wearable.cpp icons The icons are used on the Launcher Page, which is presented below. See \l {Icons in Qt Quick Controls 2} for more details about icons and themes. \section1 Launcher Page The application launcher is implemented using a circular PathView in \c LauncherPage.qml. Each application is in a separate .qml file, which is added to the ListModel on the launcher page. \quotefromfile wearable/qml/LauncherPage.qml \skipto PathView \printuntil signal launched \dots \skipto ListModel \printuntil } \dots 8 \printline ListElement \skipto "Settings" \printuntil delegate: \dots 8 \skipto icon.width \printuntil icon.name \dots 8 \skipto onClicked: \printto path: \dots \skipto /^\}/ \printline } \section1 Applications The applications are designed for touch input based on what input methods or communication means are typically offered by wearable devices. Most applications have their own JavaScript files that act as dummy application backends. They illustrate fetching external data and help manipulating or converting the data. In the \c Navigation and \c Weather applications, data acquisition is implemented using \l 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. \section2 Navigation This application displays a walking route from source to destination. This route information is obtained using the REST API provided by \l {https://www.openstreetmap.org/}. The API response is in JSON format, which is parsed using JavaScript by the application. Currently, it is not possible to specify the source and destination from within the application, but it can be 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 application running on another device such as a smart phone or PC. \section2 Weather This application displays weather information such as temperature, sunrise and sunset times, air pressure, and so on. This information is obtained from \l {https://openweathermap.org/} using its REST API. The API response is in JSON format, which is parsed using JavaScript by the application. This application can also be modified by adding screens to obtain weather data for a given location. \section2 World Clock This application displays a world clock for different cities. As of now, the list of cities is hard-coded in the application, but that can be changed based on the input capabilities of the device. \section2 Others The remaining applications return static data for now, but they can be modified to process response data obtained from respective services. \include examples-run.qdocinc */