Merge pull request #4 from fourtf/new-settings-with-boost
New settings system, boost new dependency
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
# chatterino 2
|
||||
|
||||
by @fourtf
|
||||
|
||||
## requirements
|
||||
1. install boost by going to [this link](https://sourceforge.net/projects/boost/files/boost/1.63.0/boost_1_63_0.zip/download) and extracting it to `C:\local\boost` so that `C:\local\boost\boost.png` exists
|
||||
+7
-5
@@ -15,7 +15,7 @@ COMMUNI += core model util
|
||||
# LIBS += -lcrypto -lssl
|
||||
#}
|
||||
|
||||
CONFIG += c++11
|
||||
CONFIG += c++14
|
||||
|
||||
include(lib/libcommuni/src/src.pri)
|
||||
|
||||
@@ -108,10 +108,6 @@ HEADERS += account.h \
|
||||
widgets/signallabel.h \
|
||||
widgets/textinputdialog.h \
|
||||
windows.h \
|
||||
settings/boolsetting.h \
|
||||
settings/stringsetting.h \
|
||||
settings/intsetting.h \
|
||||
settings/floatsetting.h \
|
||||
widgets/resizingtextedit.h
|
||||
|
||||
PRECOMPILED_HEADER =
|
||||
@@ -120,3 +116,9 @@ RESOURCES += \
|
||||
resources.qrc
|
||||
|
||||
DISTFILES +=
|
||||
|
||||
|
||||
# Include boost
|
||||
win32 {
|
||||
INCLUDEPATH += C:\local\boost\
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include "emojis.h"
|
||||
#include "ircmanager.h"
|
||||
#include "resources.h"
|
||||
#include "settings/settings.h"
|
||||
#include "widgets/mainwindow.h"
|
||||
#include "windows.h"
|
||||
|
||||
@@ -17,6 +18,7 @@ main(int argc, char *argv[])
|
||||
{
|
||||
QApplication a(argc, argv);
|
||||
|
||||
settings::Settings::getInstance().load();
|
||||
Resources::load();
|
||||
Emojis::loadEmojis();
|
||||
|
||||
@@ -27,5 +29,9 @@ main(int argc, char *argv[])
|
||||
|
||||
IrcManager::connect();
|
||||
|
||||
return a.exec();
|
||||
int ret = a.exec();
|
||||
|
||||
settings::Settings::getInstance().save();
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -417,8 +417,8 @@ Message::layout(int width, bool enableEmoteMargins)
|
||||
bool recalculateImages = this->emoteGeneration != Emotes::getGeneration();
|
||||
bool recalculateText = this->fontGeneration != Fonts::getGeneration();
|
||||
|
||||
qreal emoteScale = settings.getEmoteScale().get();
|
||||
bool scaleEmotesByLineHeight = settings.getScaleEmotesByLineHeight().get();
|
||||
qreal emoteScale = settings.emoteScale.get();
|
||||
bool scaleEmotesByLineHeight = settings.scaleEmotesByLineHeight.get();
|
||||
|
||||
if (recalculateImages || recalculateText) {
|
||||
this->emoteGeneration = Emotes::getGeneration();
|
||||
|
||||
@@ -1,58 +0,0 @@
|
||||
#ifndef BOOLSETTING_H
|
||||
#define BOOLSETTING_H
|
||||
|
||||
#include "settings/setting.h"
|
||||
|
||||
#include <QString>
|
||||
|
||||
namespace chatterino {
|
||||
namespace settings {
|
||||
class BoolSetting : public Setting
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
BoolSetting(const QString &name, bool defaultValue)
|
||||
: Setting(name)
|
||||
, value(defaultValue)
|
||||
, defaultValue(defaultValue)
|
||||
{
|
||||
}
|
||||
|
||||
bool
|
||||
get() const
|
||||
{
|
||||
return this->value;
|
||||
}
|
||||
|
||||
void
|
||||
set(bool value)
|
||||
{
|
||||
if (this->value != value) {
|
||||
this->value = value;
|
||||
|
||||
emit valueChanged(value);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
save(const QSettings &settings) override
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
load(const QSettings &settings) override
|
||||
{
|
||||
}
|
||||
|
||||
signals:
|
||||
void valueChanged(bool value);
|
||||
|
||||
private:
|
||||
bool value;
|
||||
bool defaultValue;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif // BOOLSETTING_H
|
||||
@@ -1,58 +0,0 @@
|
||||
#ifndef REALSETTING_H
|
||||
#define REALSETTING_H
|
||||
|
||||
#include "settings/setting.h"
|
||||
|
||||
#include <QString>
|
||||
|
||||
namespace chatterino {
|
||||
namespace settings {
|
||||
|
||||
class FloatSetting : public Setting
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
FloatSetting(const QString &name, qreal defaultValue,
|
||||
qreal minValue = std::numeric_limits<qreal>::min(),
|
||||
qreal maxValue = std::numeric_limits<qreal>::max())
|
||||
: Setting(name)
|
||||
, value(defaultValue)
|
||||
, defaultValue(defaultValue)
|
||||
, minValue(minValue)
|
||||
, maxValue(maxValue)
|
||||
{
|
||||
}
|
||||
|
||||
qreal
|
||||
get() const
|
||||
{
|
||||
return this->value;
|
||||
}
|
||||
|
||||
qreal
|
||||
set(qreal value)
|
||||
{
|
||||
return (this->value = std::max(std::min(value, maxValue), minValue));
|
||||
}
|
||||
|
||||
void
|
||||
save(const QSettings &settings) override
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
load(const QSettings &settings) override
|
||||
{
|
||||
}
|
||||
|
||||
private:
|
||||
qreal value;
|
||||
qreal defaultValue;
|
||||
qreal minValue;
|
||||
qreal maxValue;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif // REALSETTING_H
|
||||
@@ -1,51 +0,0 @@
|
||||
#ifndef INTSETTING_H
|
||||
#define INTSETTING_H
|
||||
|
||||
#include "settings/setting.h"
|
||||
|
||||
#include <QString>
|
||||
|
||||
namespace chatterino {
|
||||
namespace settings {
|
||||
class IntSetting : public Setting
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
IntSetting(const QString &name, int defaultValue)
|
||||
: Setting(name)
|
||||
, value(defaultValue)
|
||||
, defaultValue(defaultValue)
|
||||
{
|
||||
}
|
||||
|
||||
int
|
||||
get() const
|
||||
{
|
||||
return this->value;
|
||||
}
|
||||
|
||||
int
|
||||
set(int value)
|
||||
{
|
||||
return (this->value = value);
|
||||
}
|
||||
|
||||
void
|
||||
save(const QSettings &settings) override
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
load(const QSettings &settings) override
|
||||
{
|
||||
}
|
||||
|
||||
private:
|
||||
int value;
|
||||
int defaultValue;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif // INTSETTING_H
|
||||
+59
-10
@@ -3,34 +3,83 @@
|
||||
|
||||
#include <QSettings>
|
||||
#include <QString>
|
||||
#include <boost/signals2.hpp>
|
||||
|
||||
namespace chatterino {
|
||||
namespace settings {
|
||||
|
||||
class Setting : public QObject
|
||||
class BaseSetting
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit Setting(const QString &name)
|
||||
: name(name)
|
||||
BaseSetting(const QString &_name)
|
||||
: name(_name)
|
||||
{
|
||||
}
|
||||
|
||||
virtual void save(const QSettings &settings) = 0;
|
||||
virtual void save(QSettings &settings) = 0;
|
||||
virtual void load(const QSettings &settings) = 0;
|
||||
|
||||
protected:
|
||||
const QString &
|
||||
getName() const
|
||||
{
|
||||
return name;
|
||||
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;
|
||||
}
|
||||
|
||||
void
|
||||
set(const T &newValue)
|
||||
{
|
||||
if (this->value != newValue) {
|
||||
this->value = newValue;
|
||||
|
||||
this->valueChanged(newValue);
|
||||
}
|
||||
}
|
||||
|
||||
virtual void
|
||||
save(QSettings &settings) final
|
||||
{
|
||||
settings.setValue(this->getName(), QVariant::fromValue(this->value));
|
||||
}
|
||||
|
||||
virtual void
|
||||
load(const QSettings &settings) final
|
||||
{
|
||||
QVariant newValue = settings.value(this->getName(), QVariant());
|
||||
if (newValue.isValid()) {
|
||||
assert(newValue.canConvert<T>());
|
||||
this->set(newValue.value<T>());
|
||||
}
|
||||
}
|
||||
|
||||
boost::signals2::signal<void(const T &newValue)> valueChanged;
|
||||
|
||||
private:
|
||||
T value;
|
||||
};
|
||||
|
||||
} // namespace settings
|
||||
} // namespace chatterino
|
||||
|
||||
#endif // SETTING_H
|
||||
|
||||
+54
-77
@@ -1,104 +1,80 @@
|
||||
#include "settings/settings.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QDir>
|
||||
#include <QStandardPaths>
|
||||
|
||||
namespace chatterino {
|
||||
namespace settings {
|
||||
|
||||
Settings Settings::_;
|
||||
Settings Settings::instance;
|
||||
|
||||
Settings::Settings()
|
||||
: settings(
|
||||
QStandardPaths::writableLocation(QStandardPaths::AppDataLocation),
|
||||
QSettings::IniFormat)
|
||||
, settingsItems()
|
||||
, portable(false)
|
||||
, wordTypeMask(messages::Word::Default)
|
||||
, theme("", "dark")
|
||||
, user("", "")
|
||||
, emoteScale("", 1.0)
|
||||
, scaleEmotesByLineHeight("", false)
|
||||
, showTimestamps("", true)
|
||||
, showTimestampSeconds("", false)
|
||||
, showLastMessageIndicator("", false)
|
||||
, allowDouplicateMessages("", true)
|
||||
, linksDoubleClickOnly("", false)
|
||||
, hideEmptyInput("", false)
|
||||
, showMessageLength("", false)
|
||||
, seperateMessages("", false)
|
||||
, mentionUsersWithAt("", false)
|
||||
, allowCommandsAtEnd("", false)
|
||||
, enableHighlights("", true)
|
||||
, enableHighlightSound("", true)
|
||||
, enableHighlightTaskbar("", true)
|
||||
, customHighlightSound("", false)
|
||||
, enableTwitchEmotes("", true)
|
||||
, enableBttvEmotes("", true)
|
||||
, enableFfzEmotes("", true)
|
||||
, enableEmojis("", true)
|
||||
, enableGifAnimations("", true)
|
||||
, enableGifs("", true)
|
||||
, inlineWhispers("", true)
|
||||
, windowTopMost("", true)
|
||||
, hideTabX("", false)
|
||||
, theme(this->settingsItems, "theme", "dark")
|
||||
, user(this->settingsItems, "userNotSureWhatThisMaybeOAuthOrSomething", "")
|
||||
, emoteScale(this->settingsItems, "emoteScale", 1.0)
|
||||
, scaleEmotesByLineHeight(this->settingsItems, "scaleEmotesByLineHeight",
|
||||
false)
|
||||
, showTimestamps(this->settingsItems, "showTimestamps", true)
|
||||
, showTimestampSeconds(this->settingsItems, "showTimestampSeconds", false)
|
||||
, showLastMessageIndicator(this->settingsItems, "showLastMessageIndicator",
|
||||
false)
|
||||
, allowDouplicateMessages(this->settingsItems, "allowDouplicateMessages",
|
||||
true)
|
||||
, linksDoubleClickOnly(this->settingsItems, "linksDoubleClickOnly", false)
|
||||
, hideEmptyInput(this->settingsItems, "hideEmptyInput", false)
|
||||
, showMessageLength(this->settingsItems, "showMessageLength", false)
|
||||
, seperateMessages(this->settingsItems, "seperateMessages", false)
|
||||
, mentionUsersWithAt(this->settingsItems, "mentionUsersWithAt", false)
|
||||
, allowCommandsAtEnd(this->settingsItems, "allowCommandsAtEnd", false)
|
||||
, enableHighlights(this->settingsItems, "enableHighlights", true)
|
||||
, enableHighlightSound(this->settingsItems, "enableHighlightSound", true)
|
||||
, enableHighlightTaskbar(this->settingsItems, "enableHighlightTaskbar",
|
||||
true)
|
||||
, customHighlightSound(this->settingsItems, "customHighlightSound", false)
|
||||
, enableTwitchEmotes(this->settingsItems, "enableTwitchEmotes", true)
|
||||
, enableBttvEmotes(this->settingsItems, "enableBttvEmotes", true)
|
||||
, enableFfzEmotes(this->settingsItems, "enableFfzEmotes", true)
|
||||
, enableEmojis(this->settingsItems, "enableEmojis", true)
|
||||
, enableGifAnimations(this->settingsItems, "enableGifAnimations", true)
|
||||
, enableGifs(this->settingsItems, "enableGifs", true)
|
||||
, inlineWhispers(this->settingsItems, "inlineWhispers", true)
|
||||
, windowTopMost(this->settingsItems, "windowTopMost", true)
|
||||
, hideTabX(this->settingsItems, "hideTabX", false)
|
||||
{
|
||||
settingsItems.reserve(25);
|
||||
settingsItems.push_back(&theme);
|
||||
settingsItems.push_back(&user);
|
||||
settingsItems.push_back(&emoteScale);
|
||||
settingsItems.push_back(&scaleEmotesByLineHeight);
|
||||
settingsItems.push_back(&showTimestamps);
|
||||
settingsItems.push_back(&showTimestampSeconds);
|
||||
settingsItems.push_back(&showLastMessageIndicator);
|
||||
settingsItems.push_back(&allowDouplicateMessages);
|
||||
settingsItems.push_back(&linksDoubleClickOnly);
|
||||
settingsItems.push_back(&hideEmptyInput);
|
||||
settingsItems.push_back(&showMessageLength);
|
||||
settingsItems.push_back(&seperateMessages);
|
||||
settingsItems.push_back(&mentionUsersWithAt);
|
||||
settingsItems.push_back(&allowCommandsAtEnd);
|
||||
settingsItems.push_back(&enableHighlights);
|
||||
settingsItems.push_back(&enableHighlightSound);
|
||||
settingsItems.push_back(&enableHighlightTaskbar);
|
||||
settingsItems.push_back(&customHighlightSound);
|
||||
settingsItems.push_back(&enableTwitchEmotes);
|
||||
settingsItems.push_back(&enableBttvEmotes);
|
||||
settingsItems.push_back(&enableFfzEmotes);
|
||||
settingsItems.push_back(&enableEmojis);
|
||||
settingsItems.push_back(&enableGifAnimations);
|
||||
settingsItems.push_back(&enableGifs);
|
||||
settingsItems.push_back(&inlineWhispers);
|
||||
settingsItems.push_back(&windowTopMost);
|
||||
settingsItems.push_back(&hideTabX);
|
||||
|
||||
QObject::connect(&showTimestamps, &BoolSetting::valueChanged, this,
|
||||
&Settings::updateWordTypeMask);
|
||||
QObject::connect(&showTimestampSeconds, &BoolSetting::valueChanged, this,
|
||||
&Settings::updateWordTypeMask);
|
||||
QObject::connect(&enableBttvEmotes, &BoolSetting::valueChanged, this,
|
||||
&Settings::updateWordTypeMask);
|
||||
QObject::connect(&enableEmojis, &BoolSetting::valueChanged, this,
|
||||
&Settings::updateWordTypeMask);
|
||||
QObject::connect(&enableFfzEmotes, &BoolSetting::valueChanged, this,
|
||||
&Settings::updateWordTypeMask);
|
||||
QObject::connect(&enableTwitchEmotes, &BoolSetting::valueChanged, this,
|
||||
&Settings::updateWordTypeMask);
|
||||
this->showTimestamps.valueChanged.connect(
|
||||
[this](const auto &) { this->updateWordTypeMask(); });
|
||||
this->showTimestampSeconds.valueChanged.connect(
|
||||
[this](const auto &) { this->updateWordTypeMask(); });
|
||||
this->enableBttvEmotes.valueChanged.connect(
|
||||
[this](const auto &) { this->updateWordTypeMask(); });
|
||||
this->enableEmojis.valueChanged.connect(
|
||||
[this](const auto &) { this->updateWordTypeMask(); });
|
||||
this->enableFfzEmotes.valueChanged.connect(
|
||||
[this](const auto &) { this->updateWordTypeMask(); });
|
||||
this->enableTwitchEmotes.valueChanged.connect(
|
||||
[this](const auto &) { this->updateWordTypeMask(); });
|
||||
}
|
||||
|
||||
void
|
||||
Settings::save()
|
||||
{
|
||||
for (Setting *item : settingsItems) {
|
||||
item->save(settings);
|
||||
for (auto &item : settingsItems) {
|
||||
item.get().save(settings);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Settings::load()
|
||||
{
|
||||
for (Setting *item : settingsItems) {
|
||||
item->load(settings);
|
||||
for (auto &item : settingsItems) {
|
||||
qDebug() << "Loading settings for " << item.get().getName();
|
||||
item.get().load(settings);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -109,7 +85,7 @@ Settings::isIgnoredEmote(const QString &)
|
||||
}
|
||||
|
||||
void
|
||||
Settings::updateWordTypeMask(bool)
|
||||
Settings::updateWordTypeMask()
|
||||
|
||||
{
|
||||
using namespace messages;
|
||||
@@ -143,5 +119,6 @@ Settings::updateWordTypeMask(bool)
|
||||
emit wordTypeMaskChanged();
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace settings
|
||||
} // namespace chatterino
|
||||
|
||||
+34
-174
@@ -2,10 +2,7 @@
|
||||
#define APPSETTINGS_H
|
||||
|
||||
#include "messages/word.h"
|
||||
#include "settings/boolsetting.h"
|
||||
#include "settings/floatsetting.h"
|
||||
#include "settings/setting.h"
|
||||
#include "settings/stringsetting.h"
|
||||
|
||||
#include <QSettings>
|
||||
|
||||
@@ -20,7 +17,7 @@ public:
|
||||
static Settings &
|
||||
getInstance()
|
||||
{
|
||||
return _;
|
||||
return instance;
|
||||
}
|
||||
|
||||
void load();
|
||||
@@ -52,12 +49,12 @@ signals:
|
||||
private:
|
||||
Settings();
|
||||
|
||||
static Settings _;
|
||||
static Settings instance;
|
||||
|
||||
void updateWordTypeMask(bool);
|
||||
void updateWordTypeMask();
|
||||
|
||||
QSettings settings;
|
||||
std::vector<Setting *> settingsItems;
|
||||
std::vector<std::reference_wrapper<BaseSetting>> settingsItems;
|
||||
|
||||
// template <class T>
|
||||
// T
|
||||
@@ -71,174 +68,37 @@ private:
|
||||
|
||||
messages::Word::Type wordTypeMask;
|
||||
|
||||
private:
|
||||
StringSetting theme;
|
||||
StringSetting user;
|
||||
FloatSetting emoteScale;
|
||||
BoolSetting scaleEmotesByLineHeight;
|
||||
BoolSetting showTimestamps;
|
||||
BoolSetting showTimestampSeconds;
|
||||
BoolSetting showLastMessageIndicator;
|
||||
BoolSetting allowDouplicateMessages;
|
||||
BoolSetting linksDoubleClickOnly;
|
||||
BoolSetting hideEmptyInput;
|
||||
BoolSetting showMessageLength;
|
||||
BoolSetting seperateMessages;
|
||||
BoolSetting mentionUsersWithAt;
|
||||
BoolSetting allowCommandsAtEnd;
|
||||
BoolSetting enableHighlights;
|
||||
BoolSetting enableHighlightSound;
|
||||
BoolSetting enableHighlightTaskbar;
|
||||
BoolSetting customHighlightSound;
|
||||
BoolSetting enableTwitchEmotes;
|
||||
BoolSetting enableBttvEmotes;
|
||||
BoolSetting enableFfzEmotes;
|
||||
BoolSetting enableEmojis;
|
||||
BoolSetting enableGifAnimations;
|
||||
BoolSetting enableGifs;
|
||||
BoolSetting inlineWhispers;
|
||||
BoolSetting windowTopMost;
|
||||
BoolSetting hideTabX;
|
||||
|
||||
// settings
|
||||
public:
|
||||
StringSetting &
|
||||
getTheme()
|
||||
{
|
||||
return this->theme;
|
||||
}
|
||||
StringSetting &
|
||||
getUser()
|
||||
{
|
||||
return this->user;
|
||||
}
|
||||
FloatSetting &
|
||||
getEmoteScale()
|
||||
{
|
||||
return this->emoteScale;
|
||||
}
|
||||
BoolSetting &
|
||||
getScaleEmotesByLineHeight()
|
||||
{
|
||||
return this->scaleEmotesByLineHeight;
|
||||
}
|
||||
BoolSetting &
|
||||
getShowTimestamps()
|
||||
{
|
||||
return this->showTimestamps;
|
||||
}
|
||||
BoolSetting &
|
||||
getShowTimestampSeconds()
|
||||
{
|
||||
return this->showTimestampSeconds;
|
||||
}
|
||||
BoolSetting &
|
||||
getShowLastMessageIndicator()
|
||||
{
|
||||
return this->showLastMessageIndicator;
|
||||
}
|
||||
BoolSetting &
|
||||
getAllowDouplicateMessages()
|
||||
{
|
||||
return this->allowDouplicateMessages;
|
||||
}
|
||||
BoolSetting &
|
||||
getLinksDoubleClickOnly()
|
||||
{
|
||||
return this->linksDoubleClickOnly;
|
||||
}
|
||||
BoolSetting &
|
||||
getHideEmptyInput()
|
||||
{
|
||||
return this->hideEmptyInput;
|
||||
}
|
||||
BoolSetting &
|
||||
getShowMessageLength()
|
||||
{
|
||||
return this->showMessageLength;
|
||||
}
|
||||
BoolSetting &
|
||||
getSeperateMessages()
|
||||
{
|
||||
return this->seperateMessages;
|
||||
}
|
||||
BoolSetting &
|
||||
getMentionUsersWithAt()
|
||||
{
|
||||
return this->mentionUsersWithAt;
|
||||
}
|
||||
BoolSetting &
|
||||
getAllowCommandsAtEnd()
|
||||
{
|
||||
return this->allowCommandsAtEnd;
|
||||
}
|
||||
BoolSetting &
|
||||
getEnableHighlights()
|
||||
{
|
||||
return this->enableHighlights;
|
||||
}
|
||||
BoolSetting &
|
||||
getEnableHighlightSound()
|
||||
{
|
||||
return this->enableHighlightSound;
|
||||
}
|
||||
BoolSetting &
|
||||
getEnableHighlightTaskbar()
|
||||
{
|
||||
return this->enableHighlightTaskbar;
|
||||
}
|
||||
BoolSetting &
|
||||
getCustomHighlightSound()
|
||||
{
|
||||
return this->customHighlightSound;
|
||||
}
|
||||
BoolSetting &
|
||||
getEnableTwitchEmotes()
|
||||
{
|
||||
return this->enableTwitchEmotes;
|
||||
}
|
||||
BoolSetting &
|
||||
getEnableBttvEmotes()
|
||||
{
|
||||
return this->enableBttvEmotes;
|
||||
}
|
||||
BoolSetting &
|
||||
getEnableFfzEmotes()
|
||||
{
|
||||
return this->enableFfzEmotes;
|
||||
}
|
||||
BoolSetting &
|
||||
getEnableEmojis()
|
||||
{
|
||||
return this->enableEmojis;
|
||||
}
|
||||
BoolSetting &
|
||||
getEnableGifAnimations()
|
||||
{
|
||||
return this->enableGifAnimations;
|
||||
}
|
||||
BoolSetting &
|
||||
getEnableGifs()
|
||||
{
|
||||
return this->enableGifs;
|
||||
}
|
||||
BoolSetting &
|
||||
getInlineWhispers()
|
||||
{
|
||||
return this->inlineWhispers;
|
||||
}
|
||||
BoolSetting &
|
||||
getWindowTopMost()
|
||||
{
|
||||
return this->windowTopMost;
|
||||
}
|
||||
BoolSetting &
|
||||
getHideTabX()
|
||||
{
|
||||
return this->hideTabX;
|
||||
}
|
||||
Setting<QString> theme;
|
||||
Setting<QString> user;
|
||||
Setting<float> emoteScale;
|
||||
Setting<bool> scaleEmotesByLineHeight;
|
||||
Setting<bool> showTimestamps;
|
||||
Setting<bool> showTimestampSeconds;
|
||||
Setting<bool> showLastMessageIndicator;
|
||||
Setting<bool> allowDouplicateMessages;
|
||||
Setting<bool> linksDoubleClickOnly;
|
||||
Setting<bool> hideEmptyInput;
|
||||
Setting<bool> showMessageLength;
|
||||
Setting<bool> seperateMessages;
|
||||
Setting<bool> mentionUsersWithAt;
|
||||
Setting<bool> allowCommandsAtEnd;
|
||||
Setting<bool> enableHighlights;
|
||||
Setting<bool> enableHighlightSound;
|
||||
Setting<bool> enableHighlightTaskbar;
|
||||
Setting<bool> customHighlightSound;
|
||||
Setting<bool> enableTwitchEmotes;
|
||||
Setting<bool> enableBttvEmotes;
|
||||
Setting<bool> enableFfzEmotes;
|
||||
Setting<bool> enableEmojis;
|
||||
Setting<bool> enableGifAnimations;
|
||||
Setting<bool> enableGifs;
|
||||
Setting<bool> inlineWhispers;
|
||||
Setting<bool> windowTopMost;
|
||||
Setting<bool> hideTabX;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace settings
|
||||
} // namespace chatterino
|
||||
|
||||
#endif // APPSETTINGS_H
|
||||
|
||||
@@ -1,61 +0,0 @@
|
||||
#ifndef STRINGSETTING_H
|
||||
#define STRINGSETTING_H
|
||||
|
||||
#include "settings/setting.h"
|
||||
|
||||
#include <QString>
|
||||
|
||||
namespace chatterino {
|
||||
namespace settings {
|
||||
|
||||
class StringSetting : public Setting
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
StringSetting(const QString &name, const QString &defaultValue)
|
||||
: Setting(name)
|
||||
, value(defaultValue)
|
||||
, defaultValue(defaultValue)
|
||||
{
|
||||
}
|
||||
|
||||
const QString &
|
||||
get() const
|
||||
{
|
||||
return this->value;
|
||||
}
|
||||
|
||||
const QString &
|
||||
set(const QString &value)
|
||||
{
|
||||
this->value = value;
|
||||
|
||||
QString tmp = value;
|
||||
|
||||
emit valueChanged(tmp);
|
||||
|
||||
return this->value;
|
||||
}
|
||||
|
||||
void
|
||||
save(const QSettings &settings) override
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
load(const QSettings &settings) override
|
||||
{
|
||||
}
|
||||
|
||||
signals:
|
||||
void valueChanged(const QString &value);
|
||||
|
||||
private:
|
||||
QString value;
|
||||
QString defaultValue;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif // STRINGSETTING_H
|
||||
@@ -41,18 +41,23 @@ ChatWidgetInput::ChatWidgetInput()
|
||||
this->refreshTheme();
|
||||
|
||||
this->setMessageLengthVisisble(
|
||||
settings::Settings::getInstance().getShowMessageLength().get());
|
||||
settings::Settings::getInstance().showMessageLength.get());
|
||||
|
||||
QObject::connect(&settings::Settings::getInstance().getShowMessageLength(),
|
||||
/* XXX(pajlada): FIX THIS
|
||||
QObject::connect(&settings::Settings::getInstance().showMessageLength,
|
||||
&settings::BoolSetting::valueChanged, this,
|
||||
&ChatWidgetInput::setMessageLengthVisisble);
|
||||
*/
|
||||
}
|
||||
|
||||
ChatWidgetInput::~ChatWidgetInput()
|
||||
{
|
||||
/* XXX(pajlada): FIX THIS
|
||||
QObject::disconnect(
|
||||
&settings::Settings::getInstance().getShowMessageLength(),
|
||||
&settings::BoolSetting::valueChanged, this, &ChatWidgetInput::setMessageLengthVisisble);
|
||||
&settings::BoolSetting::valueChanged, this,
|
||||
&ChatWidgetInput::setMessageLengthVisisble);
|
||||
*/
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -24,24 +24,28 @@ NotebookTab::NotebookTab(Notebook *notebook)
|
||||
this->calcSize();
|
||||
this->setAcceptDrops(true);
|
||||
|
||||
/* XXX(pajlada): Fix this
|
||||
QObject::connect(&settings::Settings::getInstance().getHideTabX(),
|
||||
&settings::BoolSetting::valueChanged, this,
|
||||
&NotebookTab::hideTabXChanged);
|
||||
*/
|
||||
|
||||
this->setMouseTracking(true);
|
||||
}
|
||||
|
||||
NotebookTab::~NotebookTab()
|
||||
{
|
||||
/* XXX(pajlada): Fix this
|
||||
QObject::disconnect(&settings::Settings::getInstance().getHideTabX(),
|
||||
&settings::BoolSetting::valueChanged, this,
|
||||
&NotebookTab::hideTabXChanged);
|
||||
*/
|
||||
}
|
||||
|
||||
void
|
||||
NotebookTab::calcSize()
|
||||
{
|
||||
if (settings::Settings::getInstance().getHideTabX().get()) {
|
||||
if (settings::Settings::getInstance().hideTabX.get()) {
|
||||
this->resize(this->fontMetrics().width(this->text) + 8, 24);
|
||||
} else {
|
||||
this->resize(this->fontMetrics().width(this->text) + 8 + 24, 24);
|
||||
@@ -101,13 +105,12 @@ NotebookTab::paintEvent(QPaintEvent *)
|
||||
|
||||
QRect rect(
|
||||
0, 0,
|
||||
width() -
|
||||
(settings::Settings::getInstance().getHideTabX().get() ? 0 : 16),
|
||||
width() - (settings::Settings::getInstance().hideTabX.get() ? 0 : 16),
|
||||
height());
|
||||
|
||||
painter.drawText(rect, this->text, QTextOption(Qt::AlignCenter));
|
||||
|
||||
if (!settings::Settings::getInstance().getHideTabX().get() &&
|
||||
if (!settings::Settings::getInstance().hideTabX.get() &&
|
||||
(this->mouseOver || this->selected)) {
|
||||
if (this->mouseOverX) {
|
||||
painter.fillRect(this->getXRect(), QColor(0, 0, 0, 64));
|
||||
|
||||
+38
-36
@@ -82,17 +82,16 @@ SettingsDialog::addTabs()
|
||||
auto group = new QGroupBox("Messages");
|
||||
|
||||
auto v = new QVBoxLayout();
|
||||
v->addWidget(
|
||||
createCheckbox("Show timestamp", settings.getShowTimestamps()));
|
||||
v->addWidget(createCheckbox("Show timestamp", settings.showTimestamps));
|
||||
v->addWidget(createCheckbox("Show seconds in timestamp",
|
||||
settings.getShowTimestampSeconds()));
|
||||
settings.showTimestampSeconds));
|
||||
v->addWidget(createCheckbox(
|
||||
"Allow sending duplicate messages (add a space at the end)",
|
||||
settings.getAllowDouplicateMessages()));
|
||||
v->addWidget(createCheckbox("Seperate messages",
|
||||
settings.getSeperateMessages()));
|
||||
v->addWidget(createCheckbox("Show message length",
|
||||
settings.getShowMessageLength()));
|
||||
settings.allowDouplicateMessages));
|
||||
v->addWidget(
|
||||
createCheckbox("Seperate messages", settings.seperateMessages));
|
||||
v->addWidget(
|
||||
createCheckbox("Show message length", settings.showMessageLength));
|
||||
|
||||
group->setLayout(v);
|
||||
|
||||
@@ -106,15 +105,15 @@ SettingsDialog::addTabs()
|
||||
// Behaviour
|
||||
vbox = new QVBoxLayout();
|
||||
|
||||
vbox->addWidget(createCheckbox("Hide input box if empty",
|
||||
settings.getHideEmptyInput()));
|
||||
vbox->addWidget(
|
||||
createCheckbox("Hide input box if empty", settings.hideEmptyInput));
|
||||
vbox->addWidget(
|
||||
createCheckbox("Mention users with a @ (except in commands)",
|
||||
settings.getMentionUsersWithAt()));
|
||||
settings.mentionUsersWithAt));
|
||||
vbox->addWidget(
|
||||
createCheckbox("Window always on top", settings.getWindowTopMost()));
|
||||
createCheckbox("Window always on top", settings.windowTopMost));
|
||||
vbox->addWidget(createCheckbox("Show last read message indicator",
|
||||
settings.getShowLastMessageIndicator()));
|
||||
settings.showLastMessageIndicator));
|
||||
|
||||
{
|
||||
auto v = new QVBoxLayout();
|
||||
@@ -142,19 +141,17 @@ SettingsDialog::addTabs()
|
||||
// Emotes
|
||||
vbox = new QVBoxLayout();
|
||||
|
||||
vbox->addWidget(createCheckbox("Enable Twitch Emotes",
|
||||
settings.getEnableTwitchEmotes()));
|
||||
vbox->addWidget(createCheckbox("Enable BetterTTV Emotes",
|
||||
settings.getEnableBttvEmotes()));
|
||||
vbox->addWidget(createCheckbox("Enable FrankerFaceZ Emotes",
|
||||
settings.getEnableFfzEmotes()));
|
||||
vbox->addWidget(
|
||||
createCheckbox("Enable Gif Emotes", settings.getEnableGifs()));
|
||||
createCheckbox("Enable Twitch Emotes", settings.enableTwitchEmotes));
|
||||
vbox->addWidget(
|
||||
createCheckbox("Enable Emojis", settings.getEnableEmojis()));
|
||||
createCheckbox("Enable BetterTTV Emotes", settings.enableBttvEmotes));
|
||||
vbox->addWidget(
|
||||
createCheckbox("Enable FrankerFaceZ Emotes", settings.enableFfzEmotes));
|
||||
vbox->addWidget(createCheckbox("Enable Gif Emotes", settings.enableGifs));
|
||||
vbox->addWidget(createCheckbox("Enable Emojis", settings.enableEmojis));
|
||||
|
||||
vbox->addWidget(createCheckbox("Enable Twitch Emotes",
|
||||
settings.getEnableTwitchEmotes()));
|
||||
vbox->addWidget(
|
||||
createCheckbox("Enable Twitch Emotes", settings.enableTwitchEmotes));
|
||||
|
||||
vbox->addStretch(1);
|
||||
addTab(vbox, "Emotes", ":/images/Emoji_Color_1F60A_19.png");
|
||||
@@ -189,18 +186,6 @@ SettingsDialog::addTabs()
|
||||
tabs.addStretch(1);
|
||||
}
|
||||
|
||||
QCheckBox *
|
||||
SettingsDialog::createCheckbox(const QString &title,
|
||||
settings::BoolSetting &setting)
|
||||
{
|
||||
auto checkbox = new QCheckBox(title);
|
||||
|
||||
QObject::connect(checkbox, &QCheckBox::toggled, this,
|
||||
[&setting, this](bool state) { setting.set(state); });
|
||||
|
||||
return checkbox;
|
||||
}
|
||||
|
||||
void
|
||||
SettingsDialog::addTab(QLayout *layout, QString title, QString imageRes)
|
||||
{
|
||||
@@ -238,5 +223,22 @@ SettingsDialog::select(SettingsDialogTab *tab)
|
||||
"border-right: none;");
|
||||
selectedTab = tab;
|
||||
}
|
||||
|
||||
/// Widget creation helpers
|
||||
QCheckBox *
|
||||
SettingsDialog::createCheckbox(const QString &title,
|
||||
settings::Setting<bool> &setting)
|
||||
{
|
||||
auto checkbox = new QCheckBox(title);
|
||||
|
||||
// Set checkbox initial state
|
||||
checkbox->setChecked(setting.get());
|
||||
|
||||
QObject::connect(checkbox, &QCheckBox::toggled, this,
|
||||
[&setting, this](bool state) { setting.set(state); });
|
||||
|
||||
return checkbox;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace widgets
|
||||
} // namespace chatterino
|
||||
|
||||
@@ -40,10 +40,12 @@ private:
|
||||
|
||||
SettingsDialogTab *selectedTab = NULL;
|
||||
|
||||
/// Widget creation helpers
|
||||
QCheckBox *createCheckbox(const QString &title,
|
||||
settings::BoolSetting &setting);
|
||||
settings::Setting<bool> &setting);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace widgets
|
||||
} // namespace chatterino
|
||||
|
||||
#endif // SETTINGSDIALOG_H
|
||||
|
||||
Reference in New Issue
Block a user