2017-01-23 16:38:06 +01:00
|
|
|
#include "settings.h"
|
2017-01-18 21:30:23 +01:00
|
|
|
|
2017-01-23 09:48:32 +01:00
|
|
|
#include <QDebug>
|
2017-01-20 06:10:28 +01:00
|
|
|
#include <QDir>
|
|
|
|
#include <QStandardPaths>
|
|
|
|
|
2017-01-18 21:30:23 +01:00
|
|
|
namespace chatterino {
|
|
|
|
|
2017-01-22 23:00:35 +01:00
|
|
|
Settings Settings::instance;
|
2017-01-22 12:46:35 +01:00
|
|
|
|
|
|
|
Settings::Settings()
|
|
|
|
: settings(
|
2017-01-24 16:44:54 +01:00
|
|
|
QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) +
|
|
|
|
"/Chatterino/newsettings.ini",
|
2017-01-22 12:46:35 +01:00
|
|
|
QSettings::IniFormat)
|
|
|
|
, portable(false)
|
|
|
|
, wordTypeMask(messages::Word::Default)
|
2017-01-23 09:48:32 +01:00
|
|
|
, theme(this->settingsItems, "theme", "dark")
|
2017-01-24 19:51:57 +01:00
|
|
|
, selectedUser(this->settingsItems, "selectedUser", "")
|
2017-01-23 09:48:32 +01:00
|
|
|
, emoteScale(this->settingsItems, "emoteScale", 1.0)
|
2017-01-26 04:26:40 +01:00
|
|
|
, mouseScrollMultiplier(this->settingsItems, "mouseScrollMultiplier", 1.0)
|
2017-01-23 09:48:32 +01:00
|
|
|
, 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)
|
2017-01-22 12:46:35 +01:00
|
|
|
{
|
2017-01-22 23:00:35 +01:00
|
|
|
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(); });
|
2017-01-22 12:46:35 +01:00
|
|
|
}
|
2017-01-20 06:10:28 +01:00
|
|
|
|
|
|
|
void
|
|
|
|
Settings::save()
|
|
|
|
{
|
2017-01-22 23:00:35 +01:00
|
|
|
for (auto &item : settingsItems) {
|
2017-01-24 19:51:57 +01:00
|
|
|
this->settings.setValue(item.get().getName(), item.get().getVariant());
|
2017-01-20 06:10:28 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Settings::load()
|
2017-01-18 21:30:23 +01:00
|
|
|
{
|
2017-01-22 23:00:35 +01:00
|
|
|
for (auto &item : settingsItems) {
|
2017-01-23 09:48:32 +01:00
|
|
|
qDebug() << "Loading settings for " << item.get().getName();
|
2017-01-24 19:51:57 +01:00
|
|
|
|
|
|
|
item.get().setVariant(this->settings.value(item.get().getName()));
|
2017-01-20 06:10:28 +01:00
|
|
|
}
|
2017-01-18 21:30:23 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2017-01-22 12:46:35 +01:00
|
|
|
Settings::isIgnoredEmote(const QString &)
|
2017-01-18 21:30:23 +01:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2017-01-22 12:46:35 +01:00
|
|
|
|
|
|
|
void
|
2017-01-22 23:00:35 +01:00
|
|
|
Settings::updateWordTypeMask()
|
2017-01-22 12:46:35 +01:00
|
|
|
{
|
|
|
|
using namespace messages;
|
|
|
|
|
|
|
|
uint32_t mask = Word::Text;
|
|
|
|
|
|
|
|
if (showTimestamps.get()) {
|
|
|
|
mask |= showTimestampSeconds.get() ? Word::TimestampWithSeconds
|
|
|
|
: Word::TimestampNoSeconds;
|
|
|
|
}
|
|
|
|
|
|
|
|
mask |= enableTwitchEmotes.get() ? Word::TwitchEmoteImage
|
|
|
|
: Word::TwitchEmoteText;
|
|
|
|
mask |= enableFfzEmotes.get() ? Word::FfzEmoteImage : Word::FfzEmoteText;
|
|
|
|
mask |= enableBttvEmotes.get() ? Word::BttvEmoteImage : Word::BttvEmoteText;
|
|
|
|
mask |= (enableBttvEmotes.get() && enableGifs.get()) ? Word::BttvEmoteImage
|
|
|
|
: Word::BttvEmoteText;
|
|
|
|
mask |= enableEmojis.get() ? Word::EmojiImage : Word::EmojiText;
|
|
|
|
|
|
|
|
mask |= Word::BitsAmount;
|
|
|
|
mask |= enableGifs.get() ? Word::BitsAnimated : Word::BitsStatic;
|
|
|
|
|
|
|
|
mask |= Word::Badges;
|
|
|
|
mask |= Word::Username;
|
|
|
|
|
|
|
|
Word::Type _mask = (Word::Type)mask;
|
|
|
|
|
|
|
|
// if (mask != _mask) {
|
|
|
|
wordTypeMask = _mask;
|
|
|
|
|
|
|
|
emit wordTypeMaskChanged();
|
|
|
|
// }
|
|
|
|
}
|
2017-01-22 23:00:35 +01:00
|
|
|
|
|
|
|
} // namespace chatterino
|