summaryrefslogtreecommitdiffstats
path: root/examples/applicationmanager/animated-windows/doc/src/animated-windows.qdoc
blob: efdb3157d1087a8acd697fc1f0917b05aab7a321 (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
/****************************************************************************
**
** Copyright (C) 2019 Luxoft Sweden AB
** Copyright (C) 2018 Pelagicore AG
** Contact: https://www.qt.io/licensing/
**
** This file is part of the documentation of the Qt Application Manager.
**
** $QT_BEGIN_LICENSE:FDL-QTAS$
** Commercial License Usage
** Licensees holding valid commercial Qt Automotive Suite 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 applicationmanager/animated-windows
\brief Learn how to animate windows to appear and disappear.
\ingroup applicationmanager-examples
\title Animated Windows System UI Example
\image animated-windows-example.jpg The Animated Windows example with two applications running.

\section1 Introduction

This example shows you how to animate windows to appear and disappear, in a System UI.

\b Prerequisites: You're already familiar with the concepts and topics introduced in the
   \l {"Hello World!" System UI Example}.

Unlike with the \l{"Hello World!" System UI Example}{Hello World} example, most Graphical User
Interfaces (GUIs) avoid making sudden, abrupt, changes as they can confuse the user and are not
visually pleasant. So, when the WindowManager creates a new WindowObject, we want to animate its
appearance instead of simply having it pop up on the screen. Likewise, once a WindowObject loses
its surface - because the application closed this window or stopped altogether - and is removed
from the WindowManager's model, we want to animate its disappearance instead of having it vanish
immediately.

If you're using a ready-made, advanced layout such as ListView, you can assign Transitions to
different actions like add, remove, displaced, and so on, and keep using WindowManager as your
model. But in many situations this is not the case. Instead, you have to create your own model,
such as a ListModel, so that a WindowObject only leaves the model when you have finished
animating its delegate's disappearance. This example showcases this technique.

\section1 The Windows Model

The model we use to instantiate our \l{WindowItem}{windows} is the key point in this example.

Instead of using WindowManager directly as our model we use a plain ListModel:

\quotefromfile applicationmanager/animated-windows/system-ui/main.qml
\skipto Each WindowObject
\skipline Each WindowObject
\printuntil delegate: Rectangle

We remove a WindowObject from that model only after it has reached its end state:
WindowObject.NoSurface and is no longer being shown on screen; any state transition has already
finished.

\skipto property bool safeToRemove
\printuntil onSafeToRemoveChanged

Then, we add a WindowObject to it, and display it on screen as soon as WindowManager creates
a WindowObject.

\skipto Connections
\printuntil /\s+\}/

*/