Qt Utilities 6.14.5
Common Qt related C++ classes and routines used by my applications such as dialogs, widgets and models
Loading...
Searching...
No Matches
qtsettings.cpp
Go to the documentation of this file.
1#include "./qtsettings.h"
2
5
6#if defined(QT_UTILITIES_GUI_QTWIDGETS)
7#include "./optioncategory.h"
10#include "./optionpage.h"
11
14#endif
15
16#include "resources/config.h"
17
18#if defined(QT_UTILITIES_GUI_QTWIDGETS)
19#include "ui_qtappearanceoptionpage.h"
20#include "ui_qtenvoptionpage.h"
21#include "ui_qtlanguageoptionpage.h"
22#endif
23
24#include <c++utilities/application/commandlineutils.h>
25
26#include <QDir>
27#include <QFont>
28#include <QGuiApplication>
29#include <QIcon>
30#include <QLocale>
31#include <QOperatingSystemVersion>
32#include <QPalette>
33#include <QSettings>
34#include <QStringBuilder>
35#include <QVersionNumber>
36
37#if defined(QT_UTILITIES_GUI_QTWIDGETS)
38#include <QFileDialog>
39#include <QFontDialog>
40#include <QStyleFactory>
41#endif
42
43#if defined(Q_OS_WINDOWS) && (QT_VERSION >= QT_VERSION_CHECK(6, 3, 0)) && (QT_VERSION < QT_VERSION_CHECK(6, 7, 0))
44#include <QOperatingSystemVersion>
45#define QT_UTILITIES_USE_FUSION_ON_WINDOWS_11
46#endif
47
48#include <iostream>
49#include <memory>
50#include <optional>
51
52namespace QtUtilities {
53
56
57 QFont font;
58 std::optional<QFont> initialFont;
59 QPalette palette; // the currently applied palette (only in use if customPalette is true, though)
60 QPalette selectedPalette; // the intermediately selected palette (chosen in palette editor but not yet applied)
61#if defined(QT_UTILITIES_GUI_QTWIDGETS)
62 QString widgetStyle;
63 QString initialWidgetStyle;
64 QString styleSheetPath;
65#endif
66 QString iconTheme;
70 QString localeName;
77#if defined(QT_UTILITIES_GUI_QTWIDGETS)
78 bool customWidgetStyle;
79 bool customStyleSheet;
80#endif
84#if defined(QT_UTILITIES_GUI_QTWIDGETS)
85 bool showNotices;
86 bool retranslatable;
87#endif
88};
89
91 : iconTheme(QIcon::themeName())
94 , customFont(false)
95 , customPalette(false)
96#if defined(QT_UTILITIES_GUI_QTWIDGETS)
97 , customWidgetStyle(false)
98 , customStyleSheet(false)
99#endif
100 , customIconTheme(false)
101 , customLocale(false)
102 , isPaletteDark(false)
103#if defined(QT_UTILITIES_GUI_QTWIDGETS)
104 , showNotices(true)
105 , retranslatable(false)
106#endif
107{
108}
109
118 : m_d(std::make_unique<QtSettingsData>())
119{
120}
121
130
131#if defined(QT_UTILITIES_GUI_QTWIDGETS)
143void QtSettings::disableNotices()
144{
145 m_d->showNotices = false;
146}
147
156void QtSettings::setRetranslatable(bool retranslatable)
157{
158 m_d->retranslatable = retranslatable;
159}
160#endif
161
166{
167 return m_d->customFont;
168}
169
176void QtSettings::restore(QSettings &settings)
177{
178 settings.beginGroup(QStringLiteral("qt"));
179 m_d->font.fromString(settings.value(QStringLiteral("font")).toString());
180 m_d->customFont = settings.value(QStringLiteral("customfont"), false).toBool();
181 m_d->palette = settings.value(QStringLiteral("palette")).value<QPalette>();
182 m_d->customPalette = settings.value(QStringLiteral("custompalette"), false).toBool();
183#if defined(QT_UTILITIES_GUI_QTWIDGETS)
184 m_d->widgetStyle = settings.value(QStringLiteral("widgetstyle"), m_d->widgetStyle).toString();
185 m_d->customWidgetStyle = settings.value(QStringLiteral("customwidgetstyle"), false).toBool();
186 m_d->styleSheetPath = settings.value(QStringLiteral("stylesheetpath"), m_d->styleSheetPath).toString();
187 m_d->customStyleSheet = settings.value(QStringLiteral("customstylesheet"), false).toBool();
188#endif
189 m_d->iconTheme = settings.value(QStringLiteral("icontheme"), m_d->iconTheme).toString();
190 m_d->customIconTheme = settings.value(QStringLiteral("customicontheme"), false).toBool();
191 m_d->localeName = settings.value(QStringLiteral("locale"), m_d->localeName).toString();
192 m_d->customLocale = settings.value(QStringLiteral("customlocale"), false).toBool();
193 m_d->additionalPluginDirectory = settings.value(QStringLiteral("plugindir")).toString();
194 m_d->additionalIconThemeSearchPath = settings.value(QStringLiteral("iconthemepath")).toString();
195 TranslationFiles::additionalTranslationFilePath() = settings.value(QStringLiteral("trpath")).toString();
196 settings.endGroup();
197}
198
202void QtSettings::save(QSettings &settings) const
203{
204 settings.beginGroup(QStringLiteral("qt"));
205 settings.setValue(QStringLiteral("font"), QVariant(m_d->font.toString()));
206 settings.setValue(QStringLiteral("customfont"), m_d->customFont);
207 settings.setValue(QStringLiteral("palette"), QVariant(m_d->palette));
208 settings.setValue(QStringLiteral("custompalette"), m_d->customPalette);
209#if defined(QT_UTILITIES_GUI_QTWIDGETS)
210 settings.setValue(QStringLiteral("widgetstyle"), m_d->widgetStyle);
211 settings.setValue(QStringLiteral("customwidgetstyle"), m_d->customWidgetStyle);
212 settings.setValue(QStringLiteral("stylesheetpath"), m_d->styleSheetPath);
213 settings.setValue(QStringLiteral("customstylesheet"), m_d->customStyleSheet);
214#endif
215 settings.setValue(QStringLiteral("icontheme"), m_d->iconTheme);
216 settings.setValue(QStringLiteral("customicontheme"), m_d->customIconTheme);
217 settings.setValue(QStringLiteral("locale"), m_d->localeName);
218 settings.setValue(QStringLiteral("customlocale"), m_d->customLocale);
219 settings.setValue(QStringLiteral("plugindir"), m_d->additionalPluginDirectory);
220 settings.setValue(QStringLiteral("iconthemepath"), m_d->additionalIconThemeSearchPath);
221 settings.setValue(QStringLiteral("trpath"), QVariant(TranslationFiles::additionalTranslationFilePath()));
222 settings.endGroup();
223}
224
230static QMap<QString, QString> scanIconThemes(const QStringList &searchPaths)
231{
232 auto res = QMap<QString, QString>();
233 for (const auto &searchPath : searchPaths) {
234 const auto dir = QDir(searchPath).entryList(QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name);
235 for (const auto &iconTheme : dir) {
236 auto indexFile = QFile(searchPath % QChar('/') % iconTheme % QStringLiteral("/index.theme"));
237 auto index = QByteArray();
238 if (indexFile.open(QFile::ReadOnly) && !(index = indexFile.readAll()).isEmpty()) {
239 const auto iconThemeSection = index.indexOf("[Icon Theme]");
240 const auto nameStart = index.indexOf("Name=", iconThemeSection != -1 ? iconThemeSection : 0);
241 if (nameStart != -1) {
242 auto nameLength = index.indexOf("\n", nameStart) - nameStart - 5;
243 if (nameLength > 0) {
244 auto displayName = QString::fromUtf8(index.mid(nameStart + 5, nameLength));
245 if (displayName != iconTheme) {
246 displayName += QChar(' ') % QChar('(') % iconTheme % QChar(')');
247 }
248 res[displayName] = iconTheme;
249 continue;
250 }
251 }
252 }
253 res[iconTheme] = iconTheme;
254 }
255 }
256 return res;
257}
258
271{
272 // apply environment
273 if (m_d->additionalPluginDirectory != m_d->previousPluginDirectory) {
274 if (!m_d->previousPluginDirectory.isEmpty()) {
275 QCoreApplication::removeLibraryPath(m_d->previousPluginDirectory);
276 }
277 if (!m_d->additionalPluginDirectory.isEmpty()) {
278 QCoreApplication::addLibraryPath(m_d->additionalPluginDirectory);
279 }
280 m_d->previousPluginDirectory = m_d->additionalPluginDirectory;
281 }
282 if (m_d->additionalIconThemeSearchPath != m_d->previousIconThemeSearchPath) {
283 auto paths = QIcon::themeSearchPaths();
284 if (!m_d->previousIconThemeSearchPath.isEmpty()) {
285 paths.removeAll(m_d->previousIconThemeSearchPath);
286 }
287 if (!m_d->additionalIconThemeSearchPath.isEmpty()) {
288 paths.append(m_d->additionalIconThemeSearchPath);
289 }
290 m_d->previousIconThemeSearchPath = m_d->additionalIconThemeSearchPath;
291 QIcon::setThemeSearchPaths(paths);
292 }
293
294#if defined(QT_UTILITIES_GUI_QTWIDGETS)
295 // read style sheet
296 auto styleSheet = QString();
297 if (m_d->customStyleSheet && !m_d->styleSheetPath.isEmpty()) {
298 auto file = QFile(m_d->styleSheetPath);
299 if (!file.open(QFile::ReadOnly)) {
300 std::cerr << "Unable to open the specified stylesheet \"" << m_d->styleSheetPath.toLocal8Bit().data() << "\"." << std::endl;
301 }
302 styleSheet.append(file.readAll());
303 if (file.error() != QFile::NoError) {
304 std::cerr << "Unable to read the specified stylesheet \"" << m_d->styleSheetPath.toLocal8Bit().data() << "\"." << std::endl;
305 }
306 }
307#endif
308
309 // apply appearance
310 if (m_d->customFont) {
311 if (!m_d->initialFont.has_value()) {
312 m_d->initialFont = QGuiApplication::font();
313 }
314 QGuiApplication::setFont(m_d->font);
315 } else if (m_d->initialFont.has_value()) {
316 QGuiApplication::setFont(m_d->initialFont.value());
317 }
318#if defined(QT_UTILITIES_GUI_QTWIDGETS)
319#ifdef QT_UTILITIES_USE_FUSION_ON_WINDOWS_11
320 if (m_d->initialWidgetStyle.isEmpty()) {
321 // use Fusion on Windows 11 as the native style doesn't look good
322 // see https://bugreports.qt.io/browse/QTBUG-97668
323 if (QOperatingSystemVersion::current() >= QOperatingSystemVersion::Windows11) {
324 m_d->initialWidgetStyle = QStringLiteral("Fusion");
325 }
326 }
327#endif
328 if (m_d->customWidgetStyle) {
329#if QT_VERSION >= QT_VERSION_CHECK(6, 1, 0)
330 const auto *const currentStyle = QApplication::style();
331 if (m_d->initialWidgetStyle.isEmpty() && currentStyle) {
332 m_d->initialWidgetStyle = currentStyle->name();
333 }
334#endif
335 QApplication::setStyle(m_d->widgetStyle);
336 } else if (!m_d->initialWidgetStyle.isEmpty()) {
337 QApplication::setStyle(m_d->initialWidgetStyle);
338 }
339 if (auto *const qapp = qobject_cast<QApplication *>(QApplication::instance())) {
340 qapp->setStyleSheet(styleSheet);
341 } else {
342 std::cerr << "Unable to apply the specified stylesheet \"" << m_d->styleSheetPath.toLocal8Bit().data()
343 << "\" because no QApplication has been instantiated." << std::endl;
344 }
345#endif
346 if (m_d->customPalette) {
347 QGuiApplication::setPalette(m_d->palette);
348 } else {
349 QGuiApplication::setPalette(QPalette());
350 }
351 m_d->isPaletteDark = QtUtilities::isPaletteDark();
352 if (m_d->customIconTheme) {
353 QIcon::setThemeName(m_d->iconTheme);
354 } else if (!m_d->initialIconTheme.isEmpty()) {
355 if (m_d->iconTheme != m_d->initialIconTheme) {
356 // set the icon theme back to what it was before changing anything (not sure how to read the current system icon theme again)
357 QIcon::setThemeName(m_d->initialIconTheme);
358 }
359 } else {
360 // use bundled default icon theme matching the current palette
361 // notes: - It is ok that search paths specified via CLI arguments are not set here yet. When doing so one should also
362 // specify the desired icon theme explicitly.
363 // - The icon themes "default" and "default-dark" come from QtConfig.cmake which makes the first non-dark bundled
364 // icon theme available as "default" and the first dark icon theme available as "default-dark". An icon theme
365 // is considered dark if it ends with "-dark".
366 const auto bundledIconThemes = scanIconThemes(QStringList(QStringLiteral(":/icons")));
367 if (m_d->isPaletteDark && bundledIconThemes.contains(QStringLiteral("default-dark"))) {
368 QIcon::setThemeName(QStringLiteral("default-dark"));
369 } else if (bundledIconThemes.contains(QStringLiteral("default"))) {
370 QIcon::setThemeName(QStringLiteral("default"));
371 }
372 }
373
374 // apply locale
375 m_d->previousLocale = QLocale();
376 QLocale::setDefault(m_d->customLocale ? QLocale(m_d->localeName) : m_d->defaultLocale);
377
378 // log some debug information on the first call if env variable set
379 static auto debugInfoLogged = false;
380 if (debugInfoLogged) {
381 return;
382 }
383 const auto debugLoggingEnabled = CppUtilities::isEnvVariableSet(PROJECT_VARNAME_UPPER "_LOG_QT_CONFIG");
384 if (debugLoggingEnabled.has_value() && debugLoggingEnabled.value()) {
385 if (const auto os = QOperatingSystemVersion::current(); os.type() != static_cast<decltype(os.type())>(QOperatingSystemVersion::Unknown)) {
386 const auto version = QVersionNumber(os.majorVersion(), os.minorVersion(), os.microVersion());
387 std::cerr << "OS name and version: " << os.name().toStdString() << ' ' << version.toString().toStdString() << '\n';
388 }
389 std::cerr << "Qt version: " << qVersion() << '\n';
390 std::cerr << "Qt platform (set QT_QPA_PLATFORM to override): " << QGuiApplication::platformName().toStdString() << '\n';
391 std::cerr << "Qt locale: " << QLocale().name().toStdString() << '\n';
392 std::cerr << "Qt library paths: " << QCoreApplication::libraryPaths().join(':').toStdString() << '\n';
393 std::cerr << "Qt theme search paths: " << QIcon::themeSearchPaths().join(':').toStdString() << '\n';
394 std::cerr << "Darkmode enabled: " << (QtUtilities::isDarkModeEnabled() ? "yes" : "no") << '\n';
395 std::cerr << "Is Qt palette dark: " << (m_d->isPaletteDark ? "yes" : "no") << '\n';
396 debugInfoLogged = true;
397 }
398}
399
417{
418 if (isPaletteDark == m_d->isPaletteDark) {
419 return; // no need to do anything if there's no change
420 }
421 m_d->isPaletteDark = isPaletteDark;
422 if (auto iconTheme = QIcon::themeName(); iconTheme == QStringLiteral("default") || iconTheme == QStringLiteral("default-dark")) {
423 QIcon::setThemeName(m_d->isPaletteDark ? QStringLiteral("default-dark") : QStringLiteral("default"));
424 }
425}
426
441
449{
450 return m_d->isPaletteDark;
451}
452
457{
458 return m_d->previousLocale != QLocale();
459}
460
461#if defined(QT_UTILITIES_GUI_QTWIDGETS)
471{
472 auto *category = new OptionCategory;
473 category->setDisplayName(QCoreApplication::translate("QtGui::QtOptionCategory", "Qt"));
474 category->setIcon(QIcon::fromTheme(QStringLiteral("qtcreator"), QIcon(QStringLiteral(":/qtutilities/icons/hicolor/48x48/apps/qtcreator.svg"))));
475 category->assignPages({ new QtAppearanceOptionPage(*m_d), new QtLanguageOptionPage(*m_d), new QtEnvOptionPage(*m_d) });
476 return category;
477}
478
479QtAppearanceOptionPage::QtAppearanceOptionPage(QtSettingsData &settings, QWidget *parentWidget)
480 : QtAppearanceOptionPageBase(parentWidget)
481 , m_settings(settings)
482 , m_fontDialog(nullptr)
483{
484}
485
486QtAppearanceOptionPage::~QtAppearanceOptionPage()
487{
488}
489
490bool QtAppearanceOptionPage::apply()
491{
492 m_settings.font = ui()->fontComboBox->currentFont();
493 m_settings.customFont = !ui()->fontCheckBox->isChecked();
494 m_settings.widgetStyle = ui()->widgetStyleComboBox->currentText();
495 m_settings.customWidgetStyle = !ui()->widgetStyleCheckBox->isChecked();
496 m_settings.styleSheetPath = ui()->styleSheetPathSelection->lineEdit()->text();
497 m_settings.customStyleSheet = !ui()->styleSheetCheckBox->isChecked();
498 m_settings.palette = m_settings.selectedPalette;
499 m_settings.customPalette = !ui()->paletteCheckBox->isChecked();
500 m_settings.iconTheme
501 = ui()->iconThemeComboBox->currentIndex() != -1 ? ui()->iconThemeComboBox->currentData().toString() : ui()->iconThemeComboBox->currentText();
502 m_settings.customIconTheme = !ui()->iconThemeCheckBox->isChecked();
503 return true;
504}
505
506void QtAppearanceOptionPage::reset()
507{
508 ui()->fontComboBox->setCurrentFont(m_settings.font);
509 ui()->fontCheckBox->setChecked(!m_settings.customFont);
510 ui()->widgetStyleComboBox->setCurrentText(
511 m_settings.widgetStyle.isEmpty() ? (QApplication::style() ? QApplication::style()->objectName() : QString()) : m_settings.widgetStyle);
512 ui()->widgetStyleCheckBox->setChecked(!m_settings.customWidgetStyle);
513 ui()->styleSheetPathSelection->lineEdit()->setText(m_settings.styleSheetPath);
514 ui()->styleSheetCheckBox->setChecked(!m_settings.customStyleSheet);
515 m_settings.selectedPalette = m_settings.palette;
516 ui()->paletteCheckBox->setChecked(!m_settings.customPalette);
517 int iconThemeIndex = ui()->iconThemeComboBox->findData(m_settings.iconTheme);
518 if (iconThemeIndex != -1) {
519 ui()->iconThemeComboBox->setCurrentIndex(iconThemeIndex);
520 } else {
521 ui()->iconThemeComboBox->setCurrentText(m_settings.iconTheme);
522 }
523 ui()->iconThemeCheckBox->setChecked(!m_settings.customIconTheme);
524}
525
526QWidget *QtAppearanceOptionPage::setupWidget()
527{
528 // call base implementation first, so ui() is available
529 auto *widget = QtAppearanceOptionPageBase::setupWidget();
530 if (!m_settings.showNotices) {
531 ui()->label->hide();
532 }
533
534 // setup widget style selection
535 ui()->widgetStyleComboBox->addItems(QStyleFactory::keys());
536
537 // setup style sheet selection
538 ui()->styleSheetPathSelection->provideCustomFileMode(QFileDialog::ExistingFile);
539
540 // setup font selection
541 QObject::connect(ui()->fontPushButton, &QPushButton::clicked, widget, [this] {
542 if (!m_fontDialog) {
543 m_fontDialog = new QFontDialog(this->widget());
544 m_fontDialog->setCurrentFont(ui()->fontComboBox->font());
545 QObject::connect(m_fontDialog, &QFontDialog::fontSelected, ui()->fontComboBox, &QFontComboBox::setCurrentFont);
546 QObject::connect(ui()->fontComboBox, &QFontComboBox::currentFontChanged, m_fontDialog, &QFontDialog::setCurrentFont);
547 }
548 m_fontDialog->show();
549 });
550
551 // setup palette selection
552 QObject::connect(ui()->paletteToolButton, &QToolButton::clicked, ui()->paletteToolButton,
553 [this] { m_settings.selectedPalette = PaletteEditor::getPalette(this->widget(), m_settings.selectedPalette); });
554
555 // setup icon theme selection
556 const auto iconThemes = scanIconThemes(QIcon::themeSearchPaths() << QStringLiteral("/usr/share/icons/"));
557 auto *iconThemeComboBox = ui()->iconThemeComboBox;
558 for (auto i = iconThemes.begin(), end = iconThemes.end(); i != end; ++i) {
559 const auto &displayName = i.key();
560 const auto &id = i.value();
561 if (const auto existingItemIndex = iconThemeComboBox->findData(id); existingItemIndex != -1) {
562 iconThemeComboBox->setItemText(existingItemIndex, displayName);
563 } else {
564 iconThemeComboBox->addItem(displayName, id);
565 }
566 }
567
568 return widget;
569}
570
571QtLanguageOptionPage::QtLanguageOptionPage(QtSettingsData &settings, QWidget *parentWidget)
572 : QtLanguageOptionPageBase(parentWidget)
573 , m_settings(settings)
574{
575}
576
577QtLanguageOptionPage::~QtLanguageOptionPage()
578{
579}
580
581bool QtLanguageOptionPage::apply()
582{
583 m_settings.localeName = ui()->localeComboBox->currentText();
584 m_settings.customLocale = !ui()->localeCheckBox->isChecked();
585 return true;
586}
587
588void QtLanguageOptionPage::reset()
589{
590 ui()->localeComboBox->setCurrentText(m_settings.localeName);
591 ui()->localeCheckBox->setChecked(!m_settings.customLocale);
592}
593
594QWidget *QtLanguageOptionPage::setupWidget()
595{
596 // call base implementation first, so ui() is available
597 auto *widget = QtLanguageOptionPageBase::setupWidget();
598 if (m_settings.retranslatable) {
599 ui()->label->hide();
600 }
601
602 // add all available locales to combo box
603 auto *localeComboBox = ui()->localeComboBox;
604 const auto locales = QLocale::matchingLocales(QLocale::AnyLanguage, QLocale::AnyScript, QLocale::AnyCountry);
605 for (const QLocale &locale : locales) {
606 localeComboBox->addItem(locale.name());
607 }
608
609 auto *languageLabel = ui()->languageLabel;
610 QObject::connect(ui()->localeComboBox, &QComboBox::currentTextChanged, languageLabel, [languageLabel, localeComboBox] {
611 const auto selectedLocale = QLocale(localeComboBox->currentText());
612 const auto currentLocale = QLocale();
613 const auto territory =
614#if QT_VERSION >= QT_VERSION_CHECK(6, 2, 0)
615 currentLocale.territoryToString(selectedLocale.territory());
616#else
617 currentLocale.countryToString(selectedLocale.country());
618#endif
619 languageLabel->setText(QCoreApplication::translate("QtGui::QtLanguageOptionPage", "recognized by Qt as") % QStringLiteral(" <i>")
620 % currentLocale.languageToString(selectedLocale.language()) % QChar(',') % QChar(' ') % territory % QStringLiteral("</i>"));
621 });
622 return widget;
623}
624
625QtEnvOptionPage::QtEnvOptionPage(QtSettingsData &settings, QWidget *parentWidget)
626 : QtEnvOptionPageBase(parentWidget)
627 , m_settings(settings)
628{
629}
630
631QtEnvOptionPage::~QtEnvOptionPage()
632{
633}
634
635bool QtEnvOptionPage::apply()
636{
637 m_settings.additionalPluginDirectory = ui()->pluginPathSelection->lineEdit()->text();
638 m_settings.additionalIconThemeSearchPath = ui()->iconThemeSearchPathSelection->lineEdit()->text();
639 TranslationFiles::additionalTranslationFilePath() = ui()->translationPathSelection->lineEdit()->text();
640 return true;
641}
642
643void QtEnvOptionPage::reset()
644{
645 ui()->pluginPathSelection->lineEdit()->setText(m_settings.additionalPluginDirectory);
646 ui()->iconThemeSearchPathSelection->lineEdit()->setText(m_settings.additionalIconThemeSearchPath);
647 ui()->translationPathSelection->lineEdit()->setText(TranslationFiles::additionalTranslationFilePath());
648}
649
650QWidget *QtEnvOptionPage::setupWidget()
651{
652 // call base implementation first, so ui() is available
653 return QtEnvOptionPageBase::setupWidget();
654}
655#endif
656
663QtSettings::operator QtSettingsData &() const
664{
665 return *m_d.get();
666}
667
668} // namespace QtUtilities
669
670#if defined(QT_UTILITIES_GUI_QTWIDGETS)
671INSTANTIATE_UI_FILE_BASED_OPTION_PAGE(QtAppearanceOptionPage)
672INSTANTIATE_UI_FILE_BASED_OPTION_PAGE(QtLanguageOptionPage)
674#endif
The OptionCategory class wraps associated option pages.
void setDisplayName(const QString &displayName)
Sets the display name of the category.
void assignPages(const QList< OptionPage * > &pages)
Assigns the specified pages to the category.
void setIcon(const QIcon &icon)
Sets the icon of the category.
static QPalette getPalette(QWidget *parent, const QPalette &init=QPalette(), const QPalette &parentPal=QPalette(), int *result=nullptr)
void save(QSettings &settings) const
Saves the settings to the specified QSettings object.
OptionCategory * category()
QtSettings()
Creates a new settings object.
void reapplyDefaultIconTheme(bool isPaletteDark)
Re-applies default icon theme assuming the palette is dark or not depending on isPaletteDark.
~QtSettings()
Destroys the settings object.
void restore(QSettings &settings)
Restores the settings from the specified QSettings object.
bool hasLocaleChanged() const
Returns whether the last apply() call has changed the default locale.
bool isPaletteDark()
Returns whether the palette is dark.
bool hasCustomFont() const
Returns whether a custom font is set.
void apply()
Applies the current configuration.
void reevaluatePaletteAndDefaultIconTheme()
Re-evaluates whether the palette is dark and re-applies default icon theme.
QT_UTILITIES_EXPORT QString & additionalTranslationFilePath()
Allows to set an additional search path for translation files.
Definition resources.cpp:80
QT_UTILITIES_EXPORT std::optional< bool > isDarkModeEnabled()
Returns whether dark mode is enabled.
QT_UTILITIES_EXPORT bool isPaletteDark(const QPalette &palette=QPalette())
Returns whether palette is dark.
#define INSTANTIATE_UI_FILE_BASED_OPTION_PAGE(SomeClass)
Instantiates a class declared with BEGIN_DECLARE_UI_FILE_BASED_OPTION_PAGE in a convenient way.
Definition optionpage.h:250
std::optional< QFont > initialFont