diff options
author | Janne Anttila <janne.anttila@digia.com> | 2009-07-23 11:52:50 (GMT) |
---|---|---|
committer | Janne Anttila <janne.anttila@digia.com> | 2009-07-23 11:52:50 (GMT) |
commit | c7a431ff7f51b1ccd4b0f2a6b3766e1e67f92e4e (patch) | |
tree | 0b77ec016e602d0e942b2d92127c60dd78a658ef /src | |
parent | b0c5020c11913ad1de442ab0ef7e10dec225aec1 (diff) | |
download | Qt-c7a431ff7f51b1ccd4b0f2a6b3766e1e67f92e4e.zip Qt-c7a431ff7f51b1ccd4b0f2a6b3766e1e67f92e4e.tar.gz Qt-c7a431ff7f51b1ccd4b0f2a6b3766e1e67f92e4e.tar.bz2 |
Implemented setWindowIcon for S60 devices without context pane.
Task: 258582
All S60 versions does not have context pane in status bar area, that's
why the window icon was not shown on those devices. Fortunately there
was another API (CAknTitlePane::SetSmallPicture) whicch can be used to
put graphics next to title.
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/kernel/qwidget_s60.cpp | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/gui/kernel/qwidget_s60.cpp b/src/gui/kernel/qwidget_s60.cpp index 8582207..5b05e55 100644 --- a/src/gui/kernel/qwidget_s60.cpp +++ b/src/gui/kernel/qwidget_s60.cpp @@ -703,7 +703,43 @@ void QWidgetPrivate::setWindowIcon_sys(bool forceReset) // Icon set to null -> set context pane picture to default contextPane->SetPictureToDefaultL(); } + } else { + // Context pane does not exist, try setting small icon to title pane + TRect titlePaneRect; + TBool found = AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::ETitlePane, titlePaneRect ); + CAknTitlePane* titlePane = S60->titlePane(); + if (found && titlePane) { // We have title pane with valid metrics + // The API to get title_pane graphics size is not public -> assume square space based + // on titlebar font height. CAknBitmap would be optimum, wihtout setting the size, since + // then title pane would automatically scale the bitmap. Unfortunately it is not public API + const CFont * font = AknLayoutUtils::FontFromId(EAknLogicalFontTitleFont); + TSize iconSize(font->HeightInPixels(), font->HeightInPixels()); + + QIcon icon = q->windowIcon(); + if (!icon.isNull()) { + // Valid icon -> set it as an title pane small picture + QSize size = icon.actualSize(QSize(iconSize.iWidth, iconSize.iHeight)); + QPixmap pm = icon.pixmap(size); + QBitmap mask = pm.mask(); + if (mask.isNull()) { + mask = QBitmap(pm.size()); + mask.fill(Qt::color1); + } + + // Convert to CFbsBitmp + // TODO: When QPixmap is adapted to use native CFbsBitmap, + // it could be set directly to context pane + CFbsBitmap* nBitmap = qt_pixmapToNativeBitmapL(pm, false); + CFbsBitmap* nMask = qt_pixmapToNativeBitmapL(mask, true); + + titlePane->SetSmallPicture( nBitmap, nMask, ETrue ); + } else { + // Icon set to null -> set context pane picture to default + titlePane->SetSmallPicture( NULL, NULL, EFalse ); + } + } } + #else Q_UNUSED(forceReset) #endif |