xref: /OK3568_Linux_fs/app/forlinx/forlinx_qt/musicplayer/doc/src/qtwinextras-musicplayer.qdoc (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1/****************************************************************************
2**
3** Copyright (C) 2015 The Qt Company Ltd.
4** Contact: http://www.qt.io/licensing/
5**
6** This file is part of the documentation of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:FDL$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see http://www.qt.io/terms-conditions. For further
15** information use the contact form at http://www.qt.io/contact-us.
16**
17** GNU Free Documentation License Usage
18** Alternatively, this file may be used under the terms of the GNU Free
19** Documentation License version 1.3 as published by the Free Software
20** Foundation and appearing in the file included in the packaging of
21** this file. Please review the following information to ensure
22** the GNU Free Documentation License version 1.3 requirements
23** will be met: http://www.gnu.org/copyleft/fdl.html.
24** $QT_END_LICENSE$
25**
26****************************************************************************/
27
28/*!
29    \example musicplayer
30    \title Music Player
31    \ingroup examples-qtwinextras
32    \brief Demonstrates managing Windows DWM features, jump lists,
33           taskbar button overlay, and thumbnail toolbar.
34
35    \image qtwinextras-musicplayer-composited.png Screenshot of the Music Player example
36
37    The Music Player example demonstrates how to use the various features
38    provided by the QtWinExtras module.
39
40    \note The example uses QMediaPlayer from the QtMultimedia module to play
41    the music, but this article focuses on the parts where QtWinExtras features
42    are used.
43
44    \section1 DWM Features
45
46    The example uses Windows DWM (Desktop Window Manager) features to visually
47    integrate the window content to the window frame and to make the main window
48    and the volume popup translucent and blurred.
49
50    The example applies a different look based on whether composition is enabled
51    or not. When composition is enabled, the main window is made translucent and
52    the window frame is extended to the client area to make the window content
53    integrate seamlessly to the window frame as shown above. When composition
54    is disabled, the colorization color is used as a background color. The
55    following screenshot illustrates how the Music Player example looks when
56    composition is disabled.
57
58    \image qtwinextras-musicplayer-non-composited.png Screenshot of the Music Player example
59
60    The respective code is a combination of extending or resetting the system
61    frame, adjusting the necessary QWidget attributes, and setting an appropriate
62    style sheet to achieve the desired look.
63
64    \snippet musicplayer/musicplayer.cpp 1
65
66    The volume popup does not have a window frame so it is enough to make the
67    popup blurred when composition is enabled. Additionally, a style sheet is
68    applied to get a border that follows the colorization color. Just like for
69    the main window, when composition is disabled, the colorization color is
70    used as a background color.
71
72    \snippet musicplayer/volumebutton.cpp 0
73
74    The example application respects the user's composition settings, reacts
75    to dynamic composition changes, and looks solid regardless of whether
76    composition is enabled or not. It accomplishes this by catching
77    QWinEvent::CompositionChange and QWinEvent::ColorizationChange events
78    and adjusting its looks accordingly.
79
80    \snippet musicplayer/musicplayer.cpp 0
81
82    \section1 Jump List
83
84    The example creates a custom jump list to provide the user with fast
85    access to recently played music files.
86
87    \snippet musicplayer/musicplayer.cpp 4
88
89    To enable the application jump list to show the desired recent files,
90    the corresponding file types are registered using the following helper
91    function.
92
93    \snippet musicplayer/main.cpp 0
94
95    \section1 Taskbar Overlay and Progress
96
97    The example uses Windows Taskbar for two things; it sets an overlay icon
98    that represents the current music playback state, and it indicates the
99    playback progress in the taskbar button.
100
101    \image qtwinextras-musicplayer-taskbar.png Screenshot of the Music Player taskbar
102
103    The following snippet shows how the taskbar button is prepared. The playback
104    progress is wired directly to the taskbar progress indicator by using signals
105    and slots.
106
107    \snippet musicplayer/musicplayer.cpp 5
108
109    The overlay icon and the progress indicator are updated whenever the state
110    of the music playback changes.
111
112    \snippet musicplayer/musicplayer.cpp 2
113
114    \section1 Thumbnail Toolbar
115
116    \image qtwinextras-musicplayer-thumbnail.png Screenshot of the Music Player thumbnail
117
118    The Windows Thumbnail Toolbar is used for providing basic music playback
119    controls. These controls can be used to control the application without
120    having to activate the application.
121
122    \snippet musicplayer/musicplayer.cpp 6
123
124    The buttons in the thumbnail toolbar are updated accordingly whenever the state
125    of the music playback changes.
126
127    \snippet musicplayer/musicplayer.cpp 3
128*/
129