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();
173 if (oldMenu && !oldMenu->platformMenu())
180 QScreen *screen = platformScreen ? platformScreen->screen() : nullptr;
181 menu->popup(QHighDpi::fromNativePixels(globalNativePos, screen), nullptr);
190QMenu* QSystemTrayIcon::contextMenu()
const
228 d->toolTip = tooltip;
229 d->updateToolTip_sys();
265 return d->geometry_sys();
281 qWarning(
"QSystemTrayIcon::setVisible: No Icon set");
480 const int closeButtonSize = 15;
482#if QT_CONFIG(pushbutton)
485 closeButton->setIconSize(
QSize(closeButtonSize, closeButtonSize));
487 closeButton->setFixedSize(closeButtonSize, closeButtonSize);
502 if (msgLabel->sizeHint().width() >
limit) {
503 msgLabel->setWordWrap(
true);
504 if (msgLabel->sizeHint().width() >
limit) {
505 msgLabel->d_func()->ensureTextControl();
509 control->document()->setDefaultTextOption(
opt);
514 msgLabel->setFixedSize(
limit, msgLabel->heightForWidth(
limit));
532#if QT_CONFIG(pushbutton)
549QBalloonTip::~QBalloonTip()
565void QBalloonTip::balloon(
const QPoint&
pos,
int msecs,
bool showArrow)
567 this->showArrow = showArrow;
574 const int ah = 18, ao = 18, aw = 18, rc = 7;
576 bool arrowAtLeft = (
pos.
x() + sh.
width() - ao < screenRect.
width());
586 mb = sz.
height() - ah - 1;
595 path.moveTo(ml + rc, mt);
596 if (arrowAtTop && arrowAtLeft) {
598 path.lineTo(ml + ao, mt);
599 path.lineTo(ml + ao, mt - ah);
600 path.lineTo(ml + ao + aw, mt);
603 }
else if (arrowAtTop && !arrowAtLeft) {
605 path.lineTo(mr - ao - aw, mt);
606 path.lineTo(mr - ao, mt - ah);
607 path.lineTo(mr - ao, mt);
611 path.lineTo(mr - rc, mt);
612 path.arcTo(
QRect(mr - rc*2, mt, rc*2, rc*2), 90, -90);
613 path.lineTo(mr, mb - rc);
614 path.arcTo(
QRect(mr - rc*2, mb - rc*2, rc*2, rc*2), 0, -90);
615 if (!arrowAtTop && !arrowAtLeft) {
617 path.lineTo(mr - ao, mb);
618 path.lineTo(mr - ao, mb + ah);
619 path.lineTo(mr - ao - aw, mb);
623 }
else if (!arrowAtTop && arrowAtLeft) {
625 path.lineTo(ao + aw, mb);
626 path.lineTo(ao, mb + ah);
631 path.lineTo(ml + rc, mb);
632 path.arcTo(
QRect(ml, mb - rc*2, rc*2, rc*2), -90, -90);
633 path.lineTo(ml, mt + rc);
634 path.arcTo(
QRect(ml, mt, rc*2, rc*2), 180, -90);
642 painter1.drawPath(
path);
650 painter2.drawPath(
path);
676void QSystemTrayIconPrivate::install_sys_qpa()
688void QSystemTrayIconPrivate::remove_sys_qpa()
697void QSystemTrayIconPrivate::addPlatformMenu(
QMenu *
menu)
const
706 for (
QAction *action : actions) {
708 addPlatformMenu(action->menu());
725#include "moc_qsystemtrayicon.cpp"
726#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.
void setText(const QString &)
void setTextFormat(Qt::TextFormat)
void setPixmap(const QPixmap &)
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
Qt::MouseButton button() const
Returns the button that caused the event.
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 noexcept
Returns true if the string has no characters; otherwise returns false.
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
int timerId() const
Returns the unique timer identifier, which is the same identifier as returned from QObject::startTime...
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