summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2020-07-17 12:21:58 +0200
committerShawn Rutledge <shawn.rutledge@qt.io>2020-07-17 23:29:27 +0200
commit1b72f9676f13fc527d26a5b012ef2322414eaa25 (patch)
treed48e72a28734a18f944b71008fdad6bc5be608f0 /tests
parent40bc8d51298adf9d342de8195d6ead81a9cc6bcb (diff)
Styles manual test: show active, inactive and disabled palette colors
Change-Id: I19c9648f3099ec299e0117748a2808d7a407a3e2 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/manual/widgets/styles/main.cpp28
1 files changed, 15 insertions, 13 deletions
diff --git a/tests/manual/widgets/styles/main.cpp b/tests/manual/widgets/styles/main.cpp
index 45ceff328b..3a20c3228c 100644
--- a/tests/manual/widgets/styles/main.cpp
+++ b/tests/manual/widgets/styles/main.cpp
@@ -216,22 +216,24 @@ static QWidget *createColorsPage(QWidget *parent)
QWidget *result = new QWidget(parent);
QGridLayout *grid = new QGridLayout;
const QPalette palette = QGuiApplication::palette();
- int row = 0;
for (int r = 0; r < int(QPalette::NColorRoles); ++r) {
const QPalette::ColorRole role = static_cast<QPalette::ColorRole>(r);
- const QColor color = palette.color(QPalette::Active, role);
- if (color.isValid()) {
- const QString description =
+ const QString description =
formatEnumValue(role) + QLatin1Char('(') + QString::number(r)
- + QLatin1String(") ") + color.name(QColor::HexArgb);
- grid->addWidget(new QLabel(description), row, 0);
- QLabel *displayLabel = new QLabel;
- QPixmap pixmap(20, 20);
- pixmap.fill(color);
- displayLabel->setPixmap(pixmap);
- displayLabel->setFrameShape(QFrame::Box);
- grid->addWidget(displayLabel, row, 1);
- ++row;
+ + QLatin1String(") ") + palette.color(QPalette::Active, role).name(QColor::HexArgb);
+ grid->addWidget(new QLabel(description), r, 0);
+ int col = 1;
+ for (int g : {QPalette::Active, QPalette::Inactive, QPalette::Disabled}) {
+ const QColor color = palette.color(QPalette::ColorGroup(g), role);
+ if (color.isValid()) {
+ QLabel *displayLabel = new QLabel;
+ QPixmap pixmap(20, 20);
+ pixmap.fill(color);
+ displayLabel->setPixmap(pixmap);
+ displayLabel->setFrameShape(QFrame::Box);
+ grid->addWidget(displayLabel, r, col);
+ }
+ ++col;
}
}
QHBoxLayout *hBox = new QHBoxLayout;