Qt Utilities
6.22.1
Common Qt related C++ classes and routines used by my applications such as dialogs, widgets and models
Toggle main menu visibility
Loading...
Searching...
No Matches
settingsdialog
optionpage.cpp
Go to the documentation of this file.
1
#include "
./optionpage.h
"
2
3
#include <QCheckBox>
4
#include <QEvent>
5
#include <QGroupBox>
6
#include <QLabel>
7
#include <QPushButton>
8
#include <QRadioButton>
9
10
#include <utility>
11
12
namespace
QtUtilities
{
13
21
25
OptionPage::OptionPage
(QWidget *
parentWindow
)
26
: m_parentWindow(
parentWindow
)
27
, m_shown(false)
28
, m_keywordsInitialized(false)
29
{
30
}
31
35
OptionPage::~OptionPage
()
36
{
37
}
38
48
QWidget *
OptionPage::widget
()
49
{
50
if
(!m_widget) {
51
m_widget.reset(
setupWidget
());
// ensure widget has been created
52
}
53
if
(!m_shown) {
54
m_shown =
true
;
55
reset
();
// show current configuration if not shown yet
56
}
57
return
m_widget.get();
58
}
59
64
bool
OptionPage::matches
(
const
QString &searchKeyWord)
65
{
66
if
(searchKeyWord.isEmpty()) {
67
return
true
;
68
}
69
if
(!m_keywordsInitialized) {
70
if
(!m_widget) {
71
m_widget.reset(
setupWidget
());
// ensure widget has been created
72
}
73
m_keywords << m_widget->windowTitle();
74
// find common subwidgets
75
for
(
const
QLabel *label : m_widget->findChildren<QLabel *>())
76
m_keywords << label->text();
77
for
(
const
QCheckBox *checkbox : m_widget->findChildren<QCheckBox *>())
78
m_keywords << checkbox->text();
79
for
(
const
QRadioButton *checkbox : m_widget->findChildren<QRadioButton *>())
80
m_keywords << checkbox->text();
81
for
(
const
QPushButton *pushButton : m_widget->findChildren<QPushButton *>())
82
m_keywords << pushButton->text();
83
for
(
const
QGroupBox *groupBox : m_widget->findChildren<QGroupBox *>())
84
m_keywords << groupBox->title();
85
m_keywordsInitialized =
true
;
86
}
87
for
(
const
QString &keyword : std::as_const(m_keywords))
88
if
(keyword.contains(searchKeyWord, Qt::CaseInsensitive))
89
return
true
;
90
return
false
;
91
}
92
96
bool
OptionPageWidget::event
(QEvent *
event
)
97
{
98
switch
(
event
->type()) {
99
case
QEvent::PaletteChange:
100
emit
paletteChanged
();
101
break
;
102
case
QEvent::LanguageChange:
103
emit
retranslationRequired
();
104
break
;
105
default
:;
106
}
107
return
QWidget::event(
event
);
108
}
109
119
129
135
}
// namespace QtUtilities
QtUtilities::OptionPageWidget::paletteChanged
void paletteChanged()
QtUtilities::OptionPageWidget::event
bool event(QEvent *) override
Emits the paletteChanged() signal.
Definition
optionpage.cpp:96
QtUtilities::OptionPageWidget::retranslationRequired
void retranslationRequired()
QtUtilities::OptionPage::parentWindow
QWidget * parentWindow() const
Returns the parent window of the option page.
Definition
optionpage.h:65
QtUtilities::OptionPage::OptionPage
OptionPage(QWidget *parentWindow=nullptr)
Constructs a option page.
Definition
optionpage.cpp:25
QtUtilities::OptionPage::reset
virtual void reset()=0
Discards altered settings and resets relevant widgets.
QtUtilities::OptionPage::matches
bool matches(const QString &searchKeyWord)
Returns whether the pages matches the specified searchKeyWord.
Definition
optionpage.cpp:64
QtUtilities::OptionPage::setupWidget
virtual QWidget * setupWidget()=0
Creates the widget for the page.
QtUtilities::OptionPage::~OptionPage
virtual ~OptionPage()
Destroys the option page.
Definition
optionpage.cpp:35
QtUtilities::OptionPage::widget
QWidget * widget()
Returns the widget for the option page.
Definition
optionpage.cpp:48
QtUtilities
!
Definition
trylocker.h:8
optionpage.h
Generated on
for Qt Utilities by
1.18.0