| 1 |
#ifndef DIALOGS_SETTINGSDIALOG_H |
| 2 |
#define DIALOGS_SETTINGSDIALOG_H |
| 3 |
|
| 4 |
#include "../global.h" |
| 5 |
|
| 6 |
#include <QDialog> |
| 7 |
|
| 8 |
#include <memory> |
| 9 |
|
| 10 |
namespace QtUtilities { |
| 11 |
|
| 12 |
class OptionCategoryModel; |
| 13 |
class OptionCategoryFilterModel; |
| 14 |
class OptionCategory; |
| 15 |
class OptionPage; |
| 16 |
|
| 17 |
namespace Ui { |
| 18 |
class SettingsDialog; |
| 19 |
} |
| 20 |
|
| 21 |
class QT_UTILITIES_EXPORT SettingsDialog : public QDialog { |
| 22 |
Q_OBJECT |
| 23 |
Q_PROPERTY(bool tabBarAlwaysVisible READ isTabBarAlwaysVisible WRITE setTabBarAlwaysVisible) |
| 24 |
|
| 25 |
public: |
| 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 |
|
| 41 |
public Q_SLOTS: |
| 42 |
bool apply(); |
| 43 |
void reset(); |
| 44 |
|
| 45 |
Q_SIGNALS: |
| 46 |
void applied(); |
| 47 |
void resetted(); |
| 48 |
void retranslationRequired(); |
| 49 |
|
| 50 |
protected: |
| 51 |
bool event(QEvent *event) override; |
| 52 |
void showEvent(QShowEvent *event) override; |
| 53 |
|
| 54 |
private Q_SLOTS: |
| 55 |
void currentCategoryChanged(const QModelIndex &index); |
| 56 |
void updateTabWidget(); |
| 57 |
void retranslateTabWidget(); |
| 58 |
|
| 59 |
private: |
| 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 |
|
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
inline bool SettingsDialog::isTabBarAlwaysVisible() const |
| 75 |
{ |
| 76 |
return m_tabBarAlwaysVisible; |
| 77 |
} |
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
inline OptionCategoryModel *SettingsDialog::categoryModel() |
| 84 |
{ |
| 85 |
return m_categoryModel; |
| 86 |
} |
| 87 |
} |
| 88 |
|
| 89 |
#endif |