refactor: use some more SettingWidget & restyle external tools page (#6023)
This commit is contained in:
@@ -15,6 +15,8 @@
|
||||
#include <QtContainerFwd>
|
||||
#include <QWidget>
|
||||
|
||||
class QFormLayout;
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
class GeneralPageView;
|
||||
@@ -26,6 +28,12 @@ class SettingWidget : QWidget
|
||||
explicit SettingWidget(const QString &mainKeyword);
|
||||
|
||||
public:
|
||||
struct IntInputParams {
|
||||
std::optional<int> min;
|
||||
std::optional<int> max;
|
||||
std::optional<int> singleStep;
|
||||
};
|
||||
|
||||
~SettingWidget() override = default;
|
||||
SettingWidget &operator=(const SettingWidget &) = delete;
|
||||
SettingWidget &operator=(SettingWidget &&) = delete;
|
||||
@@ -35,6 +43,13 @@ public:
|
||||
static SettingWidget *checkbox(const QString &label, BoolSetting &setting);
|
||||
static SettingWidget *inverseCheckbox(const QString &label,
|
||||
BoolSetting &setting);
|
||||
static SettingWidget *customCheckbox(const QString &label,
|
||||
bool initialValue,
|
||||
const std::function<void(bool)> &save);
|
||||
|
||||
static SettingWidget *intInput(const QString &label, IntSetting &setting,
|
||||
IntInputParams params);
|
||||
|
||||
template <typename T>
|
||||
static SettingWidget *dropdown(const QString &label,
|
||||
EnumStringSetting<T> &setting)
|
||||
@@ -81,6 +96,11 @@ public:
|
||||
|
||||
return widget;
|
||||
}
|
||||
static SettingWidget *colorButton(const QString &label,
|
||||
QStringSetting &setting);
|
||||
static SettingWidget *lineEdit(const QString &label,
|
||||
QStringSetting &setting,
|
||||
const QString &placeholderText = {});
|
||||
|
||||
SettingWidget *setTooltip(QString tooltip);
|
||||
SettingWidget *setDescription(const QString &text);
|
||||
@@ -90,7 +110,10 @@ public:
|
||||
/// All text from the tooltip, description, and label are already keywords
|
||||
SettingWidget *addKeywords(const QStringList &newKeywords);
|
||||
|
||||
SettingWidget *conditionallyEnabledBy(BoolSetting &setting);
|
||||
|
||||
void addTo(GeneralPageView &view);
|
||||
void addTo(GeneralPageView &view, QFormLayout *formLayout);
|
||||
|
||||
private:
|
||||
QWidget *label = nullptr;
|
||||
|
||||
Reference in New Issue
Block a user