summaryrefslogtreecommitdiffstats
path: root/Swift
diff options
context:
space:
mode:
authorTobias Markmann <tm@ayena.de>2016-08-18 16:06:27 (GMT)
committerTobias Markmann <tm@ayena.de>2016-08-18 16:11:50 (GMT)
commita9599ff4edfdc0186b2f5ae3bd22f25cdeb686d1 (patch)
tree499cd58ab34ac88765ed4072c5c44f19537f4242 /Swift
parent55a977f2a4dcda32f01dab3bb673d808e9d3f3c6 (diff)
downloadswift-a9599ff4edfdc0186b2f5ae3bd22f25cdeb686d1.zip
swift-a9599ff4edfdc0186b2f5ae3bd22f25cdeb686d1.tar.bz2
Tweak grid selection dialog rendering
Recent testing on Debian 8 showed two rendering issues: 1. CE_MenuBarItem in the selected state shows drawing artifacts for our drawing size with Debian's default style. 2. CE_SizeGrip shows drawing artifacts unless it's drawn at position (0,0). Removed size grip as the resizability signification is also provided by the description text. Cells are drawn as simple squares in the palette's highlight color. Test-Information: Verified that there are no artifacts and the dialog is usable on Debian 8, Windows 8 and OS X 10.11.6. Change-Id: I9eaf1e1fd34d035ec3dffcb0dc29efca40d6da24
Diffstat (limited to 'Swift')
-rw-r--r--Swift/QtUI/Trellis/QtGridSelectionDialog.cpp23
1 files changed, 7 insertions, 16 deletions
diff --git a/Swift/QtUI/Trellis/QtGridSelectionDialog.cpp b/Swift/QtUI/Trellis/QtGridSelectionDialog.cpp
index 6bddb34..f03d0ec 100644
--- a/Swift/QtUI/Trellis/QtGridSelectionDialog.cpp
+++ b/Swift/QtUI/Trellis/QtGridSelectionDialog.cpp
@@ -11,9 +11,7 @@
#include <QPaintEvent>
#include <QPainter>
#include <QStyle>
-#include <QStyleOptionFrame>
-#include <QStyleOptionMenuItem>
-#include <QStyleOptionSizeGrip>
+#include <QStyleOption>
namespace Swift {
@@ -106,18 +104,16 @@ void QtGridSelectionDialog::mousePressEvent(QMouseEvent*) {
void QtGridSelectionDialog::paintEvent(QPaintEvent*) {
QPainter painter(this);
- QStyleOptionMenuItem option;
- option.state = QStyle::State_Enabled | QStyle::State_Selected | QStyle::State_Sunken;
- option.menuRect = QRect(QPoint(0,0), frameSize);
-
// draw grid
+ QRect gridCell = QRect(QPoint(0,0), frameSize);
+ painter.setBrush(palette().highlight());
+ painter.setPen(Qt::NoPen);
for (int x = 0; x < currentGridSize.width(); x++) {
for (int y = 0; y < currentGridSize.height(); y++) {
int xPos = horizontalMargin + (x * (frameSize.width() + padding));
int yPos = verticalMargin + (y * (frameSize.height() + padding));
- option.menuRect.moveTo(QPoint(xPos, yPos));
- option.rect = option.menuRect;
- style()->drawControl(QStyle::CE_MenuBarItem, &option, &painter, nullptr);
+ gridCell.moveTo(QPoint(xPos, yPos));
+ painter.drawRect(gridCell);
}
}
@@ -126,15 +122,10 @@ void QtGridSelectionDialog::paintEvent(QPaintEvent*) {
auto descriptionBB = fontMetrics.boundingRect(QRect(0,0, width() - 2 * horizontalMargin,0), Qt::AlignHCenter | Qt::AlignTop | Qt::TextWordWrap, descriptionText, 0, 0);
QStyleOption opt;
+ opt.initFrom(this);
int textY = verticalMargin + (currentGridSize.height() * (frameSize.height() + padding));
int textX = (size().width() - descriptionBB.width()) / 2;
style()->drawItemText(&painter, QRect(textX, textY, descriptionBB.width(), descriptionBB.height()), Qt::AlignHCenter | Qt::AlignTop | Qt::TextWordWrap, opt.palette, true, descriptionText, foregroundRole());
-
- // draw size grip at bottom right corner;
- QStyleOptionSizeGrip sizeGripOption;
- sizeGripOption.init(this);
- sizeGripOption.corner = Qt::BottomRightCorner;
- style()->drawControl(QStyle::CE_SizeGrip, &sizeGripOption, &painter, this);
}
void QtGridSelectionDialog::showEvent(QShowEvent*) {