Merge branch 'master' of https://github.com/fourtf/chatterino2
This commit is contained in:
@@ -8,6 +8,12 @@ template <typename Type>
|
||||
class ChatterinoSetting : public pajlada::Settings::Setting<Type>
|
||||
{
|
||||
public:
|
||||
ChatterinoSetting(const std::string &_path)
|
||||
: pajlada::Settings::Setting<Type>(_path)
|
||||
{
|
||||
_registerSetting(this->data);
|
||||
}
|
||||
|
||||
ChatterinoSetting(const std::string &_path, const Type &_defaultValue)
|
||||
: pajlada::Settings::Setting<Type>(_path, _defaultValue)
|
||||
{
|
||||
|
||||
@@ -200,14 +200,19 @@ void IrcManager::disconnect()
|
||||
|
||||
void IrcManager::sendMessage(const QString &channelName, QString message)
|
||||
{
|
||||
QString trimmedMessage = message.trimmed();
|
||||
if (trimmedMessage.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
this->connectionMutex.lock();
|
||||
static int i = 0;
|
||||
|
||||
if (this->writeConnection) {
|
||||
if (singletons::SettingManager::getInstance().allowDuplicateMessages && (++i % 2) == 0) {
|
||||
message.append(this->messageSuffix);
|
||||
trimmedMessage.append(this->messageSuffix);
|
||||
}
|
||||
this->writeConnection->sendRaw("PRIVMSG #" + channelName + " :" + message);
|
||||
this->writeConnection->sendRaw("PRIVMSG #" + channelName + " :" + trimmedMessage);
|
||||
}
|
||||
|
||||
this->connectionMutex.unlock();
|
||||
@@ -399,5 +404,5 @@ Communi::IrcConnection *IrcManager::getReadConnection()
|
||||
return this->readConnection.get();
|
||||
}
|
||||
|
||||
} // namespace singletons
|
||||
} // namespace chatterino
|
||||
}
|
||||
|
||||
@@ -18,15 +18,7 @@ void _registerSetting(std::weak_ptr<pajlada::Settings::ISettingData> setting)
|
||||
}
|
||||
|
||||
SettingManager::SettingManager()
|
||||
: streamlinkPath("/behaviour/streamlink/path", "")
|
||||
, preferredQuality("/behaviour/streamlink/quality", "Choose")
|
||||
, emoteScale(this->settingsItems, "emoteScale", 1.0)
|
||||
, pathHighlightSound(this->settingsItems, "pathHighlightSound", "qrc:/sounds/ping2.wav")
|
||||
, highlightProperties(this->settingsItems, "highlightProperties",
|
||||
QMap<QString, QPair<bool, bool>>())
|
||||
, highlightUserBlacklist(this->settingsItems, "highlightUserBlacklist", "")
|
||||
, snapshot(nullptr)
|
||||
, settings(Path::getAppdataPath() + "settings.ini", QSettings::IniFormat)
|
||||
: snapshot(nullptr)
|
||||
{
|
||||
this->wordMaskListener.addSetting(this->showTimestamps);
|
||||
this->wordMaskListener.addSetting(this->showTimestampSeconds);
|
||||
@@ -40,49 +32,6 @@ SettingManager::SettingManager()
|
||||
};
|
||||
}
|
||||
|
||||
void SettingManager::save()
|
||||
{
|
||||
for (auto &item : this->settingsItems) {
|
||||
if (item.get().getName() != "highlightProperties") {
|
||||
this->settings.setValue(item.get().getName(), item.get().getVariant());
|
||||
} else {
|
||||
this->settings.beginGroup("Highlights");
|
||||
QStringList list = highlightProperties.get().keys();
|
||||
list.removeAll("");
|
||||
this->settings.remove("");
|
||||
for (auto string : list) {
|
||||
this->settings.beginGroup(string);
|
||||
this->settings.setValue("highlightSound",
|
||||
highlightProperties.get().value(string).first);
|
||||
this->settings.setValue("highlightTask",
|
||||
highlightProperties.get().value(string).second);
|
||||
this->settings.endGroup();
|
||||
}
|
||||
this->settings.endGroup();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SettingManager::load()
|
||||
{
|
||||
for (auto &item : this->settingsItems) {
|
||||
if (item.get().getName() != "highlightProperties") {
|
||||
item.get().setVariant(this->settings.value(item.get().getName()));
|
||||
} else {
|
||||
this->settings.beginGroup("Highlights");
|
||||
QStringList list = this->settings.childGroups();
|
||||
for (auto string : list) {
|
||||
this->settings.beginGroup(string);
|
||||
highlightProperties.insertMap(string,
|
||||
this->settings.value("highlightSound").toBool(),
|
||||
this->settings.value("highlightTask").toBool());
|
||||
this->settings.endGroup();
|
||||
}
|
||||
this->settings.endGroup();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Word::Flags SettingManager::getWordTypeMask()
|
||||
{
|
||||
return this->wordTypeMask;
|
||||
@@ -93,9 +42,10 @@ bool SettingManager::isIgnoredEmote(const QString &)
|
||||
return false;
|
||||
}
|
||||
|
||||
QSettings &SettingManager::getQSettings()
|
||||
void SettingManager::load()
|
||||
{
|
||||
return this->settings;
|
||||
// Just to make sure the singleton is initialized
|
||||
debug::Log(".");
|
||||
}
|
||||
|
||||
void SettingManager::updateWordTypeMask()
|
||||
@@ -184,5 +134,5 @@ void SettingManager::recallSnapshot()
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace singletons
|
||||
} // namespace chatterino
|
||||
}
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include "messages/highlightphrase.hpp"
|
||||
#include "messages/word.hpp"
|
||||
#include "setting.hpp"
|
||||
#include "singletons/helper/chatterinosetting.hpp"
|
||||
|
||||
#include <QSettings>
|
||||
#include <pajlada/settings/setting.hpp>
|
||||
#include <pajlada/settings/settinglistener.hpp>
|
||||
|
||||
@@ -19,14 +18,14 @@ class SettingManager : public QObject
|
||||
|
||||
using BoolSetting = ChatterinoSetting<bool>;
|
||||
using FloatSetting = ChatterinoSetting<float>;
|
||||
using StringSetting = ChatterinoSetting<std::string>;
|
||||
using QStringSetting = ChatterinoSetting<QString>;
|
||||
|
||||
public:
|
||||
void load();
|
||||
void save();
|
||||
|
||||
messages::Word::Flags getWordTypeMask();
|
||||
bool isIgnoredEmote(const QString &emote);
|
||||
QSettings &getQSettings();
|
||||
|
||||
void load();
|
||||
|
||||
/// Appearance
|
||||
BoolSetting showTimestamps = {"/appearance/messages/showTimestamps", true};
|
||||
@@ -47,6 +46,8 @@ public:
|
||||
BoolSetting allowDuplicateMessages = {"/behaviour/allowDuplicateMessages", true};
|
||||
BoolSetting mentionUsersWithAt = {"/behaviour/mentionUsersWithAt", false};
|
||||
FloatSetting mouseScrollMultiplier = {"/behaviour/mouseScrollMultiplier", 1.0};
|
||||
StringSetting streamlinkPath = {"/behaviour/streamlink/path", ""};
|
||||
StringSetting preferredQuality = {"/behaviour/streamlink/quality", "Choose"};
|
||||
|
||||
/// Commands
|
||||
BoolSetting allowCommandsAtEnd = {"/commands/allowCommandsAtEnd", false};
|
||||
@@ -58,6 +59,7 @@ public:
|
||||
BoolSetting enableFfzEmotes = {"/emotes/enableFFZEmotes", true};
|
||||
BoolSetting enableEmojis = {"/emotes/enableEmojis", true};
|
||||
BoolSetting enableGifAnimations = {"/emotes/enableGifAnimations", true};
|
||||
FloatSetting emoteScale = {"/emotes/scale", 1.f};
|
||||
|
||||
/// Links
|
||||
BoolSetting linksDoubleClickOnly = {"/links/doubleClickToOpen", false};
|
||||
@@ -69,14 +71,12 @@ public:
|
||||
BoolSetting enableHighlightTaskbar = {"/highlighting/enableTaskbarFlashing", true};
|
||||
BoolSetting customHighlightSound = {"/highlighting/useCustomSound", false};
|
||||
|
||||
pajlada::Settings::Setting<std::string> streamlinkPath;
|
||||
pajlada::Settings::Setting<std::string> preferredQuality;
|
||||
ChatterinoSetting<std::vector<messages::HighlightPhrase>> highlightProperties = {
|
||||
"/highlighting/highlights"};
|
||||
|
||||
Setting<float> emoteScale;
|
||||
|
||||
Setting<QString> pathHighlightSound;
|
||||
Setting<QMap<QString, QPair<bool, bool>>> highlightProperties;
|
||||
Setting<QString> highlightUserBlacklist;
|
||||
QStringSetting pathHighlightSound = {"/highlighting/highlightSoundPath",
|
||||
"qrc:/sounds/ping2.wav"};
|
||||
QStringSetting highlightUserBlacklist = {"/highlighting/blacklistedUsers", ""};
|
||||
|
||||
BoolSetting highlightAlwaysPlaySound = {"/highlighting/alwaysPlaySound", false};
|
||||
|
||||
@@ -100,12 +100,10 @@ private:
|
||||
|
||||
SettingManager();
|
||||
|
||||
QSettings settings;
|
||||
std::vector<std::reference_wrapper<BaseSetting>> settingsItems;
|
||||
messages::Word::Flags wordTypeMask = messages::Word::Default;
|
||||
|
||||
pajlada::Settings::SettingListener wordMaskListener;
|
||||
};
|
||||
|
||||
} // namespace singletons
|
||||
} // namespace chatterino
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user