Add OptionPageWidget with `paletteChanged()` signal
This commit is contained in:
parent
0f7a4eb059
commit
885323e367
|
@ -1,11 +1,14 @@
|
||||||
#include "./optionpage.h"
|
#include "./optionpage.h"
|
||||||
|
|
||||||
#include <QCheckBox>
|
#include <QCheckBox>
|
||||||
|
#include <QEvent>
|
||||||
#include <QGroupBox>
|
#include <QGroupBox>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QRadioButton>
|
#include <QRadioButton>
|
||||||
|
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
namespace QtUtilities {
|
namespace QtUtilities {
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
@ -81,12 +84,26 @@ bool OptionPage::matches(const QString &searchKeyWord)
|
||||||
m_keywords << groupBox->title();
|
m_keywords << groupBox->title();
|
||||||
m_keywordsInitialized = true;
|
m_keywordsInitialized = true;
|
||||||
}
|
}
|
||||||
for (const QString &keyword : m_keywords)
|
for (const QString &keyword : std::as_const(m_keywords))
|
||||||
if (keyword.contains(searchKeyWord, Qt::CaseInsensitive))
|
if (keyword.contains(searchKeyWord, Qt::CaseInsensitive))
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Emits the paletteChanged() signal.
|
||||||
|
*/
|
||||||
|
bool OptionPageWidget::event(QEvent *event)
|
||||||
|
{
|
||||||
|
switch (event->type()) {
|
||||||
|
case QEvent::PaletteChange:
|
||||||
|
emit paletteChanged();
|
||||||
|
break;
|
||||||
|
default:;
|
||||||
|
}
|
||||||
|
return QWidget::event(event);
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \fn OptionPage::apply()
|
* \fn OptionPage::apply()
|
||||||
* \brief Applies altered settings.
|
* \brief Applies altered settings.
|
||||||
|
|
|
@ -12,6 +12,24 @@ namespace QtUtilities {
|
||||||
|
|
||||||
class SettingsDialog;
|
class SettingsDialog;
|
||||||
|
|
||||||
|
class QT_UTILITIES_EXPORT OptionPageWidget : public QWidget {
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit OptionPageWidget(QWidget *parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags());
|
||||||
|
|
||||||
|
Q_SIGNALS:
|
||||||
|
void paletteChanged();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool event(QEvent *) override;
|
||||||
|
};
|
||||||
|
|
||||||
|
inline OptionPageWidget::OptionPageWidget(QWidget *parent, Qt::WindowFlags f)
|
||||||
|
: QWidget(parent, f)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
class QT_UTILITIES_EXPORT OptionPage {
|
class QT_UTILITIES_EXPORT OptionPage {
|
||||||
friend class SettingsDialog;
|
friend class SettingsDialog;
|
||||||
|
|
||||||
|
@ -125,7 +143,7 @@ template <class UiClass> UiFileBasedOptionPage<UiClass>::~UiFileBasedOptionPage(
|
||||||
*/
|
*/
|
||||||
template <class UiClass> QWidget *UiFileBasedOptionPage<UiClass>::setupWidget()
|
template <class UiClass> QWidget *UiFileBasedOptionPage<UiClass>::setupWidget()
|
||||||
{
|
{
|
||||||
QWidget *widget = new QWidget();
|
QWidget *widget = new OptionPageWidget();
|
||||||
if (!m_ui) {
|
if (!m_ui) {
|
||||||
m_ui.reset(new UiClass);
|
m_ui.reset(new UiClass);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue