// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only

/*!
    \example wearable
    \keyword Qt Quick Controls - Wearable Demo
    \title Qt Quick Controls - Wearable Demo
    \keyword Qt Quick Controls 2 - Wearable Demo
    \ingroup qtquickcontrols-examples
    \examplecategory {Embedded}
    \brief Demonstrates an application launcher designed for wearable devices.

    \image qtquickcontrols-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/Main.qml
    \skipuntil import WearableStyle
    \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}{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 WearableStyle/PageIndicator.qml
        \li \c WearableStyle/Slider.qml
        \li \c WearableStyle/Switch.qml
        \li \c WearableStyle/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 Wearable/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/Wearable/NaviButton.qml
    \skipuntil import WearableStyle
    \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 :/Wearable/icons
    folder in the application's resources. The \c index.theme file lists the contents
    of the icon theme:

    \quotefile wearable/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} 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/Wearable/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
*/
