diff options
author | Alessandro Portale <alessandro.portale@qt.io> | 2020-06-29 19:18:16 +0200 |
---|---|---|
committer | Alessandro Portale <alessandro.portale@qt.io> | 2020-06-30 20:49:09 +0000 |
commit | 42b5aa4acac6db0a970418ffdd400966e86ebda9 (patch) | |
tree | abc934323e8c1cf5de4d69a2bf1fd98912c60589 | |
parent | f9df5b445a7035f3cce848683ccaa740e009b3ab (diff) | |
download | qt-creator-42b5aa4acac6db0a970418ffdd400966e86ebda9.tar.gz |
Target selector: Fix drawing of the run icon
With the new layout calculations (see QTCREATORBUG-24148), the
option rect can now be used to center the icon with the provided
functions in QRect.
The current code kind of works if RunColumnWidth matches the row height,
so that it can do things like subtracting vertical from horizontal
dimensions. But in fact, the icon is not centered on the option.rect.
fillRect(option.rect, Qt::red) <-to verify.
Apart from that it has a few more downsides.
This change:
- Uses the run icon made for dark background
- Paints the icon at its native 16x16px (instead of 15x15px)
- Uses QRect::center()/moveCenter() to actually center the icon
Change-Id: Ib280c650bd454b551f9e30ca108579fee06d81f0
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
-rw-r--r-- | src/plugins/projectexplorer/miniprojecttargetselector.cpp | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/src/plugins/projectexplorer/miniprojecttargetselector.cpp b/src/plugins/projectexplorer/miniprojecttargetselector.cpp index c44bb43daf..38187fd128 100644 --- a/src/plugins/projectexplorer/miniprojecttargetselector.cpp +++ b/src/plugins/projectexplorer/miniprojecttargetselector.cpp @@ -477,14 +477,10 @@ void TargetSelectorDelegate::paint(QPainter *painter, ->setData(index, index.model()->data(index, Qt::UserRole + 1).toString(), Qt::ToolTipRole); painter->drawText(option.rect.left() + 6, option.rect.top() + (option.rect.height() - fm.height()) / 2 + fm.ascent(), elidedText); if (index.column() == 1 && option.state & QStyle::State_MouseOver) { - const QIcon icon = Utils::Icons::RUN_SMALL.icon(); - QRect iconRect(option.rect.right() - option.rect.height(), - option.rect.top(), - option.rect.height() / painter->device()->devicePixelRatio(), - option.rect.height() / painter->device()->devicePixelRatio()); - iconRect.translate((option.rect.width() - iconRect.width()) / 2, - (option.rect.height() - iconRect.height()) / 2); - icon.paint(painter, iconRect, Qt::AlignHCenter | Qt::AlignVCenter); + const QIcon icon = Utils::Icons::RUN_SMALL_TOOLBAR.icon(); + QRect iconRect(0, 0, 16, 16); + iconRect.moveCenter(option.rect.center()); + icon.paint(painter, iconRect); } painter->restore(); |