Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qwindowssystemtrayicon.h
Go to the documentation of this file.
1// Copyright (C) 2017 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QWINDOWSSYSTEMTRAYICON_H
5#define QWINDOWSSYSTEMTRAYICON_H
6
7#include <QtGui/qicon.h>
8#include <QtGui/qpa/qplatformsystemtrayicon.h>
9
10#include <QtCore/qpointer.h>
11#include <QtCore/qstring.h>
12#include <QtCore/qt_windows.h>
13
14QT_BEGIN_NAMESPACE
15
16class QDebug;
17
19
21{
22public:
25
26 void init() override;
27 void cleanup() override;
28 void updateIcon(const QIcon &icon) override;
29 void updateToolTip(const QString &tooltip) override;
30 void updateMenu(QPlatformMenu *) override {}
31 QRect geometry() const override;
32 void showMessage(const QString &title, const QString &msg,
33 const QIcon &icon, MessageIcon iconType, int msecs) override;
34
35 bool isSystemTrayAvailable() const override { return true; }
36 bool supportsMessages() const override;
37
38 QPlatformMenu *createMenu() const override;
39
40 bool winEvent(const MSG &message, long *result);
41
42#ifndef QT_NO_DEBUG_STREAM
43 void formatDebug(QDebug &d) const;
44#endif
45
46private:
47 bool isInstalled() const { return m_hwnd != nullptr; }
48 bool ensureInstalled();
49 void ensureCleanup();
50 bool sendTrayMessage(DWORD msg);
51 bool setIconVisible(bool visible);
52 bool isIconVisible() const;
53 HICON createIcon(const QIcon &icon);
54
55 QIcon m_icon;
56 QString m_toolTip;
57 HWND m_hwnd = nullptr;
58 HICON m_hIcon = nullptr;
59 HICON m_hMessageIcon = nullptr;
60 mutable QPointer<QWindowsPopupMenu> m_menu;
61 bool m_ignoreNextMouseRelease = false;
62 bool m_visible = false;
63};
64
65#ifndef QT_NO_DEBUG_STREAM
66QDebug operator<<(QDebug d, const QWindowsSystemTrayIcon *);
67#endif // !QT_NO_DEBUG_STREAM
68
69QT_END_NAMESPACE
70
71#endif // QWINDOWSSYSTEMTRAYICON_H
\inmodule QtCore\reentrant
Definition qpoint.h:29
Singleton container for all relevant information.
QWindowsScreenManager & screenManager()
static QWindowsContext * instance()
const QWindowsScreen * screenAtDp(const QPoint &p) const
Windows native system tray icon.
void cleanup() override
This method is called to cleanup the platform dependent implementation.
bool supportsMessages() const override
Returns true if the system tray supports messages on the platform.
bool isSystemTrayAvailable() const override
Returns true if the system tray is available on the platform.
bool winEvent(const MSG &message, long *result)
void formatDebug(QDebug &d) const
void updateMenu(QPlatformMenu *) override
This method is called when the system tray menu did change.
QPlatformMenu * createMenu() const override
This method allows platforms to use a different QPlatformMenu for system tray menus than what would n...
void updateToolTip(const QString &tooltip) override
This method is called when the tooltip text did change.
void init() override
This method is called to initialize the platform dependent implementation.
void updateIcon(const QIcon &icon) override
This method is called when the icon did change.
void showMessage(const QString &title, const QString &msg, const QIcon &icon, MessageIcon iconType, int msecs) override
Shows a balloon message for the entry with the given title, message msg and icon for the time specifi...
QRect geometry() const override
This method returns the geometry of the platform dependent system tray icon on the screen.
Q_GLOBAL_STATIC(QReadWriteLock, g_updateMutex)
#define MYWM_NOTIFYICON
static void setIconVisibility(NOTIFYICONDATA &tnd, bool v)
static HWND createTrayIconMessageWindow()
static const UINT q_uNOTIFYICONID
static void initNotifyIconData(NOTIFYICONDATA &tnd)
static void setIconContents(NOTIFYICONDATA &tnd, const QString &tip, HICON hIcon)
static uint MYWM_TASKBARCREATED
static void qStringToLimitedWCharArray(QString in, wchar_t *target, int maxLength)
static int indexOfHwnd(HWND hwnd)