aboutsummaryrefslogtreecommitdiffstats
path: root/examples/quickcontrols2/wearable/doc/src/qtquickcontrols2-wearable.qdoc
blob: 4ae3233c3a696719f31b1f6e15cf1b4055777c3a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
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
*/