diff options
author | Alessandro Portale <alessandro.portale@qt.io> | 2017-09-19 16:26:33 +0200 |
---|---|---|
committer | Alessandro Portale <alessandro.portale@qt.io> | 2017-10-20 17:56:10 +0000 |
commit | e180244e85573597045e01453fbc503256cb89f9 (patch) | |
tree | 733dc0ab9b3d73ceec2594536ce3073cdea818df /src | |
parent | 35fa833f2981966afd1bacaff286e9ce8c41fa48 (diff) | |
download | qt-creator-e180244e85573597045e01453fbc503256cb89f9.tar.gz |
AutoTest: HighDPI adjustments for TestResultDelegate
- Remove the gap between background rect and division line.
- Consider the QWindow when drawing the icon
Change-Id: Ie10f862f556049ec1bce78a6abe8f6170bd3abaf
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/autotest/testresultdelegate.cpp | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/src/plugins/autotest/testresultdelegate.cpp b/src/plugins/autotest/testresultdelegate.cpp index c6401343b1..6840394831 100644 --- a/src/plugins/autotest/testresultdelegate.cpp +++ b/src/plugins/autotest/testresultdelegate.cpp @@ -33,6 +33,7 @@ #include <QAbstractItemView> #include <QPainter> #include <QTextLayout> +#include <QWindow> namespace Autotest { namespace Internal { @@ -57,20 +58,20 @@ void TestResultDelegate::paint(QPainter *painter, const QStyleOptionViewItem &op painter->save(); QFontMetrics fm(opt.font); + QBrush background; QColor foreground; const QAbstractItemView *view = qobject_cast<const QAbstractItemView *>(opt.widget); const bool selected = opt.state & QStyle::State_Selected; if (selected) { - painter->setBrush(opt.palette.highlight().color()); + background = opt.palette.highlight().color(); foreground = opt.palette.highlightedText().color(); } else { - painter->setBrush(opt.palette.window().color()); + background = opt.palette.window().color(); foreground = opt.palette.text().color(); } - painter->setPen(Qt::NoPen); - painter->drawRect(opt.rect); + painter->fillRect(opt.rect, background); painter->setPen(foreground); TestResultFilterModel *resultFilterModel = static_cast<TestResultFilterModel *>(view->model()); @@ -78,10 +79,13 @@ void TestResultDelegate::paint(QPainter *painter, const QStyleOptionViewItem &op const TestResult *testResult = resultFilterModel->testResult(index); QTC_ASSERT(testResult, painter->restore();return); + const QWidget *widget = dynamic_cast<const QWidget*>(painter->device()); + QWindow *window = widget ? widget->window()->windowHandle() : nullptr; + QIcon icon = index.data(Qt::DecorationRole).value<QIcon>(); if (!icon.isNull()) painter->drawPixmap(positions.left(), positions.top(), - icon.pixmap(positions.iconSize(), positions.iconSize())); + icon.pixmap(window, QSize(positions.iconSize(), positions.iconSize()))); QString typeStr = TestResult::resultToString(testResult->result()); if (selected) { @@ -130,9 +134,10 @@ void TestResultDelegate::paint(QPainter *painter, const QStyleOptionViewItem &op painter->drawText(positions.lineAreaLeft(), positions.top() + fm.ascent(), line); } - painter->setClipRect(opt.rect); + painter->setClipping(false); painter->setPen(opt.palette.mid().color()); - painter->drawLine(0, opt.rect.bottom(), opt.rect.right(), opt.rect.bottom()); + const QRectF adjustedRect(QRectF(opt.rect).adjusted(0.5, 0.5, -0.5, -0.5)); + painter->drawLine(adjustedRect.bottomLeft(), adjustedRect.bottomRight()); painter->restore(); } |