/**************************************************************************** ** ** Copyright (C) 2015 The Qt Company Ltd. ** Contact: http://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 musicplayer \title Music Player \ingroup examples-qtwinextras \brief Demonstrates managing Windows DWM features, jump lists, taskbar button overlay, and thumbnail toolbar. \image qtwinextras-musicplayer-composited.png Screenshot of the Music Player example The Music Player example demonstrates how to use the various features provided by the QtWinExtras module. \note The example uses QMediaPlayer from the QtMultimedia module to play the music, but this article focuses on the parts where QtWinExtras features are used. \section1 DWM Features The example uses Windows DWM (Desktop Window Manager) features to visually integrate the window content to the window frame and to make the main window and the volume popup translucent and blurred. The example applies a different look based on whether composition is enabled or not. When composition is enabled, the main window is made translucent and the window frame is extended to the client area to make the window content integrate seamlessly to the window frame as shown above. When composition is disabled, the colorization color is used as a background color. The following screenshot illustrates how the Music Player example looks when composition is disabled. \image qtwinextras-musicplayer-non-composited.png Screenshot of the Music Player example The respective code is a combination of extending or resetting the system frame, adjusting the necessary QWidget attributes, and setting an appropriate style sheet to achieve the desired look. \snippet musicplayer/musicplayer.cpp 1 The volume popup does not have a window frame so it is enough to make the popup blurred when composition is enabled. Additionally, a style sheet is applied to get a border that follows the colorization color. Just like for the main window, when composition is disabled, the colorization color is used as a background color. \snippet musicplayer/volumebutton.cpp 0 The example application respects the user's composition settings, reacts to dynamic composition changes, and looks solid regardless of whether composition is enabled or not. It accomplishes this by catching QWinEvent::CompositionChange and QWinEvent::ColorizationChange events and adjusting its looks accordingly. \snippet musicplayer/musicplayer.cpp 0 \section1 Jump List The example creates a custom jump list to provide the user with fast access to recently played music files. \snippet musicplayer/musicplayer.cpp 4 To enable the application jump list to show the desired recent files, the corresponding file types are registered using the following helper function. \snippet musicplayer/main.cpp 0 \section1 Taskbar Overlay and Progress The example uses Windows Taskbar for two things; it sets an overlay icon that represents the current music playback state, and it indicates the playback progress in the taskbar button. \image qtwinextras-musicplayer-taskbar.png Screenshot of the Music Player taskbar The following snippets show how the taskbar button is prepared. For the taskbar and the thumbnail toolbar to work, a native window handle must be set by passing an instance of \c QWindow to \c QWinTaskbarButton::setWindow() or \c QWinThumbnailToolBar::setWindow(), respectively. This instance is created in the process of \c QWidget::show() and can be retrieved by calling \c QWidget::windowHandle() afterwards. We override \c QWidget::showEvent() for this purpose: \snippet musicplayer/musicplayer.cpp 7 The playback progress is wired directly to the taskbar progress indicator by using signals and slots. \snippet musicplayer/musicplayer.cpp 5 The overlay icon and the progress indicator are updated whenever the state of the music playback changes. \snippet musicplayer/musicplayer.cpp 2 \section1 Thumbnail Toolbar \image qtwinextras-musicplayer-thumbnail.png Screenshot of the Music Player thumbnail The Windows Thumbnail Toolbar is used for providing basic music playback controls. These controls can be used to control the application without having to activate the application. \snippet musicplayer/musicplayer.cpp 6 The buttons in the thumbnail toolbar are updated accordingly whenever the state of the music playback changes. \snippet musicplayer/musicplayer.cpp 3 */