7#ifndef QT_NO_SYSTEMTRAYICON
17#include "private/qlabel_p.h"
19#if QT_CONFIG(pushbutton)
29#include <private/qhighdpiscaling_p.h>
30#include <qpa/qplatformscreen.h>
161void QSystemTrayIcon::setContextMenu(
QMenu *
menu)
164 QMenu *oldMenu =
d->menu.data();
167 if (oldMenu !=
menu &&
d->qpa_sys) {
176 QScreen *screen = platformScreen ? platformScreen->screen() : nullptr;
177 menu->popup(QHighDpi::fromNativePixels(globalNativePos, screen), nullptr);
186QMenu* QSystemTrayIcon::contextMenu()
const
224 d->toolTip = tooltip;
225 d->updateToolTip_sys();
261 return d->geometry_sys();
277 qWarning(
"QSystemTrayIcon::setVisible: No Icon set");
476 const int closeButtonSize = 15;
478#if QT_CONFIG(pushbutton)
483 closeButton->
setFixedSize(closeButtonSize, closeButtonSize);
501 msgLabel->d_func()->ensureTextControl();
505 control->document()->setDefaultTextOption(
opt);
528#if QT_CONFIG(pushbutton)
545QBalloonTip::~QBalloonTip()
561void QBalloonTip::balloon(
const QPoint&
pos,
int msecs,
bool showArrow)
563 this->showArrow = showArrow;
570 const int ah = 18, ao = 18, aw = 18, rc = 7;
572 bool arrowAtLeft = (
pos.
x() + sh.
width() - ao < screenRect.
width());
582 mb = sz.
height() - ah - 1;
591 path.moveTo(ml + rc, mt);
592 if (arrowAtTop && arrowAtLeft) {
594 path.lineTo(ml + ao, mt);
595 path.lineTo(ml + ao, mt - ah);
596 path.lineTo(ml + ao + aw, mt);
599 }
else if (arrowAtTop && !arrowAtLeft) {
601 path.lineTo(mr - ao - aw, mt);
602 path.lineTo(mr - ao, mt - ah);
603 path.lineTo(mr - ao, mt);
607 path.lineTo(mr - rc, mt);
608 path.arcTo(
QRect(mr - rc*2, mt, rc*2, rc*2), 90, -90);
609 path.lineTo(mr, mb - rc);
610 path.arcTo(
QRect(mr - rc*2, mb - rc*2, rc*2, rc*2), 0, -90);
611 if (!arrowAtTop && !arrowAtLeft) {
613 path.lineTo(mr - ao, mb);
614 path.lineTo(mr - ao, mb + ah);
615 path.lineTo(mr - ao - aw, mb);
619 }
else if (!arrowAtTop && arrowAtLeft) {
621 path.lineTo(ao + aw, mb);
622 path.lineTo(ao, mb + ah);
627 path.lineTo(ml + rc, mb);
628 path.arcTo(
QRect(ml, mb - rc*2, rc*2, rc*2), -90, -90);
629 path.lineTo(ml, mt + rc);
630 path.arcTo(
QRect(ml, mt, rc*2, rc*2), 180, -90);
638 painter1.drawPath(
path);
646 painter2.drawPath(
path);
662 if (
e->timerId() == timerId) {
672void QSystemTrayIconPrivate::install_sys_qpa()
684void QSystemTrayIconPrivate::remove_sys_qpa()
693void QSystemTrayIconPrivate::addPlatformMenu(
QMenu *
menu)
const
702 for (
QAction *action : actions) {
704 addPlatformMenu(action->menu());
721#include "moc_qsystemtrayicon.cpp"
722#include "moc_qsystemtrayicon_p.cpp"
The QAction class provides an abstraction for user commands that can be added to different user inter...
static QStyle * style()
Returns the application's style object.
static void hideBalloon()
static bool isBalloonVisible()
static void updateBalloonPosition(const QPoint &pos)
static void showBalloon(const QIcon &icon, const QString &title, const QString &msg, QSystemTrayIcon *trayIcon, const QPoint &pos, int timeout, bool showArrow=true)
void timerEvent(QTimerEvent *e) override
This event handler can be reimplemented in a subclass to receive timer events for the object.
void mousePressEvent(QMouseEvent *e) override
This event handler, for event event, can be reimplemented in a subclass to receive mouse press events...
void paintEvent(QPaintEvent *) override
This event handler can be reimplemented in a subclass to receive paint events passed in event.
void resizeEvent(QResizeEvent *) override
This event handler can be reimplemented in a subclass to receive widget resize events which are passe...
The QColor class provides colors based on RGB, HSV or CMYK values.
void setBold(bool)
If enable is true sets the font's weight to \l{Weight}{QFont::Bold}; otherwise sets the weight to \l{...
The QGridLayout class lays out widgets in a grid.
QScreen * primaryScreen
the primary (or default) screen of the application.
static QScreen * screenAt(const QPoint &point)
Returns the screen at point, or \nullptr if outside of any screen.
The QIcon class provides scalable icons in different modes and states.
bool isNull() const
Returns true if the icon is empty; otherwise returns false.
QPixmap pixmap(const QSize &size, Mode mode=Normal, State state=Off) const
Returns a pixmap with the requested size, mode, and state, generating one if necessary.
The QLabel widget provides a text or image display.
int heightForWidth(int) const override
\reimp
void setText(const QString &)
void setTextFormat(Qt::TextFormat)
void setPixmap(const QPixmap &)
void setAlignment(Qt::Alignment)
void setWordWrap(bool on)
QSize sizeHint() const override
\reimp
void addWidget(QWidget *w)
Adds widget w to this layout in a manner specific to the layout.
void setSizeConstraint(SizeConstraint)
void setContentsMargins(int left, int top, int right, int bottom)
int startTimer(int interval, Qt::TimerType timerType=Qt::CoarseTimer)
This is an overloaded function that will start a timer of type timerType and a timeout of interval mi...
void installEventFilter(QObject *filterObj)
Installs an event filter filterObj on this object.
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
virtual bool event(QEvent *event)
This virtual function receives events to an object and should return true if the event e was recogniz...
static bool disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *member)
\threadsafe
virtual void timerEvent(QTimerEvent *event)
This event handler can be reimplemented in a subclass to receive timer events for the object.
void destroyed(QObject *=nullptr)
This signal is emitted immediately before the object obj is destroyed, after any instances of QPointe...
void killTimer(int id)
Kills the timer with timer identifier, id.
The QPaintEvent class contains event parameters for paint events.
The QPainter class performs low-level painting on widgets and other paint devices.
void drawPixmap(const QRectF &targetRect, const QPixmap &pixmap, const QRectF &sourceRect)
Draws the rectangular portion source of the given pixmap into the given target in the paint device.
The QPalette class contains color groups for each widget state.
void setColor(ColorGroup cg, ColorRole cr, const QColor &color)
Sets the color in the specified color group, used for the given color role, to the specified solid co...
\inmodule QtCore\reentrant
constexpr int x() const noexcept
Returns the x coordinate of this point.
constexpr int y() const noexcept
Returns the y coordinate of this point.
\inmodule QtCore\reentrant
constexpr int height() const noexcept
Returns the height of the rectangle.
constexpr int left() const noexcept
Returns the x-coordinate of the rectangle's left edge.
constexpr int x() const noexcept
Returns the x-coordinate of the rectangle's left edge.
constexpr int width() const noexcept
Returns the width of the rectangle.
constexpr int right() const noexcept
Returns the x-coordinate of the rectangle's right edge.
The QResizeEvent class contains event parameters for resize events.
The QScreen class is used to query screen properties. \inmodule QtGui.
QRect geometry
the screen's geometry in pixels
constexpr int height() const noexcept
Returns the height.
constexpr int width() const noexcept
Returns the width.
\macro QT_RESTRICTED_CAST_FROM_ASCII
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
virtual QIcon standardIcon(StandardPixmap standardIcon, const QStyleOption *option=nullptr, const QWidget *widget=nullptr) const =0
StandardPixmap
This enum describes the available standard pixmaps.
@ SP_MessageBoxInformation
static bool isSystemTrayAvailable_sys()
void _q_emitActivated(QPlatformSystemTrayIcon::ActivationReason reason)
static bool supportsMessages_sys()
QPlatformSystemTrayIcon * qpa_sys
The QSystemTrayIcon class provides an icon for an application in the system tray.
ActivationReason
This enum describes the reason the system tray was activated.
bool event(QEvent *event) override
\reimp
MessageIcon
This enum describes the icon that is shown when a balloon message is displayed.
QIcon icon
the system tray icon
void messageClicked()
This signal is emitted when the message displayed using showMessage() was clicked by the user.
void setToolTip(const QString &tip)
void showMessage(const QString &title, const QString &msg, const QIcon &icon, int msecs=10000)
static bool isSystemTrayAvailable()
Returns true if the system tray is available; otherwise returns false.
static bool supportsMessages()
Returns true if the system tray supports balloon messages; otherwise returns false.
void setVisible(bool visible)
QSystemTrayIcon(QObject *parent=nullptr)
Constructs a QSystemTrayIcon object with the given parent.
~QSystemTrayIcon()
Removes the icon from the system tray and frees all allocated resources.
void setIcon(const QIcon &icon)
QString toolTip
the tooltip for the system tray entry
bool visible
whether the system tray entry is visible
Combined button and popup list for selecting options.
constexpr const T & qMin(const T &a, const T &b)
constexpr const T & qMax(const T &a, const T &b)
GLbitfield GLuint64 timeout
[4]
GLint GLenum GLsizei GLsizei GLsizei GLint border
GLuint GLsizei const GLchar * message
GLsizei GLfixed GLfixed GLfixed GLfixed const GLubyte * bitmap
GLdouble GLdouble GLdouble GLdouble q
GLsizei const GLchar *const * path
static QT_BEGIN_NAMESPACE QIcon messageIcon2qIcon(QSystemTrayIcon::MessageIcon icon)
static QBalloonTip * theSolitaryBalloonTip
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent