Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-18 09:27:02

0001 // Copyright (C) 2016 The Qt Company Ltd.
0002 // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
0003 // Qt-Security score:significant reason:default
0004 
0005 #ifndef QSYSTEMTRAYICON_H
0006 #define QSYSTEMTRAYICON_H
0007 
0008 #include <QtWidgets/qtwidgetsglobal.h>
0009 #include <QtCore/qobject.h>
0010 
0011 #ifndef QT_NO_SYSTEMTRAYICON
0012 
0013 #include <QtGui/qicon.h>
0014 
0015 QT_BEGIN_NAMESPACE
0016 
0017 
0018 class QSystemTrayIconPrivate;
0019 
0020 class QMenu;
0021 class QEvent;
0022 class QWheelEvent;
0023 class QMouseEvent;
0024 class QPoint;
0025 
0026 class Q_WIDGETS_EXPORT QSystemTrayIcon : public QObject
0027 {
0028     Q_OBJECT
0029     Q_PROPERTY(QString toolTip READ toolTip WRITE setToolTip)
0030     Q_PROPERTY(QIcon icon READ icon WRITE setIcon)
0031     Q_PROPERTY(bool visible READ isVisible WRITE setVisible DESIGNABLE false)
0032 
0033 public:
0034     QSystemTrayIcon(QObject *parent = nullptr);
0035     QSystemTrayIcon(const QIcon &icon, QObject *parent = nullptr);
0036     ~QSystemTrayIcon();
0037 
0038     enum ActivationReason {
0039         Unknown,
0040         Context,
0041         DoubleClick,
0042         Trigger,
0043         MiddleClick
0044     };
0045 
0046 #if QT_CONFIG(menu)
0047     void setContextMenu(QMenu *menu);
0048     QMenu *contextMenu() const;
0049 #endif
0050 
0051     QIcon icon() const;
0052     void setIcon(const QIcon &icon);
0053 
0054     QString toolTip() const;
0055     void setToolTip(const QString &tip);
0056 
0057     static bool isSystemTrayAvailable();
0058     static bool supportsMessages();
0059 
0060     enum MessageIcon { NoIcon, Information, Warning, Critical };
0061 
0062     QRect geometry() const;
0063     bool isVisible() const;
0064 
0065 public Q_SLOTS:
0066     void setVisible(bool visible);
0067     inline void show() { setVisible(true); }
0068     inline void hide() { setVisible(false); }
0069     void showMessage(const QString &title, const QString &msg, const QIcon &icon, int msecs = 10000);
0070     void showMessage(const QString &title, const QString &msg,
0071                      QSystemTrayIcon::MessageIcon icon = QSystemTrayIcon::Information, int msecs = 10000);
0072 
0073 Q_SIGNALS:
0074     void activated(QSystemTrayIcon::ActivationReason reason);
0075     void messageClicked();
0076 
0077 protected:
0078     bool event(QEvent *event) override;
0079 
0080 private:
0081     Q_DISABLE_COPY(QSystemTrayIcon)
0082     Q_DECLARE_PRIVATE(QSystemTrayIcon)
0083 
0084     Q_PRIVATE_SLOT(d_func(), void _q_emitActivated(QPlatformSystemTrayIcon::ActivationReason))
0085 
0086     friend class QSystemTrayIconSys;
0087     friend class QBalloonTip;
0088 };
0089 
0090 QT_END_NAMESPACE
0091 
0092 #endif // QT_NO_SYSTEMTRAYICON
0093 #endif // QSYSTEMTRAYICON_H