1 #ifndef DIALOGS_OPTIONSPAGE_H 2 #define DIALOGS_OPTIONSPAGE_H 19 explicit OptionPage(QWidget *parentWindow =
nullptr);
22 QWidget *parentWindow()
const;
24 bool hasBeenShown()
const;
25 virtual bool apply() = 0;
26 virtual void reset() = 0;
27 bool matches(
const QString &searchKeyWord);
28 const QStringList &errors()
const;
31 virtual QWidget *setupWidget() = 0;
32 QStringList &errors();
35 std::unique_ptr<QWidget> m_widget;
36 QWidget *m_parentWindow;
38 bool m_keywordsInitialized;
39 QStringList m_keywords;
48 return m_parentWindow;
58 return m_widget !=
nullptr && m_shown;
100 QWidget *setupWidget();
104 std::unique_ptr<UiClass> m_ui;
110 template <
class UiClass>
128 QWidget *widget =
new QWidget();
130 m_ui.reset(
new UiClass);
132 m_ui->setupUi(widget);
150 #define BEGIN_DECLARE_OPTION_PAGE(SomeClass) \ 151 typedef ::Dialogs::OptionPage SomeClass##Base; \ 152 class QT_UTILITIES_EXPORT SomeClass : public ::Dialogs::OptionPage { \ 154 explicit SomeClass(QWidget *parentWidget = nullptr); \ 166 #define BEGIN_DECLARE_OPTION_PAGE_CUSTOM_CTOR(SomeClass) \ 167 typedef ::Dialogs::OptionPage SomeClass##Base; \ 168 class QT_UTILITIES_EXPORT SomeClass : public ::Dialogs::OptionPage { \ 181 #define BEGIN_DECLARE_UI_FILE_BASED_OPTION_PAGE_CUSTOM_CTOR(SomeClass) \ 185 typedef ::Dialogs::UiFileBasedOptionPage<Ui::SomeClass> SomeClass##Base; \ 186 class QT_UTILITIES_EXPORT SomeClass : public ::Dialogs::UiFileBasedOptionPage<Ui::SomeClass> { \ 199 #define BEGIN_DECLARE_UI_FILE_BASED_OPTION_PAGE(SomeClass) \ 200 BEGIN_DECLARE_UI_FILE_BASED_OPTION_PAGE_CUSTOM_CTOR(SomeClass) \ 202 explicit SomeClass(QWidget *parentWidget = nullptr); \ 210 #define END_DECLARE_OPTION_PAGE \ 219 #define INSTANTIATE_UI_FILE_BASED_OPTION_PAGE(SomeClass) \ 220 namespace Dialogs { \ 221 template class UiFileBasedOptionPage<Ui::SomeClass>; \ 230 #define INSTANTIATE_UI_FILE_BASED_OPTION_PAGE_NS(SomeNamespace, SomeClass) \ 231 namespace Dialogs { \ 232 template class UiFileBasedOptionPage<::SomeNamespace::Ui::SomeClass>; \ 240 #define DECLARE_EXTERN_UI_FILE_BASED_OPTION_PAGE(SomeClass) \ 241 namespace Dialogs { \ 245 extern template class UiFileBasedOptionPage<Ui::SomeClass>; \ 254 #define DECLARE_EXTERN_UI_FILE_BASED_OPTION_PAGE_NS(SomeNamespace, SomeClass) \ 255 namespace SomeNamespace { \ 260 namespace Dialogs { \ 261 extern template class UiFileBasedOptionPage<::SomeNamespace::Ui::SomeClass>; \ 269 #define DECLARE_SETUP_WIDGETS \ 271 QWidget *setupWidget(); \ 280 #define DECLARE_UI_FILE_BASED_OPTION_PAGE(SomeClass) \ 281 BEGIN_DECLARE_UI_FILE_BASED_OPTION_PAGE(SomeClass) \ 282 END_DECLARE_OPTION_PAGE 289 #define DECLARE_OPTION_PAGE(SomeClass) \ 290 BEGIN_DECLARE_OPTION_PAGE(SomeClass) \ 291 DECLARE_SETUP_WIDGETS \ 292 END_DECLARE_OPTION_PAGE 299 #define DECLARE_UI_FILE_BASED_OPTION_PAGE_CUSTOM_SETUP(SomeClass) \ 300 BEGIN_DECLARE_UI_FILE_BASED_OPTION_PAGE(SomeClass) \ 301 DECLARE_SETUP_WIDGETS \ 302 END_DECLARE_OPTION_PAGE 304 #endif // DIALOGS_OPTIONSPAGE_H UiFileBasedOptionPage(QWidget *parentWindow=nullptr)
Constructs a new UI file based option page.
The OptionPage class is the base class for SettingsDialog pages.
The UiFileBasedOptionPage class is the base class for SettingsDialog pages using UI files to describe...
UiClass * ui()
Provides the derived class access to the UI class.
#define QT_UTILITIES_EXPORT
Marks the symbol to be exported by the qtutilities library.
bool hasBeenShown() const
Returns an indication whether the option page has been shown yet.
Provides common dialogs such as AboutDialog, EnterPasswordDialog and SettingsDialog.
const QStringList & errors() const
Returns the errors which haven been occurred when applying the changes.
The SettingsDialog class provides a framework for creating settings dialogs with different categories...
QWidget * setupWidget()
Inflates the widget for the option page using the UI class.
QWidget * parentWindow() const
Returns the parent window of the option page.
~UiFileBasedOptionPage()
Destroys the option page.