Update to latest settings library version
This commit is contained in:
@@ -24,3 +24,6 @@
|
|||||||
path = lib/WinToast
|
path = lib/WinToast
|
||||||
url = https://github.com/mohabouje/WinToast.git
|
url = https://github.com/mohabouje/WinToast.git
|
||||||
|
|
||||||
|
[submodule "lib/serialize"]
|
||||||
|
path = lib/serialize
|
||||||
|
url = https://github.com/pajlada/serialize.git
|
||||||
|
|||||||
+4
-1
@@ -9,7 +9,7 @@ message(----)
|
|||||||
QT += widgets core gui network multimedia svg concurrent
|
QT += widgets core gui network multimedia svg concurrent
|
||||||
CONFIG += communi
|
CONFIG += communi
|
||||||
COMMUNI += core model util
|
COMMUNI += core model util
|
||||||
CONFIG += c++14
|
CONFIG += c++17
|
||||||
INCLUDEPATH += src/
|
INCLUDEPATH += src/
|
||||||
TARGET = chatterino
|
TARGET = chatterino
|
||||||
TEMPLATE = app
|
TEMPLATE = app
|
||||||
@@ -17,6 +17,8 @@ DEFINES += QT_DEPRECATED_WARNINGS
|
|||||||
PRECOMPILED_HEADER = src/PrecompiledHeader.hpp
|
PRECOMPILED_HEADER = src/PrecompiledHeader.hpp
|
||||||
CONFIG += precompile_header
|
CONFIG += precompile_header
|
||||||
|
|
||||||
|
QMAKE_CXXFLAGS += -std=c++17
|
||||||
|
|
||||||
debug {
|
debug {
|
||||||
DEFINES += QT_DEBUG
|
DEFINES += QT_DEBUG
|
||||||
}
|
}
|
||||||
@@ -43,6 +45,7 @@ macx {
|
|||||||
|
|
||||||
# Submodules
|
# Submodules
|
||||||
include(dependencies/rapidjson.pri)
|
include(dependencies/rapidjson.pri)
|
||||||
|
include(dependencies/serialize.pri)
|
||||||
include(dependencies/settings.pri)
|
include(dependencies/settings.pri)
|
||||||
include(dependencies/signals.pri)
|
include(dependencies/signals.pri)
|
||||||
include(dependencies/humanize.pri)
|
include(dependencies/humanize.pri)
|
||||||
|
|||||||
Vendored
+1
-1
@@ -17,5 +17,5 @@ win32 {
|
|||||||
|
|
||||||
LIBS += -L$$BOOST_DIRECTORY\\$$BOOST_LIB_SUFFIX
|
LIBS += -L$$BOOST_DIRECTORY\\$$BOOST_LIB_SUFFIX
|
||||||
} else {
|
} else {
|
||||||
LIBS += -lboost_system
|
LIBS += -lboost_system -lboost_filesystem
|
||||||
}
|
}
|
||||||
|
|||||||
Vendored
+2
@@ -0,0 +1,2 @@
|
|||||||
|
# serialize
|
||||||
|
INCLUDEPATH += $$PWD/../lib/serialize/include/
|
||||||
Vendored
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
# settings
|
# settings
|
||||||
DEFINES += PAJLADA_SETTINGS_NO_BOOST
|
DEFINES += PAJLADA_SETTINGS_BOOST_FILESYSTEM
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
$$PWD/../lib/settings/src/settings/settingdata.cpp \
|
$$PWD/../lib/settings/src/settings/settingdata.cpp \
|
||||||
|
|||||||
Submodule
+1
Submodule lib/serialize added at 8df89adc10
+1
-1
Submodule lib/settings updated: bcbd29b793...f564560afc
+1
-1
Submodule lib/signals updated: a1b61606c1...0fde0171d6
@@ -138,7 +138,7 @@
|
|||||||
# include <map>
|
# include <map>
|
||||||
# include <memory>
|
# include <memory>
|
||||||
# include <mutex>
|
# include <mutex>
|
||||||
# include <pajlada/settings/serialize.hpp>
|
# include <pajlada/serialize.hpp>
|
||||||
# include <pajlada/settings/setting.hpp>
|
# include <pajlada/settings/setting.hpp>
|
||||||
# include <pajlada/settings/settinglistener.hpp>
|
# include <pajlada/settings/settinglistener.hpp>
|
||||||
# include <pajlada/signals/connection.hpp>
|
# include <pajlada/signals/connection.hpp>
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
||||||
void _registerSetting(std::weak_ptr<pajlada::Settings::ISettingData> setting)
|
void _registerSetting(std::weak_ptr<pajlada::Settings::SettingData> setting)
|
||||||
{
|
{
|
||||||
_actuallyRegisterSetting(setting);
|
_actuallyRegisterSetting(setting);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
||||||
void _registerSetting(std::weak_ptr<pajlada::Settings::ISettingData> setting);
|
void _registerSetting(std::weak_ptr<pajlada::Settings::SettingData> setting);
|
||||||
|
|
||||||
template <typename Type>
|
template <typename Type>
|
||||||
class ChatterinoSetting : public pajlada::Settings::Setting<Type>
|
class ChatterinoSetting : public pajlada::Settings::Setting<Type>
|
||||||
@@ -14,13 +14,13 @@ public:
|
|||||||
ChatterinoSetting(const std::string &path)
|
ChatterinoSetting(const std::string &path)
|
||||||
: pajlada::Settings::Setting<Type>(path)
|
: pajlada::Settings::Setting<Type>(path)
|
||||||
{
|
{
|
||||||
_registerSetting(this->data);
|
_registerSetting(this->getData());
|
||||||
}
|
}
|
||||||
|
|
||||||
ChatterinoSetting(const std::string &path, const Type &defaultValue)
|
ChatterinoSetting(const std::string &path, const Type &defaultValue)
|
||||||
: pajlada::Settings::Setting<Type>(path, defaultValue)
|
: pajlada::Settings::Setting<Type>(path, defaultValue)
|
||||||
{
|
{
|
||||||
_registerSetting(this->data);
|
_registerSetting(this->getData());
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T2>
|
template <typename T2>
|
||||||
@@ -46,6 +46,7 @@ public:
|
|||||||
|
|
||||||
using BoolSetting = ChatterinoSetting<bool>;
|
using BoolSetting = ChatterinoSetting<bool>;
|
||||||
using FloatSetting = ChatterinoSetting<float>;
|
using FloatSetting = ChatterinoSetting<float>;
|
||||||
|
using DoubleSetting = ChatterinoSetting<double>;
|
||||||
using IntSetting = ChatterinoSetting<int>;
|
using IntSetting = ChatterinoSetting<int>;
|
||||||
using StringSetting = ChatterinoSetting<std::string>;
|
using StringSetting = ChatterinoSetting<std::string>;
|
||||||
using QStringSetting = ChatterinoSetting<QString>;
|
using QStringSetting = ChatterinoSetting<QString>;
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
#include <QRegularExpression>
|
#include <QRegularExpression>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <pajlada/settings/serialize.hpp>
|
#include <pajlada/serialize.hpp>
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
@@ -68,42 +68,38 @@ private:
|
|||||||
} // namespace chatterino
|
} // namespace chatterino
|
||||||
|
|
||||||
namespace pajlada {
|
namespace pajlada {
|
||||||
namespace Settings {
|
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
struct Serialize<chatterino::HighlightBlacklistUser> {
|
struct Serialize<chatterino::HighlightBlacklistUser> {
|
||||||
static rapidjson::Value get(
|
static rapidjson::Value get(const chatterino::HighlightBlacklistUser &value,
|
||||||
const chatterino::HighlightBlacklistUser &value,
|
rapidjson::Document::AllocatorType &a)
|
||||||
rapidjson::Document::AllocatorType &a)
|
{
|
||||||
|
rapidjson::Value ret(rapidjson::kObjectType);
|
||||||
|
|
||||||
|
chatterino::rj::set(ret, "pattern", value.getPattern(), a);
|
||||||
|
chatterino::rj::set(ret, "regex", value.isRegex(), a);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct Deserialize<chatterino::HighlightBlacklistUser> {
|
||||||
|
static chatterino::HighlightBlacklistUser get(const rapidjson::Value &value)
|
||||||
|
{
|
||||||
|
QString pattern;
|
||||||
|
bool isRegex = false;
|
||||||
|
|
||||||
|
if (!value.IsObject())
|
||||||
{
|
{
|
||||||
rapidjson::Value ret(rapidjson::kObjectType);
|
|
||||||
|
|
||||||
AddMember(ret, "pattern", value.getPattern(), a);
|
|
||||||
AddMember(ret, "regex", value.isRegex(), a);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template <>
|
|
||||||
struct Deserialize<chatterino::HighlightBlacklistUser> {
|
|
||||||
static chatterino::HighlightBlacklistUser get(
|
|
||||||
const rapidjson::Value &value)
|
|
||||||
{
|
|
||||||
QString pattern;
|
|
||||||
bool isRegex = false;
|
|
||||||
|
|
||||||
if (!value.IsObject())
|
|
||||||
{
|
|
||||||
return chatterino::HighlightBlacklistUser(pattern, isRegex);
|
|
||||||
}
|
|
||||||
|
|
||||||
chatterino::rj::getSafe(value, "pattern", pattern);
|
|
||||||
chatterino::rj::getSafe(value, "regex", isRegex);
|
|
||||||
|
|
||||||
return chatterino::HighlightBlacklistUser(pattern, isRegex);
|
return chatterino::HighlightBlacklistUser(pattern, isRegex);
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace Settings
|
chatterino::rj::getSafe(value, "pattern", pattern);
|
||||||
|
chatterino::rj::getSafe(value, "regex", isRegex);
|
||||||
|
|
||||||
|
return chatterino::HighlightBlacklistUser(pattern, isRegex);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
} // namespace pajlada
|
} // namespace pajlada
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
#include <QRegularExpression>
|
#include <QRegularExpression>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <pajlada/settings/serialize.hpp>
|
#include <pajlada/serialize.hpp>
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
||||||
@@ -70,48 +70,44 @@ private:
|
|||||||
} // namespace chatterino
|
} // namespace chatterino
|
||||||
|
|
||||||
namespace pajlada {
|
namespace pajlada {
|
||||||
namespace Settings {
|
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
struct Serialize<chatterino::HighlightPhrase> {
|
struct Serialize<chatterino::HighlightPhrase> {
|
||||||
static rapidjson::Value get(const chatterino::HighlightPhrase &value,
|
static rapidjson::Value get(const chatterino::HighlightPhrase &value,
|
||||||
rapidjson::Document::AllocatorType &a)
|
rapidjson::Document::AllocatorType &a)
|
||||||
|
{
|
||||||
|
rapidjson::Value ret(rapidjson::kObjectType);
|
||||||
|
|
||||||
|
chatterino::rj::set(ret, "pattern", value.getPattern(), a);
|
||||||
|
chatterino::rj::set(ret, "alert", value.getAlert(), a);
|
||||||
|
chatterino::rj::set(ret, "sound", value.getSound(), a);
|
||||||
|
chatterino::rj::set(ret, "regex", value.isRegex(), a);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct Deserialize<chatterino::HighlightPhrase> {
|
||||||
|
static chatterino::HighlightPhrase get(const rapidjson::Value &value)
|
||||||
|
{
|
||||||
|
if (!value.IsObject())
|
||||||
{
|
{
|
||||||
rapidjson::Value ret(rapidjson::kObjectType);
|
return chatterino::HighlightPhrase(QString(), true, false, false);
|
||||||
|
|
||||||
AddMember(ret, "pattern", value.getPattern(), a);
|
|
||||||
AddMember(ret, "alert", value.getAlert(), a);
|
|
||||||
AddMember(ret, "sound", value.getSound(), a);
|
|
||||||
AddMember(ret, "regex", value.isRegex(), a);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
template <>
|
QString _pattern;
|
||||||
struct Deserialize<chatterino::HighlightPhrase> {
|
bool _alert = true;
|
||||||
static chatterino::HighlightPhrase get(const rapidjson::Value &value)
|
bool _sound = false;
|
||||||
{
|
bool _isRegex = false;
|
||||||
if (!value.IsObject())
|
|
||||||
{
|
|
||||||
return chatterino::HighlightPhrase(QString(), true, false,
|
|
||||||
false);
|
|
||||||
}
|
|
||||||
|
|
||||||
QString _pattern;
|
chatterino::rj::getSafe(value, "pattern", _pattern);
|
||||||
bool _alert = true;
|
chatterino::rj::getSafe(value, "alert", _alert);
|
||||||
bool _sound = false;
|
chatterino::rj::getSafe(value, "sound", _sound);
|
||||||
bool _isRegex = false;
|
chatterino::rj::getSafe(value, "regex", _isRegex);
|
||||||
|
|
||||||
chatterino::rj::getSafe(value, "pattern", _pattern);
|
return chatterino::HighlightPhrase(_pattern, _alert, _sound, _isRegex);
|
||||||
chatterino::rj::getSafe(value, "alert", _alert);
|
}
|
||||||
chatterino::rj::getSafe(value, "sound", _sound);
|
};
|
||||||
chatterino::rj::getSafe(value, "regex", _isRegex);
|
|
||||||
|
|
||||||
return chatterino::HighlightPhrase(_pattern, _alert, _sound,
|
|
||||||
_isRegex);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace Settings
|
|
||||||
} // namespace pajlada
|
} // namespace pajlada
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
#include <QRegularExpression>
|
#include <QRegularExpression>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <pajlada/settings/serialize.hpp>
|
#include <pajlada/serialize.hpp>
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
@@ -138,53 +138,51 @@ private:
|
|||||||
} // namespace chatterino
|
} // namespace chatterino
|
||||||
|
|
||||||
namespace pajlada {
|
namespace pajlada {
|
||||||
namespace Settings {
|
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
struct Serialize<chatterino::IgnorePhrase> {
|
struct Serialize<chatterino::IgnorePhrase> {
|
||||||
static rapidjson::Value get(const chatterino::IgnorePhrase &value,
|
static rapidjson::Value get(const chatterino::IgnorePhrase &value,
|
||||||
rapidjson::Document::AllocatorType &a)
|
rapidjson::Document::AllocatorType &a)
|
||||||
|
{
|
||||||
|
rapidjson::Value ret(rapidjson::kObjectType);
|
||||||
|
|
||||||
|
chatterino::rj::set(ret, "pattern", value.getPattern(), a);
|
||||||
|
chatterino::rj::set(ret, "regex", value.isRegex(), a);
|
||||||
|
chatterino::rj::set(ret, "isBlock", value.isBlock(), a);
|
||||||
|
chatterino::rj::set(ret, "replaceWith", value.getReplace(), a);
|
||||||
|
chatterino::rj::set(ret, "caseSensitive", value.isCaseSensitive(), a);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct Deserialize<chatterino::IgnorePhrase> {
|
||||||
|
static chatterino::IgnorePhrase get(const rapidjson::Value &value)
|
||||||
|
{
|
||||||
|
if (!value.IsObject())
|
||||||
{
|
{
|
||||||
rapidjson::Value ret(rapidjson::kObjectType);
|
return chatterino::IgnorePhrase(
|
||||||
|
QString(), false, false,
|
||||||
AddMember(ret, "pattern", value.getPattern(), a);
|
::chatterino::getSettings()->ignoredPhraseReplace.getValue(),
|
||||||
AddMember(ret, "regex", value.isRegex(), a);
|
true);
|
||||||
AddMember(ret, "isBlock", value.isBlock(), a);
|
|
||||||
AddMember(ret, "replaceWith", value.getReplace(), a);
|
|
||||||
AddMember(ret, "caseSensitive", value.isCaseSensitive(), a);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
template <>
|
QString _pattern;
|
||||||
struct Deserialize<chatterino::IgnorePhrase> {
|
bool _isRegex = false;
|
||||||
static chatterino::IgnorePhrase get(const rapidjson::Value &value)
|
bool _isBlock = false;
|
||||||
{
|
QString _replace;
|
||||||
if (!value.IsObject())
|
bool _caseSens = true;
|
||||||
{
|
|
||||||
return chatterino::IgnorePhrase(
|
|
||||||
QString(), false, false,
|
|
||||||
::chatterino::getSettings()
|
|
||||||
->ignoredPhraseReplace.getValue(),
|
|
||||||
true);
|
|
||||||
}
|
|
||||||
|
|
||||||
QString _pattern;
|
chatterino::rj::getSafe(value, "pattern", _pattern);
|
||||||
bool _isRegex = false;
|
chatterino::rj::getSafe(value, "regex", _isRegex);
|
||||||
bool _isBlock = false;
|
chatterino::rj::getSafe(value, "isBlock", _isBlock);
|
||||||
QString _replace;
|
chatterino::rj::getSafe(value, "replaceWith", _replace);
|
||||||
bool _caseSens = true;
|
chatterino::rj::getSafe(value, "caseSensitive", _caseSens);
|
||||||
|
|
||||||
chatterino::rj::getSafe(value, "pattern", _pattern);
|
return chatterino::IgnorePhrase(_pattern, _isRegex, _isBlock, _replace,
|
||||||
chatterino::rj::getSafe(value, "regex", _isRegex);
|
_caseSens);
|
||||||
chatterino::rj::getSafe(value, "isBlock", _isBlock);
|
}
|
||||||
chatterino::rj::getSafe(value, "replaceWith", _replace);
|
};
|
||||||
chatterino::rj::getSafe(value, "caseSensitive", _caseSens);
|
|
||||||
|
|
||||||
return chatterino::IgnorePhrase(_pattern, _isRegex, _isBlock,
|
|
||||||
_replace, _caseSens);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
} // namespace Settings
|
|
||||||
} // namespace pajlada
|
} // namespace pajlada
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <boost/optional.hpp>
|
#include <boost/optional.hpp>
|
||||||
#include <pajlada/settings/serialize.hpp>
|
#include <pajlada/serialize.hpp>
|
||||||
|
|
||||||
#include "util/RapidjsonHelpers.hpp"
|
#include "util/RapidjsonHelpers.hpp"
|
||||||
|
|
||||||
@@ -34,37 +34,35 @@ private:
|
|||||||
} // namespace chatterino
|
} // namespace chatterino
|
||||||
|
|
||||||
namespace pajlada {
|
namespace pajlada {
|
||||||
namespace Settings {
|
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
struct Serialize<chatterino::ModerationAction> {
|
struct Serialize<chatterino::ModerationAction> {
|
||||||
static rapidjson::Value get(const chatterino::ModerationAction &value,
|
static rapidjson::Value get(const chatterino::ModerationAction &value,
|
||||||
rapidjson::Document::AllocatorType &a)
|
rapidjson::Document::AllocatorType &a)
|
||||||
|
{
|
||||||
|
rapidjson::Value ret(rapidjson::kObjectType);
|
||||||
|
|
||||||
|
chatterino::rj::set(ret, "pattern", value.getAction(), a);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct Deserialize<chatterino::ModerationAction> {
|
||||||
|
static chatterino::ModerationAction get(const rapidjson::Value &value)
|
||||||
|
{
|
||||||
|
if (!value.IsObject())
|
||||||
{
|
{
|
||||||
rapidjson::Value ret(rapidjson::kObjectType);
|
return chatterino::ModerationAction(QString());
|
||||||
|
|
||||||
AddMember(ret, "pattern", value.getAction(), a);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
template <>
|
QString pattern;
|
||||||
struct Deserialize<chatterino::ModerationAction> {
|
|
||||||
static chatterino::ModerationAction get(const rapidjson::Value &value)
|
|
||||||
{
|
|
||||||
if (!value.IsObject())
|
|
||||||
{
|
|
||||||
return chatterino::ModerationAction(QString());
|
|
||||||
}
|
|
||||||
|
|
||||||
QString pattern;
|
chatterino::rj::getSafe(value, "pattern", pattern);
|
||||||
|
|
||||||
chatterino::rj::getSafe(value, "pattern", pattern);
|
return chatterino::ModerationAction(pattern);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return chatterino::ModerationAction(pattern);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace Settings
|
|
||||||
} // namespace pajlada
|
} // namespace pajlada
|
||||||
|
|||||||
@@ -242,7 +242,7 @@ void Emojis::loadEmojiSet()
|
|||||||
{
|
{
|
||||||
auto app = getApp();
|
auto app = getApp();
|
||||||
|
|
||||||
getSettings()->emojiSet.connect([=](const auto &emojiSet, auto) {
|
getSettings()->emojiSet.connect([=](const auto &emojiSet) {
|
||||||
this->emojis.each([=](const auto &name,
|
this->emojis.each([=](const auto &name,
|
||||||
std::shared_ptr<EmojiData> &emoji) {
|
std::shared_ptr<EmojiData> &emoji) {
|
||||||
QString emojiSetToUse = emojiSet;
|
QString emojiSetToUse = emojiSet;
|
||||||
|
|||||||
@@ -79,25 +79,25 @@ void TwitchAccountManager::reloadUsers()
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string username = pajlada::Settings::Setting<std::string>::get(
|
auto username = pajlada::Settings::Setting<QString>::get(
|
||||||
"/accounts/" + uid + "/username");
|
"/accounts/" + uid + "/username");
|
||||||
std::string userID = pajlada::Settings::Setting<std::string>::get(
|
auto userID = pajlada::Settings::Setting<QString>::get("/accounts/" +
|
||||||
"/accounts/" + uid + "/userID");
|
uid + "/userID");
|
||||||
std::string clientID = pajlada::Settings::Setting<std::string>::get(
|
auto clientID = pajlada::Settings::Setting<QString>::get(
|
||||||
"/accounts/" + uid + "/clientID");
|
"/accounts/" + uid + "/clientID");
|
||||||
std::string oauthToken = pajlada::Settings::Setting<std::string>::get(
|
auto oauthToken = pajlada::Settings::Setting<QString>::get(
|
||||||
"/accounts/" + uid + "/oauthToken");
|
"/accounts/" + uid + "/oauthToken");
|
||||||
|
|
||||||
if (username.empty() || userID.empty() || clientID.empty() ||
|
if (username.isEmpty() || userID.isEmpty() || clientID.isEmpty() ||
|
||||||
oauthToken.empty())
|
oauthToken.isEmpty())
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
userData.username = qS(username).trimmed();
|
userData.username = username.trimmed();
|
||||||
userData.userID = qS(userID).trimmed();
|
userData.userID = userID.trimmed();
|
||||||
userData.clientID = qS(clientID).trimmed();
|
userData.clientID = clientID.trimmed();
|
||||||
userData.oauthToken = qS(oauthToken).trimmed();
|
userData.oauthToken = oauthToken.trimmed();
|
||||||
|
|
||||||
switch (this->addUser(userData))
|
switch (this->addUser(userData))
|
||||||
{
|
{
|
||||||
@@ -138,8 +138,7 @@ void TwitchAccountManager::load()
|
|||||||
{
|
{
|
||||||
this->reloadUsers();
|
this->reloadUsers();
|
||||||
|
|
||||||
this->currentUsername.connect([this](const auto &newValue, auto) {
|
this->currentUsername.connect([this](const QString &newUsername) {
|
||||||
QString newUsername(QString::fromStdString(newValue));
|
|
||||||
auto user = this->findUserByUsername(newUsername);
|
auto user = this->findUserByUsername(newUsername);
|
||||||
if (user)
|
if (user)
|
||||||
{
|
{
|
||||||
@@ -175,14 +174,14 @@ bool TwitchAccountManager::removeUser(TwitchAccount *account)
|
|||||||
{
|
{
|
||||||
const auto &accs = this->accounts.getVector();
|
const auto &accs = this->accounts.getVector();
|
||||||
|
|
||||||
std::string userID(account->getUserId().toStdString());
|
auto userID(account->getUserId());
|
||||||
if (!userID.empty())
|
if (!userID.isEmpty())
|
||||||
{
|
{
|
||||||
pajlada::Settings::SettingManager::removeSetting("/accounts/uid" +
|
pajlada::Settings::SettingManager::removeSetting(
|
||||||
userID);
|
fS("/accounts/uid{}", userID));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (account->getUserName() == qS(this->currentUsername.getValue()))
|
if (account->getUserName() == this->currentUsername)
|
||||||
{
|
{
|
||||||
// The user that was removed is the current user, log into the anonymous
|
// The user that was removed is the current user, log into the anonymous
|
||||||
// user
|
// user
|
||||||
|
|||||||
@@ -1,11 +1,10 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "common/ChatterinoSetting.hpp"
|
||||||
#include "common/SignalVector.hpp"
|
#include "common/SignalVector.hpp"
|
||||||
#include "providers/twitch/TwitchAccount.hpp"
|
#include "providers/twitch/TwitchAccount.hpp"
|
||||||
#include "util/SharedPtrElementLess.hpp"
|
#include "util/SharedPtrElementLess.hpp"
|
||||||
|
|
||||||
#include <pajlada/settings/setting.hpp>
|
|
||||||
|
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
@@ -47,8 +46,7 @@ public:
|
|||||||
|
|
||||||
bool isLoggedIn() const;
|
bool isLoggedIn() const;
|
||||||
|
|
||||||
pajlada::Settings::Setting<std::string> currentUsername = {
|
QStringSetting currentUsername{"/accounts/current", ""};
|
||||||
"/accounts/current", ""};
|
|
||||||
pajlada::Signals::NoArgSignal currentUserChanged;
|
pajlada::Signals::NoArgSignal currentUserChanged;
|
||||||
pajlada::Signals::NoArgSignal userListUpdated;
|
pajlada::Signals::NoArgSignal userListUpdated;
|
||||||
|
|
||||||
|
|||||||
@@ -470,8 +470,6 @@ void TwitchChannel::refreshLiveStatus()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
log("[TwitchChannel:{}] Refreshing live status", this->getName());
|
|
||||||
|
|
||||||
QString url("https://api.twitch.tv/kraken/streams/" + roomID);
|
QString url("https://api.twitch.tv/kraken/streams/" + roomID);
|
||||||
|
|
||||||
// auto request = makeGetStreamRequest(roomID, QThread::currentThread());
|
// auto request = makeGetStreamRequest(roomID, QThread::currentThread());
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
#include <rapidjson/document.h>
|
#include <rapidjson/document.h>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <pajlada/settings/serialize.hpp>
|
#include <pajlada/serialize.hpp>
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
|
||||||
@@ -32,49 +32,42 @@ struct TwitchUser {
|
|||||||
} // namespace chatterino
|
} // namespace chatterino
|
||||||
|
|
||||||
namespace pajlada {
|
namespace pajlada {
|
||||||
namespace Settings {
|
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
struct Deserialize<chatterino::TwitchUser> {
|
struct Deserialize<chatterino::TwitchUser> {
|
||||||
static chatterino::TwitchUser get(const rapidjson::Value &value,
|
static chatterino::TwitchUser get(const rapidjson::Value &value,
|
||||||
bool *error = nullptr)
|
bool *error = nullptr)
|
||||||
|
{
|
||||||
|
using namespace chatterino;
|
||||||
|
|
||||||
|
TwitchUser user;
|
||||||
|
|
||||||
|
if (!value.IsObject())
|
||||||
{
|
{
|
||||||
using namespace chatterino;
|
PAJLADA_REPORT_ERROR(error)
|
||||||
|
|
||||||
TwitchUser user;
|
|
||||||
|
|
||||||
if (!value.IsObject())
|
|
||||||
{
|
|
||||||
PAJLADA_REPORT_ERROR(error)
|
|
||||||
PAJLADA_THROW_EXCEPTION(
|
|
||||||
"Deserialized rapidjson::Value is wrong type");
|
|
||||||
return user;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!rj::getSafe(value, "_id", user.id))
|
|
||||||
{
|
|
||||||
PAJLADA_REPORT_ERROR(error)
|
|
||||||
PAJLADA_THROW_EXCEPTION("Missing ID key");
|
|
||||||
return user;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!rj::getSafe(value, "name", user.name))
|
|
||||||
{
|
|
||||||
PAJLADA_REPORT_ERROR(error)
|
|
||||||
PAJLADA_THROW_EXCEPTION("Missing name key");
|
|
||||||
return user;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!rj::getSafe(value, "display_name", user.displayName))
|
|
||||||
{
|
|
||||||
PAJLADA_REPORT_ERROR(error)
|
|
||||||
PAJLADA_THROW_EXCEPTION("Missing display name key");
|
|
||||||
return user;
|
|
||||||
}
|
|
||||||
|
|
||||||
return user;
|
return user;
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace Settings
|
if (!rj::getSafe(value, "_id", user.id))
|
||||||
|
{
|
||||||
|
PAJLADA_REPORT_ERROR(error)
|
||||||
|
return user;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!rj::getSafe(value, "name", user.name))
|
||||||
|
{
|
||||||
|
PAJLADA_REPORT_ERROR(error)
|
||||||
|
return user;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!rj::getSafe(value, "display_name", user.displayName))
|
||||||
|
{
|
||||||
|
PAJLADA_REPORT_ERROR(error)
|
||||||
|
return user;
|
||||||
|
}
|
||||||
|
|
||||||
|
return user;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
} // namespace pajlada
|
} // namespace pajlada
|
||||||
|
|||||||
+32
-26
@@ -32,37 +32,43 @@ Fonts::Fonts()
|
|||||||
|
|
||||||
void Fonts::initialize(Settings &, Paths &)
|
void Fonts::initialize(Settings &, Paths &)
|
||||||
{
|
{
|
||||||
this->chatFontFamily.connect([this](const std::string &, auto) {
|
this->chatFontFamily.connect(
|
||||||
assertInGuiThread();
|
[this]() {
|
||||||
|
assertInGuiThread();
|
||||||
|
|
||||||
for (auto &map : this->fontsByType_)
|
for (auto &map : this->fontsByType_)
|
||||||
{
|
{
|
||||||
map.clear();
|
map.clear();
|
||||||
}
|
}
|
||||||
this->fontChanged.invoke();
|
this->fontChanged.invoke();
|
||||||
});
|
},
|
||||||
|
false);
|
||||||
|
|
||||||
this->chatFontSize.connect([this](const int &, auto) {
|
this->chatFontSize.connect(
|
||||||
assertInGuiThread();
|
[this]() {
|
||||||
|
assertInGuiThread();
|
||||||
|
|
||||||
for (auto &map : this->fontsByType_)
|
for (auto &map : this->fontsByType_)
|
||||||
{
|
{
|
||||||
map.clear();
|
map.clear();
|
||||||
}
|
}
|
||||||
this->fontChanged.invoke();
|
this->fontChanged.invoke();
|
||||||
});
|
},
|
||||||
|
false);
|
||||||
|
|
||||||
getSettings()->boldScale.connect([this](const int &, auto) {
|
getSettings()->boldScale.connect(
|
||||||
assertInGuiThread();
|
[this]() {
|
||||||
|
assertInGuiThread();
|
||||||
|
|
||||||
getApp()->windows->incGeneration();
|
getApp()->windows->incGeneration();
|
||||||
|
|
||||||
for (auto &map : this->fontsByType_)
|
for (auto &map : this->fontsByType_)
|
||||||
{
|
{
|
||||||
map.clear();
|
map.clear();
|
||||||
}
|
}
|
||||||
this->fontChanged.invoke();
|
this->fontChanged.invoke();
|
||||||
});
|
},
|
||||||
|
false);
|
||||||
}
|
}
|
||||||
|
|
||||||
QFont Fonts::getFont(FontStyle type, float scale)
|
QFont Fonts::getFont(FontStyle type, float scale)
|
||||||
@@ -118,7 +124,7 @@ Fonts::FontData Fonts::createFontData(FontStyle type, float scale)
|
|||||||
1, false, QFont::Weight(getSettings()->boldScale.getValue())};
|
1, false, QFont::Weight(getSettings()->boldScale.getValue())};
|
||||||
auto data = sizeScale[type];
|
auto data = sizeScale[type];
|
||||||
return FontData(
|
return FontData(
|
||||||
QFont(QString::fromStdString(this->chatFontFamily.getValue()),
|
QFont(this->chatFontFamily.getValue(),
|
||||||
int(this->chatFontSize.getValue() * data.scale * scale),
|
int(this->chatFontSize.getValue() * data.scale * scale),
|
||||||
data.weight, data.italic));
|
data.weight, data.italic));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +1,15 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "common/ChatterinoSetting.hpp"
|
||||||
#include "common/Singleton.hpp"
|
#include "common/Singleton.hpp"
|
||||||
|
|
||||||
#include <QFont>
|
#include <QFont>
|
||||||
#include <QFontDatabase>
|
#include <QFontDatabase>
|
||||||
#include <QFontMetrics>
|
#include <QFontMetrics>
|
||||||
#include <array>
|
|
||||||
#include <boost/noncopyable.hpp>
|
#include <boost/noncopyable.hpp>
|
||||||
#include <pajlada/settings/setting.hpp>
|
|
||||||
#include <pajlada/signals/signal.hpp>
|
#include <pajlada/signals/signal.hpp>
|
||||||
|
|
||||||
|
#include <array>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
@@ -49,8 +50,8 @@ public:
|
|||||||
QFont getFont(FontStyle type, float scale);
|
QFont getFont(FontStyle type, float scale);
|
||||||
QFontMetrics getFontMetrics(FontStyle type, float scale);
|
QFontMetrics getFontMetrics(FontStyle type, float scale);
|
||||||
|
|
||||||
pajlada::Settings::Setting<std::string> chatFontFamily;
|
QStringSetting chatFontFamily;
|
||||||
pajlada::Settings::Setting<int> chatFontSize;
|
IntSetting chatFontSize;
|
||||||
|
|
||||||
pajlada::Signals::NoArgSignal fontChanged;
|
pajlada::Signals::NoArgSignal fontChanged;
|
||||||
|
|
||||||
|
|||||||
+29
-11
@@ -8,12 +8,12 @@
|
|||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
||||||
std::vector<std::weak_ptr<pajlada::Settings::ISettingData>> _settings;
|
std::vector<std::weak_ptr<pajlada::Settings::SettingData>> _settings;
|
||||||
|
|
||||||
Settings *Settings::instance = nullptr;
|
Settings *Settings::instance = nullptr;
|
||||||
|
|
||||||
void _actuallyRegisterSetting(
|
void _actuallyRegisterSetting(
|
||||||
std::weak_ptr<pajlada::Settings::ISettingData> setting)
|
std::weak_ptr<pajlada::Settings::SettingData> setting)
|
||||||
{
|
{
|
||||||
_settings.push_back(setting);
|
_settings.push_back(setting);
|
||||||
}
|
}
|
||||||
@@ -24,7 +24,15 @@ Settings::Settings(Paths &paths)
|
|||||||
|
|
||||||
QString settingsPath = paths.settingsDirectory + "/settings.json";
|
QString settingsPath = paths.settingsDirectory + "/settings.json";
|
||||||
|
|
||||||
pajlada::Settings::SettingManager::gLoad(qPrintable(settingsPath));
|
// get global instance of the settings library
|
||||||
|
auto settingsInstance = pajlada::Settings::SettingManager::getInstance();
|
||||||
|
|
||||||
|
settingsInstance->load(qPrintable(settingsPath));
|
||||||
|
|
||||||
|
settingsInstance->setBackupEnabled(true);
|
||||||
|
settingsInstance->setBackupSlots(9);
|
||||||
|
settingsInstance->saveMethod =
|
||||||
|
pajlada::Settings::SettingManager::SaveMethod::SaveOnExit;
|
||||||
}
|
}
|
||||||
|
|
||||||
Settings &Settings::getInstance()
|
Settings &Settings::getInstance()
|
||||||
@@ -46,13 +54,20 @@ void Settings::saveSnapshot()
|
|||||||
}
|
}
|
||||||
|
|
||||||
rapidjson::Value key(setting->getPath().c_str(), a);
|
rapidjson::Value key(setting->getPath().c_str(), a);
|
||||||
rapidjson::Value val = setting->marshalInto(*d);
|
auto curVal = setting->unmarshalJSON();
|
||||||
|
if (curVal == nullptr)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
rapidjson::Value val;
|
||||||
|
val.CopyFrom(*curVal, a);
|
||||||
d->AddMember(key.Move(), val.Move(), a);
|
d->AddMember(key.Move(), val.Move(), a);
|
||||||
}
|
}
|
||||||
|
|
||||||
this->snapshot_.reset(d);
|
// log("Snapshot state: {}", rj::stringify(*d));
|
||||||
|
|
||||||
log("hehe: {}", pajlada::Settings::SettingManager::stringify(*d));
|
this->snapshot_.reset(d);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Settings::restoreSnapshot()
|
void Settings::restoreSnapshot()
|
||||||
@@ -62,26 +77,29 @@ void Settings::restoreSnapshot()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto &snapshotObject = this->snapshot_->GetObject();
|
const auto &snapshot = *(this->snapshot_.get());
|
||||||
|
|
||||||
|
if (!snapshot.IsObject())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
for (const auto &weakSetting : _settings)
|
for (const auto &weakSetting : _settings)
|
||||||
{
|
{
|
||||||
auto setting = weakSetting.lock();
|
auto setting = weakSetting.lock();
|
||||||
if (!setting)
|
if (!setting)
|
||||||
{
|
{
|
||||||
log("Error stage 1 of loading");
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *path = setting->getPath().c_str();
|
const char *path = setting->getPath().c_str();
|
||||||
|
|
||||||
if (!snapshotObject.HasMember(path))
|
if (!snapshot.HasMember(path))
|
||||||
{
|
{
|
||||||
log("Error stage 2 of loading");
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
setting->unmarshalValue(snapshotObject[path]);
|
setting->marshalJSON(snapshot[path]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
||||||
void _actuallyRegisterSetting(
|
void _actuallyRegisterSetting(
|
||||||
std::weak_ptr<pajlada::Settings::ISettingData> setting);
|
std::weak_ptr<pajlada::Settings::SettingData> setting);
|
||||||
|
|
||||||
class Settings
|
class Settings
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -39,8 +39,6 @@ namespace detail {
|
|||||||
} // namespace detail
|
} // namespace detail
|
||||||
|
|
||||||
Theme::Theme()
|
Theme::Theme()
|
||||||
: themeName("/appearance/theme/name", "Dark")
|
|
||||||
, themeHue("/appearance/theme/hue", 0.0)
|
|
||||||
{
|
{
|
||||||
this->update();
|
this->update();
|
||||||
|
|
||||||
|
|||||||
@@ -130,8 +130,8 @@ public:
|
|||||||
|
|
||||||
pajlada::Signals::NoArgSignal updated;
|
pajlada::Signals::NoArgSignal updated;
|
||||||
|
|
||||||
pajlada::Settings::Setting<QString> themeName;
|
QStringSetting themeName{"/appearance/theme/name", "Dark"};
|
||||||
pajlada::Settings::Setting<double> themeHue;
|
DoubleSetting themeHue{"/appearance/theme/hue", 0.0};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void actuallyUpdate(double hue, double multiplier);
|
void actuallyUpdate(double hue, double multiplier);
|
||||||
|
|||||||
@@ -1,49 +1,45 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <pajlada/settings/serialize.hpp>
|
#include <pajlada/serialize.hpp>
|
||||||
|
|
||||||
namespace pajlada {
|
namespace pajlada {
|
||||||
namespace Settings {
|
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
struct Serialize<QString> {
|
struct Serialize<QString> {
|
||||||
static rapidjson::Value get(const QString &value,
|
static rapidjson::Value get(const QString &value,
|
||||||
rapidjson::Document::AllocatorType &a)
|
rapidjson::Document::AllocatorType &a)
|
||||||
|
{
|
||||||
|
return rapidjson::Value(value.toUtf8(), a);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct Deserialize<QString> {
|
||||||
|
static QString get(const rapidjson::Value &value, bool *error = nullptr)
|
||||||
|
{
|
||||||
|
if (!value.IsString())
|
||||||
{
|
{
|
||||||
return rapidjson::Value(value.toUtf8(), a);
|
PAJLADA_REPORT_ERROR(error)
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template <>
|
|
||||||
struct Deserialize<QString> {
|
|
||||||
static QString get(const rapidjson::Value &value, bool *error = nullptr)
|
|
||||||
{
|
|
||||||
if (!value.IsString())
|
|
||||||
{
|
|
||||||
PAJLADA_REPORT_ERROR(error)
|
|
||||||
PAJLADA_THROW_EXCEPTION(
|
|
||||||
"Deserialized rapidjson::Value is not a string");
|
|
||||||
return QString{};
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
return QString::fromUtf8(value.GetString(),
|
|
||||||
value.GetStringLength());
|
|
||||||
}
|
|
||||||
catch (const std::exception &)
|
|
||||||
{
|
|
||||||
// int x = 5;
|
|
||||||
}
|
|
||||||
catch (...)
|
|
||||||
{
|
|
||||||
// int y = 5;
|
|
||||||
}
|
|
||||||
|
|
||||||
return QString{};
|
return QString{};
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace Settings
|
try
|
||||||
|
{
|
||||||
|
return QString::fromUtf8(value.GetString(),
|
||||||
|
value.GetStringLength());
|
||||||
|
}
|
||||||
|
catch (const std::exception &)
|
||||||
|
{
|
||||||
|
// int x = 5;
|
||||||
|
}
|
||||||
|
catch (...)
|
||||||
|
{
|
||||||
|
// int y = 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
return QString{};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
} // namespace pajlada
|
} // namespace pajlada
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
#include "util/RapidJsonSerializeQString.hpp"
|
#include "util/RapidJsonSerializeQString.hpp"
|
||||||
|
|
||||||
#include <rapidjson/document.h>
|
#include <rapidjson/document.h>
|
||||||
#include <pajlada/settings/serialize.hpp>
|
#include <pajlada/serialize.hpp>
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <string>
|
#include <string>
|
||||||
@@ -24,8 +24,7 @@ namespace rj {
|
|||||||
{
|
{
|
||||||
assert(obj.IsObject());
|
assert(obj.IsObject());
|
||||||
|
|
||||||
addMember(obj, key, pajlada::Settings::Serialize<Type>::get(value, a),
|
addMember(obj, key, pajlada::Serialize<Type>::get(value, a), a);
|
||||||
a);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
@@ -45,8 +44,7 @@ namespace rj {
|
|||||||
|
|
||||||
auto &a = obj.GetAllocator();
|
auto &a = obj.GetAllocator();
|
||||||
|
|
||||||
addMember(obj, key, pajlada::Settings::Serialize<Type>::get(value, a),
|
addMember(obj, key, pajlada::Serialize<Type>::get(value, a), a);
|
||||||
a);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
@@ -66,7 +64,7 @@ namespace rj {
|
|||||||
{
|
{
|
||||||
assert(arr.IsArray());
|
assert(arr.IsArray());
|
||||||
|
|
||||||
arr.PushBack(pajlada::Settings::Serialize<Type>::get(value, a), a);
|
arr.PushBack(pajlada::Serialize<Type>::get(value, a), a);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Type>
|
template <typename Type>
|
||||||
@@ -88,7 +86,7 @@ namespace rj {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool error = false;
|
bool error = false;
|
||||||
out = pajlada::Settings::Deserialize<Type>::get(obj[key], &error);
|
out = pajlada::Deserialize<Type>::get(obj[key], &error);
|
||||||
|
|
||||||
return !error;
|
return !error;
|
||||||
}
|
}
|
||||||
@@ -97,7 +95,7 @@ namespace rj {
|
|||||||
bool getSafe(const rapidjson::Value &value, Type &out)
|
bool getSafe(const rapidjson::Value &value, Type &out)
|
||||||
{
|
{
|
||||||
bool error = false;
|
bool error = false;
|
||||||
out = pajlada::Settings::Deserialize<Type>::get(value, &error);
|
out = pajlada::Deserialize<Type>::get(value, &error);
|
||||||
|
|
||||||
return !error;
|
return !error;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,8 +50,7 @@ AccountSwitchWidget::AccountSwitchWidget(QWidget *parent)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
app->accounts->twitch.currentUsername =
|
app->accounts->twitch.currentUsername = newUsername;
|
||||||
newUsername.toStdString();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -56,9 +56,9 @@ BaseWindow::BaseWindow(QWidget *parent, Flags _flags)
|
|||||||
|
|
||||||
this->init();
|
this->init();
|
||||||
|
|
||||||
this->connections_.managedConnect(
|
getSettings()->uiScale.connect(
|
||||||
getSettings()->uiScale.getValueChangedSignal(),
|
[this]() { postToThread([this] { this->updateScale(); }); },
|
||||||
[this](auto, auto) { postToThread([this] { this->updateScale(); }); });
|
this->connections_);
|
||||||
|
|
||||||
this->updateScale();
|
this->updateScale();
|
||||||
|
|
||||||
@@ -133,8 +133,8 @@ void BaseWindow::init()
|
|||||||
? Qt::WindowActive
|
? Qt::WindowActive
|
||||||
: Qt::WindowMaximized);
|
: Qt::WindowMaximized);
|
||||||
});
|
});
|
||||||
QObject::connect(_exitButton, &TitleBarButton::leftClicked, this,
|
QObject::connect(_exitButton, &TitleBarButton::leftClicked,
|
||||||
[this] { this->close(); });
|
this, [this] { this->close(); });
|
||||||
|
|
||||||
this->ui_.minButton = _minButton;
|
this->ui_.minButton = _minButton;
|
||||||
this->ui_.maxButton = _maxButton;
|
this->ui_.maxButton = _maxButton;
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
#include "common/NetworkRequest.hpp"
|
#include "common/NetworkRequest.hpp"
|
||||||
#include "controllers/accounts/AccountController.hpp"
|
#include "controllers/accounts/AccountController.hpp"
|
||||||
#include "providers/twitch/PartialTwitchUser.hpp"
|
#include "providers/twitch/PartialTwitchUser.hpp"
|
||||||
|
#include "util/Helpers.hpp"
|
||||||
|
|
||||||
#ifdef USEWINSDK
|
#ifdef USEWINSDK
|
||||||
# include <Windows.h>
|
# include <Windows.h>
|
||||||
@@ -21,26 +22,25 @@ namespace chatterino {
|
|||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
void LogInWithCredentials(const std::string &userID,
|
void LogInWithCredentials(const QString &userID, const QString &username,
|
||||||
const std::string &username,
|
const QString &clientID,
|
||||||
const std::string &clientID,
|
const QString &oauthToken)
|
||||||
const std::string &oauthToken)
|
|
||||||
{
|
{
|
||||||
QStringList errors;
|
QStringList errors;
|
||||||
|
|
||||||
if (userID.empty())
|
if (userID.isEmpty())
|
||||||
{
|
{
|
||||||
errors.append("Missing user ID");
|
errors.append("Missing user ID");
|
||||||
}
|
}
|
||||||
if (username.empty())
|
if (username.isEmpty())
|
||||||
{
|
{
|
||||||
errors.append("Missing username");
|
errors.append("Missing username");
|
||||||
}
|
}
|
||||||
if (clientID.empty())
|
if (clientID.isEmpty())
|
||||||
{
|
{
|
||||||
errors.append("Missing Client ID");
|
errors.append("Missing Client ID");
|
||||||
}
|
}
|
||||||
if (oauthToken.empty())
|
if (oauthToken.isEmpty())
|
||||||
{
|
{
|
||||||
errors.append("Missing OAuth Token");
|
errors.append("Missing OAuth Token");
|
||||||
}
|
}
|
||||||
@@ -65,14 +65,14 @@ namespace {
|
|||||||
// messageBox.setIcon(QMessageBox::Information);
|
// messageBox.setIcon(QMessageBox::Information);
|
||||||
// messageBox.setText("Successfully logged in with user <b>" +
|
// messageBox.setText("Successfully logged in with user <b>" +
|
||||||
// qS(username) + "</b>!");
|
// qS(username) + "</b>!");
|
||||||
pajlada::Settings::Setting<std::string>::set(
|
auto basePath = fS("/accounts/uid{}", userID);
|
||||||
"/accounts/uid" + userID + "/username", username);
|
pajlada::Settings::Setting<QString>::set(basePath + "/username",
|
||||||
pajlada::Settings::Setting<std::string>::set(
|
username);
|
||||||
"/accounts/uid" + userID + "/userID", userID);
|
pajlada::Settings::Setting<QString>::set(basePath + "/userID", userID);
|
||||||
pajlada::Settings::Setting<std::string>::set(
|
pajlada::Settings::Setting<QString>::set(basePath + "/clientID",
|
||||||
"/accounts/uid" + userID + "/clientID", clientID);
|
clientID);
|
||||||
pajlada::Settings::Setting<std::string>::set(
|
pajlada::Settings::Setting<QString>::set(basePath + "/oauthToken",
|
||||||
"/accounts/uid" + userID + "/oauthToken", oauthToken);
|
oauthToken);
|
||||||
|
|
||||||
getApp()->accounts->twitch.reloadUsers();
|
getApp()->accounts->twitch.reloadUsers();
|
||||||
|
|
||||||
@@ -105,7 +105,7 @@ BasicLoginWidget::BasicLoginWidget()
|
|||||||
QString clipboardString = clipboard->text();
|
QString clipboardString = clipboard->text();
|
||||||
QStringList parameters = clipboardString.split(';');
|
QStringList parameters = clipboardString.split(';');
|
||||||
|
|
||||||
std::string oauthToken, clientID, username, userID;
|
QString oauthToken, clientID, username, userID;
|
||||||
|
|
||||||
for (const auto ¶m : parameters)
|
for (const auto ¶m : parameters)
|
||||||
{
|
{
|
||||||
@@ -119,19 +119,19 @@ BasicLoginWidget::BasicLoginWidget()
|
|||||||
|
|
||||||
if (key == "oauth_token")
|
if (key == "oauth_token")
|
||||||
{
|
{
|
||||||
oauthToken = value.toStdString();
|
oauthToken = value;
|
||||||
}
|
}
|
||||||
else if (key == "client_id")
|
else if (key == "client_id")
|
||||||
{
|
{
|
||||||
clientID = value.toStdString();
|
clientID = value;
|
||||||
}
|
}
|
||||||
else if (key == "username")
|
else if (key == "username")
|
||||||
{
|
{
|
||||||
username = value.toStdString();
|
username = value;
|
||||||
}
|
}
|
||||||
else if (key == "user_id")
|
else if (key == "user_id")
|
||||||
{
|
{
|
||||||
userID = value.toStdString();
|
userID = value;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -198,16 +198,15 @@ AdvancedLoginWidget::AdvancedLoginWidget()
|
|||||||
this->ui_.oauthTokenInput.clear();
|
this->ui_.oauthTokenInput.clear();
|
||||||
});
|
});
|
||||||
|
|
||||||
connect(
|
connect(&this->ui_.buttonUpperRow.addUserButton, &QPushButton::clicked,
|
||||||
&this->ui_.buttonUpperRow.addUserButton, &QPushButton::clicked, [=]() {
|
[=]() {
|
||||||
std::string userID = this->ui_.userIDInput.text().toStdString();
|
QString userID = this->ui_.userIDInput.text();
|
||||||
std::string username = this->ui_.usernameInput.text().toStdString();
|
QString username = this->ui_.usernameInput.text();
|
||||||
std::string clientID = this->ui_.clientIDInput.text().toStdString();
|
QString clientID = this->ui_.clientIDInput.text();
|
||||||
std::string oauthToken =
|
QString oauthToken = this->ui_.oauthTokenInput.text();
|
||||||
this->ui_.oauthTokenInput.text().toStdString();
|
|
||||||
|
|
||||||
LogInWithCredentials(userID, username, clientID, oauthToken);
|
LogInWithCredentials(userID, username, clientID, oauthToken);
|
||||||
});
|
});
|
||||||
|
|
||||||
/// Lower button row
|
/// Lower button row
|
||||||
this->ui_.buttonLowerRow.fillInUserIDButton.setText(
|
this->ui_.buttonLowerRow.fillInUserIDButton.setText(
|
||||||
|
|||||||
@@ -36,8 +36,8 @@ NotebookTab::NotebookTab(Notebook *notebook)
|
|||||||
this->positionChangedAnimation_.setEasingCurve(
|
this->positionChangedAnimation_.setEasingCurve(
|
||||||
QEasingCurve(QEasingCurve::InCubic));
|
QEasingCurve(QEasingCurve::InCubic));
|
||||||
|
|
||||||
getSettings()->showTabCloseButton.connect(
|
getSettings()->showTabCloseButton.connectSimple(
|
||||||
boost::bind(&NotebookTab::hideTabXChanged, this, _1),
|
boost::bind(&NotebookTab::hideTabXChanged, this),
|
||||||
this->managedConnections_);
|
this->managedConnections_);
|
||||||
getSettings()->showTabLive.connect([this](auto, auto) { this->update(); },
|
getSettings()->showTabLive.connect([this](auto, auto) { this->update(); },
|
||||||
this->managedConnections_);
|
this->managedConnections_);
|
||||||
@@ -230,7 +230,7 @@ QRect NotebookTab::getDesiredRect() const
|
|||||||
return QRect(this->positionAnimationDesiredPoint_, size());
|
return QRect(this->positionAnimationDesiredPoint_, size());
|
||||||
}
|
}
|
||||||
|
|
||||||
void NotebookTab::hideTabXChanged(bool)
|
void NotebookTab::hideTabXChanged()
|
||||||
{
|
{
|
||||||
this->updateSize();
|
this->updateSize();
|
||||||
this->update();
|
this->update();
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ public:
|
|||||||
void moveAnimated(QPoint pos, bool animated = true);
|
void moveAnimated(QPoint pos, bool animated = true);
|
||||||
|
|
||||||
QRect getDesiredRect() const;
|
QRect getDesiredRect() const;
|
||||||
void hideTabXChanged(bool);
|
void hideTabXChanged();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void themeChangedEvent() override;
|
virtual void themeChangedEvent() override;
|
||||||
|
|||||||
@@ -148,10 +148,9 @@ void GeneralPage::initLayout(SettingsLayout &layout)
|
|||||||
layout.addTitle("Appearance");
|
layout.addTitle("Appearance");
|
||||||
layout.addDropdown("Theme", {"White", "Light", "Dark", "Black"},
|
layout.addDropdown("Theme", {"White", "Light", "Dark", "Black"},
|
||||||
getApp()->themes->themeName);
|
getApp()->themes->themeName);
|
||||||
layout.addDropdown<std::string>(
|
layout.addDropdown<QString>(
|
||||||
"Font", {"Segoe UI", "Arial", "Choose..."},
|
"Font", {"Segoe UI", "Arial", "Choose..."},
|
||||||
getApp()->fonts->chatFontFamily,
|
getApp()->fonts->chatFontFamily, [](auto val) { return val; },
|
||||||
[](auto val) { return QString::fromStdString(val); },
|
|
||||||
[this](auto args) { return this->getFont(args); });
|
[this](auto args) { return this->getFont(args); });
|
||||||
layout.addDropdown<int>(
|
layout.addDropdown<int>(
|
||||||
"Font size", {"9pt", "10pt", "12pt", "14pt", "16pt", "20pt"},
|
"Font size", {"9pt", "10pt", "12pt", "14pt", "16pt", "20pt"},
|
||||||
@@ -220,7 +219,8 @@ void GeneralPage::initLayout(SettingsLayout &layout)
|
|||||||
layout.addCheckbox("Animate only when focused", s.animationsWhenFocused);
|
layout.addCheckbox("Animate only when focused", s.animationsWhenFocused);
|
||||||
layout.addDropdown("Emoji set",
|
layout.addDropdown("Emoji set",
|
||||||
{"EmojiOne 2", "EmojiOne 3", "Twitter", "Facebook",
|
{"EmojiOne 2", "EmojiOne 3", "Twitter", "Facebook",
|
||||||
"Apple", "Google", "Messenger"});
|
"Apple", "Google", "Messenger"},
|
||||||
|
s.emojiSet);
|
||||||
|
|
||||||
layout.addTitle("Badges");
|
layout.addTitle("Badges");
|
||||||
layout.addCheckbox("Show authority badges (staff, admin, turbo, etc)",
|
layout.addCheckbox("Show authority badges (staff, admin, turbo, etc)",
|
||||||
@@ -311,7 +311,7 @@ void GeneralPage::initExtra()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string GeneralPage::getFont(const DropdownArgs &args) const
|
QString GeneralPage::getFont(const DropdownArgs &args) const
|
||||||
{
|
{
|
||||||
if (args.combobox->currentIndex() == args.combobox->count() - 1)
|
if (args.combobox->currentIndex() == args.combobox->count() - 1)
|
||||||
{
|
{
|
||||||
@@ -325,11 +325,11 @@ std::string GeneralPage::getFont(const DropdownArgs &args) const
|
|||||||
auto font = dialog.getFont(&ok);
|
auto font = dialog.getFont(&ok);
|
||||||
|
|
||||||
if (ok)
|
if (ok)
|
||||||
return font.family().toStdString();
|
return font.family();
|
||||||
else
|
else
|
||||||
return args.combobox->itemText(0).toStdString();
|
return args.combobox->itemText(0);
|
||||||
}
|
}
|
||||||
return args.value.toStdString();
|
return args.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace chatterino
|
} // namespace chatterino
|
||||||
|
|||||||
@@ -156,7 +156,7 @@ private:
|
|||||||
void initLayout(SettingsLayout &layout);
|
void initLayout(SettingsLayout &layout);
|
||||||
void initExtra();
|
void initExtra();
|
||||||
|
|
||||||
std::string getFont(const DropdownArgs &args) const;
|
QString getFont(const DropdownArgs &args) const;
|
||||||
|
|
||||||
DescriptionLabel *cachePath{};
|
DescriptionLabel *cachePath{};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -532,17 +532,15 @@ QLayout *LookPage::createFontChanger()
|
|||||||
QLabel *label = new QLabel();
|
QLabel *label = new QLabel();
|
||||||
layout->addWidget(label);
|
layout->addWidget(label);
|
||||||
|
|
||||||
auto updateFontFamilyLabel = [=](auto) {
|
auto updateFontFamilyLabel = [=]() {
|
||||||
label->setText(
|
label->setText("Font (" + app->fonts->chatFontFamily.getValue() + ", " +
|
||||||
"Font (" +
|
QString::number(app->fonts->chatFontSize) + "pt)");
|
||||||
QString::fromStdString(app->fonts->chatFontFamily.getValue()) +
|
|
||||||
", " + QString::number(app->fonts->chatFontSize) + "pt)");
|
|
||||||
};
|
};
|
||||||
|
|
||||||
app->fonts->chatFontFamily.connectSimple(updateFontFamilyLabel,
|
app->fonts->chatFontFamily.connect(updateFontFamilyLabel,
|
||||||
this->managedConnections_);
|
this->managedConnections_);
|
||||||
app->fonts->chatFontSize.connectSimple(updateFontFamilyLabel,
|
app->fonts->chatFontSize.connect(updateFontFamilyLabel,
|
||||||
this->managedConnections_);
|
this->managedConnections_);
|
||||||
|
|
||||||
// BUTTON
|
// BUTTON
|
||||||
QPushButton *button = new QPushButton("Select");
|
QPushButton *button = new QPushButton("Select");
|
||||||
@@ -554,11 +552,11 @@ QLayout *LookPage::createFontChanger()
|
|||||||
|
|
||||||
dialog.setWindowFlag(Qt::WindowStaysOnTopHint);
|
dialog.setWindowFlag(Qt::WindowStaysOnTopHint);
|
||||||
|
|
||||||
dialog.connect(
|
dialog.connect(&dialog, &QFontDialog::fontSelected,
|
||||||
&dialog, &QFontDialog::fontSelected, [=](const QFont &font) {
|
[=](const QFont &font) {
|
||||||
app->fonts->chatFontFamily = font.family().toStdString();
|
app->fonts->chatFontFamily = font.family();
|
||||||
app->fonts->chatFontSize = font.pointSize();
|
app->fonts->chatFontSize = font.pointSize();
|
||||||
});
|
});
|
||||||
|
|
||||||
dialog.show();
|
dialog.show();
|
||||||
dialog.exec();
|
dialog.exec();
|
||||||
|
|||||||
Reference in New Issue
Block a user