mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
Perform initial refactoring work
Things that were once singletons are no longer singletons, but are instead stored in the "Application" singleton Some singletons still remain, and some renaming/renamespacing is left
This commit is contained in:
parent
32b6417a55
commit
ae26b835b6
|
@ -1,4 +1,5 @@
|
||||||
#include "application.hpp"
|
#include "application.hpp"
|
||||||
|
|
||||||
#include "providers/twitch/twitchserver.hpp"
|
#include "providers/twitch/twitchserver.hpp"
|
||||||
#include "singletons/accountmanager.hpp"
|
#include "singletons/accountmanager.hpp"
|
||||||
#include "singletons/commandmanager.hpp"
|
#include "singletons/commandmanager.hpp"
|
||||||
|
@ -12,60 +13,114 @@
|
||||||
#include "singletons/windowmanager.hpp"
|
#include "singletons/windowmanager.hpp"
|
||||||
#include "util/posttothread.hpp"
|
#include "util/posttothread.hpp"
|
||||||
|
|
||||||
|
#include <atomic>
|
||||||
|
|
||||||
|
#ifdef Q_OS_WIN
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <io.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
using namespace chatterino::singletons;
|
using namespace chatterino::singletons;
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
bool isBigEndian()
|
||||||
|
{
|
||||||
|
int test = 1;
|
||||||
|
char *p = (char *)&test;
|
||||||
|
|
||||||
|
return p[0] == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
static std::atomic<bool> isAppConstructed{false};
|
||||||
|
static std::atomic<bool> isAppInitialized{false};
|
||||||
|
|
||||||
|
static Application *staticApp = nullptr;
|
||||||
|
|
||||||
// this class is responsible for handling the workflow of Chatterino
|
// this class is responsible for handling the workflow of 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(int _argc, char **_argv)
|
||||||
|
: argc(_argc)
|
||||||
|
, argv(_argv)
|
||||||
{
|
{
|
||||||
singletons::NativeMessagingManager::getInstance().registerHost();
|
}
|
||||||
|
|
||||||
singletons::WindowManager::getInstance();
|
void Application::construct()
|
||||||
|
{
|
||||||
|
assert(isAppConstructed == false);
|
||||||
|
isAppConstructed = true;
|
||||||
|
|
||||||
singletons::LoggingManager::getInstance();
|
// 1. Instantiate all classes
|
||||||
|
this->paths = new singletons::PathManager(argc, argv);
|
||||||
|
this->themes = new singletons::ThemeManager;
|
||||||
|
this->windows = new singletons::WindowManager;
|
||||||
|
this->logging = new singletons::LoggingManager;
|
||||||
|
this->commands = new singletons::CommandManager;
|
||||||
|
this->accounts = new singletons::AccountManager;
|
||||||
|
this->emotes = new singletons::EmoteManager;
|
||||||
|
this->pubsub = new singletons::PubSubManager;
|
||||||
|
this->settings = new singletons::SettingManager;
|
||||||
|
}
|
||||||
|
|
||||||
singletons::SettingManager::getInstance().initialize();
|
void Application::instantiate(int argc, char **argv)
|
||||||
singletons::CommandManager::getInstance().loadCommands();
|
{
|
||||||
|
assert(staticApp == nullptr);
|
||||||
|
|
||||||
singletons::WindowManager::getInstance().initialize();
|
staticApp = new Application(argc, argv);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Application::initialize()
|
||||||
|
{
|
||||||
|
assert(isAppInitialized == false);
|
||||||
|
isAppInitialized = true;
|
||||||
|
|
||||||
|
// 2. Initialize/load classes
|
||||||
|
this->windows->initialize();
|
||||||
|
|
||||||
|
this->nativeMessaging->registerHost();
|
||||||
|
|
||||||
|
this->settings->initialize();
|
||||||
|
this->commands->loadCommands();
|
||||||
|
|
||||||
// Initialize everything we need
|
// Initialize everything we need
|
||||||
singletons::EmoteManager::getInstance().loadGlobalEmotes();
|
this->emotes->loadGlobalEmotes();
|
||||||
|
|
||||||
singletons::AccountManager::getInstance().load();
|
this->accounts->load();
|
||||||
|
|
||||||
// XXX
|
// XXX
|
||||||
singletons::SettingManager::getInstance().updateWordTypeMask();
|
this->settings->updateWordTypeMask();
|
||||||
|
|
||||||
singletons::NativeMessagingManager::getInstance().openGuiMessageQueue();
|
this->nativeMessaging->openGuiMessageQueue();
|
||||||
auto &pubsub = singletons::PubSubManager::getInstance();
|
|
||||||
|
|
||||||
pubsub.sig.whisper.sent.connect([](const auto &msg) {
|
this->pubsub->sig.whisper.sent.connect([](const auto &msg) {
|
||||||
debug::Log("WHISPER SENT LOL"); //
|
debug::Log("WHISPER SENT LOL"); //
|
||||||
});
|
});
|
||||||
|
|
||||||
pubsub.sig.whisper.received.connect([](const auto &msg) {
|
this->pubsub->sig.whisper.received.connect([](const auto &msg) {
|
||||||
debug::Log("WHISPER RECEIVED LOL"); //
|
debug::Log("WHISPER RECEIVED LOL"); //
|
||||||
});
|
});
|
||||||
|
|
||||||
pubsub.sig.moderation.chatCleared.connect([&](const auto &action) {
|
this->pubsub->sig.moderation.chatCleared.connect([&](const auto &action) {
|
||||||
debug::Log("Chat cleared by {}", action.source.name); //
|
debug::Log("Chat cleared by {}", action.source.name); //
|
||||||
});
|
});
|
||||||
|
|
||||||
pubsub.sig.moderation.modeChanged.connect([&](const auto &action) {
|
this->pubsub->sig.moderation.modeChanged.connect([&](const auto &action) {
|
||||||
debug::Log("Mode {} was turned {} by {} (duration {})", (int &)action.mode,
|
debug::Log("Mode {} was turned {} by {} (duration {})", (int &)action.mode,
|
||||||
(bool &)action.state, action.source.name, action.args.duration);
|
(bool &)action.state, action.source.name, action.args.duration);
|
||||||
});
|
});
|
||||||
|
|
||||||
pubsub.sig.moderation.moderationStateChanged.connect([&](const auto &action) {
|
this->pubsub->sig.moderation.moderationStateChanged.connect([&](const auto &action) {
|
||||||
debug::Log("User {} was {} by {}", action.target.id, action.modded ? "modded" : "unmodded",
|
debug::Log("User {} was {} by {}", action.target.id, action.modded ? "modded" : "unmodded",
|
||||||
action.source.name);
|
action.source.name);
|
||||||
});
|
});
|
||||||
|
|
||||||
pubsub.sig.moderation.userBanned.connect([&](const auto &action) {
|
this->pubsub->sig.moderation.userBanned.connect([&](const auto &action) {
|
||||||
auto &server = providers::twitch::TwitchServer::getInstance();
|
auto &server = providers::twitch::TwitchServer::getInstance();
|
||||||
auto chan = server.getChannelOrEmptyByID(action.roomID);
|
auto chan = server.getChannelOrEmptyByID(action.roomID);
|
||||||
|
|
||||||
|
@ -78,7 +133,7 @@ Application::Application()
|
||||||
util::postToThread([chan, msg] { chan->addMessage(msg); });
|
util::postToThread([chan, msg] { chan->addMessage(msg); });
|
||||||
});
|
});
|
||||||
|
|
||||||
pubsub.sig.moderation.userUnbanned.connect([&](const auto &action) {
|
this->pubsub->sig.moderation.userUnbanned.connect([&](const auto &action) {
|
||||||
auto &server = providers::twitch::TwitchServer::getInstance();
|
auto &server = providers::twitch::TwitchServer::getInstance();
|
||||||
auto chan = server.getChannelOrEmptyByID(action.roomID);
|
auto chan = server.getChannelOrEmptyByID(action.roomID);
|
||||||
|
|
||||||
|
@ -91,44 +146,95 @@ Application::Application()
|
||||||
util::postToThread([chan, msg] { chan->addMessage(msg); });
|
util::postToThread([chan, msg] { chan->addMessage(msg); });
|
||||||
});
|
});
|
||||||
|
|
||||||
auto &accountManager = singletons::AccountManager::getInstance();
|
this->pubsub->Start();
|
||||||
|
|
||||||
pubsub.Start();
|
auto RequestModerationActions = [=]() {
|
||||||
|
this->pubsub->UnlistenAllModerationActions();
|
||||||
auto RequestModerationActions = [&]() {
|
|
||||||
pubsub.UnlistenAllModerationActions();
|
|
||||||
// TODO(pajlada): Unlisten to all authed topics instead of only moderation topics
|
// TODO(pajlada): Unlisten to all authed topics instead of only moderation topics
|
||||||
// pubsub.UnlistenAllAuthedTopics();
|
// this->pubsub->UnlistenAllAuthedTopics();
|
||||||
|
|
||||||
pubsub.ListenToWhispers(singletons::AccountManager::getInstance().Twitch.getCurrent()); //
|
this->pubsub->ListenToWhispers(this->accounts->Twitch.getCurrent()); //
|
||||||
};
|
};
|
||||||
|
|
||||||
accountManager.Twitch.userChanged.connect(RequestModerationActions);
|
this->accounts->Twitch.userChanged.connect(RequestModerationActions);
|
||||||
|
|
||||||
RequestModerationActions();
|
RequestModerationActions();
|
||||||
}
|
}
|
||||||
|
|
||||||
Application::~Application()
|
|
||||||
{
|
|
||||||
this->save();
|
|
||||||
}
|
|
||||||
|
|
||||||
int Application::run(QApplication &qtApp)
|
int Application::run(QApplication &qtApp)
|
||||||
{
|
{
|
||||||
// Start connecting to the IRC Servers (Twitch only for now)
|
// Start connecting to the IRC Servers (Twitch only for now)
|
||||||
providers::twitch::TwitchServer::getInstance().connect();
|
providers::twitch::TwitchServer::getInstance().connect();
|
||||||
|
|
||||||
// Show main window
|
// Show main window
|
||||||
singletons::WindowManager::getInstance().getMainWindow().show();
|
this->windows->getMainWindow().show();
|
||||||
|
|
||||||
return qtApp.exec();
|
return qtApp.exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::save()
|
void Application::save()
|
||||||
{
|
{
|
||||||
singletons::WindowManager::getInstance().save();
|
this->windows->save();
|
||||||
|
|
||||||
singletons::CommandManager::getInstance().saveCommands();
|
this->commands->saveCommands();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Application::runNativeMessagingHost()
|
||||||
|
{
|
||||||
|
auto app = getApp();
|
||||||
|
|
||||||
|
app->nativeMessaging = new singletons::NativeMessagingManager;
|
||||||
|
|
||||||
|
#ifdef Q_OS_WIN
|
||||||
|
_setmode(_fileno(stdin), _O_BINARY);
|
||||||
|
_setmode(_fileno(stdout), _O_BINARY);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
bool bigEndian = isBigEndian();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
while (true) {
|
||||||
|
char size_c[4];
|
||||||
|
std::cin.read(size_c, 4);
|
||||||
|
|
||||||
|
if (std::cin.eof()) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t size = *reinterpret_cast<uint32_t *>(size_c);
|
||||||
|
#if 0
|
||||||
|
// To avoid breaking strict-aliasing rules and potentially inducing undefined behaviour, the following code can be run instead
|
||||||
|
uint32_t size = 0;
|
||||||
|
if (bigEndian) {
|
||||||
|
size = size_c[3] | static_cast<uint32_t>(size_c[2]) << 8 |
|
||||||
|
static_cast<uint32_t>(size_c[1]) << 16 | static_cast<uint32_t>(size_c[0]) << 24;
|
||||||
|
} else {
|
||||||
|
size = size_c[0] | static_cast<uint32_t>(size_c[1]) << 8 |
|
||||||
|
static_cast<uint32_t>(size_c[2]) << 16 | static_cast<uint32_t>(size_c[3]) << 24;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
char *b = (char *)malloc(size + 1);
|
||||||
|
std::cin.read(b, size);
|
||||||
|
*(b + size) = '\0';
|
||||||
|
|
||||||
|
app->nativeMessaging->sendToGuiProcess(QByteArray(b, size));
|
||||||
|
|
||||||
|
free(b);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Application *getApp()
|
||||||
|
{
|
||||||
|
assert(staticApp != nullptr);
|
||||||
|
|
||||||
|
return staticApp;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool appInitialized()
|
||||||
|
{
|
||||||
|
return isAppInitialized;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace chatterino
|
} // namespace chatterino
|
||||||
|
|
|
@ -7,16 +7,59 @@
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
||||||
|
namespace singletons {
|
||||||
|
|
||||||
|
class ThemeManager;
|
||||||
|
class WindowManager;
|
||||||
|
class LoggingManager;
|
||||||
|
class PathManager;
|
||||||
|
class CommandManager;
|
||||||
|
class AccountManager;
|
||||||
|
class EmoteManager;
|
||||||
|
class PubSubManager;
|
||||||
|
class NativeMessagingManager;
|
||||||
|
class SettingManager;
|
||||||
|
|
||||||
|
} // namespace singletons
|
||||||
|
|
||||||
class Application
|
class Application
|
||||||
{
|
{
|
||||||
|
Application(int _argc, char **_argv);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Application();
|
static void instantiate(int argc, char **argv);
|
||||||
~Application();
|
|
||||||
|
~Application() = delete;
|
||||||
|
|
||||||
|
void construct();
|
||||||
|
void initialize();
|
||||||
|
void load();
|
||||||
|
|
||||||
int run(QApplication &qtApp);
|
int run(QApplication &qtApp);
|
||||||
|
|
||||||
private:
|
singletons::PathManager *paths = nullptr;
|
||||||
|
singletons::ThemeManager *themes = nullptr;
|
||||||
|
singletons::WindowManager *windows = nullptr;
|
||||||
|
singletons::LoggingManager *logging = nullptr;
|
||||||
|
singletons::CommandManager *commands = nullptr;
|
||||||
|
singletons::AccountManager *accounts = nullptr;
|
||||||
|
singletons::EmoteManager *emotes = nullptr;
|
||||||
|
singletons::PubSubManager *pubsub = nullptr;
|
||||||
|
singletons::NativeMessagingManager *nativeMessaging = nullptr;
|
||||||
|
singletons::SettingManager *settings = nullptr;
|
||||||
|
|
||||||
void save();
|
void save();
|
||||||
|
|
||||||
|
// Special application mode that only initializes the native messaging host
|
||||||
|
static void runNativeMessagingHost();
|
||||||
|
|
||||||
|
private:
|
||||||
|
int argc;
|
||||||
|
char **argv;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Application *getApp();
|
||||||
|
|
||||||
|
bool appInitialized();
|
||||||
|
|
||||||
} // namespace chatterino
|
} // namespace chatterino
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
#include "channel.hpp"
|
#include "channel.hpp"
|
||||||
|
|
||||||
|
#include "application.hpp"
|
||||||
#include "debug/log.hpp"
|
#include "debug/log.hpp"
|
||||||
#include "messages/message.hpp"
|
#include "messages/message.hpp"
|
||||||
#include "singletons/emotemanager.hpp"
|
#include "singletons/emotemanager.hpp"
|
||||||
|
@ -55,6 +57,7 @@ messages::LimitedQueueSnapshot<messages::MessagePtr> Channel::getMessageSnapshot
|
||||||
|
|
||||||
void Channel::addMessage(MessagePtr message)
|
void Channel::addMessage(MessagePtr message)
|
||||||
{
|
{
|
||||||
|
auto app = getApp();
|
||||||
MessagePtr deleted;
|
MessagePtr deleted;
|
||||||
|
|
||||||
bool isTimeout = (message->flags & Message::Timeout) != 0;
|
bool isTimeout = (message->flags & Message::Timeout) != 0;
|
||||||
|
@ -67,7 +70,7 @@ void Channel::addMessage(MessagePtr message)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
singletons::LoggingManager::getInstance().addMessage(this->name, message);
|
app->logging->addMessage(this->name, message);
|
||||||
|
|
||||||
if (isTimeout) {
|
if (isTimeout) {
|
||||||
LimitedQueueSnapshot<MessagePtr> snapshot = this->getMessageSnapshot();
|
LimitedQueueSnapshot<MessagePtr> snapshot = this->getMessageSnapshot();
|
||||||
|
|
88
src/main.cpp
88
src/main.cpp
|
@ -17,21 +17,6 @@
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include <io.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
bool isBigEndian()
|
|
||||||
{
|
|
||||||
int test = 1;
|
|
||||||
char *p = (char *)&test;
|
|
||||||
|
|
||||||
return p[0] == 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void runNativeMessagingHost();
|
|
||||||
int runGui(int argc, char *argv[]);
|
int runGui(int argc, char *argv[]);
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
|
@ -45,7 +30,7 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
// TODO: can be any argument
|
// TODO: can be any argument
|
||||||
if (args.size() > 0 && args[0].startsWith("chrome-extension://")) {
|
if (args.size() > 0 && args[0].startsWith("chrome-extension://")) {
|
||||||
runNativeMessagingHost();
|
chatterino::Application::runNativeMessagingHost();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,18 +52,17 @@ int runGui(int argc, char *argv[])
|
||||||
a.installNativeEventFilter(new chatterino::util::DpiNativeEventFilter);
|
a.installNativeEventFilter(new chatterino::util::DpiNativeEventFilter);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Initialize settings
|
|
||||||
bool success = chatterino::singletons::PathManager::getInstance().init(argc, argv);
|
|
||||||
if (!success) {
|
|
||||||
printf("Error initializing paths\n");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Initialize NetworkManager
|
// Initialize NetworkManager
|
||||||
chatterino::util::NetworkManager::init();
|
chatterino::util::NetworkManager::init();
|
||||||
|
|
||||||
|
// Initialize application
|
||||||
|
chatterino::Application::instantiate(argc, argv);
|
||||||
|
auto app = chatterino::getApp();
|
||||||
|
|
||||||
|
app->construct();
|
||||||
|
|
||||||
|
auto &pathMan = *app->paths;
|
||||||
// Running file
|
// Running file
|
||||||
auto &pathMan = chatterino::singletons::PathManager::getInstance();
|
|
||||||
auto runningPath = pathMan.settingsFolderPath + "/running_" + pathMan.appPathHash;
|
auto runningPath = pathMan.settingsFolderPath + "/running_" + pathMan.appPathHash;
|
||||||
|
|
||||||
if (QFile::exists(runningPath)) {
|
if (QFile::exists(runningPath)) {
|
||||||
|
@ -94,16 +78,14 @@ int runGui(int argc, char *argv[])
|
||||||
runningFile.close();
|
runningFile.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Application
|
app->initialize();
|
||||||
{
|
|
||||||
// Initialize application
|
|
||||||
chatterino::Application app;
|
|
||||||
|
|
||||||
// Start the application
|
// Start the application
|
||||||
app.run(a);
|
// This is a blocking call
|
||||||
|
app->run(a);
|
||||||
|
|
||||||
// Application will go out of scope here and deinitialize itself
|
// We have finished our application, make sure we save stuff
|
||||||
}
|
app->save();
|
||||||
|
|
||||||
// Running file
|
// Running file
|
||||||
QFile::remove(runningPath);
|
QFile::remove(runningPath);
|
||||||
|
@ -116,47 +98,3 @@ int runGui(int argc, char *argv[])
|
||||||
|
|
||||||
_exit(0);
|
_exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void runNativeMessagingHost()
|
|
||||||
{
|
|
||||||
#ifdef Q_OS_WIN
|
|
||||||
_setmode(_fileno(stdin), _O_BINARY);
|
|
||||||
_setmode(_fileno(stdout), _O_BINARY);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
auto &nmm = chatterino::singletons::NativeMessagingManager::getInstance();
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
bool bigEndian = isBigEndian();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
while (true) {
|
|
||||||
char size_c[4];
|
|
||||||
std::cin.read(size_c, 4);
|
|
||||||
|
|
||||||
if (std::cin.eof()) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t size = *reinterpret_cast<uint32_t *>(size_c);
|
|
||||||
#if 0
|
|
||||||
// To avoid breaking strict-aliasing rules and potentially inducing undefined behaviour, the following code can be run instead
|
|
||||||
uint32_t size = 0;
|
|
||||||
if (bigEndian) {
|
|
||||||
size = size_c[3] | static_cast<uint32_t>(size_c[2]) << 8 |
|
|
||||||
static_cast<uint32_t>(size_c[1]) << 16 | static_cast<uint32_t>(size_c[0]) << 24;
|
|
||||||
} else {
|
|
||||||
size = size_c[0] | static_cast<uint32_t>(size_c[1]) << 8 |
|
|
||||||
static_cast<uint32_t>(size_c[2]) << 16 | static_cast<uint32_t>(size_c[3]) << 24;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
char *b = (char *)malloc(size + 1);
|
|
||||||
std::cin.read(b, size);
|
|
||||||
*(b + size) = '\0';
|
|
||||||
|
|
||||||
nmm.sendToGuiProcess(QByteArray(b, size));
|
|
||||||
|
|
||||||
free(b);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
#include "messages/image.hpp"
|
#include "messages/image.hpp"
|
||||||
|
|
||||||
|
#include "application.hpp"
|
||||||
#include "singletons/emotemanager.hpp"
|
#include "singletons/emotemanager.hpp"
|
||||||
#include "singletons/ircmanager.hpp"
|
#include "singletons/ircmanager.hpp"
|
||||||
#include "singletons/windowmanager.hpp"
|
#include "singletons/windowmanager.hpp"
|
||||||
|
@ -123,7 +125,7 @@ void Image::loadImage()
|
||||||
if (this->allFrames.size() > 1) {
|
if (this->allFrames.size() > 1) {
|
||||||
if (!this->animated) {
|
if (!this->animated) {
|
||||||
util::postToThread([this] {
|
util::postToThread([this] {
|
||||||
singletons::EmoteManager::getInstance().getGifUpdateSignal().connect([=]() {
|
getApp()->emotes->getGifUpdateSignal().connect([=]() {
|
||||||
this->gifUpdateTimout();
|
this->gifUpdateTimout();
|
||||||
}); // For some reason when Boost signal is in
|
}); // For some reason when Boost signal is in
|
||||||
// thread scope and thread deletes the signal
|
// thread scope and thread deletes the signal
|
||||||
|
@ -145,9 +147,10 @@ void Image::loadImage()
|
||||||
loadedEventQueued = true;
|
loadedEventQueued = true;
|
||||||
|
|
||||||
QTimer::singleShot(500, [] {
|
QTimer::singleShot(500, [] {
|
||||||
singletons::EmoteManager::getInstance().incGeneration();
|
getApp()->emotes->incGeneration();
|
||||||
|
|
||||||
singletons::WindowManager::getInstance().layoutVisibleChatWidgets();
|
auto app = getApp();
|
||||||
|
app->windows->layoutVisibleChatWidgets();
|
||||||
loadedEventQueued = false;
|
loadedEventQueued = false;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
#include "messages/layouts/messagelayout.hpp"
|
#include "messages/layouts/messagelayout.hpp"
|
||||||
|
|
||||||
|
#include "application.hpp"
|
||||||
#include "singletons/emotemanager.hpp"
|
#include "singletons/emotemanager.hpp"
|
||||||
#include "singletons/settingsmanager.hpp"
|
#include "singletons/settingsmanager.hpp"
|
||||||
|
|
||||||
|
@ -45,7 +47,7 @@ int MessageLayout::getHeight() const
|
||||||
// return true if redraw is required
|
// return true if redraw is required
|
||||||
bool MessageLayout::layout(int width, float scale, MessageElement::Flags flags)
|
bool MessageLayout::layout(int width, float scale, MessageElement::Flags flags)
|
||||||
{
|
{
|
||||||
auto &emoteManager = singletons::EmoteManager::getInstance();
|
auto app = getApp();
|
||||||
|
|
||||||
bool layoutRequired = false;
|
bool layoutRequired = false;
|
||||||
|
|
||||||
|
@ -55,9 +57,9 @@ bool MessageLayout::layout(int width, float scale, MessageElement::Flags flags)
|
||||||
this->currentLayoutWidth = width;
|
this->currentLayoutWidth = width;
|
||||||
|
|
||||||
// check if emotes changed
|
// check if emotes changed
|
||||||
bool imagesChanged = this->emoteGeneration != emoteManager.getGeneration();
|
bool imagesChanged = this->emoteGeneration != app->emotes->getGeneration();
|
||||||
layoutRequired |= imagesChanged;
|
layoutRequired |= imagesChanged;
|
||||||
this->emoteGeneration = emoteManager.getGeneration();
|
this->emoteGeneration = app->emotes->getGeneration();
|
||||||
|
|
||||||
// check if text changed
|
// check if text changed
|
||||||
bool textChanged =
|
bool textChanged =
|
||||||
|
@ -66,14 +68,12 @@ bool MessageLayout::layout(int width, float scale, MessageElement::Flags flags)
|
||||||
this->fontGeneration = singletons::FontManager::getInstance().getGeneration();
|
this->fontGeneration = singletons::FontManager::getInstance().getGeneration();
|
||||||
|
|
||||||
// check if work mask changed
|
// check if work mask changed
|
||||||
bool wordMaskChanged = this->currentWordFlags !=
|
bool wordMaskChanged = this->currentWordFlags != flags; // app->settings->getWordTypeMask();
|
||||||
flags; // singletons::SettingManager::getInstance().getWordTypeMask();
|
|
||||||
layoutRequired |= wordMaskChanged;
|
layoutRequired |= wordMaskChanged;
|
||||||
this->currentWordFlags = flags; // singletons::SettingManager::getInstance().getWordTypeMask();
|
this->currentWordFlags = flags; // app->settings->getWordTypeMask();
|
||||||
|
|
||||||
// check if timestamp format changed
|
// check if timestamp format changed
|
||||||
bool timestampFormatChanged =
|
bool timestampFormatChanged = this->timestampFormat != app->settings->timestampFormat;
|
||||||
this->timestampFormat != singletons::SettingManager::getInstance().timestampFormat;
|
|
||||||
|
|
||||||
layoutRequired |= timestampFormatChanged;
|
layoutRequired |= timestampFormatChanged;
|
||||||
|
|
||||||
|
@ -128,8 +128,8 @@ void MessageLayout::actuallyLayout(int width, MessageElement::Flags flags)
|
||||||
void MessageLayout::paint(QPainter &painter, int y, int messageIndex, Selection &selection,
|
void MessageLayout::paint(QPainter &painter, int y, int messageIndex, Selection &selection,
|
||||||
bool isLastReadMessage, bool isWindowFocused)
|
bool isLastReadMessage, bool isWindowFocused)
|
||||||
{
|
{
|
||||||
|
auto app = getApp();
|
||||||
QPixmap *pixmap = this->buffer.get();
|
QPixmap *pixmap = this->buffer.get();
|
||||||
singletons::ThemeManager &themeManager = singletons::ThemeManager::getInstance();
|
|
||||||
|
|
||||||
// create new buffer if required
|
// create new buffer if required
|
||||||
if (!pixmap) {
|
if (!pixmap) {
|
||||||
|
@ -160,7 +160,8 @@ void MessageLayout::paint(QPainter &painter, int y, int messageIndex, Selection
|
||||||
|
|
||||||
// draw disabled
|
// draw disabled
|
||||||
if (this->message->flags.HasFlag(Message::Disabled)) {
|
if (this->message->flags.HasFlag(Message::Disabled)) {
|
||||||
painter.fillRect(0, y, pixmap->width(), pixmap->height(), themeManager.messages.disabled);
|
painter.fillRect(0, y, pixmap->width(), pixmap->height(),
|
||||||
|
app->themes->messages.disabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
// draw selection
|
// draw selection
|
||||||
|
@ -170,8 +171,9 @@ void MessageLayout::paint(QPainter &painter, int y, int messageIndex, Selection
|
||||||
|
|
||||||
// draw last read message line
|
// draw last read message line
|
||||||
if (isLastReadMessage) {
|
if (isLastReadMessage) {
|
||||||
QColor color = isWindowFocused ? themeManager.tabs.selected.backgrounds.regular.color()
|
QColor color = isWindowFocused
|
||||||
: themeManager.tabs.selected.backgrounds.unfocused.color();
|
? app->themes->tabs.selected.backgrounds.regular.color()
|
||||||
|
: app->themes->tabs.selected.backgrounds.unfocused.color();
|
||||||
|
|
||||||
QBrush brush(color, Qt::VerPattern);
|
QBrush brush(color, Qt::VerPattern);
|
||||||
|
|
||||||
|
@ -184,7 +186,7 @@ void MessageLayout::paint(QPainter &painter, int y, int messageIndex, Selection
|
||||||
|
|
||||||
void MessageLayout::updateBuffer(QPixmap *buffer, int messageIndex, Selection &selection)
|
void MessageLayout::updateBuffer(QPixmap *buffer, int messageIndex, Selection &selection)
|
||||||
{
|
{
|
||||||
singletons::ThemeManager &themeManager = singletons::ThemeManager::getInstance();
|
auto app = getApp();
|
||||||
|
|
||||||
QPainter painter(buffer);
|
QPainter painter(buffer);
|
||||||
|
|
||||||
|
@ -192,8 +194,8 @@ void MessageLayout::updateBuffer(QPixmap *buffer, int messageIndex, Selection &s
|
||||||
|
|
||||||
// draw background
|
// draw background
|
||||||
painter.fillRect(buffer->rect(), this->message->flags & Message::Highlighted
|
painter.fillRect(buffer->rect(), this->message->flags & Message::Highlighted
|
||||||
? themeManager.messages.backgrounds.highlighted
|
? app->themes->messages.backgrounds.highlighted
|
||||||
: themeManager.messages.backgrounds.regular);
|
: app->themes->messages.backgrounds.regular);
|
||||||
|
|
||||||
// draw message
|
// draw message
|
||||||
this->container.paintElements(painter);
|
this->container.paintElements(painter);
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include "messagelayoutcontainer.hpp"
|
#include "messagelayoutcontainer.hpp"
|
||||||
|
|
||||||
|
#include "application.hpp"
|
||||||
#include "messagelayoutelement.hpp"
|
#include "messagelayoutelement.hpp"
|
||||||
#include "messages/selection.hpp"
|
#include "messages/selection.hpp"
|
||||||
#include "singletons/settingsmanager.hpp"
|
#include "singletons/settingsmanager.hpp"
|
||||||
|
@ -210,8 +211,8 @@ void MessageLayoutContainer::paintAnimatedElements(QPainter &painter, int yOffse
|
||||||
void MessageLayoutContainer::paintSelection(QPainter &painter, int messageIndex,
|
void MessageLayoutContainer::paintSelection(QPainter &painter, int messageIndex,
|
||||||
Selection &selection, int yOffset)
|
Selection &selection, int yOffset)
|
||||||
{
|
{
|
||||||
singletons::ThemeManager &themeManager = singletons::ThemeManager::getInstance();
|
auto app = getApp();
|
||||||
QColor selectionColor = themeManager.messages.selection;
|
QColor selectionColor = app->themes->messages.selection;
|
||||||
|
|
||||||
// don't draw anything
|
// don't draw anything
|
||||||
if (selection.selectionMin.messageIndex > messageIndex ||
|
if (selection.selectionMin.messageIndex > messageIndex ||
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#include "messages/layouts/messagelayoutelement.hpp"
|
#include "messages/layouts/messagelayoutelement.hpp"
|
||||||
|
#include "application.hpp"
|
||||||
#include "messages/messageelement.hpp"
|
#include "messages/messageelement.hpp"
|
||||||
#include "util/debugcount.hpp"
|
#include "util/debugcount.hpp"
|
||||||
|
|
||||||
|
@ -239,9 +240,11 @@ int TextIconLayoutElement::getSelectionIndexCount()
|
||||||
|
|
||||||
void TextIconLayoutElement::paint(QPainter &painter)
|
void TextIconLayoutElement::paint(QPainter &painter)
|
||||||
{
|
{
|
||||||
|
auto app = getApp();
|
||||||
|
|
||||||
QFont font = singletons::FontManager::getInstance().getFont(FontStyle::Tiny, this->scale);
|
QFont font = singletons::FontManager::getInstance().getFont(FontStyle::Tiny, this->scale);
|
||||||
|
|
||||||
painter.setPen(singletons::ThemeManager::getInstance().messages.textColors.system);
|
painter.setPen(app->themes->messages.textColors.system);
|
||||||
painter.setFont(font);
|
painter.setFont(font);
|
||||||
|
|
||||||
QTextOption option;
|
QTextOption option;
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
#include "messages/messageelement.hpp"
|
#include "messages/messageelement.hpp"
|
||||||
|
|
||||||
|
#include "application.hpp"
|
||||||
#include "messages/layouts/messagelayoutcontainer.hpp"
|
#include "messages/layouts/messagelayoutcontainer.hpp"
|
||||||
#include "messages/layouts/messagelayoutelement.hpp"
|
#include "messages/layouts/messagelayoutelement.hpp"
|
||||||
#include "singletons/settingsmanager.hpp"
|
#include "singletons/settingsmanager.hpp"
|
||||||
|
@ -95,7 +97,7 @@ void EmoteElement::addToContainer(MessageLayoutContainer &container, MessageElem
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int quality = singletons::SettingManager::getInstance().preferredEmoteQuality;
|
int quality = getApp()->settings->preferredEmoteQuality;
|
||||||
|
|
||||||
Image *_image;
|
Image *_image;
|
||||||
if (quality == 3 && this->data.image3x != nullptr) {
|
if (quality == 3 && this->data.image3x != nullptr) {
|
||||||
|
@ -134,16 +136,16 @@ TextElement::TextElement(const QString &text, MessageElement::Flags flags,
|
||||||
|
|
||||||
void TextElement::addToContainer(MessageLayoutContainer &container, MessageElement::Flags _flags)
|
void TextElement::addToContainer(MessageLayoutContainer &container, MessageElement::Flags _flags)
|
||||||
{
|
{
|
||||||
|
auto app = getApp();
|
||||||
|
|
||||||
if (_flags & this->getFlags()) {
|
if (_flags & this->getFlags()) {
|
||||||
QFontMetrics &metrics = singletons::FontManager::getInstance().getFontMetrics(
|
QFontMetrics &metrics = singletons::FontManager::getInstance().getFontMetrics(
|
||||||
this->style, container.getScale());
|
this->style, container.getScale());
|
||||||
singletons::ThemeManager &themeManager =
|
|
||||||
singletons::ThemeManager::ThemeManager::getInstance();
|
|
||||||
|
|
||||||
for (Word &word : this->words) {
|
for (Word &word : this->words) {
|
||||||
auto getTextLayoutElement = [&](QString text, int width, bool trailingSpace) {
|
auto getTextLayoutElement = [&](QString text, int width, bool trailingSpace) {
|
||||||
QColor color = this->color.getColor(themeManager);
|
QColor color = this->color.getColor(*app->themes);
|
||||||
themeManager.normalizeColor(color);
|
app->themes->normalizeColor(color);
|
||||||
|
|
||||||
auto e = (new TextLayoutElement(*this, text, QSize(width, metrics.height()), color,
|
auto e = (new TextLayoutElement(*this, text, QSize(width, metrics.height()), color,
|
||||||
this->style, container.getScale()))
|
this->style, container.getScale()))
|
||||||
|
@ -225,8 +227,9 @@ void TimestampElement::addToContainer(MessageLayoutContainer &container,
|
||||||
MessageElement::Flags _flags)
|
MessageElement::Flags _flags)
|
||||||
{
|
{
|
||||||
if (_flags & this->getFlags()) {
|
if (_flags & this->getFlags()) {
|
||||||
if (singletons::SettingManager::getInstance().timestampFormat != this->format) {
|
auto app = getApp();
|
||||||
this->format = singletons::SettingManager::getInstance().timestampFormat.getValue();
|
if (app->settings->timestampFormat != this->format) {
|
||||||
|
this->format = app->settings->timestampFormat.getValue();
|
||||||
this->element.reset(this->formatTime(this->time));
|
this->element.reset(this->formatTime(this->time));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -238,8 +241,7 @@ TextElement *TimestampElement::formatTime(const QTime &time)
|
||||||
{
|
{
|
||||||
static QLocale locale("en_US");
|
static QLocale locale("en_US");
|
||||||
|
|
||||||
QString format =
|
QString format = locale.toString(time, getApp()->settings->timestampFormat);
|
||||||
locale.toString(time, singletons::SettingManager::getInstance().timestampFormat);
|
|
||||||
|
|
||||||
return new TextElement(format, Flags::Timestamp, MessageColor::System, FontStyle::Medium);
|
return new TextElement(format, Flags::Timestamp, MessageColor::System, FontStyle::Medium);
|
||||||
}
|
}
|
||||||
|
@ -256,8 +258,7 @@ void TwitchModerationElement::addToContainer(MessageLayoutContainer &container,
|
||||||
if (_flags & MessageElement::ModeratorTools) {
|
if (_flags & MessageElement::ModeratorTools) {
|
||||||
QSize size((int)(container.getScale() * 16), (int)(container.getScale() * 16));
|
QSize size((int)(container.getScale() * 16), (int)(container.getScale() * 16));
|
||||||
|
|
||||||
for (const singletons::ModerationAction &m :
|
for (const singletons::ModerationAction &m : getApp()->settings->getModerationActions()) {
|
||||||
singletons::SettingManager::getInstance().getModerationActions()) {
|
|
||||||
if (m.isImage()) {
|
if (m.isImage()) {
|
||||||
container.addElement((new ImageLayoutElement(*this, m.getImage(), size))
|
container.addElement((new ImageLayoutElement(*this, m.getImage(), size))
|
||||||
->setLink(Link(Link::UserAction, m.getAction())));
|
->setLink(Link(Link::UserAction, m.getAction())));
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include "ircmessagehandler.hpp"
|
#include "ircmessagehandler.hpp"
|
||||||
|
|
||||||
|
#include "application.hpp"
|
||||||
#include "debug/log.hpp"
|
#include "debug/log.hpp"
|
||||||
#include "messages/limitedqueue.hpp"
|
#include "messages/limitedqueue.hpp"
|
||||||
#include "messages/message.hpp"
|
#include "messages/message.hpp"
|
||||||
|
@ -124,8 +125,10 @@ void IrcMessageHandler::handleClearChatMessage(Communi::IrcMessage *message)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto app = getApp();
|
||||||
|
|
||||||
// refresh all
|
// refresh all
|
||||||
WindowManager::getInstance().repaintVisibleChatWidgets(chan.get());
|
app->windows->repaintVisibleChatWidgets(chan.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
void IrcMessageHandler::handleUserStateMessage(Communi::IrcMessage *message)
|
void IrcMessageHandler::handleUserStateMessage(Communi::IrcMessage *message)
|
||||||
|
@ -152,6 +155,7 @@ void IrcMessageHandler::handleUserStateMessage(Communi::IrcMessage *message)
|
||||||
|
|
||||||
void IrcMessageHandler::handleWhisperMessage(Communi::IrcMessage *message)
|
void IrcMessageHandler::handleWhisperMessage(Communi::IrcMessage *message)
|
||||||
{
|
{
|
||||||
|
auto app = getApp();
|
||||||
debug::Log("Received whisper!");
|
debug::Log("Received whisper!");
|
||||||
messages::MessageParseArgs args;
|
messages::MessageParseArgs args;
|
||||||
|
|
||||||
|
@ -171,7 +175,7 @@ void IrcMessageHandler::handleWhisperMessage(Communi::IrcMessage *message)
|
||||||
|
|
||||||
c->addMessage(_message);
|
c->addMessage(_message);
|
||||||
|
|
||||||
if (SettingManager::getInstance().inlineWhispers) {
|
if (app->settings->inlineWhispers) {
|
||||||
TwitchServer::getInstance().forEachChannel([_message](ChannelPtr channel) {
|
TwitchServer::getInstance().forEachChannel([_message](ChannelPtr channel) {
|
||||||
channel->addMessage(_message); //
|
channel->addMessage(_message); //
|
||||||
});
|
});
|
||||||
|
|
|
@ -31,6 +31,7 @@ TwitchChannel::TwitchChannel(const QString &channelName, Communi::IrcConnection
|
||||||
{
|
{
|
||||||
debug::Log("[TwitchChannel:{}] Opened", this->name);
|
debug::Log("[TwitchChannel:{}] Opened", this->name);
|
||||||
|
|
||||||
|
auto app = getApp();
|
||||||
this->reloadChannelEmotes();
|
this->reloadChannelEmotes();
|
||||||
|
|
||||||
this->liveStatusTimer = new QTimer;
|
this->liveStatusTimer = new QTimer;
|
||||||
|
@ -43,11 +44,9 @@ TwitchChannel::TwitchChannel(const QString &channelName, Communi::IrcConnection
|
||||||
this->refreshLiveStatus(); //
|
this->refreshLiveStatus(); //
|
||||||
});
|
});
|
||||||
|
|
||||||
this->managedConnect(singletons::AccountManager::getInstance().Twitch.userChanged,
|
this->managedConnect(app->accounts->Twitch.userChanged, [this]() { this->setMod(false); });
|
||||||
[this]() { this->setMod(false); });
|
|
||||||
|
|
||||||
auto refreshPubSubState = [this]() {
|
auto refreshPubSubState = [=]() {
|
||||||
const auto &x = this;
|
|
||||||
if (!this->hasModRights()) {
|
if (!this->hasModRights()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -56,17 +55,15 @@ TwitchChannel::TwitchChannel(const QString &channelName, Communi::IrcConnection
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto account = singletons::AccountManager::getInstance().Twitch.getCurrent();
|
auto account = app->accounts->Twitch.getCurrent();
|
||||||
if (account && !account->getUserId().isEmpty()) {
|
if (account && !account->getUserId().isEmpty()) {
|
||||||
singletons::PubSubManager::getInstance().ListenToChannelModerationActions(this->roomID,
|
app->pubsub->ListenToChannelModerationActions(this->roomID, account);
|
||||||
account);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
this->userStateChanged.connect(refreshPubSubState);
|
this->userStateChanged.connect(refreshPubSubState);
|
||||||
this->roomIDchanged.connect(refreshPubSubState);
|
this->roomIDchanged.connect(refreshPubSubState);
|
||||||
this->managedConnect(singletons::AccountManager::getInstance().Twitch.userChanged,
|
this->managedConnect(app->accounts->Twitch.userChanged, refreshPubSubState);
|
||||||
refreshPubSubState);
|
|
||||||
refreshPubSubState();
|
refreshPubSubState();
|
||||||
|
|
||||||
this->fetchMessages.connect([this] {
|
this->fetchMessages.connect([this] {
|
||||||
|
@ -89,9 +86,8 @@ TwitchChannel::TwitchChannel(const QString &channelName, Communi::IrcConnection
|
||||||
auto doRefreshChatters = [=]() {
|
auto doRefreshChatters = [=]() {
|
||||||
const auto streamStatus = this->GetStreamStatus();
|
const auto streamStatus = this->GetStreamStatus();
|
||||||
|
|
||||||
auto &settingManager = singletons::SettingManager::getInstance();
|
if (app->settings->onlyFetchChattersForSmallerStreamers) {
|
||||||
if (settingManager.onlyFetchChattersForSmallerStreamers) {
|
if (streamStatus.live && streamStatus.viewerCount > app->settings->smallStreamerLimit) {
|
||||||
if (streamStatus.live && streamStatus.viewerCount > settingManager.smallStreamerLimit) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -135,22 +131,22 @@ void TwitchChannel::setRoomID(const QString &_roomID)
|
||||||
|
|
||||||
void TwitchChannel::reloadChannelEmotes()
|
void TwitchChannel::reloadChannelEmotes()
|
||||||
{
|
{
|
||||||
auto &emoteManager = singletons::EmoteManager::getInstance();
|
auto app = getApp();
|
||||||
|
|
||||||
debug::Log("[TwitchChannel:{}] Reloading channel emotes", this->name);
|
debug::Log("[TwitchChannel:{}] Reloading channel emotes", this->name);
|
||||||
|
|
||||||
emoteManager.reloadBTTVChannelEmotes(this->name, this->bttvChannelEmotes);
|
app->emotes->reloadBTTVChannelEmotes(this->name, this->bttvChannelEmotes);
|
||||||
emoteManager.reloadFFZChannelEmotes(this->name, this->ffzChannelEmotes);
|
app->emotes->reloadFFZChannelEmotes(this->name, this->ffzChannelEmotes);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TwitchChannel::sendMessage(const QString &message)
|
void TwitchChannel::sendMessage(const QString &message)
|
||||||
{
|
{
|
||||||
auto &emoteManager = singletons::EmoteManager::getInstance();
|
auto app = getApp();
|
||||||
|
|
||||||
debug::Log("[TwitchChannel:{}] Send message: {}", this->name, message);
|
debug::Log("[TwitchChannel:{}] Send message: {}", this->name, message);
|
||||||
|
|
||||||
// Do last message processing
|
// Do last message processing
|
||||||
QString parsedMessage = emoteManager.replaceShortCodes(message);
|
QString parsedMessage = app->emotes->replaceShortCodes(message);
|
||||||
|
|
||||||
parsedMessage = parsedMessage.trimmed();
|
parsedMessage = parsedMessage.trimmed();
|
||||||
|
|
||||||
|
@ -158,7 +154,7 @@ void TwitchChannel::sendMessage(const QString &message)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (singletons::SettingManager::getInstance().allowDuplicateMessages) {
|
if (app->settings->allowDuplicateMessages) {
|
||||||
if (parsedMessage == this->lastSentMessage) {
|
if (parsedMessage == this->lastSentMessage) {
|
||||||
parsedMessage.append(this->messageSuffix);
|
parsedMessage.append(this->messageSuffix);
|
||||||
|
|
||||||
|
@ -187,8 +183,9 @@ void TwitchChannel::setMod(bool value)
|
||||||
|
|
||||||
bool TwitchChannel::isBroadcaster()
|
bool TwitchChannel::isBroadcaster()
|
||||||
{
|
{
|
||||||
return this->name ==
|
auto app = getApp();
|
||||||
singletons::AccountManager::getInstance().Twitch.getCurrent()->getUserName();
|
|
||||||
|
return this->name == app->accounts->Twitch.getCurrent()->getUserName();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TwitchChannel::hasModRights()
|
bool TwitchChannel::hasModRights()
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
#include "providers/twitch/twitchmessagebuilder.hpp"
|
#include "providers/twitch/twitchmessagebuilder.hpp"
|
||||||
|
|
||||||
|
#include "application.hpp"
|
||||||
#include "debug/log.hpp"
|
#include "debug/log.hpp"
|
||||||
#include "providers/twitch/twitchchannel.hpp"
|
#include "providers/twitch/twitchchannel.hpp"
|
||||||
#include "singletons/accountmanager.hpp"
|
#include "singletons/accountmanager.hpp"
|
||||||
|
@ -27,10 +29,11 @@ TwitchMessageBuilder::TwitchMessageBuilder(Channel *_channel,
|
||||||
, ircMessage(_ircMessage)
|
, ircMessage(_ircMessage)
|
||||||
, args(_args)
|
, args(_args)
|
||||||
, tags(this->ircMessage->tags())
|
, tags(this->ircMessage->tags())
|
||||||
, usernameColor(singletons::ThemeManager::getInstance().messages.textColors.system)
|
|
||||||
, originalMessage(_ircMessage->content())
|
, originalMessage(_ircMessage->content())
|
||||||
, action(_ircMessage->isAction())
|
, action(_ircMessage->isAction())
|
||||||
{
|
{
|
||||||
|
auto app = getApp();
|
||||||
|
this->usernameColor = app->themes->messages.textColors.system;
|
||||||
}
|
}
|
||||||
|
|
||||||
TwitchMessageBuilder::TwitchMessageBuilder(Channel *_channel,
|
TwitchMessageBuilder::TwitchMessageBuilder(Channel *_channel,
|
||||||
|
@ -41,15 +44,16 @@ TwitchMessageBuilder::TwitchMessageBuilder(Channel *_channel,
|
||||||
, ircMessage(_ircMessage)
|
, ircMessage(_ircMessage)
|
||||||
, args(_args)
|
, args(_args)
|
||||||
, tags(this->ircMessage->tags())
|
, tags(this->ircMessage->tags())
|
||||||
, usernameColor(singletons::ThemeManager::getInstance().messages.textColors.system)
|
|
||||||
, originalMessage(content)
|
, originalMessage(content)
|
||||||
{
|
{
|
||||||
|
auto app = getApp();
|
||||||
|
this->usernameColor = app->themes->messages.textColors.system;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TwitchMessageBuilder::isIgnored() const
|
bool TwitchMessageBuilder::isIgnored() const
|
||||||
{
|
{
|
||||||
singletons::SettingManager &settings = singletons::SettingManager::getInstance();
|
auto app = getApp();
|
||||||
std::shared_ptr<std::vector<QString>> ignoredKeywords = settings.getIgnoredKeywords();
|
std::shared_ptr<std::vector<QString>> ignoredKeywords = app->settings->getIgnoredKeywords();
|
||||||
|
|
||||||
for (const QString &keyword : *ignoredKeywords) {
|
for (const QString &keyword : *ignoredKeywords) {
|
||||||
if (this->originalMessage.contains(keyword, Qt::CaseInsensitive)) {
|
if (this->originalMessage.contains(keyword, Qt::CaseInsensitive)) {
|
||||||
|
@ -62,8 +66,7 @@ bool TwitchMessageBuilder::isIgnored() const
|
||||||
|
|
||||||
MessagePtr TwitchMessageBuilder::build()
|
MessagePtr TwitchMessageBuilder::build()
|
||||||
{
|
{
|
||||||
singletons::SettingManager &settings = singletons::SettingManager::getInstance();
|
auto app = getApp();
|
||||||
singletons::EmoteManager &emoteManager = singletons::EmoteManager::getInstance();
|
|
||||||
|
|
||||||
// PARSING
|
// PARSING
|
||||||
this->parseUsername();
|
this->parseUsername();
|
||||||
|
@ -103,7 +106,7 @@ MessagePtr TwitchMessageBuilder::build()
|
||||||
this->appendUsername();
|
this->appendUsername();
|
||||||
|
|
||||||
// highlights
|
// highlights
|
||||||
if (settings.enableHighlights && !isPastMsg) {
|
if (app->settings->enableHighlights && !isPastMsg) {
|
||||||
this->parseHighlights();
|
this->parseHighlights();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -162,7 +165,7 @@ MessagePtr TwitchMessageBuilder::build()
|
||||||
std::vector<std::tuple<util::EmoteData, QString>> parsed;
|
std::vector<std::tuple<util::EmoteData, QString>> parsed;
|
||||||
|
|
||||||
// Parse emojis and take all non-emojis and put them in parsed as full text-words
|
// Parse emojis and take all non-emojis and put them in parsed as full text-words
|
||||||
emoteManager.parseEmojis(parsed, split);
|
app->emotes->parseEmojis(parsed, split);
|
||||||
|
|
||||||
for (const auto &tuple : parsed) {
|
for (const auto &tuple : parsed) {
|
||||||
const util::EmoteData &emoteData = std::get<0>(tuple);
|
const util::EmoteData &emoteData = std::get<0>(tuple);
|
||||||
|
@ -274,6 +277,8 @@ void TwitchMessageBuilder::parseUsername()
|
||||||
|
|
||||||
void TwitchMessageBuilder::appendUsername()
|
void TwitchMessageBuilder::appendUsername()
|
||||||
{
|
{
|
||||||
|
auto app = getApp();
|
||||||
|
|
||||||
QString username = this->userName;
|
QString username = this->userName;
|
||||||
this->message->loginName = username;
|
this->message->loginName = username;
|
||||||
QString localizedName;
|
QString localizedName;
|
||||||
|
@ -334,16 +339,16 @@ void TwitchMessageBuilder::appendUsername()
|
||||||
FontStyle::MediumBold)
|
FontStyle::MediumBold)
|
||||||
->setLink({Link::UserInfo, this->userName});
|
->setLink({Link::UserInfo, this->userName});
|
||||||
|
|
||||||
auto currentUser = singletons::AccountManager::getInstance().Twitch.getCurrent();
|
auto currentUser = app->accounts->Twitch.getCurrent();
|
||||||
|
|
||||||
// Separator
|
// Separator
|
||||||
this->emplace<TextElement>(
|
this->emplace<TextElement>("->", MessageElement::Text,
|
||||||
"->", MessageElement::Text,
|
app->themes->messages.textColors.system,
|
||||||
singletons::ThemeManager::getInstance().messages.textColors.system, FontStyle::Medium);
|
FontStyle::Medium);
|
||||||
|
|
||||||
QColor selfColor = currentUser->color;
|
QColor selfColor = currentUser->color;
|
||||||
if (!selfColor.isValid()) {
|
if (!selfColor.isValid()) {
|
||||||
selfColor = singletons::ThemeManager::getInstance().messages.textColors.system;
|
selfColor = app->themes->messages.textColors.system;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Your own username
|
// Your own username
|
||||||
|
@ -364,8 +369,10 @@ void TwitchMessageBuilder::parseHighlights()
|
||||||
{
|
{
|
||||||
static auto player = new QMediaPlayer;
|
static auto player = new QMediaPlayer;
|
||||||
static QUrl currentPlayerUrl;
|
static QUrl currentPlayerUrl;
|
||||||
singletons::SettingManager &settings = singletons::SettingManager::getInstance();
|
|
||||||
auto currentUser = singletons::AccountManager::getInstance().Twitch.getCurrent();
|
auto app = getApp();
|
||||||
|
|
||||||
|
auto currentUser = app->accounts->Twitch.getCurrent();
|
||||||
|
|
||||||
QString currentUsername = currentUser->getUserName();
|
QString currentUsername = currentUser->getUserName();
|
||||||
|
|
||||||
|
@ -377,8 +384,8 @@ void TwitchMessageBuilder::parseHighlights()
|
||||||
|
|
||||||
// update the media player url if necessary
|
// update the media player url if necessary
|
||||||
QUrl highlightSoundUrl;
|
QUrl highlightSoundUrl;
|
||||||
if (settings.customHighlightSound) {
|
if (app->settings->customHighlightSound) {
|
||||||
highlightSoundUrl = QUrl(settings.pathHighlightSound.getValue());
|
highlightSoundUrl = QUrl(app->settings->pathHighlightSound.getValue());
|
||||||
} else {
|
} else {
|
||||||
highlightSoundUrl = QUrl("qrc:/sounds/ping2.wav");
|
highlightSoundUrl = QUrl("qrc:/sounds/ping2.wav");
|
||||||
}
|
}
|
||||||
|
@ -390,16 +397,16 @@ void TwitchMessageBuilder::parseHighlights()
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList blackList =
|
QStringList blackList =
|
||||||
settings.highlightUserBlacklist.getValue().split("\n", QString::SkipEmptyParts);
|
app->settings->highlightUserBlacklist.getValue().split("\n", QString::SkipEmptyParts);
|
||||||
|
|
||||||
// TODO: This vector should only be rebuilt upon highlights being changed
|
// TODO: This vector should only be rebuilt upon highlights being changed
|
||||||
auto activeHighlights = settings.highlightProperties.getValue();
|
auto activeHighlights = app->settings->highlightProperties.getValue();
|
||||||
|
|
||||||
if (settings.enableHighlightsSelf && currentUsername.size() > 0) {
|
if (app->settings->enableHighlightsSelf && currentUsername.size() > 0) {
|
||||||
messages::HighlightPhrase selfHighlight;
|
messages::HighlightPhrase selfHighlight;
|
||||||
selfHighlight.key = currentUsername;
|
selfHighlight.key = currentUsername;
|
||||||
selfHighlight.sound = settings.enableHighlightSound;
|
selfHighlight.sound = app->settings->enableHighlightSound;
|
||||||
selfHighlight.alert = settings.enableHighlightTaskbar;
|
selfHighlight.alert = app->settings->enableHighlightTaskbar;
|
||||||
activeHighlights.emplace_back(std::move(selfHighlight));
|
activeHighlights.emplace_back(std::move(selfHighlight));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -443,13 +450,12 @@ void TwitchMessageBuilder::parseHighlights()
|
||||||
|
|
||||||
this->setHighlight(doHighlight);
|
this->setHighlight(doHighlight);
|
||||||
|
|
||||||
if (playSound && (!hasFocus || settings.highlightAlwaysPlaySound)) {
|
if (playSound && (!hasFocus || app->settings->highlightAlwaysPlaySound)) {
|
||||||
player->play();
|
player->play();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (doAlert) {
|
if (doAlert) {
|
||||||
QApplication::alert(singletons::WindowManager::getInstance().getMainWindow().window(),
|
QApplication::alert(getApp()->windows->getMainWindow().window(), 2500);
|
||||||
2500);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (doHighlight) {
|
if (doHighlight) {
|
||||||
|
@ -462,7 +468,7 @@ void TwitchMessageBuilder::appendTwitchEmote(const Communi::IrcMessage *ircMessa
|
||||||
const QString &emote,
|
const QString &emote,
|
||||||
std::vector<std::pair<long int, util::EmoteData>> &vec)
|
std::vector<std::pair<long int, util::EmoteData>> &vec)
|
||||||
{
|
{
|
||||||
singletons::EmoteManager &emoteManager = singletons::EmoteManager::getInstance();
|
auto app = getApp();
|
||||||
if (!emote.contains(':')) {
|
if (!emote.contains(':')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -494,13 +500,13 @@ void TwitchMessageBuilder::appendTwitchEmote(const Communi::IrcMessage *ircMessa
|
||||||
QString name = this->originalMessage.mid(start, end - start + 1);
|
QString name = this->originalMessage.mid(start, end - start + 1);
|
||||||
|
|
||||||
vec.push_back(
|
vec.push_back(
|
||||||
std::pair<long int, util::EmoteData>(start, emoteManager.getTwitchEmoteById(id, name)));
|
std::pair<long int, util::EmoteData>(start, app->emotes->getTwitchEmoteById(id, name)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TwitchMessageBuilder::tryAppendEmote(QString &emoteString)
|
bool TwitchMessageBuilder::tryAppendEmote(QString &emoteString)
|
||||||
{
|
{
|
||||||
singletons::EmoteManager &emoteManager = singletons::EmoteManager::getInstance();
|
auto app = getApp();
|
||||||
util::EmoteData emoteData;
|
util::EmoteData emoteData;
|
||||||
|
|
||||||
auto appendEmote = [&](MessageElement::Flags flags) {
|
auto appendEmote = [&](MessageElement::Flags flags) {
|
||||||
|
@ -508,21 +514,21 @@ bool TwitchMessageBuilder::tryAppendEmote(QString &emoteString)
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
if (emoteManager.bttvGlobalEmotes.tryGet(emoteString, emoteData)) {
|
if (app->emotes->bttvGlobalEmotes.tryGet(emoteString, emoteData)) {
|
||||||
// BTTV Global Emote
|
// BTTV Global Emote
|
||||||
return appendEmote(MessageElement::BttvEmote);
|
return appendEmote(MessageElement::BttvEmote);
|
||||||
} else if (this->twitchChannel != nullptr &&
|
} else if (this->twitchChannel != nullptr &&
|
||||||
this->twitchChannel->bttvChannelEmotes->tryGet(emoteString, emoteData)) {
|
this->twitchChannel->bttvChannelEmotes->tryGet(emoteString, emoteData)) {
|
||||||
// BTTV Channel Emote
|
// BTTV Channel Emote
|
||||||
return appendEmote(MessageElement::BttvEmote);
|
return appendEmote(MessageElement::BttvEmote);
|
||||||
} else if (emoteManager.ffzGlobalEmotes.tryGet(emoteString, emoteData)) {
|
} else if (app->emotes->ffzGlobalEmotes.tryGet(emoteString, emoteData)) {
|
||||||
// FFZ Global Emote
|
// FFZ Global Emote
|
||||||
return appendEmote(MessageElement::FfzEmote);
|
return appendEmote(MessageElement::FfzEmote);
|
||||||
} else if (this->twitchChannel != nullptr &&
|
} else if (this->twitchChannel != nullptr &&
|
||||||
this->twitchChannel->ffzChannelEmotes->tryGet(emoteString, emoteData)) {
|
this->twitchChannel->ffzChannelEmotes->tryGet(emoteString, emoteData)) {
|
||||||
// FFZ Channel Emote
|
// FFZ Channel Emote
|
||||||
return appendEmote(MessageElement::FfzEmote);
|
return appendEmote(MessageElement::FfzEmote);
|
||||||
} else if (emoteManager.getChatterinoEmotes().tryGet(emoteString, emoteData)) {
|
} else if (app->emotes->getChatterinoEmotes().tryGet(emoteString, emoteData)) {
|
||||||
// Chatterino Emote
|
// Chatterino Emote
|
||||||
return appendEmote(MessageElement::Misc);
|
return appendEmote(MessageElement::Misc);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include "twitchserver.hpp"
|
#include "twitchserver.hpp"
|
||||||
|
|
||||||
|
#include "application.hpp"
|
||||||
#include "providers/twitch/ircmessagehandler.hpp"
|
#include "providers/twitch/ircmessagehandler.hpp"
|
||||||
#include "providers/twitch/twitchaccount.hpp"
|
#include "providers/twitch/twitchaccount.hpp"
|
||||||
#include "providers/twitch/twitchhelpers.hpp"
|
#include "providers/twitch/twitchhelpers.hpp"
|
||||||
|
@ -23,7 +24,7 @@ TwitchServer::TwitchServer()
|
||||||
{
|
{
|
||||||
qDebug() << "init TwitchServer";
|
qDebug() << "init TwitchServer";
|
||||||
|
|
||||||
AccountManager::getInstance().Twitch.userChanged.connect(
|
getApp()->accounts->Twitch.userChanged.connect(
|
||||||
[this]() { util::postToThread([this] { this->connect(); }); });
|
[this]() { util::postToThread([this] { this->connect(); }); });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,7 +36,7 @@ TwitchServer &TwitchServer::getInstance()
|
||||||
|
|
||||||
void TwitchServer::initializeConnection(IrcConnection *connection, bool isRead, bool isWrite)
|
void TwitchServer::initializeConnection(IrcConnection *connection, bool isRead, bool isWrite)
|
||||||
{
|
{
|
||||||
std::shared_ptr<TwitchAccount> account = AccountManager::getInstance().Twitch.getCurrent();
|
std::shared_ptr<TwitchAccount> account = getApp()->accounts->Twitch.getCurrent();
|
||||||
|
|
||||||
qDebug() << "logging in as" << account->getUserName();
|
qDebug() << "logging in as" << account->getUserName();
|
||||||
|
|
||||||
|
|
|
@ -3,31 +3,6 @@
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
namespace singletons {
|
namespace singletons {
|
||||||
|
|
||||||
namespace {
|
|
||||||
|
|
||||||
inline QString getEnvString(const char *target)
|
|
||||||
{
|
|
||||||
char *val = std::getenv(target);
|
|
||||||
if (val == nullptr) {
|
|
||||||
return QString();
|
|
||||||
}
|
|
||||||
|
|
||||||
return QString(val);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
AccountManager::AccountManager()
|
|
||||||
{
|
|
||||||
qDebug() << "init AccountManager";
|
|
||||||
}
|
|
||||||
|
|
||||||
AccountManager &AccountManager::getInstance()
|
|
||||||
{
|
|
||||||
static AccountManager instance;
|
|
||||||
return instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
void AccountManager::load()
|
void AccountManager::load()
|
||||||
{
|
{
|
||||||
this->Twitch.load();
|
this->Twitch.load();
|
||||||
|
|
|
@ -7,10 +7,11 @@ namespace singletons {
|
||||||
|
|
||||||
class AccountManager
|
class AccountManager
|
||||||
{
|
{
|
||||||
AccountManager();
|
AccountManager() = default;
|
||||||
|
friend class Application;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static AccountManager &getInstance();
|
~AccountManager() = delete;
|
||||||
|
|
||||||
void load();
|
void load();
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
#include "singletons/commandmanager.hpp"
|
#include "singletons/commandmanager.hpp"
|
||||||
|
|
||||||
|
#include "application.hpp"
|
||||||
#include "debug/log.hpp"
|
#include "debug/log.hpp"
|
||||||
#include "messages/messagebuilder.hpp"
|
#include "messages/messagebuilder.hpp"
|
||||||
#include "providers/twitch/twitchserver.hpp"
|
#include "providers/twitch/twitchserver.hpp"
|
||||||
|
@ -17,20 +19,10 @@ using namespace chatterino::providers::twitch;
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
namespace singletons {
|
namespace singletons {
|
||||||
|
|
||||||
CommandManager::CommandManager()
|
|
||||||
{
|
|
||||||
qDebug() << "init CommandManager";
|
|
||||||
}
|
|
||||||
|
|
||||||
CommandManager &CommandManager::getInstance()
|
|
||||||
{
|
|
||||||
static CommandManager instance;
|
|
||||||
return instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CommandManager::loadCommands()
|
void CommandManager::loadCommands()
|
||||||
{
|
{
|
||||||
this->filePath = PathManager::getInstance().customFolderPath + "/Commands.txt";
|
auto app = getApp();
|
||||||
|
this->filePath = app->paths->customFolderPath + "/Commands.txt";
|
||||||
|
|
||||||
QFile textFile(this->filePath);
|
QFile textFile(this->filePath);
|
||||||
if (!textFile.open(QIODevice::ReadOnly)) {
|
if (!textFile.open(QIODevice::ReadOnly)) {
|
||||||
|
@ -162,7 +154,7 @@ QString CommandManager::execCommand(const QString &text, ChannelPtr channel, boo
|
||||||
messages::MessageBuilder b;
|
messages::MessageBuilder b;
|
||||||
|
|
||||||
b.emplace<messages::TextElement>(
|
b.emplace<messages::TextElement>(
|
||||||
singletons::AccountManager::getInstance().Twitch.getCurrent()->getUserName(),
|
getApp()->accounts->Twitch.getCurrent()->getUserName(),
|
||||||
messages::MessageElement::Text);
|
messages::MessageElement::Text);
|
||||||
b.emplace<messages::TextElement>("->", messages::MessageElement::Text);
|
b.emplace<messages::TextElement>("->", messages::MessageElement::Text);
|
||||||
b.emplace<messages::TextElement>(words[1], messages::MessageElement::Text);
|
b.emplace<messages::TextElement>(words[1], messages::MessageElement::Text);
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
|
|
||||||
|
@ -16,11 +17,10 @@ namespace singletons {
|
||||||
|
|
||||||
class CommandManager
|
class CommandManager
|
||||||
{
|
{
|
||||||
CommandManager();
|
CommandManager() = default;
|
||||||
|
friend class Application;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static CommandManager &getInstance();
|
|
||||||
|
|
||||||
QString execCommand(const QString &text, std::shared_ptr<Channel> channel, bool dryRun);
|
QString execCommand(const QString &text, std::shared_ptr<Channel> channel, bool dryRun);
|
||||||
|
|
||||||
void loadCommands();
|
void loadCommands();
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
#include "emotemanager.hpp"
|
#include "emotemanager.hpp"
|
||||||
|
|
||||||
|
#include "application.hpp"
|
||||||
#include "common.hpp"
|
#include "common.hpp"
|
||||||
#include "singletons/settingsmanager.hpp"
|
#include "singletons/settingsmanager.hpp"
|
||||||
#include "singletons/windowmanager.hpp"
|
#include "singletons/windowmanager.hpp"
|
||||||
|
@ -80,21 +82,17 @@ EmoteManager::EmoteManager()
|
||||||
: findShortCodesRegex(":([-+\\w]+):")
|
: findShortCodesRegex(":([-+\\w]+):")
|
||||||
{
|
{
|
||||||
qDebug() << "init EmoteManager";
|
qDebug() << "init EmoteManager";
|
||||||
auto &accountManager = AccountManager::getInstance();
|
}
|
||||||
|
|
||||||
accountManager.Twitch.userChanged.connect([this] {
|
void EmoteManager::initialize()
|
||||||
auto currentUser = AccountManager::getInstance().Twitch.getCurrent();
|
{
|
||||||
|
getApp()->accounts->Twitch.userChanged.connect([this] {
|
||||||
|
auto currentUser = getApp()->accounts->Twitch.getCurrent();
|
||||||
assert(currentUser);
|
assert(currentUser);
|
||||||
this->refreshTwitchEmotes(currentUser);
|
this->refreshTwitchEmotes(currentUser);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
EmoteManager &EmoteManager::getInstance()
|
|
||||||
{
|
|
||||||
static EmoteManager instance;
|
|
||||||
return instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
void EmoteManager::loadGlobalEmotes()
|
void EmoteManager::loadGlobalEmotes()
|
||||||
{
|
{
|
||||||
this->loadEmojis();
|
this->loadEmojis();
|
||||||
|
@ -558,14 +556,14 @@ util::EmoteData EmoteManager::getCheerImage(long long amount, bool animated)
|
||||||
pajlada::Signals::NoArgSignal &EmoteManager::getGifUpdateSignal()
|
pajlada::Signals::NoArgSignal &EmoteManager::getGifUpdateSignal()
|
||||||
{
|
{
|
||||||
if (!this->gifUpdateTimerInitiated) {
|
if (!this->gifUpdateTimerInitiated) {
|
||||||
|
auto app = getApp();
|
||||||
|
|
||||||
this->gifUpdateTimerInitiated = true;
|
this->gifUpdateTimerInitiated = true;
|
||||||
|
|
||||||
this->gifUpdateTimer.setInterval(30);
|
this->gifUpdateTimer.setInterval(30);
|
||||||
this->gifUpdateTimer.start();
|
this->gifUpdateTimer.start();
|
||||||
|
|
||||||
auto &settingManager = singletons::SettingManager::getInstance();
|
app->settings->enableGifAnimations.connect([this](bool enabled, auto) {
|
||||||
|
|
||||||
settingManager.enableGifAnimations.connect([this](bool enabled, auto) {
|
|
||||||
if (enabled) {
|
if (enabled) {
|
||||||
this->gifUpdateTimer.start();
|
this->gifUpdateTimer.start();
|
||||||
} else {
|
} else {
|
||||||
|
@ -576,8 +574,8 @@ pajlada::Signals::NoArgSignal &EmoteManager::getGifUpdateSignal()
|
||||||
QObject::connect(&this->gifUpdateTimer, &QTimer::timeout, [this] {
|
QObject::connect(&this->gifUpdateTimer, &QTimer::timeout, [this] {
|
||||||
this->gifUpdateTimerSignal.invoke();
|
this->gifUpdateTimerSignal.invoke();
|
||||||
// fourtf:
|
// fourtf:
|
||||||
auto &windowManager = singletons::WindowManager::getInstance();
|
auto app = getApp();
|
||||||
windowManager.repaintGifEmotes();
|
app->windows->repaintGifEmotes();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,9 +23,12 @@ namespace singletons {
|
||||||
class EmoteManager
|
class EmoteManager
|
||||||
{
|
{
|
||||||
EmoteManager();
|
EmoteManager();
|
||||||
|
friend class Application;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static EmoteManager &getInstance();
|
~EmoteManager() = delete;
|
||||||
|
|
||||||
|
void initialize();
|
||||||
|
|
||||||
void loadGlobalEmotes();
|
void loadGlobalEmotes();
|
||||||
|
|
||||||
|
|
|
@ -71,8 +71,6 @@ rapidjson::Document CreateUnlistenMessage(const std::vector<std::string> &topics
|
||||||
|
|
||||||
rj::set(msg, "type", "UNLISTEN");
|
rj::set(msg, "type", "UNLISTEN");
|
||||||
|
|
||||||
auto &accountManager = AccountManager::getInstance();
|
|
||||||
|
|
||||||
rapidjson::Value data(rapidjson::kObjectType);
|
rapidjson::Value data(rapidjson::kObjectType);
|
||||||
|
|
||||||
rapidjson::Value topics(rapidjson::kArrayType);
|
rapidjson::Value topics(rapidjson::kArrayType);
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
#include "singletons/loggingmanager.hpp"
|
#include "singletons/loggingmanager.hpp"
|
||||||
|
|
||||||
|
#include "application.hpp"
|
||||||
#include "debug/log.hpp"
|
#include "debug/log.hpp"
|
||||||
#include "singletons/pathmanager.hpp"
|
#include "singletons/pathmanager.hpp"
|
||||||
#include "singletons/settingsmanager.hpp"
|
#include "singletons/settingsmanager.hpp"
|
||||||
|
@ -11,23 +13,16 @@
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
namespace singletons {
|
namespace singletons {
|
||||||
|
|
||||||
LoggingManager::LoggingManager()
|
void LoggingManager::initialize()
|
||||||
: pathManager(PathManager::getInstance())
|
|
||||||
{
|
{
|
||||||
qDebug() << "init LoggingManager";
|
this->pathManager = getApp()->paths;
|
||||||
}
|
|
||||||
|
|
||||||
LoggingManager &LoggingManager::getInstance()
|
|
||||||
{
|
|
||||||
static LoggingManager instance;
|
|
||||||
return instance;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void LoggingManager::addMessage(const QString &channelName, messages::MessagePtr message)
|
void LoggingManager::addMessage(const QString &channelName, messages::MessagePtr message)
|
||||||
{
|
{
|
||||||
const auto &settings = singletons::SettingManager::getInstance();
|
auto app = getApp();
|
||||||
|
|
||||||
if (!settings.enableLogging) {
|
if (!app->settings->enableLogging) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,13 +40,14 @@ void LoggingManager::addMessage(const QString &channelName, messages::MessagePtr
|
||||||
QString LoggingManager::getDirectoryForChannel(const QString &channelName)
|
QString LoggingManager::getDirectoryForChannel(const QString &channelName)
|
||||||
{
|
{
|
||||||
if (channelName.startsWith("/whispers")) {
|
if (channelName.startsWith("/whispers")) {
|
||||||
return this->pathManager.whispersLogsFolderPath;
|
return this->pathManager->whispersLogsFolderPath;
|
||||||
} else if (channelName.startsWith("/mentions")) {
|
} else if (channelName.startsWith("/mentions")) {
|
||||||
return this->pathManager.mentionsLogsFolderPath;
|
return this->pathManager->mentionsLogsFolderPath;
|
||||||
} else {
|
} else {
|
||||||
QString logPath(this->pathManager.channelsLogsFolderPath + QDir::separator() + channelName);
|
QString logPath(this->pathManager->channelsLogsFolderPath + QDir::separator() +
|
||||||
|
channelName);
|
||||||
|
|
||||||
if (!this->pathManager.createFolder(logPath)) {
|
if (!this->pathManager->createFolder(logPath)) {
|
||||||
debug::Log("Error creating channel logs folder for channel {}", channelName);
|
debug::Log("Error creating channel logs folder for channel {}", channelName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,8 +3,6 @@
|
||||||
#include "messages/message.hpp"
|
#include "messages/message.hpp"
|
||||||
#include "singletons/helper/loggingchannel.hpp"
|
#include "singletons/helper/loggingchannel.hpp"
|
||||||
|
|
||||||
#include <boost/noncopyable.hpp>
|
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
@ -12,14 +10,17 @@ namespace singletons {
|
||||||
|
|
||||||
class PathManager;
|
class PathManager;
|
||||||
|
|
||||||
class LoggingManager : boost::noncopyable
|
class LoggingManager
|
||||||
{
|
{
|
||||||
LoggingManager();
|
LoggingManager() = default;
|
||||||
|
friend class Application;
|
||||||
|
|
||||||
PathManager &pathManager;
|
PathManager *pathManager = nullptr;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static LoggingManager &getInstance();
|
~LoggingManager() = delete;
|
||||||
|
|
||||||
|
void initialize();
|
||||||
|
|
||||||
void addMessage(const QString &channelName, messages::MessagePtr message);
|
void addMessage(const QString &channelName, messages::MessagePtr message);
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include "nativemessagingmanager.hpp"
|
#include "nativemessagingmanager.hpp"
|
||||||
|
|
||||||
|
#include "application.hpp"
|
||||||
#include "providers/twitch/twitchserver.hpp"
|
#include "providers/twitch/twitchserver.hpp"
|
||||||
#include "singletons/pathmanager.hpp"
|
#include "singletons/pathmanager.hpp"
|
||||||
#include "util/posttothread.hpp"
|
#include "util/posttothread.hpp"
|
||||||
|
@ -17,7 +18,7 @@ namespace ipc = boost::interprocess;
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
|
|
||||||
#include <windows.h>
|
#include <Windows.h>
|
||||||
#include "singletons/windowmanager.hpp"
|
#include "singletons/windowmanager.hpp"
|
||||||
#include "widgets/attachedwindow.hpp"
|
#include "widgets/attachedwindow.hpp"
|
||||||
#endif
|
#endif
|
||||||
|
@ -35,12 +36,6 @@ NativeMessagingManager::NativeMessagingManager()
|
||||||
qDebug() << "init NativeMessagingManager";
|
qDebug() << "init NativeMessagingManager";
|
||||||
}
|
}
|
||||||
|
|
||||||
NativeMessagingManager &NativeMessagingManager::getInstance()
|
|
||||||
{
|
|
||||||
static NativeMessagingManager manager;
|
|
||||||
return manager;
|
|
||||||
}
|
|
||||||
|
|
||||||
void NativeMessagingManager::writeByteArray(QByteArray a)
|
void NativeMessagingManager::writeByteArray(QByteArray a)
|
||||||
{
|
{
|
||||||
char *data = a.data();
|
char *data = a.data();
|
||||||
|
@ -53,6 +48,8 @@ void NativeMessagingManager::writeByteArray(QByteArray a)
|
||||||
|
|
||||||
void NativeMessagingManager::registerHost()
|
void NativeMessagingManager::registerHost()
|
||||||
{
|
{
|
||||||
|
auto app = getApp();
|
||||||
|
|
||||||
// create manifest
|
// create manifest
|
||||||
QJsonDocument document;
|
QJsonDocument document;
|
||||||
QJsonObject root_obj;
|
QJsonObject root_obj;
|
||||||
|
@ -70,8 +67,7 @@ void NativeMessagingManager::registerHost()
|
||||||
root_obj.insert("allowed_extensions", allowed_extensions);
|
root_obj.insert("allowed_extensions", allowed_extensions);
|
||||||
|
|
||||||
// save the manifest
|
// save the manifest
|
||||||
QString manifestPath =
|
QString manifestPath = app->paths->settingsFolderPath + "/native-messaging-manifest.json";
|
||||||
PathManager::getInstance().settingsFolderPath + "/native-messaging-manifest.json";
|
|
||||||
|
|
||||||
document.setObject(root_obj);
|
document.setObject(root_obj);
|
||||||
|
|
||||||
|
|
|
@ -8,9 +8,10 @@ namespace singletons {
|
||||||
class NativeMessagingManager
|
class NativeMessagingManager
|
||||||
{
|
{
|
||||||
NativeMessagingManager();
|
NativeMessagingManager();
|
||||||
|
friend class Application;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static NativeMessagingManager &getInstance();
|
~NativeMessagingManager() = delete;
|
||||||
|
|
||||||
class ReceiverThread : public QThread
|
class ReceiverThread : public QThread
|
||||||
{
|
{
|
||||||
|
|
|
@ -8,18 +8,7 @@
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
namespace singletons {
|
namespace singletons {
|
||||||
|
|
||||||
PathManager::PathManager()
|
PathManager::PathManager(int argc, char **argv)
|
||||||
{
|
|
||||||
qDebug() << "init PathManager";
|
|
||||||
}
|
|
||||||
|
|
||||||
PathManager &PathManager::getInstance()
|
|
||||||
{
|
|
||||||
static PathManager instance;
|
|
||||||
return instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool PathManager::init(int argc, char **argv)
|
|
||||||
{
|
{
|
||||||
// hash of app path
|
// hash of app path
|
||||||
this->appPathHash = QCryptographicHash::hash(QCoreApplication::applicationFilePath().toUtf8(),
|
this->appPathHash = QCryptographicHash::hash(QCoreApplication::applicationFilePath().toUtf8(),
|
||||||
|
@ -50,64 +39,51 @@ bool PathManager::init(int argc, char **argv)
|
||||||
// Get settings path
|
// Get settings path
|
||||||
rootPath.append(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation));
|
rootPath.append(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation));
|
||||||
if (rootPath.isEmpty()) {
|
if (rootPath.isEmpty()) {
|
||||||
printf("Error finding writable location for settings\n");
|
throw std::runtime_error("Error finding writable location for settings");
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this->settingsFolderPath = rootPath;
|
this->settingsFolderPath = rootPath;
|
||||||
|
|
||||||
if (!QDir().mkpath(this->settingsFolderPath)) {
|
if (!QDir().mkpath(this->settingsFolderPath)) {
|
||||||
printf("Error creating directory: %s\n", qPrintable(this->settingsFolderPath));
|
throw std::runtime_error("Error creating settings folder");
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this->customFolderPath = rootPath + "/Custom";
|
this->customFolderPath = rootPath + "/Custom";
|
||||||
|
|
||||||
if (!QDir().mkpath(this->customFolderPath)) {
|
if (!QDir().mkpath(this->customFolderPath)) {
|
||||||
printf("Error creating directory: %s\n", qPrintable(this->customFolderPath));
|
throw std::runtime_error("Error creating custom folder");
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this->cacheFolderPath = rootPath + "/Cache";
|
this->cacheFolderPath = rootPath + "/Cache";
|
||||||
|
|
||||||
if (!QDir().mkpath(this->cacheFolderPath)) {
|
if (!QDir().mkpath(this->cacheFolderPath)) {
|
||||||
printf("Error creating cache directory: %s\n", qPrintable(this->cacheFolderPath));
|
throw std::runtime_error("Error creating cache folder");
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this->logsFolderPath = rootPath + "/Logs";
|
this->logsFolderPath = rootPath + "/Logs";
|
||||||
|
|
||||||
if (!QDir().mkpath(this->logsFolderPath)) {
|
if (!QDir().mkpath(this->logsFolderPath)) {
|
||||||
printf("Error creating logs directory: %s\n", qPrintable(this->logsFolderPath));
|
throw std::runtime_error("Error creating logs folder");
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this->channelsLogsFolderPath = this->logsFolderPath + "/Channels";
|
this->channelsLogsFolderPath = this->logsFolderPath + "/Channels";
|
||||||
|
|
||||||
if (!QDir().mkpath(this->channelsLogsFolderPath)) {
|
if (!QDir().mkpath(this->channelsLogsFolderPath)) {
|
||||||
printf("Error creating channelsLogs directory: %s\n",
|
throw std::runtime_error("Error creating channel logs folder");
|
||||||
qPrintable(this->channelsLogsFolderPath));
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this->whispersLogsFolderPath = this->logsFolderPath + "/Whispers";
|
this->whispersLogsFolderPath = this->logsFolderPath + "/Whispers";
|
||||||
|
|
||||||
if (!QDir().mkpath(this->whispersLogsFolderPath)) {
|
if (!QDir().mkpath(this->whispersLogsFolderPath)) {
|
||||||
printf("Error creating whispersLogs directory: %s\n",
|
throw std::runtime_error("Error creating whisper logs folder");
|
||||||
qPrintable(this->whispersLogsFolderPath));
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this->mentionsLogsFolderPath = this->logsFolderPath + "/Mentions";
|
this->mentionsLogsFolderPath = this->logsFolderPath + "/Mentions";
|
||||||
|
|
||||||
if (!QDir().mkpath(this->mentionsLogsFolderPath)) {
|
if (!QDir().mkpath(this->mentionsLogsFolderPath)) {
|
||||||
printf("Error creating mentionsLogs directory: %s\n",
|
throw std::runtime_error("Error creating mentions logs folder");
|
||||||
qPrintable(this->mentionsLogsFolderPath));
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PathManager::createFolder(const QString &folderPath)
|
bool PathManager::createFolder(const QString &folderPath)
|
||||||
|
|
|
@ -7,13 +7,10 @@ namespace singletons {
|
||||||
|
|
||||||
class PathManager
|
class PathManager
|
||||||
{
|
{
|
||||||
PathManager();
|
PathManager(int argc, char **argv);
|
||||||
|
friend class Application;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static PathManager &getInstance();
|
|
||||||
|
|
||||||
bool init(int argc, char **argv);
|
|
||||||
|
|
||||||
// %APPDATA%/chatterino or ExecutablePath for portable mode
|
// %APPDATA%/chatterino or ExecutablePath for portable mode
|
||||||
QString settingsFolderPath;
|
QString settingsFolderPath;
|
||||||
|
|
||||||
|
|
|
@ -443,12 +443,6 @@ void PubSubManager::AddClient()
|
||||||
this->websocketClient.connect(con);
|
this->websocketClient.connect(con);
|
||||||
}
|
}
|
||||||
|
|
||||||
PubSubManager &PubSubManager::getInstance()
|
|
||||||
{
|
|
||||||
static PubSubManager instance;
|
|
||||||
return instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
void PubSubManager::Start()
|
void PubSubManager::Start()
|
||||||
{
|
{
|
||||||
this->mainThread.reset(new std::thread(std::bind(&PubSubManager::RunThread, this)));
|
this->mainThread.reset(new std::thread(std::bind(&PubSubManager::RunThread, this)));
|
||||||
|
|
|
@ -69,6 +69,7 @@ private:
|
||||||
class PubSubManager
|
class PubSubManager
|
||||||
{
|
{
|
||||||
PubSubManager();
|
PubSubManager();
|
||||||
|
friend class Application;
|
||||||
|
|
||||||
using WebsocketMessagePtr = websocketpp::config::asio_tls_client::message_type::ptr;
|
using WebsocketMessagePtr = websocketpp::config::asio_tls_client::message_type::ptr;
|
||||||
using WebsocketContextPtr = websocketpp::lib::shared_ptr<boost::asio::ssl::context>;
|
using WebsocketContextPtr = websocketpp::lib::shared_ptr<boost::asio::ssl::context>;
|
||||||
|
@ -80,13 +81,13 @@ class PubSubManager
|
||||||
std::unique_ptr<std::thread> mainThread;
|
std::unique_ptr<std::thread> mainThread;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
~PubSubManager() = delete;
|
||||||
|
|
||||||
enum class State {
|
enum class State {
|
||||||
Connected,
|
Connected,
|
||||||
Disconnected,
|
Disconnected,
|
||||||
};
|
};
|
||||||
|
|
||||||
static PubSubManager &getInstance();
|
|
||||||
|
|
||||||
void Start();
|
void Start();
|
||||||
|
|
||||||
bool IsConnected() const
|
bool IsConnected() const
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
#include "singletons/settingsmanager.hpp"
|
#include "singletons/settingsmanager.hpp"
|
||||||
|
|
||||||
|
#include "application.hpp"
|
||||||
#include "debug/log.hpp"
|
#include "debug/log.hpp"
|
||||||
#include "singletons/pathmanager.hpp"
|
#include "singletons/pathmanager.hpp"
|
||||||
#include "singletons/resourcemanager.hpp"
|
#include "singletons/resourcemanager.hpp"
|
||||||
|
@ -17,8 +19,7 @@ void _actuallyRegisterSetting(std::weak_ptr<pajlada::Settings::ISettingData> set
|
||||||
}
|
}
|
||||||
|
|
||||||
SettingManager::SettingManager()
|
SettingManager::SettingManager()
|
||||||
: snapshot(nullptr)
|
: _ignoredKeywords(new std::vector<QString>)
|
||||||
, _ignoredKeywords(new std::vector<QString>)
|
|
||||||
{
|
{
|
||||||
qDebug() << "init SettingManager";
|
qDebug() << "init SettingManager";
|
||||||
|
|
||||||
|
@ -35,8 +36,10 @@ SettingManager::SettingManager()
|
||||||
this->moderationActions.connect([this](auto, auto) { this->updateModerationActions(); });
|
this->moderationActions.connect([this](auto, auto) { this->updateModerationActions(); });
|
||||||
this->ignoredKeywords.connect([this](auto, auto) { this->updateIgnoredKeywords(); });
|
this->ignoredKeywords.connect([this](auto, auto) { this->updateIgnoredKeywords(); });
|
||||||
|
|
||||||
this->timestampFormat.connect(
|
this->timestampFormat.connect([](auto, auto) {
|
||||||
[](auto, auto) { singletons::WindowManager::getInstance().layoutVisibleChatWidgets(); });
|
auto app = getApp();
|
||||||
|
app->windows->layoutVisibleChatWidgets();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
MessageElement::Flags SettingManager::getWordFlags()
|
MessageElement::Flags SettingManager::getWordFlags()
|
||||||
|
@ -51,7 +54,8 @@ bool SettingManager::isIgnoredEmote(const QString &)
|
||||||
|
|
||||||
void SettingManager::initialize()
|
void SettingManager::initialize()
|
||||||
{
|
{
|
||||||
QString settingsPath = PathManager::getInstance().settingsFolderPath + "/settings.json";
|
auto app = getApp();
|
||||||
|
QString settingsPath = app->paths->settingsFolderPath + "/settings.json";
|
||||||
|
|
||||||
pajlada::Settings::SettingManager::load(qPrintable(settingsPath));
|
pajlada::Settings::SettingManager::load(qPrintable(settingsPath));
|
||||||
}
|
}
|
||||||
|
@ -88,7 +92,7 @@ void SettingManager::updateWordTypeMask()
|
||||||
if (newMask != this->wordFlags) {
|
if (newMask != this->wordFlags) {
|
||||||
this->wordFlags = newMask;
|
this->wordFlags = newMask;
|
||||||
|
|
||||||
emit wordFlagsChanged();
|
this->wordFlagsChanged.invoke();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,17 +13,20 @@ namespace singletons {
|
||||||
|
|
||||||
void _actuallyRegisterSetting(std::weak_ptr<pajlada::Settings::ISettingData> setting);
|
void _actuallyRegisterSetting(std::weak_ptr<pajlada::Settings::ISettingData> setting);
|
||||||
|
|
||||||
class SettingManager : public QObject
|
class SettingManager
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
using BoolSetting = ChatterinoSetting<bool>;
|
using BoolSetting = ChatterinoSetting<bool>;
|
||||||
using FloatSetting = ChatterinoSetting<float>;
|
using FloatSetting = ChatterinoSetting<float>;
|
||||||
using IntSetting = ChatterinoSetting<int>;
|
using IntSetting = ChatterinoSetting<int>;
|
||||||
using StringSetting = ChatterinoSetting<std::string>;
|
using StringSetting = ChatterinoSetting<std::string>;
|
||||||
using QStringSetting = ChatterinoSetting<QString>;
|
using QStringSetting = ChatterinoSetting<QString>;
|
||||||
|
|
||||||
|
SettingManager();
|
||||||
|
friend class Application;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
~SettingManager() = delete;
|
||||||
|
|
||||||
messages::MessageElement::Flags getWordFlags();
|
messages::MessageElement::Flags getWordFlags();
|
||||||
bool isIgnoredEmote(const QString &emote);
|
bool isIgnoredEmote(const QString &emote);
|
||||||
|
|
||||||
|
@ -112,11 +115,6 @@ public:
|
||||||
|
|
||||||
BoolSetting inlineWhispers = {"/whispers/enableInlineWhispers", true};
|
BoolSetting inlineWhispers = {"/whispers/enableInlineWhispers", true};
|
||||||
|
|
||||||
static SettingManager &getInstance()
|
|
||||||
{
|
|
||||||
static SettingManager instance;
|
|
||||||
return instance;
|
|
||||||
}
|
|
||||||
void updateWordTypeMask();
|
void updateWordTypeMask();
|
||||||
|
|
||||||
void saveSnapshot();
|
void saveSnapshot();
|
||||||
|
@ -124,17 +122,13 @@ public:
|
||||||
|
|
||||||
std::vector<ModerationAction> getModerationActions() const;
|
std::vector<ModerationAction> getModerationActions() const;
|
||||||
const std::shared_ptr<std::vector<QString>> getIgnoredKeywords() const;
|
const std::shared_ptr<std::vector<QString>> getIgnoredKeywords() const;
|
||||||
|
pajlada::Signals::NoArgSignal wordFlagsChanged;
|
||||||
signals:
|
|
||||||
void wordFlagsChanged();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<ModerationAction> _moderationActions;
|
std::vector<ModerationAction> _moderationActions;
|
||||||
std::unique_ptr<rapidjson::Document> snapshot;
|
std::unique_ptr<rapidjson::Document> snapshot;
|
||||||
std::shared_ptr<std::vector<QString>> _ignoredKeywords;
|
std::shared_ptr<std::vector<QString>> _ignoredKeywords;
|
||||||
|
|
||||||
SettingManager();
|
|
||||||
|
|
||||||
void updateModerationActions();
|
void updateModerationActions();
|
||||||
void updateIgnoredKeywords();
|
void updateIgnoredKeywords();
|
||||||
|
|
||||||
|
|
|
@ -28,12 +28,6 @@ double getMultiplierByTheme(const QString &themeName)
|
||||||
|
|
||||||
} // namespace detail
|
} // namespace detail
|
||||||
|
|
||||||
ThemeManager &ThemeManager::getInstance()
|
|
||||||
{
|
|
||||||
static ThemeManager instance;
|
|
||||||
return instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
ThemeManager::ThemeManager()
|
ThemeManager::ThemeManager()
|
||||||
: themeName("/appearance/theme/name", "Dark")
|
: themeName("/appearance/theme/name", "Dark")
|
||||||
, themeHue("/appearance/theme/hue", 0.0)
|
, themeHue("/appearance/theme/hue", 0.0)
|
||||||
|
@ -42,8 +36,8 @@ ThemeManager::ThemeManager()
|
||||||
|
|
||||||
this->update();
|
this->update();
|
||||||
|
|
||||||
this->themeName.connectSimple([this](auto) { this->update(); });
|
this->themeName.connectSimple([this](auto) { this->update(); }, false);
|
||||||
this->themeHue.connectSimple([this](auto) { this->update(); });
|
this->themeHue.connectSimple([this](auto) { this->update(); }, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ThemeManager::update()
|
void ThemeManager::update()
|
||||||
|
|
|
@ -14,9 +14,10 @@ class WindowManager;
|
||||||
class ThemeManager
|
class ThemeManager
|
||||||
{
|
{
|
||||||
ThemeManager();
|
ThemeManager();
|
||||||
|
friend class Application;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static ThemeManager &getInstance();
|
~ThemeManager() = delete;
|
||||||
|
|
||||||
inline bool isLightTheme() const
|
inline bool isLightTheme() const
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
#include "windowmanager.hpp"
|
#include "windowmanager.hpp"
|
||||||
|
|
||||||
|
#include "application.hpp"
|
||||||
#include "debug/log.hpp"
|
#include "debug/log.hpp"
|
||||||
#include "providers/twitch/twitchserver.hpp"
|
#include "providers/twitch/twitchserver.hpp"
|
||||||
#include "singletons/fontmanager.hpp"
|
#include "singletons/fontmanager.hpp"
|
||||||
|
@ -18,12 +20,6 @@
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
namespace singletons {
|
namespace singletons {
|
||||||
|
|
||||||
WindowManager &WindowManager::getInstance()
|
|
||||||
{
|
|
||||||
static WindowManager instance(ThemeManager::getInstance());
|
|
||||||
return instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
void WindowManager::showSettingsDialog()
|
void WindowManager::showSettingsDialog()
|
||||||
{
|
{
|
||||||
QTimer::singleShot(80, [] { widgets::SettingsDialog::showDialog(); });
|
QTimer::singleShot(80, [] { widgets::SettingsDialog::showDialog(); });
|
||||||
|
@ -53,11 +49,9 @@ void WindowManager::showAccountSelectPopup(QPoint point)
|
||||||
w->setFocus();
|
w->setFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
WindowManager::WindowManager(ThemeManager &_themeManager)
|
WindowManager::WindowManager()
|
||||||
: themeManager(_themeManager)
|
|
||||||
{
|
{
|
||||||
qDebug() << "init WindowManager";
|
qDebug() << "init WindowManager";
|
||||||
_themeManager.repaintVisibleChatWidgets.connect([this] { this->repaintVisibleChatWidgets(); });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowManager::layoutVisibleChatWidgets(Channel *channel)
|
void WindowManager::layoutVisibleChatWidgets(Channel *channel)
|
||||||
|
@ -102,7 +96,7 @@ widgets::Window &WindowManager::createWindow(widgets::Window::WindowType type)
|
||||||
{
|
{
|
||||||
util::assertInGuiThread();
|
util::assertInGuiThread();
|
||||||
|
|
||||||
auto *window = new widgets::Window(this->themeManager, type);
|
auto *window = new widgets::Window(type);
|
||||||
this->windows.push_back(window);
|
this->windows.push_back(window);
|
||||||
window->show();
|
window->show();
|
||||||
|
|
||||||
|
@ -143,10 +137,14 @@ void WindowManager::initialize()
|
||||||
{
|
{
|
||||||
util::assertInGuiThread();
|
util::assertInGuiThread();
|
||||||
|
|
||||||
|
auto app = getApp();
|
||||||
|
app->themes->repaintVisibleChatWidgets.connect(
|
||||||
|
[this] { this->repaintVisibleChatWidgets(); });
|
||||||
|
|
||||||
assert(!this->initialized);
|
assert(!this->initialized);
|
||||||
|
|
||||||
// load file
|
// load file
|
||||||
QString settingsPath = PathManager::getInstance().settingsFolderPath + SETTINGS_FILENAME;
|
QString settingsPath = app->paths->settingsFolderPath + SETTINGS_FILENAME;
|
||||||
QFile file(settingsPath);
|
QFile file(settingsPath);
|
||||||
file.open(QIODevice::ReadOnly);
|
file.open(QIODevice::ReadOnly);
|
||||||
QByteArray data = file.readAll();
|
QByteArray data = file.readAll();
|
||||||
|
@ -230,6 +228,7 @@ void WindowManager::initialize()
|
||||||
void WindowManager::save()
|
void WindowManager::save()
|
||||||
{
|
{
|
||||||
util::assertInGuiThread();
|
util::assertInGuiThread();
|
||||||
|
auto app = getApp();
|
||||||
|
|
||||||
QJsonDocument document;
|
QJsonDocument document;
|
||||||
|
|
||||||
|
@ -301,7 +300,7 @@ void WindowManager::save()
|
||||||
document.setObject(obj);
|
document.setObject(obj);
|
||||||
|
|
||||||
// save file
|
// save file
|
||||||
QString settingsPath = PathManager::getInstance().settingsFolderPath + SETTINGS_FILENAME;
|
QString settingsPath = app->paths->settingsFolderPath + SETTINGS_FILENAME;
|
||||||
QFile file(settingsPath);
|
QFile file(settingsPath);
|
||||||
file.open(QIODevice::WriteOnly | QIODevice::Truncate);
|
file.open(QIODevice::WriteOnly | QIODevice::Truncate);
|
||||||
file.write(document.toJson());
|
file.write(document.toJson());
|
||||||
|
|
|
@ -5,14 +5,13 @@
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
namespace singletons {
|
namespace singletons {
|
||||||
|
|
||||||
class ThemeManager;
|
|
||||||
|
|
||||||
class WindowManager
|
class WindowManager
|
||||||
{
|
{
|
||||||
explicit WindowManager(ThemeManager &_themeManager);
|
WindowManager();
|
||||||
|
friend class Application;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static WindowManager &getInstance();
|
~WindowManager() = delete;
|
||||||
|
|
||||||
void showSettingsDialog();
|
void showSettingsDialog();
|
||||||
void showAccountSelectPopup(QPoint point);
|
void showAccountSelectPopup(QPoint point);
|
||||||
|
@ -37,8 +36,6 @@ public:
|
||||||
pajlada::Signals::Signal<Channel *> layout;
|
pajlada::Signals::Signal<Channel *> layout;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ThemeManager &themeManager;
|
|
||||||
|
|
||||||
bool initialized = false;
|
bool initialized = false;
|
||||||
|
|
||||||
std::vector<widgets::Window *> windows;
|
std::vector<widgets::Window *> windows;
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include "util/completionmodel.hpp"
|
#include "util/completionmodel.hpp"
|
||||||
|
|
||||||
|
#include "application.hpp"
|
||||||
#include "common.hpp"
|
#include "common.hpp"
|
||||||
#include "debug/log.hpp"
|
#include "debug/log.hpp"
|
||||||
#include "singletons/emotemanager.hpp"
|
#include "singletons/emotemanager.hpp"
|
||||||
|
@ -19,11 +20,11 @@ void CompletionModel::refresh()
|
||||||
{
|
{
|
||||||
debug::Log("[CompletionModel:{}] Refreshing...]", this->channelName);
|
debug::Log("[CompletionModel:{}] Refreshing...]", this->channelName);
|
||||||
|
|
||||||
auto &emoteManager = singletons::EmoteManager::getInstance();
|
auto app = getApp();
|
||||||
|
|
||||||
// User-specific: Twitch Emotes
|
// User-specific: Twitch Emotes
|
||||||
// TODO: Fix this so it properly updates with the proper api. oauth token needs proper scope
|
// TODO: Fix this so it properly updates with the proper api. oauth token needs proper scope
|
||||||
for (const auto &m : emoteManager.twitchAccountEmotes) {
|
for (const auto &m : app->emotes->twitchAccountEmotes) {
|
||||||
for (const auto &emoteName : m.second.emoteCodes) {
|
for (const auto &emoteName : m.second.emoteCodes) {
|
||||||
// XXX: No way to discern between a twitch global emote and sub emote right now
|
// XXX: No way to discern between a twitch global emote and sub emote right now
|
||||||
this->addString(emoteName, TaggedString::Type::TwitchGlobalEmote);
|
this->addString(emoteName, TaggedString::Type::TwitchGlobalEmote);
|
||||||
|
@ -31,33 +32,33 @@ void CompletionModel::refresh()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Global: BTTV Global Emotes
|
// Global: BTTV Global Emotes
|
||||||
std::vector<std::string> &bttvGlobalEmoteCodes = emoteManager.bttvGlobalEmoteCodes;
|
std::vector<std::string> &bttvGlobalEmoteCodes = app->emotes->bttvGlobalEmoteCodes;
|
||||||
for (const auto &m : bttvGlobalEmoteCodes) {
|
for (const auto &m : bttvGlobalEmoteCodes) {
|
||||||
this->addString(m, TaggedString::Type::BTTVGlobalEmote);
|
this->addString(m, TaggedString::Type::BTTVGlobalEmote);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Global: FFZ Global Emotes
|
// Global: FFZ Global Emotes
|
||||||
std::vector<std::string> &ffzGlobalEmoteCodes = emoteManager.ffzGlobalEmoteCodes;
|
std::vector<std::string> &ffzGlobalEmoteCodes = app->emotes->ffzGlobalEmoteCodes;
|
||||||
for (const auto &m : ffzGlobalEmoteCodes) {
|
for (const auto &m : ffzGlobalEmoteCodes) {
|
||||||
this->addString(m, TaggedString::Type::FFZGlobalEmote);
|
this->addString(m, TaggedString::Type::FFZGlobalEmote);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Channel-specific: BTTV Channel Emotes
|
// Channel-specific: BTTV Channel Emotes
|
||||||
std::vector<std::string> &bttvChannelEmoteCodes =
|
std::vector<std::string> &bttvChannelEmoteCodes =
|
||||||
emoteManager.bttvChannelEmoteCodes[this->channelName.toStdString()];
|
app->emotes->bttvChannelEmoteCodes[this->channelName.toStdString()];
|
||||||
for (const auto &m : bttvChannelEmoteCodes) {
|
for (const auto &m : bttvChannelEmoteCodes) {
|
||||||
this->addString(m, TaggedString::Type::BTTVChannelEmote);
|
this->addString(m, TaggedString::Type::BTTVChannelEmote);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Channel-specific: FFZ Channel Emotes
|
// Channel-specific: FFZ Channel Emotes
|
||||||
std::vector<std::string> &ffzChannelEmoteCodes =
|
std::vector<std::string> &ffzChannelEmoteCodes =
|
||||||
emoteManager.ffzChannelEmoteCodes[this->channelName.toStdString()];
|
app->emotes->ffzChannelEmoteCodes[this->channelName.toStdString()];
|
||||||
for (const auto &m : ffzChannelEmoteCodes) {
|
for (const auto &m : ffzChannelEmoteCodes) {
|
||||||
this->addString(m, TaggedString::Type::FFZChannelEmote);
|
this->addString(m, TaggedString::Type::FFZChannelEmote);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Global: Emojis
|
// Global: Emojis
|
||||||
const auto &emojiShortCodes = emoteManager.emojiShortCodes;
|
const auto &emojiShortCodes = app->emotes->emojiShortCodes;
|
||||||
for (const auto &m : emojiShortCodes) {
|
for (const auto &m : emojiShortCodes) {
|
||||||
this->addString(":" + m + ":", TaggedString::Type::Emoji);
|
this->addString(":" + m + ":", TaggedString::Type::Emoji);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
#include "util/networkrequest.hpp"
|
#include "util/networkrequest.hpp"
|
||||||
|
|
||||||
|
#include "application.hpp"
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
namespace util {
|
namespace util {
|
||||||
|
|
||||||
|
@ -26,9 +28,9 @@ void NetworkRequest::setUseQuickLoadCache(bool value)
|
||||||
void NetworkRequest::Data::writeToCache(const QByteArray &bytes)
|
void NetworkRequest::Data::writeToCache(const QByteArray &bytes)
|
||||||
{
|
{
|
||||||
if (this->useQuickLoadCache) {
|
if (this->useQuickLoadCache) {
|
||||||
auto &pathManager = singletons::PathManager::getInstance();
|
auto app = getApp();
|
||||||
|
|
||||||
QFile cachedFile(pathManager.cacheFolderPath + "/" + this->getHash());
|
QFile cachedFile(app->paths->cacheFolderPath + "/" + this->getHash());
|
||||||
|
|
||||||
if (cachedFile.open(QIODevice::WriteOnly)) {
|
if (cachedFile.open(QIODevice::WriteOnly)) {
|
||||||
cachedFile.write(bytes);
|
cachedFile.write(bytes);
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "application.hpp"
|
||||||
#include "singletons/pathmanager.hpp"
|
#include "singletons/pathmanager.hpp"
|
||||||
#include "util/networkmanager.hpp"
|
#include "util/networkmanager.hpp"
|
||||||
#include "util/networkrequester.hpp"
|
#include "util/networkrequester.hpp"
|
||||||
|
@ -125,9 +126,9 @@ public:
|
||||||
void get(FinishedCallback onFinished)
|
void get(FinishedCallback onFinished)
|
||||||
{
|
{
|
||||||
if (this->data.useQuickLoadCache) {
|
if (this->data.useQuickLoadCache) {
|
||||||
auto &pathManager = singletons::PathManager::getInstance();
|
auto app = getApp();
|
||||||
|
|
||||||
QFile cachedFile(pathManager.cacheFolderPath + "/" + this->data.getHash());
|
QFile cachedFile(app->paths->cacheFolderPath + "/" + this->data.getHash());
|
||||||
|
|
||||||
if (cachedFile.exists()) {
|
if (cachedFile.exists()) {
|
||||||
if (cachedFile.open(QIODevice::ReadOnly)) {
|
if (cachedFile.open(QIODevice::ReadOnly)) {
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
#include "util/streamlink.hpp"
|
#include "util/streamlink.hpp"
|
||||||
|
|
||||||
|
#include "application.hpp"
|
||||||
#include "helpers.hpp"
|
#include "helpers.hpp"
|
||||||
#include "singletons/settingsmanager.hpp"
|
#include "singletons/settingsmanager.hpp"
|
||||||
#include "widgets/qualitypopup.hpp"
|
#include "widgets/qualitypopup.hpp"
|
||||||
|
@ -50,9 +52,9 @@ bool CheckStreamlinkPath(const QString &path)
|
||||||
// TODO: Make streamlink binary finder smarter
|
// TODO: Make streamlink binary finder smarter
|
||||||
QString GetStreamlinkBinaryPath()
|
QString GetStreamlinkBinaryPath()
|
||||||
{
|
{
|
||||||
singletons::SettingManager &settings = singletons::SettingManager::getInstance();
|
auto app = getApp();
|
||||||
|
|
||||||
QString settingPath = settings.streamlinkPath;
|
QString settingPath = app->settings->streamlinkPath;
|
||||||
|
|
||||||
QStringList paths;
|
QStringList paths;
|
||||||
paths << settingPath;
|
paths << settingPath;
|
||||||
|
@ -111,15 +113,15 @@ void GetStreamQualities(const QString &channelURL, std::function<void(QStringLis
|
||||||
|
|
||||||
void OpenStreamlink(const QString &channelURL, const QString &quality, QStringList extraArguments)
|
void OpenStreamlink(const QString &channelURL, const QString &quality, QStringList extraArguments)
|
||||||
{
|
{
|
||||||
singletons::SettingManager &settings = singletons::SettingManager::getInstance();
|
auto app = getApp();
|
||||||
|
|
||||||
QString path = GetStreamlinkBinaryPath();
|
QString path = GetStreamlinkBinaryPath();
|
||||||
|
|
||||||
QStringList arguments;
|
QStringList arguments;
|
||||||
|
|
||||||
QString additionalOptions = settings.streamlinkOpts.getValue();
|
QString additionalOptions = app->settings->streamlinkOpts.getValue();
|
||||||
if (!additionalOptions.isEmpty()) {
|
if (!additionalOptions.isEmpty()) {
|
||||||
arguments << settings.streamlinkOpts;
|
arguments << app->settings->streamlinkOpts;
|
||||||
}
|
}
|
||||||
|
|
||||||
arguments.append(extraArguments);
|
arguments.append(extraArguments);
|
||||||
|
@ -135,11 +137,11 @@ void OpenStreamlink(const QString &channelURL, const QString &quality, QStringLi
|
||||||
|
|
||||||
void Start(const QString &channel)
|
void Start(const QString &channel)
|
||||||
{
|
{
|
||||||
|
auto app = getApp();
|
||||||
|
|
||||||
QString channelURL = "twitch.tv/" + channel;
|
QString channelURL = "twitch.tv/" + channel;
|
||||||
|
|
||||||
singletons::SettingManager &settings = singletons::SettingManager::getInstance();
|
QString preferredQuality = app->settings->preferredQuality;
|
||||||
|
|
||||||
QString preferredQuality = settings.preferredQuality;
|
|
||||||
preferredQuality = preferredQuality.toLower();
|
preferredQuality = preferredQuality.toLower();
|
||||||
|
|
||||||
if (preferredQuality == "choose") {
|
if (preferredQuality == "choose") {
|
||||||
|
|
|
@ -100,8 +100,7 @@ static void put(QUrl url, std::function<void(QJsonObject)> successCallback)
|
||||||
{
|
{
|
||||||
QNetworkRequest request(url);
|
QNetworkRequest request(url);
|
||||||
|
|
||||||
auto &accountManager = singletons::AccountManager::getInstance();
|
auto currentTwitchUser = getApp()->accounts->Twitch.getCurrent();
|
||||||
auto currentTwitchUser = accountManager.Twitch.getCurrent();
|
|
||||||
QByteArray oauthToken;
|
QByteArray oauthToken;
|
||||||
if (currentTwitchUser) {
|
if (currentTwitchUser) {
|
||||||
oauthToken = currentTwitchUser->getOAuthToken().toUtf8();
|
oauthToken = currentTwitchUser->getOAuthToken().toUtf8();
|
||||||
|
@ -131,8 +130,7 @@ static void sendDelete(QUrl url, std::function<void()> successCallback)
|
||||||
{
|
{
|
||||||
QNetworkRequest request(url);
|
QNetworkRequest request(url);
|
||||||
|
|
||||||
auto &accountManager = singletons::AccountManager::getInstance();
|
auto currentTwitchUser = getApp()->accounts->Twitch.getCurrent();
|
||||||
auto currentTwitchUser = accountManager.Twitch.getCurrent();
|
|
||||||
QByteArray oauthToken;
|
QByteArray oauthToken;
|
||||||
if (currentTwitchUser) {
|
if (currentTwitchUser) {
|
||||||
oauthToken = currentTwitchUser->getOAuthToken().toUtf8();
|
oauthToken = currentTwitchUser->getOAuthToken().toUtf8();
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
#include "widgets/accountpopup.hpp"
|
#include "widgets/accountpopup.hpp"
|
||||||
|
|
||||||
|
#include "application.hpp"
|
||||||
#include "channel.hpp"
|
#include "channel.hpp"
|
||||||
#include "credentials.hpp"
|
#include "credentials.hpp"
|
||||||
#include "singletons/accountmanager.hpp"
|
#include "singletons/accountmanager.hpp"
|
||||||
|
@ -23,6 +25,8 @@ AccountPopupWidget::AccountPopupWidget(ChannelPtr _channel)
|
||||||
, ui(new Ui::AccountPopup)
|
, ui(new Ui::AccountPopup)
|
||||||
, channel(_channel)
|
, channel(_channel)
|
||||||
{
|
{
|
||||||
|
auto app = getApp();
|
||||||
|
|
||||||
this->ui->setupUi(this);
|
this->ui->setupUi(this);
|
||||||
|
|
||||||
this->setStayInScreenRect(true);
|
this->setStayInScreenRect(true);
|
||||||
|
@ -33,15 +37,11 @@ AccountPopupWidget::AccountPopupWidget(ChannelPtr _channel)
|
||||||
|
|
||||||
this->resize(0, 0);
|
this->resize(0, 0);
|
||||||
|
|
||||||
auto &accountManager = singletons::AccountManager::getInstance();
|
|
||||||
|
|
||||||
connect(this, &AccountPopupWidget::refreshButtons, this,
|
connect(this, &AccountPopupWidget::refreshButtons, this,
|
||||||
&AccountPopupWidget::actuallyRefreshButtons, Qt::QueuedConnection);
|
&AccountPopupWidget::actuallyRefreshButtons, Qt::QueuedConnection);
|
||||||
|
|
||||||
accountManager.Twitch.userChanged.connect([this] {
|
app->accounts->Twitch.userChanged.connect([=] {
|
||||||
singletons::AccountManager &accountManager = singletons::AccountManager::getInstance();
|
auto currentTwitchUser = app->accounts->Twitch.getCurrent();
|
||||||
|
|
||||||
auto currentTwitchUser = accountManager.Twitch.getCurrent();
|
|
||||||
if (!currentTwitchUser) {
|
if (!currentTwitchUser) {
|
||||||
// No twitch user set (should never happen)
|
// No twitch user set (should never happen)
|
||||||
return;
|
return;
|
||||||
|
@ -53,8 +53,6 @@ AccountPopupWidget::AccountPopupWidget(ChannelPtr _channel)
|
||||||
this->loggedInUser.refreshUserType(this->channel, true);
|
this->loggedInUser.refreshUserType(this->channel, true);
|
||||||
});
|
});
|
||||||
|
|
||||||
singletons::SettingManager &settings = singletons::SettingManager::getInstance();
|
|
||||||
|
|
||||||
for (auto button : this->ui->profileLayout->findChildren<QPushButton *>()) {
|
for (auto button : this->ui->profileLayout->findChildren<QPushButton *>()) {
|
||||||
button->setFocusProxy(this);
|
button->setFocusProxy(this);
|
||||||
}
|
}
|
||||||
|
@ -129,19 +127,19 @@ AccountPopupWidget::AccountPopupWidget(ChannelPtr _channel)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
QObject::connect(this->ui->disableHighlights, &QPushButton::clicked, this, [=, &settings]() {
|
QObject::connect(this->ui->disableHighlights, &QPushButton::clicked, this, [=]() {
|
||||||
QString str = settings.highlightUserBlacklist;
|
QString str = app->settings->highlightUserBlacklist;
|
||||||
str.append(this->ui->lblUsername->text() + "\n");
|
str.append(this->ui->lblUsername->text() + "\n");
|
||||||
settings.highlightUserBlacklist = str;
|
app->settings->highlightUserBlacklist = str;
|
||||||
this->ui->disableHighlights->hide();
|
this->ui->disableHighlights->hide();
|
||||||
this->ui->enableHighlights->show();
|
this->ui->enableHighlights->show();
|
||||||
});
|
});
|
||||||
|
|
||||||
QObject::connect(this->ui->enableHighlights, &QPushButton::clicked, this, [=, &settings]() {
|
QObject::connect(this->ui->enableHighlights, &QPushButton::clicked, this, [=]() {
|
||||||
QString str = settings.highlightUserBlacklist;
|
QString str = app->settings->highlightUserBlacklist;
|
||||||
QStringList list = str.split("\n");
|
QStringList list = str.split("\n");
|
||||||
list.removeAll(this->ui->lblUsername->text());
|
list.removeAll(this->ui->lblUsername->text());
|
||||||
settings.highlightUserBlacklist = list.join("\n");
|
app->settings->highlightUserBlacklist = list.join("\n");
|
||||||
this->ui->enableHighlights->hide();
|
this->ui->enableHighlights->hide();
|
||||||
this->ui->disableHighlights->show();
|
this->ui->disableHighlights->show();
|
||||||
});
|
});
|
||||||
|
@ -279,8 +277,7 @@ void AccountPopupWidget::sendCommand(QPushButton *button, QString command)
|
||||||
|
|
||||||
void AccountPopupWidget::refreshLayouts()
|
void AccountPopupWidget::refreshLayouts()
|
||||||
{
|
{
|
||||||
singletons::AccountManager &accountManager = singletons::AccountManager::getInstance();
|
auto currentTwitchUser = getApp()->accounts->Twitch.getCurrent();
|
||||||
auto currentTwitchUser = accountManager.Twitch.getCurrent();
|
|
||||||
if (!currentTwitchUser) {
|
if (!currentTwitchUser) {
|
||||||
// No twitch user set (should never happen)
|
// No twitch user set (should never happen)
|
||||||
return;
|
return;
|
||||||
|
@ -378,7 +375,7 @@ void AccountPopupWidget::showEvent(QShowEvent *)
|
||||||
|
|
||||||
this->refreshLayouts();
|
this->refreshLayouts();
|
||||||
|
|
||||||
QString blacklisted = singletons::SettingManager::getInstance().highlightUserBlacklist;
|
QString blacklisted = getApp()->settings->highlightUserBlacklist;
|
||||||
QStringList list = blacklisted.split("\n", QString::SkipEmptyParts);
|
QStringList list = blacklisted.split("\n", QString::SkipEmptyParts);
|
||||||
if (list.contains(this->ui->lblUsername->text(), Qt::CaseInsensitive)) {
|
if (list.contains(this->ui->lblUsername->text(), Qt::CaseInsensitive)) {
|
||||||
this->ui->disableHighlights->hide();
|
this->ui->disableHighlights->hide();
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
#include "accountswitchwidget.hpp"
|
#include "accountswitchwidget.hpp"
|
||||||
|
|
||||||
|
#include "application.hpp"
|
||||||
#include "const.hpp"
|
#include "const.hpp"
|
||||||
#include "singletons/accountmanager.hpp"
|
#include "singletons/accountmanager.hpp"
|
||||||
|
|
||||||
|
@ -8,22 +10,22 @@ namespace widgets {
|
||||||
AccountSwitchWidget::AccountSwitchWidget(QWidget *parent)
|
AccountSwitchWidget::AccountSwitchWidget(QWidget *parent)
|
||||||
: QListWidget(parent)
|
: QListWidget(parent)
|
||||||
{
|
{
|
||||||
singletons::AccountManager &accountManager = singletons::AccountManager::getInstance();
|
auto app = getApp();
|
||||||
|
|
||||||
this->addItem(ANONYMOUS_USERNAME_LABEL);
|
this->addItem(ANONYMOUS_USERNAME_LABEL);
|
||||||
|
|
||||||
for (const auto &userName : accountManager.Twitch.getUsernames()) {
|
for (const auto &userName : app->accounts->Twitch.getUsernames()) {
|
||||||
this->addItem(userName);
|
this->addItem(userName);
|
||||||
}
|
}
|
||||||
|
|
||||||
accountManager.Twitch.userListUpdated.connect([this, &accountManager]() {
|
app->accounts->Twitch.userListUpdated.connect([=]() {
|
||||||
this->blockSignals(true);
|
this->blockSignals(true);
|
||||||
|
|
||||||
this->clear();
|
this->clear();
|
||||||
|
|
||||||
this->addItem(ANONYMOUS_USERNAME_LABEL);
|
this->addItem(ANONYMOUS_USERNAME_LABEL);
|
||||||
|
|
||||||
for (const auto &userName : accountManager.Twitch.getUsernames()) {
|
for (const auto &userName : app->accounts->Twitch.getUsernames()) {
|
||||||
this->addItem(userName);
|
this->addItem(userName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,13 +36,13 @@ AccountSwitchWidget::AccountSwitchWidget(QWidget *parent)
|
||||||
|
|
||||||
this->refreshSelection();
|
this->refreshSelection();
|
||||||
|
|
||||||
QObject::connect(this, &QListWidget::clicked, [this, &accountManager] {
|
QObject::connect(this, &QListWidget::clicked, [=] {
|
||||||
if (!this->selectedItems().isEmpty()) {
|
if (!this->selectedItems().isEmpty()) {
|
||||||
QString newUsername = this->currentItem()->text();
|
QString newUsername = this->currentItem()->text();
|
||||||
if (newUsername.compare(ANONYMOUS_USERNAME_LABEL, Qt::CaseInsensitive) == 0) {
|
if (newUsername.compare(ANONYMOUS_USERNAME_LABEL, Qt::CaseInsensitive) == 0) {
|
||||||
accountManager.Twitch.currentUsername = "";
|
app->accounts->Twitch.currentUsername = "";
|
||||||
} else {
|
} else {
|
||||||
accountManager.Twitch.currentUsername = newUsername.toStdString();
|
app->accounts->Twitch.currentUsername = newUsername.toStdString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -57,7 +59,9 @@ void AccountSwitchWidget::refreshSelection()
|
||||||
|
|
||||||
// Select the currently logged in user
|
// Select the currently logged in user
|
||||||
if (this->count() > 0) {
|
if (this->count() > 0) {
|
||||||
auto currentUser = singletons::AccountManager::getInstance().Twitch.getCurrent();
|
auto app = getApp();
|
||||||
|
|
||||||
|
auto currentUser = app->accounts->Twitch.getCurrent();
|
||||||
|
|
||||||
if (currentUser->isAnon()) {
|
if (currentUser->isAnon()) {
|
||||||
this->setCurrentRow(0);
|
this->setCurrentRow(0);
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
#include "attachedwindow.hpp"
|
#include "attachedwindow.hpp"
|
||||||
|
|
||||||
|
#include "application.hpp"
|
||||||
|
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
|
|
||||||
|
@ -22,7 +24,7 @@ AttachedWindow::AttachedWindow(void *_target, int _yOffset)
|
||||||
layout->setMargin(0);
|
layout->setMargin(0);
|
||||||
this->setLayout(layout);
|
this->setLayout(layout);
|
||||||
|
|
||||||
auto *split = new Split(singletons::ThemeManager::getInstance(), this);
|
auto *split = new Split(this);
|
||||||
this->ui.split = split;
|
this->ui.split = split;
|
||||||
split->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::MinimumExpanding);
|
split->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::MinimumExpanding);
|
||||||
layout->addWidget(split);
|
layout->addWidget(split);
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
#include "widgets/basewidget.hpp"
|
#include "widgets/basewidget.hpp"
|
||||||
|
|
||||||
|
#include "application.hpp"
|
||||||
#include "debug/log.hpp"
|
#include "debug/log.hpp"
|
||||||
#include "singletons/settingsmanager.hpp"
|
#include "singletons/settingsmanager.hpp"
|
||||||
#include "singletons/thememanager.hpp"
|
#include "singletons/thememanager.hpp"
|
||||||
|
@ -12,16 +14,8 @@
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
namespace widgets {
|
namespace widgets {
|
||||||
|
|
||||||
BaseWidget::BaseWidget(singletons::ThemeManager &_themeManager, QWidget *parent, Qt::WindowFlags f)
|
BaseWidget::BaseWidget(QWidget *parent, Qt::WindowFlags f)
|
||||||
: QWidget(parent, f)
|
: QWidget(parent, f)
|
||||||
, themeManager(_themeManager)
|
|
||||||
{
|
|
||||||
this->init();
|
|
||||||
}
|
|
||||||
|
|
||||||
BaseWidget::BaseWidget(BaseWidget *parent, Qt::WindowFlags f)
|
|
||||||
: QWidget(parent, f)
|
|
||||||
, themeManager(singletons::ThemeManager::getInstance())
|
|
||||||
{
|
{
|
||||||
this->init();
|
this->init();
|
||||||
}
|
}
|
||||||
|
@ -87,7 +81,10 @@ void BaseWidget::setScaleIndependantHeight(int value)
|
||||||
|
|
||||||
void BaseWidget::init()
|
void BaseWidget::init()
|
||||||
{
|
{
|
||||||
this->themeConnection = this->themeManager.updated.connect([this]() {
|
auto app = getApp();
|
||||||
|
this->themeManager = app->themes;
|
||||||
|
|
||||||
|
this->themeConnection = this->themeManager->updated.connect([this]() {
|
||||||
this->themeRefreshEvent();
|
this->themeRefreshEvent();
|
||||||
|
|
||||||
this->update();
|
this->update();
|
||||||
|
|
|
@ -17,13 +17,9 @@ class BaseWidget : public QWidget
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit BaseWidget(singletons::ThemeManager &_themeManager, QWidget *parent,
|
explicit BaseWidget(QWidget *parent, Qt::WindowFlags f = Qt::WindowFlags());
|
||||||
Qt::WindowFlags f = Qt::WindowFlags());
|
|
||||||
explicit BaseWidget(BaseWidget *parent, Qt::WindowFlags f = Qt::WindowFlags());
|
|
||||||
virtual ~BaseWidget();
|
virtual ~BaseWidget();
|
||||||
|
|
||||||
singletons::ThemeManager &themeManager;
|
|
||||||
|
|
||||||
float getScale() const;
|
float getScale() const;
|
||||||
pajlada::Signals::Signal<float> scaleChanged;
|
pajlada::Signals::Signal<float> scaleChanged;
|
||||||
|
|
||||||
|
@ -45,6 +41,8 @@ protected:
|
||||||
|
|
||||||
void setScale(float value);
|
void setScale(float value);
|
||||||
|
|
||||||
|
singletons::ThemeManager *themeManager;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void init();
|
void init();
|
||||||
float scale = 1.f;
|
float scale = 1.f;
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include "basewindow.hpp"
|
#include "basewindow.hpp"
|
||||||
|
|
||||||
|
#include "application.hpp"
|
||||||
#include "debug/log.hpp"
|
#include "debug/log.hpp"
|
||||||
#include "singletons/settingsmanager.hpp"
|
#include "singletons/settingsmanager.hpp"
|
||||||
#include "util/nativeeventhelper.hpp"
|
#include "util/nativeeventhelper.hpp"
|
||||||
|
@ -31,23 +32,8 @@
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
namespace widgets {
|
namespace widgets {
|
||||||
|
|
||||||
BaseWindow::BaseWindow(singletons::ThemeManager &_themeManager, QWidget *parent,
|
|
||||||
bool _enableCustomFrame)
|
|
||||||
: BaseWidget(_themeManager, parent, Qt::Window)
|
|
||||||
, enableCustomFrame(_enableCustomFrame)
|
|
||||||
{
|
|
||||||
this->init();
|
|
||||||
}
|
|
||||||
|
|
||||||
BaseWindow::BaseWindow(BaseWidget *parent, bool _enableCustomFrame)
|
|
||||||
: BaseWidget(parent, Qt::Window)
|
|
||||||
, enableCustomFrame(_enableCustomFrame)
|
|
||||||
{
|
|
||||||
this->init();
|
|
||||||
}
|
|
||||||
|
|
||||||
BaseWindow::BaseWindow(QWidget *parent, bool _enableCustomFrame)
|
BaseWindow::BaseWindow(QWidget *parent, bool _enableCustomFrame)
|
||||||
: BaseWidget(singletons::ThemeManager::getInstance(), parent, Qt::Window)
|
: BaseWidget(parent, Qt::Window)
|
||||||
, enableCustomFrame(_enableCustomFrame)
|
, enableCustomFrame(_enableCustomFrame)
|
||||||
{
|
{
|
||||||
this->init();
|
this->init();
|
||||||
|
@ -55,6 +41,8 @@ BaseWindow::BaseWindow(QWidget *parent, bool _enableCustomFrame)
|
||||||
|
|
||||||
void BaseWindow::init()
|
void BaseWindow::init()
|
||||||
{
|
{
|
||||||
|
auto app = getApp();
|
||||||
|
|
||||||
this->setWindowIcon(QIcon(":/images/icon.png"));
|
this->setWindowIcon(QIcon(":/images/icon.png"));
|
||||||
|
|
||||||
#ifdef USEWINSDK
|
#ifdef USEWINSDK
|
||||||
|
@ -127,7 +115,7 @@ void BaseWindow::init()
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (singletons::SettingManager::getInstance().windowTopMost.getValue()) {
|
if (app->settings->windowTopMost.getValue()) {
|
||||||
this->setWindowFlags(this->windowFlags() | Qt::WindowStaysOnTopHint);
|
this->setWindowFlags(this->windowFlags() | Qt::WindowStaysOnTopHint);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -167,21 +155,21 @@ void BaseWindow::themeRefreshEvent()
|
||||||
if (this->hasCustomWindowFrame()) {
|
if (this->hasCustomWindowFrame()) {
|
||||||
QPalette palette;
|
QPalette palette;
|
||||||
palette.setColor(QPalette::Background, QColor(0, 0, 0, 0));
|
palette.setColor(QPalette::Background, QColor(0, 0, 0, 0));
|
||||||
palette.setColor(QPalette::Foreground, this->themeManager.window.text);
|
palette.setColor(QPalette::Foreground, this->themeManager->window.text);
|
||||||
this->setPalette(palette);
|
this->setPalette(palette);
|
||||||
|
|
||||||
QPalette palette_title;
|
QPalette palette_title;
|
||||||
palette_title.setColor(QPalette::Foreground,
|
palette_title.setColor(QPalette::Foreground,
|
||||||
this->themeManager.isLightTheme() ? "#333" : "#ccc");
|
this->themeManager->isLightTheme() ? "#333" : "#ccc");
|
||||||
this->ui.titleLabel->setPalette(palette_title);
|
this->ui.titleLabel->setPalette(palette_title);
|
||||||
|
|
||||||
for (RippleEffectButton *button : this->ui.buttons) {
|
for (RippleEffectButton *button : this->ui.buttons) {
|
||||||
button->setMouseEffectColor(this->themeManager.window.text);
|
button->setMouseEffectColor(this->themeManager->window.text);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
QPalette palette;
|
QPalette palette;
|
||||||
palette.setColor(QPalette::Background, this->themeManager.window.background);
|
palette.setColor(QPalette::Background, this->themeManager->window.background);
|
||||||
palette.setColor(QPalette::Foreground, this->themeManager.window.text);
|
palette.setColor(QPalette::Foreground, this->themeManager->window.text);
|
||||||
this->setPalette(palette);
|
this->setPalette(palette);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -430,7 +418,7 @@ void BaseWindow::paintEvent(QPaintEvent *event)
|
||||||
// bool windowFocused = this->window() == QApplication::activeWindow();
|
// bool windowFocused = this->window() == QApplication::activeWindow();
|
||||||
|
|
||||||
painter.fillRect(QRect(0, 1, this->width() - 0, this->height() - 0),
|
painter.fillRect(QRect(0, 1, this->width() - 0, this->height() - 0),
|
||||||
this->themeManager.window.background);
|
this->themeManager->window.background);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,9 +19,6 @@ class BaseWindow : public BaseWidget
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit BaseWindow(singletons::ThemeManager &_themeManager, QWidget *parent,
|
|
||||||
bool enableCustomFrame = false);
|
|
||||||
explicit BaseWindow(BaseWidget *parent, bool enableCustomFrame = false);
|
|
||||||
explicit BaseWindow(QWidget *parent = nullptr, bool enableCustomFrame = false);
|
explicit BaseWindow(QWidget *parent = nullptr, bool enableCustomFrame = false);
|
||||||
|
|
||||||
QWidget *getLayoutContainer();
|
QWidget *getLayoutContainer();
|
||||||
|
|
|
@ -1,21 +1,22 @@
|
||||||
#include "emotepopup.hpp"
|
#include "emotepopup.hpp"
|
||||||
|
|
||||||
#include <QHBoxLayout>
|
#include "application.hpp"
|
||||||
#include <QTabWidget>
|
|
||||||
|
|
||||||
#include "messages/messagebuilder.hpp"
|
#include "messages/messagebuilder.hpp"
|
||||||
#include "providers/twitch/twitchchannel.hpp"
|
#include "providers/twitch/twitchchannel.hpp"
|
||||||
#include "singletons/accountmanager.hpp"
|
#include "singletons/accountmanager.hpp"
|
||||||
#include "widgets/notebook.hpp"
|
#include "widgets/notebook.hpp"
|
||||||
|
|
||||||
|
#include <QHBoxLayout>
|
||||||
|
#include <QTabWidget>
|
||||||
|
|
||||||
using namespace chatterino::providers::twitch;
|
using namespace chatterino::providers::twitch;
|
||||||
using namespace chatterino::messages;
|
using namespace chatterino::messages;
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
namespace widgets {
|
namespace widgets {
|
||||||
|
|
||||||
EmotePopup::EmotePopup(singletons::ThemeManager &themeManager)
|
EmotePopup::EmotePopup()
|
||||||
: BaseWindow(themeManager, nullptr, true)
|
: BaseWindow(nullptr, true)
|
||||||
{
|
{
|
||||||
this->viewEmotes = new ChannelView();
|
this->viewEmotes = new ChannelView();
|
||||||
this->viewEmojis = new ChannelView();
|
this->viewEmojis = new ChannelView();
|
||||||
|
@ -80,16 +81,16 @@ void EmotePopup::loadChannel(ChannelPtr _channel)
|
||||||
emoteChannel->addMessage(builder2.getMessage());
|
emoteChannel->addMessage(builder2.getMessage());
|
||||||
};
|
};
|
||||||
|
|
||||||
singletons::EmoteManager &emoteManager = singletons::EmoteManager::getInstance();
|
auto app = getApp();
|
||||||
|
|
||||||
QString userID = singletons::AccountManager::getInstance().Twitch.getCurrent()->getUserId();
|
QString userID = app->accounts->Twitch.getCurrent()->getUserId();
|
||||||
|
|
||||||
addEmotes(emoteManager.twitchAccountEmotes[userID.toStdString()].emotes,
|
addEmotes(app->emotes->twitchAccountEmotes[userID.toStdString()].emotes,
|
||||||
"Twitch Account Emotes", "Twitch Account Emote");
|
"Twitch Account Emotes", "Twitch Account Emote");
|
||||||
addEmotes(emoteManager.bttvGlobalEmotes, "BetterTTV Global Emotes", "BetterTTV Global Emote");
|
addEmotes(app->emotes->bttvGlobalEmotes, "BetterTTV Global Emotes", "BetterTTV Global Emote");
|
||||||
addEmotes(*channel->bttvChannelEmotes.get(), "BetterTTV Channel Emotes",
|
addEmotes(*channel->bttvChannelEmotes.get(), "BetterTTV Channel Emotes",
|
||||||
"BetterTTV Channel Emote");
|
"BetterTTV Channel Emote");
|
||||||
addEmotes(emoteManager.ffzGlobalEmotes, "FrankerFaceZ Global Emotes",
|
addEmotes(app->emotes->ffzGlobalEmotes, "FrankerFaceZ Global Emotes",
|
||||||
"FrankerFaceZ Global Emote");
|
"FrankerFaceZ Global Emote");
|
||||||
addEmotes(*channel->ffzChannelEmotes.get(), "FrankerFaceZ Channel Emotes",
|
addEmotes(*channel->ffzChannelEmotes.get(), "FrankerFaceZ Channel Emotes",
|
||||||
"FrankerFaceZ Channel Emote");
|
"FrankerFaceZ Channel Emote");
|
||||||
|
@ -99,7 +100,7 @@ void EmotePopup::loadChannel(ChannelPtr _channel)
|
||||||
|
|
||||||
void EmotePopup::loadEmojis()
|
void EmotePopup::loadEmojis()
|
||||||
{
|
{
|
||||||
auto &emojis = singletons::EmoteManager::getInstance().getEmojis();
|
auto &emojis = getApp()->emotes->getEmojis();
|
||||||
|
|
||||||
ChannelPtr emojiChannel(new Channel("", Channel::None));
|
ChannelPtr emojiChannel(new Channel("", Channel::None));
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ namespace widgets {
|
||||||
class EmotePopup : public BaseWindow
|
class EmotePopup : public BaseWindow
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit EmotePopup(singletons::ThemeManager &);
|
EmotePopup();
|
||||||
|
|
||||||
void loadChannel(ChannelPtr channel);
|
void loadChannel(ChannelPtr channel);
|
||||||
void loadEmojis();
|
void loadEmojis();
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
#include "channelview.hpp"
|
#include "channelview.hpp"
|
||||||
|
|
||||||
|
#include "application.hpp"
|
||||||
#include "debug/log.hpp"
|
#include "debug/log.hpp"
|
||||||
#include "messages/layouts/messagelayout.hpp"
|
#include "messages/layouts/messagelayout.hpp"
|
||||||
#include "messages/limitedqueuesnapshot.hpp"
|
#include "messages/limitedqueuesnapshot.hpp"
|
||||||
|
@ -38,14 +40,17 @@ ChannelView::ChannelView(BaseWidget *parent)
|
||||||
, scrollBar(this)
|
, scrollBar(this)
|
||||||
, userPopupWidget(std::shared_ptr<TwitchChannel>())
|
, userPopupWidget(std::shared_ptr<TwitchChannel>())
|
||||||
{
|
{
|
||||||
|
auto app = getApp();
|
||||||
|
|
||||||
#ifndef Q_OS_MAC
|
#ifndef Q_OS_MAC
|
||||||
// this->setAttribute(Qt::WA_OpaquePaintEvent);
|
// this->setAttribute(Qt::WA_OpaquePaintEvent);
|
||||||
#endif
|
#endif
|
||||||
this->setMouseTracking(true);
|
this->setMouseTracking(true);
|
||||||
|
|
||||||
QObject::connect(&singletons::SettingManager::getInstance(),
|
this->managedConnections.emplace_back(app->settings->wordFlagsChanged.connect([=] {
|
||||||
&singletons::SettingManager::wordFlagsChanged, this,
|
this->layoutMessages();
|
||||||
&ChannelView::wordFlagsChanged);
|
this->update();
|
||||||
|
}));
|
||||||
|
|
||||||
this->scrollBar.getCurrentValueChanged().connect([this] {
|
this->scrollBar.getCurrentValueChanged().connect([this] {
|
||||||
// Whenever the scrollbar value has been changed, re-render the ChatWidgetView
|
// Whenever the scrollbar value has been changed, re-render the ChatWidgetView
|
||||||
|
@ -56,10 +61,10 @@ ChannelView::ChannelView(BaseWidget *parent)
|
||||||
this->queueUpdate();
|
this->queueUpdate();
|
||||||
});
|
});
|
||||||
|
|
||||||
singletons::WindowManager &windowManager = singletons::WindowManager::getInstance();
|
this->repaintGifsConnection = app->windows->repaintGifs.connect([&] {
|
||||||
|
this->queueUpdate(); //
|
||||||
this->repaintGifsConnection = windowManager.repaintGifs.connect([&] { this->queueUpdate(); });
|
});
|
||||||
this->layoutConnection = windowManager.layout.connect([&](Channel *channel) {
|
this->layoutConnection = app->windows->layout.connect([&](Channel *channel) {
|
||||||
if (channel == nullptr || this->channel.get() == channel) {
|
if (channel == nullptr || this->channel.get() == channel) {
|
||||||
this->layoutMessages();
|
this->layoutMessages();
|
||||||
}
|
}
|
||||||
|
@ -75,10 +80,10 @@ ChannelView::ChannelView(BaseWidget *parent)
|
||||||
this->layoutMessages(); //
|
this->layoutMessages(); //
|
||||||
}));
|
}));
|
||||||
|
|
||||||
connect(goToBottom, &RippleEffectLabel::clicked, this, [this] {
|
connect(goToBottom, &RippleEffectLabel::clicked, this, [=] {
|
||||||
QTimer::singleShot(180, [this] {
|
QTimer::singleShot(180, [=] {
|
||||||
this->scrollBar.scrollToBottom(singletons::SettingManager::getInstance()
|
this->scrollBar.scrollToBottom(
|
||||||
.enableSmoothScrollingNewMessages.getValue());
|
app->settings->enableSmoothScrollingNewMessages.getValue());
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -100,8 +105,11 @@ ChannelView::ChannelView(BaseWidget *parent)
|
||||||
|
|
||||||
this->scrollBar.resize(this->scrollBar.width(), this->height() + 1);
|
this->scrollBar.resize(this->scrollBar.width(), this->height() + 1);
|
||||||
|
|
||||||
singletons::SettingManager::getInstance().showLastMessageIndicator.connect(
|
app->settings->showLastMessageIndicator.connect(
|
||||||
[this](auto, auto) { this->update(); }, this->managedConnections);
|
[this](auto, auto) {
|
||||||
|
this->update(); //
|
||||||
|
},
|
||||||
|
this->managedConnections);
|
||||||
|
|
||||||
this->layoutCooldown = new QTimer(this);
|
this->layoutCooldown = new QTimer(this);
|
||||||
this->layoutCooldown->setSingleShot(true);
|
this->layoutCooldown->setSingleShot(true);
|
||||||
|
@ -117,9 +125,6 @@ ChannelView::ChannelView(BaseWidget *parent)
|
||||||
|
|
||||||
ChannelView::~ChannelView()
|
ChannelView::~ChannelView()
|
||||||
{
|
{
|
||||||
QObject::disconnect(&singletons::SettingManager::getInstance(),
|
|
||||||
&singletons::SettingManager::wordFlagsChanged, this,
|
|
||||||
&ChannelView::wordFlagsChanged);
|
|
||||||
this->messageAppendedConnection.disconnect();
|
this->messageAppendedConnection.disconnect();
|
||||||
this->messageRemovedConnection.disconnect();
|
this->messageRemovedConnection.disconnect();
|
||||||
this->repaintGifsConnection.disconnect();
|
this->repaintGifsConnection.disconnect();
|
||||||
|
@ -161,6 +166,8 @@ void ChannelView::layoutMessages()
|
||||||
|
|
||||||
void ChannelView::actuallyLayoutMessages()
|
void ChannelView::actuallyLayoutMessages()
|
||||||
{
|
{
|
||||||
|
auto app = getApp();
|
||||||
|
|
||||||
// BENCH(timer)
|
// BENCH(timer)
|
||||||
auto messagesSnapshot = this->getMessagesSnapshot();
|
auto messagesSnapshot = this->getMessagesSnapshot();
|
||||||
|
|
||||||
|
@ -238,9 +245,8 @@ void ChannelView::actuallyLayoutMessages()
|
||||||
// Perhaps also if the user scrolled with the scrollwheel in this ChatWidget in the last 0.2
|
// Perhaps also if the user scrolled with the scrollwheel in this ChatWidget in the last 0.2
|
||||||
// seconds or something
|
// seconds or something
|
||||||
if (this->enableScrollingToBottom && this->showingLatestMessages && showScrollbar) {
|
if (this->enableScrollingToBottom && this->showingLatestMessages && showScrollbar) {
|
||||||
this->scrollBar.scrollToBottom(
|
this->scrollBar.scrollToBottom(this->messageWasAdded &&
|
||||||
this->messageWasAdded &&
|
app->settings->enableSmoothScrollingNewMessages.getValue());
|
||||||
singletons::SettingManager::getInstance().enableSmoothScrollingNewMessages.getValue());
|
|
||||||
this->messageWasAdded = false;
|
this->messageWasAdded = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -494,11 +500,13 @@ void ChannelView::setSelection(const SelectionItem &start, const SelectionItem &
|
||||||
|
|
||||||
messages::MessageElement::Flags ChannelView::getFlags() const
|
messages::MessageElement::Flags ChannelView::getFlags() const
|
||||||
{
|
{
|
||||||
|
auto app = getApp();
|
||||||
|
|
||||||
if (this->overrideFlags) {
|
if (this->overrideFlags) {
|
||||||
return this->overrideFlags.get();
|
return this->overrideFlags.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
MessageElement::Flags flags = singletons::SettingManager::getInstance().getWordFlags();
|
MessageElement::Flags flags = app->settings->getWordFlags();
|
||||||
|
|
||||||
Split *split = dynamic_cast<Split *>(this->parentWidget());
|
Split *split = dynamic_cast<Split *>(this->parentWidget());
|
||||||
|
|
||||||
|
@ -520,7 +528,7 @@ void ChannelView::paintEvent(QPaintEvent * /*event*/)
|
||||||
|
|
||||||
QPainter painter(this);
|
QPainter painter(this);
|
||||||
|
|
||||||
painter.fillRect(rect(), this->themeManager.splits.background);
|
painter.fillRect(rect(), this->themeManager->splits.background);
|
||||||
|
|
||||||
// draw messages
|
// draw messages
|
||||||
this->drawMessages(painter);
|
this->drawMessages(painter);
|
||||||
|
@ -532,6 +540,8 @@ void ChannelView::paintEvent(QPaintEvent * /*event*/)
|
||||||
// overlay when a message is disabled
|
// overlay when a message is disabled
|
||||||
void ChannelView::drawMessages(QPainter &painter)
|
void ChannelView::drawMessages(QPainter &painter)
|
||||||
{
|
{
|
||||||
|
auto app = getApp();
|
||||||
|
|
||||||
auto messagesSnapshot = this->getMessagesSnapshot();
|
auto messagesSnapshot = this->getMessagesSnapshot();
|
||||||
|
|
||||||
size_t start = this->scrollBar.getCurrentValue();
|
size_t start = this->scrollBar.getCurrentValue();
|
||||||
|
@ -550,7 +560,7 @@ void ChannelView::drawMessages(QPainter &painter)
|
||||||
messages::MessageLayout *layout = messagesSnapshot[i].get();
|
messages::MessageLayout *layout = messagesSnapshot[i].get();
|
||||||
|
|
||||||
bool isLastMessage = false;
|
bool isLastMessage = false;
|
||||||
if (singletons::SettingManager::getInstance().showLastMessageIndicator) {
|
if (app->settings->showLastMessageIndicator) {
|
||||||
isLastMessage = this->lastReadMessage.get() == layout;
|
isLastMessage = this->lastReadMessage.get() == layout;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -599,7 +609,9 @@ void ChannelView::drawMessages(QPainter &painter)
|
||||||
void ChannelView::wheelEvent(QWheelEvent *event)
|
void ChannelView::wheelEvent(QWheelEvent *event)
|
||||||
{
|
{
|
||||||
if (this->scrollBar.isVisible()) {
|
if (this->scrollBar.isVisible()) {
|
||||||
float mouseMultiplier = singletons::SettingManager::getInstance().mouseScrollMultiplier;
|
auto app = getApp();
|
||||||
|
|
||||||
|
float mouseMultiplier = app->settings->mouseScrollMultiplier;
|
||||||
|
|
||||||
float desired = this->scrollBar.getDesiredValue();
|
float desired = this->scrollBar.getDesiredValue();
|
||||||
float delta = event->delta() * 1.5 * mouseMultiplier;
|
float delta = event->delta() * 1.5 * mouseMultiplier;
|
||||||
|
@ -677,7 +689,9 @@ void ChannelView::mouseMoveEvent(QMouseEvent *event)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (singletons::SettingManager::getInstance().pauseChatHover.getValue()) {
|
auto app = getApp();
|
||||||
|
|
||||||
|
if (app->settings->pauseChatHover.getValue()) {
|
||||||
this->pause(300);
|
this->pause(300);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -745,7 +759,9 @@ void ChannelView::mousePressEvent(QMouseEvent *event)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (singletons::SettingManager::getInstance().linksDoubleClickOnly.getValue()) {
|
auto app = getApp();
|
||||||
|
|
||||||
|
if (app->settings->linksDoubleClickOnly.getValue()) {
|
||||||
this->pause(200);
|
this->pause(200);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -808,6 +824,8 @@ void ChannelView::mouseReleaseEvent(QMouseEvent *event)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto app = getApp();
|
||||||
|
|
||||||
if (this->selecting) {
|
if (this->selecting) {
|
||||||
this->paused = false;
|
this->paused = false;
|
||||||
}
|
}
|
||||||
|
@ -852,8 +870,7 @@ void ChannelView::mouseReleaseEvent(QMouseEvent *event)
|
||||||
}
|
}
|
||||||
|
|
||||||
auto &link = hoverLayoutElement->getLink();
|
auto &link = hoverLayoutElement->getLink();
|
||||||
if (event->button() != Qt::LeftButton ||
|
if (event->button() != Qt::LeftButton || !app->settings->linksDoubleClickOnly) {
|
||||||
!singletons::SettingManager::getInstance().linksDoubleClickOnly) {
|
|
||||||
this->handleLinkClick(event, link, layout.get());
|
this->handleLinkClick(event, link, layout.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -862,7 +879,9 @@ void ChannelView::mouseReleaseEvent(QMouseEvent *event)
|
||||||
|
|
||||||
void ChannelView::mouseDoubleClickEvent(QMouseEvent *event)
|
void ChannelView::mouseDoubleClickEvent(QMouseEvent *event)
|
||||||
{
|
{
|
||||||
if (singletons::SettingManager::getInstance().linksDoubleClickOnly) {
|
auto app = getApp();
|
||||||
|
|
||||||
|
if (app->settings->linksDoubleClickOnly) {
|
||||||
std::shared_ptr<messages::MessageLayout> layout;
|
std::shared_ptr<messages::MessageLayout> layout;
|
||||||
QPoint relativePos;
|
QPoint relativePos;
|
||||||
int messageIndex;
|
int messageIndex;
|
||||||
|
|
|
@ -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->themeManager.splits.dropPreview);
|
this->themeManager->splits.dropPreview);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NotebookPageDropPreview::hideEvent(QHideEvent *)
|
void NotebookPageDropPreview::hideEvent(QHideEvent *)
|
||||||
|
|
|
@ -22,7 +22,7 @@ NotebookButton::NotebookButton(BaseWidget *parent)
|
||||||
|
|
||||||
void NotebookButton::themeRefreshEvent()
|
void NotebookButton::themeRefreshEvent()
|
||||||
{
|
{
|
||||||
this->setMouseEffectColor(this->themeManager.tabs.regular.text);
|
this->setMouseEffectColor(this->themeManager->tabs.regular.text);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NotebookButton::paintEvent(QPaintEvent *)
|
void NotebookButton::paintEvent(QPaintEvent *)
|
||||||
|
@ -33,11 +33,11 @@ void NotebookButton::paintEvent(QPaintEvent *)
|
||||||
QColor foreground;
|
QColor foreground;
|
||||||
|
|
||||||
if (mouseDown || mouseOver) {
|
if (mouseDown || mouseOver) {
|
||||||
background = this->themeManager.tabs.regular.backgrounds.hover.color();
|
background = this->themeManager->tabs.regular.backgrounds.hover.color();
|
||||||
foreground = this->themeManager.tabs.regular.text;
|
foreground = this->themeManager->tabs.regular.text;
|
||||||
} else {
|
} else {
|
||||||
background = this->themeManager.tabs.regular.backgrounds.regular.color();
|
background = this->themeManager->tabs.regular.backgrounds.regular.color();
|
||||||
foreground = this->themeManager.tabs.regular.text;
|
foreground = this->themeManager->tabs.regular.text;
|
||||||
}
|
}
|
||||||
|
|
||||||
painter.setPen(Qt::NoPen);
|
painter.setPen(Qt::NoPen);
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
#include "widgets/helper/notebooktab.hpp"
|
#include "widgets/helper/notebooktab.hpp"
|
||||||
|
|
||||||
|
#include "application.hpp"
|
||||||
#include "common.hpp"
|
#include "common.hpp"
|
||||||
#include "debug/log.hpp"
|
#include "debug/log.hpp"
|
||||||
#include "singletons/settingsmanager.hpp"
|
#include "singletons/settingsmanager.hpp"
|
||||||
|
@ -23,12 +25,14 @@ NotebookTab2::NotebookTab2(Notebook2 *_notebook)
|
||||||
, notebook(_notebook)
|
, notebook(_notebook)
|
||||||
, menu(this)
|
, menu(this)
|
||||||
{
|
{
|
||||||
|
auto app = getApp();
|
||||||
|
|
||||||
this->setAcceptDrops(true);
|
this->setAcceptDrops(true);
|
||||||
|
|
||||||
this->positionChangedAnimation.setEasingCurve(QEasingCurve(QEasingCurve::InCubic));
|
this->positionChangedAnimation.setEasingCurve(QEasingCurve(QEasingCurve::InCubic));
|
||||||
|
|
||||||
singletons::SettingManager::getInstance().hideTabX.connect(
|
app->settings->hideTabX.connect(boost::bind(&NotebookTab2::hideTabXChanged, this, _1),
|
||||||
boost::bind(&NotebookTab2::hideTabXChanged, this, _1), this->managedConnections);
|
this->managedConnections);
|
||||||
|
|
||||||
this->setMouseTracking(true);
|
this->setMouseTracking(true);
|
||||||
|
|
||||||
|
@ -77,12 +81,13 @@ void NotebookTab2::themeRefreshEvent()
|
||||||
|
|
||||||
void NotebookTab2::updateSize()
|
void NotebookTab2::updateSize()
|
||||||
{
|
{
|
||||||
|
auto app = getApp();
|
||||||
float scale = getScale();
|
float scale = getScale();
|
||||||
|
|
||||||
int width;
|
int width;
|
||||||
QFontMetrics metrics(this->font());
|
QFontMetrics metrics(this->font());
|
||||||
|
|
||||||
if (singletons::SettingManager::getInstance().hideTabX) {
|
if (app->settings->hideTabX) {
|
||||||
width = (int)((metrics.width(this->title) + 16 /*+ 16*/) * scale);
|
width = (int)((metrics.width(this->title) + 16 /*+ 16*/) * scale);
|
||||||
} else {
|
} else {
|
||||||
width = (int)((metrics.width(this->title) + 8 + 24 /*+ 16*/) * scale);
|
width = (int)((metrics.width(this->title) + 8 + 24 /*+ 16*/) * scale);
|
||||||
|
@ -173,7 +178,7 @@ void NotebookTab2::moveAnimated(QPoint pos, bool animated)
|
||||||
|
|
||||||
void NotebookTab2::paintEvent(QPaintEvent *)
|
void NotebookTab2::paintEvent(QPaintEvent *)
|
||||||
{
|
{
|
||||||
singletons::SettingManager &settingManager = singletons::SettingManager::getInstance();
|
auto app = getApp();
|
||||||
QPainter painter(this);
|
QPainter painter(this);
|
||||||
float scale = this->getScale();
|
float scale = this->getScale();
|
||||||
|
|
||||||
|
@ -182,16 +187,16 @@ void NotebookTab2::paintEvent(QPaintEvent *)
|
||||||
|
|
||||||
// select the right tab colors
|
// select the right tab colors
|
||||||
singletons::ThemeManager::TabColors colors;
|
singletons::ThemeManager::TabColors colors;
|
||||||
singletons::ThemeManager::TabColors regular = this->themeManager.tabs.regular;
|
singletons::ThemeManager::TabColors regular = this->themeManager->tabs.regular;
|
||||||
|
|
||||||
if (this->selected) {
|
if (this->selected) {
|
||||||
colors = this->themeManager.tabs.selected;
|
colors = this->themeManager->tabs.selected;
|
||||||
} else if (this->highlightState == HighlightState::Highlighted) {
|
} else if (this->highlightState == HighlightState::Highlighted) {
|
||||||
colors = this->themeManager.tabs.highlighted;
|
colors = this->themeManager->tabs.highlighted;
|
||||||
} else if (this->highlightState == HighlightState::NewMessage) {
|
} else if (this->highlightState == HighlightState::NewMessage) {
|
||||||
colors = this->themeManager.tabs.newMessage;
|
colors = this->themeManager->tabs.newMessage;
|
||||||
} else {
|
} else {
|
||||||
colors = this->themeManager.tabs.regular;
|
colors = this->themeManager->tabs.regular;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool windowFocused = this->window() == QApplication::activeWindow();
|
bool windowFocused = this->window() == QApplication::activeWindow();
|
||||||
|
@ -248,7 +253,7 @@ void NotebookTab2::paintEvent(QPaintEvent *)
|
||||||
painter.setPen(colors.text);
|
painter.setPen(colors.text);
|
||||||
|
|
||||||
// set area for text
|
// set area for text
|
||||||
int rectW = (settingManager.hideTabX ? 0 : static_cast<int>(16) * scale);
|
int rectW = (app->settings->hideTabX ? 0 : static_cast<int>(16) * scale);
|
||||||
QRect rect(0, 0, this->width() - rectW, height);
|
QRect rect(0, 0, this->width() - rectW, height);
|
||||||
|
|
||||||
// draw text
|
// draw text
|
||||||
|
@ -269,7 +274,7 @@ void NotebookTab2::paintEvent(QPaintEvent *)
|
||||||
}
|
}
|
||||||
|
|
||||||
// draw close x
|
// draw close x
|
||||||
if (!settingManager.hideTabX && (mouseOver || selected)) {
|
if (!app->settings->hideTabX && (mouseOver || selected)) {
|
||||||
QRect xRect = this->getXRect();
|
QRect xRect = this->getXRect();
|
||||||
if (!xRect.isNull()) {
|
if (!xRect.isNull()) {
|
||||||
if (mouseOverX) {
|
if (mouseOverX) {
|
||||||
|
@ -315,7 +320,7 @@ void NotebookTab2::mouseReleaseEvent(QMouseEvent *event)
|
||||||
this->notebook->removePage(this->page);
|
this->notebook->removePage(this->page);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!singletons::SettingManager::getInstance().hideTabX && this->mouseDownX &&
|
if (!getApp()->settings->hideTabX && this->mouseDownX &&
|
||||||
this->getXRect().contains(event->pos())) {
|
this->getXRect().contains(event->pos())) {
|
||||||
this->mouseDownX = false;
|
this->mouseDownX = false;
|
||||||
|
|
||||||
|
@ -350,8 +355,9 @@ void NotebookTab2::dragEnterEvent(QDragEnterEvent *)
|
||||||
|
|
||||||
void NotebookTab2::mouseMoveEvent(QMouseEvent *event)
|
void NotebookTab2::mouseMoveEvent(QMouseEvent *event)
|
||||||
{
|
{
|
||||||
if (!singletons::SettingManager::getInstance().hideTabX &&
|
auto app = getApp();
|
||||||
this->notebook->getAllowUserTabManagement()) //
|
|
||||||
|
if (!app->settings->hideTabX && this->notebook->getAllowUserTabManagement()) //
|
||||||
{
|
{
|
||||||
bool overX = this->getXRect().contains(event->pos());
|
bool overX = this->getXRect().contains(event->pos());
|
||||||
|
|
||||||
|
@ -397,12 +403,14 @@ NotebookTab::NotebookTab(Notebook *_notebook)
|
||||||
, notebook(_notebook)
|
, notebook(_notebook)
|
||||||
, menu(this)
|
, menu(this)
|
||||||
{
|
{
|
||||||
|
auto app = getApp();
|
||||||
|
|
||||||
this->setAcceptDrops(true);
|
this->setAcceptDrops(true);
|
||||||
|
|
||||||
this->positionChangedAnimation.setEasingCurve(QEasingCurve(QEasingCurve::InCubic));
|
this->positionChangedAnimation.setEasingCurve(QEasingCurve(QEasingCurve::InCubic));
|
||||||
|
|
||||||
singletons::SettingManager::getInstance().hideTabX.connect(
|
app->settings->hideTabX.connect(boost::bind(&NotebookTab::hideTabXChanged, this, _1),
|
||||||
boost::bind(&NotebookTab::hideTabXChanged, this, _1), this->managedConnections);
|
this->managedConnections);
|
||||||
|
|
||||||
this->setMouseTracking(true);
|
this->setMouseTracking(true);
|
||||||
|
|
||||||
|
@ -449,11 +457,13 @@ void NotebookTab::themeRefreshEvent()
|
||||||
|
|
||||||
void NotebookTab::updateSize()
|
void NotebookTab::updateSize()
|
||||||
{
|
{
|
||||||
|
auto app = getApp();
|
||||||
|
|
||||||
float scale = getScale();
|
float scale = getScale();
|
||||||
|
|
||||||
int width;
|
int width;
|
||||||
|
|
||||||
if (singletons::SettingManager::getInstance().hideTabX) {
|
if (app->settings->hideTabX) {
|
||||||
width = (int)((fontMetrics().width(this->title) + 16 /*+ 16*/) * scale);
|
width = (int)((fontMetrics().width(this->title) + 16 /*+ 16*/) * scale);
|
||||||
} else {
|
} else {
|
||||||
width = (int)((fontMetrics().width(this->title) + 8 + 24 /*+ 16*/) * scale);
|
width = (int)((fontMetrics().width(this->title) + 8 + 24 /*+ 16*/) * scale);
|
||||||
|
@ -544,7 +554,7 @@ void NotebookTab::moveAnimated(QPoint pos, bool animated)
|
||||||
|
|
||||||
void NotebookTab::paintEvent(QPaintEvent *)
|
void NotebookTab::paintEvent(QPaintEvent *)
|
||||||
{
|
{
|
||||||
singletons::SettingManager &settingManager = singletons::SettingManager::getInstance();
|
auto app = getApp();
|
||||||
QPainter painter(this);
|
QPainter painter(this);
|
||||||
float scale = this->getScale();
|
float scale = this->getScale();
|
||||||
|
|
||||||
|
@ -553,16 +563,16 @@ void NotebookTab::paintEvent(QPaintEvent *)
|
||||||
|
|
||||||
// select the right tab colors
|
// select the right tab colors
|
||||||
singletons::ThemeManager::TabColors colors;
|
singletons::ThemeManager::TabColors colors;
|
||||||
singletons::ThemeManager::TabColors regular = this->themeManager.tabs.regular;
|
singletons::ThemeManager::TabColors regular = this->themeManager->tabs.regular;
|
||||||
|
|
||||||
if (this->selected) {
|
if (this->selected) {
|
||||||
colors = this->themeManager.tabs.selected;
|
colors = this->themeManager->tabs.selected;
|
||||||
} else if (this->highlightState == HighlightState::Highlighted) {
|
} else if (this->highlightState == HighlightState::Highlighted) {
|
||||||
colors = this->themeManager.tabs.highlighted;
|
colors = this->themeManager->tabs.highlighted;
|
||||||
} else if (this->highlightState == HighlightState::NewMessage) {
|
} else if (this->highlightState == HighlightState::NewMessage) {
|
||||||
colors = this->themeManager.tabs.newMessage;
|
colors = this->themeManager->tabs.newMessage;
|
||||||
} else {
|
} else {
|
||||||
colors = this->themeManager.tabs.regular;
|
colors = this->themeManager->tabs.regular;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool windowFocused = this->window() == QApplication::activeWindow();
|
bool windowFocused = this->window() == QApplication::activeWindow();
|
||||||
|
@ -619,7 +629,7 @@ void NotebookTab::paintEvent(QPaintEvent *)
|
||||||
painter.setPen(colors.text);
|
painter.setPen(colors.text);
|
||||||
|
|
||||||
// set area for text
|
// set area for text
|
||||||
int rectW = (settingManager.hideTabX ? 0 : static_cast<int>(16) * scale);
|
int rectW = (app->settings->hideTabX ? 0 : static_cast<int>(16) * scale);
|
||||||
QRect rect(0, 0, this->width() - rectW, height);
|
QRect rect(0, 0, this->width() - rectW, height);
|
||||||
|
|
||||||
// draw text
|
// draw text
|
||||||
|
@ -640,7 +650,7 @@ void NotebookTab::paintEvent(QPaintEvent *)
|
||||||
}
|
}
|
||||||
|
|
||||||
// draw close x
|
// draw close x
|
||||||
if (!settingManager.hideTabX && (mouseOver || selected)) {
|
if (!app->settings->hideTabX && (mouseOver || selected)) {
|
||||||
QRect xRect = this->getXRect();
|
QRect xRect = this->getXRect();
|
||||||
if (mouseOverX) {
|
if (mouseOverX) {
|
||||||
painter.fillRect(xRect, QColor(0, 0, 0, 64));
|
painter.fillRect(xRect, QColor(0, 0, 0, 64));
|
||||||
|
@ -675,6 +685,8 @@ void NotebookTab::mousePressEvent(QMouseEvent *event)
|
||||||
|
|
||||||
void NotebookTab::mouseReleaseEvent(QMouseEvent *event)
|
void NotebookTab::mouseReleaseEvent(QMouseEvent *event)
|
||||||
{
|
{
|
||||||
|
auto app = getApp();
|
||||||
|
|
||||||
this->mouseDown = false;
|
this->mouseDown = false;
|
||||||
|
|
||||||
if (event->button() == Qt::MiddleButton) {
|
if (event->button() == Qt::MiddleButton) {
|
||||||
|
@ -682,7 +694,7 @@ void NotebookTab::mouseReleaseEvent(QMouseEvent *event)
|
||||||
this->notebook->removePage(this->page);
|
this->notebook->removePage(this->page);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!singletons::SettingManager::getInstance().hideTabX && this->mouseDownX &&
|
if (!app->settings->hideTabX && this->mouseDownX &&
|
||||||
this->getXRect().contains(event->pos())) {
|
this->getXRect().contains(event->pos())) {
|
||||||
this->mouseDownX = false;
|
this->mouseDownX = false;
|
||||||
|
|
||||||
|
@ -715,7 +727,9 @@ void NotebookTab::dragEnterEvent(QDragEnterEvent *)
|
||||||
|
|
||||||
void NotebookTab::mouseMoveEvent(QMouseEvent *event)
|
void NotebookTab::mouseMoveEvent(QMouseEvent *event)
|
||||||
{
|
{
|
||||||
if (!singletons::SettingManager::getInstance().hideTabX) {
|
auto app = getApp();
|
||||||
|
|
||||||
|
if (!app->settings->hideTabX) {
|
||||||
bool overX = this->getXRect().contains(event->pos());
|
bool overX = this->getXRect().contains(event->pos());
|
||||||
|
|
||||||
if (overX != this->mouseOverX) {
|
if (overX != this->mouseOverX) {
|
||||||
|
|
|
@ -64,7 +64,7 @@ void RippleEffectButton::fancyPaint(QPainter &painter)
|
||||||
if (this->mouseEffectColor) {
|
if (this->mouseEffectColor) {
|
||||||
c = this->mouseEffectColor.get();
|
c = this->mouseEffectColor.get();
|
||||||
} else {
|
} else {
|
||||||
c = this->themeManager.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) {
|
||||||
|
|
|
@ -218,8 +218,8 @@ void SplitHeader::paintEvent(QPaintEvent *)
|
||||||
{
|
{
|
||||||
QPainter painter(this);
|
QPainter painter(this);
|
||||||
|
|
||||||
painter.fillRect(rect(), this->themeManager.splits.header.background);
|
painter.fillRect(rect(), this->themeManager->splits.header.background);
|
||||||
painter.setPen(this->themeManager.splits.header.border);
|
painter.setPen(this->themeManager->splits.header.border);
|
||||||
painter.drawRect(0, 0, width() - 1, height() - 1);
|
painter.drawRect(0, 0, width() - 1, height() - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -268,7 +268,7 @@ void SplitHeader::rightButtonClicked()
|
||||||
void SplitHeader::themeRefreshEvent()
|
void SplitHeader::themeRefreshEvent()
|
||||||
{
|
{
|
||||||
QPalette palette;
|
QPalette palette;
|
||||||
palette.setColor(QPalette::Foreground, this->themeManager.splits.header.text);
|
palette.setColor(QPalette::Foreground, this->themeManager->splits.header.text);
|
||||||
|
|
||||||
// this->dropdownButton->setPalette(palette);
|
// this->dropdownButton->setPalette(palette);
|
||||||
this->titleLabel->setPalette(palette);
|
this->titleLabel->setPalette(palette);
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
#include "widgets/helper/splitinput.hpp"
|
#include "widgets/helper/splitinput.hpp"
|
||||||
|
|
||||||
|
#include "application.hpp"
|
||||||
#include "singletons/commandmanager.hpp"
|
#include "singletons/commandmanager.hpp"
|
||||||
#include "singletons/ircmanager.hpp"
|
#include "singletons/ircmanager.hpp"
|
||||||
#include "singletons/settingsmanager.hpp"
|
#include "singletons/settingsmanager.hpp"
|
||||||
|
@ -36,6 +38,7 @@ SplitInput::SplitInput(Split *_chatWidget)
|
||||||
|
|
||||||
void SplitInput::initLayout()
|
void SplitInput::initLayout()
|
||||||
{
|
{
|
||||||
|
auto app = getApp();
|
||||||
auto &fontManager = singletons::FontManager::getInstance();
|
auto &fontManager = singletons::FontManager::getInstance();
|
||||||
util::LayoutCreator<SplitInput> layoutCreator(this);
|
util::LayoutCreator<SplitInput> layoutCreator(this);
|
||||||
|
|
||||||
|
@ -73,7 +76,7 @@ void SplitInput::initLayout()
|
||||||
// open emote popup
|
// open emote popup
|
||||||
QObject::connect(this->ui.emoteButton, &RippleEffectLabel::clicked, [this] {
|
QObject::connect(this->ui.emoteButton, &RippleEffectLabel::clicked, [this] {
|
||||||
if (!this->emotePopup) {
|
if (!this->emotePopup) {
|
||||||
this->emotePopup = std::make_unique<EmotePopup>(this->themeManager);
|
this->emotePopup = std::make_unique<EmotePopup>();
|
||||||
this->emotePopup->linkClicked.connect([this](const messages::Link &link) {
|
this->emotePopup->linkClicked.connect([this](const messages::Link &link) {
|
||||||
if (link.type == messages::Link::InsertText) {
|
if (link.type == messages::Link::InsertText) {
|
||||||
this->insertText(link.value + " ");
|
this->insertText(link.value + " ");
|
||||||
|
@ -95,7 +98,7 @@ void SplitInput::initLayout()
|
||||||
});
|
});
|
||||||
|
|
||||||
// textEditLength visibility
|
// textEditLength visibility
|
||||||
singletons::SettingManager::getInstance().showMessageLength.connect(
|
app->settings->showMessageLength.connect(
|
||||||
[this](const bool &value, auto) { this->ui.textEditLength->setHidden(!value); },
|
[this](const bool &value, auto) { this->ui.textEditLength->setHidden(!value); },
|
||||||
this->managedConnections);
|
this->managedConnections);
|
||||||
}
|
}
|
||||||
|
@ -117,18 +120,20 @@ void SplitInput::themeRefreshEvent()
|
||||||
{
|
{
|
||||||
QPalette palette;
|
QPalette palette;
|
||||||
|
|
||||||
palette.setColor(QPalette::Foreground, this->themeManager.splits.input.text);
|
palette.setColor(QPalette::Foreground, this->themeManager->splits.input.text);
|
||||||
|
|
||||||
this->ui.textEditLength->setPalette(palette);
|
this->ui.textEditLength->setPalette(palette);
|
||||||
|
|
||||||
this->ui.textEdit->setStyleSheet(this->themeManager.splits.input.styleSheet);
|
this->ui.textEdit->setStyleSheet(this->themeManager->splits.input.styleSheet);
|
||||||
|
|
||||||
this->ui.hbox->setMargin((this->themeManager.isLightTheme() ? 4 : 2) * this->getScale());
|
this->ui.hbox->setMargin((this->themeManager->isLightTheme() ? 4 : 2) * this->getScale());
|
||||||
}
|
}
|
||||||
|
|
||||||
void SplitInput::installKeyPressedEvent()
|
void SplitInput::installKeyPressedEvent()
|
||||||
{
|
{
|
||||||
this->ui.textEdit->keyPressed.connect([this](QKeyEvent *event) {
|
auto app = getApp();
|
||||||
|
|
||||||
|
this->ui.textEdit->keyPressed.connect([this, app](QKeyEvent *event) {
|
||||||
if (event->key() == Qt::Key_Enter || event->key() == Qt::Key_Return) {
|
if (event->key() == Qt::Key_Enter || event->key() == Qt::Key_Return) {
|
||||||
auto c = this->chatWidget->getChannel();
|
auto c = this->chatWidget->getChannel();
|
||||||
if (c == nullptr) {
|
if (c == nullptr) {
|
||||||
|
@ -136,8 +141,7 @@ void SplitInput::installKeyPressedEvent()
|
||||||
}
|
}
|
||||||
QString message = ui.textEdit->toPlainText();
|
QString message = ui.textEdit->toPlainText();
|
||||||
|
|
||||||
QString sendMessage =
|
QString sendMessage = app->commands->execCommand(message, c, false);
|
||||||
singletons::CommandManager::getInstance().execCommand(message, c, false);
|
|
||||||
sendMessage = sendMessage.replace('\n', ' ');
|
sendMessage = sendMessage.replace('\n', ' ');
|
||||||
|
|
||||||
c->sendMessage(sendMessage);
|
c->sendMessage(sendMessage);
|
||||||
|
@ -278,6 +282,8 @@ void SplitInput::insertText(const QString &text)
|
||||||
|
|
||||||
void SplitInput::editTextChanged()
|
void SplitInput::editTextChanged()
|
||||||
{
|
{
|
||||||
|
auto app = getApp();
|
||||||
|
|
||||||
// set textLengthLabel value
|
// set textLengthLabel value
|
||||||
QString text = this->ui.textEdit->toPlainText();
|
QString text = this->ui.textEdit->toPlainText();
|
||||||
|
|
||||||
|
@ -287,8 +293,7 @@ void SplitInput::editTextChanged()
|
||||||
static QRegularExpression spaceRegex("\\s\\s+");
|
static QRegularExpression spaceRegex("\\s\\s+");
|
||||||
text = text.replace(spaceRegex, " ");
|
text = text.replace(spaceRegex, " ");
|
||||||
|
|
||||||
text = singletons::CommandManager::getInstance().execCommand(
|
text = app->commands->execCommand(text, this->chatWidget->getChannel(), true);
|
||||||
text, this->chatWidget->getChannel(), true);
|
|
||||||
|
|
||||||
QString labelText;
|
QString labelText;
|
||||||
|
|
||||||
|
@ -305,10 +310,10 @@ void SplitInput::paintEvent(QPaintEvent *)
|
||||||
{
|
{
|
||||||
QPainter painter(this);
|
QPainter painter(this);
|
||||||
|
|
||||||
painter.fillRect(this->rect(), this->themeManager.splits.input.background);
|
painter.fillRect(this->rect(), this->themeManager->splits.input.background);
|
||||||
|
|
||||||
QPen pen(this->themeManager.splits.input.border);
|
QPen pen(this->themeManager->splits.input.border);
|
||||||
if (this->themeManager.isLightTheme()) {
|
if (this->themeManager->isLightTheme()) {
|
||||||
pen.setWidth((int)(6 * this->getScale()));
|
pen.setWidth((int)(6 * this->getScale()));
|
||||||
}
|
}
|
||||||
painter.setPen(pen);
|
painter.setPen(pen);
|
||||||
|
|
|
@ -25,8 +25,8 @@ void TitleBarButton::paintEvent(QPaintEvent *)
|
||||||
{
|
{
|
||||||
QPainter painter(this);
|
QPainter painter(this);
|
||||||
|
|
||||||
QColor color = this->themeManager.window.text;
|
QColor color = this->themeManager->window.text;
|
||||||
QColor background = this->themeManager.window.background;
|
QColor background = this->themeManager->window.background;
|
||||||
|
|
||||||
int xD = this->height() / 3;
|
int xD = this->height() / 3;
|
||||||
int centerX = this->width() / 2;
|
int centerX = this->width() / 2;
|
||||||
|
@ -49,7 +49,7 @@ void TitleBarButton::paintEvent(QPaintEvent *)
|
||||||
|
|
||||||
painter.drawRect(centerX - xD / 2 + xD2, xD, xD3, xD3);
|
painter.drawRect(centerX - xD / 2 + xD2, xD, xD3, xD3);
|
||||||
painter.fillRect(centerX - xD / 2, xD + xD2, xD3, xD3,
|
painter.fillRect(centerX - xD / 2, xD + xD2, xD3, xD3,
|
||||||
this->themeManager.window.background);
|
this->themeManager->window.background);
|
||||||
painter.drawRect(centerX - xD / 2, xD + xD2, xD3, xD3);
|
painter.drawRect(centerX - xD / 2, xD + xD2, xD3, xD3);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,7 @@ void LogInWithCredentials(const std::string &userID, const std::string &username
|
||||||
pajlada::Settings::Setting<std::string>::set("/accounts/uid" + userID + "/oauthToken",
|
pajlada::Settings::Setting<std::string>::set("/accounts/uid" + userID + "/oauthToken",
|
||||||
oauthToken);
|
oauthToken);
|
||||||
|
|
||||||
singletons::AccountManager::getInstance().Twitch.reloadUsers();
|
getApp()->accounts->Twitch.reloadUsers();
|
||||||
|
|
||||||
messageBox.exec();
|
messageBox.exec();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
#include "widgets/notebook.hpp"
|
#include "widgets/notebook.hpp"
|
||||||
|
|
||||||
|
#include "application.hpp"
|
||||||
#include "debug/log.hpp"
|
#include "debug/log.hpp"
|
||||||
#include "singletons/thememanager.hpp"
|
#include "singletons/thememanager.hpp"
|
||||||
#include "singletons/windowmanager.hpp"
|
#include "singletons/windowmanager.hpp"
|
||||||
|
@ -24,7 +26,7 @@ namespace chatterino {
|
||||||
namespace widgets {
|
namespace widgets {
|
||||||
|
|
||||||
Notebook2::Notebook2(QWidget *parent)
|
Notebook2::Notebook2(QWidget *parent)
|
||||||
: BaseWidget(singletons::ThemeManager::getInstance(), parent)
|
: BaseWidget(parent)
|
||||||
, addButton(this)
|
, addButton(this)
|
||||||
{
|
{
|
||||||
this->addButton.setHidden(true);
|
this->addButton.setHidden(true);
|
||||||
|
@ -258,7 +260,7 @@ void Notebook2::resizeEvent(QResizeEvent *)
|
||||||
|
|
||||||
void Notebook2::performLayout(bool animated)
|
void Notebook2::performLayout(bool animated)
|
||||||
{
|
{
|
||||||
singletons::SettingManager &settings = singletons::SettingManager::getInstance();
|
auto app = getApp();
|
||||||
|
|
||||||
int xStart = (int)(2 * this->getScale());
|
int xStart = (int)(2 * this->getScale());
|
||||||
|
|
||||||
|
@ -269,13 +271,13 @@ void Notebook2::performLayout(bool animated)
|
||||||
|
|
||||||
// bool customFrame = false;
|
// bool customFrame = false;
|
||||||
|
|
||||||
// if (!this->showButtons || settings.hidePreferencesButton || customFrame) {
|
// if (!this->showButtons || app->settings->hidePreferencesButton || customFrame) {
|
||||||
// this->settingsButton.hide();
|
// this->settingsButton.hide();
|
||||||
// } else {
|
// } else {
|
||||||
// this->settingsButton.show();
|
// this->settingsButton.show();
|
||||||
// x += settingsButton.width();
|
// x += settingsButton.width();
|
||||||
// }
|
// }
|
||||||
// if (!this->showButtons || settings.hideUserButton || customFrame) {
|
// if (!this->showButtons || app->settings->hideUserButton || customFrame) {
|
||||||
// this->userButton.hide();
|
// this->userButton.hide();
|
||||||
// } else {
|
// } else {
|
||||||
// this->userButton.move(x, 0);
|
// this->userButton.move(x, 0);
|
||||||
|
@ -284,7 +286,7 @@ void Notebook2::performLayout(bool animated)
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// if (customFrame || !this->showButtons ||
|
// if (customFrame || !this->showButtons ||
|
||||||
// (settings.hideUserButton && settings.hidePreferencesButton)) {
|
// (app->settings->hideUserButton && app->settings->hidePreferencesButton)) {
|
||||||
// x += (int)(scale * 2);
|
// x += (int)(scale * 2);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
@ -342,7 +344,7 @@ void Notebook2::paintEvent(QPaintEvent *event)
|
||||||
|
|
||||||
QPainter painter(this);
|
QPainter painter(this);
|
||||||
painter.fillRect(0, this->lineY, this->width(), (int)(1 * this->getScale()),
|
painter.fillRect(0, this->lineY, this->width(), (int)(1 * this->getScale()),
|
||||||
this->themeManager.tabs.bottomLine);
|
this->themeManager->tabs.bottomLine);
|
||||||
}
|
}
|
||||||
|
|
||||||
NotebookTab2 *Notebook2::getTabFromPage(QWidget *page)
|
NotebookTab2 *Notebook2::getTabFromPage(QWidget *page)
|
||||||
|
@ -366,6 +368,8 @@ Notebook::Notebook(Window *parent, bool _showButtons)
|
||||||
, showButtons(_showButtons)
|
, showButtons(_showButtons)
|
||||||
, closeConfirmDialog(this)
|
, closeConfirmDialog(this)
|
||||||
{
|
{
|
||||||
|
auto app = getApp();
|
||||||
|
|
||||||
this->connect(&this->settingsButton, SIGNAL(clicked()), this, SLOT(settingsButtonClicked()));
|
this->connect(&this->settingsButton, SIGNAL(clicked()), this, SLOT(settingsButtonClicked()));
|
||||||
this->connect(&this->userButton, SIGNAL(clicked()), this, SLOT(usersButtonClicked()));
|
this->connect(&this->userButton, SIGNAL(clicked()), this, SLOT(usersButtonClicked()));
|
||||||
this->connect(&this->addButton, SIGNAL(clicked()), this, SLOT(addPageButtonClicked()));
|
this->connect(&this->addButton, SIGNAL(clicked()), this, SLOT(addPageButtonClicked()));
|
||||||
|
@ -375,10 +379,8 @@ Notebook::Notebook(Window *parent, bool _showButtons)
|
||||||
this->userButton.move(24, 0);
|
this->userButton.move(24, 0);
|
||||||
this->userButton.icon = NotebookButton::IconUser;
|
this->userButton.icon = NotebookButton::IconUser;
|
||||||
|
|
||||||
auto &settingsManager = singletons::SettingManager::getInstance();
|
app->settings->hidePreferencesButton.connectSimple([this](auto) { this->performLayout(); });
|
||||||
|
app->settings->hideUserButton.connectSimple([this](auto) { this->performLayout(); });
|
||||||
settingsManager.hidePreferencesButton.connectSimple([this](auto) { this->performLayout(); });
|
|
||||||
settingsManager.hideUserButton.connectSimple([this](auto) { this->performLayout(); });
|
|
||||||
|
|
||||||
closeConfirmDialog.setText("Are you sure you want to close this tab?");
|
closeConfirmDialog.setText("Are you sure you want to close this tab?");
|
||||||
closeConfirmDialog.setIcon(QMessageBox::Icon::Question);
|
closeConfirmDialog.setIcon(QMessageBox::Icon::Question);
|
||||||
|
@ -568,19 +570,19 @@ void Notebook::previousTab()
|
||||||
|
|
||||||
void Notebook::performLayout(bool animated)
|
void Notebook::performLayout(bool animated)
|
||||||
{
|
{
|
||||||
singletons::SettingManager &settings = singletons::SettingManager::getInstance();
|
auto app = getApp();
|
||||||
|
|
||||||
int x = 0, y = 0;
|
int x = 0, y = 0;
|
||||||
float scale = this->getScale();
|
float scale = this->getScale();
|
||||||
bool customFrame = this->parentWindow->hasCustomWindowFrame();
|
bool customFrame = this->parentWindow->hasCustomWindowFrame();
|
||||||
|
|
||||||
if (!this->showButtons || settings.hidePreferencesButton || customFrame) {
|
if (!this->showButtons || app->settings->hidePreferencesButton || customFrame) {
|
||||||
this->settingsButton.hide();
|
this->settingsButton.hide();
|
||||||
} else {
|
} else {
|
||||||
this->settingsButton.show();
|
this->settingsButton.show();
|
||||||
x += settingsButton.width();
|
x += settingsButton.width();
|
||||||
}
|
}
|
||||||
if (!this->showButtons || settings.hideUserButton || customFrame) {
|
if (!this->showButtons || app->settings->hideUserButton || customFrame) {
|
||||||
this->userButton.hide();
|
this->userButton.hide();
|
||||||
} else {
|
} else {
|
||||||
this->userButton.move(x, 0);
|
this->userButton.move(x, 0);
|
||||||
|
@ -589,7 +591,7 @@ void Notebook::performLayout(bool animated)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (customFrame || !this->showButtons ||
|
if (customFrame || !this->showButtons ||
|
||||||
(settings.hideUserButton && settings.hidePreferencesButton)) {
|
(app->settings->hideUserButton && app->settings->hidePreferencesButton)) {
|
||||||
x += (int)(scale * 2);
|
x += (int)(scale * 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -654,12 +656,14 @@ void Notebook::scaleChangedEvent(float)
|
||||||
|
|
||||||
void Notebook::settingsButtonClicked()
|
void Notebook::settingsButtonClicked()
|
||||||
{
|
{
|
||||||
singletons::WindowManager::getInstance().showSettingsDialog();
|
auto app = getApp();
|
||||||
|
app->windows->showSettingsDialog();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Notebook::usersButtonClicked()
|
void Notebook::usersButtonClicked()
|
||||||
{
|
{
|
||||||
singletons::WindowManager::getInstance().showAccountSelectPopup(
|
auto app = getApp();
|
||||||
|
app->windows->showAccountSelectPopup(
|
||||||
this->mapToGlobal(this->userButton.rect().bottomRight()));
|
this->mapToGlobal(this->userButton.rect().bottomRight()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
#include "widgets/scrollbar.hpp"
|
#include "widgets/scrollbar.hpp"
|
||||||
|
|
||||||
|
#include "application.hpp"
|
||||||
#include "singletons/thememanager.hpp"
|
#include "singletons/thememanager.hpp"
|
||||||
#include "widgets/helper/channelview.hpp"
|
#include "widgets/helper/channelview.hpp"
|
||||||
|
|
||||||
|
@ -6,6 +8,7 @@
|
||||||
#include <QMouseEvent>
|
#include <QMouseEvent>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
#define MIN_THUMB_HEIGHT 10
|
#define MIN_THUMB_HEIGHT 10
|
||||||
|
@ -16,7 +19,6 @@ namespace widgets {
|
||||||
Scrollbar::Scrollbar(ChannelView *parent)
|
Scrollbar::Scrollbar(ChannelView *parent)
|
||||||
: BaseWidget(parent)
|
: BaseWidget(parent)
|
||||||
, currentValueAnimation(this, "currentValue")
|
, currentValueAnimation(this, "currentValue")
|
||||||
, smoothScrollingSetting(singletons::SettingManager::getInstance().enableSmoothScrolling)
|
|
||||||
{
|
{
|
||||||
resize((int)(16 * this->getScale()), 100);
|
resize((int)(16 * this->getScale()), 100);
|
||||||
this->currentValueAnimation.setDuration(150);
|
this->currentValueAnimation.setDuration(150);
|
||||||
|
@ -92,7 +94,8 @@ void Scrollbar::setSmallChange(qreal value)
|
||||||
|
|
||||||
void Scrollbar::setDesiredValue(qreal value, bool animated)
|
void Scrollbar::setDesiredValue(qreal value, bool animated)
|
||||||
{
|
{
|
||||||
animated &= this->smoothScrollingSetting.getValue();
|
auto app = getApp();
|
||||||
|
animated &= app->settings->enableSmoothScrolling.getValue();
|
||||||
value = std::max(this->minimum, std::min(this->maximum - this->largeChange, value));
|
value = std::max(this->minimum, std::min(this->maximum - this->largeChange, value));
|
||||||
|
|
||||||
if (this->desiredValue + this->smoothScrollingOffset != value) {
|
if (this->desiredValue + this->smoothScrollingOffset != value) {
|
||||||
|
@ -197,23 +200,23 @@ void Scrollbar::paintEvent(QPaintEvent *)
|
||||||
int xOffset = mouseOver ? 0 : width() - (int)(4 * this->getScale());
|
int xOffset = mouseOver ? 0 : width() - (int)(4 * this->getScale());
|
||||||
|
|
||||||
QPainter painter(this);
|
QPainter painter(this);
|
||||||
// painter.fillRect(rect(), this->themeManager.ScrollbarBG);
|
// painter.fillRect(rect(), this->themeManager->ScrollbarBG);
|
||||||
|
|
||||||
// painter.fillRect(QRect(xOffset, 0, width(), this->buttonHeight),
|
// painter.fillRect(QRect(xOffset, 0, width(), this->buttonHeight),
|
||||||
// this->themeManager.ScrollbarArrow);
|
// this->themeManager->ScrollbarArrow);
|
||||||
// painter.fillRect(QRect(xOffset, height() - this->buttonHeight, width(),
|
// painter.fillRect(QRect(xOffset, height() - this->buttonHeight, width(),
|
||||||
// this->buttonHeight),
|
// this->buttonHeight),
|
||||||
// this->themeManager.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->themeManager.scrollbars.thumbSelected);
|
painter.fillRect(this->thumbRect, this->themeManager->scrollbars.thumbSelected);
|
||||||
}
|
}
|
||||||
// mouse not over thumb
|
// mouse not over thumb
|
||||||
else {
|
else {
|
||||||
painter.fillRect(this->thumbRect, this->themeManager.scrollbars.thumb);
|
painter.fillRect(this->thumbRect, this->themeManager->scrollbars.thumb);
|
||||||
}
|
}
|
||||||
|
|
||||||
// draw highlights
|
// draw highlights
|
||||||
|
@ -235,10 +238,10 @@ void Scrollbar::paintEvent(QPaintEvent *)
|
||||||
if (!highlight.isNull()) {
|
if (!highlight.isNull()) {
|
||||||
if (highlight.getStyle() == ScrollbarHighlight::Default) {
|
if (highlight.getStyle() == ScrollbarHighlight::Default) {
|
||||||
painter.fillRect(w / 8 * 3, (int)y, w / 4, highlightHeight,
|
painter.fillRect(w / 8 * 3, (int)y, w / 4, highlightHeight,
|
||||||
this->themeManager.tabs.selected.backgrounds.regular.color());
|
this->themeManager->tabs.selected.backgrounds.regular.color());
|
||||||
} else {
|
} else {
|
||||||
painter.fillRect(0, (int)y, w, 1,
|
painter.fillRect(0, (int)y, w, 1,
|
||||||
this->themeManager.tabs.selected.backgrounds.regular.color());
|
this->themeManager->tabs.selected.backgrounds.regular.color());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -88,8 +88,6 @@ private:
|
||||||
|
|
||||||
pajlada::Signals::NoArgSignal currentValueChanged;
|
pajlada::Signals::NoArgSignal currentValueChanged;
|
||||||
|
|
||||||
pajlada::Settings::Setting<bool> &smoothScrollingSetting;
|
|
||||||
|
|
||||||
void updateScroll();
|
void updateScroll();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -266,7 +266,7 @@ void SelectChannelDialog::themeRefreshEvent()
|
||||||
{
|
{
|
||||||
BaseWindow::themeRefreshEvent();
|
BaseWindow::themeRefreshEvent();
|
||||||
|
|
||||||
if (this->themeManager.isLightTheme()) {
|
if (this->themeManager->isLightTheme()) {
|
||||||
this->setStyleSheet("QRadioButton { color: #000 } QLabel { color: #000 }");
|
this->setStyleSheet("QRadioButton { color: #000 } QLabel { color: #000 }");
|
||||||
} else {
|
} else {
|
||||||
this->setStyleSheet("QRadioButton { color: #fff } QLabel { color: #fff }");
|
this->setStyleSheet("QRadioButton { color: #fff } QLabel { color: #fff }");
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
#include "widgets/settingsdialog.hpp"
|
#include "widgets/settingsdialog.hpp"
|
||||||
|
|
||||||
|
#include "application.hpp"
|
||||||
#include "util/layoutcreator.hpp"
|
#include "util/layoutcreator.hpp"
|
||||||
#include "widgets/helper/settingsdialogtab.hpp"
|
#include "widgets/helper/settingsdialogtab.hpp"
|
||||||
#include "widgets/settingspages/aboutpage.hpp"
|
#include "widgets/settingspages/aboutpage.hpp"
|
||||||
|
@ -150,7 +152,7 @@ void SettingsDialog::refresh()
|
||||||
{
|
{
|
||||||
// this->ui.accountSwitchWidget->refresh();
|
// this->ui.accountSwitchWidget->refresh();
|
||||||
|
|
||||||
singletons::SettingManager::getInstance().saveSnapshot();
|
getApp()->settings->saveSnapshot();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SettingsDialog::scaleChangedEvent(float newDpi)
|
void SettingsDialog::scaleChangedEvent(float newDpi)
|
||||||
|
@ -209,13 +211,11 @@ void SettingsDialog::okButtonClicked()
|
||||||
|
|
||||||
void SettingsDialog::cancelButtonClicked()
|
void SettingsDialog::cancelButtonClicked()
|
||||||
{
|
{
|
||||||
auto &settings = singletons::SettingManager::getInstance();
|
|
||||||
|
|
||||||
for (auto &tab : this->tabs) {
|
for (auto &tab : this->tabs) {
|
||||||
tab->getSettingsPage()->cancel();
|
tab->getSettingsPage()->cancel();
|
||||||
}
|
}
|
||||||
|
|
||||||
settings.recallSnapshot();
|
getApp()->settings->recallSnapshot();
|
||||||
|
|
||||||
this->close();
|
this->close();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,14 @@
|
||||||
#include "accountspage.hpp"
|
#include "accountspage.hpp"
|
||||||
|
|
||||||
#include <QDialogButtonBox>
|
#include "application.hpp"
|
||||||
#include <QVBoxLayout>
|
|
||||||
|
|
||||||
#include "const.hpp"
|
#include "const.hpp"
|
||||||
#include "singletons/accountmanager.hpp"
|
#include "singletons/accountmanager.hpp"
|
||||||
#include "util/layoutcreator.hpp"
|
#include "util/layoutcreator.hpp"
|
||||||
#include "widgets/logindialog.hpp"
|
#include "widgets/logindialog.hpp"
|
||||||
|
|
||||||
|
#include <QDialogButtonBox>
|
||||||
|
#include <QVBoxLayout>
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
namespace widgets {
|
namespace widgets {
|
||||||
namespace settingspages {
|
namespace settingspages {
|
||||||
|
@ -39,7 +40,7 @@ AccountsPage::AccountsPage()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
singletons::AccountManager::getInstance().Twitch.removeUser(selectedUser);
|
getApp()->accounts->Twitch.removeUser(selectedUser);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,9 @@
|
||||||
#include "appearancepage.hpp"
|
#include "appearancepage.hpp"
|
||||||
|
|
||||||
|
#include "application.hpp"
|
||||||
|
#include "util/layoutcreator.hpp"
|
||||||
|
#include "util/removescrollareabackground.hpp"
|
||||||
|
|
||||||
#include <QFontDialog>
|
#include <QFontDialog>
|
||||||
#include <QFormLayout>
|
#include <QFormLayout>
|
||||||
#include <QGroupBox>
|
#include <QGroupBox>
|
||||||
|
@ -9,9 +13,6 @@
|
||||||
#include <QSlider>
|
#include <QSlider>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
|
|
||||||
#include "util/layoutcreator.hpp"
|
|
||||||
#include "util/removescrollareabackground.hpp"
|
|
||||||
|
|
||||||
#define THEME_ITEMS "White", "Light", "Dark", "Black"
|
#define THEME_ITEMS "White", "Light", "Dark", "Black"
|
||||||
|
|
||||||
#define TAB_X "Show close button"
|
#define TAB_X "Show close button"
|
||||||
|
@ -34,7 +35,7 @@ namespace settingspages {
|
||||||
AppearancePage::AppearancePage()
|
AppearancePage::AppearancePage()
|
||||||
: SettingsPage("Look", ":/images/theme.svg")
|
: SettingsPage("Look", ":/images/theme.svg")
|
||||||
{
|
{
|
||||||
singletons::SettingManager &settings = singletons::SettingManager::getInstance();
|
auto app = getApp();
|
||||||
util::LayoutCreator<AppearancePage> layoutCreator(this);
|
util::LayoutCreator<AppearancePage> layoutCreator(this);
|
||||||
|
|
||||||
auto scroll = layoutCreator.emplace<QScrollArea>();
|
auto scroll = layoutCreator.emplace<QScrollArea>();
|
||||||
|
@ -49,50 +50,52 @@ AppearancePage::AppearancePage()
|
||||||
auto form = application.emplace<QFormLayout>();
|
auto form = application.emplace<QFormLayout>();
|
||||||
|
|
||||||
// clang-format off
|
// clang-format off
|
||||||
form->addRow("Theme:", this->createComboBox({THEME_ITEMS}, singletons::ThemeManager::getInstance().themeName));
|
form->addRow("Theme:", this->createComboBox({THEME_ITEMS}, app->themes->themeName));
|
||||||
form->addRow("Theme color:", this->createThemeColorChanger());
|
form->addRow("Theme color:", this->createThemeColorChanger());
|
||||||
form->addRow("Font:", this->createFontChanger());
|
form->addRow("Font:", this->createFontChanger());
|
||||||
|
|
||||||
form->addRow("Tabs:", this->createCheckBox(TAB_X, settings.hideTabX));
|
form->addRow("Tabs:", this->createCheckBox(TAB_X, app->settings->hideTabX));
|
||||||
#ifndef USEWINSDK
|
#ifndef USEWINSDK
|
||||||
form->addRow("", this->createCheckBox(TAB_PREF, settings.hidePreferencesButton));
|
form->addRow("", this->createCheckBox(TAB_PREF, app->settings->hidePreferencesButton));
|
||||||
form->addRow("", this->createCheckBox(TAB_USER, settings.hideUserButton));
|
form->addRow("", this->createCheckBox(TAB_USER, app->settings->hideUserButton));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
form->addRow("Scrolling:", this->createCheckBox(SCROLL_SMOOTH, settings.enableSmoothScrolling));
|
form->addRow("Scrolling:", this->createCheckBox(SCROLL_SMOOTH, app->settings->enableSmoothScrolling));
|
||||||
form->addRow("", this->createCheckBox(SCROLL_NEWMSG, settings.enableSmoothScrollingNewMessages));
|
form->addRow("", this->createCheckBox(SCROLL_NEWMSG, app->settings->enableSmoothScrollingNewMessages));
|
||||||
// clang-format on
|
// clang-format on
|
||||||
}
|
}
|
||||||
|
|
||||||
auto messages = layout.emplace<QGroupBox>("Messages").emplace<QVBoxLayout>();
|
auto messages = layout.emplace<QGroupBox>("Messages").emplace<QVBoxLayout>();
|
||||||
{
|
{
|
||||||
messages.append(this->createCheckBox("Show timestamp", settings.showTimestamps));
|
messages.append(this->createCheckBox("Show timestamp", app->settings->showTimestamps));
|
||||||
auto tbox = messages.emplace<QHBoxLayout>().withoutMargin();
|
auto tbox = messages.emplace<QHBoxLayout>().withoutMargin();
|
||||||
{
|
{
|
||||||
tbox.emplace<QLabel>("timestamp format (a = am/pm):");
|
tbox.emplace<QLabel>("timestamp format (a = am/pm):");
|
||||||
tbox.append(this->createComboBox({TIMESTAMP_FORMATS}, settings.timestampFormat));
|
tbox.append(this->createComboBox({TIMESTAMP_FORMATS}, app->settings->timestampFormat));
|
||||||
tbox->addStretch(1);
|
tbox->addStretch(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
messages.append(this->createCheckBox("Show badges", settings.showBadges));
|
messages.append(this->createCheckBox("Show badges", app->settings->showBadges));
|
||||||
auto checkbox = this->createCheckBox("Seperate messages", settings.seperateMessages);
|
auto checkbox = this->createCheckBox("Seperate messages", app->settings->seperateMessages);
|
||||||
checkbox->setEnabled(false);
|
checkbox->setEnabled(false);
|
||||||
messages.append(checkbox);
|
messages.append(checkbox);
|
||||||
messages.append(
|
messages.append(this->createCheckBox("Show message length while typing",
|
||||||
this->createCheckBox("Show message length while typing", settings.showMessageLength));
|
app->settings->showMessageLength));
|
||||||
|
|
||||||
messages.append(this->createCheckBox(LAST_MSG, settings.showLastMessageIndicator));
|
messages.append(this->createCheckBox(LAST_MSG, app->settings->showLastMessageIndicator));
|
||||||
}
|
}
|
||||||
|
|
||||||
auto emotes = layout.emplace<QGroupBox>("Emotes").setLayoutType<QVBoxLayout>();
|
auto emotes = layout.emplace<QGroupBox>("Emotes").setLayoutType<QVBoxLayout>();
|
||||||
{
|
{
|
||||||
emotes.append(this->createCheckBox("Enable Twitch emotes", settings.enableTwitchEmotes));
|
|
||||||
emotes.append(
|
emotes.append(
|
||||||
this->createCheckBox("Enable BetterTTV emotes for Twitch", settings.enableBttvEmotes));
|
this->createCheckBox("Enable Twitch emotes", app->settings->enableTwitchEmotes));
|
||||||
|
emotes.append(this->createCheckBox("Enable BetterTTV emotes for Twitch",
|
||||||
|
app->settings->enableBttvEmotes));
|
||||||
emotes.append(this->createCheckBox("Enable FrankerFaceZ emotes for Twitch",
|
emotes.append(this->createCheckBox("Enable FrankerFaceZ emotes for Twitch",
|
||||||
settings.enableFfzEmotes));
|
app->settings->enableFfzEmotes));
|
||||||
emotes.append(this->createCheckBox("Enable emojis", settings.enableEmojis));
|
emotes.append(this->createCheckBox("Enable emojis", app->settings->enableEmojis));
|
||||||
emotes.append(this->createCheckBox("Enable animations", settings.enableGifAnimations));
|
emotes.append(
|
||||||
|
this->createCheckBox("Enable animations", app->settings->enableGifAnimations));
|
||||||
}
|
}
|
||||||
|
|
||||||
layout->addStretch(1);
|
layout->addStretch(1);
|
||||||
|
@ -100,9 +103,10 @@ AppearancePage::AppearancePage()
|
||||||
|
|
||||||
QLayout *AppearancePage::createThemeColorChanger()
|
QLayout *AppearancePage::createThemeColorChanger()
|
||||||
{
|
{
|
||||||
|
auto app = getApp();
|
||||||
QHBoxLayout *layout = new QHBoxLayout;
|
QHBoxLayout *layout = new QHBoxLayout;
|
||||||
|
|
||||||
auto &themeHue = singletons::ThemeManager::getInstance().themeHue;
|
auto &themeHue = app->themes->themeHue;
|
||||||
|
|
||||||
// SLIDER
|
// SLIDER
|
||||||
QSlider *slider = new QSlider(Qt::Horizontal);
|
QSlider *slider = new QSlider(Qt::Horizontal);
|
||||||
|
@ -115,9 +119,9 @@ QLayout *AppearancePage::createThemeColorChanger()
|
||||||
button->setFlat(true);
|
button->setFlat(true);
|
||||||
button->setFixedWidth(64);
|
button->setFixedWidth(64);
|
||||||
|
|
||||||
auto setButtonColor = [button](int value) mutable {
|
auto setButtonColor = [button, app](int value) mutable {
|
||||||
double newValue = value / 100.0;
|
double newValue = value / 100.0;
|
||||||
singletons::ThemeManager::getInstance().themeHue.setValue(newValue);
|
app->themes->themeHue.setValue(newValue);
|
||||||
|
|
||||||
QPalette pal = button->palette();
|
QPalette pal = button->palette();
|
||||||
QColor color;
|
QColor color;
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
#include "behaviourpage.hpp"
|
#include "behaviourpage.hpp"
|
||||||
|
|
||||||
|
#include "application.hpp"
|
||||||
|
#include "util/layoutcreator.hpp"
|
||||||
|
|
||||||
#include <QFormLayout>
|
#include <QFormLayout>
|
||||||
#include <QGroupBox>
|
#include <QGroupBox>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
|
|
||||||
#include <util/layoutcreator.hpp>
|
|
||||||
|
|
||||||
#define WINDOW_TOPMOST "Window always on top (requires restart)"
|
#define WINDOW_TOPMOST "Window always on top (requires restart)"
|
||||||
#define INPUT_EMPTY "Hide input box when empty"
|
#define INPUT_EMPTY "Hide input box when empty"
|
||||||
#define PAUSE_HOVERING "When hovering"
|
#define PAUSE_HOVERING "When hovering"
|
||||||
|
@ -20,20 +21,21 @@ namespace settingspages {
|
||||||
BehaviourPage::BehaviourPage()
|
BehaviourPage::BehaviourPage()
|
||||||
: SettingsPage("Feel", ":/images/behave.svg")
|
: SettingsPage("Feel", ":/images/behave.svg")
|
||||||
{
|
{
|
||||||
singletons::SettingManager &settings = singletons::SettingManager::getInstance();
|
auto app = getApp();
|
||||||
util::LayoutCreator<BehaviourPage> layoutCreator(this);
|
util::LayoutCreator<BehaviourPage> layoutCreator(this);
|
||||||
|
|
||||||
auto layout = layoutCreator.setLayoutType<QVBoxLayout>();
|
auto layout = layoutCreator.setLayoutType<QVBoxLayout>();
|
||||||
|
|
||||||
auto form = layout.emplace<QFormLayout>().withoutMargin();
|
auto form = layout.emplace<QFormLayout>().withoutMargin();
|
||||||
{
|
{
|
||||||
form->addRow("Window:", this->createCheckBox(WINDOW_TOPMOST, settings.windowTopMost));
|
form->addRow("Window:", this->createCheckBox(WINDOW_TOPMOST, app->settings->windowTopMost));
|
||||||
form->addRow("Messages:", this->createCheckBox(INPUT_EMPTY, settings.hideEmptyInput));
|
form->addRow("Messages:", this->createCheckBox(INPUT_EMPTY, app->settings->hideEmptyInput));
|
||||||
form->addRow("Pause chat:", this->createCheckBox(PAUSE_HOVERING, settings.pauseChatHover));
|
form->addRow("Pause chat:",
|
||||||
|
this->createCheckBox(PAUSE_HOVERING, app->settings->pauseChatHover));
|
||||||
|
|
||||||
form->addRow("Mouse scroll speed:", this->createMouseScrollSlider());
|
form->addRow("Mouse scroll speed:", this->createMouseScrollSlider());
|
||||||
form->addRow("Links:", this->createCheckBox("Open links only on double click",
|
form->addRow("Links:", this->createCheckBox("Open links only on double click",
|
||||||
settings.linksDoubleClickOnly));
|
app->settings->linksDoubleClickOnly));
|
||||||
}
|
}
|
||||||
|
|
||||||
layout->addSpacing(16);
|
layout->addSpacing(16);
|
||||||
|
@ -43,17 +45,18 @@ BehaviourPage::BehaviourPage()
|
||||||
auto groupLayout = group.setLayoutType<QFormLayout>();
|
auto groupLayout = group.setLayoutType<QFormLayout>();
|
||||||
groupLayout->addRow(
|
groupLayout->addRow(
|
||||||
LIMIT_CHATTERS_FOR_SMALLER_STREAMERS,
|
LIMIT_CHATTERS_FOR_SMALLER_STREAMERS,
|
||||||
this->createCheckBox("", settings.onlyFetchChattersForSmallerStreamers));
|
this->createCheckBox("", app->settings->onlyFetchChattersForSmallerStreamers));
|
||||||
|
|
||||||
groupLayout->addRow("What viewer count counts as a \"smaller streamer\"",
|
groupLayout->addRow("What viewer count counts as a \"smaller streamer\"",
|
||||||
this->createSpinBox(settings.smallStreamerLimit, 10, 50000));
|
this->createSpinBox(app->settings->smallStreamerLimit, 10, 50000));
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
auto group = layout.emplace<QGroupBox>("Misc");
|
auto group = layout.emplace<QGroupBox>("Misc");
|
||||||
auto groupLayout = group.setLayoutType<QVBoxLayout>();
|
auto groupLayout = group.setLayoutType<QVBoxLayout>();
|
||||||
|
|
||||||
groupLayout.append(this->createCheckBox("Show whispers inline", settings.inlineWhispers));
|
groupLayout.append(
|
||||||
|
this->createCheckBox("Show whispers inline", app->settings->inlineWhispers));
|
||||||
}
|
}
|
||||||
|
|
||||||
layout->addStretch(1);
|
layout->addStretch(1);
|
||||||
|
@ -61,16 +64,17 @@ BehaviourPage::BehaviourPage()
|
||||||
|
|
||||||
QSlider *BehaviourPage::createMouseScrollSlider()
|
QSlider *BehaviourPage::createMouseScrollSlider()
|
||||||
{
|
{
|
||||||
|
auto app = getApp();
|
||||||
auto slider = new QSlider(Qt::Horizontal);
|
auto slider = new QSlider(Qt::Horizontal);
|
||||||
|
|
||||||
float currentValue = singletons::SettingManager::getInstance().mouseScrollMultiplier;
|
float currentValue = app->settings->mouseScrollMultiplier;
|
||||||
int sliderValue = ((currentValue - 0.1f) / 2.f) * 99.f;
|
int sliderValue = ((currentValue - 0.1f) / 2.f) * 99.f;
|
||||||
slider->setValue(sliderValue);
|
slider->setValue(sliderValue);
|
||||||
|
|
||||||
QObject::connect(slider, &QSlider::valueChanged, [](int newValue) {
|
QObject::connect(slider, &QSlider::valueChanged, [=](int newValue) {
|
||||||
float mul = static_cast<float>(newValue) / 99.f;
|
float mul = static_cast<float>(newValue) / 99.f;
|
||||||
float newSliderValue = (mul * 2.1f) + 0.1f;
|
float newSliderValue = (mul * 2.1f) + 0.1f;
|
||||||
singletons::SettingManager::getInstance().mouseScrollMultiplier = newSliderValue;
|
app->settings->mouseScrollMultiplier = newSliderValue;
|
||||||
});
|
});
|
||||||
|
|
||||||
return slider;
|
return slider;
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
#include "commandpage.hpp"
|
#include "commandpage.hpp"
|
||||||
|
|
||||||
|
#include "application.hpp"
|
||||||
|
#include "singletons/commandmanager.hpp"
|
||||||
|
#include "util/layoutcreator.hpp"
|
||||||
|
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QTextEdit>
|
#include <QTextEdit>
|
||||||
|
|
||||||
#include "singletons/commandmanager.hpp"
|
|
||||||
#include "util/layoutcreator.hpp"
|
|
||||||
|
|
||||||
// clang-format off
|
// clang-format off
|
||||||
#define TEXT "One command per line.\n"\
|
#define TEXT "One command per line.\n"\
|
||||||
"\"/cmd example command\" will print \"example command\" when you type /cmd in chat.\n"\
|
"\"/cmd example command\" will print \"example command\" when you type /cmd in chat.\n"\
|
||||||
|
@ -34,27 +35,27 @@ CommandPage::CommandPage()
|
||||||
|
|
||||||
QTextEdit *CommandPage::getCommandsTextEdit()
|
QTextEdit *CommandPage::getCommandsTextEdit()
|
||||||
{
|
{
|
||||||
singletons::CommandManager &commandManager = singletons::CommandManager::getInstance();
|
auto app = getApp();
|
||||||
|
|
||||||
// cancel
|
// cancel
|
||||||
QStringList currentCommands = commandManager.getCommands();
|
QStringList currentCommands = app->commands->getCommands();
|
||||||
|
|
||||||
this->onCancel.connect(
|
this->onCancel.connect(
|
||||||
[currentCommands, &commandManager] { commandManager.setCommands(currentCommands); });
|
[currentCommands, app] { app->commands->setCommands(currentCommands); });
|
||||||
|
|
||||||
// create text edit
|
// create text edit
|
||||||
QTextEdit *textEdit = new QTextEdit;
|
QTextEdit *textEdit = new QTextEdit;
|
||||||
|
|
||||||
textEdit->setPlainText(QString(commandManager.getCommands().join('\n')));
|
textEdit->setPlainText(QString(app->commands->getCommands().join('\n')));
|
||||||
|
|
||||||
QObject::connect(textEdit, &QTextEdit::textChanged,
|
QObject::connect(textEdit, &QTextEdit::textChanged,
|
||||||
[this] { this->commandsEditTimer.start(200); });
|
[this] { this->commandsEditTimer.start(200); });
|
||||||
|
|
||||||
QObject::connect(&this->commandsEditTimer, &QTimer::timeout, [textEdit, &commandManager] {
|
QObject::connect(&this->commandsEditTimer, &QTimer::timeout, [textEdit, app] {
|
||||||
QString text = textEdit->toPlainText();
|
QString text = textEdit->toPlainText();
|
||||||
QStringList lines = text.split(QRegularExpression("(\r?\n|\r\n?)"));
|
QStringList lines = text.split(QRegularExpression("(\r?\n|\r\n?)"));
|
||||||
|
|
||||||
commandManager.setCommands(lines);
|
app->commands->setCommands(lines);
|
||||||
});
|
});
|
||||||
|
|
||||||
return textEdit;
|
return textEdit;
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include "externaltoolspage.hpp"
|
#include "externaltoolspage.hpp"
|
||||||
|
|
||||||
|
#include "application.hpp"
|
||||||
#include "util/layoutcreator.hpp"
|
#include "util/layoutcreator.hpp"
|
||||||
|
|
||||||
#include <QGroupBox>
|
#include <QGroupBox>
|
||||||
|
@ -13,17 +14,21 @@ namespace settingspages {
|
||||||
ExternalToolsPage::ExternalToolsPage()
|
ExternalToolsPage::ExternalToolsPage()
|
||||||
: SettingsPage("External tools", "")
|
: SettingsPage("External tools", "")
|
||||||
{
|
{
|
||||||
singletons::SettingManager &settings = singletons::SettingManager::getInstance();
|
auto app = getApp();
|
||||||
|
|
||||||
util::LayoutCreator<ExternalToolsPage> layoutCreator(this);
|
util::LayoutCreator<ExternalToolsPage> layoutCreator(this);
|
||||||
auto layout = layoutCreator.setLayoutType<QVBoxLayout>();
|
auto layout = layoutCreator.setLayoutType<QVBoxLayout>();
|
||||||
|
|
||||||
{
|
{
|
||||||
auto group = layout.emplace<QGroupBox>("Streamlink");
|
auto group = layout.emplace<QGroupBox>("Streamlink");
|
||||||
auto groupLayout = group.setLayoutType<QFormLayout>();
|
auto groupLayout = group.setLayoutType<QFormLayout>();
|
||||||
groupLayout->addRow("Streamlink path:", this->createLineEdit(settings.streamlinkPath));
|
groupLayout->addRow("Streamlink path:",
|
||||||
groupLayout->addRow("Prefered quality:",
|
this->createLineEdit(app->settings->streamlinkPath));
|
||||||
this->createComboBox({STREAMLINK_QUALITY}, settings.preferredQuality));
|
groupLayout->addRow(
|
||||||
groupLayout->addRow("Additional options:", this->createLineEdit(settings.streamlinkOpts));
|
"Prefered quality:",
|
||||||
|
this->createComboBox({STREAMLINK_QUALITY}, app->settings->preferredQuality));
|
||||||
|
groupLayout->addRow("Additional options:",
|
||||||
|
this->createLineEdit(app->settings->streamlinkOpts));
|
||||||
}
|
}
|
||||||
|
|
||||||
layout->addStretch(1);
|
layout->addStretch(1);
|
||||||
|
|
|
@ -1,5 +1,11 @@
|
||||||
#include "highlightingpage.hpp"
|
#include "highlightingpage.hpp"
|
||||||
|
|
||||||
|
#include "application.hpp"
|
||||||
|
#include "debug/log.hpp"
|
||||||
|
#include "singletons/settingsmanager.hpp"
|
||||||
|
#include "util/layoutcreator.hpp"
|
||||||
|
#include "util/standarditemhelper.hpp"
|
||||||
|
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QListWidget>
|
#include <QListWidget>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
|
@ -8,11 +14,6 @@
|
||||||
#include <QTableView>
|
#include <QTableView>
|
||||||
#include <QTextEdit>
|
#include <QTextEdit>
|
||||||
|
|
||||||
#include "debug/log.hpp"
|
|
||||||
#include "singletons/settingsmanager.hpp"
|
|
||||||
#include "util/layoutcreator.hpp"
|
|
||||||
#include "util/standarditemhelper.hpp"
|
|
||||||
|
|
||||||
#define ENABLE_HIGHLIGHTS "Enable Highlighting"
|
#define ENABLE_HIGHLIGHTS "Enable Highlighting"
|
||||||
#define HIGHLIGHT_MSG "Highlight messages containing your name"
|
#define HIGHLIGHT_MSG "Highlight messages containing your name"
|
||||||
#define PLAY_SOUND "Play sound when your name is mentioned"
|
#define PLAY_SOUND "Play sound when your name is mentioned"
|
||||||
|
@ -26,13 +27,13 @@ namespace settingspages {
|
||||||
HighlightingPage::HighlightingPage()
|
HighlightingPage::HighlightingPage()
|
||||||
: SettingsPage("Highlights", ":/images/notifications.svg")
|
: SettingsPage("Highlights", ":/images/notifications.svg")
|
||||||
{
|
{
|
||||||
singletons::SettingManager &settings = singletons::SettingManager::getInstance();
|
auto app = getApp();
|
||||||
util::LayoutCreator<HighlightingPage> layoutCreator(this);
|
util::LayoutCreator<HighlightingPage> layoutCreator(this);
|
||||||
|
|
||||||
auto layout = layoutCreator.emplace<QVBoxLayout>().withoutMargin();
|
auto layout = layoutCreator.emplace<QVBoxLayout>().withoutMargin();
|
||||||
{
|
{
|
||||||
// GENERAL
|
// GENERAL
|
||||||
layout.append(this->createCheckBox(ENABLE_HIGHLIGHTS, settings.enableHighlights));
|
layout.append(this->createCheckBox(ENABLE_HIGHLIGHTS, app->settings->enableHighlights));
|
||||||
|
|
||||||
// TABS
|
// TABS
|
||||||
auto tabs = layout.emplace<QTabWidget>();
|
auto tabs = layout.emplace<QTabWidget>();
|
||||||
|
@ -56,17 +57,17 @@ HighlightingPage::HighlightingPage()
|
||||||
yourName->setData(QBrush("#666"), Qt::ForegroundRole);
|
yourName->setData(QBrush("#666"), Qt::ForegroundRole);
|
||||||
yourName->setFlags(yourName->flags() | Qt::ItemIsUserCheckable |
|
yourName->setFlags(yourName->flags() | Qt::ItemIsUserCheckable |
|
||||||
Qt::ItemIsUserCheckable);
|
Qt::ItemIsUserCheckable);
|
||||||
yourName->setData(settings.enableHighlightsSelf ? 2 : 0, Qt::CheckStateRole);
|
yourName->setData(app->settings->enableHighlightsSelf ? 2 : 0, Qt::CheckStateRole);
|
||||||
model->appendRow(
|
model->appendRow(
|
||||||
{yourName,
|
{yourName,
|
||||||
util::boolItem(settings.enableHighlightTaskbar.getValue(), true, false),
|
util::boolItem(app->settings->enableHighlightTaskbar.getValue(), true, false),
|
||||||
util::boolItem(settings.enableHighlightSound.getValue(), true, false),
|
util::boolItem(app->settings->enableHighlightSound.getValue(), true, false),
|
||||||
util::emptyItem()});
|
util::emptyItem()});
|
||||||
|
|
||||||
// highlight phrases
|
// highlight phrases
|
||||||
// fourtf: could crash
|
// fourtf: could crash
|
||||||
for (const messages::HighlightPhrase &phrase :
|
for (const messages::HighlightPhrase &phrase :
|
||||||
settings.highlightProperties.getValue()) {
|
app->settings->highlightProperties.getValue()) {
|
||||||
model->appendRow({util::stringItem(phrase.key), util::boolItem(phrase.alert),
|
model->appendRow({util::stringItem(phrase.key), util::boolItem(phrase.alert),
|
||||||
util::boolItem(phrase.sound), util::boolItem(phrase.regex)});
|
util::boolItem(phrase.sound), util::boolItem(phrase.regex)});
|
||||||
}
|
}
|
||||||
|
@ -79,8 +80,9 @@ HighlightingPage::HighlightingPage()
|
||||||
|
|
||||||
auto buttons = highlights.emplace<QHBoxLayout>();
|
auto buttons = highlights.emplace<QHBoxLayout>();
|
||||||
|
|
||||||
QObject::connect(model, &QStandardItemModel::dataChanged,
|
QObject::connect(
|
||||||
[model](const QModelIndex &topLeft, const QModelIndex &bottomRight,
|
model, &QStandardItemModel::dataChanged,
|
||||||
|
[model, app](const QModelIndex &topLeft, const QModelIndex &bottomRight,
|
||||||
const QVector<int> &roles) {
|
const QVector<int> &roles) {
|
||||||
std::vector<messages::HighlightPhrase> phrases;
|
std::vector<messages::HighlightPhrase> phrases;
|
||||||
for (int i = 1; i < model->rowCount(); i++) {
|
for (int i = 1; i < model->rowCount(); i++) {
|
||||||
|
@ -90,13 +92,12 @@ HighlightingPage::HighlightingPage()
|
||||||
model->item(i, 2)->data(Qt::CheckStateRole).toBool(),
|
model->item(i, 2)->data(Qt::CheckStateRole).toBool(),
|
||||||
model->item(i, 3)->data(Qt::CheckStateRole).toBool()});
|
model->item(i, 3)->data(Qt::CheckStateRole).toBool()});
|
||||||
}
|
}
|
||||||
auto &settings = singletons::SettingManager::getInstance();
|
app->settings->highlightProperties.setValue(phrases);
|
||||||
settings.highlightProperties.setValue(phrases);
|
app->settings->enableHighlightsSelf.setValue(
|
||||||
settings.enableHighlightsSelf.setValue(
|
|
||||||
model->item(0, 0)->data(Qt::CheckStateRole).toBool());
|
model->item(0, 0)->data(Qt::CheckStateRole).toBool());
|
||||||
settings.enableHighlightTaskbar.setValue(
|
app->settings->enableHighlightTaskbar.setValue(
|
||||||
model->item(0, 1)->data(Qt::CheckStateRole).toBool());
|
model->item(0, 1)->data(Qt::CheckStateRole).toBool());
|
||||||
settings.enableHighlightSound.setValue(
|
app->settings->enableHighlightSound.setValue(
|
||||||
model->item(0, 2)->data(Qt::CheckStateRole).toBool());
|
model->item(0, 2)->data(Qt::CheckStateRole).toBool());
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -138,13 +139,13 @@ HighlightingPage::HighlightingPage()
|
||||||
[this] { this->disabledUsersChangedTimer.start(200); });
|
[this] { this->disabledUsersChangedTimer.start(200); });
|
||||||
|
|
||||||
QObject::connect(
|
QObject::connect(
|
||||||
&this->disabledUsersChangedTimer, &QTimer::timeout, this, [text, &settings]() {
|
&this->disabledUsersChangedTimer, &QTimer::timeout, this, [text, app]() {
|
||||||
QStringList list = text->toPlainText().split("\n", QString::SkipEmptyParts);
|
QStringList list = text->toPlainText().split("\n", QString::SkipEmptyParts);
|
||||||
list.removeDuplicates();
|
list.removeDuplicates();
|
||||||
settings.highlightUserBlacklist = list.join("\n") + "\n";
|
app->settings->highlightUserBlacklist = list.join("\n") + "\n";
|
||||||
});
|
});
|
||||||
|
|
||||||
settings.highlightUserBlacklist.connect([=](const QString &str, auto) {
|
app->settings->highlightUserBlacklist.connect([=](const QString &str, auto) {
|
||||||
text->setPlainText(str); //
|
text->setPlainText(str); //
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -153,17 +154,17 @@ HighlightingPage::HighlightingPage()
|
||||||
// MISC
|
// MISC
|
||||||
auto customSound = layout.emplace<QHBoxLayout>().withoutMargin();
|
auto customSound = layout.emplace<QHBoxLayout>().withoutMargin();
|
||||||
{
|
{
|
||||||
customSound.append(this->createCheckBox("Custom sound", settings.customHighlightSound));
|
customSound.append(
|
||||||
|
this->createCheckBox("Custom sound", app->settings->customHighlightSound));
|
||||||
auto selectFile = customSound.emplace<QPushButton>("Select custom sound file");
|
auto selectFile = customSound.emplace<QPushButton>("Select custom sound file");
|
||||||
QObject::connect(selectFile.getElement(), &QPushButton::clicked, this,
|
QObject::connect(selectFile.getElement(), &QPushButton::clicked, this, [this, app] {
|
||||||
[&settings, this] {
|
auto fileName = QFileDialog::getOpenFileName(this, tr("Open Sound"), "",
|
||||||
auto fileName = QFileDialog::getOpenFileName(
|
tr("Audio Files (*.mp3 *.wav)"));
|
||||||
this, tr("Open Sound"), "", tr("Audio Files (*.mp3 *.wav)"));
|
app->settings->pathHighlightSound = fileName;
|
||||||
settings.pathHighlightSound = fileName;
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
layout.append(createCheckBox(ALWAYS_PLAY, settings.highlightAlwaysPlaySound));
|
layout.append(createCheckBox(ALWAYS_PLAY, app->settings->highlightAlwaysPlaySound));
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---- misc
|
// ---- misc
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include "ignoremessagespage.hpp"
|
#include "ignoremessagespage.hpp"
|
||||||
|
|
||||||
|
#include "application.hpp"
|
||||||
#include "util/layoutcreator.hpp"
|
#include "util/layoutcreator.hpp"
|
||||||
|
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
|
@ -12,22 +13,22 @@ namespace settingspages {
|
||||||
IgnoreMessagesPage::IgnoreMessagesPage()
|
IgnoreMessagesPage::IgnoreMessagesPage()
|
||||||
: SettingsPage("Ignore Messages", "")
|
: SettingsPage("Ignore Messages", "")
|
||||||
{
|
{
|
||||||
singletons::SettingManager &settings = singletons::SettingManager::getInstance();
|
auto app = getApp();
|
||||||
util::LayoutCreator<IgnoreMessagesPage> layoutCreator(this);
|
util::LayoutCreator<IgnoreMessagesPage> layoutCreator(this);
|
||||||
auto layout = layoutCreator.setLayoutType<QVBoxLayout>();
|
auto layout = layoutCreator.setLayoutType<QVBoxLayout>();
|
||||||
|
|
||||||
layout.emplace<QLabel>("Ignored keywords:");
|
layout.emplace<QLabel>("Ignored keywords:");
|
||||||
QTextEdit *textEdit = layout.emplace<QTextEdit>().getElement();
|
QTextEdit *textEdit = layout.emplace<QTextEdit>().getElement();
|
||||||
|
|
||||||
textEdit->setPlainText(settings.ignoredKeywords);
|
textEdit->setPlainText(app->settings->ignoredKeywords);
|
||||||
|
|
||||||
QObject::connect(textEdit, &QTextEdit::textChanged,
|
QObject::connect(textEdit, &QTextEdit::textChanged,
|
||||||
[this] { this->keywordsUpdated.start(200); });
|
[this] { this->keywordsUpdated.start(200); });
|
||||||
|
|
||||||
QObject::connect(&this->keywordsUpdated, &QTimer::timeout, [textEdit, &settings] {
|
QObject::connect(&this->keywordsUpdated, &QTimer::timeout, [textEdit, app] {
|
||||||
QString text = textEdit->toPlainText();
|
QString text = textEdit->toPlainText();
|
||||||
|
|
||||||
settings.ignoredKeywords = text;
|
app->settings->ignoredKeywords = text;
|
||||||
});
|
});
|
||||||
|
|
||||||
// ---- misc
|
// ---- misc
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include "ignoreuserspage.hpp"
|
#include "ignoreuserspage.hpp"
|
||||||
|
|
||||||
|
#include "application.hpp"
|
||||||
#include "singletons/settingsmanager.hpp"
|
#include "singletons/settingsmanager.hpp"
|
||||||
#include "util/layoutcreator.hpp"
|
#include "util/layoutcreator.hpp"
|
||||||
|
|
||||||
|
@ -21,14 +22,15 @@ namespace settingspages {
|
||||||
IgnoreUsersPage::IgnoreUsersPage()
|
IgnoreUsersPage::IgnoreUsersPage()
|
||||||
: SettingsPage("Ignores", "")
|
: SettingsPage("Ignores", "")
|
||||||
{
|
{
|
||||||
singletons::SettingManager &settings = singletons::SettingManager::getInstance();
|
auto app = getApp();
|
||||||
|
|
||||||
util::LayoutCreator<IgnoreUsersPage> layoutCreator(this);
|
util::LayoutCreator<IgnoreUsersPage> layoutCreator(this);
|
||||||
auto layout = layoutCreator.setLayoutType<QVBoxLayout>();
|
auto layout = layoutCreator.setLayoutType<QVBoxLayout>();
|
||||||
|
|
||||||
auto group = layout.emplace<QGroupBox>("Ignored users").setLayoutType<QVBoxLayout>();
|
auto group = layout.emplace<QGroupBox>("Ignored users").setLayoutType<QVBoxLayout>();
|
||||||
{
|
{
|
||||||
group.append(
|
group.append(this->createCheckBox("Enable twitch ignored users",
|
||||||
this->createCheckBox("Enable twitch ignored users", settings.enableTwitchIgnoredUsers));
|
app->settings->enableTwitchIgnoredUsers));
|
||||||
|
|
||||||
auto anyways = group.emplace<QHBoxLayout>().withoutMargin();
|
auto anyways = group.emplace<QHBoxLayout>().withoutMargin();
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
#include "logspage.hpp"
|
#include "logspage.hpp"
|
||||||
|
|
||||||
|
#include "application.hpp"
|
||||||
#include "singletons/pathmanager.hpp"
|
#include "singletons/pathmanager.hpp"
|
||||||
|
|
||||||
#include <QFormLayout>
|
#include <QFormLayout>
|
||||||
|
@ -23,12 +25,12 @@ inline QString CreateLink(const QString &url, bool file = false)
|
||||||
LogsPage::LogsPage()
|
LogsPage::LogsPage()
|
||||||
: SettingsPage("Logs", "")
|
: SettingsPage("Logs", "")
|
||||||
{
|
{
|
||||||
singletons::SettingManager &settings = singletons::SettingManager::getInstance();
|
auto app = getApp();
|
||||||
|
|
||||||
util::LayoutCreator<LogsPage> layoutCreator(this);
|
util::LayoutCreator<LogsPage> layoutCreator(this);
|
||||||
auto layout = layoutCreator.emplace<QVBoxLayout>().withoutMargin();
|
auto layout = layoutCreator.emplace<QVBoxLayout>().withoutMargin();
|
||||||
|
|
||||||
singletons::PathManager &pathManager = singletons::PathManager::getInstance();
|
auto logPath = app->paths->logsFolderPath;
|
||||||
auto logPath = pathManager.logsFolderPath;
|
|
||||||
|
|
||||||
auto created = layout.emplace<QLabel>();
|
auto created = layout.emplace<QLabel>();
|
||||||
created->setText("Logs are saved to " + CreateLink(logPath, true));
|
created->setText("Logs are saved to " + CreateLink(logPath, true));
|
||||||
|
@ -36,7 +38,7 @@ LogsPage::LogsPage()
|
||||||
created->setTextInteractionFlags(Qt::TextBrowserInteraction | Qt::LinksAccessibleByKeyboard |
|
created->setTextInteractionFlags(Qt::TextBrowserInteraction | Qt::LinksAccessibleByKeyboard |
|
||||||
Qt::LinksAccessibleByKeyboard);
|
Qt::LinksAccessibleByKeyboard);
|
||||||
created->setOpenExternalLinks(true);
|
created->setOpenExternalLinks(true);
|
||||||
layout.append(this->createCheckBox("Enable logging", settings.enableLogging));
|
layout.append(this->createCheckBox("Enable logging", app->settings->enableLogging));
|
||||||
|
|
||||||
layout->addStretch(1);
|
layout->addStretch(1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,9 @@
|
||||||
#include "moderationpage.hpp"
|
#include "moderationpage.hpp"
|
||||||
|
|
||||||
|
#include "application.hpp"
|
||||||
|
#include "singletons/pathmanager.hpp"
|
||||||
|
#include "util/layoutcreator.hpp"
|
||||||
|
|
||||||
#include <QGroupBox>
|
#include <QGroupBox>
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
|
@ -8,9 +12,6 @@
|
||||||
#include <QTextEdit>
|
#include <QTextEdit>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
|
|
||||||
#include "singletons/pathmanager.hpp"
|
|
||||||
#include "util/layoutcreator.hpp"
|
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
namespace widgets {
|
namespace widgets {
|
||||||
namespace settingspages {
|
namespace settingspages {
|
||||||
|
@ -28,14 +29,13 @@ inline QString CreateLink(const QString &url, bool file = false)
|
||||||
ModerationPage::ModerationPage()
|
ModerationPage::ModerationPage()
|
||||||
: SettingsPage("Moderation", "")
|
: SettingsPage("Moderation", "")
|
||||||
{
|
{
|
||||||
singletons::SettingManager &settings = singletons::SettingManager::getInstance();
|
auto app = getApp();
|
||||||
singletons::PathManager &pathManager = singletons::PathManager::getInstance();
|
|
||||||
util::LayoutCreator<ModerationPage> layoutCreator(this);
|
util::LayoutCreator<ModerationPage> layoutCreator(this);
|
||||||
|
|
||||||
auto layout = layoutCreator.setLayoutType<QVBoxLayout>();
|
auto layout = layoutCreator.setLayoutType<QVBoxLayout>();
|
||||||
{
|
{
|
||||||
// Logs (copied from LoggingMananger)
|
// Logs (copied from LoggingMananger)
|
||||||
auto logPath = pathManager.logsFolderPath;
|
auto logPath = app->paths->logsFolderPath;
|
||||||
|
|
||||||
auto created = layout.emplace<QLabel>();
|
auto created = layout.emplace<QLabel>();
|
||||||
created->setText("Logs are saved to " + CreateLink(logPath, true));
|
created->setText("Logs are saved to " + CreateLink(logPath, true));
|
||||||
|
@ -44,7 +44,7 @@ ModerationPage::ModerationPage()
|
||||||
Qt::LinksAccessibleByKeyboard |
|
Qt::LinksAccessibleByKeyboard |
|
||||||
Qt::LinksAccessibleByKeyboard);
|
Qt::LinksAccessibleByKeyboard);
|
||||||
created->setOpenExternalLinks(true);
|
created->setOpenExternalLinks(true);
|
||||||
layout.append(this->createCheckBox("Enable logging", settings.enableLogging));
|
layout.append(this->createCheckBox("Enable logging", app->settings->enableLogging));
|
||||||
|
|
||||||
layout->addStretch(1);
|
layout->addStretch(1);
|
||||||
// Logs end
|
// Logs end
|
||||||
|
@ -58,7 +58,7 @@ ModerationPage::ModerationPage()
|
||||||
auto form = layout.emplace<QFormLayout>();
|
auto form = layout.emplace<QFormLayout>();
|
||||||
{
|
{
|
||||||
form->addRow("Action on timed out messages (unimplemented):",
|
form->addRow("Action on timed out messages (unimplemented):",
|
||||||
this->createComboBox({"Disable", "Hide"}, settings.timeoutAction));
|
this->createComboBox({"Disable", "Hide"}, app->settings->timeoutAction));
|
||||||
}
|
}
|
||||||
|
|
||||||
auto modButtons =
|
auto modButtons =
|
||||||
|
@ -71,13 +71,13 @@ ModerationPage::ModerationPage()
|
||||||
|
|
||||||
auto text = modButtons.emplace<QTextEdit>().getElement();
|
auto text = modButtons.emplace<QTextEdit>().getElement();
|
||||||
|
|
||||||
text->setPlainText(settings.moderationActions);
|
text->setPlainText(app->settings->moderationActions);
|
||||||
|
|
||||||
QObject::connect(text, &QTextEdit::textChanged, this,
|
QObject::connect(text, &QTextEdit::textChanged, this,
|
||||||
[this] { this->itemsChangedTimer.start(200); });
|
[this] { this->itemsChangedTimer.start(200); });
|
||||||
|
|
||||||
QObject::connect(&this->itemsChangedTimer, &QTimer::timeout, this, [text, &settings]() {
|
QObject::connect(&this->itemsChangedTimer, &QTimer::timeout, this, [text, app]() {
|
||||||
settings.moderationActions = text->toPlainText();
|
app->settings->moderationActions = text->toPlainText();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include "specialchannelspage.hpp"
|
#include "specialchannelspage.hpp"
|
||||||
|
|
||||||
|
#include "application.hpp"
|
||||||
#include "singletons/settingsmanager.hpp"
|
#include "singletons/settingsmanager.hpp"
|
||||||
#include "util/layoutcreator.hpp"
|
#include "util/layoutcreator.hpp"
|
||||||
|
|
||||||
|
@ -14,7 +15,8 @@ namespace settingspages {
|
||||||
SpecialChannelsPage::SpecialChannelsPage()
|
SpecialChannelsPage::SpecialChannelsPage()
|
||||||
: SettingsPage("Special channels", "")
|
: SettingsPage("Special channels", "")
|
||||||
{
|
{
|
||||||
singletons::SettingManager &settings = singletons::SettingManager::getInstance();
|
auto app = getApp();
|
||||||
|
|
||||||
util::LayoutCreator<SpecialChannelsPage> layoutCreator(this);
|
util::LayoutCreator<SpecialChannelsPage> layoutCreator(this);
|
||||||
auto layout = layoutCreator.setLayoutType<QVBoxLayout>();
|
auto layout = layoutCreator.setLayoutType<QVBoxLayout>();
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
#include "widgets/split.hpp"
|
#include "widgets/split.hpp"
|
||||||
|
|
||||||
|
#include "application.hpp"
|
||||||
#include "providers/twitch/emotevalue.hpp"
|
#include "providers/twitch/emotevalue.hpp"
|
||||||
#include "providers/twitch/twitchchannel.hpp"
|
#include "providers/twitch/twitchchannel.hpp"
|
||||||
#include "providers/twitch/twitchmessagebuilder.hpp"
|
#include "providers/twitch/twitchmessagebuilder.hpp"
|
||||||
|
@ -36,19 +38,8 @@ using namespace chatterino::messages;
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
namespace widgets {
|
namespace widgets {
|
||||||
|
|
||||||
Split::Split(SplitContainer *parent)
|
Split::Split(QWidget *parent)
|
||||||
: Split((BaseWidget *)parent)
|
: BaseWidget(parent)
|
||||||
{
|
|
||||||
this->container = parent;
|
|
||||||
}
|
|
||||||
|
|
||||||
Split::Split(BaseWidget *widget)
|
|
||||||
: Split(widget->themeManager, widget)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
Split::Split(singletons::ThemeManager &manager, QWidget *parent)
|
|
||||||
: BaseWidget(manager, parent)
|
|
||||||
, container(nullptr)
|
, container(nullptr)
|
||||||
, channel(Channel::getEmpty())
|
, channel(Channel::getEmpty())
|
||||||
, vbox(this)
|
, vbox(this)
|
||||||
|
@ -56,6 +47,8 @@ Split::Split(singletons::ThemeManager &manager, QWidget *parent)
|
||||||
, view(this)
|
, view(this)
|
||||||
, input(this)
|
, input(this)
|
||||||
{
|
{
|
||||||
|
auto app = getApp();
|
||||||
|
|
||||||
this->setMouseTracking(true);
|
this->setMouseTracking(true);
|
||||||
|
|
||||||
this->vbox.setSpacing(0);
|
this->vbox.setSpacing(0);
|
||||||
|
@ -97,8 +90,8 @@ Split::Split(singletons::ThemeManager &manager, QWidget *parent)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
this->input.textChanged.connect([this](const QString &newText) {
|
this->input.textChanged.connect([=](const QString &newText) {
|
||||||
if (!singletons::SettingManager::getInstance().hideEmptyInput) {
|
if (!app->settings->hideEmptyInput) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -109,14 +102,15 @@ Split::Split(singletons::ThemeManager &manager, QWidget *parent)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
singletons::SettingManager::getInstance().hideEmptyInput.connect(
|
app->settings->hideEmptyInput.connect(
|
||||||
[this](const bool &hideEmptyInput, auto) {
|
[this](const bool &hideEmptyInput, auto) {
|
||||||
if (hideEmptyInput && this->input.getInputText().length() == 0) {
|
if (hideEmptyInput && this->input.getInputText().length() == 0) {
|
||||||
this->input.hide();
|
this->input.hide();
|
||||||
} else {
|
} else {
|
||||||
this->input.show();
|
this->input.show();
|
||||||
}
|
}
|
||||||
});
|
},
|
||||||
|
this->managedConnections);
|
||||||
|
|
||||||
this->header.updateModerationModeIcon();
|
this->header.updateModerationModeIcon();
|
||||||
|
|
||||||
|
@ -260,7 +254,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->themeManager.splits.background);
|
painter.fillRect(this->rect(), this->themeManager->splits.background);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Split::mouseMoveEvent(QMouseEvent *event)
|
void Split::mouseMoveEvent(QMouseEvent *event)
|
||||||
|
@ -328,7 +322,8 @@ void Split::doChangeChannel()
|
||||||
|
|
||||||
void Split::doPopup()
|
void Split::doPopup()
|
||||||
{
|
{
|
||||||
Window &window = singletons::WindowManager::getInstance().createWindow(Window::Popup);
|
auto app = getApp();
|
||||||
|
Window &window = app->windows->createWindow(Window::Popup);
|
||||||
|
|
||||||
Split *split =
|
Split *split =
|
||||||
new Split(static_cast<SplitContainer *>(window.getNotebook().getOrAddSelectedPage()));
|
new Split(static_cast<SplitContainer *>(window.getNotebook().getOrAddSelectedPage()));
|
||||||
|
@ -397,7 +392,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->themeManager.splits.header.background);
|
label->setBackgroundColor(this->themeManager->splits.header.background);
|
||||||
labelList.append(label);
|
labelList.append(label);
|
||||||
}
|
}
|
||||||
auto loadingLabel = new QLabel("Loading...");
|
auto loadingLabel = new QLabel("Loading...");
|
||||||
|
@ -454,7 +449,7 @@ void Split::doOpenViewerList()
|
||||||
dockVbox->addWidget(resultList);
|
dockVbox->addWidget(resultList);
|
||||||
resultList->hide();
|
resultList->hide();
|
||||||
|
|
||||||
multiWidget->setStyleSheet(this->themeManager.splits.input.styleSheet);
|
multiWidget->setStyleSheet(this->themeManager->splits.input.styleSheet);
|
||||||
multiWidget->setLayout(dockVbox);
|
multiWidget->setLayout(dockVbox);
|
||||||
viewerDock->setWidget(multiWidget);
|
viewerDock->setWidget(multiWidget);
|
||||||
viewerDock->show();
|
viewerDock->show();
|
||||||
|
|
|
@ -43,9 +43,7 @@ class Split : public BaseWidget
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit Split(SplitContainer *parent);
|
explicit Split(QWidget *parent);
|
||||||
explicit Split(BaseWidget *widget);
|
|
||||||
explicit Split(singletons::ThemeManager &manager, QWidget *parent);
|
|
||||||
~Split() override;
|
~Split() override;
|
||||||
|
|
||||||
pajlada::Signals::NoArgSignal channelChanged;
|
pajlada::Signals::NoArgSignal channelChanged;
|
||||||
|
@ -103,6 +101,8 @@ private:
|
||||||
pajlada::Signals::Connection usermodeChangedConnection;
|
pajlada::Signals::Connection usermodeChangedConnection;
|
||||||
pajlada::Signals::Connection indirectChannelChangedConnection;
|
pajlada::Signals::Connection indirectChannelChangedConnection;
|
||||||
|
|
||||||
|
std::vector<pajlada::Signals::ScopedConnection> managedConnections;
|
||||||
|
|
||||||
void doOpenAccountPopupWidget(AccountPopupWidget *widget, QString user);
|
void doOpenAccountPopupWidget(AccountPopupWidget *widget, QString user);
|
||||||
void channelNameUpdated(const QString &newChannelName);
|
void channelNameUpdated(const QString &newChannelName);
|
||||||
void handleModifiers(QEvent *event, Qt::KeyboardModifiers modifiers);
|
void handleModifiers(QEvent *event, Qt::KeyboardModifiers modifiers);
|
||||||
|
|
|
@ -27,7 +27,7 @@ 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(Notebook *parent, NotebookTab *_tab)
|
SplitContainer::SplitContainer(Notebook *parent, NotebookTab *_tab)
|
||||||
: BaseWidget(parent->themeManager, parent)
|
: BaseWidget(parent)
|
||||||
, tab(_tab)
|
, tab(_tab)
|
||||||
, dropPreview(this)
|
, dropPreview(this)
|
||||||
{
|
{
|
||||||
|
@ -450,9 +450,9 @@ 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->themeManager.splits.background);
|
painter.fillRect(rect(), this->themeManager->splits.background);
|
||||||
|
|
||||||
painter.setPen(this->themeManager.splits.header.text);
|
painter.setPen(this->themeManager->splits.header.text);
|
||||||
|
|
||||||
QString text = "Click to add a <split>";
|
QString text = "Click to add a <split>";
|
||||||
|
|
||||||
|
@ -467,12 +467,12 @@ void SplitContainer::paintEvent(QPaintEvent *)
|
||||||
|
|
||||||
painter.drawText(rect(), text, QTextOption(Qt::AlignCenter));
|
painter.drawText(rect(), text, QTextOption(Qt::AlignCenter));
|
||||||
} else {
|
} else {
|
||||||
painter.fillRect(rect(), this->themeManager.splits.messageSeperator);
|
painter.fillRect(rect(), this->themeManager->splits.messageSeperator);
|
||||||
}
|
}
|
||||||
|
|
||||||
QBrush accentColor = (QApplication::activeWindow() == this->window()
|
QBrush accentColor = (QApplication::activeWindow() == this->window()
|
||||||
? this->themeManager.tabs.selected.backgrounds.regular
|
? this->themeManager->tabs.selected.backgrounds.regular
|
||||||
: this->themeManager.tabs.selected.backgrounds.unfocused);
|
: this->themeManager->tabs.selected.backgrounds.unfocused);
|
||||||
|
|
||||||
painter.fillRect(0, 0, width(), 1, accentColor);
|
painter.fillRect(0, 0, width(), 1, accentColor);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
#include "widgets/window.hpp"
|
#include "widgets/window.hpp"
|
||||||
|
|
||||||
|
#include "application.hpp"
|
||||||
#include "singletons/accountmanager.hpp"
|
#include "singletons/accountmanager.hpp"
|
||||||
#include "singletons/ircmanager.hpp"
|
#include "singletons/ircmanager.hpp"
|
||||||
#include "singletons/settingsmanager.hpp"
|
#include "singletons/settingsmanager.hpp"
|
||||||
|
@ -21,14 +23,15 @@
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
namespace widgets {
|
namespace widgets {
|
||||||
|
|
||||||
Window::Window(singletons::ThemeManager &_themeManager, WindowType _type)
|
Window::Window(WindowType _type)
|
||||||
: BaseWindow(_themeManager, nullptr, true)
|
: BaseWindow(nullptr, true)
|
||||||
, type(_type)
|
, type(_type)
|
||||||
, dpi(this->getScale())
|
, dpi(this->getScale())
|
||||||
, notebook(this, !this->hasCustomWindowFrame())
|
, notebook(this, !this->hasCustomWindowFrame())
|
||||||
{
|
{
|
||||||
singletons::AccountManager::getInstance().Twitch.currentUsername.connect(
|
auto app = getApp();
|
||||||
[this](const std::string &newUsername, auto) {
|
|
||||||
|
app->accounts->Twitch.currentUsername.connect([this](const std::string &newUsername, auto) {
|
||||||
if (newUsername.empty()) {
|
if (newUsername.empty()) {
|
||||||
this->refreshWindowTitle("Not logged in");
|
this->refreshWindowTitle("Not logged in");
|
||||||
} else {
|
} else {
|
||||||
|
@ -37,17 +40,15 @@ Window::Window(singletons::ThemeManager &_themeManager, WindowType _type)
|
||||||
});
|
});
|
||||||
|
|
||||||
if (this->hasCustomWindowFrame() && _type == Window::Main) {
|
if (this->hasCustomWindowFrame() && _type == Window::Main) {
|
||||||
this->addTitleBarButton(TitleBarButton::Settings, [] {
|
this->addTitleBarButton(TitleBarButton::Settings, [app] {
|
||||||
singletons::WindowManager::getInstance().showSettingsDialog();
|
app->windows->showSettingsDialog(); //
|
||||||
});
|
});
|
||||||
auto user = this->addTitleBarLabel([] {
|
auto user = this->addTitleBarLabel([app] {
|
||||||
singletons::WindowManager::getInstance().showAccountSelectPopup(QCursor::pos());
|
app->windows->showAccountSelectPopup(QCursor::pos()); //
|
||||||
});
|
});
|
||||||
|
|
||||||
singletons::AccountManager::getInstance().Twitch.userChanged.connect([user] {
|
app->accounts->Twitch.userChanged.connect(
|
||||||
user->getLabel().setText(
|
[=] { user->getLabel().setText(app->accounts->Twitch.getCurrent()->getUserName()); });
|
||||||
singletons::AccountManager::getInstance().Twitch.getCurrent()->getUserName());
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_type == Window::Main) {
|
if (_type == Window::Main) {
|
||||||
|
@ -161,8 +162,9 @@ bool Window::event(QEvent *e)
|
||||||
void Window::closeEvent(QCloseEvent *event)
|
void Window::closeEvent(QCloseEvent *event)
|
||||||
{
|
{
|
||||||
if (this->type == Window::Main) {
|
if (this->type == Window::Main) {
|
||||||
singletons::WindowManager::getInstance().save();
|
auto app = getApp();
|
||||||
singletons::WindowManager::getInstance().closeAll();
|
app->windows->save();
|
||||||
|
app->windows->closeAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
this->closed.invoke();
|
this->closed.invoke();
|
||||||
|
|
|
@ -25,7 +25,7 @@ class Window : public BaseWindow
|
||||||
public:
|
public:
|
||||||
enum WindowType { Main, Popup, Attached };
|
enum WindowType { Main, Popup, Attached };
|
||||||
|
|
||||||
explicit Window(singletons::ThemeManager &_themeManager, WindowType type);
|
explicit Window(WindowType type);
|
||||||
|
|
||||||
void repaintVisibleChatWidgets(Channel *channel = nullptr);
|
void repaintVisibleChatWidgets(Channel *channel = nullptr);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue