Qt Utilities: settingsdialog/settingsdialog.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
settingsdialog.h
Go to the documentation of this file.
1#ifndef DIALOGS_SETTINGSDIALOG_H
2#define DIALOGS_SETTINGSDIALOG_H
3
4#include "../global.h"
5
6#include <QDialog>
7
8#include <memory>
9
10namespace QtUtilities {
11
12class OptionCategoryModel;
13class OptionCategoryFilterModel;
14class OptionCategory;
15class OptionPage;
16
17namespace Ui {
18class SettingsDialog;
19}
20
21 class QT_UTILITIES_EXPORT SettingsDialog : public QDialog {
22 Q_OBJECT
23 Q_PROPERTY(bool tabBarAlwaysVisible READ isTabBarAlwaysVisible WRITE setTabBarAlwaysVisible)
24
25public:
26 explicit SettingsDialog(QWidget *parent = nullptr);
27 ~SettingsDialog() override;
28 bool isTabBarAlwaysVisible() const;
29 void setTabBarAlwaysVisible(bool value);
30 OptionCategoryModel *categoryModel();
31 OptionCategory *category(int categoryIndex) const;
32 OptionPage *page(int categoryIndex, int pageIndex) const;
33 void showCategory(OptionCategory *category);
34 void translateCategory(OptionCategory *category, const std::function<QString()> &translator);
35 void setSingleCategory(OptionCategory *singleCategory);
36 QWidget *cornerWidget(Qt::Corner corner = Qt::TopRightCorner) const;
37 void setCornerWidget(QWidget *widget, Qt::Corner corner = Qt::TopRightCorner);
38 void addHeadingWidget(QWidget *widget);
39 void selectPage(int categoryIndex, int pageIndex);
40
41public Q_SLOTS:
42 bool apply();
43 void reset();
44
45Q_SIGNALS:
46 void applied();
47 void resetted();
48 void retranslationRequired();
49
50protected:
51 bool event(QEvent *event) override;
52 void showEvent(QShowEvent *event) override;
53
54private Q_SLOTS:
55 void currentCategoryChanged(const QModelIndex &index);
56 void updateTabWidget();
57 void retranslateTabWidget();
58
59private:
60 std::unique_ptr<Ui::SettingsDialog> m_ui;
61 OptionCategoryModel *m_categoryModel;
62 OptionCategoryFilterModel *m_categoryFilterModel;
63 OptionCategory *m_currentCategory;
64 bool m_tabBarAlwaysVisible;
65};
66
74 inline bool SettingsDialog::isTabBarAlwaysVisible() const
75{
76 return m_tabBarAlwaysVisible;
77}
78
83 inline OptionCategoryModel *SettingsDialog::categoryModel()
84{
85 return m_categoryModel;
86}
87} // namespace QtUtilities
88
89#endif // DIALOGS_SETTINGSDIALOG_H
QtUtilities::OptionCategoryFilterModel
The OptionCategoryFilterModel class is used by SettingsDialog to filter option categories.
Definition optioncategoryfiltermodel.h:8
QtUtilities::OptionCategoryModel
The OptionCategoryModel class is used by SettingsDialog to store and display option categories.
Definition optioncategorymodel.h:14
QtUtilities::OptionCategory
The OptionCategory class wraps associated option pages.
Definition optioncategory.h:18
QtUtilities::OptionPage
The OptionPage class is the base class for SettingsDialog pages.
Definition optionpage.h:34
QtUtilities::SettingsDialog::categoryModel
OptionCategoryModel * categoryModel()
Returns the category model used by the settings dialog to manage the categories.
Definition settingsdialog.h:83
QtUtilities::SettingsDialog::applied
void applied()
QtUtilities::SettingsDialog::setTabBarAlwaysVisible
void setTabBarAlwaysVisible(bool value)
Sets whether the tab bar is always visible.
Definition settingsdialog.cpp:72
QtUtilities::SettingsDialog::category
OptionCategory * category(int categoryIndex) const
Returns the category for the specified categoryIndex.
Definition settingsdialog.cpp:86
QtUtilities::SettingsDialog::SettingsDialog
SettingsDialog(QWidget *parent=nullptr)
Constructs a settings dialog.
Definition settingsdialog.cpp:30
QtUtilities::SettingsDialog::retranslationRequired
void retranslationRequired()
QtUtilities::SettingsDialog::showCategory
void showCategory(OptionCategory *category)
Sets the current category to the specified category and updates the relevant widgets to show it.
Definition settingsdialog.cpp:141
QtUtilities::SettingsDialog::event
bool event(QEvent *event) override
Definition settingsdialog.cpp:359
QtUtilities::SettingsDialog::page
OptionPage * page(int categoryIndex, int pageIndex) const
Returns the page for the specified categoryIndex and the specified pageIndex.
Definition settingsdialog.cpp:98
QtUtilities::SettingsDialog::resetted
void resetted()
QtUtilities::SettingsDialog::reset
void reset()
Resets all changes.
Definition settingsdialog.cpp:351
QtUtilities::SettingsDialog::apply
bool apply()
Applies all changes.
Definition settingsdialog.cpp:307
QtUtilities::SettingsDialog::addHeadingWidget
void addHeadingWidget(QWidget *widget)
Adds a widget next to the heading.
Definition settingsdialog.cpp:213
QtUtilities::SettingsDialog::cornerWidget
QWidget * cornerWidget(Qt::Corner corner=Qt::TopRightCorner) const
Returns the tab-widget's corner widget.
Definition settingsdialog.cpp:197
QtUtilities::SettingsDialog::tabBarAlwaysVisible
bool tabBarAlwaysVisible
Definition settingsdialog.h:23
QtUtilities::SettingsDialog::translateCategory
void translateCategory(OptionCategory *category, const std::function< QString()> &translator)
Allows to set the categories display name so that it is retranslated as needed.
Definition settingsdialog.cpp:165
QtUtilities::SettingsDialog::showEvent
void showEvent(QShowEvent *event) override
Resets all pages before the dialog is shown by the application.
Definition settingsdialog.cpp:111
QtUtilities::SettingsDialog::isTabBarAlwaysVisible
bool isTabBarAlwaysVisible() const
Returns whether the tab bar is always visible.
Definition settingsdialog.h:74
QtUtilities::SettingsDialog::setSingleCategory
void setSingleCategory(OptionCategory *singleCategory)
Enables single-category mode to show only the specified singleCategory.
Definition settingsdialog.cpp:181
QtUtilities::SettingsDialog::setCornerWidget
void setCornerWidget(QWidget *widget, Qt::Corner corner=Qt::TopRightCorner)
Sets the tab-widget's corner widget.
Definition settingsdialog.cpp:205
QtUtilities::SettingsDialog::selectPage
void selectPage(int categoryIndex, int pageIndex)
Selects the specified page within the specified category.
Definition settingsdialog.cpp:221
global.h
QT_UTILITIES_EXPORT
#define QT_UTILITIES_EXPORT
Marks the symbol to be exported by the qtutilities library.
Definition global.h:14
QtUtilities::Ui
Definition aboutdialog.h:14
QtUtilities
!
Definition trylocker.h:8