diff options
author | Eike Ziller <eike.ziller@qt.io> | 2017-03-21 13:21:40 +0100 |
---|---|---|
committer | Eike Ziller <eike.ziller@qt.io> | 2017-03-24 15:22:07 +0000 |
commit | ad869ba7c76a676032d4f410239eade6bc06eb70 (patch) | |
tree | 9f74b3bedb3818a4b1de8742eb7fecf42f772c42 /src/plugins | |
parent | 3729500740a0e5db3f5c036b20562b36e9db639f (diff) | |
download | qt-creator-ad869ba7c76a676032d4f410239eade6bc06eb70.tar.gz |
SearchResultDelegate: Fix display of icons on HiDPI screens
Visible in e.g. the C++ Symbols search. The icon returns a higher
resolution pixmap, and QItemDelegate::drawDecoration does not position
pixmaps with higher devicePixelRatio correctly. Just draw the icon
ourselves with similar code as QItemDelegate draws icons.
Change-Id: Ia412de026c3fb38d91cb87381475b6884005a231
Reviewed-by: Serhii Moroz <frost.asm@gmail.com>
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/coreplugin/find/searchresulttreeitemdelegate.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/plugins/coreplugin/find/searchresulttreeitemdelegate.cpp b/src/plugins/coreplugin/find/searchresulttreeitemdelegate.cpp index 7bc02adb38..de67e62b99 100644 --- a/src/plugins/coreplugin/find/searchresulttreeitemdelegate.cpp +++ b/src/plugins/coreplugin/find/searchresulttreeitemdelegate.cpp @@ -67,19 +67,20 @@ void SearchResultTreeItemDelegate::paint(QPainter *painter, const QStyleOptionVi // icon QIcon icon = index.model()->data(index, ItemDataRoles::ResultIconRole).value<QIcon>(); - if (!icon.isNull()) - pixmapRect = QRect(0, 0, iconSize, iconSize); + if (!icon.isNull()) { + const QSize size = icon.actualSize(QSize(iconSize, iconSize)); + pixmapRect = QRect(0, 0, size.width(), size.height()); + } // text textRect = opt.rect.adjusted(0, 0, checkRect.width() + pixmapRect.width(), 0); // do layout doLayout(opt, &checkRect, &pixmapRect, &textRect, false); - // ---- draw the items // icon if (!icon.isNull()) - QItemDelegate::drawDecoration(painter, opt, pixmapRect, icon.pixmap(iconSize)); + icon.paint(painter, pixmapRect, option.decorationAlignment); // line numbers int lineNumberAreaWidth = drawLineNumber(painter, opt, textRect, index); |