// 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::createIcon() { hIcon = 0; QIcon icon = q->icon(); if (icon.isNull()) return; //const QSize preferredSize(GetSystemMetrics(SM_CXSMICON) * 2, GetSystemMetrics(SM_CYSMICON) * 2); const QSize preferredSize(GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CYICON)); QPixmap pm = icon.pixmap(preferredSize); if (pm.isNull()) return; hIcon = pm.toWinHICON(); }
void QSystemTrayIconSys::createIcon() { hIcon = 0; QIcon icon = q->icon(); if (icon.isNull()) return; const int iconSizeX = GetSystemMetrics(SM_CXSMICON); const int iconSizeY = GetSystemMetrics(SM_CYSMICON); QSize size = icon.actualSize(QSize(iconSizeX, iconSizeY)); QPixmap pm = icon.pixmap(size); if (pm.isNull()) return; hIcon = pm.toWinHICON(); }