1#ifndef DIALOGS_OPTIONSPAGE_H
2#define DIALOGS_OPTIONSPAGE_H
19 explicit OptionPageWidget(QWidget *parent =
nullptr, Qt::WindowFlags f = Qt::WindowFlags());
26 bool event(QEvent *)
override;
38 explicit OptionPage(QWidget *parentWindow =
nullptr);
41 QWidget *parentWindow()
const;
43 bool hasBeenShown()
const;
46 bool matches(
const QString &searchKeyWord);
47 const QStringList &errors()
const;
51 QStringList &errors();
54 std::unique_ptr<QWidget> m_widget;
55 QWidget *m_parentWindow;
57 bool m_keywordsInitialized;
58 QStringList m_keywords;
67 return m_parentWindow;
77 return m_widget !=
nullptr && m_shown;
119 QWidget *setupWidget()
override;
123 std::unique_ptr<UiClass> m_ui;
129template <
class UiClass>
149 m_ui.reset(
new UiClass);
151 m_ui->setupUi(widget);
168#define BEGIN_DECLARE_TYPEDEF_OPTION_PAGE(SomeClass) using SomeClass##Base = ::QtUtilities::OptionPage;
175#define BEGIN_DECLARE_OPTION_PAGE(SomeClass) \
176 BEGIN_DECLARE_TYPEDEF_OPTION_PAGE(SomeClass) \
177 class QT_UTILITIES_EXPORT SomeClass : public ::QtUtilities::OptionPage { \
179 explicit SomeClass(QWidget *parentWidget = nullptr); \
180 ~SomeClass() override; \
181 bool apply() override; \
182 void reset() override; \
191#define BEGIN_DECLARE_OPTION_PAGE_CUSTOM_CTOR(SomeClass) \
192 BEGIN_DECLARE_TYPEDEF_OPTION_PAGE(SomeClass) \
193 class QT_UTILITIES_EXPORT SomeClass : public ::QtUtilities::OptionPage { \
195 ~SomeClass() override; \
196 bool apply() override; \
197 void reset() override; \
204#define BEGIN_DECLARE_TYPEDEF_UI_FILE_BASED_OPTION_PAGE(SomeClass) \
208 using SomeClass##Base = ::QtUtilities::UiFileBasedOptionPage<Ui::SomeClass>;
215#define BEGIN_DECLARE_UI_FILE_BASED_OPTION_PAGE_CUSTOM_CTOR(SomeClass) \
216 BEGIN_DECLARE_TYPEDEF_UI_FILE_BASED_OPTION_PAGE(SomeClass) \
217 class QT_UTILITIES_EXPORT SomeClass : public ::QtUtilities::UiFileBasedOptionPage<Ui::SomeClass> { \
219 ~SomeClass() override; \
220 bool apply() override; \
221 void reset() override; \
230#define BEGIN_DECLARE_UI_FILE_BASED_OPTION_PAGE(SomeClass) \
231 BEGIN_DECLARE_UI_FILE_BASED_OPTION_PAGE_CUSTOM_CTOR(SomeClass) \
233 explicit SomeClass(QWidget *parentWidget = nullptr); \
241#define END_DECLARE_OPTION_PAGE \
250#define INSTANTIATE_UI_FILE_BASED_OPTION_PAGE(SomeClass) \
251 namespace QtUtilities { \
252 template class UiFileBasedOptionPage<Ui::SomeClass>; \
261#define INSTANTIATE_UI_FILE_BASED_OPTION_PAGE_NS(SomeNamespace, SomeClass) \
262 namespace QtUtilities { \
263 template class UiFileBasedOptionPage<::SomeNamespace::Ui::SomeClass>; \
271#define DECLARE_EXTERN_UI_FILE_BASED_OPTION_PAGE(SomeClass) \
272 namespace QtUtilities { \
276 extern template class UiFileBasedOptionPage<Ui::SomeClass>; \
285#define DECLARE_EXTERN_UI_FILE_BASED_OPTION_PAGE_NS(SomeNamespace, SomeClass) \
286 namespace SomeNamespace { \
291 namespace QtUtilities { \
292 extern template class UiFileBasedOptionPage<::SomeNamespace::Ui::SomeClass>; \
300#define DECLARE_SETUP_WIDGETS \
302 QWidget *setupWidget() override; \
311#define DECLARE_UI_FILE_BASED_OPTION_PAGE(SomeClass) \
312 BEGIN_DECLARE_UI_FILE_BASED_OPTION_PAGE(SomeClass) \
313 END_DECLARE_OPTION_PAGE
320#define DECLARE_OPTION_PAGE(SomeClass) \
321 BEGIN_DECLARE_OPTION_PAGE(SomeClass) \
322 DECLARE_SETUP_WIDGETS \
323 END_DECLARE_OPTION_PAGE
330#define DECLARE_UI_FILE_BASED_OPTION_PAGE_CUSTOM_SETUP(SomeClass) \
331 BEGIN_DECLARE_UI_FILE_BASED_OPTION_PAGE(SomeClass) \
332 DECLARE_SETUP_WIDGETS \
333 END_DECLARE_OPTION_PAGE
void retranslationRequired()
OptionPageWidget(QWidget *parent=nullptr, Qt::WindowFlags f=Qt::WindowFlags())
The OptionPage class is the base class for SettingsDialog pages.
QWidget * parentWindow() const
Returns the parent window of the option page.
virtual void reset()=0
Discards altered settings and resets relevant widgets.
virtual bool apply()=0
Applies altered settings.
const QStringList & errors() const
Returns the errors which haven been occurred when applying the changes.
bool hasBeenShown() const
Returns an indication whether the option page has been shown yet.
virtual QWidget * setupWidget()=0
Creates the widget for the page.
The SettingsDialog class provides a framework for creating settings dialogs with different categories...
UiClass * ui()
Provides the derived class access to the UI class.
UiFileBasedOptionPage(QWidget *parentWindow=nullptr)
Constructs a new UI file based option page.
void reset() override=0
Discards altered settings and resets relevant widgets.
~UiFileBasedOptionPage() override
Destroys the option page.
QWidget * setupWidget() override
Inflates the widget for the option page using the UI class.
bool apply() override=0
Applies altered settings.
#define QT_UTILITIES_EXPORT
Marks the symbol to be exported by the qtutilities library.