From 1b72f9676f13fc527d26a5b012ef2322414eaa25 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Fri, 17 Jul 2020 12:21:58 +0200 Subject: Styles manual test: show active, inactive and disabled palette colors Change-Id: I19c9648f3099ec299e0117748a2808d7a407a3e2 Reviewed-by: Volker Hilsheimer --- tests/manual/widgets/styles/main.cpp | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) (limited to 'tests/manual/widgets') 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(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; -- cgit v1.2.3