mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
refactored the managers
This commit is contained in:
parent
258288bad9
commit
bfa2f1637e
|
@ -55,8 +55,7 @@ SOURCES += \
|
||||||
src/application.cpp \
|
src/application.cpp \
|
||||||
src/channel.cpp \
|
src/channel.cpp \
|
||||||
src/channeldata.cpp \
|
src/channeldata.cpp \
|
||||||
src/colorscheme.cpp \
|
src/singletons/ircmanager.cpp \
|
||||||
src/ircmanager.cpp \
|
|
||||||
src/messages/lazyloadedimage.cpp \
|
src/messages/lazyloadedimage.cpp \
|
||||||
src/messages/link.cpp \
|
src/messages/link.cpp \
|
||||||
src/messages/message.cpp \
|
src/messages/message.cpp \
|
||||||
|
@ -74,23 +73,23 @@ SOURCES += \
|
||||||
src/messages/messageref.cpp \
|
src/messages/messageref.cpp \
|
||||||
src/logging/loggingmanager.cpp \
|
src/logging/loggingmanager.cpp \
|
||||||
src/logging/loggingchannel.cpp \
|
src/logging/loggingchannel.cpp \
|
||||||
src/windowmanager.cpp \
|
src/singletons/windowmanager.cpp \
|
||||||
src/channelmanager.cpp \
|
src/singletons/channelmanager.cpp \
|
||||||
src/fontmanager.cpp \
|
src/singletons/fontmanager.cpp \
|
||||||
src/settingsmanager.cpp \
|
src/singletons/settingsmanager.cpp \
|
||||||
src/emotemanager.cpp \
|
src/singletons/emotemanager.cpp \
|
||||||
src/messages/messagebuilder.cpp \
|
src/messages/messagebuilder.cpp \
|
||||||
src/twitch/twitchmessagebuilder.cpp \
|
src/twitch/twitchmessagebuilder.cpp \
|
||||||
src/twitch/twitchparsemessage.cpp \
|
src/twitch/twitchparsemessage.cpp \
|
||||||
src/widgets/titlebar.cpp \
|
src/widgets/titlebar.cpp \
|
||||||
src/appdatapath.cpp \
|
src/appdatapath.cpp \
|
||||||
src/accountmanager.cpp \
|
src/singletons/accountmanager.cpp \
|
||||||
src/twitch/twitchuser.cpp \
|
src/twitch/twitchuser.cpp \
|
||||||
src/ircaccount.cpp \
|
src/ircaccount.cpp \
|
||||||
src/widgets/accountpopup.cpp \
|
src/widgets/accountpopup.cpp \
|
||||||
src/widgets/basewidget.cpp \
|
src/widgets/basewidget.cpp \
|
||||||
src/widgets/helper/resizingtextedit.cpp \
|
src/widgets/helper/resizingtextedit.cpp \
|
||||||
src/completionmanager.cpp \
|
src/singletons/completionmanager.cpp \
|
||||||
src/widgets/logindialog.cpp \
|
src/widgets/logindialog.cpp \
|
||||||
src/widgets/qualitypopup.cpp \
|
src/widgets/qualitypopup.cpp \
|
||||||
src/widgets/emotepopup.cpp \
|
src/widgets/emotepopup.cpp \
|
||||||
|
@ -100,7 +99,7 @@ SOURCES += \
|
||||||
src/widgets/helper/rippleeffectbutton.cpp \
|
src/widgets/helper/rippleeffectbutton.cpp \
|
||||||
src/messages/messagecolor.cpp \
|
src/messages/messagecolor.cpp \
|
||||||
src/util/networkmanager.cpp \
|
src/util/networkmanager.cpp \
|
||||||
src/commandmanager.cpp \
|
src/singletons/commandmanager.cpp \
|
||||||
src/widgets/split.cpp \
|
src/widgets/split.cpp \
|
||||||
src/widgets/helper/splitinput.cpp \
|
src/widgets/helper/splitinput.cpp \
|
||||||
src/widgets/helper/splitheader.cpp \
|
src/widgets/helper/splitheader.cpp \
|
||||||
|
@ -110,16 +109,18 @@ SOURCES += \
|
||||||
src/widgets/helper/splitcolumn.cpp \
|
src/widgets/helper/splitcolumn.cpp \
|
||||||
src/widgets/accountswitchwidget.cpp \
|
src/widgets/accountswitchwidget.cpp \
|
||||||
src/widgets/accountswitchpopupwidget.cpp \
|
src/widgets/accountswitchpopupwidget.cpp \
|
||||||
src/widgets/tooltipwidget.cpp
|
src/widgets/tooltipwidget.cpp \
|
||||||
|
src/singletons/thememanager.cpp \
|
||||||
|
src/twitch/twitchaccountmanager.cpp \
|
||||||
|
src/singletons/helper/completionmodel.cpp
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
src/precompiled_headers.hpp \
|
src/precompiled_headers.hpp \
|
||||||
src/asyncexec.hpp \
|
src/asyncexec.hpp \
|
||||||
src/channel.hpp \
|
src/channel.hpp \
|
||||||
src/colorscheme.hpp \
|
|
||||||
src/concurrentmap.hpp \
|
src/concurrentmap.hpp \
|
||||||
src/emojis.hpp \
|
src/emojis.hpp \
|
||||||
src/ircmanager.hpp \
|
src/singletons/ircmanager.hpp \
|
||||||
src/messages/lazyloadedimage.hpp \
|
src/messages/lazyloadedimage.hpp \
|
||||||
src/messages/link.hpp \
|
src/messages/link.hpp \
|
||||||
src/messages/message.hpp \
|
src/messages/message.hpp \
|
||||||
|
@ -144,11 +145,11 @@ HEADERS += \
|
||||||
src/messages/messageref.hpp \
|
src/messages/messageref.hpp \
|
||||||
src/logging/loggingmanager.hpp \
|
src/logging/loggingmanager.hpp \
|
||||||
src/logging/loggingchannel.hpp \
|
src/logging/loggingchannel.hpp \
|
||||||
src/channelmanager.hpp \
|
src/singletons/channelmanager.hpp \
|
||||||
src/windowmanager.hpp \
|
src/singletons/windowmanager.hpp \
|
||||||
src/settingsmanager.hpp \
|
src/singletons/settingsmanager.hpp \
|
||||||
src/fontmanager.hpp \
|
src/singletons/fontmanager.hpp \
|
||||||
src/emotemanager.hpp \
|
src/singletons/emotemanager.hpp \
|
||||||
src/util/urlfetch.hpp \
|
src/util/urlfetch.hpp \
|
||||||
src/messages/messageparseargs.hpp \
|
src/messages/messageparseargs.hpp \
|
||||||
src/messages/messagebuilder.hpp \
|
src/messages/messagebuilder.hpp \
|
||||||
|
@ -156,13 +157,13 @@ HEADERS += \
|
||||||
src/twitch/twitchparsemessage.hpp \
|
src/twitch/twitchparsemessage.hpp \
|
||||||
src/widgets/titlebar.hpp \
|
src/widgets/titlebar.hpp \
|
||||||
src/appdatapath.hpp \
|
src/appdatapath.hpp \
|
||||||
src/accountmanager.hpp \
|
src/singletons/accountmanager.hpp \
|
||||||
src/twitch/twitchuser.hpp \
|
src/twitch/twitchuser.hpp \
|
||||||
src/ircaccount.hpp \
|
src/ircaccount.hpp \
|
||||||
src/widgets/accountpopup.hpp \
|
src/widgets/accountpopup.hpp \
|
||||||
src/util/distancebetweenpoints.hpp \
|
src/util/distancebetweenpoints.hpp \
|
||||||
src/widgets/basewidget.hpp \
|
src/widgets/basewidget.hpp \
|
||||||
src/completionmanager.hpp \
|
src/singletons/completionmanager.hpp \
|
||||||
src/widgets/helper/channelview.hpp \
|
src/widgets/helper/channelview.hpp \
|
||||||
src/twitch/twitchchannel.hpp \
|
src/twitch/twitchchannel.hpp \
|
||||||
src/widgets/helper/rippleeffectbutton.hpp \
|
src/widgets/helper/rippleeffectbutton.hpp \
|
||||||
|
@ -174,7 +175,7 @@ HEADERS += \
|
||||||
src/debug/log.hpp \
|
src/debug/log.hpp \
|
||||||
src/util/benchmark.hpp \
|
src/util/benchmark.hpp \
|
||||||
src/util/networkmanager.hpp \
|
src/util/networkmanager.hpp \
|
||||||
src/commandmanager.hpp \
|
src/singletons/commandmanager.hpp \
|
||||||
src/widgets/split.hpp \
|
src/widgets/split.hpp \
|
||||||
src/widgets/helper/splitheader.hpp \
|
src/widgets/helper/splitheader.hpp \
|
||||||
src/widgets/helper/splitinput.hpp \
|
src/widgets/helper/splitinput.hpp \
|
||||||
|
@ -189,7 +190,11 @@ HEADERS += \
|
||||||
src/const.hpp \
|
src/const.hpp \
|
||||||
src/widgets/tooltipwidget.hpp \
|
src/widgets/tooltipwidget.hpp \
|
||||||
src/precompiled_headers.hpp \
|
src/precompiled_headers.hpp \
|
||||||
src/messages/wordflags.hpp
|
src/messages/wordflags.hpp \
|
||||||
|
src/singletons/thememanager.hpp \
|
||||||
|
src/twitch/twitchaccountmanager.hpp \
|
||||||
|
src/singletons/helper/completionmodel.hpp \
|
||||||
|
src/singletons/helper/chatterinosetting.hpp
|
||||||
|
|
||||||
|
|
||||||
PRECOMPILED_HEADER =
|
PRECOMPILED_HEADER =
|
||||||
|
@ -210,20 +215,22 @@ win32 {
|
||||||
}
|
}
|
||||||
|
|
||||||
# Optional dependency on windows sdk 7.1
|
# Optional dependency on windows sdk 7.1
|
||||||
win32:exists(C:\Program Files\Microsoft SDKs\Windows\v7.1\Include\Windows.h) {
|
!contains(QMAKE_TARGET.arch, x86_64) {
|
||||||
LIBS += -L"C:\Program Files\Microsoft SDKs\Windows\v7.1\Lib" \
|
win32:exists(C:\Program Files\Microsoft SDKs\Windows\v7.1\Include\Windows.h) {
|
||||||
-ldwmapi \
|
LIBS += -L"C:\Program Files\Microsoft SDKs\Windows\v7.1\Lib" \
|
||||||
-lgdi32
|
-ldwmapi \
|
||||||
|
-lgdi32
|
||||||
|
|
||||||
# SOURCES += platform/borderless/qwinwidget.cpp \
|
# SOURCES += platform/borderless/qwinwidget.cpp \
|
||||||
# platform/borderless/winnativewindow.cpp \
|
# platform/borderless/winnativewindow.cpp \
|
||||||
# platform/borderless/widget.cpp
|
# platform/borderless/widget.cpp
|
||||||
|
|
||||||
# HEADERS += platform/borderless/qwinwidget.h \
|
# HEADERS += platform/borderless/qwinwidget.h \
|
||||||
# platform/borderless/winnativewindow.h \
|
# platform/borderless/winnativewindow.h \
|
||||||
# platform/borderless/widget.h
|
# platform/borderless/widget.h
|
||||||
|
|
||||||
DEFINES += "USEWINSDK"
|
DEFINES += "USEWINSDK"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
macx {
|
macx {
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
#include "application.hpp"
|
#include "application.hpp"
|
||||||
#include "accountmanager.hpp"
|
|
||||||
#include "colorscheme.hpp"
|
|
||||||
#include "logging/loggingmanager.hpp"
|
#include "logging/loggingmanager.hpp"
|
||||||
#include "settingsmanager.hpp"
|
#include "singletons/accountmanager.hpp"
|
||||||
|
#include "singletons/emotemanager.hpp"
|
||||||
|
#include "singletons/settingsmanager.hpp"
|
||||||
|
#include "singletons/thememanager.hpp"
|
||||||
|
#include "singletons/windowmanager.hpp"
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
||||||
|
@ -10,15 +12,11 @@ namespace chatterino {
|
||||||
// It will create the instances of the major classes, and connect their signals to each other
|
// It will create the instances of the major classes, and connect their signals to each other
|
||||||
|
|
||||||
Application::Application()
|
Application::Application()
|
||||||
: windowManager(this->channelManager, this->colorScheme)
|
|
||||||
, colorScheme(this->windowManager)
|
|
||||||
, channelManager(this->windowManager, this->ircManager)
|
|
||||||
, ircManager(this->channelManager, this->resources, this->windowManager)
|
|
||||||
{
|
{
|
||||||
logging::init();
|
logging::init();
|
||||||
SettingsManager::getInstance().load();
|
SettingsManager::getInstance().load();
|
||||||
|
|
||||||
this->windowManager.initMainWindow();
|
WindowManager::getInstance().initMainWindow();
|
||||||
|
|
||||||
// Initialize everything we need
|
// Initialize everything we need
|
||||||
EmoteManager::getInstance().loadGlobalEmotes();
|
EmoteManager::getInstance().loadGlobalEmotes();
|
||||||
|
@ -39,17 +37,17 @@ Application::~Application()
|
||||||
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)
|
||||||
this->ircManager.connect();
|
IrcManager::getInstance().connect();
|
||||||
|
|
||||||
// Show main window
|
// Show main window
|
||||||
this->windowManager.getMainWindow().show();
|
WindowManager::getInstance().getMainWindow().show();
|
||||||
|
|
||||||
return qtApp.exec();
|
return qtApp.exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::save()
|
void Application::save()
|
||||||
{
|
{
|
||||||
this->windowManager.save();
|
WindowManager::getInstance().save();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace chatterino
|
} // namespace chatterino
|
||||||
|
|
|
@ -1,12 +1,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "channelmanager.hpp"
|
#include "singletons/ircmanager.hpp"
|
||||||
#include "colorscheme.hpp"
|
|
||||||
#include "completionmanager.hpp"
|
|
||||||
#include "emotemanager.hpp"
|
|
||||||
#include "ircmanager.hpp"
|
|
||||||
#include "resources.hpp"
|
#include "resources.hpp"
|
||||||
#include "windowmanager.hpp"
|
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
|
|
||||||
|
@ -20,12 +15,6 @@ public:
|
||||||
|
|
||||||
int run(QApplication &qtApp);
|
int run(QApplication &qtApp);
|
||||||
|
|
||||||
WindowManager windowManager;
|
|
||||||
ColorScheme colorScheme;
|
|
||||||
Resources resources;
|
|
||||||
ChannelManager channelManager;
|
|
||||||
IrcManager ircManager;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void save();
|
void save();
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
#include "channel.hpp"
|
#include "channel.hpp"
|
||||||
#include "debug/log.hpp"
|
#include "debug/log.hpp"
|
||||||
#include "emotemanager.hpp"
|
#include "singletons/emotemanager.hpp"
|
||||||
#include "ircmanager.hpp"
|
#include "singletons/ircmanager.hpp"
|
||||||
#include "logging/loggingmanager.hpp"
|
#include "logging/loggingmanager.hpp"
|
||||||
#include "messages/message.hpp"
|
#include "messages/message.hpp"
|
||||||
#include "windowmanager.hpp"
|
#include "singletons/windowmanager.hpp"
|
||||||
|
|
||||||
#include <QJsonArray>
|
#include <QJsonArray>
|
||||||
#include <QJsonDocument>
|
#include <QJsonDocument>
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "concurrentmap.hpp"
|
#include "concurrentmap.hpp"
|
||||||
#include "emotemanager.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"
|
||||||
|
|
|
@ -17,4 +17,4 @@ private:
|
||||||
// std::map<std::string, BadgeData> subscriptionBadges;
|
// std::map<std::string, BadgeData> subscriptionBadges;
|
||||||
};
|
};
|
||||||
|
|
||||||
}; // namespace chatterino
|
} // namespace chatterino
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
#include "messages/lazyloadedimage.hpp"
|
#include "messages/lazyloadedimage.hpp"
|
||||||
#include "asyncexec.hpp"
|
#include "asyncexec.hpp"
|
||||||
#include "emotemanager.hpp"
|
#include "singletons/emotemanager.hpp"
|
||||||
#include "ircmanager.hpp"
|
#include "singletons/ircmanager.hpp"
|
||||||
|
#include "singletons/windowmanager.hpp"
|
||||||
#include "util/networkmanager.hpp"
|
#include "util/networkmanager.hpp"
|
||||||
#include "util/urlfetch.hpp"
|
#include "util/urlfetch.hpp"
|
||||||
#include "windowmanager.hpp"
|
|
||||||
|
|
||||||
#include <QBuffer>
|
#include <QBuffer>
|
||||||
#include <QImageReader>
|
#include <QImageReader>
|
||||||
|
@ -81,7 +81,7 @@ void LazyLoadedImage::loadImage()
|
||||||
|
|
||||||
EmoteManager::getInstance().incGeneration();
|
EmoteManager::getInstance().incGeneration();
|
||||||
|
|
||||||
WindowManager::instance->layoutVisibleChatWidgets();
|
WindowManager::getInstance().layoutVisibleChatWidgets();
|
||||||
});
|
});
|
||||||
|
|
||||||
EmoteManager::getInstance().getGifUpdateSignal().connect([=]() {
|
EmoteManager::getInstance().getGifUpdateSignal().connect([=]() {
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
#include "messages/message.hpp"
|
#include "messages/message.hpp"
|
||||||
#include "channel.hpp"
|
#include "channel.hpp"
|
||||||
#include "colorscheme.hpp"
|
#include "singletons/thememanager.hpp"
|
||||||
#include "emojis.hpp"
|
#include "emojis.hpp"
|
||||||
#include "emotemanager.hpp"
|
#include "singletons/emotemanager.hpp"
|
||||||
#include "fontmanager.hpp"
|
#include "singletons/fontmanager.hpp"
|
||||||
#include "ircmanager.hpp"
|
#include "singletons/ircmanager.hpp"
|
||||||
#include "messages/link.hpp"
|
#include "messages/link.hpp"
|
||||||
#include "resources.hpp"
|
#include "resources.hpp"
|
||||||
#include "util/irchelpers.hpp"
|
#include "util/irchelpers.hpp"
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#include "messagebuilder.hpp"
|
#include "messagebuilder.hpp"
|
||||||
#include "colorscheme.hpp"
|
#include "singletons/thememanager.hpp"
|
||||||
#include "emotemanager.hpp"
|
#include "singletons/emotemanager.hpp"
|
||||||
#include "resources.hpp"
|
#include "resources.hpp"
|
||||||
|
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
|
|
|
@ -19,17 +19,17 @@ MessageColor::Type MessageColor::getType() const
|
||||||
return this->type;
|
return this->type;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QColor &MessageColor::getColor(ColorScheme &colorScheme) const
|
const QColor &MessageColor::getColor(ThemeManager &themeManager) const
|
||||||
{
|
{
|
||||||
switch (this->type) {
|
switch (this->type) {
|
||||||
case Type::Custom:
|
case Type::Custom:
|
||||||
return this->color;
|
return this->color;
|
||||||
case Type::Text:
|
case Type::Text:
|
||||||
return colorScheme.Text;
|
return themeManager.Text;
|
||||||
case Type::System:
|
case Type::System:
|
||||||
return colorScheme.SystemMessageColor;
|
return themeManager.SystemMessageColor;
|
||||||
case Type::Link:
|
case Type::Link:
|
||||||
return colorScheme.TextLink;
|
return themeManager.TextLink;
|
||||||
}
|
}
|
||||||
|
|
||||||
static QColor _default;
|
static QColor _default;
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
#include <QColor>
|
#include <QColor>
|
||||||
|
|
||||||
#include <colorscheme.hpp>
|
#include "singletons/thememanager.hpp"
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
namespace messages {
|
namespace messages {
|
||||||
|
@ -16,7 +16,7 @@ public:
|
||||||
explicit MessageColor(Type type = Text);
|
explicit MessageColor(Type type = Text);
|
||||||
|
|
||||||
Type getType() const;
|
Type getType() const;
|
||||||
const QColor &getColor(ColorScheme &colorScheme) const;
|
const QColor &getColor(ThemeManager &themeManager) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Type type;
|
Type type;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#include "messages/messageref.hpp"
|
#include "messages/messageref.hpp"
|
||||||
#include "emotemanager.hpp"
|
#include "singletons/emotemanager.hpp"
|
||||||
#include "settingsmanager.hpp"
|
#include "singletons/settingsmanager.hpp"
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#include "messages/word.hpp"
|
#include "messages/word.hpp"
|
||||||
#include "settingsmanager.hpp"
|
#include "singletons/settingsmanager.hpp"
|
||||||
#include "util/benchmark.hpp"
|
#include "util/benchmark.hpp"
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "fontmanager.hpp"
|
#include "singletons/fontmanager.hpp"
|
||||||
#include "messages/lazyloadedimage.hpp"
|
#include "messages/lazyloadedimage.hpp"
|
||||||
#include "messages/link.hpp"
|
#include "messages/link.hpp"
|
||||||
#include "messages/messagecolor.hpp"
|
#include "messages/messagecolor.hpp"
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#include "resources.hpp"
|
#include "resources.hpp"
|
||||||
#include "emotemanager.hpp"
|
//#include "singletons/emotemanager.hpp"
|
||||||
|
//#include "singletons/windowmanager.hpp"
|
||||||
#include "util/urlfetch.hpp"
|
#include "util/urlfetch.hpp"
|
||||||
#include "windowmanager.hpp"
|
|
||||||
|
|
||||||
#include <QPixmap>
|
#include <QPixmap>
|
||||||
|
|
||||||
|
@ -41,6 +41,12 @@ Resources::Resources()
|
||||||
this->loadChatterinoBadges();
|
this->loadChatterinoBadges();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Resources &Resources::getInstance()
|
||||||
|
{
|
||||||
|
static Resources instance;
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
Resources::BadgeVersion::BadgeVersion(QJsonObject &&root)
|
Resources::BadgeVersion::BadgeVersion(QJsonObject &&root)
|
||||||
: badgeImage1x(new messages::LazyLoadedImage(root.value("image_url_1x").toString()))
|
: badgeImage1x(new messages::LazyLoadedImage(root.value("image_url_1x").toString()))
|
||||||
, badgeImage2x(new messages::LazyLoadedImage(root.value("image_url_2x").toString()))
|
, badgeImage2x(new messages::LazyLoadedImage(root.value("image_url_2x").toString()))
|
||||||
|
|
|
@ -10,9 +10,11 @@ namespace chatterino {
|
||||||
|
|
||||||
class Resources
|
class Resources
|
||||||
{
|
{
|
||||||
public:
|
|
||||||
explicit Resources();
|
explicit Resources();
|
||||||
|
|
||||||
|
public:
|
||||||
|
static Resources &getInstance();
|
||||||
|
|
||||||
messages::LazyLoadedImage *badgeStaff;
|
messages::LazyLoadedImage *badgeStaff;
|
||||||
messages::LazyLoadedImage *badgeAdmin;
|
messages::LazyLoadedImage *badgeAdmin;
|
||||||
messages::LazyLoadedImage *badgeGlobalModerator;
|
messages::LazyLoadedImage *badgeGlobalModerator;
|
||||||
|
|
45
src/singletons/accountmanager.cpp
Normal file
45
src/singletons/accountmanager.cpp
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
#include "singletons/accountmanager.hpp"
|
||||||
|
|
||||||
|
namespace chatterino {
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
inline QString getEnvString(const char *target)
|
||||||
|
{
|
||||||
|
char *val = std::getenv(target);
|
||||||
|
if (val == nullptr) {
|
||||||
|
return QString();
|
||||||
|
}
|
||||||
|
|
||||||
|
return QString(val);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
AccountManager::AccountManager()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
AccountManager &AccountManager::getInstance()
|
||||||
|
{
|
||||||
|
static AccountManager instance;
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
void AccountManager::load()
|
||||||
|
{
|
||||||
|
this->Twitch.reloadUsers();
|
||||||
|
|
||||||
|
auto currentUser = this->Twitch.findUserByUsername(
|
||||||
|
QString::fromStdString(this->Twitch.currentUsername.getValue()));
|
||||||
|
|
||||||
|
if (currentUser) {
|
||||||
|
this->Twitch.currentUser = currentUser;
|
||||||
|
} else {
|
||||||
|
this->Twitch.currentUser = this->Twitch.anonymousUser;
|
||||||
|
}
|
||||||
|
|
||||||
|
this->Twitch.userChanged.invoke();
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace chatterino
|
19
src/singletons/accountmanager.hpp
Normal file
19
src/singletons/accountmanager.hpp
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "twitch/twitchaccountmanager.hpp"
|
||||||
|
|
||||||
|
namespace chatterino {
|
||||||
|
|
||||||
|
class AccountManager
|
||||||
|
{
|
||||||
|
AccountManager();
|
||||||
|
|
||||||
|
public:
|
||||||
|
static AccountManager &getInstance();
|
||||||
|
|
||||||
|
void load();
|
||||||
|
|
||||||
|
twitch::TwitchAccountManager Twitch;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace chatterino
|
|
@ -1,20 +1,21 @@
|
||||||
#include "channelmanager.hpp"
|
#include "singletons/channelmanager.hpp"
|
||||||
#include "ircmanager.hpp"
|
#include "singletons/ircmanager.hpp"
|
||||||
|
|
||||||
using namespace chatterino::twitch;
|
using namespace chatterino::twitch;
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
||||||
ChannelManager *ChannelManager::instance = nullptr;
|
ChannelManager &ChannelManager::getInstance()
|
||||||
|
{
|
||||||
ChannelManager::ChannelManager(WindowManager &_windowManager, IrcManager &_ircManager)
|
static ChannelManager instance;
|
||||||
: windowManager(_windowManager)
|
return instance;
|
||||||
, ircManager(_ircManager)
|
}
|
||||||
, whispersChannel(new TwitchChannel(_ircManager, "/whispers", true))
|
|
||||||
, mentionsChannel(new TwitchChannel(_ircManager, "/mentions", true))
|
ChannelManager::ChannelManager()
|
||||||
, emptyChannel(new TwitchChannel(_ircManager, "", true))
|
: whispersChannel(new Channel("/whispers"))
|
||||||
|
, mentionsChannel(new Channel("/mentions"))
|
||||||
|
, emptyChannel(new Channel(""))
|
||||||
{
|
{
|
||||||
ChannelManager::instance = this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::vector<std::shared_ptr<Channel>> ChannelManager::getItems()
|
const std::vector<std::shared_ptr<Channel>> ChannelManager::getItems()
|
||||||
|
@ -30,7 +31,7 @@ const std::vector<std::shared_ptr<Channel>> ChannelManager::getItems()
|
||||||
return items;
|
return items;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<TwitchChannel> ChannelManager::addTwitchChannel(const QString &rawChannelName)
|
std::shared_ptr<Channel> ChannelManager::addTwitchChannel(const QString &rawChannelName)
|
||||||
{
|
{
|
||||||
QString channelName = rawChannelName.toLower();
|
QString channelName = rawChannelName.toLower();
|
||||||
|
|
||||||
|
@ -47,11 +48,11 @@ std::shared_ptr<TwitchChannel> ChannelManager::addTwitchChannel(const QString &r
|
||||||
auto it = this->twitchChannels.find(channelName);
|
auto it = this->twitchChannels.find(channelName);
|
||||||
|
|
||||||
if (it == this->twitchChannels.end()) {
|
if (it == this->twitchChannels.end()) {
|
||||||
auto channel = std::make_shared<TwitchChannel>(this->ircManager, channelName);
|
auto channel = std::make_shared<TwitchChannel>(channelName);
|
||||||
|
|
||||||
this->twitchChannels.insert(channelName, std::make_tuple(channel, 1));
|
this->twitchChannels.insert(channelName, std::make_tuple(channel, 1));
|
||||||
|
|
||||||
this->ircManager.joinChannel(channelName);
|
this->ircJoin.invoke(channelName);
|
||||||
|
|
||||||
return channel;
|
return channel;
|
||||||
}
|
}
|
||||||
|
@ -61,7 +62,7 @@ std::shared_ptr<TwitchChannel> ChannelManager::addTwitchChannel(const QString &r
|
||||||
return std::get<0>(it.value());
|
return std::get<0>(it.value());
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<TwitchChannel> ChannelManager::getTwitchChannel(const QString &channel)
|
std::shared_ptr<Channel> ChannelManager::getTwitchChannel(const QString &channel)
|
||||||
{
|
{
|
||||||
QMutexLocker locker(&this->channelsMutex);
|
QMutexLocker locker(&this->channelsMutex);
|
||||||
|
|
||||||
|
@ -107,7 +108,7 @@ void ChannelManager::removeTwitchChannel(const QString &channel)
|
||||||
std::get<1>(a.value())--;
|
std::get<1>(a.value())--;
|
||||||
|
|
||||||
if (std::get<1>(a.value()) == 0) {
|
if (std::get<1>(a.value()) == 0) {
|
||||||
this->ircManager.partChannel(c);
|
this->ircPart.invoke(c);
|
||||||
this->twitchChannels.remove(c);
|
this->twitchChannels.remove(c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -126,7 +127,7 @@ const std::string &ChannelManager::getUserID(const std::string &username)
|
||||||
return temporary;
|
return temporary;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChannelManager::doOnAll(std::function<void(std::shared_ptr<TwitchChannel>)> func)
|
void ChannelManager::doOnAll(std::function<void(std::shared_ptr<Channel>)> func)
|
||||||
{
|
{
|
||||||
for (const auto &channel : this->twitchChannels) {
|
for (const auto &channel : this->twitchChannels) {
|
||||||
func(std::get<0>(channel));
|
func(std::get<0>(channel));
|
|
@ -13,28 +13,25 @@ class IrcManager;
|
||||||
|
|
||||||
class ChannelManager
|
class ChannelManager
|
||||||
{
|
{
|
||||||
|
explicit ChannelManager();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit ChannelManager(WindowManager &_windowManager, IrcManager &_ircManager);
|
static ChannelManager &getInstance();
|
||||||
|
|
||||||
static ChannelManager *instance;
|
|
||||||
|
|
||||||
WindowManager &windowManager;
|
|
||||||
IrcManager &ircManager;
|
|
||||||
|
|
||||||
const std::vector<std::shared_ptr<Channel>> getItems();
|
const std::vector<std::shared_ptr<Channel>> getItems();
|
||||||
|
|
||||||
std::shared_ptr<twitch::TwitchChannel> addTwitchChannel(const QString &channel);
|
std::shared_ptr<Channel> addTwitchChannel(const QString &channel);
|
||||||
std::shared_ptr<twitch::TwitchChannel> getTwitchChannel(const QString &channel);
|
std::shared_ptr<Channel> getTwitchChannel(const QString &channel);
|
||||||
void removeTwitchChannel(const QString &channel);
|
void removeTwitchChannel(const QString &channel);
|
||||||
|
|
||||||
const std::string &getUserID(const std::string &username);
|
const std::string &getUserID(const std::string &username);
|
||||||
|
|
||||||
void doOnAll(std::function<void(std::shared_ptr<twitch::TwitchChannel>)> func);
|
void doOnAll(std::function<void(std::shared_ptr<Channel>)> func);
|
||||||
|
|
||||||
// Special channels
|
// Special channels
|
||||||
const std::shared_ptr<twitch::TwitchChannel> whispersChannel;
|
const std::shared_ptr<Channel> whispersChannel;
|
||||||
const std::shared_ptr<twitch::TwitchChannel> mentionsChannel;
|
const std::shared_ptr<Channel> mentionsChannel;
|
||||||
const std::shared_ptr<twitch::TwitchChannel> emptyChannel;
|
const std::shared_ptr<Channel> emptyChannel;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::map<std::string, std::string> usernameToID;
|
std::map<std::string, std::string> usernameToID;
|
||||||
|
@ -42,6 +39,11 @@ private:
|
||||||
|
|
||||||
QMutex channelsMutex;
|
QMutex channelsMutex;
|
||||||
QMap<QString, std::tuple<std::shared_ptr<twitch::TwitchChannel>, int>> twitchChannels;
|
QMap<QString, std::tuple<std::shared_ptr<twitch::TwitchChannel>, int>> twitchChannels;
|
||||||
|
|
||||||
|
pajlada::Signals::Signal<const QString &> ircJoin;
|
||||||
|
pajlada::Signals::Signal<const QString &> ircPart;
|
||||||
|
|
||||||
|
friend class IrcManager;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace chatterino
|
} // namespace chatterino
|
|
@ -1,8 +1,14 @@
|
||||||
#include "commandmanager.hpp"
|
#include "singletons/commandmanager.hpp"
|
||||||
|
|
||||||
#include <QRegularExpression>
|
#include <QRegularExpression>
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
CommandManager &CommandManager::getInstance()
|
||||||
|
{
|
||||||
|
static CommandManager instance;
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
// QString CommandManager::execCommand(QString text)
|
// QString CommandManager::execCommand(QString text)
|
||||||
//{
|
//{
|
||||||
// QStringList words = text.split(' ', QString::SkipEmptyParts);
|
// QStringList words = text.split(' ', QString::SkipEmptyParts);
|
|
@ -7,7 +7,11 @@ namespace chatterino {
|
||||||
|
|
||||||
class CommandManager
|
class CommandManager
|
||||||
{
|
{
|
||||||
// public:
|
CommandManager() = default;
|
||||||
|
|
||||||
|
public:
|
||||||
|
static CommandManager &getInstance();
|
||||||
|
|
||||||
// CommandManager() = delete;
|
// CommandManager() = delete;
|
||||||
|
|
||||||
// QString execCommand(QString text);
|
// QString execCommand(QString text);
|
28
src/singletons/completionmanager.cpp
Normal file
28
src/singletons/completionmanager.cpp
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
#include "singletons/completionmanager.hpp"
|
||||||
|
#include "common.hpp"
|
||||||
|
#include "debug/log.hpp"
|
||||||
|
#include "singletons/channelmanager.hpp"
|
||||||
|
#include "singletons/emotemanager.hpp"
|
||||||
|
|
||||||
|
namespace chatterino {
|
||||||
|
|
||||||
|
CompletionManager &CompletionManager::getInstance()
|
||||||
|
{
|
||||||
|
static CompletionManager instance;
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
CompletionModel *CompletionManager::createModel(const std::string &channelName)
|
||||||
|
{
|
||||||
|
auto it = this->models.find(channelName);
|
||||||
|
if (it != this->models.end()) {
|
||||||
|
return it->second;
|
||||||
|
}
|
||||||
|
|
||||||
|
CompletionModel *ret = new CompletionModel(qS(channelName));
|
||||||
|
this->models[channelName] = ret;
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace chatterino
|
24
src/singletons/completionmanager.hpp
Normal file
24
src/singletons/completionmanager.hpp
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <QAbstractListModel>
|
||||||
|
#include <QVector>
|
||||||
|
#include <map>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#include "helper/completionmodel.hpp"
|
||||||
|
|
||||||
|
namespace chatterino {
|
||||||
|
class CompletionManager
|
||||||
|
{
|
||||||
|
CompletionManager() = default;
|
||||||
|
|
||||||
|
public:
|
||||||
|
static CompletionManager &getInstance();
|
||||||
|
|
||||||
|
CompletionModel *createModel(const std::string &channelName);
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::map<std::string, CompletionModel *> models;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace chatterino
|
|
@ -1,10 +1,11 @@
|
||||||
#include "emotemanager.hpp"
|
#include "emotemanager.hpp"
|
||||||
#include "common.hpp"
|
#include "common.hpp"
|
||||||
#include "settingsmanager.hpp"
|
#include "singletons/settingsmanager.hpp"
|
||||||
|
#include "singletons/windowmanager.hpp"
|
||||||
#include "util/urlfetch.hpp"
|
#include "util/urlfetch.hpp"
|
||||||
#include "windowmanager.hpp"
|
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
#include <QFile>
|
||||||
#include <QJsonArray>
|
#include <QJsonArray>
|
||||||
#include <QJsonDocument>
|
#include <QJsonDocument>
|
||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
|
@ -21,8 +22,10 @@ using namespace chatterino::messages;
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
||||||
EmoteManager::EmoteManager()
|
EmoteManager::EmoteManager(SettingsManager &_settingsManager, WindowManager &_windowManager)
|
||||||
: findShortCodesRegex(":([-+\\w]+):")
|
: settingsManager(_settingsManager)
|
||||||
|
, windowManager(_windowManager)
|
||||||
|
, findShortCodesRegex(":([-+\\w]+):")
|
||||||
{
|
{
|
||||||
auto &accountManager = AccountManager::getInstance();
|
auto &accountManager = AccountManager::getInstance();
|
||||||
|
|
||||||
|
@ -33,6 +36,12 @@ EmoteManager::EmoteManager()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EmoteManager &EmoteManager::getInstance()
|
||||||
|
{
|
||||||
|
static EmoteManager instance(SettingsManager::getInstance(), WindowManager::getInstance());
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
void EmoteManager::loadGlobalEmotes()
|
void EmoteManager::loadGlobalEmotes()
|
||||||
{
|
{
|
||||||
this->loadEmojis();
|
this->loadEmojis();
|
||||||
|
@ -507,7 +516,7 @@ boost::signals2::signal<void()> &EmoteManager::getGifUpdateSignal()
|
||||||
this->gifUpdateTimer.setInterval(30);
|
this->gifUpdateTimer.setInterval(30);
|
||||||
this->gifUpdateTimer.start();
|
this->gifUpdateTimer.start();
|
||||||
|
|
||||||
SettingsManager::getInstance().enableGifAnimations.connect([this](bool enabled, auto) {
|
this->settingsManager.enableGifAnimations.connect([this](bool enabled, auto) {
|
||||||
if (enabled) {
|
if (enabled) {
|
||||||
this->gifUpdateTimer.start();
|
this->gifUpdateTimer.start();
|
||||||
} else {
|
} else {
|
||||||
|
@ -517,7 +526,8 @@ boost::signals2::signal<void()> &EmoteManager::getGifUpdateSignal()
|
||||||
|
|
||||||
QObject::connect(&this->gifUpdateTimer, &QTimer::timeout, [this] {
|
QObject::connect(&this->gifUpdateTimer, &QTimer::timeout, [this] {
|
||||||
this->gifUpdateTimerSignal();
|
this->gifUpdateTimerSignal();
|
||||||
WindowManager::instance->repaintGifEmotes();
|
// fourtf:
|
||||||
|
this->windowManager.repaintGifEmotes();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,9 @@
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
||||||
|
class SettingsManager;
|
||||||
|
class WindowManager;
|
||||||
|
|
||||||
struct EmoteData {
|
struct EmoteData {
|
||||||
EmoteData()
|
EmoteData()
|
||||||
{
|
{
|
||||||
|
@ -35,14 +38,10 @@ typedef ConcurrentMap<QString, EmoteData> EmoteMap;
|
||||||
|
|
||||||
class EmoteManager
|
class EmoteManager
|
||||||
{
|
{
|
||||||
EmoteManager();
|
explicit EmoteManager(SettingsManager &manager, WindowManager &windowManager);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static EmoteManager &getInstance()
|
static EmoteManager &getInstance();
|
||||||
{
|
|
||||||
static EmoteManager instance;
|
|
||||||
return instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
void loadGlobalEmotes();
|
void loadGlobalEmotes();
|
||||||
|
|
||||||
|
@ -79,6 +78,9 @@ public:
|
||||||
ConcurrentMap<QString, messages::LazyLoadedImage *> miscImageCache;
|
ConcurrentMap<QString, messages::LazyLoadedImage *> miscImageCache;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
SettingsManager &settingsManager;
|
||||||
|
WindowManager &windowManager;
|
||||||
|
|
||||||
/// Emojis
|
/// Emojis
|
||||||
QRegularExpression findShortCodesRegex;
|
QRegularExpression findShortCodesRegex;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#include "fontmanager.hpp"
|
#include "singletons/fontmanager.hpp"
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
|
@ -23,6 +23,13 @@ FontManager::FontManager()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FontManager &FontManager::getInstance()
|
||||||
|
{
|
||||||
|
static FontManager instance;
|
||||||
|
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
QFont &FontManager::getFont(Type type, float dpi)
|
QFont &FontManager::getFont(Type type, float dpi)
|
||||||
{
|
{
|
||||||
// return this->currentFont.getFont(type);
|
// return this->currentFont.getFont(type);
|
|
@ -11,6 +11,7 @@ class FontManager
|
||||||
{
|
{
|
||||||
FontManager(const FontManager &) = delete;
|
FontManager(const FontManager &) = delete;
|
||||||
FontManager(FontManager &&) = delete;
|
FontManager(FontManager &&) = delete;
|
||||||
|
FontManager();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum Type : uint8_t {
|
enum Type : uint8_t {
|
||||||
|
@ -24,12 +25,7 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
// FontManager is initialized only once, on first use
|
// FontManager is initialized only once, on first use
|
||||||
static FontManager &getInstance()
|
static FontManager &getInstance();
|
||||||
{
|
|
||||||
static FontManager instance;
|
|
||||||
|
|
||||||
return instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
QFont &getFont(Type type, float dpi);
|
QFont &getFont(Type type, float dpi);
|
||||||
QFontMetrics &getFontMetrics(Type type, float dpi);
|
QFontMetrics &getFontMetrics(Type type, float dpi);
|
||||||
|
@ -50,8 +46,6 @@ public:
|
||||||
pajlada::Signals::NoArgSignal fontChanged;
|
pajlada::Signals::NoArgSignal fontChanged;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
FontManager();
|
|
||||||
|
|
||||||
struct FontData {
|
struct FontData {
|
||||||
FontData(QFont &&_font)
|
FontData(QFont &&_font)
|
||||||
: font(_font)
|
: font(_font)
|
||||||
|
@ -68,7 +62,7 @@ private:
|
||||||
|
|
||||||
explicit Font(const char *fontFamilyName, int mediumSize)
|
explicit Font(const char *fontFamilyName, int mediumSize)
|
||||||
: small(QFont(fontFamilyName, mediumSize - 4))
|
: small(QFont(fontFamilyName, mediumSize - 4))
|
||||||
, mediumSmall(QFont(fontFamilyName, mediumSize -2))
|
, mediumSmall(QFont(fontFamilyName, mediumSize - 2))
|
||||||
, medium(QFont(fontFamilyName, mediumSize))
|
, medium(QFont(fontFamilyName, mediumSize))
|
||||||
, mediumBold(QFont(fontFamilyName, mediumSize, QFont::DemiBold))
|
, mediumBold(QFont(fontFamilyName, mediumSize, QFont::DemiBold))
|
||||||
, mediumItalic(QFont(fontFamilyName, mediumSize, -1, true))
|
, mediumItalic(QFont(fontFamilyName, mediumSize, -1, true))
|
67
src/singletons/helper/chatterinosetting.hpp
Normal file
67
src/singletons/helper/chatterinosetting.hpp
Normal file
|
@ -0,0 +1,67 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
namespace chatterino {
|
||||||
|
static void _registerSetting(std::weak_ptr<pajlada::Settings::ISettingData> setting);
|
||||||
|
|
||||||
|
template <typename Type>
|
||||||
|
class ChatterinoSetting : public pajlada::Settings::Setting<Type>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ChatterinoSetting(const std::string &_path, const Type &_defaultValue)
|
||||||
|
: pajlada::Settings::Setting<Type>(_path, _defaultValue)
|
||||||
|
{
|
||||||
|
_registerSetting(this->data);
|
||||||
|
}
|
||||||
|
|
||||||
|
void saveRecall();
|
||||||
|
|
||||||
|
ChatterinoSetting &operator=(const Type &newValue)
|
||||||
|
{
|
||||||
|
assert(this->data != nullptr);
|
||||||
|
|
||||||
|
this->setValue(newValue);
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T2>
|
||||||
|
ChatterinoSetting &operator=(const T2 &newValue)
|
||||||
|
{
|
||||||
|
assert(this->data != nullptr);
|
||||||
|
|
||||||
|
this->setValue(newValue);
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
ChatterinoSetting &operator=(Type &&newValue) noexcept
|
||||||
|
{
|
||||||
|
assert(this->data != nullptr);
|
||||||
|
|
||||||
|
this->setValue(std::move(newValue));
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator==(const Type &rhs) const
|
||||||
|
{
|
||||||
|
assert(this->data != nullptr);
|
||||||
|
|
||||||
|
return this->getValue() == rhs;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator!=(const Type &rhs) const
|
||||||
|
{
|
||||||
|
assert(this->data != nullptr);
|
||||||
|
|
||||||
|
return this->getValue() != rhs;
|
||||||
|
}
|
||||||
|
|
||||||
|
operator const Type() const
|
||||||
|
{
|
||||||
|
assert(this->data != nullptr);
|
||||||
|
|
||||||
|
return this->getValue();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
|
@ -1,11 +1,12 @@
|
||||||
#include "completionmanager.hpp"
|
#include "completionmodel.hpp"
|
||||||
#include "channelmanager.hpp"
|
|
||||||
#include "common.hpp"
|
#include "common.hpp"
|
||||||
#include "debug/log.hpp"
|
#include "debug/log.hpp"
|
||||||
#include "emotemanager.hpp"
|
#include "singletons/channelmanager.hpp"
|
||||||
|
#include "singletons/completionmanager.hpp"
|
||||||
|
#include "singletons/emotemanager.hpp"
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
||||||
CompletionModel::CompletionModel(const QString &_channelName)
|
CompletionModel::CompletionModel(const QString &_channelName)
|
||||||
: channelName(_channelName)
|
: channelName(_channelName)
|
||||||
{
|
{
|
||||||
|
@ -59,11 +60,7 @@ void CompletionModel::refresh()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Channel-specific: Usernames
|
// Channel-specific: Usernames
|
||||||
auto *channelManager = ChannelManager::instance;
|
auto c = ChannelManager::getInstance().getTwitchChannel(this->channelName);
|
||||||
auto c = channelManager->getTwitchChannel(this->channelName);
|
|
||||||
if (!c) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
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());
|
||||||
|
@ -88,18 +85,4 @@ void CompletionModel::addString(const QString &str)
|
||||||
// Always add a space at the end of completions
|
// Always add a space at the end of completions
|
||||||
this->emotes.push_back(str + " ");
|
this->emotes.push_back(str + " ");
|
||||||
}
|
}
|
||||||
|
|
||||||
CompletionModel *CompletionManager::createModel(const std::string &channelName)
|
|
||||||
{
|
|
||||||
auto it = this->models.find(channelName);
|
|
||||||
if (it != this->models.end()) {
|
|
||||||
return it->second;
|
|
||||||
}
|
|
||||||
|
|
||||||
CompletionModel *ret = new CompletionModel(qS(channelName));
|
|
||||||
this->models[channelName] = ret;
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace chatterino
|
|
|
@ -7,7 +7,6 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
||||||
class CompletionModel : public QAbstractListModel
|
class CompletionModel : public QAbstractListModel
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -39,21 +38,4 @@ private:
|
||||||
|
|
||||||
QString channelName;
|
QString channelName;
|
||||||
};
|
};
|
||||||
|
}
|
||||||
class CompletionManager
|
|
||||||
{
|
|
||||||
CompletionManager() = default;
|
|
||||||
|
|
||||||
std::map<std::string, CompletionModel *> models;
|
|
||||||
|
|
||||||
public:
|
|
||||||
static CompletionManager &getInstance()
|
|
||||||
{
|
|
||||||
static CompletionManager instance;
|
|
||||||
return instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
CompletionModel *createModel(const std::string &channelName);
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace chatterino
|
|
|
@ -1,17 +1,18 @@
|
||||||
#include "ircmanager.hpp"
|
#include "singletons/ircmanager.hpp"
|
||||||
#include "accountmanager.hpp"
|
|
||||||
#include "asyncexec.hpp"
|
#include "asyncexec.hpp"
|
||||||
#include "channel.hpp"
|
#include "channel.hpp"
|
||||||
#include "channelmanager.hpp"
|
|
||||||
#include "debug/log.hpp"
|
#include "debug/log.hpp"
|
||||||
#include "emotemanager.hpp"
|
|
||||||
#include "messages/messageparseargs.hpp"
|
#include "messages/messageparseargs.hpp"
|
||||||
#include "settingsmanager.hpp"
|
#include "resources.hpp"
|
||||||
|
#include "singletons/accountmanager.hpp"
|
||||||
|
#include "singletons/channelmanager.hpp"
|
||||||
|
#include "singletons/emotemanager.hpp"
|
||||||
|
#include "singletons/settingsmanager.hpp"
|
||||||
|
#include "singletons/windowmanager.hpp"
|
||||||
#include "twitch/twitchmessagebuilder.hpp"
|
#include "twitch/twitchmessagebuilder.hpp"
|
||||||
#include "twitch/twitchparsemessage.hpp"
|
#include "twitch/twitchparsemessage.hpp"
|
||||||
#include "twitch/twitchuser.hpp"
|
#include "twitch/twitchuser.hpp"
|
||||||
#include "util/urlfetch.hpp"
|
#include "util/urlfetch.hpp"
|
||||||
#include "windowmanager.hpp"
|
|
||||||
|
|
||||||
#include <irccommand.h>
|
#include <irccommand.h>
|
||||||
#include <QJsonArray>
|
#include <QJsonArray>
|
||||||
|
@ -27,16 +28,17 @@ using namespace chatterino::messages;
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
||||||
IrcManager::IrcManager(ChannelManager &_channelManager, Resources &_resources,
|
IrcManager::IrcManager(ChannelManager &_channelManager, Resources &_resources,
|
||||||
WindowManager &_windowManager)
|
AccountManager &_accountManager)
|
||||||
: channelManager(_channelManager)
|
: channelManager(_channelManager)
|
||||||
, resources(_resources)
|
, resources(_resources)
|
||||||
, windowManager(_windowManager)
|
, accountManager(_accountManager)
|
||||||
{
|
{
|
||||||
this->messageSuffix.append(' ');
|
this->messageSuffix.append(' ');
|
||||||
this->messageSuffix.append(QChar(0x206D));
|
this->messageSuffix.append(QChar(0x206D));
|
||||||
|
|
||||||
AccountManager::getInstance().Twitch.userChanged.connect([this]() {
|
this->account = accountManager.Twitch.getCurrent();
|
||||||
this->setUser(AccountManager::getInstance().Twitch.getCurrent());
|
accountManager.Twitch.userChanged.connect([this]() {
|
||||||
|
this->setUser(accountManager.Twitch.getCurrent());
|
||||||
|
|
||||||
debug::Log("[IrcManager] Reconnecting to Twitch IRC as new user {}",
|
debug::Log("[IrcManager] Reconnecting to Twitch IRC as new user {}",
|
||||||
this->account->getUserName());
|
this->account->getUserName());
|
||||||
|
@ -66,6 +68,13 @@ IrcManager::IrcManager(ChannelManager &_channelManager, Resources &_resources,
|
||||||
&IrcManager::onDisconnected);
|
&IrcManager::onDisconnected);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
IrcManager &IrcManager::getInstance()
|
||||||
|
{
|
||||||
|
static IrcManager instance(ChannelManager::getInstance(), Resources::getInstance(),
|
||||||
|
AccountManager::getInstance());
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
void IrcManager::setUser(std::shared_ptr<twitch::TwitchUser> newAccount)
|
void IrcManager::setUser(std::shared_ptr<twitch::TwitchUser> newAccount)
|
||||||
{
|
{
|
||||||
this->account = newAccount;
|
this->account = newAccount;
|
||||||
|
@ -231,8 +240,7 @@ void IrcManager::privateMessageReceived(Communi::IrcPrivateMessage *message)
|
||||||
|
|
||||||
messages::MessageParseArgs args;
|
messages::MessageParseArgs args;
|
||||||
|
|
||||||
twitch::TwitchMessageBuilder builder(c.get(), this->resources, this->windowManager, message,
|
twitch::TwitchMessageBuilder builder(c.get(), message, args);
|
||||||
args);
|
|
||||||
|
|
||||||
c->addMessage(builder.parse());
|
c->addMessage(builder.parse());
|
||||||
}
|
}
|
||||||
|
@ -282,8 +290,11 @@ void IrcManager::handleRoomStateMessage(Communi::IrcMessage *message)
|
||||||
if (iterator != tags.end()) {
|
if (iterator != tags.end()) {
|
||||||
auto roomID = iterator.value().toString();
|
auto roomID = iterator.value().toString();
|
||||||
|
|
||||||
auto channel = QString(message->toData()).split("#").at(1);
|
auto channel = channelManager.getTwitchChannel(QString(message->toData()).split("#").at(1));
|
||||||
channelManager.getTwitchChannel(channel)->setRoomID(roomID);
|
auto twitchChannel = dynamic_cast<twitch::TwitchChannel *>(channel.get());
|
||||||
|
if (twitchChannel != nullptr) {
|
||||||
|
twitchChannel->setRoomID(roomID);
|
||||||
|
}
|
||||||
|
|
||||||
this->resources.loadChannelData(roomID);
|
this->resources.loadChannelData(roomID);
|
||||||
}
|
}
|
||||||
|
@ -495,7 +506,7 @@ void IrcManager::onConnected()
|
||||||
{
|
{
|
||||||
std::shared_ptr<Message> msg(Message::createSystemMessage("connected to chat"));
|
std::shared_ptr<Message> msg(Message::createSystemMessage("connected to chat"));
|
||||||
|
|
||||||
this->channelManager.doOnAll([msg](std::shared_ptr<twitch::TwitchChannel> channel) {
|
this->channelManager.doOnAll([msg](std::shared_ptr<Channel> channel) {
|
||||||
assert(channel);
|
assert(channel);
|
||||||
channel->addMessage(msg);
|
channel->addMessage(msg);
|
||||||
});
|
});
|
||||||
|
@ -505,7 +516,7 @@ void IrcManager::onDisconnected()
|
||||||
{
|
{
|
||||||
std::shared_ptr<Message> msg(Message::createSystemMessage("disconnected from chat"));
|
std::shared_ptr<Message> msg(Message::createSystemMessage("disconnected from chat"));
|
||||||
|
|
||||||
this->channelManager.doOnAll([msg](std::shared_ptr<twitch::TwitchChannel> channel) {
|
this->channelManager.doOnAll([msg](std::shared_ptr<Channel> channel) {
|
||||||
assert(channel);
|
assert(channel);
|
||||||
channel->addMessage(msg);
|
channel->addMessage(msg);
|
||||||
});
|
});
|
|
@ -20,14 +20,17 @@ namespace chatterino {
|
||||||
|
|
||||||
class ChannelManager;
|
class ChannelManager;
|
||||||
class Resources;
|
class Resources;
|
||||||
class WindowManager;
|
class AccountManager;
|
||||||
|
|
||||||
class IrcManager : public QObject
|
class IrcManager : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
// Q_OBJECT
|
||||||
|
|
||||||
|
IrcManager(ChannelManager &channelManager, Resources &resources,
|
||||||
|
AccountManager &accountManager);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
IrcManager(ChannelManager &channelManager, Resources &resources, WindowManager &windowManager);
|
static IrcManager &getInstance();
|
||||||
|
|
||||||
void connect();
|
void connect();
|
||||||
void disconnect();
|
void disconnect();
|
||||||
|
@ -48,12 +51,13 @@ public:
|
||||||
pajlada::Signals::Signal<Communi::IrcPrivateMessage *> onPrivateMessage;
|
pajlada::Signals::Signal<Communi::IrcPrivateMessage *> onPrivateMessage;
|
||||||
void privateMessageReceived(Communi::IrcPrivateMessage *message);
|
void privateMessageReceived(Communi::IrcPrivateMessage *message);
|
||||||
|
|
||||||
|
Communi::IrcConnection *getReadConnection();
|
||||||
|
|
||||||
|
private:
|
||||||
ChannelManager &channelManager;
|
ChannelManager &channelManager;
|
||||||
Resources &resources;
|
Resources &resources;
|
||||||
WindowManager &windowManager;
|
AccountManager &accountManager;
|
||||||
|
|
||||||
Communi::IrcConnection* getReadConnection();
|
|
||||||
private:
|
|
||||||
// variables
|
// variables
|
||||||
std::shared_ptr<twitch::TwitchUser> account = nullptr;
|
std::shared_ptr<twitch::TwitchUser> account = nullptr;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#include "settingsmanager.hpp"
|
#include "singletons/settingsmanager.hpp"
|
||||||
#include "appdatapath.hpp"
|
#include "appdatapath.hpp"
|
||||||
#include "debug/log.hpp"
|
#include "debug/log.hpp"
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
#include "messages/word.hpp"
|
#include "messages/word.hpp"
|
||||||
#include "setting.hpp"
|
#include "setting.hpp"
|
||||||
|
#include "singletons/helper/chatterinosetting.hpp"
|
||||||
|
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <pajlada/settings/setting.hpp>
|
#include <pajlada/settings/setting.hpp>
|
||||||
|
@ -11,68 +12,6 @@ namespace chatterino {
|
||||||
|
|
||||||
static void _registerSetting(std::weak_ptr<pajlada::Settings::ISettingData> setting);
|
static void _registerSetting(std::weak_ptr<pajlada::Settings::ISettingData> setting);
|
||||||
|
|
||||||
template <typename Type>
|
|
||||||
class ChatterinoSetting : public pajlada::Settings::Setting<Type>
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
ChatterinoSetting(const std::string &_path, const Type &_defaultValue)
|
|
||||||
: pajlada::Settings::Setting<Type>(_path, _defaultValue)
|
|
||||||
{
|
|
||||||
_registerSetting(this->data);
|
|
||||||
}
|
|
||||||
|
|
||||||
void saveRecall();
|
|
||||||
|
|
||||||
ChatterinoSetting &operator=(const Type &newValue)
|
|
||||||
{
|
|
||||||
assert(this->data != nullptr);
|
|
||||||
|
|
||||||
this->setValue(newValue);
|
|
||||||
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T2>
|
|
||||||
ChatterinoSetting &operator=(const T2 &newValue)
|
|
||||||
{
|
|
||||||
assert(this->data != nullptr);
|
|
||||||
|
|
||||||
this->setValue(newValue);
|
|
||||||
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
ChatterinoSetting &operator=(Type &&newValue) noexcept
|
|
||||||
{
|
|
||||||
assert(this->data != nullptr);
|
|
||||||
|
|
||||||
this->setValue(std::move(newValue));
|
|
||||||
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool operator==(const Type &rhs) const
|
|
||||||
{
|
|
||||||
assert(this->data != nullptr);
|
|
||||||
|
|
||||||
return this->getValue() == rhs;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool operator!=(const Type &rhs) const
|
|
||||||
{
|
|
||||||
assert(this->data != nullptr);
|
|
||||||
|
|
||||||
return this->getValue() != rhs;
|
|
||||||
}
|
|
||||||
|
|
||||||
operator const Type() const
|
|
||||||
{
|
|
||||||
assert(this->data != nullptr);
|
|
||||||
|
|
||||||
return this->getValue();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class SettingsManager : public QObject
|
class SettingsManager : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
|
@ -1,7 +1,6 @@
|
||||||
#define LOOKUP_COLOR_COUNT 360
|
#define LOOKUP_COLOR_COUNT 360
|
||||||
|
|
||||||
#include "colorscheme.hpp"
|
#include "thememanager.hpp"
|
||||||
#include "windowmanager.hpp"
|
|
||||||
|
|
||||||
#include <QColor>
|
#include <QColor>
|
||||||
|
|
||||||
|
@ -28,32 +27,30 @@ double getMultiplierByTheme(const std::string &themeName)
|
||||||
|
|
||||||
} // namespace detail
|
} // namespace detail
|
||||||
|
|
||||||
ColorScheme *ColorScheme::instance = nullptr;
|
ThemeManager &ThemeManager::getInstance()
|
||||||
|
{
|
||||||
|
static ThemeManager instance;
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
ColorScheme::ColorScheme(WindowManager &windowManager)
|
ThemeManager::ThemeManager()
|
||||||
: themeName("/appearance/theme/name", "Dark")
|
: themeName("/appearance/theme/name", "Dark")
|
||||||
, themeHue("/appearance/theme/hue", 0.0)
|
, themeHue("/appearance/theme/hue", 0.0)
|
||||||
{
|
{
|
||||||
ColorScheme::instance = this;
|
|
||||||
|
|
||||||
this->update();
|
this->update();
|
||||||
|
|
||||||
this->themeName.connectSimple([this](auto) { this->update(); });
|
this->themeName.connectSimple([this](auto) { this->update(); });
|
||||||
this->themeHue.connectSimple([this](auto) { this->update(); });
|
this->themeHue.connectSimple([this](auto) { this->update(); });
|
||||||
|
|
||||||
this->updated.connect([&windowManager] {
|
|
||||||
windowManager.repaintVisibleChatWidgets(); //
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ColorScheme::update()
|
void ThemeManager::update()
|
||||||
{
|
{
|
||||||
this->setColors(this->themeHue, detail::getMultiplierByTheme(this->themeName));
|
this->actuallyUpdate(this->themeHue, detail::getMultiplierByTheme(this->themeName));
|
||||||
}
|
}
|
||||||
|
|
||||||
// hue: theme color (0 - 1)
|
// hue: theme color (0 - 1)
|
||||||
// multiplier: 1 = white, 0.8 = light, -0.8 dark, -1 black
|
// multiplier: 1 = white, 0.8 = light, -0.8 dark, -1 black
|
||||||
void ColorScheme::setColors(double hue, double multiplier)
|
void ThemeManager::actuallyUpdate(double hue, double multiplier)
|
||||||
{
|
{
|
||||||
lightTheme = multiplier > 0;
|
lightTheme = multiplier > 0;
|
||||||
|
|
||||||
|
@ -126,7 +123,7 @@ void ColorScheme::setColors(double hue, double multiplier)
|
||||||
this->updated();
|
this->updated();
|
||||||
}
|
}
|
||||||
|
|
||||||
QColor ColorScheme::blendColors(const QColor &color1, const QColor &color2, qreal ratio)
|
QColor ThemeManager::blendColors(const QColor &color1, const QColor &color2, qreal ratio)
|
||||||
{
|
{
|
||||||
int r = color1.red() * (1 - ratio) + color2.red() * ratio;
|
int r = color1.red() * (1 - ratio) + color2.red() * ratio;
|
||||||
int g = color1.green() * (1 - ratio) + color2.green() * ratio;
|
int g = color1.green() * (1 - ratio) + color2.green() * ratio;
|
||||||
|
@ -135,7 +132,7 @@ QColor ColorScheme::blendColors(const QColor &color1, const QColor &color2, qrea
|
||||||
return QColor(r, g, b, 255);
|
return QColor(r, g, b, 255);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ColorScheme::normalizeColor(QColor &color)
|
void ThemeManager::normalizeColor(QColor &color)
|
||||||
{
|
{
|
||||||
if (this->lightTheme) {
|
if (this->lightTheme) {
|
||||||
if (color.lightnessF() > 0.5f) {
|
if (color.lightnessF() > 0.5f) {
|
||||||
|
@ -143,10 +140,10 @@ void ColorScheme::normalizeColor(QColor &color)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (color.lightnessF() > 0.4f && color.hueF() > 0.1 && color.hueF() < 0.33333) {
|
if (color.lightnessF() > 0.4f && color.hueF() > 0.1 && color.hueF() < 0.33333) {
|
||||||
color.setHslF(
|
color.setHslF(color.hueF(), color.saturationF(),
|
||||||
color.hueF(), color.saturationF(),
|
color.lightnessF() -
|
||||||
color.lightnessF() - sin((color.hueF() - 0.1) / (0.3333 - 0.1) * 3.14159) *
|
sin((color.hueF() - 0.1) / (0.3333 - 0.1) * 3.14159) *
|
||||||
color.saturationF() * 0.2);
|
color.saturationF() * 0.2);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (color.lightnessF() < 0.5f) {
|
if (color.lightnessF() < 0.5f) {
|
||||||
|
@ -154,10 +151,10 @@ void ColorScheme::normalizeColor(QColor &color)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (color.lightnessF() < 0.6f && color.hueF() > 0.54444 && color.hueF() < 0.83333) {
|
if (color.lightnessF() < 0.6f && color.hueF() > 0.54444 && color.hueF() < 0.83333) {
|
||||||
color.setHslF(
|
color.setHslF(color.hueF(), color.saturationF(),
|
||||||
color.hueF(), color.saturationF(),
|
color.lightnessF() +
|
||||||
color.lightnessF() + sin((color.hueF() - 0.54444) / (0.8333 - 0.54444) * 3.14159) *
|
sin((color.hueF() - 0.54444) / (0.8333 - 0.54444) * 3.14159) *
|
||||||
color.saturationF() * 0.4);
|
color.saturationF() * 0.4);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -9,18 +9,18 @@ namespace chatterino {
|
||||||
|
|
||||||
class WindowManager;
|
class WindowManager;
|
||||||
|
|
||||||
class ColorScheme
|
class ThemeManager
|
||||||
{
|
{
|
||||||
|
ThemeManager();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit ColorScheme(WindowManager &windowManager);
|
static ThemeManager &getInstance();
|
||||||
|
|
||||||
inline bool isLightTheme() const
|
inline bool isLightTheme() const
|
||||||
{
|
{
|
||||||
return this->lightTheme;
|
return this->lightTheme;
|
||||||
}
|
}
|
||||||
|
|
||||||
static ColorScheme *instance;
|
|
||||||
|
|
||||||
QString InputStyleSheet;
|
QString InputStyleSheet;
|
||||||
|
|
||||||
QColor SystemMessageColor;
|
QColor SystemMessageColor;
|
||||||
|
@ -90,7 +90,7 @@ private:
|
||||||
pajlada::Settings::Setting<std::string> themeName;
|
pajlada::Settings::Setting<std::string> themeName;
|
||||||
pajlada::Settings::Setting<double> themeHue;
|
pajlada::Settings::Setting<double> themeHue;
|
||||||
|
|
||||||
void setColors(double hue, double multiplier);
|
void actuallyUpdate(double hue, double multiplier);
|
||||||
QColor blendColors(const QColor &color1, const QColor &color2, qreal ratio);
|
QColor blendColors(const QColor &color1, const QColor &color2, qreal ratio);
|
||||||
|
|
||||||
double middleLookupTable[360] = {};
|
double middleLookupTable[360] = {};
|
||||||
|
@ -100,6 +100,10 @@ private:
|
||||||
double toValue);
|
double toValue);
|
||||||
|
|
||||||
bool lightTheme = false;
|
bool lightTheme = false;
|
||||||
|
|
||||||
|
pajlada::Signals::NoArgSignal repaintVisibleChatWidgets;
|
||||||
|
|
||||||
|
friend class WindowManager;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace chatterino
|
} // namespace chatterino
|
|
@ -1,27 +1,27 @@
|
||||||
#include "windowmanager.hpp"
|
#include "windowmanager.hpp"
|
||||||
#include "appdatapath.hpp"
|
#include "appdatapath.hpp"
|
||||||
#include "channelmanager.hpp"
|
#include "singletons/thememanager.hpp"
|
||||||
#include "colorscheme.hpp"
|
|
||||||
#include "settingsmanager.hpp"
|
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QStandardPaths>
|
#include <QStandardPaths>
|
||||||
#include <boost/foreach.hpp>
|
#include <boost/foreach.hpp>
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
WindowManager *WindowManager::instance = nullptr;
|
WindowManager &WindowManager::getInstance()
|
||||||
|
|
||||||
WindowManager::WindowManager(ChannelManager &_channelManager, ColorScheme &_colorScheme)
|
|
||||||
: channelManager(_channelManager)
|
|
||||||
, colorScheme(_colorScheme)
|
|
||||||
{
|
{
|
||||||
WindowManager::instance = this;
|
static WindowManager instance(ThemeManager::getInstance());
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
WindowManager::WindowManager(ThemeManager &_themeManager)
|
||||||
|
: themeManager(_themeManager)
|
||||||
|
{
|
||||||
|
_themeManager.repaintVisibleChatWidgets.connect([this] { this->repaintVisibleChatWidgets(); });
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowManager::initMainWindow()
|
void WindowManager::initMainWindow()
|
||||||
{
|
{
|
||||||
this->selectedWindow = this->mainWindow =
|
this->selectedWindow = this->mainWindow = new widgets::Window("main", this->themeManager, true);
|
||||||
new widgets::Window("main", this->channelManager, this->colorScheme, true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static const std::string &getSettingsPath()
|
static const std::string &getSettingsPath()
|
||||||
|
@ -67,7 +67,7 @@ widgets::Window &WindowManager::getSelectedWindow()
|
||||||
|
|
||||||
widgets::Window &WindowManager::createWindow()
|
widgets::Window &WindowManager::createWindow()
|
||||||
{
|
{
|
||||||
auto *window = new widgets::Window("external", this->channelManager, this->colorScheme, false);
|
auto *window = new widgets::Window("external", this->themeManager, false);
|
||||||
window->getNotebook().addNewPage();
|
window->getNotebook().addNewPage();
|
||||||
|
|
||||||
this->windows.push_back(window);
|
this->windows.push_back(window);
|
|
@ -4,19 +4,14 @@
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
||||||
class ChannelManager;
|
class ThemeManager;
|
||||||
class ColorScheme;
|
|
||||||
class CompletionManager;
|
|
||||||
|
|
||||||
class WindowManager
|
class WindowManager
|
||||||
{
|
{
|
||||||
|
explicit WindowManager(ThemeManager &_themeManager);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit WindowManager(ChannelManager &_channelManager, ColorScheme &_colorScheme);
|
static WindowManager &getInstance();
|
||||||
|
|
||||||
static WindowManager *instance;
|
|
||||||
|
|
||||||
ChannelManager &channelManager;
|
|
||||||
ColorScheme &colorScheme;
|
|
||||||
|
|
||||||
void layoutVisibleChatWidgets(Channel *channel = nullptr);
|
void layoutVisibleChatWidgets(Channel *channel = nullptr);
|
||||||
void repaintVisibleChatWidgets(Channel *channel = nullptr);
|
void repaintVisibleChatWidgets(Channel *channel = nullptr);
|
||||||
|
@ -37,6 +32,8 @@ public:
|
||||||
boost::signals2::signal<void()> layout;
|
boost::signals2::signal<void()> layout;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
ThemeManager &themeManager;
|
||||||
|
|
||||||
std::vector<widgets::Window *> windows;
|
std::vector<widgets::Window *> windows;
|
||||||
|
|
||||||
widgets::Window *mainWindow = nullptr;
|
widgets::Window *mainWindow = nullptr;
|
|
@ -1,23 +1,11 @@
|
||||||
#include "accountmanager.hpp"
|
#include "twitchaccountmanager.hpp"
|
||||||
|
|
||||||
#include "common.hpp"
|
#include "common.hpp"
|
||||||
#include "const.hpp"
|
#include "const.hpp"
|
||||||
#include "debug/log.hpp"
|
#include "debug/log.hpp"
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
namespace twitch {
|
||||||
namespace {
|
|
||||||
|
|
||||||
inline QString getEnvString(const char *target)
|
|
||||||
{
|
|
||||||
char *val = std::getenv(target);
|
|
||||||
if (val == nullptr) {
|
|
||||||
return QString();
|
|
||||||
}
|
|
||||||
|
|
||||||
return QString(val);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
TwitchAccountManager::TwitchAccountManager()
|
TwitchAccountManager::TwitchAccountManager()
|
||||||
{
|
{
|
||||||
|
@ -198,25 +186,5 @@ TwitchAccountManager::AddUserResponse TwitchAccountManager::addUser(
|
||||||
|
|
||||||
return AddUserResponse::UserAdded;
|
return AddUserResponse::UserAdded;
|
||||||
}
|
}
|
||||||
|
|
||||||
AccountManager::AccountManager()
|
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AccountManager::load()
|
|
||||||
{
|
|
||||||
this->Twitch.reloadUsers();
|
|
||||||
|
|
||||||
auto currentUser = this->Twitch.findUserByUsername(
|
|
||||||
QString::fromStdString(this->Twitch.currentUsername.getValue()));
|
|
||||||
|
|
||||||
if (currentUser) {
|
|
||||||
this->Twitch.currentUser = currentUser;
|
|
||||||
} else {
|
|
||||||
this->Twitch.currentUser = this->Twitch.anonymousUser;
|
|
||||||
}
|
|
||||||
|
|
||||||
this->Twitch.userChanged.invoke();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace chatterino
|
|
|
@ -7,15 +7,21 @@
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace chatterino {
|
//
|
||||||
|
// Warning: This class is not supposed to be created directly.
|
||||||
|
// Get yourself an instance from our friends over at AccountManager.hpp
|
||||||
|
//
|
||||||
|
|
||||||
|
namespace chatterino {
|
||||||
class AccountManager;
|
class AccountManager;
|
||||||
|
|
||||||
|
namespace twitch {
|
||||||
|
|
||||||
class TwitchAccountManager
|
class TwitchAccountManager
|
||||||
{
|
{
|
||||||
public:
|
|
||||||
TwitchAccountManager();
|
TwitchAccountManager();
|
||||||
|
|
||||||
|
public:
|
||||||
struct UserData {
|
struct UserData {
|
||||||
QString username;
|
QString username;
|
||||||
QString userID;
|
QString userID;
|
||||||
|
@ -53,24 +59,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 AccountManager;
|
friend class chatterino::AccountManager;
|
||||||
};
|
};
|
||||||
|
}
|
||||||
class AccountManager
|
}
|
||||||
{
|
|
||||||
public:
|
|
||||||
static AccountManager &getInstance()
|
|
||||||
{
|
|
||||||
static AccountManager instance;
|
|
||||||
return instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
void load();
|
|
||||||
|
|
||||||
TwitchAccountManager Twitch;
|
|
||||||
|
|
||||||
private:
|
|
||||||
AccountManager();
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace chatterino
|
|
|
@ -1,6 +1,6 @@
|
||||||
#include "twitchchannel.hpp"
|
#include "twitchchannel.hpp"
|
||||||
#include "debug/log.hpp"
|
#include "debug/log.hpp"
|
||||||
#include "emotemanager.hpp"
|
#include "singletons/emotemanager.hpp"
|
||||||
#include "util/urlfetch.hpp"
|
#include "util/urlfetch.hpp"
|
||||||
|
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
|
@ -9,24 +9,20 @@
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
namespace twitch {
|
namespace twitch {
|
||||||
|
|
||||||
TwitchChannel::TwitchChannel(IrcManager &ircManager, const QString &channelName, bool _isSpecial)
|
TwitchChannel::TwitchChannel(const QString &channelName)
|
||||||
: Channel(channelName)
|
: Channel(channelName)
|
||||||
, ircManager(ircManager)
|
|
||||||
, bttvChannelEmotes(new EmoteMap)
|
, bttvChannelEmotes(new EmoteMap)
|
||||||
, ffzChannelEmotes(new EmoteMap)
|
, ffzChannelEmotes(new 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)
|
||||||
, isLive(false)
|
, isLive(false)
|
||||||
, isSpecial(_isSpecial)
|
|
||||||
{
|
{
|
||||||
debug::Log("[TwitchChannel:{}] Opened", this->name);
|
debug::Log("[TwitchChannel:{}] Opened", this->name);
|
||||||
|
|
||||||
this->dontAddMessages = true;
|
this->dontAddMessages = true;
|
||||||
|
|
||||||
if (!this->isSpecial) {
|
this->reloadChannelEmotes();
|
||||||
this->reloadChannelEmotes();
|
|
||||||
}
|
|
||||||
|
|
||||||
this->liveStatusTimer = new QTimer;
|
this->liveStatusTimer = new QTimer;
|
||||||
QObject::connect(this->liveStatusTimer, &QTimer::timeout, [this]() {
|
QObject::connect(this->liveStatusTimer, &QTimer::timeout, [this]() {
|
||||||
|
@ -56,7 +52,7 @@ bool TwitchChannel::isEmpty() const
|
||||||
|
|
||||||
bool TwitchChannel::canSendMessage() const
|
bool TwitchChannel::canSendMessage() const
|
||||||
{
|
{
|
||||||
return !this->isEmpty() && !this->isSpecial;
|
return !this->isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TwitchChannel::setRoomID(const QString &_roomID)
|
void TwitchChannel::setRoomID(const QString &_roomID)
|
||||||
|
@ -85,7 +81,7 @@ void TwitchChannel::sendMessage(const QString &message)
|
||||||
// Do last message processing
|
// Do last message processing
|
||||||
QString parsedMessage = emoteManager.replaceShortCodes(message);
|
QString parsedMessage = emoteManager.replaceShortCodes(message);
|
||||||
|
|
||||||
this->ircManager.sendMessage(this->name, parsedMessage);
|
IrcManager::getInstance().sendMessage(this->name, parsedMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TwitchChannel::setLive(bool newLiveStatus)
|
void TwitchChannel::setLive(bool newLiveStatus)
|
||||||
|
@ -159,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 = this->ircManager.getReadConnection();
|
static auto readConnection = 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;
|
||||||
|
@ -169,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);
|
||||||
this->ircManager.privateMessageReceived(privMsg);
|
IrcManager::getInstance().privateMessageReceived(privMsg);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,8 @@
|
||||||
|
|
||||||
#include "channel.hpp"
|
#include "channel.hpp"
|
||||||
#include "concurrentmap.hpp"
|
#include "concurrentmap.hpp"
|
||||||
#include "ircmanager.hpp"
|
#include "singletons/emotemanager.hpp"
|
||||||
|
#include "singletons/ircmanager.hpp"
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
namespace twitch {
|
namespace twitch {
|
||||||
|
@ -12,8 +13,7 @@ class TwitchChannel : public Channel
|
||||||
QTimer *liveStatusTimer;
|
QTimer *liveStatusTimer;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit TwitchChannel(IrcManager &ircManager, const QString &channelName,
|
explicit TwitchChannel(const QString &channelName);
|
||||||
bool _isSpecial = false);
|
|
||||||
~TwitchChannel();
|
~TwitchChannel();
|
||||||
|
|
||||||
void reloadChannelEmotes();
|
void reloadChannelEmotes();
|
||||||
|
@ -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<EmoteMap> bttvChannelEmotes;
|
const std::shared_ptr<chatterino::EmoteMap> bttvChannelEmotes;
|
||||||
const std::shared_ptr<EmoteMap> ffzChannelEmotes;
|
const std::shared_ptr<chatterino::EmoteMap> ffzChannelEmotes;
|
||||||
|
|
||||||
const QString subscriptionURL;
|
const QString subscriptionURL;
|
||||||
const QString channelURL;
|
const QString channelURL;
|
||||||
|
@ -47,10 +47,6 @@ private:
|
||||||
void refreshLiveStatus();
|
void refreshLiveStatus();
|
||||||
|
|
||||||
void fetchRecentMessages();
|
void fetchRecentMessages();
|
||||||
|
|
||||||
IrcManager &ircManager;
|
|
||||||
|
|
||||||
bool isSpecial;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace twitch
|
} // namespace twitch
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
#include "twitch/twitchmessagebuilder.hpp"
|
#include "twitchmessagebuilder.hpp"
|
||||||
#include "colorscheme.hpp"
|
|
||||||
#include "debug/log.hpp"
|
#include "debug/log.hpp"
|
||||||
#include "emotemanager.hpp"
|
|
||||||
#include "ircmanager.hpp"
|
|
||||||
#include "resources.hpp"
|
#include "resources.hpp"
|
||||||
#include "settingsmanager.hpp"
|
#include "singletons/emotemanager.hpp"
|
||||||
#include "windowmanager.hpp"
|
#include "singletons/ircmanager.hpp"
|
||||||
|
#include "singletons/settingsmanager.hpp"
|
||||||
|
#include "singletons/thememanager.hpp"
|
||||||
|
#include "singletons/windowmanager.hpp"
|
||||||
|
#include "twitch/twitchchannel.hpp"
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
@ -16,19 +17,15 @@ using namespace chatterino::messages;
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
namespace twitch {
|
namespace twitch {
|
||||||
|
|
||||||
TwitchMessageBuilder::TwitchMessageBuilder(TwitchChannel *_channel, Resources &_resources,
|
TwitchMessageBuilder::TwitchMessageBuilder(Channel *_channel,
|
||||||
WindowManager &_windowManager,
|
|
||||||
const Communi::IrcPrivateMessage *_ircMessage,
|
const Communi::IrcPrivateMessage *_ircMessage,
|
||||||
const messages::MessageParseArgs &_args)
|
const messages::MessageParseArgs &_args)
|
||||||
: channel(_channel)
|
: channel(_channel)
|
||||||
, twitchChannel(_channel)
|
, twitchChannel(dynamic_cast<TwitchChannel *>(_channel))
|
||||||
, resources(_resources)
|
|
||||||
, windowManager(_windowManager)
|
|
||||||
, colorScheme(this->windowManager.colorScheme)
|
|
||||||
, ircMessage(_ircMessage)
|
, ircMessage(_ircMessage)
|
||||||
, args(_args)
|
, args(_args)
|
||||||
, tags(this->ircMessage->tags())
|
, tags(this->ircMessage->tags())
|
||||||
, usernameColor(this->colorScheme.SystemMessageColor)
|
, usernameColor(ThemeManager::getInstance().SystemMessageColor)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,7 +39,7 @@ SharedMessage TwitchMessageBuilder::parse()
|
||||||
this->parseUsername();
|
this->parseUsername();
|
||||||
|
|
||||||
// this->message->setCollapsedDefault(true);
|
// this->message->setCollapsedDefault(true);
|
||||||
// this->appendWord(Word(this->resources.badgeCollapsed, Word::Collapsed, QString(),
|
// this->appendWord(Word(Resources::getInstance().badgeCollapsed, Word::Collapsed, QString(),
|
||||||
// QString()));
|
// QString()));
|
||||||
|
|
||||||
// The timestamp is always appended to the builder
|
// The timestamp is always appended to the builder
|
||||||
|
@ -268,6 +265,10 @@ void TwitchMessageBuilder::parseMessageID()
|
||||||
|
|
||||||
void TwitchMessageBuilder::parseRoomID()
|
void TwitchMessageBuilder::parseRoomID()
|
||||||
{
|
{
|
||||||
|
if (this->twitchChannel == nullptr) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
auto iterator = this->tags.find("room-id");
|
auto iterator = this->tags.find("room-id");
|
||||||
|
|
||||||
if (iterator != std::end(this->tags)) {
|
if (iterator != std::end(this->tags)) {
|
||||||
|
@ -470,7 +471,7 @@ void TwitchMessageBuilder::parseHighlights()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (doAlert) {
|
if (doAlert) {
|
||||||
QApplication::alert(windowManager.getMainWindow().window(), 2500);
|
QApplication::alert(WindowManager::getInstance().getMainWindow().window(), 2500);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -481,9 +482,9 @@ 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(this->resources.buttonBan, Word::ButtonBan, QString(), buttonBanTooltip,
|
this->appendWord(Word(Resources::getInstance().buttonBan, Word::ButtonBan, QString(),
|
||||||
Link(Link::UserBan, ircMessage->account())));
|
buttonBanTooltip, Link(Link::UserBan, ircMessage->account())));
|
||||||
this->appendWord(Word(this->resources.buttonTimeout, Word::ButtonTimeout, QString(),
|
this->appendWord(Word(Resources::getInstance().buttonTimeout, Word::ButtonTimeout, QString(),
|
||||||
buttonTimeoutTooltip, Link(Link::UserTimeout, ircMessage->account())));
|
buttonTimeoutTooltip, Link(Link::UserTimeout, ircMessage->account())));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -535,13 +536,15 @@ bool TwitchMessageBuilder::tryAppendEmote(QString &emoteString)
|
||||||
if (emoteManager.bttvGlobalEmotes.tryGet(emoteString, emoteData)) {
|
if (emoteManager.bttvGlobalEmotes.tryGet(emoteString, emoteData)) {
|
||||||
// BTTV Global Emote
|
// BTTV Global Emote
|
||||||
return this->appendEmote(emoteData);
|
return this->appendEmote(emoteData);
|
||||||
} else if (this->twitchChannel->bttvChannelEmotes->tryGet(emoteString, emoteData)) {
|
} else if (this->twitchChannel != nullptr &&
|
||||||
|
this->twitchChannel->bttvChannelEmotes->tryGet(emoteString, emoteData)) {
|
||||||
// BTTV Channel Emote
|
// BTTV Channel Emote
|
||||||
return this->appendEmote(emoteData);
|
return this->appendEmote(emoteData);
|
||||||
} else if (emoteManager.ffzGlobalEmotes.tryGet(emoteString, emoteData)) {
|
} else if (emoteManager.ffzGlobalEmotes.tryGet(emoteString, emoteData)) {
|
||||||
// FFZ Global Emote
|
// FFZ Global Emote
|
||||||
return this->appendEmote(emoteData);
|
return this->appendEmote(emoteData);
|
||||||
} else if (this->twitchChannel->ffzChannelEmotes->tryGet(emoteString, emoteData)) {
|
} else if (this->twitchChannel != nullptr &&
|
||||||
|
this->twitchChannel->ffzChannelEmotes->tryGet(emoteString, emoteData)) {
|
||||||
// FFZ Channel Emote
|
// FFZ Channel Emote
|
||||||
return this->appendEmote(emoteData);
|
return this->appendEmote(emoteData);
|
||||||
} else if (emoteManager.getChatterinoEmotes().tryGet(emoteString, emoteData)) {
|
} else if (emoteManager.getChatterinoEmotes().tryGet(emoteString, emoteData)) {
|
||||||
|
@ -564,7 +567,7 @@ bool TwitchMessageBuilder::appendEmote(EmoteData &emoteData)
|
||||||
|
|
||||||
void TwitchMessageBuilder::parseTwitchBadges()
|
void TwitchMessageBuilder::parseTwitchBadges()
|
||||||
{
|
{
|
||||||
const auto &channelResources = this->resources.channels[this->roomID];
|
const auto &channelResources = Resources::getInstance().channels[this->roomID];
|
||||||
|
|
||||||
auto iterator = this->tags.find("badges");
|
auto iterator = this->tags.find("badges");
|
||||||
|
|
||||||
|
@ -581,7 +584,7 @@ void TwitchMessageBuilder::parseTwitchBadges()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (badge.startsWith("bits/")) {
|
if (badge.startsWith("bits/")) {
|
||||||
if (!this->resources.dynamicBadgesLoaded) {
|
if (!Resources::getInstance().dynamicBadgesLoaded) {
|
||||||
// Do nothing
|
// Do nothing
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -590,7 +593,7 @@ void TwitchMessageBuilder::parseTwitchBadges()
|
||||||
std::string versionKey = cheerAmountQS.toStdString();
|
std::string versionKey = cheerAmountQS.toStdString();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
auto &badgeSet = this->resources.badgeSets.at("bits");
|
auto &badgeSet = Resources::getInstance().badgeSets.at("bits");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
auto &badgeVersion = badgeSet.versions.at(versionKey);
|
auto &badgeVersion = badgeSet.versions.at(versionKey);
|
||||||
|
@ -606,34 +609,35 @@ 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(this->resources.badgeStaff, Word::BadgeGlobalAuthority, QString(),
|
appendWord(Word(Resources::getInstance().badgeStaff, Word::BadgeGlobalAuthority,
|
||||||
QString("Twitch Staff")));
|
QString(), QString("Twitch Staff")));
|
||||||
} else if (badge == "admin/1") {
|
} else if (badge == "admin/1") {
|
||||||
appendWord(Word(this->resources.badgeAdmin, Word::BadgeGlobalAuthority, QString(),
|
appendWord(Word(Resources::getInstance().badgeAdmin, Word::BadgeGlobalAuthority,
|
||||||
QString("Twitch Admin")));
|
QString(), QString("Twitch Admin")));
|
||||||
} else if (badge == "global_mod/1") {
|
} else if (badge == "global_mod/1") {
|
||||||
appendWord(Word(this->resources.badgeGlobalModerator, Word::BadgeGlobalAuthority,
|
appendWord(Word(Resources::getInstance().badgeGlobalModerator,
|
||||||
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(this->resources.badgeModerator, Word::BadgeChannelAuthority, QString(),
|
appendWord(Word(Resources::getInstance().badgeModerator, Word::BadgeChannelAuthority,
|
||||||
|
QString(),
|
||||||
QString("Channel Moderator"))); // custom badge
|
QString("Channel Moderator"))); // custom badge
|
||||||
} else if (badge == "turbo/1") {
|
} else if (badge == "turbo/1") {
|
||||||
appendWord(Word(this->resources.badgeTurbo, Word::BadgeVanity, QString(),
|
appendWord(Word(Resources::getInstance().badgeTurbo, Word::BadgeVanity, QString(),
|
||||||
QString("Turbo Subscriber")));
|
QString("Turbo Subscriber")));
|
||||||
} else if (badge == "broadcaster/1") {
|
} else if (badge == "broadcaster/1") {
|
||||||
appendWord(Word(this->resources.badgeBroadcaster, Word::BadgeChannelAuthority,
|
appendWord(Word(Resources::getInstance().badgeBroadcaster, Word::BadgeChannelAuthority,
|
||||||
QString(), QString("Channel Broadcaster")));
|
QString(), QString("Channel Broadcaster")));
|
||||||
} else if (badge == "premium/1") {
|
} else if (badge == "premium/1") {
|
||||||
appendWord(Word(this->resources.badgePremium, Word::BadgeVanity, QString(),
|
appendWord(Word(Resources::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(this->resources.badgeVerified, Word::BadgeVanity, QString(),
|
appendWord(Word(Resources::getInstance().badgeVerified, Word::BadgeVanity,
|
||||||
"Twitch Verified"));
|
QString(), "Twitch Verified"));
|
||||||
} break;
|
} break;
|
||||||
default: {
|
default: {
|
||||||
printf("[TwitchMessageBuilder] Unhandled partner badge index: %d\n", index);
|
printf("[TwitchMessageBuilder] Unhandled partner badge index: %d\n", index);
|
||||||
|
@ -648,8 +652,9 @@ 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(this->resources.badgeSubscriber, Word::Flags::BadgeSubscription,
|
appendWord(Word(Resources::getInstance().badgeSubscriber,
|
||||||
QString(), QString("Twitch Subscriber")));
|
Word::Flags::BadgeSubscription, QString(),
|
||||||
|
QString("Twitch Subscriber")));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -661,8 +666,9 @@ 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(this->resources.badgeSubscriber, Word::Flags::BadgeSubscription,
|
appendWord(Word(Resources::getInstance().badgeSubscriber,
|
||||||
QString(), QString("Twitch Subscriber")));
|
Word::Flags::BadgeSubscription, QString(),
|
||||||
|
QString("Twitch Subscriber")));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -671,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 (!this->resources.dynamicBadgesLoaded) {
|
if (!Resources::getInstance().dynamicBadgesLoaded) {
|
||||||
// Do nothing
|
// Do nothing
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -689,7 +695,7 @@ void TwitchMessageBuilder::parseTwitchBadges()
|
||||||
std::string versionKey = parts[1].toStdString();
|
std::string versionKey = parts[1].toStdString();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
auto &badgeSet = this->resources.badgeSets.at(badgeSetKey);
|
auto &badgeSet = Resources::getInstance().badgeSets.at(badgeSetKey);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
auto &badgeVersion = badgeSet.versions.at(versionKey);
|
auto &badgeVersion = badgeSet.versions.at(versionKey);
|
||||||
|
@ -711,7 +717,7 @@ void TwitchMessageBuilder::parseTwitchBadges()
|
||||||
|
|
||||||
void TwitchMessageBuilder::parseChatterinoBadges()
|
void TwitchMessageBuilder::parseChatterinoBadges()
|
||||||
{
|
{
|
||||||
auto &badges = this->resources.chatterinoBadges;
|
auto &badges = Resources::getInstance().chatterinoBadges;
|
||||||
auto it = badges.find(this->userName.toStdString());
|
auto it = badges.find(this->userName.toStdString());
|
||||||
|
|
||||||
if (it == badges.end()) {
|
if (it == badges.end()) {
|
||||||
|
|
|
@ -2,8 +2,9 @@
|
||||||
|
|
||||||
#include "messages/messagebuilder.hpp"
|
#include "messages/messagebuilder.hpp"
|
||||||
#include "messages/messageparseargs.hpp"
|
#include "messages/messageparseargs.hpp"
|
||||||
#include "resources.hpp"
|
#include "singletons/emotemanager.hpp"
|
||||||
#include "twitch/twitchchannel.hpp"
|
|
||||||
|
#include <IrcMessage>
|
||||||
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
|
@ -12,9 +13,10 @@ namespace chatterino {
|
||||||
|
|
||||||
class WindowManager;
|
class WindowManager;
|
||||||
class Channel;
|
class Channel;
|
||||||
class ColorScheme;
|
class ThemeManager;
|
||||||
|
|
||||||
namespace twitch {
|
namespace twitch {
|
||||||
|
class TwitchChannel;
|
||||||
|
|
||||||
class TwitchMessageBuilder : public messages::MessageBuilder
|
class TwitchMessageBuilder : public messages::MessageBuilder
|
||||||
{
|
{
|
||||||
|
@ -27,16 +29,11 @@ public:
|
||||||
|
|
||||||
TwitchMessageBuilder() = delete;
|
TwitchMessageBuilder() = delete;
|
||||||
|
|
||||||
explicit TwitchMessageBuilder(TwitchChannel *_channel, Resources &_resources,
|
explicit TwitchMessageBuilder(Channel *_channel, const Communi::IrcPrivateMessage *_ircMessage,
|
||||||
WindowManager &_windowManager,
|
|
||||||
const Communi::IrcPrivateMessage *_ircMessage,
|
|
||||||
const messages::MessageParseArgs &_args);
|
const messages::MessageParseArgs &_args);
|
||||||
|
|
||||||
Channel *channel;
|
Channel *channel;
|
||||||
TwitchChannel *twitchChannel;
|
TwitchChannel *twitchChannel;
|
||||||
Resources &resources;
|
|
||||||
WindowManager &windowManager;
|
|
||||||
ColorScheme &colorScheme;
|
|
||||||
const Communi::IrcPrivateMessage *ircMessage;
|
const Communi::IrcPrivateMessage *ircMessage;
|
||||||
messages::MessageParseArgs args;
|
messages::MessageParseArgs args;
|
||||||
const QVariantMap tags;
|
const QVariantMap tags;
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
//#include "twitchparsemessage.hpp"
|
//#include "twitchparsemessage.hpp"
|
||||||
//#include "colorscheme.hpp"
|
//#include "colorscheme.hpp"
|
||||||
//#include "emojis.hpp"
|
//#include "emojis.hpp"
|
||||||
//#include "emotemanager.hpp"
|
//#include "singletons/emotemanager.hpp"
|
||||||
//#include "ircmanager.hpp"
|
//#include "singletons/ircmanager.hpp"
|
||||||
//#include "resources.hpp"
|
//#include "resources.hpp"
|
||||||
//#include "twitch/twitchmessagebuilder.hpp"
|
//#include "twitch/twitchmessagebuilder.hpp"
|
||||||
//
|
//
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "accountmanager.hpp"
|
#include "singletons/accountmanager.hpp"
|
||||||
#include "credentials.hpp"
|
#include "credentials.hpp"
|
||||||
#include "debug/log.hpp"
|
#include "debug/log.hpp"
|
||||||
#include "util/networkmanager.hpp"
|
#include "util/networkmanager.hpp"
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
#include "widgets/accountpopup.hpp"
|
#include "widgets/accountpopup.hpp"
|
||||||
#include "accountmanager.hpp"
|
#include "singletons/accountmanager.hpp"
|
||||||
#include "channel.hpp"
|
#include "channel.hpp"
|
||||||
#include "credentials.hpp"
|
#include "credentials.hpp"
|
||||||
#include "settingsmanager.hpp"
|
#include "singletons/settingsmanager.hpp"
|
||||||
#include "ui_accountpopupform.h"
|
#include "ui_accountpopupform.h"
|
||||||
#include "util/urlfetch.hpp"
|
#include "util/urlfetch.hpp"
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#include "accountswitchwidget.hpp"
|
#include "accountswitchwidget.hpp"
|
||||||
#include "accountmanager.hpp"
|
#include "singletons/accountmanager.hpp"
|
||||||
#include "const.hpp"
|
#include "const.hpp"
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#include "widgets/basewidget.hpp"
|
#include "widgets/basewidget.hpp"
|
||||||
#include "colorscheme.hpp"
|
#include "singletons/settingsmanager.hpp"
|
||||||
#include "settingsmanager.hpp"
|
#include "singletons/thememanager.hpp"
|
||||||
#include "widgets/tooltipwidget.hpp"
|
#include "widgets/tooltipwidget.hpp"
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
@ -12,23 +12,23 @@
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
namespace widgets {
|
namespace widgets {
|
||||||
|
|
||||||
BaseWidget::BaseWidget(ColorScheme &_colorScheme, QWidget *parent)
|
BaseWidget::BaseWidget(ThemeManager &_themeManager, QWidget *parent)
|
||||||
: QWidget(parent)
|
: QWidget(parent)
|
||||||
, colorScheme(_colorScheme)
|
, themeManager(_themeManager)
|
||||||
{
|
{
|
||||||
this->init();
|
this->init();
|
||||||
}
|
}
|
||||||
|
|
||||||
BaseWidget::BaseWidget(BaseWidget *parent)
|
BaseWidget::BaseWidget(BaseWidget *parent)
|
||||||
: QWidget(parent)
|
: QWidget(parent)
|
||||||
, colorScheme(*ColorScheme::instance)
|
, themeManager(ThemeManager::getInstance())
|
||||||
{
|
{
|
||||||
this->init();
|
this->init();
|
||||||
}
|
}
|
||||||
|
|
||||||
BaseWidget::BaseWidget(QWidget *parent)
|
BaseWidget::BaseWidget(QWidget *parent)
|
||||||
: QWidget(parent)
|
: QWidget(parent)
|
||||||
, colorScheme(*ColorScheme::instance)
|
, themeManager(ThemeManager::getInstance())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ float BaseWidget::getDpiMultiplier()
|
||||||
|
|
||||||
void BaseWidget::init()
|
void BaseWidget::init()
|
||||||
{
|
{
|
||||||
auto connection = this->colorScheme.updated.connect([this]() {
|
auto connection = this->themeManager.updated.connect([this]() {
|
||||||
this->refreshTheme();
|
this->refreshTheme();
|
||||||
|
|
||||||
this->update();
|
this->update();
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
||||||
class ColorScheme;
|
class ThemeManager;
|
||||||
|
|
||||||
namespace widgets {
|
namespace widgets {
|
||||||
|
|
||||||
|
@ -13,13 +13,13 @@ class BaseWidget : public QWidget
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit BaseWidget(ColorScheme &_colorScheme, QWidget *parent);
|
explicit BaseWidget(ThemeManager &_themeManager, QWidget *parent);
|
||||||
|
|
||||||
explicit BaseWidget(BaseWidget *parent);
|
explicit BaseWidget(BaseWidget *parent);
|
||||||
|
|
||||||
explicit BaseWidget(QWidget *parent = nullptr);
|
explicit BaseWidget(QWidget *parent = nullptr);
|
||||||
|
|
||||||
ColorScheme &colorScheme;
|
ThemeManager &themeManager;
|
||||||
|
|
||||||
float getDpiMultiplier();
|
float getDpiMultiplier();
|
||||||
|
|
||||||
|
|
|
@ -12,8 +12,8 @@ using namespace chatterino::messages;
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
namespace widgets {
|
namespace widgets {
|
||||||
|
|
||||||
EmotePopup::EmotePopup(ColorScheme &colorScheme)
|
EmotePopup::EmotePopup(ThemeManager &themeManager)
|
||||||
: BaseWidget(colorScheme, 0)
|
: BaseWidget(themeManager, 0)
|
||||||
{
|
{
|
||||||
this->initAsWindow();
|
this->initAsWindow();
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ namespace widgets {
|
||||||
class EmotePopup : public BaseWidget
|
class EmotePopup : public BaseWidget
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit EmotePopup(ColorScheme &);
|
explicit EmotePopup(ThemeManager &);
|
||||||
|
|
||||||
void loadChannel(std::shared_ptr<Channel> channel);
|
void loadChannel(std::shared_ptr<Channel> channel);
|
||||||
void loadEmojis();
|
void loadEmojis();
|
||||||
|
|
|
@ -1,17 +1,17 @@
|
||||||
#include "widgets/helper/channelview.hpp"
|
#include "channelview.hpp"
|
||||||
#include "channelmanager.hpp"
|
|
||||||
#include "colorscheme.hpp"
|
|
||||||
#include "debug/log.hpp"
|
#include "debug/log.hpp"
|
||||||
#include "messages/limitedqueuesnapshot.hpp"
|
#include "messages/limitedqueuesnapshot.hpp"
|
||||||
#include "messages/message.hpp"
|
#include "messages/message.hpp"
|
||||||
#include "messages/messageref.hpp"
|
#include "messages/messageref.hpp"
|
||||||
#include "settingsmanager.hpp"
|
#include "singletons/channelmanager.hpp"
|
||||||
|
#include "singletons/settingsmanager.hpp"
|
||||||
|
#include "singletons/thememanager.hpp"
|
||||||
|
#include "singletons/windowmanager.hpp"
|
||||||
#include "ui_accountpopupform.h"
|
#include "ui_accountpopupform.h"
|
||||||
#include "util/benchmark.hpp"
|
#include "util/benchmark.hpp"
|
||||||
#include "util/distancebetweenpoints.hpp"
|
#include "util/distancebetweenpoints.hpp"
|
||||||
#include "widgets/split.hpp"
|
#include "widgets/split.hpp"
|
||||||
#include "widgets/tooltipwidget.hpp"
|
#include "widgets/tooltipwidget.hpp"
|
||||||
#include "windowmanager.hpp"
|
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QDesktopServices>
|
#include <QDesktopServices>
|
||||||
|
@ -51,7 +51,7 @@ ChannelView::ChannelView(BaseWidget *parent)
|
||||||
this->queueUpdate();
|
this->queueUpdate();
|
||||||
});
|
});
|
||||||
|
|
||||||
WindowManager &windowManager = *WindowManager::instance;
|
WindowManager &windowManager = WindowManager::getInstance();
|
||||||
|
|
||||||
this->repaintGifsConnection =
|
this->repaintGifsConnection =
|
||||||
windowManager.repaintGifs.connect([&] { this->updateGifEmotes(); });
|
windowManager.repaintGifs.connect([&] { this->updateGifEmotes(); });
|
||||||
|
@ -445,7 +445,7 @@ void ChannelView::paintEvent(QPaintEvent * /*event*/)
|
||||||
// this->onlyUpdateEmotes = false;
|
// this->onlyUpdateEmotes = false;
|
||||||
|
|
||||||
// for (const GifEmoteData &item : this->gifEmotes) {
|
// for (const GifEmoteData &item : this->gifEmotes) {
|
||||||
// painter.fillRect(item.rect, this->colorScheme.ChatBackground);
|
// painter.fillRect(item.rect, this->themeManager.ChatBackground);
|
||||||
|
|
||||||
// painter.drawPixmap(item.rect, *item.image->getPixmap());
|
// painter.drawPixmap(item.rect, *item.image->getPixmap());
|
||||||
// }
|
// }
|
||||||
|
@ -457,7 +457,7 @@ void ChannelView::paintEvent(QPaintEvent * /*event*/)
|
||||||
// update all messages
|
// update all messages
|
||||||
this->gifEmotes.clear();
|
this->gifEmotes.clear();
|
||||||
|
|
||||||
painter.fillRect(rect(), this->colorScheme.ChatBackground);
|
painter.fillRect(rect(), this->themeManager.ChatBackground);
|
||||||
|
|
||||||
// draw messages
|
// draw messages
|
||||||
this->drawMessages(painter);
|
this->drawMessages(painter);
|
||||||
|
@ -466,7 +466,7 @@ void ChannelView::paintEvent(QPaintEvent * /*event*/)
|
||||||
|
|
||||||
// draw gif emotes
|
// draw gif emotes
|
||||||
for (GifEmoteData &item : this->gifEmotes) {
|
for (GifEmoteData &item : this->gifEmotes) {
|
||||||
// painter.fillRect(item.rect, this->colorScheme.ChatBackground);
|
// painter.fillRect(item.rect, this->themeManager.ChatBackground);
|
||||||
|
|
||||||
painter.drawPixmap(item.rect, *item.image->getPixmap());
|
painter.drawPixmap(item.rect, *item.image->getPixmap());
|
||||||
}
|
}
|
||||||
|
@ -588,8 +588,8 @@ void ChannelView::updateMessageBuffer(messages::MessageRef *messageRef, QPixmap
|
||||||
//} else {
|
//} else {
|
||||||
painter.fillRect(buffer->rect(),
|
painter.fillRect(buffer->rect(),
|
||||||
(messageRef->getMessage()->containsHighlightedPhrase())
|
(messageRef->getMessage()->containsHighlightedPhrase())
|
||||||
? this->colorScheme.ChatBackgroundHighlighted
|
? this->themeManager.ChatBackgroundHighlighted
|
||||||
: this->colorScheme.ChatBackground);
|
: this->themeManager.ChatBackground);
|
||||||
//}
|
//}
|
||||||
|
|
||||||
// draw selection
|
// draw selection
|
||||||
|
@ -613,9 +613,9 @@ void ChannelView::updateMessageBuffer(messages::MessageRef *messageRef, QPixmap
|
||||||
}
|
}
|
||||||
// text
|
// text
|
||||||
else {
|
else {
|
||||||
QColor color = wordPart.getWord().getTextColor().getColor(this->colorScheme);
|
QColor color = wordPart.getWord().getTextColor().getColor(this->themeManager);
|
||||||
|
|
||||||
this->colorScheme.normalizeColor(color);
|
this->themeManager.normalizeColor(color);
|
||||||
|
|
||||||
painter.setPen(color);
|
painter.setPen(color);
|
||||||
painter.setFont(wordPart.getWord().getFont(this->getDpiMultiplier()));
|
painter.setFont(wordPart.getWord().getFont(this->getDpiMultiplier()));
|
||||||
|
@ -636,7 +636,7 @@ void ChannelView::drawMessageSelection(QPainter &painter, messages::MessageRef *
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QColor selectionColor = this->colorScheme.Selection;
|
QColor selectionColor = this->themeManager.Selection;
|
||||||
|
|
||||||
int charIndex = 0;
|
int charIndex = 0;
|
||||||
size_t i = 0;
|
size_t i = 0;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#include "widgets/helper/droppreview.hpp"
|
#include "widgets/helper/droppreview.hpp"
|
||||||
#include "colorscheme.hpp"
|
#include "singletons/thememanager.hpp"
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
|
@ -20,7 +20,7 @@ void NotebookPageDropPreview::paintEvent(QPaintEvent *)
|
||||||
QPainter painter(this);
|
QPainter painter(this);
|
||||||
|
|
||||||
painter.fillRect(8, 8, this->width() - 17, this->height() - 17,
|
painter.fillRect(8, 8, this->width() - 17, this->height() - 17,
|
||||||
this->colorScheme.DropPreviewBackground);
|
this->themeManager.DropPreviewBackground);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NotebookPageDropPreview::hideEvent(QHideEvent *)
|
void NotebookPageDropPreview::hideEvent(QHideEvent *)
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#include "widgets/helper/notebookbutton.hpp"
|
#include "widgets/helper/notebookbutton.hpp"
|
||||||
#include "colorscheme.hpp"
|
#include "singletons/thememanager.hpp"
|
||||||
#include "widgets/helper/rippleeffectbutton.hpp"
|
#include "widgets/helper/rippleeffectbutton.hpp"
|
||||||
|
|
||||||
#include <QMouseEvent>
|
#include <QMouseEvent>
|
||||||
|
@ -23,16 +23,16 @@ void NotebookButton::paintEvent(QPaintEvent *)
|
||||||
QColor background;
|
QColor background;
|
||||||
QColor foreground;
|
QColor foreground;
|
||||||
|
|
||||||
background = this->colorScheme.TabBackground;
|
background = this->themeManager.TabBackground;
|
||||||
|
|
||||||
if (mouseDown) {
|
if (mouseDown) {
|
||||||
// background = this->colorScheme.TabSelectedBackground;
|
// background = this->themeManager.TabSelectedBackground;
|
||||||
foreground = this->colorScheme.TabHoverText;
|
foreground = this->themeManager.TabHoverText;
|
||||||
} else if (mouseOver) {
|
} else if (mouseOver) {
|
||||||
// background = this->colorScheme.TabHoverText;
|
// background = this->themeManager.TabHoverText;
|
||||||
foreground = this->colorScheme.TabHoverText;
|
foreground = this->themeManager.TabHoverText;
|
||||||
} else {
|
} else {
|
||||||
// background = this->colorScheme.TabPanelBackground;
|
// background = this->themeManager.TabPanelBackground;
|
||||||
foreground = QColor(70, 80, 80);
|
foreground = QColor(70, 80, 80);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
#include "widgets/helper/notebooktab.hpp"
|
#include "widgets/helper/notebooktab.hpp"
|
||||||
#include "colorscheme.hpp"
|
#include "singletons/thememanager.hpp"
|
||||||
#include "common.hpp"
|
#include "common.hpp"
|
||||||
#include "debug/log.hpp"
|
#include "debug/log.hpp"
|
||||||
#include "settingsmanager.hpp"
|
#include "singletons/settingsmanager.hpp"
|
||||||
#include "util/helpers.hpp"
|
#include "util/helpers.hpp"
|
||||||
#include "widgets/notebook.hpp"
|
#include "widgets/notebook.hpp"
|
||||||
#include "widgets/textinputdialog.hpp"
|
#include "widgets/textinputdialog.hpp"
|
||||||
|
@ -167,24 +167,24 @@ void NotebookTab::paintEvent(QPaintEvent *)
|
||||||
|
|
||||||
if (this->selected) {
|
if (this->selected) {
|
||||||
if (this->window() == QApplication::activeWindow()) {
|
if (this->window() == QApplication::activeWindow()) {
|
||||||
painter.fillRect(rect(), this->colorScheme.TabSelectedBackground);
|
painter.fillRect(rect(), this->themeManager.TabSelectedBackground);
|
||||||
fg = this->colorScheme.TabSelectedText;
|
fg = this->themeManager.TabSelectedText;
|
||||||
} else {
|
} else {
|
||||||
painter.fillRect(rect(), this->colorScheme.TabSelectedUnfocusedBackground);
|
painter.fillRect(rect(), this->themeManager.TabSelectedUnfocusedBackground);
|
||||||
fg = this->colorScheme.TabSelectedUnfocusedText;
|
fg = this->themeManager.TabSelectedUnfocusedText;
|
||||||
}
|
}
|
||||||
} else if (this->mouseOver) {
|
} else if (this->mouseOver) {
|
||||||
painter.fillRect(rect(), this->colorScheme.TabHoverBackground);
|
painter.fillRect(rect(), this->themeManager.TabHoverBackground);
|
||||||
fg = this->colorScheme.TabHoverText;
|
fg = this->themeManager.TabHoverText;
|
||||||
} else if (this->highlightState == HighlightState::Highlighted) {
|
} else if (this->highlightState == HighlightState::Highlighted) {
|
||||||
painter.fillRect(rect(), this->colorScheme.TabHighlightedBackground);
|
painter.fillRect(rect(), this->themeManager.TabHighlightedBackground);
|
||||||
fg = this->colorScheme.TabHighlightedText;
|
fg = this->themeManager.TabHighlightedText;
|
||||||
} else if (this->highlightState == HighlightState::NewMessage) {
|
} else if (this->highlightState == HighlightState::NewMessage) {
|
||||||
painter.fillRect(rect(), this->colorScheme.TabNewMessageBackground);
|
painter.fillRect(rect(), this->themeManager.TabNewMessageBackground);
|
||||||
fg = this->colorScheme.TabHighlightedText;
|
fg = this->themeManager.TabHighlightedText;
|
||||||
} else {
|
} else {
|
||||||
painter.fillRect(rect(), this->colorScheme.TabBackground);
|
painter.fillRect(rect(), this->themeManager.TabBackground);
|
||||||
fg = this->colorScheme.TabText;
|
fg = this->themeManager.TabText;
|
||||||
}
|
}
|
||||||
|
|
||||||
painter.setPen(fg);
|
painter.setPen(fg);
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
||||||
class ColorScheme;
|
class ThemeManager;
|
||||||
|
|
||||||
namespace widgets {
|
namespace widgets {
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#include "widgets/helper/resizingtextedit.hpp"
|
#include "widgets/helper/resizingtextedit.hpp"
|
||||||
#include "completionmanager.hpp"
|
#include "singletons/completionmanager.hpp"
|
||||||
|
|
||||||
ResizingTextEdit::ResizingTextEdit()
|
ResizingTextEdit::ResizingTextEdit()
|
||||||
{
|
{
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
|
|
||||||
#include "colorscheme.hpp"
|
#include "singletons/thememanager.hpp"
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
namespace widgets {
|
namespace widgets {
|
||||||
|
@ -37,7 +37,7 @@ void RippleEffectButton::fancyPaint(QPainter &painter)
|
||||||
if (this->mouseEffectColor) {
|
if (this->mouseEffectColor) {
|
||||||
c = this->mouseEffectColor.get();
|
c = this->mouseEffectColor.get();
|
||||||
} else {
|
} else {
|
||||||
c = this->colorScheme.isLightTheme() ? QColor(0, 0, 0) : QColor(255, 255, 255);
|
c = this->themeManager.isLightTheme() ? QColor(0, 0, 0) : QColor(255, 255, 255);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this->hoverMultiplier > 0) {
|
if (this->hoverMultiplier > 0) {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#include "widgets/helper/rippleeffectlabel.hpp"
|
#include "widgets/helper/rippleeffectlabel.hpp"
|
||||||
#include "colorscheme.hpp"
|
#include "singletons/thememanager.hpp"
|
||||||
#include "widgets/helper/splitheader.hpp"
|
#include "widgets/helper/splitheader.hpp"
|
||||||
|
|
||||||
#include <QBrush>
|
#include <QBrush>
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
||||||
class ColorScheme;
|
class ThemeManager;
|
||||||
|
|
||||||
namespace widgets {
|
namespace widgets {
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#include "widgets/helper/scrollbarhighlight.hpp"
|
#include "widgets/helper/scrollbarhighlight.hpp"
|
||||||
#include "colorscheme.hpp"
|
#include "singletons/thememanager.hpp"
|
||||||
#include "widgets/scrollbar.hpp"
|
#include "widgets/scrollbar.hpp"
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
@ -7,9 +7,9 @@ namespace widgets {
|
||||||
|
|
||||||
ScrollBarHighlight::ScrollBarHighlight(double _position, int _colorIndex, ScrollBar *parent,
|
ScrollBarHighlight::ScrollBarHighlight(double _position, int _colorIndex, ScrollBar *parent,
|
||||||
Style _style, QString _tag)
|
Style _style, QString _tag)
|
||||||
: colorScheme(parent->colorScheme)
|
: themeManager(parent->themeManager)
|
||||||
, position(_position)
|
, position(_position)
|
||||||
, colorIndex(std::max(0, std::min(this->colorScheme.HighlightColorCount, _colorIndex)))
|
, colorIndex(std::max(0, std::min(this->themeManager.HighlightColorCount, _colorIndex)))
|
||||||
, style(_style)
|
, style(_style)
|
||||||
, tag(_tag)
|
, tag(_tag)
|
||||||
{
|
{
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
||||||
class ColorScheme;
|
class ThemeManager;
|
||||||
|
|
||||||
namespace widgets {
|
namespace widgets {
|
||||||
|
|
||||||
|
@ -18,7 +18,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 = "");
|
||||||
|
|
||||||
ColorScheme &colorScheme;
|
ThemeManager &themeManager;
|
||||||
|
|
||||||
double getPosition()
|
double getPosition()
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#include "widgets/helper/splitheader.hpp"
|
#include "widgets/helper/splitheader.hpp"
|
||||||
#include "colorscheme.hpp"
|
#include "singletons/thememanager.hpp"
|
||||||
#include "twitch/twitchchannel.hpp"
|
#include "twitch/twitchchannel.hpp"
|
||||||
#include "util/urlfetch.hpp"
|
#include "util/urlfetch.hpp"
|
||||||
#include "widgets/split.hpp"
|
#include "widgets/split.hpp"
|
||||||
|
@ -135,8 +135,8 @@ void SplitHeader::paintEvent(QPaintEvent *)
|
||||||
{
|
{
|
||||||
QPainter painter(this);
|
QPainter painter(this);
|
||||||
|
|
||||||
painter.fillRect(rect(), this->colorScheme.ChatHeaderBackground);
|
painter.fillRect(rect(), this->themeManager.ChatHeaderBackground);
|
||||||
painter.setPen(this->colorScheme.ChatHeaderBorder);
|
painter.setPen(this->themeManager.ChatHeaderBorder);
|
||||||
painter.drawRect(0, 0, width() - 1, height() - 1);
|
painter.drawRect(0, 0, width() - 1, height() - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -217,7 +217,7 @@ void SplitHeader::rightButtonClicked()
|
||||||
void SplitHeader::refreshTheme()
|
void SplitHeader::refreshTheme()
|
||||||
{
|
{
|
||||||
QPalette palette;
|
QPalette palette;
|
||||||
palette.setColor(QPalette::Foreground, this->colorScheme.Text);
|
palette.setColor(QPalette::Foreground, this->themeManager.Text);
|
||||||
|
|
||||||
this->leftLabel.setPalette(palette);
|
this->leftLabel.setPalette(palette);
|
||||||
this->channelNameLabel.setPalette(palette);
|
this->channelNameLabel.setPalette(palette);
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
||||||
class ColorScheme;
|
class ThemeManager;
|
||||||
|
|
||||||
namespace widgets {
|
namespace widgets {
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
#include "widgets/helper/splitinput.hpp"
|
#include "widgets/helper/splitinput.hpp"
|
||||||
#include "colorscheme.hpp"
|
#include "singletons/completionmanager.hpp"
|
||||||
#include "completionmanager.hpp"
|
#include "singletons/ircmanager.hpp"
|
||||||
#include "ircmanager.hpp"
|
#include "singletons/settingsmanager.hpp"
|
||||||
#include "settingsmanager.hpp"
|
#include "singletons/thememanager.hpp"
|
||||||
#include "widgets/notebook.hpp"
|
#include "widgets/notebook.hpp"
|
||||||
#include "widgets/split.hpp"
|
#include "widgets/split.hpp"
|
||||||
#include "widgets/splitcontainer.hpp"
|
#include "widgets/splitcontainer.hpp"
|
||||||
|
@ -55,7 +55,7 @@ SplitInput::SplitInput(Split *_chatWidget)
|
||||||
|
|
||||||
connect(&this->emotesLabel, &RippleEffectLabel::clicked, [this] {
|
connect(&this->emotesLabel, &RippleEffectLabel::clicked, [this] {
|
||||||
if (this->emotePopup == nullptr) {
|
if (this->emotePopup == nullptr) {
|
||||||
this->emotePopup = new EmotePopup(this->colorScheme);
|
this->emotePopup = new EmotePopup(this->themeManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
this->emotePopup->resize((int)(300 * this->emotePopup->getDpiMultiplier()),
|
this->emotePopup->resize((int)(300 * this->emotePopup->getDpiMultiplier()),
|
||||||
|
@ -210,13 +210,13 @@ void SplitInput::refreshTheme()
|
||||||
{
|
{
|
||||||
QPalette palette;
|
QPalette palette;
|
||||||
|
|
||||||
palette.setColor(QPalette::Foreground, this->colorScheme.Text);
|
palette.setColor(QPalette::Foreground, this->themeManager.Text);
|
||||||
|
|
||||||
this->textLengthLabel.setPalette(palette);
|
this->textLengthLabel.setPalette(palette);
|
||||||
|
|
||||||
this->textInput.setStyleSheet(this->colorScheme.InputStyleSheet);
|
this->textInput.setStyleSheet(this->themeManager.InputStyleSheet);
|
||||||
|
|
||||||
this->hbox.setMargin((this->colorScheme.isLightTheme() ? 4 : 2) * this->getDpiMultiplier());
|
this->hbox.setMargin((this->themeManager.isLightTheme() ? 4 : 2) * this->getDpiMultiplier());
|
||||||
}
|
}
|
||||||
|
|
||||||
void SplitInput::editTextChanged()
|
void SplitInput::editTextChanged()
|
||||||
|
@ -244,10 +244,10 @@ void SplitInput::paintEvent(QPaintEvent *)
|
||||||
{
|
{
|
||||||
QPainter painter(this);
|
QPainter painter(this);
|
||||||
|
|
||||||
painter.fillRect(this->rect(), this->colorScheme.ChatInputBackground);
|
painter.fillRect(this->rect(), this->themeManager.ChatInputBackground);
|
||||||
|
|
||||||
QPen pen(this->colorScheme.ChatInputBorder);
|
QPen pen(this->themeManager.ChatInputBorder);
|
||||||
if (this->colorScheme.isLightTheme()) {
|
if (this->themeManager.isLightTheme()) {
|
||||||
pen.setWidth((int)(6 * this->getDpiMultiplier()));
|
pen.setWidth((int)(6 * this->getDpiMultiplier()));
|
||||||
}
|
}
|
||||||
painter.setPen(pen);
|
painter.setPen(pen);
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#include "widgets/notebook.hpp"
|
#include "widgets/notebook.hpp"
|
||||||
#include "colorscheme.hpp"
|
|
||||||
#include "debug/log.hpp"
|
#include "debug/log.hpp"
|
||||||
|
#include "singletons/thememanager.hpp"
|
||||||
#include "widgets/accountswitchpopupwidget.hpp"
|
#include "widgets/accountswitchpopupwidget.hpp"
|
||||||
#include "widgets/helper/notebookbutton.hpp"
|
#include "widgets/helper/notebookbutton.hpp"
|
||||||
#include "widgets/helper/notebooktab.hpp"
|
#include "widgets/helper/notebooktab.hpp"
|
||||||
|
@ -22,11 +22,9 @@
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
namespace widgets {
|
namespace widgets {
|
||||||
|
|
||||||
Notebook::Notebook(ChannelManager &_channelManager, Window *parent, bool _showButtons,
|
Notebook::Notebook(Window *parent, bool _showButtons, const std::string &settingPrefix)
|
||||||
const std::string &settingPrefix)
|
|
||||||
: BaseWidget(parent)
|
: BaseWidget(parent)
|
||||||
, settingRoot(fS("{}/notebook", settingPrefix))
|
, settingRoot(fS("{}/notebook", settingPrefix))
|
||||||
, channelManager(_channelManager)
|
|
||||||
, addButton(this)
|
, addButton(this)
|
||||||
, settingsButton(this)
|
, settingsButton(this)
|
||||||
, userButton(this)
|
, userButton(this)
|
||||||
|
@ -58,7 +56,7 @@ SplitContainer *Notebook::addNewPage()
|
||||||
SplitContainer *Notebook::addPage(const std::string &uuid, bool select)
|
SplitContainer *Notebook::addPage(const std::string &uuid, bool select)
|
||||||
{
|
{
|
||||||
auto tab = new NotebookTab(this, uuid);
|
auto tab = new NotebookTab(this, uuid);
|
||||||
auto page = new SplitContainer(this->channelManager, this, tab, uuid);
|
auto page = new SplitContainer(this, tab, uuid);
|
||||||
|
|
||||||
tab->show();
|
tab->show();
|
||||||
|
|
||||||
|
|
|
@ -25,8 +25,7 @@ class Notebook : public BaseWidget
|
||||||
public:
|
public:
|
||||||
enum HighlightType { none, highlighted, newMessage };
|
enum HighlightType { none, highlighted, newMessage };
|
||||||
|
|
||||||
explicit Notebook(ChannelManager &_channelManager, Window *parent, bool _showButtons,
|
explicit Notebook(Window *parent, bool _showButtons, const std::string &settingPrefix);
|
||||||
const std::string &settingPrefix);
|
|
||||||
|
|
||||||
SplitContainer *addNewPage();
|
SplitContainer *addNewPage();
|
||||||
SplitContainer *addPage(const std::string &uuid, bool select = false);
|
SplitContainer *addPage(const std::string &uuid, bool select = false);
|
||||||
|
@ -58,9 +57,6 @@ public slots:
|
||||||
void usersButtonClicked();
|
void usersButtonClicked();
|
||||||
void addPageButtonClicked();
|
void addPageButtonClicked();
|
||||||
|
|
||||||
public:
|
|
||||||
ChannelManager &channelManager;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QList<SplitContainer *> pages;
|
QList<SplitContainer *> pages;
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#include "widgets/scrollbar.hpp"
|
#include "widgets/scrollbar.hpp"
|
||||||
#include "colorscheme.hpp"
|
#include "singletons/thememanager.hpp"
|
||||||
#include "widgets/helper/channelview.hpp"
|
#include "widgets/helper/channelview.hpp"
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
@ -234,22 +234,22 @@ void ScrollBar::paintEvent(QPaintEvent *)
|
||||||
int xOffset = mouseOver ? 0 : width() - (int)(4 * this->getDpiMultiplier());
|
int xOffset = mouseOver ? 0 : width() - (int)(4 * this->getDpiMultiplier());
|
||||||
|
|
||||||
QPainter painter(this);
|
QPainter painter(this);
|
||||||
// painter.fillRect(rect(), this->colorScheme.ScrollbarBG);
|
// painter.fillRect(rect(), this->themeManager.ScrollbarBG);
|
||||||
|
|
||||||
painter.fillRect(QRect(xOffset, 0, width(), this->buttonHeight),
|
painter.fillRect(QRect(xOffset, 0, width(), this->buttonHeight),
|
||||||
this->colorScheme.ScrollbarArrow);
|
this->themeManager.ScrollbarArrow);
|
||||||
painter.fillRect(QRect(xOffset, height() - this->buttonHeight, width(), this->buttonHeight),
|
painter.fillRect(QRect(xOffset, height() - this->buttonHeight, width(), this->buttonHeight),
|
||||||
this->colorScheme.ScrollbarArrow);
|
this->themeManager.ScrollbarArrow);
|
||||||
|
|
||||||
this->thumbRect.setX(xOffset);
|
this->thumbRect.setX(xOffset);
|
||||||
|
|
||||||
// mouse over thumb
|
// mouse over thumb
|
||||||
if (this->mouseDownIndex == 2) {
|
if (this->mouseDownIndex == 2) {
|
||||||
painter.fillRect(this->thumbRect, this->colorScheme.ScrollbarThumbSelected);
|
painter.fillRect(this->thumbRect, this->themeManager.ScrollbarThumbSelected);
|
||||||
}
|
}
|
||||||
// mouse not over thumb
|
// mouse not over thumb
|
||||||
else {
|
else {
|
||||||
painter.fillRect(this->thumbRect, this->colorScheme.ScrollbarThumb);
|
painter.fillRect(this->thumbRect, this->themeManager.ScrollbarThumb);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ScrollBarHighlight *highlight = highlights;
|
// ScrollBarHighlight *highlight = highlights;
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "singletons/settingsmanager.hpp"
|
||||||
#include "widgets/basewidget.hpp"
|
#include "widgets/basewidget.hpp"
|
||||||
#include "widgets/helper/scrollbarhighlight.hpp"
|
#include "widgets/helper/scrollbarhighlight.hpp"
|
||||||
|
|
||||||
|
@ -7,11 +8,10 @@
|
||||||
#include <QPropertyAnimation>
|
#include <QPropertyAnimation>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <boost/signals2.hpp>
|
#include <boost/signals2.hpp>
|
||||||
#include <settingsmanager.hpp>
|
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
||||||
class ColorScheme;
|
class ThemeManager;
|
||||||
|
|
||||||
namespace widgets {
|
namespace widgets {
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
#include "widgets/settingsdialog.hpp"
|
#include "widgets/settingsdialog.hpp"
|
||||||
#include "accountmanager.hpp"
|
#include "singletons/accountmanager.hpp"
|
||||||
#include "const.hpp"
|
#include "const.hpp"
|
||||||
#include "debug/log.hpp"
|
#include "debug/log.hpp"
|
||||||
#include "twitch/twitchmessagebuilder.hpp"
|
#include "twitch/twitchmessagebuilder.hpp"
|
||||||
#include "twitch/twitchuser.hpp"
|
#include "twitch/twitchuser.hpp"
|
||||||
#include "widgets/helper/settingsdialogtab.hpp"
|
#include "widgets/helper/settingsdialogtab.hpp"
|
||||||
#include "widgets/logindialog.hpp"
|
#include "widgets/logindialog.hpp"
|
||||||
#include "windowmanager.hpp"
|
#include "singletons/windowmanager.hpp"
|
||||||
|
|
||||||
#include <QComboBox>
|
#include <QComboBox>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "settingsmanager.hpp"
|
#include "singletons/settingsmanager.hpp"
|
||||||
#include "widgets/accountswitchwidget.hpp"
|
#include "widgets/accountswitchwidget.hpp"
|
||||||
#include "widgets/helper/settingsdialogtab.hpp"
|
#include "widgets/helper/settingsdialogtab.hpp"
|
||||||
|
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
#include "widgets/split.hpp"
|
#include "widgets/split.hpp"
|
||||||
#include "channelmanager.hpp"
|
#include "singletons/channelmanager.hpp"
|
||||||
#include "colorscheme.hpp"
|
#include "singletons/settingsmanager.hpp"
|
||||||
#include "settingsmanager.hpp"
|
#include "singletons/thememanager.hpp"
|
||||||
|
#include "singletons/windowmanager.hpp"
|
||||||
#include "twitch/twitchmessagebuilder.hpp"
|
#include "twitch/twitchmessagebuilder.hpp"
|
||||||
#include "util/urlfetch.hpp"
|
#include "util/urlfetch.hpp"
|
||||||
#include "widgets/qualitypopup.hpp"
|
#include "widgets/qualitypopup.hpp"
|
||||||
#include "widgets/splitcontainer.hpp"
|
#include "widgets/splitcontainer.hpp"
|
||||||
#include "widgets/textinputdialog.hpp"
|
#include "widgets/textinputdialog.hpp"
|
||||||
#include "widgets/window.hpp"
|
#include "widgets/window.hpp"
|
||||||
#include "windowmanager.hpp"
|
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QClipboard>
|
#include <QClipboard>
|
||||||
|
@ -45,14 +45,13 @@ inline void ezShortcut(Split *w, const char *key, T t)
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
Split::Split(ChannelManager &_channelManager, SplitContainer *parent, const std::string &_uuid)
|
Split::Split(SplitContainer *parent, const std::string &_uuid)
|
||||||
: BaseWidget(parent)
|
: BaseWidget(parent)
|
||||||
, uuid(_uuid)
|
, uuid(_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)
|
||||||
, channelManager(_channelManager)
|
, channel(ChannelManager::getInstance().emptyChannel)
|
||||||
, channel(_channelManager.emptyChannel)
|
|
||||||
, vbox(this)
|
, vbox(this)
|
||||||
, header(this)
|
, header(this)
|
||||||
, view(this)
|
, view(this)
|
||||||
|
@ -171,17 +170,18 @@ double Split::getFlexSizeY()
|
||||||
|
|
||||||
void Split::channelNameUpdated(const std::string &newChannelName)
|
void Split::channelNameUpdated(const std::string &newChannelName)
|
||||||
{
|
{
|
||||||
|
auto &cman = ChannelManager::getInstance();
|
||||||
|
|
||||||
// remove current channel
|
// remove current channel
|
||||||
if (!this->channel->isEmpty()) {
|
if (!this->channel->isEmpty()) {
|
||||||
this->channelManager.removeTwitchChannel(this->channel->name);
|
cman.removeTwitchChannel(this->channel->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
// update messages
|
// update messages
|
||||||
if (newChannelName.empty()) {
|
if (newChannelName.empty()) {
|
||||||
this->setChannel(this->channelManager.emptyChannel);
|
this->setChannel(cman.emptyChannel);
|
||||||
} else {
|
} else {
|
||||||
this->setChannel(
|
this->setChannel(cman.addTwitchChannel(QString::fromStdString(newChannelName)));
|
||||||
this->channelManager.addTwitchChannel(QString::fromStdString(newChannelName)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// update header
|
// update header
|
||||||
|
@ -236,7 +236,7 @@ void Split::paintEvent(QPaintEvent *)
|
||||||
// color the background of the chat
|
// color the background of the chat
|
||||||
QPainter painter(this);
|
QPainter painter(this);
|
||||||
|
|
||||||
painter.fillRect(this->rect(), this->colorScheme.ChatBackground);
|
painter.fillRect(this->rect(), this->themeManager.ChatBackground);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Slots
|
/// Slots
|
||||||
|
@ -264,10 +264,9 @@ void Split::doChangeChannel()
|
||||||
|
|
||||||
void Split::doPopup()
|
void Split::doPopup()
|
||||||
{
|
{
|
||||||
Window &window = WindowManager::instance->createWindow();
|
Window &window = WindowManager::getInstance().createWindow();
|
||||||
|
|
||||||
Split *split = new Split(this->channelManager,
|
Split *split = new Split(static_cast<SplitContainer *>(window.getNotebook().getSelectedPage()),
|
||||||
static_cast<SplitContainer *>(window.getNotebook().getSelectedPage()),
|
|
||||||
this->uuid);
|
this->uuid);
|
||||||
|
|
||||||
window.getNotebook().getSelectedPage()->addToLayout(split);
|
window.getNotebook().getSelectedPage()->addToLayout(split);
|
||||||
|
@ -396,7 +395,7 @@ void Split::doOpenViewerList()
|
||||||
QList<QListWidgetItem *> labelList;
|
QList<QListWidgetItem *> labelList;
|
||||||
for (auto &x : labels) {
|
for (auto &x : labels) {
|
||||||
auto label = new QListWidgetItem(x);
|
auto label = new QListWidgetItem(x);
|
||||||
label->setBackgroundColor(this->colorScheme.ChatHeaderBackground);
|
label->setBackgroundColor(this->themeManager.ChatHeaderBackground);
|
||||||
labelList.append(label);
|
labelList.append(label);
|
||||||
}
|
}
|
||||||
auto loadingLabel = new QLabel("Loading...");
|
auto loadingLabel = new QLabel("Loading...");
|
||||||
|
@ -453,7 +452,7 @@ void Split::doOpenViewerList()
|
||||||
dockVbox->addWidget(resultList);
|
dockVbox->addWidget(resultList);
|
||||||
resultList->hide();
|
resultList->hide();
|
||||||
|
|
||||||
multiWidget->setStyleSheet(this->colorScheme.InputStyleSheet);
|
multiWidget->setStyleSheet(this->themeManager.InputStyleSheet);
|
||||||
multiWidget->setLayout(dockVbox);
|
multiWidget->setLayout(dockVbox);
|
||||||
viewerDock->setWidget(multiWidget);
|
viewerDock->setWidget(multiWidget);
|
||||||
viewerDock->show();
|
viewerDock->show();
|
||||||
|
|
|
@ -19,9 +19,6 @@
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
||||||
class ChannelManager;
|
|
||||||
class ColorScheme;
|
|
||||||
|
|
||||||
namespace widgets {
|
namespace widgets {
|
||||||
|
|
||||||
class SplitContainer;
|
class SplitContainer;
|
||||||
|
@ -46,10 +43,9 @@ class Split : public BaseWidget
|
||||||
const std::string settingRoot;
|
const std::string settingRoot;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Split(ChannelManager &_channelManager, SplitContainer *parent, const std::string &_uuid);
|
Split(SplitContainer *parent, const std::string &_uuid);
|
||||||
~Split();
|
~Split();
|
||||||
|
|
||||||
ChannelManager &channelManager;
|
|
||||||
pajlada::Settings::Setting<std::string> channelName;
|
pajlada::Settings::Setting<std::string> channelName;
|
||||||
boost::signals2::signal<void()> channelChanged;
|
boost::signals2::signal<void()> channelChanged;
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#include "widgets/splitcontainer.hpp"
|
#include "widgets/splitcontainer.hpp"
|
||||||
#include "colorscheme.hpp"
|
|
||||||
#include "common.hpp"
|
#include "common.hpp"
|
||||||
|
#include "singletons/thememanager.hpp"
|
||||||
#include "util/helpers.hpp"
|
#include "util/helpers.hpp"
|
||||||
#include "widgets/helper/notebooktab.hpp"
|
#include "widgets/helper/notebooktab.hpp"
|
||||||
#include "widgets/notebook.hpp"
|
#include "widgets/notebook.hpp"
|
||||||
|
@ -25,13 +25,11 @@ bool SplitContainer::isDraggingSplit = false;
|
||||||
Split *SplitContainer::draggingSplit = nullptr;
|
Split *SplitContainer::draggingSplit = nullptr;
|
||||||
std::pair<int, int> SplitContainer::dropPosition = std::pair<int, int>(-1, -1);
|
std::pair<int, int> SplitContainer::dropPosition = std::pair<int, int>(-1, -1);
|
||||||
|
|
||||||
SplitContainer::SplitContainer(ChannelManager &_channelManager, Notebook *parent, NotebookTab *_tab,
|
SplitContainer::SplitContainer(Notebook *parent, NotebookTab *_tab, const std::string &_uuid)
|
||||||
const std::string &_uuid)
|
: BaseWidget(parent->themeManager, parent)
|
||||||
: BaseWidget(parent->colorScheme, parent)
|
|
||||||
, uuid(_uuid)
|
, uuid(_uuid)
|
||||||
, settingRoot(fS("/containers/{}", this->uuid))
|
, settingRoot(fS("/containers/{}", this->uuid))
|
||||||
, chats(fS("{}/chats", this->settingRoot))
|
, chats(fS("{}/chats", this->settingRoot))
|
||||||
, channelManager(_channelManager)
|
|
||||||
, tab(_tab)
|
, tab(_tab)
|
||||||
, dropPreview(this)
|
, dropPreview(this)
|
||||||
, chatWidgets()
|
, chatWidgets()
|
||||||
|
@ -387,17 +385,17 @@ void SplitContainer::paintEvent(QPaintEvent *)
|
||||||
QPainter painter(this);
|
QPainter painter(this);
|
||||||
|
|
||||||
if (this->ui.hbox.count() == 0) {
|
if (this->ui.hbox.count() == 0) {
|
||||||
painter.fillRect(rect(), this->colorScheme.ChatBackground);
|
painter.fillRect(rect(), this->themeManager.ChatBackground);
|
||||||
|
|
||||||
painter.setPen(this->colorScheme.Text);
|
painter.setPen(this->themeManager.Text);
|
||||||
painter.drawText(rect(), "Add Chat", QTextOption(Qt::AlignCenter));
|
painter.drawText(rect(), "Add Chat", QTextOption(Qt::AlignCenter));
|
||||||
} else {
|
} else {
|
||||||
painter.fillRect(rect(), this->colorScheme.ChatSeperator);
|
painter.fillRect(rect(), this->themeManager.ChatSeperator);
|
||||||
}
|
}
|
||||||
|
|
||||||
QColor accentColor = (QApplication::activeWindow() == this->window()
|
QColor accentColor = (QApplication::activeWindow() == this->window()
|
||||||
? this->colorScheme.TabSelectedBackground
|
? this->themeManager.TabSelectedBackground
|
||||||
: this->colorScheme.TabSelectedUnfocusedBackground);
|
: this->themeManager.TabSelectedUnfocusedBackground);
|
||||||
|
|
||||||
painter.fillRect(0, 0, width(), 2, accentColor);
|
painter.fillRect(0, 0, width(), 2, accentColor);
|
||||||
}
|
}
|
||||||
|
@ -432,7 +430,7 @@ std::pair<int, int> SplitContainer::getChatPosition(const Split *chatWidget)
|
||||||
|
|
||||||
Split *SplitContainer::createChatWidget(const std::string &uuid)
|
Split *SplitContainer::createChatWidget(const std::string &uuid)
|
||||||
{
|
{
|
||||||
auto split = new Split(this->channelManager, this, uuid);
|
auto split = new Split(this, uuid);
|
||||||
|
|
||||||
split->getChannelView().highlightedMessageReceived.connect([this] {
|
split->getChannelView().highlightedMessageReceived.connect([this] {
|
||||||
this->tab->setHighlightState(HighlightState::Highlighted); //
|
this->tab->setHighlightState(HighlightState::Highlighted); //
|
||||||
|
|
|
@ -26,16 +26,13 @@ class SplitContainer : public BaseWidget
|
||||||
const std::string settingRoot;
|
const std::string settingRoot;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SplitContainer(ChannelManager &_channelManager, Notebook *parent, NotebookTab *_tab,
|
SplitContainer(Notebook *parent, NotebookTab *_tab, const std::string &_uuid);
|
||||||
const std::string &_uuid);
|
|
||||||
|
|
||||||
const std::string &getUUID() const
|
const std::string &getUUID() const
|
||||||
{
|
{
|
||||||
return this->uuid;
|
return this->uuid;
|
||||||
}
|
}
|
||||||
|
|
||||||
ChannelManager &channelManager;
|
|
||||||
|
|
||||||
std::pair<int, int> removeFromLayout(Split *widget);
|
std::pair<int, int> removeFromLayout(Split *widget);
|
||||||
void addToLayout(Split *widget, std::pair<int, int> position = std::pair<int, int>(-1, -1));
|
void addToLayout(Split *widget, std::pair<int, int> position = std::pair<int, int>(-1, -1));
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#include "tooltipwidget.hpp"
|
#include "tooltipwidget.hpp"
|
||||||
#include "colorscheme.hpp"
|
#include "singletons/thememanager.hpp"
|
||||||
#include "fontmanager.hpp"
|
#include "singletons/fontmanager.hpp"
|
||||||
|
|
||||||
#include <QStyle>
|
#include <QStyle>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
#include "widgets/window.hpp"
|
#include "widgets/window.hpp"
|
||||||
#include "accountmanager.hpp"
|
#include "singletons/accountmanager.hpp"
|
||||||
#include "channelmanager.hpp"
|
#include "singletons/channelmanager.hpp"
|
||||||
#include "colorscheme.hpp"
|
#include "singletons/settingsmanager.hpp"
|
||||||
#include "settingsmanager.hpp"
|
#include "singletons/thememanager.hpp"
|
||||||
#include "widgets/notebook.hpp"
|
#include "widgets/notebook.hpp"
|
||||||
#include "widgets/settingsdialog.hpp"
|
#include "widgets/settingsdialog.hpp"
|
||||||
#include "widgets/split.hpp"
|
#include "widgets/split.hpp"
|
||||||
|
@ -14,15 +14,13 @@
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
namespace widgets {
|
namespace widgets {
|
||||||
|
|
||||||
Window::Window(const QString &windowName, ChannelManager &_channelManager,
|
Window::Window(const QString &windowName, ThemeManager &_themeManager, bool _isMainWindow)
|
||||||
ColorScheme &_colorScheme, bool _isMainWindow)
|
: BaseWidget(_themeManager, nullptr)
|
||||||
: BaseWidget(_colorScheme, nullptr)
|
|
||||||
, settingRoot(fS("/windows/{}", windowName))
|
, settingRoot(fS("/windows/{}", windowName))
|
||||||
, windowGeometry(this->settingRoot)
|
, windowGeometry(this->settingRoot)
|
||||||
, dpi(this->getDpiMultiplier())
|
, dpi(this->getDpiMultiplier())
|
||||||
, channelManager(_channelManager)
|
, themeManager(_themeManager)
|
||||||
, colorScheme(_colorScheme)
|
, notebook(this, _isMainWindow, this->settingRoot)
|
||||||
, notebook(this->channelManager, this, _isMainWindow, this->settingRoot)
|
|
||||||
{
|
{
|
||||||
this->initAsWindow();
|
this->initAsWindow();
|
||||||
|
|
||||||
|
@ -110,7 +108,7 @@ void Window::closeEvent(QCloseEvent *)
|
||||||
void Window::refreshTheme()
|
void Window::refreshTheme()
|
||||||
{
|
{
|
||||||
QPalette palette;
|
QPalette palette;
|
||||||
palette.setColor(QPalette::Background, this->colorScheme.TabBackground);
|
palette.setColor(QPalette::Background, this->themeManager.TabBackground);
|
||||||
this->setPalette(palette);
|
this->setPalette(palette);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
||||||
class ChannelManager;
|
class ChannelManager;
|
||||||
class ColorScheme;
|
class ThemeManager;
|
||||||
class CompletionManager;
|
class CompletionManager;
|
||||||
|
|
||||||
namespace widgets {
|
namespace widgets {
|
||||||
|
@ -45,8 +45,7 @@ class Window : public BaseWidget
|
||||||
WindowGeometry windowGeometry;
|
WindowGeometry windowGeometry;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit Window(const QString &windowName, ChannelManager &_channelManager,
|
explicit Window(const QString &windowName, ThemeManager &_themeManager, bool isMainWindow);
|
||||||
ColorScheme &_colorScheme, bool isMainWindow);
|
|
||||||
|
|
||||||
void repaintVisibleChatWidgets(Channel *channel = nullptr);
|
void repaintVisibleChatWidgets(Channel *channel = nullptr);
|
||||||
|
|
||||||
|
@ -60,15 +59,14 @@ protected:
|
||||||
virtual void closeEvent(QCloseEvent *event) override;
|
virtual void closeEvent(QCloseEvent *event) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
ThemeManager &themeManager;
|
||||||
|
|
||||||
float dpi;
|
float dpi;
|
||||||
|
|
||||||
virtual void refreshTheme() override;
|
virtual void refreshTheme() override;
|
||||||
|
|
||||||
void loadGeometry();
|
void loadGeometry();
|
||||||
|
|
||||||
ChannelManager &channelManager;
|
|
||||||
ColorScheme &colorScheme;
|
|
||||||
|
|
||||||
Notebook notebook;
|
Notebook notebook;
|
||||||
TitleBar titleBar;
|
TitleBar titleBar;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue