43 #ifndef QT_NO_SYSTEMTRAYICON 44 #define _WIN32_IE 0x0600 //required for NOTIFYICONDATA_V2_SIZE 48 #include <QApplication> 53 #define MYWM_NOTIFYICON (WM_APP+101) 67 bool winEvent(
MSG *m,
long *result );
68 bool trayMessage(DWORD msg);
69 void setIconContents(NOTIFYICONDATA &
data);
71 QRect findTrayGeometry();
78 bool ignoreNextMouseRelease;
82 : hIcon(0), q(
object), ignoreNextMouseRelease(
false)
85 notifyIconSize = FIELD_OFFSET(NOTIFYICONDATA, szTip[64]);
98 QPoint brCorner =
qApp->desktop()->screenGeometry().bottomRight();
99 QRect ret(brCorner.
x() - 10, brCorner.
y() - 10, 10, 10);
105 tnd.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP;
111 tip = tip.
left(maxTipLength - 1) +
QChar();
112 memcpy(tnd.szTip, tip.
utf16(),
qMin(tip.
length() + 1, maxTipLength) *
sizeof(
wchar_t));
119 memset(&tnd, 0, notifyIconSize);
121 tnd.cbSize = notifyIconSize;
126 if (msg != NIM_DELETE) {
127 setIconContents(tnd);
130 return Shell_NotifyIcon(msg, &tnd);
136 QIcon icon = q->icon();
141 const QSize preferredSize(GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CYICON));
153 SetWindowLong(winId(), GWL_USERDATA, (LONG)((CREATESTRUCTW*)m->lParam)->lpCreateParams);
162 if (ignoreNextMouseRelease)
163 ignoreNextMouseRelease =
false;
168 case WM_LBUTTONDBLCLK:
169 ignoreNextMouseRelease =
true;
175 if (q->contextMenu()) {
176 q->contextMenu()->popup(gpos);
179 QRect desktopRect =
qApp->desktop()->availableGeometry();
180 int maxY = desktopRect.
y() + desktopRect.
height() - q->contextMenu()->height();
181 if (gpos.
y() > maxY) {
183 q->contextMenu()->move(gpos);
210 sys->trayMessage(NIM_ADD);
222 else uSecs = (int)timeOut;
229 messageString = message.
left(255) +
QChar();
235 QRect trayRect = sys->findTrayGeometry();
237 trayRect.
center().
y()), uSecs,
false);
250 sys->trayMessage(NIM_DELETE);
260 HICON hIconToDestroy = sys->hIcon;
263 sys->trayMessage(NIM_MODIFY);
266 DestroyIcon(hIconToDestroy);
void showMessage_sys(const QString &msg, const QString &title, QSystemTrayIcon::MessageIcon icon, int secs)
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
#define QT_END_NAMESPACE
This macro expands to.
int length() const
Returns the number of characters in this string.
QRect geometry_sys() const
int left() const
Returns the x-coordinate of the rectangle's left edge.
int & ry()
Returns a reference to the y coordinate of this point.
bool winEvent(MSG *m, long *result)
This special event handler can be reimplemented in a subclass to receive native Windows events which ...
int height() const
Returns the height of the rectangle.
The QString class provides a Unicode character string.
static bool supportsMessages_sys()
The QChar class provides a 16-bit Unicode character.
static void showBalloon(QSystemTrayIcon::MessageIcon icon, const QString &title, const QString &msg, QSystemTrayIcon *trayIcon, const QPoint &pos, int timeout, bool showArrow=true)
#define QT_BEGIN_NAMESPACE
This macro expands to.
QString left(int n) const Q_REQUIRED_RESULT
Returns a substring that contains the n leftmost characters of the string.
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
static bool isSystemTrayAvailable_sys()
bool isNull() const
Returns true if the icon is empty; otherwise returns false.
void setIconContents(NOTIFYICONDATA &data)
static const char * data(const QByteArray &arr)
static const UINT q_uNOTIFYICONID
bool isNull() const
Returns true if this string is null; otherwise returns false.
QPoint center() const
Returns the center point of the rectangle.
HICON toWinHICON() const
Returns the HICON handle.
int y() const
Returns the y-coordinate of the rectangle's top edge.
The QPoint class defines a point in the plane using integer precision.
The QRect class defines a rectangle in the plane using integer precision.
int y() const
Returns the y coordinate of this point.
The QPixmap class is an off-screen image representation that can be used as a paint device...
bool trayMessage(DWORD msg)
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 QSize class defines the size of a two-dimensional object using integer point precision.
int x() const
Returns the x coordinate of this point.
bool isNull() const
Returns true if this is a null pixmap; otherwise returns false.
MessageIcon
This enum describes the icon that is shown when a balloon message is displayed.
QSystemTrayIconSys(QSystemTrayIcon *icon, QSystemTrayIconPrivate *d)
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
static QPoint pos()
Returns the position of the cursor (hot spot) in global screen coordinates.
The QSystemTrayIcon class provides an icon for an application in the system tray. ...
const ushort * utf16() const
Returns the QString as a '\0\'-terminated array of unsigned shorts.
The QIcon class provides scalable icons in different modes and states.