summaryrefslogtreecommitdiffstats
path: root/src/gui/util
diff options
context:
space:
mode:
authorminiak <milan.burda@gmail.com>2009-09-22 08:33:27 (GMT)
committerEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>2009-09-22 08:33:27 (GMT)
commitac7fca3606d1a7dd5985b6fc284c40c0f2682fe5 (patch)
tree986d53bf15469aa9207e301b8a1c7c401218dc36 /src/gui/util
parentc0f1055fe809e6f4c90ea7ba3c369b2c01aaae07 (diff)
downloadQt-ac7fca3606d1a7dd5985b6fc284c40c0f2682fe5.zip
Qt-ac7fca3606d1a7dd5985b6fc284c40c0f2682fe5.tar.gz
Qt-ac7fca3606d1a7dd5985b6fc284c40c0f2682fe5.tar.bz2
* QPixmap: Add toWinHICON() & fromWinHICON() method
Duplicate QPixmap <-> HICON conversion code removed from qwidget_win.cpp & qsystemtrayicon_win.cpp. Task-number: 218533 Merge-request: 1570 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>
Diffstat (limited to 'src/gui/util')
-rw-r--r--src/gui/util/qsystemtrayicon_win.cpp34
1 files changed, 1 insertions, 33 deletions
diff --git a/src/gui/util/qsystemtrayicon_win.cpp b/src/gui/util/qsystemtrayicon_win.cpp
index fc3d527..362be5b 100644
--- a/src/gui/util/qsystemtrayicon_win.cpp
+++ b/src/gui/util/qsystemtrayicon_win.cpp
@@ -98,7 +98,6 @@ public:
bool allowsMessages();
bool supportsMessages();
QRect findIconGeometry(const int a_iButtonID);
- HBITMAP createIconMask(const QBitmap &bitmap);
void createIcon();
HICON hIcon;
QPoint globalPos;
@@ -241,21 +240,6 @@ bool QSystemTrayIconSys::iconDrawItem(LPDRAWITEMSTRUCT lpdi)
return true;
}
-HBITMAP QSystemTrayIconSys::createIconMask(const QBitmap &bitmap)
-{
- QImage bm = bitmap.toImage().convertToFormat(QImage::Format_Mono);
- int w = bm.width();
- int h = bm.height();
- int bpl = ((w+15)/16)*2; // bpl, 16 bit alignment
- uchar *bits = new uchar[bpl*h];
- bm.invertPixels();
- for (int y=0; y<h; y++)
- memcpy(bits+y*bpl, bm.scanLine(y), bpl);
- HBITMAP hbm = CreateBitmap(w, h, 1, 1, bits);
- delete [] bits;
- return hbm;
-}
-
void QSystemTrayIconSys::createIcon()
{
hIcon = 0;
@@ -270,23 +254,7 @@ void QSystemTrayIconSys::createIcon()
if (pm.isNull())
return;
- QBitmap mask = pm.mask();
- if (mask.isNull()) {
- mask = QBitmap(pm.size());
- mask.fill(Qt::color1);
- }
-
- HBITMAP im = createIconMask(mask);
- ICONINFO ii;
- ii.fIcon = true;
- ii.hbmMask = im;
- ii.hbmColor = pm.toWinHBITMAP(QPixmap::Alpha);
- ii.xHotspot = 0;
- ii.yHotspot = 0;
- hIcon = CreateIconIndirect(&ii);
-
- DeleteObject(ii.hbmColor);
- DeleteObject(im);
+ hIcon = pm.toWinHICON();
}
bool QSystemTrayIconSys::winEvent( MSG *m, long *result )