Qt Utilities: settingsdialog/optioncategory.h Source File

Qt Utilities 6.22.1 Common Qt related C++ classes and routines used by my applications such as dialogs, widgets and models

Loading...
Searching...
No Matches
optioncategory.h
Go to the documentation of this file.
1#ifndef DIALOGS_OPTIONSCATEGORY_H
2#define DIALOGS_OPTIONSCATEGORY_H
3
4#include "../global.h"
5
6#include <QIcon>
7#include <QList>
8#include <QObject>
9
10#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
11Q_MOC_INCLUDE("settingsdialog/optionpage.h")
12#endif
13
14namespace QtUtilities {
15
16class OptionPage;
17
18 class QT_UTILITIES_EXPORT OptionCategory : public QObject {
19 Q_OBJECT
20 Q_PROPERTY(QString displayName READ displayName WRITE setDisplayName NOTIFY displayNameChanged)
21 Q_PROPERTY(QIcon icon READ icon WRITE setIcon NOTIFY iconChanged)
22 Q_PROPERTY(QList<OptionPage *> pages READ pages WRITE assignPages NOTIFY pagesChanged)
23
24public:
25 explicit OptionCategory(QObject *parent = nullptr);
26 ~OptionCategory() override;
27
28 const QString &displayName() const;
29 void setDisplayName(const QString &displayName);
30 const QIcon &icon() const;
31 void setIcon(const QIcon &icon);
32 const QList<OptionPage *> &pages() const;
33 void assignPages(const QList<OptionPage *> &pages);
34 bool applyAllPages();
35 void resetAllPages();
36 void retranslateAllPages();
37 bool matches(const QString &searchKeyWord) const;
38 int currentIndex() const;
39 void setCurrentIndex(int currentIndex);
40
41Q_SIGNALS:
42 void displayNameChanged(const QString &displayName);
43 void iconChanged(const QIcon &icon);
44 void pagesChanged(const QList<QtUtilities::OptionPage *> &pages);
45
46private:
47 QString m_displayName;
48 QIcon m_icon;
49 QList<OptionPage *> m_pages;
50 int m_currentIndex;
51};
52
56inline const QString &OptionCategory::displayName() const
57{
58 return m_displayName;
59}
60
64 inline void OptionCategory::setDisplayName(const QString &displayName)
65{
66 emit displayNameChanged(m_displayName = displayName);
67}
68
72 inline const QIcon &OptionCategory::icon() const
73{
74 return m_icon;
75}
76
80 inline void OptionCategory::setIcon(const QIcon &icon)
81{
82 emit iconChanged(m_icon = icon);
83}
84
88 inline const QList<OptionPage *> &OptionCategory::pages() const
89{
90 return m_pages;
91}
92
98 inline int OptionCategory::currentIndex() const
99{
100 return m_currentIndex;
101}
102
107 inline void OptionCategory::setCurrentIndex(int currentIndex)
108{
109 m_currentIndex = currentIndex;
110}
111} // namespace QtUtilities
112
113#endif // DIALOGS_OPTIONSCATEGORY_H
QtUtilities::OptionCategory::setCurrentIndex
void setCurrentIndex(int currentIndex)
Sets the current index.
Definition optioncategory.h:107
QtUtilities::OptionCategory::setDisplayName
void setDisplayName(const QString &displayName)
Sets the display name of the category.
Definition optioncategory.h:64
QtUtilities::OptionCategory::displayNameChanged
void displayNameChanged(const QString &displayName)
Emitted when the display name changed.
QtUtilities::OptionCategory::currentIndex
int currentIndex() const
Returns the index of the currently shown page.
Definition optioncategory.h:98
QtUtilities::OptionCategory::matches
bool matches(const QString &searchKeyWord) const
Returns whether the option category matches the specified searchKeyWord.
Definition optioncategory.cpp:83
QtUtilities::OptionCategory::OptionCategory
OptionCategory(QObject *parent=nullptr)
Constructs a option category.
Definition optioncategory.cpp:17
QtUtilities::OptionCategory::resetAllPages
void resetAllPages()
Resets all pages.
Definition optioncategory.cpp:56
QtUtilities::OptionCategory::assignPages
void assignPages(const QList< OptionPage * > &pages)
Assigns the specified pages to the category.
Definition optioncategory.cpp:99
QtUtilities::OptionCategory::setIcon
void setIcon(const QIcon &icon)
Sets the icon of the category.
Definition optioncategory.h:80
QtUtilities::OptionCategory::displayName
QString displayName
Definition optioncategory.h:20
QtUtilities::OptionCategory::iconChanged
void iconChanged(const QIcon &icon)
Emitted when the icon changed.
QtUtilities::OptionCategory::retranslateAllPages
void retranslateAllPages()
Triggers retranslation of all pages.
Definition optioncategory.cpp:69
QtUtilities::OptionCategory::icon
QIcon icon
Definition optioncategory.h:21
QtUtilities::OptionCategory::pages
QList< OptionPage * > pages
Definition optioncategory.h:22
QtUtilities::OptionCategory::pagesChanged
void pagesChanged(const QList< QtUtilities::OptionPage * > &pages)
Emitted when the pages changed.
QtUtilities::OptionCategory::applyAllPages
bool applyAllPages()
Applies all pages.
Definition optioncategory.cpp:37
QtUtilities::OptionPage
The OptionPage class is the base class for SettingsDialog pages.
Definition optionpage.h:34
global.h
QT_UTILITIES_EXPORT
#define QT_UTILITIES_EXPORT
Marks the symbol to be exported by the qtutilities library.
Definition global.h:14
QtUtilities
!
Definition trylocker.h:8