mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
put singletons into their namespace
This commit is contained in:
parent
ad001431f2
commit
5a26d5f17f
72 changed files with 357 additions and 288 deletions
|
@ -118,7 +118,7 @@ HEADERS += \
|
||||||
src/precompiled_headers.hpp \
|
src/precompiled_headers.hpp \
|
||||||
src/asyncexec.hpp \
|
src/asyncexec.hpp \
|
||||||
src/channel.hpp \
|
src/channel.hpp \
|
||||||
src/concurrentmap.hpp \
|
src/util/concurrentmap.hpp \
|
||||||
src/emojis.hpp \
|
src/emojis.hpp \
|
||||||
src/singletons/ircmanager.hpp \
|
src/singletons/ircmanager.hpp \
|
||||||
src/messages/lazyloadedimage.hpp \
|
src/messages/lazyloadedimage.hpp \
|
||||||
|
@ -194,7 +194,8 @@ HEADERS += \
|
||||||
src/twitch/twitchaccountmanager.hpp \
|
src/twitch/twitchaccountmanager.hpp \
|
||||||
src/singletons/helper/completionmodel.hpp \
|
src/singletons/helper/completionmodel.hpp \
|
||||||
src/singletons/helper/chatterinosetting.hpp \
|
src/singletons/helper/chatterinosetting.hpp \
|
||||||
src/singletons/resourcemanager.hpp
|
src/singletons/resourcemanager.hpp \
|
||||||
|
src/util/emotemap.hpp
|
||||||
|
|
||||||
|
|
||||||
PRECOMPILED_HEADER =
|
PRECOMPILED_HEADER =
|
||||||
|
|
|
@ -6,6 +6,8 @@
|
||||||
#include "singletons/thememanager.hpp"
|
#include "singletons/thememanager.hpp"
|
||||||
#include "singletons/windowmanager.hpp"
|
#include "singletons/windowmanager.hpp"
|
||||||
|
|
||||||
|
using namespace chatterino::singletons;
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
||||||
// this class is responsible for handling the workflow of Chatterino
|
// this class is responsible for handling the workflow of Chatterino
|
||||||
|
@ -13,41 +15,43 @@ namespace chatterino {
|
||||||
|
|
||||||
Application::Application()
|
Application::Application()
|
||||||
{
|
{
|
||||||
logging::init();
|
singletons::WindowManager::getInstance();
|
||||||
SettingsManager::getInstance().load();
|
|
||||||
|
|
||||||
WindowManager::getInstance().initMainWindow();
|
logging::init();
|
||||||
|
singletons::SettingManager::getInstance().load();
|
||||||
|
|
||||||
|
singletons::WindowManager::getInstance().initMainWindow();
|
||||||
|
|
||||||
// Initialize everything we need
|
// Initialize everything we need
|
||||||
EmoteManager::getInstance().loadGlobalEmotes();
|
singletons::EmoteManager::getInstance().loadGlobalEmotes();
|
||||||
|
|
||||||
AccountManager::getInstance().load();
|
singletons::AccountManager::getInstance().load();
|
||||||
|
|
||||||
// XXX
|
// XXX
|
||||||
SettingsManager::getInstance().updateWordTypeMask();
|
singletons::SettingManager::getInstance().updateWordTypeMask();
|
||||||
}
|
}
|
||||||
|
|
||||||
Application::~Application()
|
Application::~Application()
|
||||||
{
|
{
|
||||||
this->save();
|
this->save();
|
||||||
|
|
||||||
chatterino::SettingsManager::getInstance().save();
|
chatterino::singletons::SettingManager::getInstance().save();
|
||||||
}
|
}
|
||||||
|
|
||||||
int Application::run(QApplication &qtApp)
|
int Application::run(QApplication &qtApp)
|
||||||
{
|
{
|
||||||
// Start connecting to the IRC Servers (Twitch only for now)
|
// Start connecting to the IRC Servers (Twitch only for now)
|
||||||
IrcManager::getInstance().connect();
|
singletons::IrcManager::getInstance().connect();
|
||||||
|
|
||||||
// Show main window
|
// Show main window
|
||||||
WindowManager::getInstance().getMainWindow().show();
|
singletons::WindowManager::getInstance().getMainWindow().show();
|
||||||
|
|
||||||
return qtApp.exec();
|
return qtApp.exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::save()
|
void Application::save()
|
||||||
{
|
{
|
||||||
WindowManager::getInstance().save();
|
singletons::WindowManager::getInstance().save();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace chatterino
|
} // namespace chatterino
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "concurrentmap.hpp"
|
|
||||||
#include "logging/loggingchannel.hpp"
|
#include "logging/loggingchannel.hpp"
|
||||||
#include "messages/lazyloadedimage.hpp"
|
#include "messages/lazyloadedimage.hpp"
|
||||||
#include "messages/limitedqueue.hpp"
|
#include "messages/limitedqueue.hpp"
|
||||||
|
#include "util/concurrentmap.hpp"
|
||||||
|
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
#include <QMutex>
|
#include <QMutex>
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "concurrentmap.hpp"
|
|
||||||
#include "messages/lazyloadedimage.hpp"
|
#include "messages/lazyloadedimage.hpp"
|
||||||
|
#include "util/concurrentmap.hpp"
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
|
@ -90,5 +90,6 @@ int main(int argc, char *argv[])
|
||||||
// Deinitialize NetworkManager (stop thread and wait for finish, should be instant)
|
// Deinitialize NetworkManager (stop thread and wait for finish, should be instant)
|
||||||
chatterino::util::NetworkManager::deinit();
|
chatterino::util::NetworkManager::deinit();
|
||||||
|
|
||||||
|
exit(0);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,12 +79,12 @@ void LazyLoadedImage::loadImage()
|
||||||
lli->animated = true;
|
lli->animated = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
EmoteManager::getInstance().incGeneration();
|
singletons::EmoteManager::getInstance().incGeneration();
|
||||||
|
|
||||||
WindowManager::getInstance().layoutVisibleChatWidgets();
|
singletons::WindowManager::getInstance().layoutVisibleChatWidgets();
|
||||||
});
|
});
|
||||||
|
|
||||||
EmoteManager::getInstance().getGifUpdateSignal().connect([=]() {
|
singletons::EmoteManager::getInstance().getGifUpdateSignal().connect([=]() {
|
||||||
this->gifUpdateTimout();
|
this->gifUpdateTimout();
|
||||||
}); // For some reason when Boost signal is in thread scope and thread deletes the signal
|
}); // For some reason when Boost signal is in thread scope and thread deletes the signal
|
||||||
// doesn't work, so this is the fix.
|
// doesn't work, so this is the fix.
|
||||||
|
|
|
@ -83,14 +83,14 @@ void AddCurrentTimestamp(Message *message)
|
||||||
strftime(timeStampBuffer, 69, "%H:%M", localtime(&t));
|
strftime(timeStampBuffer, 69, "%H:%M", localtime(&t));
|
||||||
QString timestampNoSeconds(timeStampBuffer);
|
QString timestampNoSeconds(timeStampBuffer);
|
||||||
message->getWords().push_back(Word(timestampNoSeconds, Word::TimestampNoSeconds,
|
message->getWords().push_back(Word(timestampNoSeconds, Word::TimestampNoSeconds,
|
||||||
MessageColor(MessageColor::System), FontManager::Medium,
|
MessageColor(MessageColor::System), singletons::FontManager::Medium,
|
||||||
QString(), QString()));
|
QString(), QString()));
|
||||||
|
|
||||||
// Add word for timestamp with seconds
|
// Add word for timestamp with seconds
|
||||||
strftime(timeStampBuffer, 69, "%H:%M:%S", localtime(&t));
|
strftime(timeStampBuffer, 69, "%H:%M:%S", localtime(&t));
|
||||||
QString timestampWithSeconds(timeStampBuffer);
|
QString timestampWithSeconds(timeStampBuffer);
|
||||||
message->getWords().push_back(Word(timestampWithSeconds, Word::TimestampWithSeconds,
|
message->getWords().push_back(Word(timestampWithSeconds, Word::TimestampWithSeconds,
|
||||||
MessageColor(MessageColor::System), FontManager::Medium,
|
MessageColor(MessageColor::System), singletons::FontManager::Medium,
|
||||||
QString(), QString()));
|
QString(), QString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,7 +108,7 @@ Message *Message::createSystemMessage(const QString &text)
|
||||||
for (QString word : words) {
|
for (QString word : words) {
|
||||||
message->getWords().push_back(Word(word, Word::Flags::Default,
|
message->getWords().push_back(Word(word, Word::Flags::Default,
|
||||||
MessageColor(MessageColor::Type::System),
|
MessageColor(MessageColor::Type::System),
|
||||||
FontManager::Medium, word, QString()));
|
singletons::FontManager::Medium, word, QString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
return message;
|
return message;
|
||||||
|
@ -149,7 +149,7 @@ Message *Message::createTimeoutMessage(const QString &username, const QString &d
|
||||||
text.append(".");
|
text.append(".");
|
||||||
|
|
||||||
Word word(text, Word::Flags::Default, MessageColor(MessageColor::Type::System),
|
Word word(text, Word::Flags::Default, MessageColor(MessageColor::Type::System),
|
||||||
FontManager::Medium, text, QString());
|
singletons::FontManager::Medium, text, QString());
|
||||||
|
|
||||||
message->getWords().push_back(word);
|
message->getWords().push_back(word);
|
||||||
|
|
||||||
|
|
|
@ -40,13 +40,13 @@ void MessageBuilder::appendTimestamp(QDateTime &time)
|
||||||
// Add word for timestamp with no seconds
|
// Add word for timestamp with no seconds
|
||||||
QString timestampNoSeconds(time.toString("hh:mm"));
|
QString timestampNoSeconds(time.toString("hh:mm"));
|
||||||
this->appendWord(Word(timestampNoSeconds, Word::TimestampNoSeconds,
|
this->appendWord(Word(timestampNoSeconds, Word::TimestampNoSeconds,
|
||||||
MessageColor(MessageColor::System), FontManager::Medium, QString(),
|
MessageColor(MessageColor::System), singletons::FontManager::Medium, QString(),
|
||||||
QString()));
|
QString()));
|
||||||
|
|
||||||
// Add word for timestamp with seconds
|
// Add word for timestamp with seconds
|
||||||
QString timestampWithSeconds(time.toString("hh:mm:ss"));
|
QString timestampWithSeconds(time.toString("hh:mm:ss"));
|
||||||
this->appendWord(Word(timestampWithSeconds, Word::TimestampWithSeconds,
|
this->appendWord(Word(timestampWithSeconds, Word::TimestampWithSeconds,
|
||||||
MessageColor(MessageColor::System), FontManager::Medium, QString(),
|
MessageColor(MessageColor::System), singletons::FontManager::Medium, QString(),
|
||||||
QString()));
|
QString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ MessageColor::Type MessageColor::getType() const
|
||||||
return this->type;
|
return this->type;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QColor &MessageColor::getColor(ThemeManager &themeManager) const
|
const QColor &MessageColor::getColor(singletons::ThemeManager &themeManager) const
|
||||||
{
|
{
|
||||||
switch (this->type) {
|
switch (this->type) {
|
||||||
case Type::Custom:
|
case Type::Custom:
|
||||||
|
|
|
@ -16,7 +16,7 @@ public:
|
||||||
explicit MessageColor(Type type = Text);
|
explicit MessageColor(Type type = Text);
|
||||||
|
|
||||||
Type getType() const;
|
Type getType() const;
|
||||||
const QColor &getColor(ThemeManager &themeManager) const;
|
const QColor &getColor(singletons::ThemeManager &themeManager) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Type type;
|
Type type;
|
||||||
|
|
|
@ -35,7 +35,7 @@ int MessageRef::getHeight() const
|
||||||
// return true if redraw is required
|
// return true if redraw is required
|
||||||
bool MessageRef::layout(int width, float scale)
|
bool MessageRef::layout(int width, float scale)
|
||||||
{
|
{
|
||||||
auto &emoteManager = EmoteManager::getInstance();
|
auto &emoteManager = singletons::EmoteManager::getInstance();
|
||||||
|
|
||||||
bool rebuildRequired = false, layoutRequired = false;
|
bool rebuildRequired = false, layoutRequired = false;
|
||||||
|
|
||||||
|
@ -50,15 +50,15 @@ bool MessageRef::layout(int width, float scale)
|
||||||
this->emoteGeneration = emoteManager.getGeneration();
|
this->emoteGeneration = emoteManager.getGeneration();
|
||||||
|
|
||||||
// check if text changed
|
// check if text changed
|
||||||
bool textChanged = this->fontGeneration != FontManager::getInstance().getGeneration();
|
bool textChanged = this->fontGeneration != singletons::FontManager::getInstance().getGeneration();
|
||||||
layoutRequired |= textChanged;
|
layoutRequired |= textChanged;
|
||||||
this->fontGeneration = FontManager::getInstance().getGeneration();
|
this->fontGeneration = singletons::FontManager::getInstance().getGeneration();
|
||||||
|
|
||||||
// check if work mask changed
|
// check if work mask changed
|
||||||
bool wordMaskChanged =
|
bool wordMaskChanged =
|
||||||
this->currentWordTypes != SettingsManager::getInstance().getWordTypeMask();
|
this->currentWordTypes != singletons::SettingManager::getInstance().getWordTypeMask();
|
||||||
layoutRequired |= wordMaskChanged;
|
layoutRequired |= wordMaskChanged;
|
||||||
this->currentWordTypes = SettingsManager::getInstance().getWordTypeMask();
|
this->currentWordTypes = singletons::SettingManager::getInstance().getWordTypeMask();
|
||||||
|
|
||||||
// check if dpi changed
|
// check if dpi changed
|
||||||
bool scaleChanged = this->scale != scale;
|
bool scaleChanged = this->scale != scale;
|
||||||
|
@ -92,7 +92,7 @@ bool MessageRef::layout(int width, float scale)
|
||||||
|
|
||||||
void MessageRef::actuallyLayout(int width)
|
void MessageRef::actuallyLayout(int width)
|
||||||
{
|
{
|
||||||
auto &settings = SettingsManager::getInstance();
|
auto &settings = singletons::SettingManager::getInstance();
|
||||||
|
|
||||||
const int spaceWidth = 4;
|
const int spaceWidth = 4;
|
||||||
const int right = width - MARGIN_RIGHT;
|
const int right = width - MARGIN_RIGHT;
|
||||||
|
|
|
@ -18,8 +18,9 @@ Word::Word(LazyLoadedImage *image, Flags type, const QString ©text, const QS
|
||||||
}
|
}
|
||||||
|
|
||||||
// Text word
|
// Text word
|
||||||
Word::Word(const QString &text, Flags type, const MessageColor &color, FontManager::Type font,
|
Word::Word(const QString &text, Flags type, const MessageColor &color,
|
||||||
const QString ©text, const QString &tooltip, const Link &link)
|
singletons::FontManager::Type font, const QString ©text, const QString &tooltip,
|
||||||
|
const Link &link)
|
||||||
: image(nullptr)
|
: image(nullptr)
|
||||||
, text(text)
|
, text(text)
|
||||||
, color(color)
|
, color(color)
|
||||||
|
@ -64,10 +65,11 @@ QSize Word::getSize(float scale) const
|
||||||
data.size.setHeight((int)(metrics.height()));
|
data.size.setHeight((int)(metrics.height()));
|
||||||
} else {
|
} else {
|
||||||
const int mediumTextLineHeight =
|
const int mediumTextLineHeight =
|
||||||
FontManager::getInstance().getFontMetrics(this->font, scale).height();
|
singletons::FontManager::getInstance().getFontMetrics(this->font, scale).height();
|
||||||
const qreal emoteScale = SettingsManager::getInstance().emoteScale.get() * scale;
|
const qreal emoteScale =
|
||||||
|
singletons::SettingManager::getInstance().emoteScale.get() * scale;
|
||||||
const bool scaleEmotesByLineHeight =
|
const bool scaleEmotesByLineHeight =
|
||||||
SettingsManager::getInstance().scaleEmotesByLineHeight;
|
singletons::SettingManager::getInstance().scaleEmotesByLineHeight;
|
||||||
|
|
||||||
auto &image = this->getImage();
|
auto &image = this->getImage();
|
||||||
|
|
||||||
|
@ -114,12 +116,12 @@ bool Word::hasTrailingSpace() const
|
||||||
|
|
||||||
QFont &Word::getFont(float scale) const
|
QFont &Word::getFont(float scale) const
|
||||||
{
|
{
|
||||||
return FontManager::getInstance().getFont(this->font, scale);
|
return singletons::FontManager::getInstance().getFont(this->font, scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
QFontMetrics &Word::getFontMetrics(float scale) const
|
QFontMetrics &Word::getFontMetrics(float scale) const
|
||||||
{
|
{
|
||||||
return FontManager::getInstance().getFontMetrics(this->font, scale);
|
return singletons::FontManager::getInstance().getFontMetrics(this->font, scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
Word::Flags Word::getFlags() const
|
Word::Flags Word::getFlags() const
|
||||||
|
|
|
@ -96,7 +96,7 @@ public:
|
||||||
explicit Word(LazyLoadedImage *_image, Flags getFlags, const QString ©text,
|
explicit Word(LazyLoadedImage *_image, Flags getFlags, const QString ©text,
|
||||||
const QString &tooltip, const Link &getLink = Link());
|
const QString &tooltip, const Link &getLink = Link());
|
||||||
explicit Word(const QString &_text, Flags getFlags, const MessageColor &textColor,
|
explicit Word(const QString &_text, Flags getFlags, const MessageColor &textColor,
|
||||||
FontManager::Type font, const QString ©text, const QString &tooltip,
|
singletons::FontManager::Type font, const QString ©text, const QString &tooltip,
|
||||||
const Link &getLink = Link());
|
const Link &getLink = Link());
|
||||||
|
|
||||||
bool isImage() const;
|
bool isImage() const;
|
||||||
|
@ -138,7 +138,7 @@ private:
|
||||||
int yOffset = 0;
|
int yOffset = 0;
|
||||||
|
|
||||||
bool _hasTrailingSpace = true;
|
bool _hasTrailingSpace = true;
|
||||||
FontManager::Type font = FontManager::Medium;
|
singletons::FontManager::Type font = singletons::FontManager::Medium;
|
||||||
Link link;
|
Link link;
|
||||||
|
|
||||||
struct ScaleDependantData {
|
struct ScaleDependantData {
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#include "singletons/accountmanager.hpp"
|
#include "singletons/accountmanager.hpp"
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
namespace singletons {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
@ -43,3 +44,4 @@ void AccountManager::load()
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace chatterino
|
} // namespace chatterino
|
||||||
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
#include "twitch/twitchaccountmanager.hpp"
|
#include "twitch/twitchaccountmanager.hpp"
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
namespace singletons {
|
||||||
|
|
||||||
class AccountManager
|
class AccountManager
|
||||||
{
|
{
|
||||||
|
@ -17,3 +18,4 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace chatterino
|
} // namespace chatterino
|
||||||
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
using namespace chatterino::twitch;
|
using namespace chatterino::twitch;
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
namespace singletons {
|
||||||
|
|
||||||
ChannelManager &ChannelManager::getInstance()
|
ChannelManager &ChannelManager::getInstance()
|
||||||
{
|
{
|
||||||
|
@ -138,3 +139,4 @@ void ChannelManager::doOnAll(std::function<void(std::shared_ptr<Channel>)> func)
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace chatterino
|
} // namespace chatterino
|
||||||
|
}
|
||||||
|
|
|
@ -7,8 +7,7 @@
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
namespace singletons {
|
||||||
class WindowManager;
|
|
||||||
class IrcManager;
|
class IrcManager;
|
||||||
|
|
||||||
class ChannelManager
|
class ChannelManager
|
||||||
|
@ -43,7 +42,8 @@ private:
|
||||||
pajlada::Signals::Signal<const QString &> ircJoin;
|
pajlada::Signals::Signal<const QString &> ircJoin;
|
||||||
pajlada::Signals::Signal<const QString &> ircPart;
|
pajlada::Signals::Signal<const QString &> ircPart;
|
||||||
|
|
||||||
friend class IrcManager;
|
friend class singletons::IrcManager;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace chatterino
|
} // namespace chatterino
|
||||||
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
#include <QRegularExpression>
|
#include <QRegularExpression>
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
namespace singletons {
|
||||||
CommandManager &CommandManager::getInstance()
|
CommandManager &CommandManager::getInstance()
|
||||||
{
|
{
|
||||||
static CommandManager instance;
|
static CommandManager instance;
|
||||||
|
@ -81,3 +82,4 @@ CommandManager &CommandManager::getInstance()
|
||||||
// this->text = _text.mid(index + 1);
|
// this->text = _text.mid(index + 1);
|
||||||
//}
|
//}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
namespace singletons {
|
||||||
|
|
||||||
class CommandManager
|
class CommandManager
|
||||||
{
|
{
|
||||||
|
@ -36,3 +37,4 @@ public:
|
||||||
// std::vector<Command> commands;
|
// std::vector<Command> commands;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#include "singletons/emotemanager.hpp"
|
#include "singletons/emotemanager.hpp"
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
namespace singletons {
|
||||||
|
|
||||||
CompletionManager &CompletionManager::getInstance()
|
CompletionManager &CompletionManager::getInstance()
|
||||||
{
|
{
|
||||||
|
@ -26,3 +27,4 @@ CompletionModel *CompletionManager::createModel(const std::string &channelName)
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace chatterino
|
} // namespace chatterino
|
||||||
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
#include "helper/completionmodel.hpp"
|
#include "helper/completionmodel.hpp"
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
namespace singletons {
|
||||||
class CompletionManager
|
class CompletionManager
|
||||||
{
|
{
|
||||||
CompletionManager() = default;
|
CompletionManager() = default;
|
||||||
|
@ -22,3 +23,4 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace chatterino
|
} // namespace chatterino
|
||||||
|
}
|
||||||
|
|
|
@ -21,8 +21,9 @@
|
||||||
using namespace chatterino::messages;
|
using namespace chatterino::messages;
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
namespace singletons {
|
||||||
|
|
||||||
EmoteManager::EmoteManager(SettingsManager &_settingsManager, WindowManager &_windowManager)
|
EmoteManager::EmoteManager(SettingManager &_settingsManager, WindowManager &_windowManager)
|
||||||
: settingsManager(_settingsManager)
|
: settingsManager(_settingsManager)
|
||||||
, windowManager(_windowManager)
|
, windowManager(_windowManager)
|
||||||
, findShortCodesRegex(":([-+\\w]+):")
|
, findShortCodesRegex(":([-+\\w]+):")
|
||||||
|
@ -38,7 +39,7 @@ EmoteManager::EmoteManager(SettingsManager &_settingsManager, WindowManager &_wi
|
||||||
|
|
||||||
EmoteManager &EmoteManager::getInstance()
|
EmoteManager &EmoteManager::getInstance()
|
||||||
{
|
{
|
||||||
static EmoteManager instance(SettingsManager::getInstance(), WindowManager::getInstance());
|
static EmoteManager instance(SettingManager::getInstance(), WindowManager::getInstance());
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,7 +50,8 @@ void EmoteManager::loadGlobalEmotes()
|
||||||
this->loadFFZEmotes();
|
this->loadFFZEmotes();
|
||||||
}
|
}
|
||||||
|
|
||||||
void EmoteManager::reloadBTTVChannelEmotes(const QString &channelName, std::weak_ptr<EmoteMap> _map)
|
void EmoteManager::reloadBTTVChannelEmotes(const QString &channelName,
|
||||||
|
std::weak_ptr<util::EmoteMap> _map)
|
||||||
{
|
{
|
||||||
printf("[EmoteManager] Reload BTTV Channel Emotes for channel %s\n", qPrintable(channelName));
|
printf("[EmoteManager] Reload BTTV Channel Emotes for channel %s\n", qPrintable(channelName));
|
||||||
|
|
||||||
|
@ -88,7 +90,7 @@ void EmoteManager::reloadBTTVChannelEmotes(const QString &channelName, std::weak
|
||||||
link = link.replace("{{id}}", id).replace("{{image}}", "1x");
|
link = link.replace("{{id}}", id).replace("{{image}}", "1x");
|
||||||
|
|
||||||
auto emote = this->getBTTVChannelEmoteFromCaches().getOrAdd(id, [this, &code, &link] {
|
auto emote = this->getBTTVChannelEmoteFromCaches().getOrAdd(id, [this, &code, &link] {
|
||||||
return EmoteData(
|
return util::EmoteData(
|
||||||
new LazyLoadedImage(link, 1, code, code + "<br/>Channel BTTV Emote"));
|
new LazyLoadedImage(link, 1, code, code + "<br/>Channel BTTV Emote"));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -101,7 +103,8 @@ void EmoteManager::reloadBTTVChannelEmotes(const QString &channelName, std::weak
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void EmoteManager::reloadFFZChannelEmotes(const QString &channelName, std::weak_ptr<EmoteMap> _map)
|
void EmoteManager::reloadFFZChannelEmotes(const QString &channelName,
|
||||||
|
std::weak_ptr<util::EmoteMap> _map)
|
||||||
{
|
{
|
||||||
printf("[EmoteManager] Reload FFZ Channel Emotes for channel %s\n", qPrintable(channelName));
|
printf("[EmoteManager] Reload FFZ Channel Emotes for channel %s\n", qPrintable(channelName));
|
||||||
|
|
||||||
|
@ -137,7 +140,7 @@ void EmoteManager::reloadFFZChannelEmotes(const QString &channelName, std::weak_
|
||||||
|
|
||||||
auto emote =
|
auto emote =
|
||||||
this->getFFZChannelEmoteFromCaches().getOrAdd(id, [this, &code, &url1] {
|
this->getFFZChannelEmoteFromCaches().getOrAdd(id, [this, &code, &url1] {
|
||||||
return EmoteData(
|
return util::EmoteData(
|
||||||
new LazyLoadedImage(url1, 1, code, code + "<br/>Channel FFZ Emote"));
|
new LazyLoadedImage(url1, 1, code, code + "<br/>Channel FFZ Emote"));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -151,37 +154,37 @@ void EmoteManager::reloadFFZChannelEmotes(const QString &channelName, std::weak_
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
ConcurrentMap<QString, twitch::EmoteValue *> &EmoteManager::getTwitchEmotes()
|
util::ConcurrentMap<QString, twitch::EmoteValue *> &EmoteManager::getTwitchEmotes()
|
||||||
{
|
{
|
||||||
return _twitchEmotes;
|
return _twitchEmotes;
|
||||||
}
|
}
|
||||||
|
|
||||||
EmoteMap &EmoteManager::getFFZEmotes()
|
util::EmoteMap &EmoteManager::getFFZEmotes()
|
||||||
{
|
{
|
||||||
return ffzGlobalEmotes;
|
return ffzGlobalEmotes;
|
||||||
}
|
}
|
||||||
|
|
||||||
EmoteMap &EmoteManager::getChatterinoEmotes()
|
util::EmoteMap &EmoteManager::getChatterinoEmotes()
|
||||||
{
|
{
|
||||||
return _chatterinoEmotes;
|
return _chatterinoEmotes;
|
||||||
}
|
}
|
||||||
|
|
||||||
EmoteMap &EmoteManager::getBTTVChannelEmoteFromCaches()
|
util::EmoteMap &EmoteManager::getBTTVChannelEmoteFromCaches()
|
||||||
{
|
{
|
||||||
return _bttvChannelEmoteFromCaches;
|
return _bttvChannelEmoteFromCaches;
|
||||||
}
|
}
|
||||||
|
|
||||||
EmoteMap &EmoteManager::getEmojis()
|
util::EmoteMap &EmoteManager::getEmojis()
|
||||||
{
|
{
|
||||||
return this->emojis;
|
return this->emojis;
|
||||||
}
|
}
|
||||||
|
|
||||||
ConcurrentMap<int, EmoteData> &EmoteManager::getFFZChannelEmoteFromCaches()
|
util::ConcurrentMap<int, util::EmoteData> &EmoteManager::getFFZChannelEmoteFromCaches()
|
||||||
{
|
{
|
||||||
return _ffzChannelEmoteFromCaches;
|
return _ffzChannelEmoteFromCaches;
|
||||||
}
|
}
|
||||||
|
|
||||||
ConcurrentMap<long, EmoteData> &EmoteManager::getTwitchEmoteFromCache()
|
util::ConcurrentMap<long, util::EmoteData> &EmoteManager::getTwitchEmoteFromCache()
|
||||||
{
|
{
|
||||||
return _twitchEmoteFromCache;
|
return _twitchEmoteFromCache;
|
||||||
}
|
}
|
||||||
|
@ -237,7 +240,8 @@ void EmoteManager::loadEmojis()
|
||||||
"emojione/2.2.6/assets/png/" +
|
"emojione/2.2.6/assets/png/" +
|
||||||
code + ".png";
|
code + ".png";
|
||||||
|
|
||||||
this->emojis.insert(code, EmoteData(new LazyLoadedImage(url, 0.35, ":" + shortCode + ":",
|
this->emojis.insert(code,
|
||||||
|
util::EmoteData(new LazyLoadedImage(url, 0.35, ":" + shortCode + ":",
|
||||||
":" + shortCode + ":<br/>Emoji")));
|
":" + shortCode + ":<br/>Emoji")));
|
||||||
|
|
||||||
// TODO(pajlada): The vectors in emojiFirstByte need to be sorted by
|
// TODO(pajlada): The vectors in emojiFirstByte need to be sorted by
|
||||||
|
@ -245,7 +249,7 @@ void EmoteManager::loadEmojis()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void EmoteManager::parseEmojis(std::vector<std::tuple<EmoteData, QString>> &parsedWords,
|
void EmoteManager::parseEmojis(std::vector<std::tuple<util::EmoteData, QString>> &parsedWords,
|
||||||
const QString &text)
|
const QString &text)
|
||||||
{
|
{
|
||||||
int lastParsedEmojiEndIndex = 0;
|
int lastParsedEmojiEndIndex = 0;
|
||||||
|
@ -316,11 +320,12 @@ void EmoteManager::parseEmojis(std::vector<std::tuple<EmoteData, QString>> &pars
|
||||||
|
|
||||||
// Create or fetch cached emoji image
|
// Create or fetch cached emoji image
|
||||||
auto emojiImage = this->emojis.getOrAdd(matchedEmoji.code, [this, &url] {
|
auto emojiImage = this->emojis.getOrAdd(matchedEmoji.code, [this, &url] {
|
||||||
return EmoteData(new LazyLoadedImage(url, 0.35, "?????????", "???????????????")); //
|
return util::EmoteData(
|
||||||
|
new LazyLoadedImage(url, 0.35, "?????????", "???????????????")); //
|
||||||
});
|
});
|
||||||
|
|
||||||
// Push the emoji as a word to parsedWords
|
// Push the emoji as a word to parsedWords
|
||||||
parsedWords.push_back(std::tuple<EmoteData, QString>(emojiImage, QString()));
|
parsedWords.push_back(std::tuple<util::EmoteData, QString>(emojiImage, QString()));
|
||||||
|
|
||||||
lastParsedEmojiEndIndex = currentParsedEmojiEndIndex;
|
lastParsedEmojiEndIndex = currentParsedEmojiEndIndex;
|
||||||
|
|
||||||
|
@ -482,7 +487,7 @@ void EmoteManager::loadFFZEmotes()
|
||||||
|
|
||||||
// id is used for lookup
|
// id is used for lookup
|
||||||
// emoteName is used for giving a name to the emote in case it doesn't exist
|
// emoteName is used for giving a name to the emote in case it doesn't exist
|
||||||
EmoteData EmoteManager::getTwitchEmoteById(long id, const QString &emoteName)
|
util::EmoteData EmoteManager::getTwitchEmoteById(long id, const QString &emoteName)
|
||||||
{
|
{
|
||||||
return _twitchEmoteFromCache.getOrAdd(id, [this, &emoteName, &id] {
|
return _twitchEmoteFromCache.getOrAdd(id, [this, &emoteName, &id] {
|
||||||
qreal scale;
|
qreal scale;
|
||||||
|
@ -502,10 +507,10 @@ QString EmoteManager::getTwitchEmoteLink(long id, qreal &scale)
|
||||||
return value.replace("{id}", QString::number(id)).replace("{scale}", "2");
|
return value.replace("{id}", QString::number(id)).replace("{scale}", "2");
|
||||||
}
|
}
|
||||||
|
|
||||||
EmoteData EmoteManager::getCheerImage(long long amount, bool animated)
|
util::EmoteData EmoteManager::getCheerImage(long long amount, bool animated)
|
||||||
{
|
{
|
||||||
// TODO: fix this xD
|
// TODO: fix this xD
|
||||||
return EmoteData();
|
return util::EmoteData();
|
||||||
}
|
}
|
||||||
|
|
||||||
boost::signals2::signal<void()> &EmoteManager::getGifUpdateSignal()
|
boost::signals2::signal<void()> &EmoteManager::getGifUpdateSignal()
|
||||||
|
@ -535,3 +540,4 @@ boost::signals2::signal<void()> &EmoteManager::getGifUpdateSignal()
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace chatterino
|
} // namespace chatterino
|
||||||
|
}
|
||||||
|
|
|
@ -2,12 +2,13 @@
|
||||||
|
|
||||||
#define GIF_FRAME_LENGTH 33
|
#define GIF_FRAME_LENGTH 33
|
||||||
|
|
||||||
#include "concurrentmap.hpp"
|
|
||||||
#include "emojis.hpp"
|
#include "emojis.hpp"
|
||||||
#include "messages/lazyloadedimage.hpp"
|
#include "messages/lazyloadedimage.hpp"
|
||||||
#include "signalvector.hpp"
|
#include "signalvector.hpp"
|
||||||
#include "twitch/emotevalue.hpp"
|
#include "twitch/emotevalue.hpp"
|
||||||
#include "twitch/twitchuser.hpp"
|
#include "twitch/twitchuser.hpp"
|
||||||
|
#include "util/concurrentmap.hpp"
|
||||||
|
#include "util/emotemap.hpp"
|
||||||
|
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
#include <QMutex>
|
#include <QMutex>
|
||||||
|
@ -17,28 +18,15 @@
|
||||||
#include <boost/signals2.hpp>
|
#include <boost/signals2.hpp>
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
namespace singletons {
|
||||||
|
|
||||||
class SettingsManager;
|
class SettingManager;
|
||||||
class WindowManager;
|
class WindowManager;
|
||||||
|
|
||||||
struct EmoteData {
|
|
||||||
EmoteData()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
EmoteData(messages::LazyLoadedImage *_image)
|
|
||||||
: image(_image)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
messages::LazyLoadedImage *image = nullptr;
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef ConcurrentMap<QString, EmoteData> EmoteMap;
|
|
||||||
|
|
||||||
class EmoteManager
|
class EmoteManager
|
||||||
{
|
{
|
||||||
explicit EmoteManager(SettingsManager &manager, WindowManager &windowManager);
|
explicit EmoteManager(singletons::SettingManager &manager,
|
||||||
|
singletons::WindowManager &windowManager);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static EmoteManager &getInstance();
|
static EmoteManager &getInstance();
|
||||||
|
@ -46,21 +34,21 @@ public:
|
||||||
void loadGlobalEmotes();
|
void loadGlobalEmotes();
|
||||||
|
|
||||||
void reloadBTTVChannelEmotes(const QString &channelName,
|
void reloadBTTVChannelEmotes(const QString &channelName,
|
||||||
std::weak_ptr<EmoteMap> channelEmoteMap);
|
std::weak_ptr<util::EmoteMap> channelEmoteMap);
|
||||||
void reloadFFZChannelEmotes(const QString &channelName,
|
void reloadFFZChannelEmotes(const QString &channelName,
|
||||||
std::weak_ptr<EmoteMap> channelEmoteMap);
|
std::weak_ptr<util::EmoteMap> channelEmoteMap);
|
||||||
|
|
||||||
ConcurrentMap<QString, twitch::EmoteValue *> &getTwitchEmotes();
|
util::ConcurrentMap<QString, twitch::EmoteValue *> &getTwitchEmotes();
|
||||||
EmoteMap &getFFZEmotes();
|
util::EmoteMap &getFFZEmotes();
|
||||||
EmoteMap &getChatterinoEmotes();
|
util::EmoteMap &getChatterinoEmotes();
|
||||||
EmoteMap &getBTTVChannelEmoteFromCaches();
|
util::EmoteMap &getBTTVChannelEmoteFromCaches();
|
||||||
EmoteMap &getEmojis();
|
util::EmoteMap &getEmojis();
|
||||||
ConcurrentMap<int, EmoteData> &getFFZChannelEmoteFromCaches();
|
util::ConcurrentMap<int, util::EmoteData> &getFFZChannelEmoteFromCaches();
|
||||||
ConcurrentMap<long, EmoteData> &getTwitchEmoteFromCache();
|
util::ConcurrentMap<long, util::EmoteData> &getTwitchEmoteFromCache();
|
||||||
|
|
||||||
EmoteData getCheerImage(long long int amount, bool animated);
|
util::EmoteData getCheerImage(long long int amount, bool animated);
|
||||||
|
|
||||||
EmoteData getTwitchEmoteById(long int id, const QString &emoteName);
|
util::EmoteData getTwitchEmoteById(long int id, const QString &emoteName);
|
||||||
|
|
||||||
int getGeneration()
|
int getGeneration()
|
||||||
{
|
{
|
||||||
|
@ -75,10 +63,10 @@ public:
|
||||||
boost::signals2::signal<void()> &getGifUpdateSignal();
|
boost::signals2::signal<void()> &getGifUpdateSignal();
|
||||||
|
|
||||||
// Bit badge/emotes?
|
// Bit badge/emotes?
|
||||||
ConcurrentMap<QString, messages::LazyLoadedImage *> miscImageCache;
|
util::ConcurrentMap<QString, messages::LazyLoadedImage *> miscImageCache;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SettingsManager &settingsManager;
|
SettingManager &settingsManager;
|
||||||
WindowManager &windowManager;
|
WindowManager &windowManager;
|
||||||
|
|
||||||
/// Emojis
|
/// Emojis
|
||||||
|
@ -91,12 +79,13 @@ private:
|
||||||
QMap<QChar, QVector<EmojiData>> emojiFirstByte;
|
QMap<QChar, QVector<EmojiData>> emojiFirstByte;
|
||||||
|
|
||||||
// url Emoji-one image
|
// url Emoji-one image
|
||||||
EmoteMap emojis;
|
util::EmoteMap emojis;
|
||||||
|
|
||||||
void loadEmojis();
|
void loadEmojis();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void parseEmojis(std::vector<std::tuple<EmoteData, QString>> &parsedWords, const QString &text);
|
void parseEmojis(std::vector<std::tuple<util::EmoteData, QString>> &parsedWords,
|
||||||
|
const QString &text);
|
||||||
|
|
||||||
QString replaceShortCodes(const QString &text);
|
QString replaceShortCodes(const QString &text);
|
||||||
|
|
||||||
|
@ -123,41 +112,41 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// emote code
|
// emote code
|
||||||
ConcurrentMap<QString, twitch::EmoteValue *> _twitchEmotes;
|
util::ConcurrentMap<QString, twitch::EmoteValue *> _twitchEmotes;
|
||||||
|
|
||||||
// emote id
|
// emote id
|
||||||
ConcurrentMap<long, EmoteData> _twitchEmoteFromCache;
|
util::ConcurrentMap<long, util::EmoteData> _twitchEmoteFromCache;
|
||||||
|
|
||||||
/// BTTV emotes
|
/// BTTV emotes
|
||||||
EmoteMap bttvChannelEmotes;
|
util::EmoteMap bttvChannelEmotes;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ConcurrentMap<QString, EmoteMap> bttvChannels;
|
util::ConcurrentMap<QString, util::EmoteMap> bttvChannels;
|
||||||
EmoteMap bttvGlobalEmotes;
|
util::EmoteMap bttvGlobalEmotes;
|
||||||
SignalVector<std::string> bttvGlobalEmoteCodes;
|
SignalVector<std::string> bttvGlobalEmoteCodes;
|
||||||
// roomID
|
// roomID
|
||||||
std::map<std::string, SignalVector<std::string>> bttvChannelEmoteCodes;
|
std::map<std::string, SignalVector<std::string>> bttvChannelEmoteCodes;
|
||||||
EmoteMap _bttvChannelEmoteFromCaches;
|
util::EmoteMap _bttvChannelEmoteFromCaches;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void loadBTTVEmotes();
|
void loadBTTVEmotes();
|
||||||
|
|
||||||
/// FFZ emotes
|
/// FFZ emotes
|
||||||
EmoteMap ffzChannelEmotes;
|
util::EmoteMap ffzChannelEmotes;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ConcurrentMap<QString, EmoteMap> ffzChannels;
|
util::ConcurrentMap<QString, util::EmoteMap> ffzChannels;
|
||||||
EmoteMap ffzGlobalEmotes;
|
util::EmoteMap ffzGlobalEmotes;
|
||||||
SignalVector<std::string> ffzGlobalEmoteCodes;
|
SignalVector<std::string> ffzGlobalEmoteCodes;
|
||||||
std::map<std::string, SignalVector<std::string>> ffzChannelEmoteCodes;
|
std::map<std::string, SignalVector<std::string>> ffzChannelEmoteCodes;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ConcurrentMap<int, EmoteData> _ffzChannelEmoteFromCaches;
|
util::ConcurrentMap<int, util::EmoteData> _ffzChannelEmoteFromCaches;
|
||||||
|
|
||||||
void loadFFZEmotes();
|
void loadFFZEmotes();
|
||||||
|
|
||||||
/// Chatterino emotes
|
/// Chatterino emotes
|
||||||
EmoteMap _chatterinoEmotes;
|
util::EmoteMap _chatterinoEmotes;
|
||||||
|
|
||||||
boost::signals2::signal<void()> gifUpdateTimerSignal;
|
boost::signals2::signal<void()> gifUpdateTimerSignal;
|
||||||
QTimer gifUpdateTimer;
|
QTimer gifUpdateTimer;
|
||||||
|
@ -170,3 +159,4 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace chatterino
|
} // namespace chatterino
|
||||||
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
namespace singletons {
|
||||||
|
|
||||||
FontManager::FontManager()
|
FontManager::FontManager()
|
||||||
: currentFontFamily("/appearance/currentFontFamily", "Arial")
|
: currentFontFamily("/appearance/currentFontFamily", "Arial")
|
||||||
|
@ -89,3 +90,4 @@ FontManager::Font &FontManager::getCurrentFont(float dpi)
|
||||||
return this->currentFontByDpi.back().second;
|
return this->currentFontByDpi.back().second;
|
||||||
}
|
}
|
||||||
} // namespace chatterino
|
} // namespace chatterino
|
||||||
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
#include <pajlada/signals/signal.hpp>
|
#include <pajlada/signals/signal.hpp>
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
namespace singletons {
|
||||||
|
|
||||||
class FontManager
|
class FontManager
|
||||||
{
|
{
|
||||||
|
@ -133,3 +134,4 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace chatterino
|
} // namespace chatterino
|
||||||
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
namespace singletons {
|
||||||
static void _registerSetting(std::weak_ptr<pajlada::Settings::ISettingData> setting);
|
static void _registerSetting(std::weak_ptr<pajlada::Settings::ISettingData> setting);
|
||||||
|
|
||||||
template <typename Type>
|
template <typename Type>
|
||||||
|
@ -65,3 +66,4 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
#include "singletons/emotemanager.hpp"
|
#include "singletons/emotemanager.hpp"
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
namespace singletons {
|
||||||
CompletionModel::CompletionModel(const QString &_channelName)
|
CompletionModel::CompletionModel(const QString &_channelName)
|
||||||
: channelName(_channelName)
|
: channelName(_channelName)
|
||||||
{
|
{
|
||||||
|
@ -16,7 +17,7 @@ void CompletionModel::refresh()
|
||||||
{
|
{
|
||||||
// debug::Log("[CompletionModel:{}] Refreshing...]", this->channelName);
|
// debug::Log("[CompletionModel:{}] Refreshing...]", this->channelName);
|
||||||
|
|
||||||
auto &emoteManager = EmoteManager::getInstance();
|
auto &emoteManager = singletons::EmoteManager::getInstance();
|
||||||
this->emotes.clear();
|
this->emotes.clear();
|
||||||
|
|
||||||
// User-specific: Twitch Emotes
|
// User-specific: Twitch Emotes
|
||||||
|
@ -60,7 +61,7 @@ void CompletionModel::refresh()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Channel-specific: Usernames
|
// Channel-specific: Usernames
|
||||||
auto c = ChannelManager::getInstance().getTwitchChannel(this->channelName);
|
auto c = singletons::ChannelManager::getInstance().getTwitchChannel(this->channelName);
|
||||||
auto usernames = c->getUsernamesForCompletions();
|
auto usernames = c->getUsernamesForCompletions();
|
||||||
for (const auto &name : usernames) {
|
for (const auto &name : usernames) {
|
||||||
assert(!name.displayName.isEmpty());
|
assert(!name.displayName.isEmpty());
|
||||||
|
@ -86,3 +87,4 @@ void CompletionModel::addString(const QString &str)
|
||||||
this->emotes.push_back(str + " ");
|
this->emotes.push_back(str + " ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
namespace singletons {
|
||||||
class CompletionModel : public QAbstractListModel
|
class CompletionModel : public QAbstractListModel
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -39,3 +40,4 @@ private:
|
||||||
QString channelName;
|
QString channelName;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
using namespace chatterino::messages;
|
using namespace chatterino::messages;
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
namespace singletons {
|
||||||
|
|
||||||
IrcManager::IrcManager(ChannelManager &_channelManager, ResourceManager &_resources,
|
IrcManager::IrcManager(ChannelManager &_channelManager, ResourceManager &_resources,
|
||||||
AccountManager &_accountManager)
|
AccountManager &_accountManager)
|
||||||
|
@ -70,7 +71,8 @@ IrcManager::IrcManager(ChannelManager &_channelManager, ResourceManager &_resour
|
||||||
|
|
||||||
IrcManager &IrcManager::getInstance()
|
IrcManager &IrcManager::getInstance()
|
||||||
{
|
{
|
||||||
static IrcManager instance(ChannelManager::getInstance(), ResourceManager::getInstance(),
|
static IrcManager instance(ChannelManager::getInstance(),
|
||||||
|
singletons::ResourceManager::getInstance(),
|
||||||
AccountManager::getInstance());
|
AccountManager::getInstance());
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
@ -196,7 +198,7 @@ void IrcManager::sendMessage(const QString &channelName, QString message)
|
||||||
static int i = 0;
|
static int i = 0;
|
||||||
|
|
||||||
if (this->writeConnection) {
|
if (this->writeConnection) {
|
||||||
if (SettingsManager::getInstance().allowDuplicateMessages && (++i % 2) == 0) {
|
if (singletons::SettingManager::getInstance().allowDuplicateMessages && (++i % 2) == 0) {
|
||||||
message.append(this->messageSuffix);
|
message.append(this->messageSuffix);
|
||||||
}
|
}
|
||||||
this->writeConnection->sendRaw("PRIVMSG #" + channelName + " :" + message);
|
this->writeConnection->sendRaw("PRIVMSG #" + channelName + " :" + message);
|
||||||
|
@ -528,3 +530,4 @@ Communi::IrcConnection *IrcManager::getReadConnection()
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace chatterino
|
} // namespace chatterino
|
||||||
|
}
|
||||||
|
|
|
@ -17,10 +17,12 @@
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
namespace singletons {
|
||||||
|
|
||||||
class ChannelManager;
|
class ChannelManager;
|
||||||
class ResourceManager;
|
class ResourceManager;
|
||||||
class AccountManager;
|
class AccountManager;
|
||||||
|
class WindowManager;
|
||||||
|
|
||||||
class IrcManager : public QObject
|
class IrcManager : public QObject
|
||||||
{
|
{
|
||||||
|
@ -100,3 +102,4 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace chatterino
|
} // namespace chatterino
|
||||||
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
#include <QPixmap>
|
#include <QPixmap>
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
namespace singletons {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
@ -153,3 +154,4 @@ void ResourceManager::loadChatterinoBadges()
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace chatterino
|
} // namespace chatterino
|
||||||
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
namespace singletons {
|
||||||
|
|
||||||
class ResourceManager
|
class ResourceManager
|
||||||
{
|
{
|
||||||
|
@ -90,3 +91,4 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace chatterino
|
} // namespace chatterino
|
||||||
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
using namespace chatterino::messages;
|
using namespace chatterino::messages;
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
namespace singletons {
|
||||||
|
|
||||||
std::vector<std::weak_ptr<pajlada::Settings::ISettingData>> _settings;
|
std::vector<std::weak_ptr<pajlada::Settings::ISettingData>> _settings;
|
||||||
|
|
||||||
|
@ -16,7 +17,7 @@ void _registerSetting(std::weak_ptr<pajlada::Settings::ISettingData> setting)
|
||||||
_settings.push_back(setting);
|
_settings.push_back(setting);
|
||||||
}
|
}
|
||||||
|
|
||||||
SettingsManager::SettingsManager()
|
SettingManager::SettingManager()
|
||||||
: streamlinkPath("/behaviour/streamlink/path", "")
|
: streamlinkPath("/behaviour/streamlink/path", "")
|
||||||
, preferredQuality("/behaviour/streamlink/quality", "Choose")
|
, preferredQuality("/behaviour/streamlink/quality", "Choose")
|
||||||
, emoteScale(this->settingsItems, "emoteScale", 1.0)
|
, emoteScale(this->settingsItems, "emoteScale", 1.0)
|
||||||
|
@ -39,7 +40,7 @@ SettingsManager::SettingsManager()
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
void SettingsManager::save()
|
void SettingManager::save()
|
||||||
{
|
{
|
||||||
for (auto &item : this->settingsItems) {
|
for (auto &item : this->settingsItems) {
|
||||||
if (item.get().getName() != "highlightProperties") {
|
if (item.get().getName() != "highlightProperties") {
|
||||||
|
@ -62,7 +63,7 @@ void SettingsManager::save()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SettingsManager::load()
|
void SettingManager::load()
|
||||||
{
|
{
|
||||||
for (auto &item : this->settingsItems) {
|
for (auto &item : this->settingsItems) {
|
||||||
if (item.get().getName() != "highlightProperties") {
|
if (item.get().getName() != "highlightProperties") {
|
||||||
|
@ -82,22 +83,22 @@ void SettingsManager::load()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Word::Flags SettingsManager::getWordTypeMask()
|
Word::Flags SettingManager::getWordTypeMask()
|
||||||
{
|
{
|
||||||
return this->wordTypeMask;
|
return this->wordTypeMask;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SettingsManager::isIgnoredEmote(const QString &)
|
bool SettingManager::isIgnoredEmote(const QString &)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
QSettings &SettingsManager::getQSettings()
|
QSettings &SettingManager::getQSettings()
|
||||||
{
|
{
|
||||||
return this->settings;
|
return this->settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SettingsManager::updateWordTypeMask()
|
void SettingManager::updateWordTypeMask()
|
||||||
{
|
{
|
||||||
uint32_t newMaskUint = Word::Text;
|
uint32_t newMaskUint = Word::Text;
|
||||||
|
|
||||||
|
@ -136,7 +137,7 @@ void SettingsManager::updateWordTypeMask()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SettingsManager::saveSnapshot()
|
void SettingManager::saveSnapshot()
|
||||||
{
|
{
|
||||||
rapidjson::Document *d = new rapidjson::Document(rapidjson::kObjectType);
|
rapidjson::Document *d = new rapidjson::Document(rapidjson::kObjectType);
|
||||||
rapidjson::Document::AllocatorType &a = d->GetAllocator();
|
rapidjson::Document::AllocatorType &a = d->GetAllocator();
|
||||||
|
@ -157,7 +158,7 @@ void SettingsManager::saveSnapshot()
|
||||||
debug::Log("hehe: {}", pajlada::Settings::SettingManager::stringify(*d));
|
debug::Log("hehe: {}", pajlada::Settings::SettingManager::stringify(*d));
|
||||||
}
|
}
|
||||||
|
|
||||||
void SettingsManager::recallSnapshot()
|
void SettingManager::recallSnapshot()
|
||||||
{
|
{
|
||||||
if (!this->snapshot) {
|
if (!this->snapshot) {
|
||||||
return;
|
return;
|
||||||
|
@ -184,3 +185,4 @@ void SettingsManager::recallSnapshot()
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace chatterino
|
} // namespace chatterino
|
||||||
|
}
|
||||||
|
|
|
@ -9,10 +9,11 @@
|
||||||
#include <pajlada/settings/settinglistener.hpp>
|
#include <pajlada/settings/settinglistener.hpp>
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
namespace singletons {
|
||||||
|
|
||||||
static void _registerSetting(std::weak_ptr<pajlada::Settings::ISettingData> setting);
|
static void _registerSetting(std::weak_ptr<pajlada::Settings::ISettingData> setting);
|
||||||
|
|
||||||
class SettingsManager : public QObject
|
class SettingManager : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
@ -81,9 +82,9 @@ public:
|
||||||
|
|
||||||
BoolSetting inlineWhispers = {"/whispers/enableInlineWhispers", true};
|
BoolSetting inlineWhispers = {"/whispers/enableInlineWhispers", true};
|
||||||
|
|
||||||
static SettingsManager &getInstance()
|
static SettingManager &getInstance()
|
||||||
{
|
{
|
||||||
static SettingsManager instance;
|
static SettingManager instance;
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
void updateWordTypeMask();
|
void updateWordTypeMask();
|
||||||
|
@ -97,7 +98,7 @@ signals:
|
||||||
private:
|
private:
|
||||||
std::unique_ptr<rapidjson::Document> snapshot;
|
std::unique_ptr<rapidjson::Document> snapshot;
|
||||||
|
|
||||||
SettingsManager();
|
SettingManager();
|
||||||
|
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
std::vector<std::reference_wrapper<BaseSetting>> settingsItems;
|
std::vector<std::reference_wrapper<BaseSetting>> settingsItems;
|
||||||
|
@ -107,3 +108,4 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace chatterino
|
} // namespace chatterino
|
||||||
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
namespace singletons {
|
||||||
|
|
||||||
namespace detail {
|
namespace detail {
|
||||||
|
|
||||||
|
@ -160,3 +161,4 @@ void ThemeManager::normalizeColor(QColor &color)
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace chatterino
|
} // namespace chatterino
|
||||||
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
#include <pajlada/settings/setting.hpp>
|
#include <pajlada/settings/setting.hpp>
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
namespace singletons {
|
||||||
|
|
||||||
class WindowManager;
|
class WindowManager;
|
||||||
|
|
||||||
|
@ -107,3 +108,4 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace chatterino
|
} // namespace chatterino
|
||||||
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include "windowmanager.hpp"
|
#include "windowmanager.hpp"
|
||||||
#include "appdatapath.hpp"
|
#include "appdatapath.hpp"
|
||||||
|
#include "singletons/fontmanager.hpp"
|
||||||
#include "singletons/thememanager.hpp"
|
#include "singletons/thememanager.hpp"
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
@ -7,6 +8,7 @@
|
||||||
#include <boost/foreach.hpp>
|
#include <boost/foreach.hpp>
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
namespace singletons {
|
||||||
WindowManager &WindowManager::getInstance()
|
WindowManager &WindowManager::getInstance()
|
||||||
{
|
{
|
||||||
static WindowManager instance(ThemeManager::getInstance());
|
static WindowManager instance(ThemeManager::getInstance());
|
||||||
|
@ -102,3 +104,4 @@ void WindowManager::save()
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace chatterino
|
} // namespace chatterino
|
||||||
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
#include "widgets/window.hpp"
|
#include "widgets/window.hpp"
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
namespace singletons {
|
||||||
|
|
||||||
class ThemeManager;
|
class ThemeManager;
|
||||||
|
|
||||||
|
@ -41,3 +42,4 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace chatterino
|
} // namespace chatterino
|
||||||
|
}
|
||||||
|
|
|
@ -13,7 +13,9 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
namespace singletons {
|
||||||
class AccountManager;
|
class AccountManager;
|
||||||
|
}
|
||||||
|
|
||||||
namespace twitch {
|
namespace twitch {
|
||||||
|
|
||||||
|
@ -59,7 +61,7 @@ private:
|
||||||
std::vector<std::shared_ptr<twitch::TwitchUser>> users;
|
std::vector<std::shared_ptr<twitch::TwitchUser>> users;
|
||||||
mutable std::mutex mutex;
|
mutable std::mutex mutex;
|
||||||
|
|
||||||
friend class chatterino::AccountManager;
|
friend class chatterino::singletons::AccountManager;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,8 +11,8 @@ namespace twitch {
|
||||||
|
|
||||||
TwitchChannel::TwitchChannel(const QString &channelName)
|
TwitchChannel::TwitchChannel(const QString &channelName)
|
||||||
: Channel(channelName)
|
: Channel(channelName)
|
||||||
, bttvChannelEmotes(new EmoteMap)
|
, bttvChannelEmotes(new util::EmoteMap)
|
||||||
, ffzChannelEmotes(new EmoteMap)
|
, ffzChannelEmotes(new util::EmoteMap)
|
||||||
, subscriptionURL("https://www.twitch.tv/subs/" + name)
|
, subscriptionURL("https://www.twitch.tv/subs/" + name)
|
||||||
, channelURL("https://twitch.tv/" + name)
|
, channelURL("https://twitch.tv/" + name)
|
||||||
, popoutPlayerURL("https://player.twitch.tv/?channel=" + name)
|
, popoutPlayerURL("https://player.twitch.tv/?channel=" + name)
|
||||||
|
@ -64,7 +64,7 @@ void TwitchChannel::setRoomID(const QString &_roomID)
|
||||||
|
|
||||||
void TwitchChannel::reloadChannelEmotes()
|
void TwitchChannel::reloadChannelEmotes()
|
||||||
{
|
{
|
||||||
auto &emoteManager = EmoteManager::getInstance();
|
auto &emoteManager = singletons::EmoteManager::getInstance();
|
||||||
|
|
||||||
debug::Log("[TwitchChannel:{}] Reloading channel emotes", this->name);
|
debug::Log("[TwitchChannel:{}] Reloading channel emotes", this->name);
|
||||||
|
|
||||||
|
@ -74,14 +74,14 @@ void TwitchChannel::reloadChannelEmotes()
|
||||||
|
|
||||||
void TwitchChannel::sendMessage(const QString &message)
|
void TwitchChannel::sendMessage(const QString &message)
|
||||||
{
|
{
|
||||||
auto &emoteManager = EmoteManager::getInstance();
|
auto &emoteManager = singletons::EmoteManager::getInstance();
|
||||||
|
|
||||||
debug::Log("[TwitchChannel:{}] Send message: {}", this->name, message);
|
debug::Log("[TwitchChannel:{}] Send message: {}", this->name, message);
|
||||||
|
|
||||||
// Do last message processing
|
// Do last message processing
|
||||||
QString parsedMessage = emoteManager.replaceShortCodes(message);
|
QString parsedMessage = emoteManager.replaceShortCodes(message);
|
||||||
|
|
||||||
IrcManager::getInstance().sendMessage(this->name, parsedMessage);
|
singletons::IrcManager::getInstance().sendMessage(this->name, parsedMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TwitchChannel::setLive(bool newLiveStatus)
|
void TwitchChannel::setLive(bool newLiveStatus)
|
||||||
|
@ -155,7 +155,7 @@ void TwitchChannel::fetchRecentMessages()
|
||||||
{
|
{
|
||||||
static QString genericURL =
|
static QString genericURL =
|
||||||
"https://tmi.twitch.tv/api/rooms/%1/recent_messages?client_id=" + getDefaultClientID();
|
"https://tmi.twitch.tv/api/rooms/%1/recent_messages?client_id=" + getDefaultClientID();
|
||||||
static auto readConnection = IrcManager::getInstance().getReadConnection();
|
static auto readConnection = singletons::IrcManager::getInstance().getReadConnection();
|
||||||
|
|
||||||
util::twitch::get(genericURL.arg(roomID), QThread::currentThread(), [=](QJsonObject obj) {
|
util::twitch::get(genericURL.arg(roomID), QThread::currentThread(), [=](QJsonObject obj) {
|
||||||
this->dontAddMessages = false;
|
this->dontAddMessages = false;
|
||||||
|
@ -165,7 +165,7 @@ void TwitchChannel::fetchRecentMessages()
|
||||||
QByteArray content = msgArray[i].toString().toUtf8();
|
QByteArray content = msgArray[i].toString().toUtf8();
|
||||||
auto msg = Communi::IrcMessage::fromData(content, readConnection);
|
auto msg = Communi::IrcMessage::fromData(content, readConnection);
|
||||||
auto privMsg = static_cast<Communi::IrcPrivateMessage *>(msg);
|
auto privMsg = static_cast<Communi::IrcPrivateMessage *>(msg);
|
||||||
IrcManager::getInstance().privateMessageReceived(privMsg);
|
singletons::IrcManager::getInstance().privateMessageReceived(privMsg);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "channel.hpp"
|
#include "channel.hpp"
|
||||||
#include "concurrentmap.hpp"
|
|
||||||
#include "singletons/emotemanager.hpp"
|
#include "singletons/emotemanager.hpp"
|
||||||
#include "singletons/ircmanager.hpp"
|
#include "singletons/ircmanager.hpp"
|
||||||
|
#include "util/concurrentmap.hpp"
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
namespace twitch {
|
namespace twitch {
|
||||||
|
@ -22,8 +22,8 @@ public:
|
||||||
bool canSendMessage() const override;
|
bool canSendMessage() const override;
|
||||||
void sendMessage(const QString &message) override;
|
void sendMessage(const QString &message) override;
|
||||||
|
|
||||||
const std::shared_ptr<chatterino::EmoteMap> bttvChannelEmotes;
|
const std::shared_ptr<chatterino::util::EmoteMap> bttvChannelEmotes;
|
||||||
const std::shared_ptr<chatterino::EmoteMap> ffzChannelEmotes;
|
const std::shared_ptr<chatterino::util::EmoteMap> ffzChannelEmotes;
|
||||||
|
|
||||||
const QString subscriptionURL;
|
const QString subscriptionURL;
|
||||||
const QString channelURL;
|
const QString channelURL;
|
||||||
|
|
|
@ -25,14 +25,14 @@ TwitchMessageBuilder::TwitchMessageBuilder(Channel *_channel,
|
||||||
, ircMessage(_ircMessage)
|
, ircMessage(_ircMessage)
|
||||||
, args(_args)
|
, args(_args)
|
||||||
, tags(this->ircMessage->tags())
|
, tags(this->ircMessage->tags())
|
||||||
, usernameColor(ThemeManager::getInstance().SystemMessageColor)
|
, usernameColor(singletons::ThemeManager::getInstance().SystemMessageColor)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
SharedMessage TwitchMessageBuilder::parse()
|
SharedMessage TwitchMessageBuilder::parse()
|
||||||
{
|
{
|
||||||
SettingsManager &settings = SettingsManager::getInstance();
|
singletons::SettingManager &settings = singletons::SettingManager::getInstance();
|
||||||
EmoteManager &emoteManager = EmoteManager::getInstance();
|
singletons::EmoteManager &emoteManager = singletons::EmoteManager::getInstance();
|
||||||
|
|
||||||
this->originalMessage = this->ircMessage->content();
|
this->originalMessage = this->ircMessage->content();
|
||||||
|
|
||||||
|
@ -86,7 +86,7 @@ SharedMessage TwitchMessageBuilder::parse()
|
||||||
}
|
}
|
||||||
|
|
||||||
// twitch emotes
|
// twitch emotes
|
||||||
std::vector<std::pair<long, EmoteData>> twitchEmotes;
|
std::vector<std::pair<long, util::EmoteData>> twitchEmotes;
|
||||||
|
|
||||||
iterator = this->tags.find("emotes");
|
iterator = this->tags.find("emotes");
|
||||||
if (iterator != this->tags.end()) {
|
if (iterator != this->tags.end()) {
|
||||||
|
@ -97,8 +97,8 @@ SharedMessage TwitchMessageBuilder::parse()
|
||||||
}
|
}
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
bool operator()(const std::pair<long, EmoteData> &lhs,
|
bool operator()(const std::pair<long, util::EmoteData> &lhs,
|
||||||
const std::pair<long, EmoteData> &rhs)
|
const std::pair<long, util::EmoteData> &rhs)
|
||||||
{
|
{
|
||||||
return lhs.first < rhs.first;
|
return lhs.first < rhs.first;
|
||||||
}
|
}
|
||||||
|
@ -127,7 +127,7 @@ SharedMessage TwitchMessageBuilder::parse()
|
||||||
currentTwitchEmote->second.image->getName() + QString("\nTwitch Emote")));
|
currentTwitchEmote->second.image->getName() + QString("\nTwitch Emote")));
|
||||||
this->appendWord(
|
this->appendWord(
|
||||||
Word(currentTwitchEmote->second.image->getName(), Word::TwitchEmoteText, textColor,
|
Word(currentTwitchEmote->second.image->getName(), Word::TwitchEmoteText, textColor,
|
||||||
FontManager::Medium, currentTwitchEmote->second.image->getName(),
|
singletons::FontManager::Medium, currentTwitchEmote->second.image->getName(),
|
||||||
currentTwitchEmote->second.image->getName() + QString("\nTwitch Emote")));
|
currentTwitchEmote->second.image->getName() + QString("\nTwitch Emote")));
|
||||||
|
|
||||||
i += split.length() + 1;
|
i += split.length() + 1;
|
||||||
|
@ -137,13 +137,13 @@ SharedMessage TwitchMessageBuilder::parse()
|
||||||
}
|
}
|
||||||
|
|
||||||
// split words
|
// split words
|
||||||
std::vector<std::tuple<EmoteData, QString>> parsed;
|
std::vector<std::tuple<util::EmoteData, QString>> parsed;
|
||||||
|
|
||||||
// Parse emojis and take all non-emojis and put them in parsed as full text-words
|
// Parse emojis and take all non-emojis and put them in parsed as full text-words
|
||||||
emoteManager.parseEmojis(parsed, split);
|
emoteManager.parseEmojis(parsed, split);
|
||||||
|
|
||||||
for (const auto &tuple : parsed) {
|
for (const auto &tuple : parsed) {
|
||||||
const EmoteData &emoteData = std::get<0>(tuple);
|
const util::EmoteData &emoteData = std::get<0>(tuple);
|
||||||
|
|
||||||
if (emoteData.image == nullptr) { // is text
|
if (emoteData.image == nullptr) { // is text
|
||||||
QString string = std::get<1>(tuple);
|
QString string = std::get<1>(tuple);
|
||||||
|
@ -200,7 +200,7 @@ SharedMessage TwitchMessageBuilder::parse()
|
||||||
|
|
||||||
this->appendWord(Word(
|
this->appendWord(Word(
|
||||||
QString("x" + string.mid(5)), Word::BitsAmount, MessageColor(bitsColor),
|
QString("x" + string.mid(5)), Word::BitsAmount, MessageColor(bitsColor),
|
||||||
FontManager::Medium, QString(string.mid(5)), QString("Twitch Cheer"),
|
singletons::FontManager::Medium, QString(string.mid(5)), QString("Twitch Cheer"),
|
||||||
Link(Link::Url,
|
Link(Link::Url,
|
||||||
QString("https://blog.twitch.tv/"
|
QString("https://blog.twitch.tv/"
|
||||||
"introducing-cheering-celebrate-together-da62af41fac6"))));
|
"introducing-cheering-celebrate-together-da62af41fac6"))));
|
||||||
|
@ -230,12 +230,12 @@ SharedMessage TwitchMessageBuilder::parse()
|
||||||
textColor = MessageColor(MessageColor::Link);
|
textColor = MessageColor(MessageColor::Link);
|
||||||
}
|
}
|
||||||
|
|
||||||
this->appendWord(Word(string, Word::Text, textColor, FontManager::Medium, string,
|
this->appendWord(Word(string, Word::Text, textColor, singletons::FontManager::Medium, string,
|
||||||
QString(), link));
|
QString(), link));
|
||||||
} else { // is emoji
|
} else { // is emoji
|
||||||
this->appendWord(Word(emoteData.image, Word::EmojiImage, emoteData.image->getName(),
|
this->appendWord(Word(emoteData.image, Word::EmojiImage, emoteData.image->getName(),
|
||||||
emoteData.image->getTooltip()));
|
emoteData.image->getTooltip()));
|
||||||
Word(emoteData.image->getName(), Word::EmojiText, textColor, FontManager::Medium,
|
Word(emoteData.image->getName(), Word::EmojiText, textColor, singletons::FontManager::Medium,
|
||||||
emoteData.image->getName(), emoteData.image->getTooltip());
|
emoteData.image->getName(), emoteData.image->getTooltip());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -284,7 +284,7 @@ void TwitchMessageBuilder::parseChannelName()
|
||||||
{
|
{
|
||||||
QString channelName("#" + this->channel->name);
|
QString channelName("#" + this->channel->name);
|
||||||
this->appendWord(Word(channelName, Word::Misc, MessageColor(MessageColor::System),
|
this->appendWord(Word(channelName, Word::Misc, MessageColor(MessageColor::System),
|
||||||
FontManager::Medium, QString(channelName), QString(),
|
singletons::FontManager::Medium, QString(channelName), QString(),
|
||||||
Link(Link::Url, this->channel->name + "\n" + this->messageID)));
|
Link(Link::Url, this->channel->name + "\n" + this->messageID)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -372,7 +372,7 @@ void TwitchMessageBuilder::appendUsername()
|
||||||
}
|
}
|
||||||
|
|
||||||
this->appendWord(Word(usernameString, Word::Username, MessageColor(this->usernameColor),
|
this->appendWord(Word(usernameString, Word::Username, MessageColor(this->usernameColor),
|
||||||
FontManager::MediumBold, usernameString, QString(),
|
singletons::FontManager::MediumBold, usernameString, QString(),
|
||||||
Link(Link::UserInfo, this->userName)));
|
Link(Link::UserInfo, this->userName)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -380,7 +380,7 @@ void TwitchMessageBuilder::parseHighlights()
|
||||||
{
|
{
|
||||||
static auto player = new QMediaPlayer;
|
static auto player = new QMediaPlayer;
|
||||||
static QUrl currentPlayerUrl;
|
static QUrl currentPlayerUrl;
|
||||||
SettingsManager &settings = SettingsManager::getInstance();
|
singletons::SettingManager &settings = singletons::SettingManager::getInstance();
|
||||||
static pajlada::Settings::Setting<std::string> currentUser("/accounts/current");
|
static pajlada::Settings::Setting<std::string> currentUser("/accounts/current");
|
||||||
|
|
||||||
QString currentUsername = QString::fromStdString(currentUser.getValue());
|
QString currentUsername = QString::fromStdString(currentUser.getValue());
|
||||||
|
@ -471,7 +471,7 @@ void TwitchMessageBuilder::parseHighlights()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (doAlert) {
|
if (doAlert) {
|
||||||
QApplication::alert(WindowManager::getInstance().getMainWindow().window(), 2500);
|
QApplication::alert(singletons::WindowManager::getInstance().getMainWindow().window(), 2500);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -482,17 +482,17 @@ void TwitchMessageBuilder::appendModerationButtons()
|
||||||
static QString buttonBanTooltip("Ban user");
|
static QString buttonBanTooltip("Ban user");
|
||||||
static QString buttonTimeoutTooltip("Timeout user");
|
static QString buttonTimeoutTooltip("Timeout user");
|
||||||
|
|
||||||
this->appendWord(Word(ResourceManager::getInstance().buttonBan, Word::ButtonBan, QString(),
|
this->appendWord(Word(singletons::ResourceManager::getInstance().buttonBan, Word::ButtonBan, QString(),
|
||||||
buttonBanTooltip, Link(Link::UserBan, ircMessage->account())));
|
buttonBanTooltip, Link(Link::UserBan, ircMessage->account())));
|
||||||
this->appendWord(Word(ResourceManager::getInstance().buttonTimeout, Word::ButtonTimeout, QString(),
|
this->appendWord(Word(singletons::ResourceManager::getInstance().buttonTimeout, Word::ButtonTimeout, QString(),
|
||||||
buttonTimeoutTooltip, Link(Link::UserTimeout, ircMessage->account())));
|
buttonTimeoutTooltip, Link(Link::UserTimeout, ircMessage->account())));
|
||||||
}
|
}
|
||||||
|
|
||||||
void TwitchMessageBuilder::appendTwitchEmote(const Communi::IrcPrivateMessage *ircMessage,
|
void TwitchMessageBuilder::appendTwitchEmote(const Communi::IrcPrivateMessage *ircMessage,
|
||||||
const QString &emote,
|
const QString &emote,
|
||||||
std::vector<std::pair<long int, EmoteData>> &vec)
|
std::vector<std::pair<long int, util::EmoteData>> &vec)
|
||||||
{
|
{
|
||||||
EmoteManager &emoteManager = EmoteManager::getInstance();
|
singletons::EmoteManager &emoteManager = singletons::EmoteManager::getInstance();
|
||||||
if (!emote.contains(':')) {
|
if (!emote.contains(':')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -524,14 +524,14 @@ void TwitchMessageBuilder::appendTwitchEmote(const Communi::IrcPrivateMessage *i
|
||||||
QString name = ircMessage->content().mid(start, end - start + 1);
|
QString name = ircMessage->content().mid(start, end - start + 1);
|
||||||
|
|
||||||
vec.push_back(
|
vec.push_back(
|
||||||
std::pair<long int, EmoteData>(start, emoteManager.getTwitchEmoteById(id, name)));
|
std::pair<long int, util::EmoteData>(start, emoteManager.getTwitchEmoteById(id, name)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TwitchMessageBuilder::tryAppendEmote(QString &emoteString)
|
bool TwitchMessageBuilder::tryAppendEmote(QString &emoteString)
|
||||||
{
|
{
|
||||||
EmoteManager &emoteManager = EmoteManager::getInstance();
|
singletons::EmoteManager &emoteManager = singletons::EmoteManager::getInstance();
|
||||||
EmoteData emoteData;
|
util::EmoteData emoteData;
|
||||||
|
|
||||||
if (emoteManager.bttvGlobalEmotes.tryGet(emoteString, emoteData)) {
|
if (emoteManager.bttvGlobalEmotes.tryGet(emoteString, emoteData)) {
|
||||||
// BTTV Global Emote
|
// BTTV Global Emote
|
||||||
|
@ -555,7 +555,7 @@ bool TwitchMessageBuilder::tryAppendEmote(QString &emoteString)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TwitchMessageBuilder::appendEmote(EmoteData &emoteData)
|
bool TwitchMessageBuilder::appendEmote(util::EmoteData &emoteData)
|
||||||
{
|
{
|
||||||
this->appendWord(Word(emoteData.image, Word::BttvEmoteImage, emoteData.image->getName(),
|
this->appendWord(Word(emoteData.image, Word::BttvEmoteImage, emoteData.image->getName(),
|
||||||
emoteData.image->getTooltip(),
|
emoteData.image->getTooltip(),
|
||||||
|
@ -567,7 +567,7 @@ bool TwitchMessageBuilder::appendEmote(EmoteData &emoteData)
|
||||||
|
|
||||||
void TwitchMessageBuilder::parseTwitchBadges()
|
void TwitchMessageBuilder::parseTwitchBadges()
|
||||||
{
|
{
|
||||||
const auto &channelResources = ResourceManager::getInstance().channels[this->roomID];
|
const auto &channelResources = singletons::ResourceManager::getInstance().channels[this->roomID];
|
||||||
|
|
||||||
auto iterator = this->tags.find("badges");
|
auto iterator = this->tags.find("badges");
|
||||||
|
|
||||||
|
@ -584,7 +584,7 @@ void TwitchMessageBuilder::parseTwitchBadges()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (badge.startsWith("bits/")) {
|
if (badge.startsWith("bits/")) {
|
||||||
if (!ResourceManager::getInstance().dynamicBadgesLoaded) {
|
if (!singletons::ResourceManager::getInstance().dynamicBadgesLoaded) {
|
||||||
// Do nothing
|
// Do nothing
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -593,7 +593,7 @@ void TwitchMessageBuilder::parseTwitchBadges()
|
||||||
std::string versionKey = cheerAmountQS.toStdString();
|
std::string versionKey = cheerAmountQS.toStdString();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
auto &badgeSet = ResourceManager::getInstance().badgeSets.at("bits");
|
auto &badgeSet = singletons::ResourceManager::getInstance().badgeSets.at("bits");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
auto &badgeVersion = badgeSet.versions.at(versionKey);
|
auto &badgeVersion = badgeSet.versions.at(versionKey);
|
||||||
|
@ -609,34 +609,34 @@ void TwitchMessageBuilder::parseTwitchBadges()
|
||||||
debug::Log("No badge set with key bits. Exception: {}", e.what());
|
debug::Log("No badge set with key bits. Exception: {}", e.what());
|
||||||
}
|
}
|
||||||
} else if (badge == "staff/1") {
|
} else if (badge == "staff/1") {
|
||||||
appendWord(Word(ResourceManager::getInstance().badgeStaff, Word::BadgeGlobalAuthority,
|
appendWord(Word(singletons::ResourceManager::getInstance().badgeStaff, Word::BadgeGlobalAuthority,
|
||||||
QString(), QString("Twitch Staff")));
|
QString(), QString("Twitch Staff")));
|
||||||
} else if (badge == "admin/1") {
|
} else if (badge == "admin/1") {
|
||||||
appendWord(Word(ResourceManager::getInstance().badgeAdmin, Word::BadgeGlobalAuthority,
|
appendWord(Word(singletons::ResourceManager::getInstance().badgeAdmin, Word::BadgeGlobalAuthority,
|
||||||
QString(), QString("Twitch Admin")));
|
QString(), QString("Twitch Admin")));
|
||||||
} else if (badge == "global_mod/1") {
|
} else if (badge == "global_mod/1") {
|
||||||
appendWord(Word(ResourceManager::getInstance().badgeGlobalModerator,
|
appendWord(Word(singletons::ResourceManager::getInstance().badgeGlobalModerator,
|
||||||
Word::BadgeGlobalAuthority, QString(), QString("Global Moderator")));
|
Word::BadgeGlobalAuthority, QString(), QString("Global Moderator")));
|
||||||
} else if (badge == "moderator/1") {
|
} else if (badge == "moderator/1") {
|
||||||
// TODO: Implement custom FFZ moderator badge
|
// TODO: Implement custom FFZ moderator badge
|
||||||
appendWord(Word(ResourceManager::getInstance().badgeModerator, Word::BadgeChannelAuthority,
|
appendWord(Word(singletons::ResourceManager::getInstance().badgeModerator, Word::BadgeChannelAuthority,
|
||||||
QString(),
|
QString(),
|
||||||
QString("Channel Moderator"))); // custom badge
|
QString("Channel Moderator"))); // custom badge
|
||||||
} else if (badge == "turbo/1") {
|
} else if (badge == "turbo/1") {
|
||||||
appendWord(Word(ResourceManager::getInstance().badgeTurbo, Word::BadgeVanity, QString(),
|
appendWord(Word(singletons::ResourceManager::getInstance().badgeTurbo, Word::BadgeVanity, QString(),
|
||||||
QString("Turbo Subscriber")));
|
QString("Turbo Subscriber")));
|
||||||
} else if (badge == "broadcaster/1") {
|
} else if (badge == "broadcaster/1") {
|
||||||
appendWord(Word(ResourceManager::getInstance().badgeBroadcaster, Word::BadgeChannelAuthority,
|
appendWord(Word(singletons::ResourceManager::getInstance().badgeBroadcaster, Word::BadgeChannelAuthority,
|
||||||
QString(), QString("Channel Broadcaster")));
|
QString(), QString("Channel Broadcaster")));
|
||||||
} else if (badge == "premium/1") {
|
} else if (badge == "premium/1") {
|
||||||
appendWord(Word(ResourceManager::getInstance().badgePremium, Word::BadgeVanity, QString(),
|
appendWord(Word(singletons::ResourceManager::getInstance().badgePremium, Word::BadgeVanity, QString(),
|
||||||
QString("Twitch Prime")));
|
QString("Twitch Prime")));
|
||||||
|
|
||||||
} else if (badge.startsWith("partner/")) {
|
} else if (badge.startsWith("partner/")) {
|
||||||
int index = badge.midRef(8).toInt();
|
int index = badge.midRef(8).toInt();
|
||||||
switch (index) {
|
switch (index) {
|
||||||
case 1: {
|
case 1: {
|
||||||
appendWord(Word(ResourceManager::getInstance().badgeVerified, Word::BadgeVanity,
|
appendWord(Word(singletons::ResourceManager::getInstance().badgeVerified, Word::BadgeVanity,
|
||||||
QString(), "Twitch Verified"));
|
QString(), "Twitch Verified"));
|
||||||
} break;
|
} break;
|
||||||
default: {
|
default: {
|
||||||
|
@ -652,7 +652,7 @@ void TwitchMessageBuilder::parseTwitchBadges()
|
||||||
auto badgeSetIt = channelResources.badgeSets.find("subscriber");
|
auto badgeSetIt = channelResources.badgeSets.find("subscriber");
|
||||||
if (badgeSetIt == channelResources.badgeSets.end()) {
|
if (badgeSetIt == channelResources.badgeSets.end()) {
|
||||||
// Fall back to default badge
|
// Fall back to default badge
|
||||||
appendWord(Word(ResourceManager::getInstance().badgeSubscriber,
|
appendWord(Word(singletons::ResourceManager::getInstance().badgeSubscriber,
|
||||||
Word::Flags::BadgeSubscription, QString(),
|
Word::Flags::BadgeSubscription, QString(),
|
||||||
QString("Twitch Subscriber")));
|
QString("Twitch Subscriber")));
|
||||||
continue;
|
continue;
|
||||||
|
@ -666,7 +666,7 @@ void TwitchMessageBuilder::parseTwitchBadges()
|
||||||
|
|
||||||
if (badgeVersionIt == badgeSet.versions.end()) {
|
if (badgeVersionIt == badgeSet.versions.end()) {
|
||||||
// Fall back to default badge
|
// Fall back to default badge
|
||||||
appendWord(Word(ResourceManager::getInstance().badgeSubscriber,
|
appendWord(Word(singletons::ResourceManager::getInstance().badgeSubscriber,
|
||||||
Word::Flags::BadgeSubscription, QString(),
|
Word::Flags::BadgeSubscription, QString(),
|
||||||
QString("Twitch Subscriber")));
|
QString("Twitch Subscriber")));
|
||||||
continue;
|
continue;
|
||||||
|
@ -677,7 +677,7 @@ void TwitchMessageBuilder::parseTwitchBadges()
|
||||||
appendWord(Word(badgeVersion.badgeImage1x, Word::Flags::BadgeSubscription, QString(),
|
appendWord(Word(badgeVersion.badgeImage1x, Word::Flags::BadgeSubscription, QString(),
|
||||||
QString("Twitch " + QString::fromStdString(badgeVersion.title))));
|
QString("Twitch " + QString::fromStdString(badgeVersion.title))));
|
||||||
} else {
|
} else {
|
||||||
if (!ResourceManager::getInstance().dynamicBadgesLoaded) {
|
if (!singletons::ResourceManager::getInstance().dynamicBadgesLoaded) {
|
||||||
// Do nothing
|
// Do nothing
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -695,7 +695,7 @@ void TwitchMessageBuilder::parseTwitchBadges()
|
||||||
std::string versionKey = parts[1].toStdString();
|
std::string versionKey = parts[1].toStdString();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
auto &badgeSet = ResourceManager::getInstance().badgeSets.at(badgeSetKey);
|
auto &badgeSet = singletons::ResourceManager::getInstance().badgeSets.at(badgeSetKey);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
auto &badgeVersion = badgeSet.versions.at(versionKey);
|
auto &badgeVersion = badgeSet.versions.at(versionKey);
|
||||||
|
@ -717,7 +717,7 @@ void TwitchMessageBuilder::parseTwitchBadges()
|
||||||
|
|
||||||
void TwitchMessageBuilder::parseChatterinoBadges()
|
void TwitchMessageBuilder::parseChatterinoBadges()
|
||||||
{
|
{
|
||||||
auto &badges = ResourceManager::getInstance().chatterinoBadges;
|
auto &badges = singletons::ResourceManager::getInstance().chatterinoBadges;
|
||||||
auto it = badges.find(this->userName.toStdString());
|
auto it = badges.find(this->userName.toStdString());
|
||||||
|
|
||||||
if (it == badges.end()) {
|
if (it == badges.end()) {
|
||||||
|
|
|
@ -10,10 +10,7 @@
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
||||||
class WindowManager;
|
|
||||||
class Channel;
|
class Channel;
|
||||||
class ThemeManager;
|
|
||||||
|
|
||||||
namespace twitch {
|
namespace twitch {
|
||||||
class TwitchChannel;
|
class TwitchChannel;
|
||||||
|
@ -61,9 +58,9 @@ private:
|
||||||
|
|
||||||
void appendModerationButtons();
|
void appendModerationButtons();
|
||||||
void appendTwitchEmote(const Communi::IrcPrivateMessage *ircMessage, const QString &emote,
|
void appendTwitchEmote(const Communi::IrcPrivateMessage *ircMessage, const QString &emote,
|
||||||
std::vector<std::pair<long, EmoteData>> &vec);
|
std::vector<std::pair<long, util::EmoteData>> &vec);
|
||||||
bool tryAppendEmote(QString &emoteString);
|
bool tryAppendEmote(QString &emoteString);
|
||||||
bool appendEmote(EmoteData &emoteData);
|
bool appendEmote(util::EmoteData &emoteData);
|
||||||
|
|
||||||
void parseTwitchBadges();
|
void parseTwitchBadges();
|
||||||
void parseChatterinoBadges();
|
void parseChatterinoBadges();
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
namespace util {
|
||||||
|
|
||||||
template <typename TKey, typename TValue>
|
template <typename TKey, typename TValue>
|
||||||
class ConcurrentMap
|
class ConcurrentMap
|
||||||
|
@ -84,3 +85,4 @@ private:
|
||||||
QMap<TKey, TValue> data;
|
QMap<TKey, TValue> data;
|
||||||
};
|
};
|
||||||
} // namespace chatterino
|
} // namespace chatterino
|
||||||
|
}
|
24
src/util/emotemap.hpp
Normal file
24
src/util/emotemap.hpp
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "messages/lazyloadedimage.hpp"
|
||||||
|
#include "util/concurrentmap.hpp"
|
||||||
|
|
||||||
|
namespace chatterino {
|
||||||
|
namespace util {
|
||||||
|
|
||||||
|
struct EmoteData {
|
||||||
|
EmoteData()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
EmoteData(messages::LazyLoadedImage *_image)
|
||||||
|
: image(_image)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
messages::LazyLoadedImage *image = nullptr;
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef ConcurrentMap<QString, EmoteData> EmoteMap;
|
||||||
|
}
|
||||||
|
}
|
|
@ -133,7 +133,7 @@ static void put(QUrl url, std::function<void(QJsonObject)> successCallback)
|
||||||
{
|
{
|
||||||
QNetworkRequest request(url);
|
QNetworkRequest request(url);
|
||||||
|
|
||||||
auto &accountManager = AccountManager::getInstance();
|
auto &accountManager = singletons::AccountManager::getInstance();
|
||||||
auto currentTwitchUser = accountManager.Twitch.getCurrent();
|
auto currentTwitchUser = accountManager.Twitch.getCurrent();
|
||||||
QByteArray oauthToken;
|
QByteArray oauthToken;
|
||||||
if (currentTwitchUser) {
|
if (currentTwitchUser) {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#include "widgets/accountpopup.hpp"
|
#include "widgets/accountpopup.hpp"
|
||||||
#include "singletons/accountmanager.hpp"
|
|
||||||
#include "channel.hpp"
|
#include "channel.hpp"
|
||||||
#include "credentials.hpp"
|
#include "credentials.hpp"
|
||||||
|
#include "singletons/accountmanager.hpp"
|
||||||
#include "singletons/settingsmanager.hpp"
|
#include "singletons/settingsmanager.hpp"
|
||||||
#include "ui_accountpopupform.h"
|
#include "ui_accountpopupform.h"
|
||||||
#include "util/urlfetch.hpp"
|
#include "util/urlfetch.hpp"
|
||||||
|
@ -32,7 +32,7 @@ AccountPopupWidget::AccountPopupWidget(std::shared_ptr<Channel> _channel)
|
||||||
|
|
||||||
this->resize(0, 0);
|
this->resize(0, 0);
|
||||||
|
|
||||||
SettingsManager &settings = SettingsManager::getInstance();
|
singletons::SettingManager &settings = singletons::SettingManager::getInstance();
|
||||||
|
|
||||||
this->permission = permissions::User;
|
this->permission = permissions::User;
|
||||||
for (auto button : this->ui->profileLayout->findChildren<QPushButton *>()) {
|
for (auto button : this->ui->profileLayout->findChildren<QPushButton *>()) {
|
||||||
|
@ -59,7 +59,7 @@ AccountPopupWidget::AccountPopupWidget(std::shared_ptr<Channel> _channel)
|
||||||
this->sendCommand(this->ui->mod, "/mod ");
|
this->sendCommand(this->ui->mod, "/mod ");
|
||||||
this->sendCommand(this->ui->unMod, "/unmod ");
|
this->sendCommand(this->ui->unMod, "/unmod ");
|
||||||
|
|
||||||
auto &accountManager = AccountManager::getInstance();
|
auto &accountManager = singletons::AccountManager::getInstance();
|
||||||
QString userId;
|
QString userId;
|
||||||
QString userNickname;
|
QString userNickname;
|
||||||
auto currentTwitchUser = accountManager.Twitch.getCurrent();
|
auto currentTwitchUser = accountManager.Twitch.getCurrent();
|
||||||
|
@ -185,7 +185,8 @@ void AccountPopupWidget::loadAvatar(const QUrl &avatarUrl)
|
||||||
|
|
||||||
void AccountPopupWidget::updatePermissions()
|
void AccountPopupWidget::updatePermissions()
|
||||||
{
|
{
|
||||||
AccountManager &accountManager = AccountManager::getInstance();
|
singletons::AccountManager &accountManager = singletons::AccountManager::getInstance();
|
||||||
|
|
||||||
auto currentTwitchUser = accountManager.Twitch.getCurrent();
|
auto currentTwitchUser = accountManager.Twitch.getCurrent();
|
||||||
if (!currentTwitchUser) {
|
if (!currentTwitchUser) {
|
||||||
// No twitch user set (should never happen)
|
// No twitch user set (should never happen)
|
||||||
|
@ -242,7 +243,7 @@ void AccountPopupWidget::focusOutEvent(QFocusEvent *)
|
||||||
|
|
||||||
void AccountPopupWidget::showEvent(QShowEvent *)
|
void AccountPopupWidget::showEvent(QShowEvent *)
|
||||||
{
|
{
|
||||||
AccountManager &accountManager = AccountManager::getInstance();
|
singletons::AccountManager &accountManager = singletons::AccountManager::getInstance();
|
||||||
auto currentTwitchUser = accountManager.Twitch.getCurrent();
|
auto currentTwitchUser = accountManager.Twitch.getCurrent();
|
||||||
if (!currentTwitchUser) {
|
if (!currentTwitchUser) {
|
||||||
// No twitch user set (should never happen)
|
// No twitch user set (should never happen)
|
||||||
|
@ -266,7 +267,8 @@ void AccountPopupWidget::showEvent(QShowEvent *)
|
||||||
this->updateButtons(this->ui->ownerLayout, false);
|
this->updateButtons(this->ui->ownerLayout, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString blacklisted = SettingsManager::getInstance().highlightUserBlacklist.getnonConst();
|
QString blacklisted =
|
||||||
|
singletons::SettingManager::getInstance().highlightUserBlacklist.getnonConst();
|
||||||
QStringList list = blacklisted.split("\n", QString::SkipEmptyParts);
|
QStringList list = blacklisted.split("\n", QString::SkipEmptyParts);
|
||||||
if (list.contains(this->ui->lblUsername->text(), Qt::CaseInsensitive)) {
|
if (list.contains(this->ui->lblUsername->text(), Qt::CaseInsensitive)) {
|
||||||
this->ui->disableHighlights->hide();
|
this->ui->disableHighlights->hide();
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "basewidget.hpp"
|
#include "basewidget.hpp"
|
||||||
#include "concurrentmap.hpp"
|
#include "util/concurrentmap.hpp"
|
||||||
#include "twitch/twitchchannel.hpp"
|
#include "twitch/twitchchannel.hpp"
|
||||||
|
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
|
@ -52,7 +52,7 @@ private:
|
||||||
QString userID;
|
QString userID;
|
||||||
QPixmap avatar;
|
QPixmap avatar;
|
||||||
|
|
||||||
ConcurrentMap<QString, QPixmap> avatarMap;
|
util::ConcurrentMap<QString, QPixmap> avatarMap;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void focusOutEvent(QFocusEvent *event) override;
|
virtual void focusOutEvent(QFocusEvent *event) override;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#include "accountswitchwidget.hpp"
|
#include "accountswitchwidget.hpp"
|
||||||
#include "singletons/accountmanager.hpp"
|
|
||||||
#include "const.hpp"
|
#include "const.hpp"
|
||||||
|
#include "singletons/accountmanager.hpp"
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
namespace widgets {
|
namespace widgets {
|
||||||
|
@ -8,20 +8,22 @@ namespace widgets {
|
||||||
AccountSwitchWidget::AccountSwitchWidget(QWidget *parent)
|
AccountSwitchWidget::AccountSwitchWidget(QWidget *parent)
|
||||||
: QListWidget(parent)
|
: QListWidget(parent)
|
||||||
{
|
{
|
||||||
|
singletons::AccountManager &accountManager = singletons::AccountManager::getInstance();
|
||||||
|
|
||||||
this->addItem(ANONYMOUS_USERNAME_LABEL);
|
this->addItem(ANONYMOUS_USERNAME_LABEL);
|
||||||
|
|
||||||
for (const auto &userName : AccountManager::getInstance().Twitch.getUsernames()) {
|
for (const auto &userName : accountManager.Twitch.getUsernames()) {
|
||||||
this->addItem(userName);
|
this->addItem(userName);
|
||||||
}
|
}
|
||||||
|
|
||||||
AccountManager::getInstance().Twitch.userListUpdated.connect([this]() {
|
accountManager.Twitch.userListUpdated.connect([this, &accountManager]() {
|
||||||
this->blockSignals(true);
|
this->blockSignals(true);
|
||||||
|
|
||||||
this->clear();
|
this->clear();
|
||||||
|
|
||||||
this->addItem(ANONYMOUS_USERNAME_LABEL);
|
this->addItem(ANONYMOUS_USERNAME_LABEL);
|
||||||
|
|
||||||
for (const auto &userName : AccountManager::getInstance().Twitch.getUsernames()) {
|
for (const auto &userName : accountManager.Twitch.getUsernames()) {
|
||||||
this->addItem(userName);
|
this->addItem(userName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,13 +34,13 @@ AccountSwitchWidget::AccountSwitchWidget(QWidget *parent)
|
||||||
|
|
||||||
this->refreshSelection();
|
this->refreshSelection();
|
||||||
|
|
||||||
QObject::connect(this, &QListWidget::clicked, [this] {
|
QObject::connect(this, &QListWidget::clicked, [this, &accountManager] {
|
||||||
if (!this->selectedItems().isEmpty()) {
|
if (!this->selectedItems().isEmpty()) {
|
||||||
QString newUsername = this->currentItem()->text();
|
QString newUsername = this->currentItem()->text();
|
||||||
if (newUsername.compare(ANONYMOUS_USERNAME_LABEL, Qt::CaseInsensitive) == 0) {
|
if (newUsername.compare(ANONYMOUS_USERNAME_LABEL, Qt::CaseInsensitive) == 0) {
|
||||||
AccountManager::getInstance().Twitch.currentUsername = "";
|
accountManager.Twitch.currentUsername = "";
|
||||||
} else {
|
} else {
|
||||||
AccountManager::getInstance().Twitch.currentUsername = newUsername.toStdString();
|
accountManager.Twitch.currentUsername = newUsername.toStdString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -55,7 +57,7 @@ void AccountSwitchWidget::refreshSelection()
|
||||||
|
|
||||||
// Select the currently logged in user
|
// Select the currently logged in user
|
||||||
if (this->count() > 0) {
|
if (this->count() > 0) {
|
||||||
auto currentUser = AccountManager::getInstance().Twitch.getCurrent();
|
auto currentUser = singletons::AccountManager::getInstance().Twitch.getCurrent();
|
||||||
|
|
||||||
if (currentUser->isAnon()) {
|
if (currentUser->isAnon()) {
|
||||||
this->setCurrentRow(0);
|
this->setCurrentRow(0);
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
namespace widgets {
|
namespace widgets {
|
||||||
|
|
||||||
BaseWidget::BaseWidget(ThemeManager &_themeManager, QWidget *parent)
|
BaseWidget::BaseWidget(singletons::ThemeManager &_themeManager, QWidget *parent)
|
||||||
: QWidget(parent)
|
: QWidget(parent)
|
||||||
, themeManager(_themeManager)
|
, themeManager(_themeManager)
|
||||||
{
|
{
|
||||||
|
@ -21,14 +21,14 @@ BaseWidget::BaseWidget(ThemeManager &_themeManager, QWidget *parent)
|
||||||
|
|
||||||
BaseWidget::BaseWidget(BaseWidget *parent)
|
BaseWidget::BaseWidget(BaseWidget *parent)
|
||||||
: QWidget(parent)
|
: QWidget(parent)
|
||||||
, themeManager(ThemeManager::getInstance())
|
, themeManager(singletons::ThemeManager::getInstance())
|
||||||
{
|
{
|
||||||
this->init();
|
this->init();
|
||||||
}
|
}
|
||||||
|
|
||||||
BaseWidget::BaseWidget(QWidget *parent)
|
BaseWidget::BaseWidget(QWidget *parent)
|
||||||
: QWidget(parent)
|
: QWidget(parent)
|
||||||
, themeManager(ThemeManager::getInstance())
|
, themeManager(singletons::ThemeManager::getInstance())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,7 +72,7 @@ void BaseWidget::initAsWindow()
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (SettingsManager::getInstance().windowTopMost.getValue()) {
|
if (singletons::SettingManager::getInstance().windowTopMost.getValue()) {
|
||||||
this->setWindowFlags(this->windowFlags() | Qt::WindowStaysOnTopHint);
|
this->setWindowFlags(this->windowFlags() | Qt::WindowStaysOnTopHint);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,8 +3,9 @@
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
namespace singletons {
|
||||||
class ThemeManager;
|
class ThemeManager;
|
||||||
|
}
|
||||||
|
|
||||||
namespace widgets {
|
namespace widgets {
|
||||||
|
|
||||||
|
@ -13,13 +14,13 @@ class BaseWidget : public QWidget
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit BaseWidget(ThemeManager &_themeManager, QWidget *parent);
|
explicit BaseWidget(singletons::ThemeManager &_themeManager, QWidget *parent);
|
||||||
|
|
||||||
explicit BaseWidget(BaseWidget *parent);
|
explicit BaseWidget(BaseWidget *parent);
|
||||||
|
|
||||||
explicit BaseWidget(QWidget *parent = nullptr);
|
explicit BaseWidget(QWidget *parent = nullptr);
|
||||||
|
|
||||||
ThemeManager &themeManager;
|
singletons::ThemeManager &themeManager;
|
||||||
|
|
||||||
float getDpiMultiplier();
|
float getDpiMultiplier();
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ using namespace chatterino::messages;
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
namespace widgets {
|
namespace widgets {
|
||||||
|
|
||||||
EmotePopup::EmotePopup(ThemeManager &themeManager)
|
EmotePopup::EmotePopup(singletons::ThemeManager &themeManager)
|
||||||
: BaseWidget(themeManager, 0)
|
: BaseWidget(themeManager, 0)
|
||||||
{
|
{
|
||||||
this->initAsWindow();
|
this->initAsWindow();
|
||||||
|
@ -44,12 +44,12 @@ void EmotePopup::loadChannel(std::shared_ptr<Channel> _channel)
|
||||||
|
|
||||||
std::shared_ptr<Channel> emoteChannel(new Channel(""));
|
std::shared_ptr<Channel> emoteChannel(new Channel(""));
|
||||||
|
|
||||||
auto addEmotes = [&](EmoteMap &map, const QString &title, const QString &emoteDesc) {
|
auto addEmotes = [&](util::EmoteMap &map, const QString &title, const QString &emoteDesc) {
|
||||||
// TITLE
|
// TITLE
|
||||||
messages::MessageBuilder builder1;
|
messages::MessageBuilder builder1;
|
||||||
|
|
||||||
builder1.appendWord(Word(title, Word::Flags::Text, MessageColor(MessageColor::Text),
|
builder1.appendWord(Word(title, Word::Flags::Text, MessageColor(MessageColor::Text),
|
||||||
FontManager::Medium, QString(), QString()));
|
singletons::FontManager::Medium, QString(), QString()));
|
||||||
|
|
||||||
builder1.getMessage()->centered = true;
|
builder1.getMessage()->centered = true;
|
||||||
emoteChannel->addMessage(builder1.getMessage());
|
emoteChannel->addMessage(builder1.getMessage());
|
||||||
|
@ -58,7 +58,7 @@ void EmotePopup::loadChannel(std::shared_ptr<Channel> _channel)
|
||||||
messages::MessageBuilder builder2;
|
messages::MessageBuilder builder2;
|
||||||
builder2.getMessage()->centered = true;
|
builder2.getMessage()->centered = true;
|
||||||
|
|
||||||
map.each([&](const QString &key, const EmoteData &value) {
|
map.each([&](const QString &key, const util::EmoteData &value) {
|
||||||
builder2.appendWord(Word(value.image, Word::Flags::AlwaysShow, key, emoteDesc,
|
builder2.appendWord(Word(value.image, Word::Flags::AlwaysShow, key, emoteDesc,
|
||||||
Link(Link::Type::InsertText, key)));
|
Link(Link::Type::InsertText, key)));
|
||||||
});
|
});
|
||||||
|
@ -66,7 +66,7 @@ void EmotePopup::loadChannel(std::shared_ptr<Channel> _channel)
|
||||||
emoteChannel->addMessage(builder2.getMessage());
|
emoteChannel->addMessage(builder2.getMessage());
|
||||||
};
|
};
|
||||||
|
|
||||||
EmoteManager &emoteManager = EmoteManager::getInstance();
|
singletons::EmoteManager &emoteManager = singletons::EmoteManager::getInstance();
|
||||||
|
|
||||||
addEmotes(emoteManager.bttvGlobalEmotes, "BetterTTV Global Emotes", "BetterTTV Global Emote");
|
addEmotes(emoteManager.bttvGlobalEmotes, "BetterTTV Global Emotes", "BetterTTV Global Emote");
|
||||||
addEmotes(*channel->bttvChannelEmotes.get(), "BetterTTV Channel Emotes",
|
addEmotes(*channel->bttvChannelEmotes.get(), "BetterTTV Channel Emotes",
|
||||||
|
@ -81,7 +81,7 @@ void EmotePopup::loadChannel(std::shared_ptr<Channel> _channel)
|
||||||
|
|
||||||
void EmotePopup::loadEmojis()
|
void EmotePopup::loadEmojis()
|
||||||
{
|
{
|
||||||
EmoteMap &emojis = EmoteManager::getInstance().getEmojis();
|
util::EmoteMap &emojis = singletons::EmoteManager::getInstance().getEmojis();
|
||||||
|
|
||||||
std::shared_ptr<Channel> emojiChannel(new Channel(""));
|
std::shared_ptr<Channel> emojiChannel(new Channel(""));
|
||||||
|
|
||||||
|
@ -89,7 +89,7 @@ void EmotePopup::loadEmojis()
|
||||||
messages::MessageBuilder builder1;
|
messages::MessageBuilder builder1;
|
||||||
|
|
||||||
builder1.appendWord(Word("emojis", Word::Flags::Text, MessageColor(MessageColor::Text),
|
builder1.appendWord(Word("emojis", Word::Flags::Text, MessageColor(MessageColor::Text),
|
||||||
FontManager::Medium, QString(), QString()));
|
singletons::FontManager::Medium, QString(), QString()));
|
||||||
|
|
||||||
builder1.getMessage()->centered = true;
|
builder1.getMessage()->centered = true;
|
||||||
emojiChannel->addMessage(builder1.getMessage());
|
emojiChannel->addMessage(builder1.getMessage());
|
||||||
|
@ -97,7 +97,7 @@ void EmotePopup::loadEmojis()
|
||||||
// emojis
|
// emojis
|
||||||
messages::MessageBuilder builder;
|
messages::MessageBuilder builder;
|
||||||
builder.getMessage()->centered = true;
|
builder.getMessage()->centered = true;
|
||||||
emojis.each([this, &builder](const QString &key, const EmoteData &value) {
|
emojis.each([this, &builder](const QString &key, const util::EmoteData &value) {
|
||||||
builder.appendWord(Word(value.image, Word::Flags::AlwaysShow, key, "emoji",
|
builder.appendWord(Word(value.image, Word::Flags::AlwaysShow, key, "emoji",
|
||||||
Link(Link::Type::InsertText, key)));
|
Link(Link::Type::InsertText, key)));
|
||||||
});
|
});
|
||||||
|
|
|
@ -10,7 +10,7 @@ namespace widgets {
|
||||||
class EmotePopup : public BaseWidget
|
class EmotePopup : public BaseWidget
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit EmotePopup(ThemeManager &);
|
explicit EmotePopup(singletons::ThemeManager &);
|
||||||
|
|
||||||
void loadChannel(std::shared_ptr<Channel> channel);
|
void loadChannel(std::shared_ptr<Channel> channel);
|
||||||
void loadEmojis();
|
void loadEmojis();
|
||||||
|
|
|
@ -39,7 +39,8 @@ ChannelView::ChannelView(BaseWidget *parent)
|
||||||
#endif
|
#endif
|
||||||
this->setMouseTracking(true);
|
this->setMouseTracking(true);
|
||||||
|
|
||||||
QObject::connect(&SettingsManager::getInstance(), &SettingsManager::wordTypeMaskChanged, this,
|
QObject::connect(&singletons::SettingManager::getInstance(),
|
||||||
|
&singletons::SettingManager::wordTypeMaskChanged, this,
|
||||||
&ChannelView::wordTypeMaskChanged);
|
&ChannelView::wordTypeMaskChanged);
|
||||||
|
|
||||||
this->scrollBar.getCurrentValueChanged().connect([this] {
|
this->scrollBar.getCurrentValueChanged().connect([this] {
|
||||||
|
@ -51,7 +52,7 @@ ChannelView::ChannelView(BaseWidget *parent)
|
||||||
this->queueUpdate();
|
this->queueUpdate();
|
||||||
});
|
});
|
||||||
|
|
||||||
WindowManager &windowManager = WindowManager::getInstance();
|
singletons::WindowManager &windowManager = singletons::WindowManager::getInstance();
|
||||||
|
|
||||||
this->repaintGifsConnection =
|
this->repaintGifsConnection =
|
||||||
windowManager.repaintGifs.connect([&] { this->updateGifEmotes(); });
|
windowManager.repaintGifs.connect([&] { this->updateGifEmotes(); });
|
||||||
|
@ -62,9 +63,10 @@ ChannelView::ChannelView(BaseWidget *parent)
|
||||||
this->goToBottom->getLabel().setText("Jump to bottom");
|
this->goToBottom->getLabel().setText("Jump to bottom");
|
||||||
this->goToBottom->setVisible(false);
|
this->goToBottom->setVisible(false);
|
||||||
|
|
||||||
this->managedConnections.emplace_back(FontManager::getInstance().fontChanged.connect([this] {
|
this->managedConnections.emplace_back(
|
||||||
this->layoutMessages(); //
|
singletons::FontManager::getInstance().fontChanged.connect([this] {
|
||||||
}));
|
this->layoutMessages(); //
|
||||||
|
}));
|
||||||
|
|
||||||
connect(goToBottom, &RippleEffectLabel::clicked, this,
|
connect(goToBottom, &RippleEffectLabel::clicked, this,
|
||||||
[this] { QTimer::singleShot(180, [this] { this->scrollBar.scrollToBottom(); }); });
|
[this] { QTimer::singleShot(180, [this] { this->scrollBar.scrollToBottom(); }); });
|
||||||
|
@ -82,8 +84,9 @@ ChannelView::ChannelView(BaseWidget *parent)
|
||||||
|
|
||||||
ChannelView::~ChannelView()
|
ChannelView::~ChannelView()
|
||||||
{
|
{
|
||||||
QObject::disconnect(&SettingsManager::getInstance(), &SettingsManager::wordTypeMaskChanged,
|
QObject::disconnect(&singletons::SettingManager::getInstance(),
|
||||||
this, &ChannelView::wordTypeMaskChanged);
|
&singletons::SettingManager::wordTypeMaskChanged, this,
|
||||||
|
&ChannelView::wordTypeMaskChanged);
|
||||||
this->messageAppendedConnection.disconnect();
|
this->messageAppendedConnection.disconnect();
|
||||||
this->messageRemovedConnection.disconnect();
|
this->messageRemovedConnection.disconnect();
|
||||||
this->repaintGifsConnection.disconnect();
|
this->repaintGifsConnection.disconnect();
|
||||||
|
@ -776,7 +779,7 @@ void ChannelView::drawMessageSelection(QPainter &painter, messages::MessageRef *
|
||||||
void ChannelView::wheelEvent(QWheelEvent *event)
|
void ChannelView::wheelEvent(QWheelEvent *event)
|
||||||
{
|
{
|
||||||
if (this->scrollBar.isVisible()) {
|
if (this->scrollBar.isVisible()) {
|
||||||
float mouseMultiplier = SettingsManager::getInstance().mouseScrollMultiplier;
|
float mouseMultiplier = singletons::SettingManager::getInstance().mouseScrollMultiplier;
|
||||||
|
|
||||||
this->scrollBar.setDesiredValue(
|
this->scrollBar.setDesiredValue(
|
||||||
this->scrollBar.getDesiredValue() - event->delta() / 10.0 * mouseMultiplier, true);
|
this->scrollBar.getDesiredValue() - event->delta() / 10.0 * mouseMultiplier, true);
|
||||||
|
|
|
@ -29,7 +29,7 @@ NotebookTab::NotebookTab(Notebook *_notebook, const std::string &_uuid)
|
||||||
|
|
||||||
this->positionChangedAnimation.setEasingCurve(QEasingCurve(QEasingCurve::InCubic));
|
this->positionChangedAnimation.setEasingCurve(QEasingCurve(QEasingCurve::InCubic));
|
||||||
|
|
||||||
SettingsManager::getInstance().hideTabX.connect(
|
singletons::SettingManager::getInstance().hideTabX.connect(
|
||||||
boost::bind(&NotebookTab::hideTabXChanged, this, _1), this->managedConnections);
|
boost::bind(&NotebookTab::hideTabXChanged, this, _1), this->managedConnections);
|
||||||
|
|
||||||
this->setMouseTracking(true);
|
this->setMouseTracking(true);
|
||||||
|
@ -74,7 +74,7 @@ void NotebookTab::calcSize()
|
||||||
float scale = getDpiMultiplier();
|
float scale = getDpiMultiplier();
|
||||||
QString qTitle(qS(this->title));
|
QString qTitle(qS(this->title));
|
||||||
|
|
||||||
if (SettingsManager::getInstance().hideTabX) {
|
if (singletons::SettingManager::getInstance().hideTabX) {
|
||||||
this->resize(static_cast<int>((fontMetrics().width(qTitle) + 16) * scale),
|
this->resize(static_cast<int>((fontMetrics().width(qTitle) + 16) * scale),
|
||||||
static_cast<int>(24 * scale));
|
static_cast<int>(24 * scale));
|
||||||
} else {
|
} else {
|
||||||
|
@ -190,12 +190,12 @@ void NotebookTab::paintEvent(QPaintEvent *)
|
||||||
painter.setPen(fg);
|
painter.setPen(fg);
|
||||||
|
|
||||||
float scale = this->getDpiMultiplier();
|
float scale = this->getDpiMultiplier();
|
||||||
int rectW = (SettingsManager::getInstance().hideTabX ? 0 : static_cast<int>(16) * scale);
|
int rectW = (singletons::SettingManager::getInstance().hideTabX ? 0 : static_cast<int>(16) * scale);
|
||||||
QRect rect(0, 0, this->width() - rectW, this->height());
|
QRect rect(0, 0, this->width() - rectW, this->height());
|
||||||
|
|
||||||
painter.drawText(rect, this->getTitle(), QTextOption(Qt::AlignCenter));
|
painter.drawText(rect, this->getTitle(), QTextOption(Qt::AlignCenter));
|
||||||
|
|
||||||
if (!SettingsManager::getInstance().hideTabX && (mouseOver || selected)) {
|
if (!singletons::SettingManager::getInstance().hideTabX && (mouseOver || selected)) {
|
||||||
QRect xRect = this->getXRect();
|
QRect xRect = this->getXRect();
|
||||||
if (mouseOverX) {
|
if (mouseOverX) {
|
||||||
painter.fillRect(xRect, QColor(0, 0, 0, 64));
|
painter.fillRect(xRect, QColor(0, 0, 0, 64));
|
||||||
|
@ -237,7 +237,7 @@ void NotebookTab::mouseReleaseEvent(QMouseEvent *event)
|
||||||
this->notebook->removePage(this->page);
|
this->notebook->removePage(this->page);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!SettingsManager::getInstance().hideTabX && this->mouseDownX &&
|
if (!singletons::SettingManager::getInstance().hideTabX && this->mouseDownX &&
|
||||||
this->getXRect().contains(event->pos())) {
|
this->getXRect().contains(event->pos())) {
|
||||||
this->mouseDownX = false;
|
this->mouseDownX = false;
|
||||||
|
|
||||||
|
@ -270,7 +270,7 @@ void NotebookTab::dragEnterEvent(QDragEnterEvent *)
|
||||||
|
|
||||||
void NotebookTab::mouseMoveEvent(QMouseEvent *event)
|
void NotebookTab::mouseMoveEvent(QMouseEvent *event)
|
||||||
{
|
{
|
||||||
if (!SettingsManager::getInstance().hideTabX) {
|
if (!singletons::SettingManager::getInstance().hideTabX) {
|
||||||
bool overX = this->getXRect().contains(event->pos());
|
bool overX = this->getXRect().contains(event->pos());
|
||||||
|
|
||||||
if (overX != this->mouseOverX) {
|
if (overX != this->mouseOverX) {
|
||||||
|
|
|
@ -10,8 +10,6 @@
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
||||||
class ThemeManager;
|
|
||||||
|
|
||||||
namespace widgets {
|
namespace widgets {
|
||||||
|
|
||||||
class Notebook;
|
class Notebook;
|
||||||
|
|
|
@ -88,7 +88,7 @@ void ResizingTextEdit::keyPressEvent(QKeyEvent *event)
|
||||||
}
|
}
|
||||||
|
|
||||||
auto *completionModel =
|
auto *completionModel =
|
||||||
static_cast<chatterino::CompletionModel *>(this->completer->model());
|
static_cast<chatterino::singletons::CompletionModel *>(this->completer->model());
|
||||||
|
|
||||||
if (!this->nextCompletion) {
|
if (!this->nextCompletion) {
|
||||||
completionModel->refresh();
|
completionModel->refresh();
|
||||||
|
|
|
@ -10,9 +10,6 @@
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
||||||
class ThemeManager;
|
|
||||||
|
|
||||||
namespace widgets {
|
namespace widgets {
|
||||||
|
|
||||||
class RippleEffectLabel : public RippleEffectButton
|
class RippleEffectLabel : public RippleEffectButton
|
||||||
|
|
|
@ -3,8 +3,9 @@
|
||||||
#include "QString"
|
#include "QString"
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
namespace singletons {
|
||||||
class ThemeManager;
|
class ThemeManager;
|
||||||
|
}
|
||||||
|
|
||||||
namespace widgets {
|
namespace widgets {
|
||||||
|
|
||||||
|
@ -18,7 +19,7 @@ public:
|
||||||
ScrollBarHighlight(double _position, int _colorIndex, ScrollBar *parent, Style _style = Default,
|
ScrollBarHighlight(double _position, int _colorIndex, ScrollBar *parent, Style _style = Default,
|
||||||
QString _tag = "");
|
QString _tag = "");
|
||||||
|
|
||||||
ThemeManager &themeManager;
|
singletons::ThemeManager &themeManager;
|
||||||
|
|
||||||
double getPosition()
|
double getPosition()
|
||||||
{
|
{
|
||||||
|
|
|
@ -16,8 +16,6 @@
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
||||||
class ThemeManager;
|
|
||||||
|
|
||||||
namespace widgets {
|
namespace widgets {
|
||||||
|
|
||||||
class Split;
|
class Split;
|
||||||
|
|
|
@ -27,13 +27,13 @@ SplitInput::SplitInput(Split *_chatWidget)
|
||||||
this->hbox.addLayout(&this->editContainer);
|
this->hbox.addLayout(&this->editContainer);
|
||||||
this->hbox.addLayout(&this->vbox);
|
this->hbox.addLayout(&this->vbox);
|
||||||
|
|
||||||
auto &fontManager = FontManager::getInstance();
|
auto &fontManager = singletons::FontManager::getInstance();
|
||||||
|
|
||||||
this->textInput.setFont(
|
this->textInput.setFont(
|
||||||
fontManager.getFont(FontManager::Type::Medium, this->getDpiMultiplier()));
|
fontManager.getFont(singletons::FontManager::Type::Medium, this->getDpiMultiplier()));
|
||||||
this->managedConnections.emplace_back(fontManager.fontChanged.connect([this, &fontManager]() {
|
this->managedConnections.emplace_back(fontManager.fontChanged.connect([this, &fontManager]() {
|
||||||
this->textInput.setFont(
|
this->textInput.setFont(
|
||||||
fontManager.getFont(FontManager::Type::Medium, this->getDpiMultiplier()));
|
fontManager.getFont(singletons::FontManager::Type::Medium, this->getDpiMultiplier()));
|
||||||
}));
|
}));
|
||||||
|
|
||||||
this->editContainer.addWidget(&this->textInput);
|
this->editContainer.addWidget(&this->textInput);
|
||||||
|
@ -67,10 +67,10 @@ SplitInput::SplitInput(Split *_chatWidget)
|
||||||
connect(&textInput, &ResizingTextEdit::textChanged, this, &SplitInput::editTextChanged);
|
connect(&textInput, &ResizingTextEdit::textChanged, this, &SplitInput::editTextChanged);
|
||||||
|
|
||||||
this->refreshTheme();
|
this->refreshTheme();
|
||||||
textLengthLabel.setHidden(!SettingsManager::getInstance().showMessageLength);
|
textLengthLabel.setHidden(!singletons::SettingManager::getInstance().showMessageLength);
|
||||||
|
|
||||||
auto completer =
|
auto completer = new QCompleter(
|
||||||
new QCompleter(CompletionManager::getInstance().createModel(this->chatWidget->channelName));
|
singletons::CompletionManager::getInstance().createModel(this->chatWidget->channelName));
|
||||||
|
|
||||||
this->textInput.setCompleter(completer);
|
this->textInput.setCompleter(completer);
|
||||||
|
|
||||||
|
@ -180,7 +180,7 @@ SplitInput::SplitInput(Split *_chatWidget)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
SettingsManager::getInstance().showMessageLength.connect(
|
singletons::SettingManager::getInstance().showMessageLength.connect(
|
||||||
[this](const bool &value, auto) { this->textLengthLabel.setHidden(!value); },
|
[this](const bool &value, auto) { this->textLengthLabel.setHidden(!value); },
|
||||||
this->managedConnections);
|
this->managedConnections);
|
||||||
|
|
||||||
|
|
|
@ -50,7 +50,7 @@ void LogInWithCredentials(const std::string &userID, const std::string &username
|
||||||
pajlada::Settings::Setting<std::string>::set("/accounts/uid" + userID + "/oauthToken",
|
pajlada::Settings::Setting<std::string>::set("/accounts/uid" + userID + "/oauthToken",
|
||||||
oauthToken);
|
oauthToken);
|
||||||
|
|
||||||
AccountManager::getInstance().Twitch.reloadUsers();
|
singletons::AccountManager::getInstance().Twitch.reloadUsers();
|
||||||
|
|
||||||
messageBox.exec();
|
messageBox.exec();
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,7 @@ Notebook::Notebook(Window *parent, bool _showButtons, const std::string &setting
|
||||||
this->userButton.move(24, 0);
|
this->userButton.move(24, 0);
|
||||||
this->userButton.icon = NotebookButton::IconUser;
|
this->userButton.icon = NotebookButton::IconUser;
|
||||||
|
|
||||||
auto &settingsManager = SettingsManager::getInstance();
|
auto &settingsManager = singletons::SettingManager::getInstance();
|
||||||
|
|
||||||
settingsManager.hidePreferencesButton.connectSimple([this](auto) { this->performLayout(); });
|
settingsManager.hidePreferencesButton.connectSimple([this](auto) { this->performLayout(); });
|
||||||
settingsManager.hideUserButton.connectSimple([this](auto) { this->performLayout(); });
|
settingsManager.hideUserButton.connectSimple([this](auto) { this->performLayout(); });
|
||||||
|
@ -177,13 +177,13 @@ void Notebook::performLayout(bool animated)
|
||||||
int x = 0, y = 0;
|
int x = 0, y = 0;
|
||||||
float scale = this->getDpiMultiplier();
|
float scale = this->getDpiMultiplier();
|
||||||
|
|
||||||
if (!showButtons || SettingsManager::getInstance().hidePreferencesButton) {
|
if (!showButtons || singletons::SettingManager::getInstance().hidePreferencesButton) {
|
||||||
this->settingsButton.hide();
|
this->settingsButton.hide();
|
||||||
} else {
|
} else {
|
||||||
this->settingsButton.show();
|
this->settingsButton.show();
|
||||||
x += settingsButton.width();
|
x += settingsButton.width();
|
||||||
}
|
}
|
||||||
if (!showButtons || SettingsManager::getInstance().hideUserButton) {
|
if (!showButtons || singletons::SettingManager::getInstance().hideUserButton) {
|
||||||
this->userButton.hide();
|
this->userButton.hide();
|
||||||
} else {
|
} else {
|
||||||
this->userButton.move(x, 0);
|
this->userButton.move(x, 0);
|
||||||
|
|
|
@ -9,9 +9,6 @@
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
||||||
class ChannelManager;
|
|
||||||
|
|
||||||
namespace widgets {
|
namespace widgets {
|
||||||
|
|
||||||
class Window;
|
class Window;
|
||||||
|
|
|
@ -17,7 +17,7 @@ ScrollBar::ScrollBar(ChannelView *parent)
|
||||||
: BaseWidget(parent)
|
: BaseWidget(parent)
|
||||||
, currentValueAnimation(this, "currentValue")
|
, currentValueAnimation(this, "currentValue")
|
||||||
, highlights(nullptr)
|
, highlights(nullptr)
|
||||||
, smoothScrollingSetting(SettingsManager::getInstance().enableSmoothScrolling)
|
, smoothScrollingSetting(singletons::SettingManager::getInstance().enableSmoothScrolling)
|
||||||
{
|
{
|
||||||
resize((int)(16 * this->getDpiMultiplier()), 100);
|
resize((int)(16 * this->getDpiMultiplier()), 100);
|
||||||
this->currentValueAnimation.setDuration(250);
|
this->currentValueAnimation.setDuration(250);
|
||||||
|
|
|
@ -11,8 +11,6 @@
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
||||||
class ThemeManager;
|
|
||||||
|
|
||||||
namespace widgets {
|
namespace widgets {
|
||||||
|
|
||||||
class ChannelView;
|
class ChannelView;
|
||||||
|
|
|
@ -106,7 +106,7 @@ void SettingsDialog::addTabs()
|
||||||
QVBoxLayout *SettingsDialog::createAccountsTab()
|
QVBoxLayout *SettingsDialog::createAccountsTab()
|
||||||
{
|
{
|
||||||
auto layout = new QVBoxLayout();
|
auto layout = new QVBoxLayout();
|
||||||
SettingsManager &settings = SettingsManager::getInstance();
|
singletons::SettingManager &settings = singletons::SettingManager::getInstance();
|
||||||
|
|
||||||
// add remove buttons
|
// add remove buttons
|
||||||
auto buttonBox = new QDialogButtonBox(this);
|
auto buttonBox = new QDialogButtonBox(this);
|
||||||
|
@ -136,7 +136,7 @@ QVBoxLayout *SettingsDialog::createAccountsTab()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
AccountManager::getInstance().Twitch.removeUser(selectedUser);
|
singletons::AccountManager::getInstance().Twitch.removeUser(selectedUser);
|
||||||
});
|
});
|
||||||
|
|
||||||
layout->addWidget(this->ui.accountSwitchWidget);
|
layout->addWidget(this->ui.accountSwitchWidget);
|
||||||
|
@ -146,7 +146,7 @@ QVBoxLayout *SettingsDialog::createAccountsTab()
|
||||||
|
|
||||||
QVBoxLayout *SettingsDialog::createAppearanceTab()
|
QVBoxLayout *SettingsDialog::createAppearanceTab()
|
||||||
{
|
{
|
||||||
auto &settings = SettingsManager::getInstance();
|
auto &settings = singletons::SettingManager::getInstance();
|
||||||
auto layout = this->createTabLayout();
|
auto layout = this->createTabLayout();
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -163,7 +163,7 @@ QVBoxLayout *SettingsDialog::createAppearanceTab()
|
||||||
fontLayout->addWidget(fontFamilyLabel);
|
fontLayout->addWidget(fontFamilyLabel);
|
||||||
|
|
||||||
{
|
{
|
||||||
auto &fontManager = FontManager::getInstance();
|
auto &fontManager = singletons::FontManager::getInstance();
|
||||||
|
|
||||||
auto UpdateFontFamilyLabel = [fontFamilyLabel, &fontManager](auto) {
|
auto UpdateFontFamilyLabel = [fontFamilyLabel, &fontManager](auto) {
|
||||||
fontFamilyLabel->setText(
|
fontFamilyLabel->setText(
|
||||||
|
@ -178,11 +178,11 @@ QVBoxLayout *SettingsDialog::createAppearanceTab()
|
||||||
}
|
}
|
||||||
|
|
||||||
fontButton->connect(fontButton, &QPushButton::clicked, []() {
|
fontButton->connect(fontButton, &QPushButton::clicked, []() {
|
||||||
auto &fontManager = FontManager::getInstance();
|
auto &fontManager = singletons::FontManager::getInstance();
|
||||||
QFontDialog dialog(fontManager.getFont(FontManager::Medium, 1.));
|
QFontDialog dialog(fontManager.getFont(singletons::FontManager::Medium, 1.));
|
||||||
|
|
||||||
dialog.connect(&dialog, &QFontDialog::fontSelected, [](const QFont &font) {
|
dialog.connect(&dialog, &QFontDialog::fontSelected, [](const QFont &font) {
|
||||||
auto &fontManager = FontManager::getInstance();
|
auto &fontManager = singletons::FontManager::getInstance();
|
||||||
fontManager.currentFontFamily = font.family().toStdString();
|
fontManager.currentFontFamily = font.family().toStdString();
|
||||||
fontManager.currentFontSize = font.pointSize();
|
fontManager.currentFontSize = font.pointSize();
|
||||||
});
|
});
|
||||||
|
@ -263,7 +263,7 @@ QVBoxLayout *SettingsDialog::createAppearanceTab()
|
||||||
|
|
||||||
QObject::connect(combo, &QComboBox::currentTextChanged, this, [](const QString &value) {
|
QObject::connect(combo, &QComboBox::currentTextChanged, this, [](const QString &value) {
|
||||||
// dirty hack
|
// dirty hack
|
||||||
EmoteManager::getInstance().incGeneration();
|
singletons::EmoteManager::getInstance().incGeneration();
|
||||||
pajlada::Settings::Setting<std::string>::set("/appearance/theme/name",
|
pajlada::Settings::Setting<std::string>::set("/appearance/theme/name",
|
||||||
value.toStdString());
|
value.toStdString());
|
||||||
});
|
});
|
||||||
|
@ -312,7 +312,7 @@ QVBoxLayout *SettingsDialog::createAppearanceTab()
|
||||||
|
|
||||||
QVBoxLayout *SettingsDialog::createBehaviourTab()
|
QVBoxLayout *SettingsDialog::createBehaviourTab()
|
||||||
{
|
{
|
||||||
SettingsManager &settings = SettingsManager::getInstance();
|
singletons::SettingManager &settings = singletons::SettingManager::getInstance();
|
||||||
auto layout = this->createTabLayout();
|
auto layout = this->createTabLayout();
|
||||||
|
|
||||||
auto form = new QFormLayout();
|
auto form = new QFormLayout();
|
||||||
|
@ -329,14 +329,14 @@ QVBoxLayout *SettingsDialog::createBehaviourTab()
|
||||||
auto scroll = new QSlider(Qt::Horizontal);
|
auto scroll = new QSlider(Qt::Horizontal);
|
||||||
form->addRow("Mouse scroll speed:", scroll);
|
form->addRow("Mouse scroll speed:", scroll);
|
||||||
|
|
||||||
float currentValue = SettingsManager::getInstance().mouseScrollMultiplier;
|
float currentValue = singletons::SettingManager::getInstance().mouseScrollMultiplier;
|
||||||
int scrollValue = ((currentValue - 0.1f) / 2.f) * 99.f;
|
int scrollValue = ((currentValue - 0.1f) / 2.f) * 99.f;
|
||||||
scroll->setValue(scrollValue);
|
scroll->setValue(scrollValue);
|
||||||
|
|
||||||
connect(scroll, &QSlider::valueChanged, [](int newValue) {
|
connect(scroll, &QSlider::valueChanged, [](int newValue) {
|
||||||
float mul = static_cast<float>(newValue) / 99.f;
|
float mul = static_cast<float>(newValue) / 99.f;
|
||||||
float newScrollValue = (mul * 2.1f) + 0.1f;
|
float newScrollValue = (mul * 2.1f) + 0.1f;
|
||||||
SettingsManager::getInstance().mouseScrollMultiplier = newScrollValue;
|
singletons::SettingManager::getInstance().mouseScrollMultiplier = newScrollValue;
|
||||||
});
|
});
|
||||||
|
|
||||||
form->addRow("Streamlink path:", createLineEdit(settings.streamlinkPath));
|
form->addRow("Streamlink path:", createLineEdit(settings.streamlinkPath));
|
||||||
|
@ -361,7 +361,7 @@ QVBoxLayout *SettingsDialog::createCommandsTab()
|
||||||
|
|
||||||
QVBoxLayout *SettingsDialog::createEmotesTab()
|
QVBoxLayout *SettingsDialog::createEmotesTab()
|
||||||
{
|
{
|
||||||
SettingsManager &settings = SettingsManager::getInstance();
|
singletons::SettingManager &settings = singletons::SettingManager::getInstance();
|
||||||
auto layout = this->createTabLayout();
|
auto layout = this->createTabLayout();
|
||||||
|
|
||||||
layout->addWidget(createCheckbox("Enable Twitch Emotes", settings.enableTwitchEmotes));
|
layout->addWidget(createCheckbox("Enable Twitch Emotes", settings.enableTwitchEmotes));
|
||||||
|
@ -405,7 +405,7 @@ QVBoxLayout *SettingsDialog::createLogsTab()
|
||||||
|
|
||||||
QVBoxLayout *SettingsDialog::createHighlightingTab()
|
QVBoxLayout *SettingsDialog::createHighlightingTab()
|
||||||
{
|
{
|
||||||
SettingsManager &settings = SettingsManager::getInstance();
|
singletons::SettingManager &settings = singletons::SettingManager::getInstance();
|
||||||
auto layout = this->createTabLayout();
|
auto layout = this->createTabLayout();
|
||||||
|
|
||||||
auto highlights = new QListWidget();
|
auto highlights = new QListWidget();
|
||||||
|
@ -615,7 +615,7 @@ void SettingsDialog::refresh()
|
||||||
{
|
{
|
||||||
this->ui.accountSwitchWidget->refresh();
|
this->ui.accountSwitchWidget->refresh();
|
||||||
|
|
||||||
SettingsManager::getInstance().saveSnapshot();
|
singletons::SettingManager::getInstance().saveSnapshot();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SettingsDialog::dpiMultiplierChanged(float oldDpi, float newDpi)
|
void SettingsDialog::dpiMultiplierChanged(float oldDpi, float newDpi)
|
||||||
|
@ -754,7 +754,7 @@ void SettingsDialog::okButtonClicked()
|
||||||
|
|
||||||
void SettingsDialog::cancelButtonClicked()
|
void SettingsDialog::cancelButtonClicked()
|
||||||
{
|
{
|
||||||
auto &settings = SettingsManager::getInstance();
|
auto &settings = singletons::SettingManager::getInstance();
|
||||||
|
|
||||||
settings.recallSnapshot();
|
settings.recallSnapshot();
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,7 @@ Split::Split(SplitContainer *parent, const std::string &_uuid)
|
||||||
, settingRoot(fS("/splits/{}", this->uuid))
|
, settingRoot(fS("/splits/{}", this->uuid))
|
||||||
, channelName(fS("{}/channelName", this->settingRoot))
|
, channelName(fS("{}/channelName", this->settingRoot))
|
||||||
, parentPage(*parent)
|
, parentPage(*parent)
|
||||||
, channel(ChannelManager::getInstance().emptyChannel)
|
, channel(singletons::ChannelManager::getInstance().emptyChannel)
|
||||||
, vbox(this)
|
, vbox(this)
|
||||||
, header(this)
|
, header(this)
|
||||||
, view(this)
|
, view(this)
|
||||||
|
@ -97,7 +97,7 @@ Split::Split(SplitContainer *parent, const std::string &_uuid)
|
||||||
});
|
});
|
||||||
|
|
||||||
this->input.textChanged.connect([this](const QString &newText) {
|
this->input.textChanged.connect([this](const QString &newText) {
|
||||||
if (!SettingsManager::getInstance().hideEmptyInput) {
|
if (!singletons::SettingManager::getInstance().hideEmptyInput) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,7 +108,7 @@ Split::Split(SplitContainer *parent, const std::string &_uuid)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
SettingsManager::getInstance().hideEmptyInput.connect([this](const bool &hideEmptyInput, auto) {
|
singletons::SettingManager::getInstance().hideEmptyInput.connect([this](const bool &hideEmptyInput, auto) {
|
||||||
if (hideEmptyInput && this->input.getInputText().length() == 0) {
|
if (hideEmptyInput && this->input.getInputText().length() == 0) {
|
||||||
this->input.hide();
|
this->input.hide();
|
||||||
} else {
|
} else {
|
||||||
|
@ -170,7 +170,7 @@ double Split::getFlexSizeY()
|
||||||
|
|
||||||
void Split::channelNameUpdated(const std::string &newChannelName)
|
void Split::channelNameUpdated(const std::string &newChannelName)
|
||||||
{
|
{
|
||||||
auto &cman = ChannelManager::getInstance();
|
auto &cman = singletons::ChannelManager::getInstance();
|
||||||
|
|
||||||
// remove current channel
|
// remove current channel
|
||||||
if (!this->channel->isEmpty()) {
|
if (!this->channel->isEmpty()) {
|
||||||
|
@ -264,7 +264,7 @@ void Split::doChangeChannel()
|
||||||
|
|
||||||
void Split::doPopup()
|
void Split::doPopup()
|
||||||
{
|
{
|
||||||
Window &window = WindowManager::getInstance().createWindow();
|
Window &window = singletons::WindowManager::getInstance().createWindow();
|
||||||
|
|
||||||
Split *split = new Split(static_cast<SplitContainer *>(window.getNotebook().getSelectedPage()),
|
Split *split = new Split(static_cast<SplitContainer *>(window.getNotebook().getSelectedPage()),
|
||||||
this->uuid);
|
this->uuid);
|
||||||
|
@ -293,7 +293,7 @@ void Split::doOpenPopupPlayer()
|
||||||
|
|
||||||
void Split::doOpenStreamlink()
|
void Split::doOpenStreamlink()
|
||||||
{
|
{
|
||||||
SettingsManager &settings = SettingsManager::getInstance();
|
singletons::SettingManager &settings = singletons::SettingManager::getInstance();
|
||||||
QString preferredQuality =
|
QString preferredQuality =
|
||||||
QString::fromStdString(settings.preferredQuality.getValue()).toLower();
|
QString::fromStdString(settings.preferredQuality.getValue()).toLower();
|
||||||
// TODO(Confuseh): Default streamlink paths
|
// TODO(Confuseh): Default streamlink paths
|
||||||
|
|
|
@ -13,9 +13,6 @@
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
||||||
class ChannelManager;
|
|
||||||
|
|
||||||
namespace widgets {
|
namespace widgets {
|
||||||
|
|
||||||
class SplitContainer : public BaseWidget
|
class SplitContainer : public BaseWidget
|
||||||
|
|
|
@ -20,7 +20,7 @@ TooltipWidget::TooltipWidget(BaseWidget *parent)
|
||||||
palette.setColor(QPalette::Background, black);
|
palette.setColor(QPalette::Background, black);
|
||||||
this->setPalette(palette);
|
this->setPalette(palette);
|
||||||
this->setWindowOpacity(0.8);
|
this->setWindowOpacity(0.8);
|
||||||
this->setFont(FontManager::getInstance().getFont(FontManager::Type::MediumSmall,
|
this->setFont(singletons::FontManager::getInstance().getFont(singletons::FontManager::Type::MediumSmall,
|
||||||
this->getDpiMultiplier()));
|
this->getDpiMultiplier()));
|
||||||
|
|
||||||
this->setAttribute(Qt::WA_ShowWithoutActivating);
|
this->setAttribute(Qt::WA_ShowWithoutActivating);
|
||||||
|
@ -32,8 +32,8 @@ TooltipWidget::TooltipWidget(BaseWidget *parent)
|
||||||
layout->addWidget(displayText);
|
layout->addWidget(displayText);
|
||||||
this->setLayout(layout);
|
this->setLayout(layout);
|
||||||
|
|
||||||
FontManager::getInstance().fontChanged.connect([this] {
|
singletons::FontManager::getInstance().fontChanged.connect([this] {
|
||||||
this->setFont(FontManager::getInstance().getFont(FontManager::Type::MediumSmall,
|
this->setFont(singletons::FontManager::getInstance().getFont(singletons::FontManager::Type::MediumSmall,
|
||||||
this->getDpiMultiplier()));
|
this->getDpiMultiplier()));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
namespace widgets {
|
namespace widgets {
|
||||||
|
|
||||||
Window::Window(const QString &windowName, ThemeManager &_themeManager, bool _isMainWindow)
|
Window::Window(const QString &windowName, singletons::ThemeManager &_themeManager, bool _isMainWindow)
|
||||||
: BaseWidget(_themeManager, nullptr)
|
: BaseWidget(_themeManager, nullptr)
|
||||||
, settingRoot(fS("/windows/{}", windowName))
|
, settingRoot(fS("/windows/{}", windowName))
|
||||||
, windowGeometry(this->settingRoot)
|
, windowGeometry(this->settingRoot)
|
||||||
|
@ -24,7 +24,7 @@ Window::Window(const QString &windowName, ThemeManager &_themeManager, bool _isM
|
||||||
{
|
{
|
||||||
this->initAsWindow();
|
this->initAsWindow();
|
||||||
|
|
||||||
AccountManager::getInstance().Twitch.currentUsername.connect(
|
singletons::AccountManager::getInstance().Twitch.currentUsername.connect(
|
||||||
[this](const std::string &newUsername, auto) {
|
[this](const std::string &newUsername, auto) {
|
||||||
if (newUsername.empty()) {
|
if (newUsername.empty()) {
|
||||||
this->refreshWindowTitle("Not logged in");
|
this->refreshWindowTitle("Not logged in");
|
||||||
|
|
|
@ -14,10 +14,9 @@
|
||||||
#include <pajlada/signals/signal.hpp>
|
#include <pajlada/signals/signal.hpp>
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
namespace singletons {
|
||||||
class ChannelManager;
|
|
||||||
class ThemeManager;
|
class ThemeManager;
|
||||||
class CompletionManager;
|
}
|
||||||
|
|
||||||
namespace widgets {
|
namespace widgets {
|
||||||
|
|
||||||
|
@ -45,7 +44,7 @@ class Window : public BaseWidget
|
||||||
WindowGeometry windowGeometry;
|
WindowGeometry windowGeometry;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit Window(const QString &windowName, ThemeManager &_themeManager, bool isMainWindow);
|
explicit Window(const QString &windowName, singletons::ThemeManager &_themeManager, bool isMainWindow);
|
||||||
|
|
||||||
void repaintVisibleChatWidgets(Channel *channel = nullptr);
|
void repaintVisibleChatWidgets(Channel *channel = nullptr);
|
||||||
|
|
||||||
|
@ -59,7 +58,7 @@ protected:
|
||||||
virtual void closeEvent(QCloseEvent *event) override;
|
virtual void closeEvent(QCloseEvent *event) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ThemeManager &themeManager;
|
singletons::ThemeManager &themeManager;
|
||||||
|
|
||||||
float dpi;
|
float dpi;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue