diff options
Diffstat (limited to 'examples/widgets/gallery/widgetgallery.cpp')
-rw-r--r-- | examples/widgets/gallery/widgetgallery.cpp | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/examples/widgets/gallery/widgetgallery.cpp b/examples/widgets/gallery/widgetgallery.cpp index 2de46419d9..92c878fcb6 100644 --- a/examples/widgets/gallery/widgetgallery.cpp +++ b/examples/widgets/gallery/widgetgallery.cpp @@ -26,6 +26,7 @@ #include <QSpinBox> #include <QStandardItemModel> #include <QStyle> +#include <QStyleHints> #include <QStyleFactory> #include <QTextBrowser> #include <QTreeView> @@ -135,6 +136,19 @@ WidgetGallery::WidgetGallery(QWidget *parent) auto styleLabel = createWidget1<QLabel>(tr("&Style:"), "styleLabel"); styleLabel->setBuddy(styleComboBox); + auto colorSchemeComboBox = createWidget<QComboBox>("colorSchemeComboBox"); + colorSchemeComboBox->addItem(tr("Auto")); + colorSchemeComboBox->addItem(tr("Light")); + colorSchemeComboBox->addItem(tr("Dark")); + colorSchemeComboBox->setCurrentIndex(static_cast<int>(qApp->styleHints()->colorScheme())); + + auto colorSchemeLabel = createWidget1<QLabel>(tr("&Color Scheme:"), "colorSchemeLabel"); + colorSchemeLabel->setBuddy(colorSchemeComboBox); + + connect(colorSchemeComboBox, &QComboBox::currentIndexChanged, this, [](int index){ + QGuiApplication::styleHints()->setColorScheme(static_cast<Qt::ColorScheme>(index)); + }); + auto helpLabel = createWidget1<QLabel>(tr("Press F1 over a widget to see Documentation"), "helpLabel"); auto disableWidgetsCheckBox = createWidget1<QCheckBox>(tr("&Disable widgets"), "disableWidgetsCheckBox"); @@ -156,8 +170,12 @@ WidgetGallery::WidgetGallery(QWidget *parent) simpleInputWidgetsGroupBox, &QWidget::setDisabled); auto topLayout = new QHBoxLayout; - topLayout->addWidget(styleLabel); - topLayout->addWidget(styleComboBox); + auto appearanceLayout = new QGridLayout; + appearanceLayout->addWidget(styleLabel, 0, 0); + appearanceLayout->addWidget(styleComboBox, 0, 1); + appearanceLayout->addWidget(colorSchemeLabel, 1, 0); + appearanceLayout->addWidget(colorSchemeComboBox, 1, 1); + topLayout->addLayout(appearanceLayout); topLayout->addStretch(1); topLayout->addWidget(helpLabel); topLayout->addStretch(1); |