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;
56 return m_widget !=
nullptr && m_shown;
98 QWidget *setupWidget();
102 std::unique_ptr<UiClass> m_ui;
108 template <
class UiClass>
126 QWidget *
widget =
new QWidget();
128 m_ui.reset(
new UiClass);
130 m_ui->setupUi(widget);
148 #define BEGIN_DECLARE_OPTION_PAGE(SomeClass) \ 149 typedef ::Dialogs::OptionPage SomeClass##Base; \ 150 class QT_UTILITIES_EXPORT SomeClass : public ::Dialogs::OptionPage { \ 152 explicit SomeClass(QWidget *parentWidget = nullptr); \ 164 #define BEGIN_DECLARE_UI_FILE_BASED_OPTION_PAGE_CUSTOM_CTOR(SomeClass) \ 168 typedef ::Dialogs::UiFileBasedOptionPage<Ui::SomeClass> SomeClass##Base; \ 169 class QT_UTILITIES_EXPORT SomeClass : public ::Dialogs::UiFileBasedOptionPage<Ui::SomeClass> { \ 182 #define BEGIN_DECLARE_UI_FILE_BASED_OPTION_PAGE(SomeClass) \ 183 BEGIN_DECLARE_UI_FILE_BASED_OPTION_PAGE_CUSTOM_CTOR(SomeClass) \ 185 explicit SomeClass(QWidget *parentWidget = nullptr); \ 193 #define END_DECLARE_OPTION_PAGE \ 202 #define INSTANTIATE_UI_FILE_BASED_OPTION_PAGE(SomeClass) \ 203 namespace Dialogs { \ 204 template class UiFileBasedOptionPage<Ui::SomeClass>; \ 213 #define INSTANTIATE_UI_FILE_BASED_OPTION_PAGE_NS(SomeNamespace, SomeClass) \ 214 namespace Dialogs { \ 215 template class UiFileBasedOptionPage<::SomeNamespace::Ui::SomeClass>; \ 223 #define DECLARE_EXTERN_UI_FILE_BASED_OPTION_PAGE(SomeClass) \ 224 namespace Dialogs { \ 228 extern template class UiFileBasedOptionPage<Ui::SomeClass>; \ 237 #define DECLARE_EXTERN_UI_FILE_BASED_OPTION_PAGE_NS(SomeNamespace, SomeClass) \ 238 namespace SomeNamespace { \ 243 namespace Dialogs { \ 244 extern template class UiFileBasedOptionPage<::SomeNamespace::Ui::SomeClass>; \ 252 #define DECLARE_SETUP_WIDGETS \ 254 QWidget *setupWidget(); \ 263 #define DECLARE_UI_FILE_BASED_OPTION_PAGE(SomeClass) \ 264 BEGIN_DECLARE_UI_FILE_BASED_OPTION_PAGE(SomeClass) \ 265 END_DECLARE_OPTION_PAGE 272 #define DECLARE_OPTION_PAGE(SomeClass) \ 273 BEGIN_DECLARE_OPTION_PAGE(SomeClass) \ 274 DECLARE_SETUP_WIDGETS \ 275 END_DECLARE_OPTION_PAGE 282 #define DECLARE_UI_FILE_BASED_OPTION_PAGE_CUSTOM_SETUP(SomeClass) \ 283 BEGIN_DECLARE_UI_FILE_BASED_OPTION_PAGE(SomeClass) \ 284 DECLARE_SETUP_WIDGETS \ 285 END_DECLARE_OPTION_PAGE 287 #endif // DIALOGS_OPTIONSPAGE_H QWidget * widget()
Returns the widget for the option page.
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.