Styles manual test: show active, inactive and disabled palette colors
Change-Id: I19c9648f3099ec299e0117748a2808d7a407a3e2 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
This commit is contained in:
parent
40bc8d5129
commit
1b72f9676f
@ -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 =
|
||||
formatEnumValue(role) + QLatin1Char('(') + QString::number(r)
|
||||
+ QLatin1String(") ") + color.name(QColor::HexArgb);
|
||||
grid->addWidget(new QLabel(description), row, 0);
|
||||
+ 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, row, 1);
|
||||
++row;
|
||||
grid->addWidget(displayLabel, r, col);
|
||||
}
|
||||
++col;
|
||||
}
|
||||
}
|
||||
QHBoxLayout *hBox = new QHBoxLayout;
|
||||
|
Loading…
x
Reference in New Issue
Block a user