Convert remaining settings to the new settings system
This commit is contained in:
@@ -126,7 +126,6 @@ HEADERS += \
|
|||||||
src/messages/message.hpp \
|
src/messages/message.hpp \
|
||||||
src/messages/word.hpp \
|
src/messages/word.hpp \
|
||||||
src/messages/wordpart.hpp \
|
src/messages/wordpart.hpp \
|
||||||
src/setting.hpp \
|
|
||||||
src/twitch/emotevalue.hpp \
|
src/twitch/emotevalue.hpp \
|
||||||
src/widgets/notebook.hpp \
|
src/widgets/notebook.hpp \
|
||||||
src/widgets/helper/notebookbutton.hpp \
|
src/widgets/helper/notebookbutton.hpp \
|
||||||
@@ -138,7 +137,6 @@ HEADERS += \
|
|||||||
src/widgets/helper/signallabel.hpp \
|
src/widgets/helper/signallabel.hpp \
|
||||||
src/widgets/textinputdialog.hpp \
|
src/widgets/textinputdialog.hpp \
|
||||||
src/widgets/helper/resizingtextedit.hpp \
|
src/widgets/helper/resizingtextedit.hpp \
|
||||||
src/settingssnapshot.hpp \
|
|
||||||
src/messages/limitedqueue.hpp \
|
src/messages/limitedqueue.hpp \
|
||||||
src/messages/limitedqueuesnapshot.hpp \
|
src/messages/limitedqueuesnapshot.hpp \
|
||||||
src/messages/messageref.hpp \
|
src/messages/messageref.hpp \
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ QSize Word::getSize(float scale) const
|
|||||||
const int mediumTextLineHeight =
|
const int mediumTextLineHeight =
|
||||||
singletons::FontManager::getInstance().getFontMetrics(this->font, scale).height();
|
singletons::FontManager::getInstance().getFontMetrics(this->font, scale).height();
|
||||||
const qreal emoteScale =
|
const qreal emoteScale =
|
||||||
singletons::SettingManager::getInstance().emoteScale.get() * scale;
|
singletons::SettingManager::getInstance().emoteScale.getValue() * scale;
|
||||||
const bool scaleEmotesByLineHeight =
|
const bool scaleEmotesByLineHeight =
|
||||||
singletons::SettingManager::getInstance().scaleEmotesByLineHeight;
|
singletons::SettingManager::getInstance().scaleEmotesByLineHeight;
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "singletons/fontmanager.hpp"
|
|
||||||
#include "messages/lazyloadedimage.hpp"
|
#include "messages/lazyloadedimage.hpp"
|
||||||
#include "messages/link.hpp"
|
#include "messages/link.hpp"
|
||||||
#include "messages/messagecolor.hpp"
|
#include "messages/messagecolor.hpp"
|
||||||
|
#include "singletons/fontmanager.hpp"
|
||||||
//#include "wordflags.hpp"
|
//#include "wordflags.hpp"
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
@@ -96,8 +96,8 @@ public:
|
|||||||
explicit Word(LazyLoadedImage *_image, Flags getFlags, const QString ©text,
|
explicit Word(LazyLoadedImage *_image, Flags getFlags, const QString ©text,
|
||||||
const QString &tooltip, const Link &getLink = Link());
|
const QString &tooltip, const Link &getLink = Link());
|
||||||
explicit Word(const QString &_text, Flags getFlags, const MessageColor &textColor,
|
explicit Word(const QString &_text, Flags getFlags, const MessageColor &textColor,
|
||||||
singletons::FontManager::Type font, const QString ©text, const QString &tooltip,
|
singletons::FontManager::Type font, const QString ©text,
|
||||||
const Link &getLink = Link());
|
const QString &tooltip, const Link &getLink = Link());
|
||||||
|
|
||||||
bool isImage() const;
|
bool isImage() const;
|
||||||
bool isText() const;
|
bool isText() const;
|
||||||
|
|||||||
@@ -1,85 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include <QSettings>
|
|
||||||
#include <QString>
|
|
||||||
#include <boost/signals2.hpp>
|
|
||||||
|
|
||||||
namespace chatterino {
|
|
||||||
|
|
||||||
class BaseSetting
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
BaseSetting(const QString &_name)
|
|
||||||
: name(_name)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual QVariant getVariant() = 0;
|
|
||||||
virtual void setVariant(QVariant value) = 0;
|
|
||||||
|
|
||||||
const QString &getName() const
|
|
||||||
{
|
|
||||||
return this->name;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
QString name;
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
class Setting : public BaseSetting
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
Setting(std::vector<std::reference_wrapper<BaseSetting>> &settingItems, const QString &_name,
|
|
||||||
const T &defaultValue)
|
|
||||||
: BaseSetting(_name)
|
|
||||||
, value(defaultValue)
|
|
||||||
{
|
|
||||||
settingItems.push_back(*this);
|
|
||||||
}
|
|
||||||
|
|
||||||
const T &get() const
|
|
||||||
{
|
|
||||||
return this->value;
|
|
||||||
}
|
|
||||||
|
|
||||||
T &getnonConst()
|
|
||||||
{
|
|
||||||
return this->value;
|
|
||||||
}
|
|
||||||
|
|
||||||
void set(const T &newValue)
|
|
||||||
{
|
|
||||||
if (this->value != newValue) {
|
|
||||||
this->value = newValue;
|
|
||||||
|
|
||||||
valueChanged(newValue);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual QVariant getVariant() final
|
|
||||||
{
|
|
||||||
return QVariant::fromValue(this->value);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void setVariant(QVariant newValue) final
|
|
||||||
{
|
|
||||||
if (newValue.isValid()) {
|
|
||||||
assert(newValue.canConvert<T>());
|
|
||||||
set(newValue.value<T>());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void insertMap(QString id, bool sound, bool task)
|
|
||||||
{
|
|
||||||
QPair<bool, bool> pair(sound, task);
|
|
||||||
this->value.insert(id, pair);
|
|
||||||
}
|
|
||||||
|
|
||||||
boost::signals2::signal<void(const T &newValue)> valueChanged;
|
|
||||||
|
|
||||||
private:
|
|
||||||
T value;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace chatterino
|
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include "setting.hpp"
|
|
||||||
|
|
||||||
namespace chatterino {
|
|
||||||
|
|
||||||
struct SettingsSnapshot {
|
|
||||||
public:
|
|
||||||
SettingsSnapshot()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void addItem(std::reference_wrapper<BaseSetting> setting, const QVariant &value)
|
|
||||||
{
|
|
||||||
this->items.push_back(
|
|
||||||
std::pair<std::reference_wrapper<BaseSetting>, QVariant>(setting.get(), value));
|
|
||||||
}
|
|
||||||
|
|
||||||
void addMapItem(QString string, QPair<bool, bool> pair)
|
|
||||||
{
|
|
||||||
QMap<QString, QPair<bool, bool>> map;
|
|
||||||
this->mapItems.insert(string, pair);
|
|
||||||
}
|
|
||||||
|
|
||||||
void apply()
|
|
||||||
{
|
|
||||||
for (auto &item : this->items) {
|
|
||||||
item.first.get().setVariant(item.second);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
QMap<QString, QPair<bool, bool>> mapItems;
|
|
||||||
|
|
||||||
private:
|
|
||||||
std::vector<std::pair<std::reference_wrapper<BaseSetting>, QVariant>> items;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace chatterino
|
|
||||||
@@ -18,13 +18,7 @@ void _registerSetting(std::weak_ptr<pajlada::Settings::ISettingData> setting)
|
|||||||
}
|
}
|
||||||
|
|
||||||
SettingManager::SettingManager()
|
SettingManager::SettingManager()
|
||||||
: streamlinkPath("/behaviour/streamlink/path", "")
|
: snapshot(nullptr)
|
||||||
, preferredQuality("/behaviour/streamlink/quality", "Choose")
|
|
||||||
, emoteScale(this->settingsItems, "emoteScale", 1.0)
|
|
||||||
, pathHighlightSound(this->settingsItems, "pathHighlightSound", "qrc:/sounds/ping2.wav")
|
|
||||||
, highlightUserBlacklist(this->settingsItems, "highlightUserBlacklist", "")
|
|
||||||
, snapshot(nullptr)
|
|
||||||
, settings(Path::getAppdataPath() + "settings.ini", QSettings::IniFormat)
|
|
||||||
{
|
{
|
||||||
this->wordMaskListener.addSetting(this->showTimestamps);
|
this->wordMaskListener.addSetting(this->showTimestamps);
|
||||||
this->wordMaskListener.addSetting(this->showTimestampSeconds);
|
this->wordMaskListener.addSetting(this->showTimestampSeconds);
|
||||||
@@ -48,11 +42,6 @@ bool SettingManager::isIgnoredEmote(const QString &)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
QSettings &SettingManager::getQSettings()
|
|
||||||
{
|
|
||||||
return this->settings;
|
|
||||||
}
|
|
||||||
|
|
||||||
void SettingManager::load()
|
void SettingManager::load()
|
||||||
{
|
{
|
||||||
// Just to make sure the singleton is initialized
|
// Just to make sure the singleton is initialized
|
||||||
|
|||||||
@@ -2,10 +2,8 @@
|
|||||||
|
|
||||||
#include "messages/highlightphrase.hpp"
|
#include "messages/highlightphrase.hpp"
|
||||||
#include "messages/word.hpp"
|
#include "messages/word.hpp"
|
||||||
#include "setting.hpp"
|
|
||||||
#include "singletons/helper/chatterinosetting.hpp"
|
#include "singletons/helper/chatterinosetting.hpp"
|
||||||
|
|
||||||
#include <QSettings>
|
|
||||||
#include <pajlada/settings/setting.hpp>
|
#include <pajlada/settings/setting.hpp>
|
||||||
#include <pajlada/settings/settinglistener.hpp>
|
#include <pajlada/settings/settinglistener.hpp>
|
||||||
|
|
||||||
@@ -20,11 +18,12 @@ class SettingManager : public QObject
|
|||||||
|
|
||||||
using BoolSetting = ChatterinoSetting<bool>;
|
using BoolSetting = ChatterinoSetting<bool>;
|
||||||
using FloatSetting = ChatterinoSetting<float>;
|
using FloatSetting = ChatterinoSetting<float>;
|
||||||
|
using StringSetting = ChatterinoSetting<std::string>;
|
||||||
|
using QStringSetting = ChatterinoSetting<QString>;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
messages::Word::Flags getWordTypeMask();
|
messages::Word::Flags getWordTypeMask();
|
||||||
bool isIgnoredEmote(const QString &emote);
|
bool isIgnoredEmote(const QString &emote);
|
||||||
QSettings &getQSettings();
|
|
||||||
|
|
||||||
void load();
|
void load();
|
||||||
|
|
||||||
@@ -47,6 +46,8 @@ public:
|
|||||||
BoolSetting allowDuplicateMessages = {"/behaviour/allowDuplicateMessages", true};
|
BoolSetting allowDuplicateMessages = {"/behaviour/allowDuplicateMessages", true};
|
||||||
BoolSetting mentionUsersWithAt = {"/behaviour/mentionUsersWithAt", false};
|
BoolSetting mentionUsersWithAt = {"/behaviour/mentionUsersWithAt", false};
|
||||||
FloatSetting mouseScrollMultiplier = {"/behaviour/mouseScrollMultiplier", 1.0};
|
FloatSetting mouseScrollMultiplier = {"/behaviour/mouseScrollMultiplier", 1.0};
|
||||||
|
StringSetting streamlinkPath = {"/behaviour/streamlink/path", ""};
|
||||||
|
StringSetting preferredQuality = {"/behaviour/streamlink/quality", "Choose"};
|
||||||
|
|
||||||
/// Commands
|
/// Commands
|
||||||
BoolSetting allowCommandsAtEnd = {"/commands/allowCommandsAtEnd", false};
|
BoolSetting allowCommandsAtEnd = {"/commands/allowCommandsAtEnd", false};
|
||||||
@@ -58,6 +59,7 @@ public:
|
|||||||
BoolSetting enableFfzEmotes = {"/emotes/enableFFZEmotes", true};
|
BoolSetting enableFfzEmotes = {"/emotes/enableFFZEmotes", true};
|
||||||
BoolSetting enableEmojis = {"/emotes/enableEmojis", true};
|
BoolSetting enableEmojis = {"/emotes/enableEmojis", true};
|
||||||
BoolSetting enableGifAnimations = {"/emotes/enableGifAnimations", true};
|
BoolSetting enableGifAnimations = {"/emotes/enableGifAnimations", true};
|
||||||
|
FloatSetting emoteScale = {"/emotes/scale", 1.f};
|
||||||
|
|
||||||
/// Links
|
/// Links
|
||||||
BoolSetting linksDoubleClickOnly = {"/links/doubleClickToOpen", false};
|
BoolSetting linksDoubleClickOnly = {"/links/doubleClickToOpen", false};
|
||||||
@@ -69,15 +71,12 @@ public:
|
|||||||
BoolSetting enableHighlightTaskbar = {"/highlighting/enableTaskbarFlashing", true};
|
BoolSetting enableHighlightTaskbar = {"/highlighting/enableTaskbarFlashing", true};
|
||||||
BoolSetting customHighlightSound = {"/highlighting/useCustomSound", false};
|
BoolSetting customHighlightSound = {"/highlighting/useCustomSound", false};
|
||||||
|
|
||||||
pajlada::Settings::Setting<std::string> streamlinkPath;
|
|
||||||
pajlada::Settings::Setting<std::string> preferredQuality;
|
|
||||||
|
|
||||||
Setting<float> emoteScale;
|
|
||||||
ChatterinoSetting<std::vector<messages::HighlightPhrase>> highlightProperties = {
|
ChatterinoSetting<std::vector<messages::HighlightPhrase>> highlightProperties = {
|
||||||
"/highlighting/highlights"};
|
"/highlighting/highlights"};
|
||||||
|
|
||||||
Setting<QString> pathHighlightSound;
|
QStringSetting pathHighlightSound = {"/highlighting/highlightSoundPath",
|
||||||
Setting<QString> highlightUserBlacklist;
|
"qrc:/sounds/ping2.wav"};
|
||||||
|
QStringSetting highlightUserBlacklist = {"/highlighting/blacklistedUsers", ""};
|
||||||
|
|
||||||
BoolSetting highlightAlwaysPlaySound = {"/highlighting/alwaysPlaySound", false};
|
BoolSetting highlightAlwaysPlaySound = {"/highlighting/alwaysPlaySound", false};
|
||||||
|
|
||||||
@@ -101,8 +100,6 @@ private:
|
|||||||
|
|
||||||
SettingManager();
|
SettingManager();
|
||||||
|
|
||||||
QSettings settings;
|
|
||||||
std::vector<std::reference_wrapper<BaseSetting>> settingsItems;
|
|
||||||
messages::Word::Flags wordTypeMask = messages::Word::Default;
|
messages::Word::Flags wordTypeMask = messages::Word::Default;
|
||||||
|
|
||||||
pajlada::Settings::SettingListener wordMaskListener;
|
pajlada::Settings::SettingListener wordMaskListener;
|
||||||
|
|||||||
@@ -396,7 +396,7 @@ void TwitchMessageBuilder::parseHighlights()
|
|||||||
// update the media player url if necessary
|
// update the media player url if necessary
|
||||||
QUrl highlightSoundUrl;
|
QUrl highlightSoundUrl;
|
||||||
if (settings.customHighlightSound) {
|
if (settings.customHighlightSound) {
|
||||||
highlightSoundUrl = QUrl(settings.pathHighlightSound.get());
|
highlightSoundUrl = QUrl(settings.pathHighlightSound.getValue());
|
||||||
} else {
|
} else {
|
||||||
highlightSoundUrl = QUrl("qrc:/sounds/ping2.wav");
|
highlightSoundUrl = QUrl("qrc:/sounds/ping2.wav");
|
||||||
}
|
}
|
||||||
@@ -408,7 +408,7 @@ void TwitchMessageBuilder::parseHighlights()
|
|||||||
}
|
}
|
||||||
|
|
||||||
QStringList blackList =
|
QStringList blackList =
|
||||||
settings.highlightUserBlacklist.get().split("\n", QString::SkipEmptyParts);
|
settings.highlightUserBlacklist.getValue().split("\n", QString::SkipEmptyParts);
|
||||||
|
|
||||||
// TODO: This vector should only be rebuilt upon highlights being changed
|
// TODO: This vector should only be rebuilt upon highlights being changed
|
||||||
auto activeHighlights = settings.highlightProperties.getValue();
|
auto activeHighlights = settings.highlightProperties.getValue();
|
||||||
|
|||||||
@@ -95,18 +95,18 @@ AccountPopupWidget::AccountPopupWidget(std::shared_ptr<Channel> _channel)
|
|||||||
});
|
});
|
||||||
|
|
||||||
QObject::connect(this->ui->disableHighlights, &QPushButton::clicked, this, [=, &settings]() {
|
QObject::connect(this->ui->disableHighlights, &QPushButton::clicked, this, [=, &settings]() {
|
||||||
QString str = settings.highlightUserBlacklist.getnonConst();
|
QString str = settings.highlightUserBlacklist;
|
||||||
str.append(this->ui->lblUsername->text() + "\n");
|
str.append(this->ui->lblUsername->text() + "\n");
|
||||||
settings.highlightUserBlacklist.set(str);
|
settings.highlightUserBlacklist = str;
|
||||||
this->ui->disableHighlights->hide();
|
this->ui->disableHighlights->hide();
|
||||||
this->ui->enableHighlights->show();
|
this->ui->enableHighlights->show();
|
||||||
});
|
});
|
||||||
|
|
||||||
QObject::connect(this->ui->enableHighlights, &QPushButton::clicked, this, [=, &settings]() {
|
QObject::connect(this->ui->enableHighlights, &QPushButton::clicked, this, [=, &settings]() {
|
||||||
QString str = settings.highlightUserBlacklist.getnonConst();
|
QString str = settings.highlightUserBlacklist;
|
||||||
QStringList list = str.split("\n");
|
QStringList list = str.split("\n");
|
||||||
list.removeAll(this->ui->lblUsername->text());
|
list.removeAll(this->ui->lblUsername->text());
|
||||||
settings.highlightUserBlacklist.set(list.join("\n"));
|
settings.highlightUserBlacklist = list.join("\n");
|
||||||
this->ui->enableHighlights->hide();
|
this->ui->enableHighlights->hide();
|
||||||
this->ui->disableHighlights->show();
|
this->ui->disableHighlights->show();
|
||||||
});
|
});
|
||||||
@@ -267,8 +267,7 @@ void AccountPopupWidget::showEvent(QShowEvent *)
|
|||||||
this->updateButtons(this->ui->ownerLayout, false);
|
this->updateButtons(this->ui->ownerLayout, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString blacklisted =
|
QString blacklisted = singletons::SettingManager::getInstance().highlightUserBlacklist;
|
||||||
singletons::SettingManager::getInstance().highlightUserBlacklist.getnonConst();
|
|
||||||
QStringList list = blacklisted.split("\n", QString::SkipEmptyParts);
|
QStringList list = blacklisted.split("\n", QString::SkipEmptyParts);
|
||||||
if (list.contains(this->ui->lblUsername->text(), Qt::CaseInsensitive)) {
|
if (list.contains(this->ui->lblUsername->text(), Qt::CaseInsensitive)) {
|
||||||
this->ui->disableHighlights->hide();
|
this->ui->disableHighlights->hide();
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "basewidget.hpp"
|
#include "basewidget.hpp"
|
||||||
#include "util/concurrentmap.hpp"
|
|
||||||
#include "twitch/twitchchannel.hpp"
|
#include "twitch/twitchchannel.hpp"
|
||||||
|
#include "util/concurrentmap.hpp"
|
||||||
|
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|||||||
@@ -422,7 +422,7 @@ QVBoxLayout *SettingsDialog::createHighlightingTab()
|
|||||||
for (const auto &highlightProperty : highlightProperties) {
|
for (const auto &highlightProperty : highlightProperties) {
|
||||||
highlights->addItem(highlightProperty.key);
|
highlights->addItem(highlightProperty.key);
|
||||||
}
|
}
|
||||||
highlightUserBlacklist->setText(settings.highlightUserBlacklist.getnonConst());
|
highlightUserBlacklist->setText(settings.highlightUserBlacklist);
|
||||||
auto highlightTab = new QTabWidget();
|
auto highlightTab = new QTabWidget();
|
||||||
auto customSound = new QHBoxLayout();
|
auto customSound = new QHBoxLayout();
|
||||||
auto soundForm = new QFormLayout();
|
auto soundForm = new QFormLayout();
|
||||||
@@ -439,7 +439,7 @@ QVBoxLayout *SettingsDialog::createHighlightingTab()
|
|||||||
QObject::connect(selectBtn, &QPushButton::clicked, this, [&settings, this] {
|
QObject::connect(selectBtn, &QPushButton::clicked, this, [&settings, this] {
|
||||||
auto fileName = QFileDialog::getOpenFileName(this, tr("Open Sound"), "",
|
auto fileName = QFileDialog::getOpenFileName(this, tr("Open Sound"), "",
|
||||||
tr("Audio Files (*.mp3 *.wav)"));
|
tr("Audio Files (*.mp3 *.wav)"));
|
||||||
settings.pathHighlightSound.set(fileName);
|
settings.pathHighlightSound = fileName;
|
||||||
});
|
});
|
||||||
customSound->addWidget(selectBtn);
|
customSound->addWidget(selectBtn);
|
||||||
}
|
}
|
||||||
@@ -617,11 +617,12 @@ QVBoxLayout *SettingsDialog::createHighlightingTab()
|
|||||||
QStringList list =
|
QStringList list =
|
||||||
highlightUserBlacklist->toPlainText().split("\n", QString::SkipEmptyParts);
|
highlightUserBlacklist->toPlainText().split("\n", QString::SkipEmptyParts);
|
||||||
list.removeDuplicates();
|
list.removeDuplicates();
|
||||||
settings.highlightUserBlacklist.set(list.join("\n") + "\n");
|
settings.highlightUserBlacklist = list.join("\n") + "\n";
|
||||||
});
|
});
|
||||||
|
|
||||||
settings.highlightUserBlacklist.valueChanged.connect(
|
settings.highlightUserBlacklist.connect([=](const QString &str, auto) {
|
||||||
[=](const QString &str) { highlightUserBlacklist->setPlainText(str); });
|
highlightUserBlacklist->setPlainText(str); //
|
||||||
|
});
|
||||||
|
|
||||||
return layout;
|
return layout;
|
||||||
}
|
}
|
||||||
@@ -739,20 +740,6 @@ QVBoxLayout *SettingsDialog::createTabLayout()
|
|||||||
return layout;
|
return layout;
|
||||||
}
|
}
|
||||||
|
|
||||||
QCheckBox *SettingsDialog::createCheckbox(const QString &title, Setting<bool> &setting)
|
|
||||||
{
|
|
||||||
auto checkbox = new QCheckBox(title);
|
|
||||||
|
|
||||||
// Set checkbox initial state
|
|
||||||
checkbox->setChecked(setting.get());
|
|
||||||
|
|
||||||
QObject::connect(checkbox, &QCheckBox::toggled, this, [&setting](bool state) {
|
|
||||||
setting.set(state); //
|
|
||||||
});
|
|
||||||
|
|
||||||
return checkbox;
|
|
||||||
}
|
|
||||||
|
|
||||||
QCheckBox *SettingsDialog::createCheckbox(const QString &title,
|
QCheckBox *SettingsDialog::createCheckbox(const QString &title,
|
||||||
pajlada::Settings::Setting<bool> &setting)
|
pajlada::Settings::Setting<bool> &setting)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -88,7 +88,6 @@ private:
|
|||||||
|
|
||||||
/// Widget creation helpers
|
/// Widget creation helpers
|
||||||
QVBoxLayout *createTabLayout();
|
QVBoxLayout *createTabLayout();
|
||||||
QCheckBox *createCheckbox(const QString &title, Setting<bool> &setting);
|
|
||||||
QCheckBox *createCheckbox(const QString &title, pajlada::Settings::Setting<bool> &setting);
|
QCheckBox *createCheckbox(const QString &title, pajlada::Settings::Setting<bool> &setting);
|
||||||
QHBoxLayout *createCombobox(const QString &title, pajlada::Settings::Setting<int> &setting,
|
QHBoxLayout *createCombobox(const QString &title, pajlada::Settings::Setting<int> &setting,
|
||||||
QStringList items,
|
QStringList items,
|
||||||
|
|||||||
Reference in New Issue
Block a user