Qt Utilities: settingsdialog/qtsettings.h Source File

Qt Utilities 6.21.2 Common Qt related C++ classes and routines used by my applications such as dialogs, widgets and models

Loading...
Searching...
No Matches
qtsettings.h
Go to the documentation of this file.
1#ifndef DIALOGS_QT_UTILITIES_QTSETTINGS_H
2#define DIALOGS_QT_UTILITIES_QTSETTINGS_H
3
4#include "../global.h"
5
6#if defined(QT_UTILITIES_GUI_QTWIDGETS)
7#include "./optionpage.h"
8#endif
9
10#include <QtGlobal>
11
12#include <memory>
13
14QT_FORWARD_DECLARE_CLASS(QFontDialog)
15QT_FORWARD_DECLARE_CLASS(QSettings)
16
17namespace QtUtilities {
18
19class OptionCategory;
20struct QtSettingsData;
21
22#if defined(QT_UTILITIES_GUI_QTWIDGETS)
23 BEGIN_DECLARE_UI_FILE_BASED_OPTION_PAGE_CUSTOM_CTOR(QtAppearanceOptionPage)
24public:
25explicit QtAppearanceOptionPage(QtSettingsData &settings, QWidget *parentWidget = nullptr);
26
27private:
28 DECLARE_SETUP_WIDGETS
29 QtSettingsData & m_settings;
30QFontDialog *m_fontDialog;
31 END_DECLARE_OPTION_PAGE
32
33 BEGIN_DECLARE_UI_FILE_BASED_OPTION_PAGE_CUSTOM_CTOR(QtLanguageOptionPage)
34public:
35explicit QtLanguageOptionPage(QtSettingsData &settings, QWidget *parentWidget = nullptr);
36
37private:
38 DECLARE_SETUP_WIDGETS
39 QtSettingsData & m_settings;
40 END_DECLARE_OPTION_PAGE
41
42 BEGIN_DECLARE_UI_FILE_BASED_OPTION_PAGE_CUSTOM_CTOR(QtEnvOptionPage)
43public:
44explicit QtEnvOptionPage(QtSettingsData &settings, QWidget *parentWidget = nullptr);
45
46private:
47 DECLARE_SETUP_WIDGETS
48 QtSettingsData & m_settings;
49 END_DECLARE_OPTION_PAGE
50#endif
51
52 class QT_UTILITIES_EXPORT QtSettings {
53public:
54 QtSettings();
55 ~QtSettings();
56
57#if defined(QT_UTILITIES_GUI_QTWIDGETS)
58 void disableNotices();
59 void setRetranslatable(bool retranslatable);
60#endif
61 void restore(QSettings &settings);
62 void save(QSettings &settings) const;
63 void apply();
64 void reapplyDefaultIconTheme(bool isPaletteDark);
65 void reevaluatePaletteAndDefaultIconTheme();
66 bool isPaletteDark();
67 bool hasCustomFont() const;
68 bool hasLocaleChanged() const;
69 operator QtSettingsData &() const;
70
71 OptionCategory *category();
72
73private:
74 std::unique_ptr<QtSettingsData> m_d;
75};
76} // namespace QtUtilities
77
78#if defined(QT_UTILITIES_GUI_QTWIDGETS)
79 DECLARE_EXTERN_UI_FILE_BASED_OPTION_PAGE(QtAppearanceOptionPage)
80 DECLARE_EXTERN_UI_FILE_BASED_OPTION_PAGE(QtLanguageOptionPage)
81 DECLARE_EXTERN_UI_FILE_BASED_OPTION_PAGE(QtEnvOptionPage)
82#endif
83
84#endif // DIALOGS_QT_UTILITIES_QTSETTINGS_H
QtUtilities::OptionCategory
The OptionCategory class wraps associated option pages.
Definition optioncategory.h:18
QtUtilities::QtSettings::save
void save(QSettings &settings) const
Saves the settings to the specified QSettings object.
Definition qtsettings.cpp:205
QtUtilities::QtSettings::category
OptionCategory * category()
QtUtilities::QtSettings::QtSettings
QtSettings()
Creates a new settings object.
Definition qtsettings.cpp:117
QtUtilities::QtSettings::reapplyDefaultIconTheme
void reapplyDefaultIconTheme(bool isPaletteDark)
Re-applies default icon theme assuming the palette is dark or not depending on isPaletteDark.
Definition qtsettings.cpp:422
QtUtilities::QtSettings::restore
void restore(QSettings &settings)
Restores the settings from the specified QSettings object.
Definition qtsettings.cpp:176
QtUtilities::QtSettings::hasLocaleChanged
bool hasLocaleChanged() const
Returns whether the last apply() call has changed the default locale.
Definition qtsettings.cpp:462
QtUtilities::QtSettings::isPaletteDark
bool isPaletteDark()
Returns whether the palette is dark.
Definition qtsettings.cpp:454
QtUtilities::QtSettings::hasCustomFont
bool hasCustomFont() const
Returns whether a custom font is set.
Definition qtsettings.cpp:165
QtUtilities::QtSettings::apply
void apply()
Applies the current configuration.
Definition qtsettings.cpp:276
QtUtilities::QtSettings::reevaluatePaletteAndDefaultIconTheme
void reevaluatePaletteAndDefaultIconTheme()
Re-evaluates whether the palette is dark and re-applies default icon theme.
Definition qtsettings.cpp:443
global.h
QT_UTILITIES_EXPORT
#define QT_UTILITIES_EXPORT
Marks the symbol to be exported by the qtutilities library.
Definition global.h:14
QtUtilities
!
Definition trylocker.h:8
optionpage.h
DECLARE_EXTERN_UI_FILE_BASED_OPTION_PAGE
#define DECLARE_EXTERN_UI_FILE_BASED_OPTION_PAGE(SomeClass)
Declares external instantiation of class declared with BEGIN_DECLARE_UI_FILE_BASED_OPTION_PAGE in a c...
Definition optionpage.h:271
BEGIN_DECLARE_UI_FILE_BASED_OPTION_PAGE_CUSTOM_CTOR
#define BEGIN_DECLARE_UI_FILE_BASED_OPTION_PAGE_CUSTOM_CTOR(SomeClass)
Declares a class inheriting from Dialogs::UiFileBasedOptionPage in a convenient way.
Definition optionpage.h:215
END_DECLARE_OPTION_PAGE
#define END_DECLARE_OPTION_PAGE
Must be used after BEGIN_DECLARE_OPTION_PAGE and BEGIN_DECLARE_UI_FILE_BASED_OPTION_PAGE.
Definition optionpage.h:241
DECLARE_SETUP_WIDGETS
#define DECLARE_SETUP_WIDGETS
Declares the method setupWidget() in a convenient way.
Definition optionpage.h:300
QtUtilities::QtSettingsData
Definition qtsettings.cpp:54