mirror-chatterino2/src/widgets/settingspages/SettingsPage.hpp

82 lines
2.7 KiB
C++
Raw Normal View History

2018-01-12 23:09:05 +01:00
#pragma once
#include <QCheckBox>
#include <QComboBox>
#include <QLineEdit>
#include <QSpinBox>
2018-01-12 23:09:05 +01:00
#include <pajlada/signals/signal.hpp>
2018-06-28 19:46:45 +02:00
#include "singletons/Settings.hpp"
2018-01-12 23:09:05 +01:00
#define SETTINGS_PAGE_WIDGET_BOILERPLATE(type, parent) \
class type : public parent \
{ \
using parent::parent; \
\
public: \
bool greyedOut{}; \
\
protected: \
void paintEvent(QPaintEvent *e) override \
{ \
parent::paintEvent(e); \
\
if (this->greyedOut) \
{ \
QPainter painter(this); \
QColor color = QColor("#222222"); \
color.setAlphaF(0.7); \
painter.fillRect(this->rect(), color); \
} \
} \
};
2018-01-12 23:09:05 +01:00
namespace chatterino {
SETTINGS_PAGE_WIDGET_BOILERPLATE(SCheckBox, QCheckBox)
SETTINGS_PAGE_WIDGET_BOILERPLATE(SLabel, QLabel)
SETTINGS_PAGE_WIDGET_BOILERPLATE(SComboBox, QComboBox)
class SettingsDialogTab;
2018-10-31 19:45:51 +01:00
class SettingsPage : public QFrame
2018-01-12 23:09:05 +01:00
{
2018-10-31 19:45:51 +01:00
Q_OBJECT
2018-01-12 23:09:05 +01:00
public:
2018-01-13 00:18:18 +01:00
SettingsPage(const QString &name, const QString &iconResource);
2018-01-12 23:09:05 +01:00
const QString &getName();
2018-01-13 00:18:18 +01:00
const QString &getIconResource();
2018-01-12 23:09:05 +01:00
2019-09-02 16:39:21 +02:00
virtual bool filterElements(const QString &query);
SettingsDialogTab *tab() const;
void setTab(SettingsDialogTab *tab);
2018-01-12 23:09:05 +01:00
void cancel();
2018-08-06 21:17:03 +02:00
QCheckBox *createCheckBox(const QString &text,
pajlada::Settings::Setting<bool> &setting);
2018-01-12 23:09:05 +01:00
QComboBox *createComboBox(const QStringList &items,
pajlada::Settings::Setting<QString> &setting);
QLineEdit *createLineEdit(pajlada::Settings::Setting<QString> &setting);
2018-08-06 21:17:03 +02:00
QSpinBox *createSpinBox(pajlada::Settings::Setting<int> &setting,
int min = 0, int max = 2500);
2018-01-12 23:09:05 +01:00
virtual void onShow()
{
}
2018-01-12 23:09:05 +01:00
protected:
2018-07-06 19:23:47 +02:00
QString name_;
QString iconResource_;
2018-01-12 23:09:05 +01:00
SettingsDialogTab *tab_;
2018-07-06 19:23:47 +02:00
pajlada::Signals::NoArgSignal onCancel_;
std::vector<pajlada::Signals::ScopedConnection> managedConnections_;
2018-01-12 23:09:05 +01:00
};
2018-01-12 23:33:04 +01:00
2018-01-12 23:09:05 +01:00
} // namespace chatterino