// Testing get/set functions void tst_QSystemTrayIcon::getSetCheck() { QSystemTrayIcon icon; QCOMPARE(true, icon.toolTip().isEmpty()); icon.setToolTip("testToolTip"); QCOMPARE(true, "testToolTip" == icon.toolTip()); QCOMPARE(true, icon.icon().isNull()); icon.setIcon(QIcon("icons/icon.png")); QCOMPARE(false, icon.icon().isNull()); QMenu menu; QCOMPARE(true, icon.contextMenu() == 0); icon.setContextMenu(&menu); QCOMPARE(false, icon.contextMenu() == 0); }
void QSystemTrayIconSys::setIconContents(NOTIFYICONDATA &tnd) { tnd.uFlags |= NIF_MESSAGE | NIF_ICON | NIF_TIP; tnd.uCallbackMessage = MYWM_NOTIFYICON; tnd.hIcon = hIcon; QString tip = q->toolTip(); if (!tip.isNull()) { tip = tip.left(maxTipLength - 1) + QChar(); memcpy(tnd.szTip, tip.utf16(), qMin(tip.length() + 1, maxTipLength) * sizeof(wchar_t)); } }
void QSystemTrayIconSys::setIconContentsA(NOTIFYICONDATAA &tnd) { tnd.uFlags = NIF_MESSAGE|NIF_ICON|NIF_TIP; tnd.uCallbackMessage = MYWM_NOTIFYICON; tnd.hIcon = hIcon; QString tip = q->toolTip(); if (!tip.isNull()) { // Tip is limited to maxTipLength - NULL; lstrcpyn appends a NULL terminator. tip = tip.left(maxTipLength - 1) + QChar(); #if defined(Q_OS_WINCE) strncpy(tnd.szTip, tip.toLocal8Bit().constData(), qMin(tip.length()+1, maxTipLength)); #else lstrcpynA(tnd.szTip, tip.toLocal8Bit().constData(), qMin(tip.length()+1, maxTipLength)); #endif } }
void QSystemTrayIconSys::setIconContentsW(NOTIFYICONDATAW &tnd) { tnd.uFlags = NIF_MESSAGE|NIF_ICON|NIF_TIP; tnd.uCallbackMessage = MYWM_NOTIFYICON; tnd.hIcon = hIcon; QString tip = q->toolTip(); if (!tip.isNull()) { // Tip is limited to maxTipLength - NULL; lstrcpyn appends a NULL terminator. tip = tip.left(maxTipLength - 1) + QChar(); #if defined(Q_OS_WINCE) wcsncpy(tnd.szTip, reinterpret_cast<const wchar_t *> (tip.utf16()), qMin(tip.length()+1, maxTipLength)); #else lstrcpynW(tnd.szTip, (TCHAR*)tip.utf16(), qMin(tip.length()+1, maxTipLength)); #endif } }