mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
chore: remove Singleton & replace getIApp with getApp (#5514)
This commit is contained in:
parent
21186df058
commit
5deec1f02f
145 changed files with 802 additions and 856 deletions
|
@ -5,7 +5,7 @@
|
||||||
#include "controllers/highlights/HighlightPhrase.hpp"
|
#include "controllers/highlights/HighlightPhrase.hpp"
|
||||||
#include "messages/Message.hpp"
|
#include "messages/Message.hpp"
|
||||||
#include "messages/SharedMessageBuilder.hpp"
|
#include "messages/SharedMessageBuilder.hpp"
|
||||||
#include "mocks/EmptyApplication.hpp"
|
#include "mocks/BaseApplication.hpp"
|
||||||
#include "singletons/Settings.hpp"
|
#include "singletons/Settings.hpp"
|
||||||
#include "util/Helpers.hpp"
|
#include "util/Helpers.hpp"
|
||||||
|
|
||||||
|
@ -47,9 +47,14 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class MockApplication : mock::EmptyApplication
|
class MockApplication : public mock::BaseApplication
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
MockApplication()
|
||||||
|
: highlights(this->settings, &this->accounts)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
AccountController *getAccounts() override
|
AccountController *getAccounts() override
|
||||||
{
|
{
|
||||||
return &this->accounts;
|
return &this->accounts;
|
||||||
|
@ -61,7 +66,6 @@ public:
|
||||||
|
|
||||||
AccountController accounts;
|
AccountController accounts;
|
||||||
HighlightController highlights;
|
HighlightController highlights;
|
||||||
// TODO: Figure this out
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static void BM_HighlightTest(benchmark::State &state)
|
static void BM_HighlightTest(benchmark::State &state)
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
#include "controllers/accounts/AccountController.hpp"
|
#include "controllers/accounts/AccountController.hpp"
|
||||||
#include "controllers/highlights/HighlightController.hpp"
|
#include "controllers/highlights/HighlightController.hpp"
|
||||||
#include "messages/Emote.hpp"
|
#include "messages/Emote.hpp"
|
||||||
|
#include "mocks/BaseApplication.hpp"
|
||||||
#include "mocks/DisabledStreamerMode.hpp"
|
#include "mocks/DisabledStreamerMode.hpp"
|
||||||
#include "mocks/EmptyApplication.hpp"
|
|
||||||
#include "mocks/LinkResolver.hpp"
|
#include "mocks/LinkResolver.hpp"
|
||||||
#include "mocks/TwitchIrcServer.hpp"
|
#include "mocks/TwitchIrcServer.hpp"
|
||||||
#include "mocks/UserData.hpp"
|
#include "mocks/UserData.hpp"
|
||||||
|
@ -32,9 +32,14 @@ using namespace literals;
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
class MockApplication : mock::EmptyApplication
|
class MockApplication : public mock::BaseApplication
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
MockApplication()
|
||||||
|
: highlights(this->settings, &this->accounts)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
IEmotes *getEmotes() override
|
IEmotes *getEmotes() override
|
||||||
{
|
{
|
||||||
return &this->emotes;
|
return &this->emotes;
|
||||||
|
|
37
mocks/include/mocks/BaseApplication.hpp
Normal file
37
mocks/include/mocks/BaseApplication.hpp
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "mocks/DisabledStreamerMode.hpp"
|
||||||
|
#include "mocks/EmptyApplication.hpp"
|
||||||
|
#include "singletons/Settings.hpp"
|
||||||
|
|
||||||
|
#include <QString>
|
||||||
|
|
||||||
|
namespace chatterino::mock {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* BaseApplication intends to be a mock application with a few more sane defaults, but with less configurability
|
||||||
|
*/
|
||||||
|
class BaseApplication : public EmptyApplication
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
BaseApplication()
|
||||||
|
: settings(this->settingsDir.filePath("settings.json"))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
explicit BaseApplication(const QString &settingsData)
|
||||||
|
: EmptyApplication(settingsData)
|
||||||
|
, settings(this->settingsDir.filePath("settings.json"))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
IStreamerMode *getStreamerMode() override
|
||||||
|
{
|
||||||
|
return &this->streamerMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
Settings settings;
|
||||||
|
DisabledStreamerMode streamerMode;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace chatterino::mock
|
|
@ -17,7 +17,17 @@ public:
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~EmptyApplication() = default;
|
explicit EmptyApplication(const QString &settingsData)
|
||||||
|
: EmptyApplication()
|
||||||
|
{
|
||||||
|
QFile settingsFile(this->settingsDir.filePath("settings.json"));
|
||||||
|
settingsFile.open(QIODevice::WriteOnly | QIODevice::Text);
|
||||||
|
settingsFile.write(settingsData.toUtf8());
|
||||||
|
settingsFile.flush();
|
||||||
|
settingsFile.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
~EmptyApplication() override = default;
|
||||||
|
|
||||||
bool isTest() const override
|
bool isTest() const override
|
||||||
{
|
{
|
||||||
|
@ -249,7 +259,6 @@ public:
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
|
||||||
QTemporaryDir settingsDir;
|
QTemporaryDir settingsDir;
|
||||||
Paths paths_;
|
Paths paths_;
|
||||||
Args args_;
|
Args args_;
|
||||||
|
|
|
@ -118,26 +118,26 @@ Application::Application(Settings &_settings, const Paths &paths,
|
||||||
const Args &_args, Updates &_updates)
|
const Args &_args, Updates &_updates)
|
||||||
: paths_(paths)
|
: paths_(paths)
|
||||||
, args_(_args)
|
, args_(_args)
|
||||||
, themes(&this->emplace<Theme>())
|
, themes(new Theme(paths))
|
||||||
, fonts(new Fonts(_settings))
|
, fonts(new Fonts(_settings))
|
||||||
, emotes(&this->emplace<Emotes>())
|
, emotes(new Emotes)
|
||||||
, accounts(&this->emplace<AccountController>())
|
, accounts(new AccountController)
|
||||||
, hotkeys(&this->emplace<HotkeyController>())
|
, hotkeys(new HotkeyController)
|
||||||
, windows(&this->emplace(new WindowManager(paths)))
|
, windows(new WindowManager(paths))
|
||||||
, toasts(&this->emplace<Toasts>())
|
, toasts(new Toasts)
|
||||||
, imageUploader(&this->emplace<ImageUploader>())
|
, imageUploader(new ImageUploader)
|
||||||
, seventvAPI(&this->emplace<SeventvAPI>())
|
, seventvAPI(new SeventvAPI)
|
||||||
, crashHandler(&this->emplace(new CrashHandler(paths)))
|
, crashHandler(new CrashHandler(paths))
|
||||||
|
|
||||||
, commands(&this->emplace<CommandController>())
|
, commands(new CommandController(paths))
|
||||||
, notifications(&this->emplace<NotificationController>())
|
, notifications(new NotificationController)
|
||||||
, highlights(&this->emplace<HighlightController>())
|
, highlights(new HighlightController(_settings, this->accounts.get()))
|
||||||
, twitch(new TwitchIrcServer)
|
, twitch(new TwitchIrcServer)
|
||||||
, ffzBadges(&this->emplace<FfzBadges>())
|
, ffzBadges(new FfzBadges)
|
||||||
, seventvBadges(&this->emplace<SeventvBadges>())
|
, seventvBadges(new SeventvBadges)
|
||||||
, userData(new UserDataController(paths))
|
, userData(new UserDataController(paths))
|
||||||
, sound(makeSoundController(_settings))
|
, sound(makeSoundController(_settings))
|
||||||
, twitchLiveController(&this->emplace<TwitchLiveController>())
|
, twitchLiveController(new TwitchLiveController)
|
||||||
, twitchPubSub(new PubSub(TWITCH_PUBSUB_URL))
|
, twitchPubSub(new PubSub(TWITCH_PUBSUB_URL))
|
||||||
, twitchBadges(new TwitchBadges)
|
, twitchBadges(new TwitchBadges)
|
||||||
, chatterinoBadges(new ChatterinoBadges)
|
, chatterinoBadges(new ChatterinoBadges)
|
||||||
|
@ -148,7 +148,7 @@ Application::Application(Settings &_settings, const Paths &paths,
|
||||||
, linkResolver(new LinkResolver)
|
, linkResolver(new LinkResolver)
|
||||||
, streamerMode(new StreamerMode)
|
, streamerMode(new StreamerMode)
|
||||||
#ifdef CHATTERINO_HAVE_PLUGINS
|
#ifdef CHATTERINO_HAVE_PLUGINS
|
||||||
, plugins(&this->emplace(new PluginController(paths)))
|
, plugins(new PluginController(paths))
|
||||||
#endif
|
#endif
|
||||||
, updates(_updates)
|
, updates(_updates)
|
||||||
{
|
{
|
||||||
|
@ -165,16 +165,35 @@ Application::~Application() = default;
|
||||||
|
|
||||||
void Application::fakeDtor()
|
void Application::fakeDtor()
|
||||||
{
|
{
|
||||||
|
#ifdef CHATTERINO_HAVE_PLUGINS
|
||||||
|
this->plugins.reset();
|
||||||
|
#endif
|
||||||
this->twitchPubSub.reset();
|
this->twitchPubSub.reset();
|
||||||
this->twitchBadges.reset();
|
this->twitchBadges.reset();
|
||||||
|
this->twitchLiveController.reset();
|
||||||
this->chatterinoBadges.reset();
|
this->chatterinoBadges.reset();
|
||||||
this->bttvEmotes.reset();
|
this->bttvEmotes.reset();
|
||||||
this->ffzEmotes.reset();
|
this->ffzEmotes.reset();
|
||||||
this->seventvEmotes.reset();
|
this->seventvEmotes.reset();
|
||||||
|
this->notifications.reset();
|
||||||
|
this->commands.reset();
|
||||||
|
// If a crash happens after crashHandler has been reset, we'll assert
|
||||||
|
// This isn't super different from before, where if the app is already killed, the getApp() portion of it is already dead
|
||||||
|
this->crashHandler.reset();
|
||||||
|
this->seventvAPI.reset();
|
||||||
|
this->highlights.reset();
|
||||||
|
this->seventvBadges.reset();
|
||||||
|
this->ffzBadges.reset();
|
||||||
// this->twitch.reset();
|
// this->twitch.reset();
|
||||||
|
this->imageUploader.reset();
|
||||||
|
this->hotkeys.reset();
|
||||||
this->fonts.reset();
|
this->fonts.reset();
|
||||||
this->sound.reset();
|
this->sound.reset();
|
||||||
this->userData.reset();
|
this->userData.reset();
|
||||||
|
this->toasts.reset();
|
||||||
|
this->accounts.reset();
|
||||||
|
this->emotes.reset();
|
||||||
|
this->themes.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::initialize(Settings &settings, const Paths &paths)
|
void Application::initialize(Settings &settings, const Paths &paths)
|
||||||
|
@ -208,17 +227,24 @@ void Application::initialize(Settings &settings, const Paths &paths)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto &singleton : this->singletons_)
|
this->accounts->load();
|
||||||
{
|
|
||||||
singleton->initialize(settings, paths);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
this->windows->initialize(settings);
|
||||||
|
|
||||||
|
this->ffzBadges->load();
|
||||||
this->twitch->initialize();
|
this->twitch->initialize();
|
||||||
|
|
||||||
|
// Load live status
|
||||||
|
this->notifications->initialize();
|
||||||
|
|
||||||
// XXX: Loading Twitch badges after Helix has been initialized, which only happens after
|
// XXX: Loading Twitch badges after Helix has been initialized, which only happens after
|
||||||
// the AccountController initialize has been called
|
// the AccountController initialize has been called
|
||||||
this->twitchBadges->loadTwitchBadges();
|
this->twitchBadges->loadTwitchBadges();
|
||||||
|
|
||||||
|
#ifdef CHATTERINO_HAVE_PLUGINS
|
||||||
|
this->plugins->initialize(settings);
|
||||||
|
#endif
|
||||||
|
|
||||||
// Show crash message.
|
// Show crash message.
|
||||||
// On Windows, the crash message was already shown.
|
// On Windows, the crash message was already shown.
|
||||||
#ifndef Q_OS_WIN
|
#ifndef Q_OS_WIN
|
||||||
|
@ -335,8 +361,9 @@ int Application::run(QApplication &qtApp)
|
||||||
Theme *Application::getThemes()
|
Theme *Application::getThemes()
|
||||||
{
|
{
|
||||||
assertInGuiThread();
|
assertInGuiThread();
|
||||||
|
assert(this->themes);
|
||||||
|
|
||||||
return this->themes;
|
return this->themes.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
Fonts *Application::getFonts()
|
Fonts *Application::getFonts()
|
||||||
|
@ -350,22 +377,25 @@ Fonts *Application::getFonts()
|
||||||
IEmotes *Application::getEmotes()
|
IEmotes *Application::getEmotes()
|
||||||
{
|
{
|
||||||
assertInGuiThread();
|
assertInGuiThread();
|
||||||
|
assert(this->emotes);
|
||||||
|
|
||||||
return this->emotes;
|
return this->emotes.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
AccountController *Application::getAccounts()
|
AccountController *Application::getAccounts()
|
||||||
{
|
{
|
||||||
assertInGuiThread();
|
assertInGuiThread();
|
||||||
|
assert(this->accounts);
|
||||||
|
|
||||||
return this->accounts;
|
return this->accounts.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
HotkeyController *Application::getHotkeys()
|
HotkeyController *Application::getHotkeys()
|
||||||
{
|
{
|
||||||
assertInGuiThread();
|
assertInGuiThread();
|
||||||
|
assert(this->hotkeys);
|
||||||
|
|
||||||
return this->hotkeys;
|
return this->hotkeys.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
WindowManager *Application::getWindows()
|
WindowManager *Application::getWindows()
|
||||||
|
@ -373,56 +403,63 @@ WindowManager *Application::getWindows()
|
||||||
assertInGuiThread();
|
assertInGuiThread();
|
||||||
assert(this->windows);
|
assert(this->windows);
|
||||||
|
|
||||||
return this->windows;
|
return this->windows.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
Toasts *Application::getToasts()
|
Toasts *Application::getToasts()
|
||||||
{
|
{
|
||||||
assertInGuiThread();
|
assertInGuiThread();
|
||||||
|
assert(this->toasts);
|
||||||
|
|
||||||
return this->toasts;
|
return this->toasts.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
CrashHandler *Application::getCrashHandler()
|
CrashHandler *Application::getCrashHandler()
|
||||||
{
|
{
|
||||||
assertInGuiThread();
|
assertInGuiThread();
|
||||||
|
assert(this->crashHandler);
|
||||||
|
|
||||||
return this->crashHandler;
|
return this->crashHandler.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
CommandController *Application::getCommands()
|
CommandController *Application::getCommands()
|
||||||
{
|
{
|
||||||
assertInGuiThread();
|
assertInGuiThread();
|
||||||
|
assert(this->commands);
|
||||||
|
|
||||||
return this->commands;
|
return this->commands.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
NotificationController *Application::getNotifications()
|
NotificationController *Application::getNotifications()
|
||||||
{
|
{
|
||||||
assertInGuiThread();
|
assertInGuiThread();
|
||||||
|
assert(this->notifications);
|
||||||
|
|
||||||
return this->notifications;
|
return this->notifications.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
HighlightController *Application::getHighlights()
|
HighlightController *Application::getHighlights()
|
||||||
{
|
{
|
||||||
assertInGuiThread();
|
assertInGuiThread();
|
||||||
|
assert(this->highlights);
|
||||||
|
|
||||||
return this->highlights;
|
return this->highlights.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
FfzBadges *Application::getFfzBadges()
|
FfzBadges *Application::getFfzBadges()
|
||||||
{
|
{
|
||||||
assertInGuiThread();
|
assertInGuiThread();
|
||||||
|
assert(this->ffzBadges);
|
||||||
|
|
||||||
return this->ffzBadges;
|
return this->ffzBadges.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
SeventvBadges *Application::getSeventvBadges()
|
SeventvBadges *Application::getSeventvBadges()
|
||||||
{
|
{
|
||||||
// SeventvBadges handles its own locks, so we don't need to assert that this is called in the GUI thread
|
// SeventvBadges handles its own locks, so we don't need to assert that this is called in the GUI thread
|
||||||
|
assert(this->seventvBadges);
|
||||||
|
|
||||||
return this->seventvBadges;
|
return this->seventvBadges.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
IUserDataController *Application::getUserData()
|
IUserDataController *Application::getUserData()
|
||||||
|
@ -442,8 +479,9 @@ ISoundController *Application::getSound()
|
||||||
ITwitchLiveController *Application::getTwitchLiveController()
|
ITwitchLiveController *Application::getTwitchLiveController()
|
||||||
{
|
{
|
||||||
assertInGuiThread();
|
assertInGuiThread();
|
||||||
|
assert(this->twitchLiveController);
|
||||||
|
|
||||||
return this->twitchLiveController;
|
return this->twitchLiveController.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
TwitchBadges *Application::getTwitchBadges()
|
TwitchBadges *Application::getTwitchBadges()
|
||||||
|
@ -465,23 +503,26 @@ IChatterinoBadges *Application::getChatterinoBadges()
|
||||||
ImageUploader *Application::getImageUploader()
|
ImageUploader *Application::getImageUploader()
|
||||||
{
|
{
|
||||||
assertInGuiThread();
|
assertInGuiThread();
|
||||||
|
assert(this->imageUploader);
|
||||||
|
|
||||||
return this->imageUploader;
|
return this->imageUploader.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
SeventvAPI *Application::getSeventvAPI()
|
SeventvAPI *Application::getSeventvAPI()
|
||||||
{
|
{
|
||||||
assertInGuiThread();
|
assertInGuiThread();
|
||||||
|
assert(this->seventvAPI);
|
||||||
|
|
||||||
return this->seventvAPI;
|
return this->seventvAPI.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CHATTERINO_HAVE_PLUGINS
|
#ifdef CHATTERINO_HAVE_PLUGINS
|
||||||
PluginController *Application::getPlugins()
|
PluginController *Application::getPlugins()
|
||||||
{
|
{
|
||||||
assertInGuiThread();
|
assertInGuiThread();
|
||||||
|
assert(this->plugins);
|
||||||
|
|
||||||
return this->plugins;
|
return this->plugins.get();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -551,10 +592,9 @@ SeventvEmotes *Application::getSeventvEmotes()
|
||||||
|
|
||||||
void Application::save()
|
void Application::save()
|
||||||
{
|
{
|
||||||
for (auto &singleton : this->singletons_)
|
this->commands->save();
|
||||||
{
|
this->hotkeys->save();
|
||||||
singleton->save();
|
this->windows->save();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::initNm(const Paths &paths)
|
void Application::initNm(const Paths &paths)
|
||||||
|
@ -896,11 +936,11 @@ void Application::initPubSub()
|
||||||
chan->addMessage(p.second,
|
chan->addMessage(p.second,
|
||||||
MessageContext::Original);
|
MessageContext::Original);
|
||||||
|
|
||||||
getIApp()
|
getApp()
|
||||||
->getTwitch()
|
->getTwitch()
|
||||||
->getAutomodChannel()
|
->getAutomodChannel()
|
||||||
->addMessage(p.first, MessageContext::Original);
|
->addMessage(p.first, MessageContext::Original);
|
||||||
getIApp()
|
getApp()
|
||||||
->getTwitch()
|
->getTwitch()
|
||||||
->getAutomodChannel()
|
->getAutomodChannel()
|
||||||
->addMessage(p.second,
|
->addMessage(p.second,
|
||||||
|
@ -908,12 +948,12 @@ void Application::initPubSub()
|
||||||
|
|
||||||
if (getSettings()->showAutomodInMentions)
|
if (getSettings()->showAutomodInMentions)
|
||||||
{
|
{
|
||||||
getIApp()
|
getApp()
|
||||||
->getTwitch()
|
->getTwitch()
|
||||||
->getMentionsChannel()
|
->getMentionsChannel()
|
||||||
->addMessage(p.first,
|
->addMessage(p.first,
|
||||||
MessageContext::Original);
|
MessageContext::Original);
|
||||||
getIApp()
|
getApp()
|
||||||
->getTwitch()
|
->getTwitch()
|
||||||
->getMentionsChannel()
|
->getMentionsChannel()
|
||||||
->addMessage(p.second,
|
->addMessage(p.second,
|
||||||
|
@ -1124,14 +1164,7 @@ void Application::initSeventvEventAPI()
|
||||||
seventvEventAPI->start();
|
seventvEventAPI->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
Application *getApp()
|
IApplication *getApp()
|
||||||
{
|
|
||||||
assert(Application::instance != nullptr);
|
|
||||||
|
|
||||||
return Application::instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
IApplication *getIApp()
|
|
||||||
{
|
{
|
||||||
assert(IApplication::instance != nullptr);
|
assert(IApplication::instance != nullptr);
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "common/Singleton.hpp"
|
|
||||||
#include "debug/AssertInGuiThread.hpp"
|
#include "debug/AssertInGuiThread.hpp"
|
||||||
#include "singletons/NativeMessaging.hpp"
|
#include "singletons/NativeMessaging.hpp"
|
||||||
|
|
||||||
|
@ -108,7 +107,6 @@ class Application : public IApplication
|
||||||
{
|
{
|
||||||
const Paths &paths_;
|
const Paths &paths_;
|
||||||
const Args &args_;
|
const Args &args_;
|
||||||
std::vector<std::unique_ptr<Singleton>> singletons_;
|
|
||||||
int argc_{};
|
int argc_{};
|
||||||
char **argv_{};
|
char **argv_{};
|
||||||
|
|
||||||
|
@ -144,25 +142,25 @@ public:
|
||||||
friend void test();
|
friend void test();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Theme *const themes{};
|
std::unique_ptr<Theme> themes;
|
||||||
std::unique_ptr<Fonts> fonts{};
|
std::unique_ptr<Fonts> fonts;
|
||||||
Emotes *const emotes{};
|
std::unique_ptr<Emotes> emotes;
|
||||||
AccountController *const accounts{};
|
std::unique_ptr<AccountController> accounts;
|
||||||
HotkeyController *const hotkeys{};
|
std::unique_ptr<HotkeyController> hotkeys;
|
||||||
WindowManager *const windows{};
|
std::unique_ptr<WindowManager> windows;
|
||||||
Toasts *const toasts{};
|
std::unique_ptr<Toasts> toasts;
|
||||||
ImageUploader *const imageUploader{};
|
std::unique_ptr<ImageUploader> imageUploader;
|
||||||
SeventvAPI *const seventvAPI{};
|
std::unique_ptr<SeventvAPI> seventvAPI;
|
||||||
CrashHandler *const crashHandler{};
|
std::unique_ptr<CrashHandler> crashHandler;
|
||||||
CommandController *const commands{};
|
std::unique_ptr<CommandController> commands;
|
||||||
NotificationController *const notifications{};
|
std::unique_ptr<NotificationController> notifications;
|
||||||
HighlightController *const highlights{};
|
std::unique_ptr<HighlightController> highlights;
|
||||||
std::unique_ptr<TwitchIrcServer> twitch;
|
std::unique_ptr<TwitchIrcServer> twitch;
|
||||||
FfzBadges *const ffzBadges{};
|
std::unique_ptr<FfzBadges> ffzBadges;
|
||||||
SeventvBadges *const seventvBadges{};
|
std::unique_ptr<SeventvBadges> seventvBadges;
|
||||||
std::unique_ptr<UserDataController> userData;
|
std::unique_ptr<UserDataController> userData;
|
||||||
std::unique_ptr<ISoundController> sound;
|
std::unique_ptr<ISoundController> sound;
|
||||||
TwitchLiveController *const twitchLiveController{};
|
std::unique_ptr<TwitchLiveController> twitchLiveController;
|
||||||
std::unique_ptr<PubSub> twitchPubSub;
|
std::unique_ptr<PubSub> twitchPubSub;
|
||||||
std::unique_ptr<TwitchBadges> twitchBadges;
|
std::unique_ptr<TwitchBadges> twitchBadges;
|
||||||
std::unique_ptr<ChatterinoBadges> chatterinoBadges;
|
std::unique_ptr<ChatterinoBadges> chatterinoBadges;
|
||||||
|
@ -173,7 +171,7 @@ private:
|
||||||
std::unique_ptr<ILinkResolver> linkResolver;
|
std::unique_ptr<ILinkResolver> linkResolver;
|
||||||
std::unique_ptr<IStreamerMode> streamerMode;
|
std::unique_ptr<IStreamerMode> streamerMode;
|
||||||
#ifdef CHATTERINO_HAVE_PLUGINS
|
#ifdef CHATTERINO_HAVE_PLUGINS
|
||||||
PluginController *const plugins{};
|
std::unique_ptr<PluginController> plugins;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -227,36 +225,15 @@ public:
|
||||||
IStreamerMode *getStreamerMode() override;
|
IStreamerMode *getStreamerMode() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void addSingleton(Singleton *singleton);
|
|
||||||
void initPubSub();
|
void initPubSub();
|
||||||
void initBttvLiveUpdates();
|
void initBttvLiveUpdates();
|
||||||
void initSeventvEventAPI();
|
void initSeventvEventAPI();
|
||||||
void initNm(const Paths &paths);
|
void initNm(const Paths &paths);
|
||||||
|
|
||||||
template <typename T,
|
|
||||||
typename = std::enable_if_t<std::is_base_of<Singleton, T>::value>>
|
|
||||||
T &emplace()
|
|
||||||
{
|
|
||||||
auto t = new T;
|
|
||||||
this->singletons_.push_back(std::unique_ptr<T>(t));
|
|
||||||
return *t;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T,
|
|
||||||
typename = std::enable_if_t<std::is_base_of<Singleton, T>::value>>
|
|
||||||
T &emplace(T *t)
|
|
||||||
{
|
|
||||||
this->singletons_.push_back(std::unique_ptr<T>(t));
|
|
||||||
return *t;
|
|
||||||
}
|
|
||||||
|
|
||||||
NativeMessagingServer nmServer{};
|
NativeMessagingServer nmServer{};
|
||||||
Updates &updates;
|
Updates &updates;
|
||||||
};
|
};
|
||||||
|
|
||||||
Application *getApp();
|
IApplication *getApp();
|
||||||
|
|
||||||
// Get an interface version of the Application class - should be preferred when possible for new code
|
|
||||||
IApplication *getIApp();
|
|
||||||
|
|
||||||
} // namespace chatterino
|
} // namespace chatterino
|
||||||
|
|
|
@ -444,8 +444,6 @@ set(SOURCE_FILES
|
||||||
providers/twitch/api/Helix.cpp
|
providers/twitch/api/Helix.cpp
|
||||||
providers/twitch/api/Helix.hpp
|
providers/twitch/api/Helix.hpp
|
||||||
|
|
||||||
singletons/Badges.cpp
|
|
||||||
singletons/Badges.hpp
|
|
||||||
singletons/CrashHandler.cpp
|
singletons/CrashHandler.cpp
|
||||||
singletons/CrashHandler.hpp
|
singletons/CrashHandler.hpp
|
||||||
singletons/Emotes.cpp
|
singletons/Emotes.cpp
|
||||||
|
|
|
@ -131,7 +131,7 @@ namespace {
|
||||||
using namespace std::chrono_literals;
|
using namespace std::chrono_literals;
|
||||||
|
|
||||||
if (std::chrono::steady_clock::now() - signalsInitTime > 30s &&
|
if (std::chrono::steady_clock::now() - signalsInitTime > 30s &&
|
||||||
getIApp()->getCrashHandler()->shouldRecover())
|
getApp()->getCrashHandler()->shouldRecover())
|
||||||
{
|
{
|
||||||
QProcess proc;
|
QProcess proc;
|
||||||
|
|
||||||
|
|
|
@ -100,9 +100,9 @@ void Channel::addMessage(MessagePtr message, MessageContext context,
|
||||||
if (!isDoNotLogSet)
|
if (!isDoNotLogSet)
|
||||||
{
|
{
|
||||||
// Only log messages where the `DoNotLog` flag is not set
|
// Only log messages where the `DoNotLog` flag is not set
|
||||||
getIApp()->getChatLogger()->addMessage(this->name_, message,
|
getApp()->getChatLogger()->addMessage(this->name_, message,
|
||||||
this->platform_,
|
this->platform_,
|
||||||
this->getCurrentStreamID());
|
this->getCurrentStreamID());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -56,7 +56,7 @@ bool useKeyring()
|
||||||
// Insecure storage:
|
// Insecure storage:
|
||||||
QString insecurePath()
|
QString insecurePath()
|
||||||
{
|
{
|
||||||
return combinePath(getIApp()->getPaths().settingsDirectory,
|
return combinePath(getApp()->getPaths().settingsDirectory,
|
||||||
"credentials.json");
|
"credentials.json");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,31 +0,0 @@
|
||||||
#pragma once
|
|
||||||
|
|
||||||
namespace chatterino {
|
|
||||||
|
|
||||||
class Settings;
|
|
||||||
class Paths;
|
|
||||||
|
|
||||||
class Singleton
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
Singleton() = default;
|
|
||||||
virtual ~Singleton() = default;
|
|
||||||
|
|
||||||
Singleton(const Singleton &) = delete;
|
|
||||||
Singleton &operator=(const Singleton &) = delete;
|
|
||||||
|
|
||||||
Singleton(Singleton &&) = delete;
|
|
||||||
Singleton &operator=(Singleton &&) = delete;
|
|
||||||
|
|
||||||
virtual void initialize(Settings &settings, const Paths &paths)
|
|
||||||
{
|
|
||||||
(void)(settings);
|
|
||||||
(void)(paths);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void save()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace chatterino
|
|
|
@ -59,7 +59,7 @@ void loadUncached(std::shared_ptr<NetworkData> &&data)
|
||||||
|
|
||||||
void loadCached(std::shared_ptr<NetworkData> &&data)
|
void loadCached(std::shared_ptr<NetworkData> &&data)
|
||||||
{
|
{
|
||||||
QFile cachedFile(getIApp()->getPaths().cacheDirectory() + "/" +
|
QFile cachedFile(getApp()->getPaths().cacheDirectory() + "/" +
|
||||||
data->getHash());
|
data->getHash());
|
||||||
|
|
||||||
if (!cachedFile.exists() || !cachedFile.open(QIODevice::ReadOnly))
|
if (!cachedFile.exists() || !cachedFile.open(QIODevice::ReadOnly))
|
||||||
|
|
|
@ -118,7 +118,7 @@ void NetworkTask::logReply()
|
||||||
void NetworkTask::writeToCache(const QByteArray &bytes) const
|
void NetworkTask::writeToCache(const QByteArray &bytes) const
|
||||||
{
|
{
|
||||||
std::ignore = QtConcurrent::run([data = this->data_, bytes] {
|
std::ignore = QtConcurrent::run([data = this->data_, bytes] {
|
||||||
QFile cachedFile(getIApp()->getPaths().cacheDirectory() + "/" +
|
QFile cachedFile(getApp()->getPaths().cacheDirectory() + "/" +
|
||||||
data->getHash());
|
data->getHash());
|
||||||
|
|
||||||
if (cachedFile.open(QIODevice::WriteOnly))
|
if (cachedFile.open(QIODevice::WriteOnly))
|
||||||
|
|
|
@ -47,7 +47,7 @@ AccountController::AccountController()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void AccountController::initialize(Settings &settings, const Paths &paths)
|
void AccountController::load()
|
||||||
{
|
{
|
||||||
this->twitch.load();
|
this->twitch.load();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "common/SignalVector.hpp"
|
#include "common/SignalVector.hpp"
|
||||||
#include "common/Singleton.hpp"
|
|
||||||
#include "providers/twitch/TwitchAccountManager.hpp"
|
#include "providers/twitch/TwitchAccountManager.hpp"
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
@ -14,14 +13,17 @@ class Paths;
|
||||||
|
|
||||||
class AccountModel;
|
class AccountModel;
|
||||||
|
|
||||||
class AccountController final : public Singleton
|
class AccountController final
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
AccountController();
|
AccountController();
|
||||||
|
|
||||||
AccountModel *createModel(QObject *parent);
|
AccountModel *createModel(QObject *parent);
|
||||||
|
|
||||||
void initialize(Settings &settings, const Paths &paths) override;
|
/**
|
||||||
|
* Load current user & send off a signal to subscribers about any potential changes
|
||||||
|
*/
|
||||||
|
void load();
|
||||||
|
|
||||||
TwitchAccountManager twitch;
|
TwitchAccountManager twitch;
|
||||||
|
|
||||||
|
|
|
@ -121,7 +121,7 @@ const std::unordered_map<QString, VariableReplacer> COMMAND_VARS{
|
||||||
(void)(channel); //unused
|
(void)(channel); //unused
|
||||||
(void)(message); //unused
|
(void)(message); //unused
|
||||||
auto uid =
|
auto uid =
|
||||||
getIApp()->getAccounts()->twitch.getCurrent()->getUserId();
|
getApp()->getAccounts()->twitch.getCurrent()->getUserId();
|
||||||
return uid.isEmpty() ? altText : uid;
|
return uid.isEmpty() ? altText : uid;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -131,7 +131,7 @@ const std::unordered_map<QString, VariableReplacer> COMMAND_VARS{
|
||||||
(void)(channel); //unused
|
(void)(channel); //unused
|
||||||
(void)(message); //unused
|
(void)(message); //unused
|
||||||
auto name =
|
auto name =
|
||||||
getIApp()->getAccounts()->twitch.getCurrent()->getUserName();
|
getApp()->getAccounts()->twitch.getCurrent()->getUserName();
|
||||||
return name.isEmpty() ? altText : name;
|
return name.isEmpty() ? altText : name;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -263,7 +263,7 @@ const std::unordered_map<QString, VariableReplacer> COMMAND_VARS{
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
||||||
void CommandController::initialize(Settings &, const Paths &paths)
|
CommandController::CommandController(const Paths &paths)
|
||||||
{
|
{
|
||||||
// Update commands map when the vector of commands has been updated
|
// Update commands map when the vector of commands has been updated
|
||||||
auto addFirstMatchToMap = [this](auto args) {
|
auto addFirstMatchToMap = [this](auto args) {
|
||||||
|
@ -485,7 +485,7 @@ QString CommandController::execCommand(const QString &textNoEmoji,
|
||||||
ChannelPtr channel, bool dryRun)
|
ChannelPtr channel, bool dryRun)
|
||||||
{
|
{
|
||||||
QString text =
|
QString text =
|
||||||
getIApp()->getEmotes()->getEmojis()->replaceShortCodes(textNoEmoji);
|
getApp()->getEmotes()->getEmojis()->replaceShortCodes(textNoEmoji);
|
||||||
QStringList words = text.split(' ', Qt::SkipEmptyParts);
|
QStringList words = text.split(' ', Qt::SkipEmptyParts);
|
||||||
|
|
||||||
if (words.length() == 0)
|
if (words.length() == 0)
|
||||||
|
@ -500,7 +500,7 @@ QString CommandController::execCommand(const QString &textNoEmoji,
|
||||||
const auto it = this->userCommands_.find(commandName);
|
const auto it = this->userCommands_.find(commandName);
|
||||||
if (it != this->userCommands_.end())
|
if (it != this->userCommands_.end())
|
||||||
{
|
{
|
||||||
text = getIApp()->getEmotes()->getEmojis()->replaceShortCodes(
|
text = getApp()->getEmotes()->getEmojis()->replaceShortCodes(
|
||||||
this->execCustomCommand(words, it.value(), dryRun, channel));
|
this->execCustomCommand(words, it.value(), dryRun, channel));
|
||||||
|
|
||||||
words = text.split(' ', Qt::SkipEmptyParts);
|
words = text.split(' ', Qt::SkipEmptyParts);
|
||||||
|
@ -570,7 +570,7 @@ bool CommandController::registerPluginCommand(const QString &commandName)
|
||||||
}
|
}
|
||||||
|
|
||||||
this->commands_[commandName] = [commandName](const CommandContext &ctx) {
|
this->commands_[commandName] = [commandName](const CommandContext &ctx) {
|
||||||
return getIApp()->getPlugins()->tryExecPluginCommand(commandName, ctx);
|
return getApp()->getPlugins()->tryExecPluginCommand(commandName, ctx);
|
||||||
};
|
};
|
||||||
this->pluginCommands_.append(commandName);
|
this->pluginCommands_.append(commandName);
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "common/SignalVector.hpp"
|
#include "common/SignalVector.hpp"
|
||||||
#include "common/Singleton.hpp"
|
|
||||||
#include "util/QStringHash.hpp"
|
#include "util/QStringHash.hpp"
|
||||||
|
|
||||||
#include <pajlada/settings.hpp>
|
#include <pajlada/settings.hpp>
|
||||||
|
@ -24,7 +23,7 @@ struct Command;
|
||||||
class CommandModel;
|
class CommandModel;
|
||||||
struct CommandContext;
|
struct CommandContext;
|
||||||
|
|
||||||
class CommandController final : public Singleton
|
class CommandController final
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SignalVector<Command> items;
|
SignalVector<Command> items;
|
||||||
|
@ -33,8 +32,8 @@ public:
|
||||||
bool dryRun);
|
bool dryRun);
|
||||||
QStringList getDefaultChatterinoCommandList();
|
QStringList getDefaultChatterinoCommandList();
|
||||||
|
|
||||||
void initialize(Settings &, const Paths &paths) override;
|
CommandController(const Paths &paths);
|
||||||
void save() override;
|
void save();
|
||||||
|
|
||||||
CommandModel *createModel(QObject *parent);
|
CommandModel *createModel(QObject *parent);
|
||||||
|
|
||||||
|
|
|
@ -220,7 +220,7 @@ QString marker(const CommandContext &ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Avoid Helix calls without Client ID and/or OAuth Token
|
// Avoid Helix calls without Client ID and/or OAuth Token
|
||||||
if (getIApp()->getAccounts()->twitch.getCurrent()->isAnon())
|
if (getApp()->getAccounts()->twitch.getCurrent()->isAnon())
|
||||||
{
|
{
|
||||||
ctx.channel->addSystemMessage(
|
ctx.channel->addSystemMessage(
|
||||||
"You need to be logged in to create stream markers!");
|
"You need to be logged in to create stream markers!");
|
||||||
|
@ -367,7 +367,7 @@ QString popup(const CommandContext &ctx)
|
||||||
if (target.isEmpty())
|
if (target.isEmpty())
|
||||||
{
|
{
|
||||||
auto *currentPage =
|
auto *currentPage =
|
||||||
dynamic_cast<SplitContainer *>(getIApp()
|
dynamic_cast<SplitContainer *>(getApp()
|
||||||
->getWindows()
|
->getWindows()
|
||||||
->getMainWindow()
|
->getMainWindow()
|
||||||
.getNotebook()
|
.getNotebook()
|
||||||
|
@ -388,9 +388,8 @@ QString popup(const CommandContext &ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Open channel passed as argument in a popup
|
// Open channel passed as argument in a popup
|
||||||
auto targetChannel =
|
auto targetChannel = getApp()->getTwitchAbstract()->getOrAddChannel(target);
|
||||||
getIApp()->getTwitchAbstract()->getOrAddChannel(target);
|
getApp()->getWindows()->openInPopup(targetChannel);
|
||||||
getIApp()->getWindows()->openInPopup(targetChannel);
|
|
||||||
|
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
@ -399,7 +398,7 @@ QString clearmessages(const CommandContext &ctx)
|
||||||
{
|
{
|
||||||
(void)ctx;
|
(void)ctx;
|
||||||
|
|
||||||
auto *currentPage = getIApp()
|
auto *currentPage = getApp()
|
||||||
->getWindows()
|
->getWindows()
|
||||||
->getLastSelectedWindow()
|
->getLastSelectedWindow()
|
||||||
->getNotebook()
|
->getNotebook()
|
||||||
|
@ -531,7 +530,7 @@ QString sendRawMessage(const CommandContext &ctx)
|
||||||
|
|
||||||
if (ctx.channel->isTwitchChannel())
|
if (ctx.channel->isTwitchChannel())
|
||||||
{
|
{
|
||||||
getIApp()->getTwitchAbstract()->sendRawMessage(
|
getApp()->getTwitchAbstract()->sendRawMessage(
|
||||||
ctx.words.mid(1).join(" "));
|
ctx.words.mid(1).join(" "));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -565,7 +564,7 @@ QString injectFakeMessage(const CommandContext &ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
auto ircText = ctx.words.mid(1).join(" ");
|
auto ircText = ctx.words.mid(1).join(" ");
|
||||||
getIApp()->getTwitchAbstract()->addFakeMessage(ircText);
|
getApp()->getTwitchAbstract()->addFakeMessage(ircText);
|
||||||
|
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
@ -634,7 +633,7 @@ QString unstableSetUserClientSideColor(const CommandContext &ctx)
|
||||||
|
|
||||||
auto color = ctx.words.value(2);
|
auto color = ctx.words.value(2);
|
||||||
|
|
||||||
getIApp()->getUserData()->setUserColor(userID, color);
|
getApp()->getUserData()->setUserColor(userID, color);
|
||||||
|
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
@ -664,7 +663,7 @@ QString openUsercard(const CommandContext &ctx)
|
||||||
stripChannelName(channelName);
|
stripChannelName(channelName);
|
||||||
|
|
||||||
ChannelPtr channelTemp =
|
ChannelPtr channelTemp =
|
||||||
getIApp()->getTwitchAbstract()->getChannelOrEmpty(channelName);
|
getApp()->getTwitchAbstract()->getChannelOrEmpty(channelName);
|
||||||
|
|
||||||
if (channelTemp->isEmpty())
|
if (channelTemp->isEmpty())
|
||||||
{
|
{
|
||||||
|
@ -679,7 +678,7 @@ QString openUsercard(const CommandContext &ctx)
|
||||||
|
|
||||||
// try to link to current split if possible
|
// try to link to current split if possible
|
||||||
Split *currentSplit = nullptr;
|
Split *currentSplit = nullptr;
|
||||||
auto *currentPage = dynamic_cast<SplitContainer *>(getIApp()
|
auto *currentPage = dynamic_cast<SplitContainer *>(getApp()
|
||||||
->getWindows()
|
->getWindows()
|
||||||
->getMainWindow()
|
->getMainWindow()
|
||||||
.getNotebook()
|
.getNotebook()
|
||||||
|
@ -695,7 +694,7 @@ QString openUsercard(const CommandContext &ctx)
|
||||||
{
|
{
|
||||||
// not possible to use current split, try searching for one
|
// not possible to use current split, try searching for one
|
||||||
const auto ¬ebook =
|
const auto ¬ebook =
|
||||||
getIApp()->getWindows()->getMainWindow().getNotebook();
|
getApp()->getWindows()->getMainWindow().getNotebook();
|
||||||
auto count = notebook.getPageCount();
|
auto count = notebook.getPageCount();
|
||||||
for (int i = 0; i < count; i++)
|
for (int i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
|
|
|
@ -32,7 +32,7 @@ QString addModerator(const CommandContext &ctx)
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
auto currentUser = getIApp()->getAccounts()->twitch.getCurrent();
|
auto currentUser = getApp()->getAccounts()->twitch.getCurrent();
|
||||||
if (currentUser->isAnon())
|
if (currentUser->isAnon())
|
||||||
{
|
{
|
||||||
ctx.channel->addSystemMessage("You must be logged in to mod someone!");
|
ctx.channel->addSystemMessage("You must be logged in to mod someone!");
|
||||||
|
|
|
@ -32,7 +32,7 @@ QString addVIP(const CommandContext &ctx)
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
auto currentUser = getIApp()->getAccounts()->twitch.getCurrent();
|
auto currentUser = getApp()->getAccounts()->twitch.getCurrent();
|
||||||
if (currentUser->isAnon())
|
if (currentUser->isAnon())
|
||||||
{
|
{
|
||||||
ctx.channel->addSystemMessage("You must be logged in to VIP someone!");
|
ctx.channel->addSystemMessage("You must be logged in to VIP someone!");
|
||||||
|
|
|
@ -50,7 +50,7 @@ QString sendAnnouncementColor(const CommandContext &ctx,
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
auto user = getIApp()->getAccounts()->twitch.getCurrent();
|
auto user = getApp()->getAccounts()->twitch.getCurrent();
|
||||||
if (user->isAnon())
|
if (user->isAnon())
|
||||||
{
|
{
|
||||||
ctx.channel->addSystemMessage(
|
ctx.channel->addSystemMessage(
|
||||||
|
|
|
@ -141,7 +141,7 @@ QString sendBan(const CommandContext &ctx)
|
||||||
|
|
||||||
assert(!actions.value().empty());
|
assert(!actions.value().empty());
|
||||||
|
|
||||||
auto currentUser = getIApp()->getAccounts()->twitch.getCurrent();
|
auto currentUser = getApp()->getAccounts()->twitch.getCurrent();
|
||||||
if (currentUser->isAnon())
|
if (currentUser->isAnon())
|
||||||
{
|
{
|
||||||
ctx.channel->addSystemMessage("You must be logged in to ban someone!");
|
ctx.channel->addSystemMessage("You must be logged in to ban someone!");
|
||||||
|
@ -252,7 +252,7 @@ QString sendBanById(const CommandContext &ctx)
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
auto currentUser = getIApp()->getAccounts()->twitch.getCurrent();
|
auto currentUser = getApp()->getAccounts()->twitch.getCurrent();
|
||||||
if (currentUser->isAnon())
|
if (currentUser->isAnon())
|
||||||
{
|
{
|
||||||
channel->addSystemMessage("You must be logged in to ban someone!");
|
channel->addSystemMessage("You must be logged in to ban someone!");
|
||||||
|
@ -292,7 +292,7 @@ QString sendTimeout(const CommandContext &ctx)
|
||||||
|
|
||||||
assert(!actions.value().empty());
|
assert(!actions.value().empty());
|
||||||
|
|
||||||
auto currentUser = getIApp()->getAccounts()->twitch.getCurrent();
|
auto currentUser = getApp()->getAccounts()->twitch.getCurrent();
|
||||||
if (currentUser->isAnon())
|
if (currentUser->isAnon())
|
||||||
{
|
{
|
||||||
ctx.channel->addSystemMessage(
|
ctx.channel->addSystemMessage(
|
||||||
|
|
|
@ -36,7 +36,7 @@ QString blockUser(const CommandContext &ctx)
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
auto currentUser = getIApp()->getAccounts()->twitch.getCurrent();
|
auto currentUser = getApp()->getAccounts()->twitch.getCurrent();
|
||||||
|
|
||||||
if (currentUser->isAnon())
|
if (currentUser->isAnon())
|
||||||
{
|
{
|
||||||
|
@ -52,7 +52,7 @@ QString blockUser(const CommandContext &ctx)
|
||||||
target,
|
target,
|
||||||
[currentUser, channel{ctx.channel},
|
[currentUser, channel{ctx.channel},
|
||||||
target](const HelixUser &targetUser) {
|
target](const HelixUser &targetUser) {
|
||||||
getIApp()->getAccounts()->twitch.getCurrent()->blockUser(
|
getApp()->getAccounts()->twitch.getCurrent()->blockUser(
|
||||||
targetUser.id, nullptr,
|
targetUser.id, nullptr,
|
||||||
[channel, target, targetUser] {
|
[channel, target, targetUser] {
|
||||||
channel->addSystemMessage(
|
channel->addSystemMessage(
|
||||||
|
@ -109,7 +109,7 @@ QString unblockUser(const CommandContext &ctx)
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
auto currentUser = getIApp()->getAccounts()->twitch.getCurrent();
|
auto currentUser = getApp()->getAccounts()->twitch.getCurrent();
|
||||||
|
|
||||||
if (currentUser->isAnon())
|
if (currentUser->isAnon())
|
||||||
{
|
{
|
||||||
|
@ -124,7 +124,7 @@ QString unblockUser(const CommandContext &ctx)
|
||||||
getHelix()->getUserByName(
|
getHelix()->getUserByName(
|
||||||
target,
|
target,
|
||||||
[currentUser, channel{ctx.channel}, target](const auto &targetUser) {
|
[currentUser, channel{ctx.channel}, target](const auto &targetUser) {
|
||||||
getIApp()->getAccounts()->twitch.getCurrent()->unblockUser(
|
getApp()->getAccounts()->twitch.getCurrent()->unblockUser(
|
||||||
targetUser.id, nullptr,
|
targetUser.id, nullptr,
|
||||||
[channel, target, targetUser] {
|
[channel, target, targetUser] {
|
||||||
channel->addSystemMessage(
|
channel->addSystemMessage(
|
||||||
|
|
|
@ -100,7 +100,7 @@ namespace chatterino::commands {
|
||||||
|
|
||||||
QString emoteOnly(const CommandContext &ctx)
|
QString emoteOnly(const CommandContext &ctx)
|
||||||
{
|
{
|
||||||
auto currentUser = getIApp()->getAccounts()->twitch.getCurrent();
|
auto currentUser = getApp()->getAccounts()->twitch.getCurrent();
|
||||||
if (currentUser->isAnon())
|
if (currentUser->isAnon())
|
||||||
{
|
{
|
||||||
ctx.channel->addSystemMessage(P_NOT_LOGGED_IN);
|
ctx.channel->addSystemMessage(P_NOT_LOGGED_IN);
|
||||||
|
@ -130,7 +130,7 @@ QString emoteOnly(const CommandContext &ctx)
|
||||||
|
|
||||||
QString emoteOnlyOff(const CommandContext &ctx)
|
QString emoteOnlyOff(const CommandContext &ctx)
|
||||||
{
|
{
|
||||||
auto currentUser = getIApp()->getAccounts()->twitch.getCurrent();
|
auto currentUser = getApp()->getAccounts()->twitch.getCurrent();
|
||||||
if (currentUser->isAnon())
|
if (currentUser->isAnon())
|
||||||
{
|
{
|
||||||
ctx.channel->addSystemMessage(P_NOT_LOGGED_IN);
|
ctx.channel->addSystemMessage(P_NOT_LOGGED_IN);
|
||||||
|
@ -158,7 +158,7 @@ QString emoteOnlyOff(const CommandContext &ctx)
|
||||||
|
|
||||||
QString subscribers(const CommandContext &ctx)
|
QString subscribers(const CommandContext &ctx)
|
||||||
{
|
{
|
||||||
auto currentUser = getIApp()->getAccounts()->twitch.getCurrent();
|
auto currentUser = getApp()->getAccounts()->twitch.getCurrent();
|
||||||
if (currentUser->isAnon())
|
if (currentUser->isAnon())
|
||||||
{
|
{
|
||||||
ctx.channel->addSystemMessage(P_NOT_LOGGED_IN);
|
ctx.channel->addSystemMessage(P_NOT_LOGGED_IN);
|
||||||
|
@ -188,7 +188,7 @@ QString subscribers(const CommandContext &ctx)
|
||||||
|
|
||||||
QString subscribersOff(const CommandContext &ctx)
|
QString subscribersOff(const CommandContext &ctx)
|
||||||
{
|
{
|
||||||
auto currentUser = getIApp()->getAccounts()->twitch.getCurrent();
|
auto currentUser = getApp()->getAccounts()->twitch.getCurrent();
|
||||||
if (currentUser->isAnon())
|
if (currentUser->isAnon())
|
||||||
{
|
{
|
||||||
ctx.channel->addSystemMessage(P_NOT_LOGGED_IN);
|
ctx.channel->addSystemMessage(P_NOT_LOGGED_IN);
|
||||||
|
@ -218,7 +218,7 @@ QString subscribersOff(const CommandContext &ctx)
|
||||||
|
|
||||||
QString slow(const CommandContext &ctx)
|
QString slow(const CommandContext &ctx)
|
||||||
{
|
{
|
||||||
auto currentUser = getIApp()->getAccounts()->twitch.getCurrent();
|
auto currentUser = getApp()->getAccounts()->twitch.getCurrent();
|
||||||
if (currentUser->isAnon())
|
if (currentUser->isAnon())
|
||||||
{
|
{
|
||||||
ctx.channel->addSystemMessage(P_NOT_LOGGED_IN);
|
ctx.channel->addSystemMessage(P_NOT_LOGGED_IN);
|
||||||
|
@ -265,7 +265,7 @@ QString slow(const CommandContext &ctx)
|
||||||
|
|
||||||
QString slowOff(const CommandContext &ctx)
|
QString slowOff(const CommandContext &ctx)
|
||||||
{
|
{
|
||||||
auto currentUser = getIApp()->getAccounts()->twitch.getCurrent();
|
auto currentUser = getApp()->getAccounts()->twitch.getCurrent();
|
||||||
if (currentUser->isAnon())
|
if (currentUser->isAnon())
|
||||||
{
|
{
|
||||||
ctx.channel->addSystemMessage(P_NOT_LOGGED_IN);
|
ctx.channel->addSystemMessage(P_NOT_LOGGED_IN);
|
||||||
|
@ -294,7 +294,7 @@ QString slowOff(const CommandContext &ctx)
|
||||||
|
|
||||||
QString followers(const CommandContext &ctx)
|
QString followers(const CommandContext &ctx)
|
||||||
{
|
{
|
||||||
auto currentUser = getIApp()->getAccounts()->twitch.getCurrent();
|
auto currentUser = getApp()->getAccounts()->twitch.getCurrent();
|
||||||
if (currentUser->isAnon())
|
if (currentUser->isAnon())
|
||||||
{
|
{
|
||||||
ctx.channel->addSystemMessage(P_NOT_LOGGED_IN);
|
ctx.channel->addSystemMessage(P_NOT_LOGGED_IN);
|
||||||
|
@ -342,7 +342,7 @@ QString followers(const CommandContext &ctx)
|
||||||
|
|
||||||
QString followersOff(const CommandContext &ctx)
|
QString followersOff(const CommandContext &ctx)
|
||||||
{
|
{
|
||||||
auto currentUser = getIApp()->getAccounts()->twitch.getCurrent();
|
auto currentUser = getApp()->getAccounts()->twitch.getCurrent();
|
||||||
if (currentUser->isAnon())
|
if (currentUser->isAnon())
|
||||||
{
|
{
|
||||||
ctx.channel->addSystemMessage(P_NOT_LOGGED_IN);
|
ctx.channel->addSystemMessage(P_NOT_LOGGED_IN);
|
||||||
|
@ -372,7 +372,7 @@ QString followersOff(const CommandContext &ctx)
|
||||||
|
|
||||||
QString uniqueChat(const CommandContext &ctx)
|
QString uniqueChat(const CommandContext &ctx)
|
||||||
{
|
{
|
||||||
auto currentUser = getIApp()->getAccounts()->twitch.getCurrent();
|
auto currentUser = getApp()->getAccounts()->twitch.getCurrent();
|
||||||
if (currentUser->isAnon())
|
if (currentUser->isAnon())
|
||||||
{
|
{
|
||||||
ctx.channel->addSystemMessage(P_NOT_LOGGED_IN);
|
ctx.channel->addSystemMessage(P_NOT_LOGGED_IN);
|
||||||
|
@ -402,7 +402,7 @@ QString uniqueChat(const CommandContext &ctx)
|
||||||
|
|
||||||
QString uniqueChatOff(const CommandContext &ctx)
|
QString uniqueChatOff(const CommandContext &ctx)
|
||||||
{
|
{
|
||||||
auto currentUser = getIApp()->getAccounts()->twitch.getCurrent();
|
auto currentUser = getApp()->getAccounts()->twitch.getCurrent();
|
||||||
if (currentUser->isAnon())
|
if (currentUser->isAnon())
|
||||||
{
|
{
|
||||||
ctx.channel->addSystemMessage(P_NOT_LOGGED_IN);
|
ctx.channel->addSystemMessage(P_NOT_LOGGED_IN);
|
||||||
|
|
|
@ -77,7 +77,7 @@ QString chatters(const CommandContext &ctx)
|
||||||
// Refresh chatter list via helix api for mods
|
// Refresh chatter list via helix api for mods
|
||||||
getHelix()->getChatters(
|
getHelix()->getChatters(
|
||||||
ctx.twitchChannel->roomId(),
|
ctx.twitchChannel->roomId(),
|
||||||
getIApp()->getAccounts()->twitch.getCurrent()->getUserId(), 1,
|
getApp()->getAccounts()->twitch.getCurrent()->getUserId(), 1,
|
||||||
[channel{ctx.channel}](auto result) {
|
[channel{ctx.channel}](auto result) {
|
||||||
channel->addSystemMessage(QString("Chatter count: %1.")
|
channel->addSystemMessage(QString("Chatter count: %1.")
|
||||||
.arg(localizeNumbers(result.total)));
|
.arg(localizeNumbers(result.total)));
|
||||||
|
@ -106,7 +106,7 @@ QString testChatters(const CommandContext &ctx)
|
||||||
|
|
||||||
getHelix()->getChatters(
|
getHelix()->getChatters(
|
||||||
ctx.twitchChannel->roomId(),
|
ctx.twitchChannel->roomId(),
|
||||||
getIApp()->getAccounts()->twitch.getCurrent()->getUserId(), 5000,
|
getApp()->getAccounts()->twitch.getCurrent()->getUserId(), 5000,
|
||||||
[channel{ctx.channel}, twitchChannel{ctx.twitchChannel}](auto result) {
|
[channel{ctx.channel}, twitchChannel{ctx.twitchChannel}](auto result) {
|
||||||
QStringList entries;
|
QStringList entries;
|
||||||
for (const auto &username : result.chatters)
|
for (const auto &username : result.chatters)
|
||||||
|
|
|
@ -21,7 +21,7 @@ QString deleteMessages(TwitchChannel *twitchChannel, const QString &messageID)
|
||||||
{
|
{
|
||||||
const auto *commandName = messageID.isEmpty() ? "/clear" : "/delete";
|
const auto *commandName = messageID.isEmpty() ? "/clear" : "/delete";
|
||||||
|
|
||||||
auto user = getIApp()->getAccounts()->twitch.getCurrent();
|
auto user = getApp()->getAccounts()->twitch.getCurrent();
|
||||||
|
|
||||||
// Avoid Helix calls without Client ID and/or OAuth Token
|
// Avoid Helix calls without Client ID and/or OAuth Token
|
||||||
if (user->isAnon())
|
if (user->isAnon())
|
||||||
|
|
|
@ -81,7 +81,7 @@ QString getVIPs(const CommandContext &ctx)
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
auto currentUser = getIApp()->getAccounts()->twitch.getCurrent();
|
auto currentUser = getApp()->getAccounts()->twitch.getCurrent();
|
||||||
if (currentUser->isAnon())
|
if (currentUser->isAnon())
|
||||||
{
|
{
|
||||||
ctx.channel->addSystemMessage(
|
ctx.channel->addSystemMessage(
|
||||||
|
|
|
@ -136,7 +136,7 @@ QString startRaid(const CommandContext &ctx)
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
auto currentUser = getIApp()->getAccounts()->twitch.getCurrent();
|
auto currentUser = getApp()->getAccounts()->twitch.getCurrent();
|
||||||
if (currentUser->isAnon())
|
if (currentUser->isAnon())
|
||||||
{
|
{
|
||||||
ctx.channel->addSystemMessage("You must be logged in to start a raid!");
|
ctx.channel->addSystemMessage("You must be logged in to start a raid!");
|
||||||
|
@ -192,7 +192,7 @@ QString cancelRaid(const CommandContext &ctx)
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
auto currentUser = getIApp()->getAccounts()->twitch.getCurrent();
|
auto currentUser = getApp()->getAccounts()->twitch.getCurrent();
|
||||||
if (currentUser->isAnon())
|
if (currentUser->isAnon())
|
||||||
{
|
{
|
||||||
ctx.channel->addSystemMessage(
|
ctx.channel->addSystemMessage(
|
||||||
|
|
|
@ -32,7 +32,7 @@ QString removeModerator(const CommandContext &ctx)
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
auto currentUser = getIApp()->getAccounts()->twitch.getCurrent();
|
auto currentUser = getApp()->getAccounts()->twitch.getCurrent();
|
||||||
if (currentUser->isAnon())
|
if (currentUser->isAnon())
|
||||||
{
|
{
|
||||||
ctx.channel->addSystemMessage(
|
ctx.channel->addSystemMessage(
|
||||||
|
|
|
@ -34,7 +34,7 @@ QString removeVIP(const CommandContext &ctx)
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
auto currentUser = getIApp()->getAccounts()->twitch.getCurrent();
|
auto currentUser = getApp()->getAccounts()->twitch.getCurrent();
|
||||||
if (currentUser->isAnon())
|
if (currentUser->isAnon())
|
||||||
{
|
{
|
||||||
ctx.channel->addSystemMessage(
|
ctx.channel->addSystemMessage(
|
||||||
|
|
|
@ -92,7 +92,7 @@ QString formatWhisperError(HelixWhisperError error, const QString &message)
|
||||||
|
|
||||||
bool appendWhisperMessageWordsLocally(const QStringList &words)
|
bool appendWhisperMessageWordsLocally(const QStringList &words)
|
||||||
{
|
{
|
||||||
auto *app = getIApp();
|
auto *app = getApp();
|
||||||
|
|
||||||
MessageBuilder b;
|
MessageBuilder b;
|
||||||
|
|
||||||
|
@ -102,7 +102,7 @@ bool appendWhisperMessageWordsLocally(const QStringList &words)
|
||||||
MessageElementFlag::Text, MessageColor::Text,
|
MessageElementFlag::Text, MessageColor::Text,
|
||||||
FontStyle::ChatMediumBold);
|
FontStyle::ChatMediumBold);
|
||||||
b.emplace<TextElement>("->", MessageElementFlag::Text,
|
b.emplace<TextElement>("->", MessageElementFlag::Text,
|
||||||
getIApp()->getThemes()->messages.textColors.system);
|
getApp()->getThemes()->messages.textColors.system);
|
||||||
b.emplace<TextElement>(words[1] + ":", MessageElementFlag::Text,
|
b.emplace<TextElement>(words[1] + ":", MessageElementFlag::Text,
|
||||||
MessageColor::Text, FontStyle::ChatMediumBold);
|
MessageColor::Text, FontStyle::ChatMediumBold);
|
||||||
|
|
||||||
|
@ -177,12 +177,12 @@ bool appendWhisperMessageWordsLocally(const QStringList &words)
|
||||||
b->flags.set(MessageFlag::Whisper);
|
b->flags.set(MessageFlag::Whisper);
|
||||||
auto messagexD = b.release();
|
auto messagexD = b.release();
|
||||||
|
|
||||||
getIApp()->getTwitch()->getWhispersChannel()->addMessage(
|
getApp()->getTwitch()->getWhispersChannel()->addMessage(
|
||||||
messagexD, MessageContext::Original);
|
messagexD, MessageContext::Original);
|
||||||
|
|
||||||
if (getSettings()->inlineWhispers &&
|
if (getSettings()->inlineWhispers &&
|
||||||
!(getSettings()->streamerModeSuppressInlineWhispers &&
|
!(getSettings()->streamerModeSuppressInlineWhispers &&
|
||||||
getIApp()->getStreamerMode()->isEnabled()))
|
getApp()->getStreamerMode()->isEnabled()))
|
||||||
{
|
{
|
||||||
app->getTwitchAbstract()->forEachChannel(
|
app->getTwitchAbstract()->forEachChannel(
|
||||||
[&messagexD](ChannelPtr _channel) {
|
[&messagexD](ChannelPtr _channel) {
|
||||||
|
@ -210,7 +210,7 @@ QString sendWhisper(const CommandContext &ctx)
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
auto currentUser = getIApp()->getAccounts()->twitch.getCurrent();
|
auto currentUser = getApp()->getAccounts()->twitch.getCurrent();
|
||||||
if (currentUser->isAnon())
|
if (currentUser->isAnon())
|
||||||
{
|
{
|
||||||
ctx.channel->addSystemMessage(
|
ctx.channel->addSystemMessage(
|
||||||
|
|
|
@ -22,7 +22,7 @@ QString toggleShieldMode(const CommandContext &ctx, bool isActivating)
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
auto user = getIApp()->getAccounts()->twitch.getCurrent();
|
auto user = getApp()->getAccounts()->twitch.getCurrent();
|
||||||
|
|
||||||
// Avoid Helix calls without Client ID and/or OAuth Token
|
// Avoid Helix calls without Client ID and/or OAuth Token
|
||||||
if (user->isAnon())
|
if (user->isAnon())
|
||||||
|
|
|
@ -23,7 +23,7 @@ QString sendShoutout(const CommandContext &ctx)
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
auto currentUser = getIApp()->getAccounts()->twitch.getCurrent();
|
auto currentUser = getApp()->getAccounts()->twitch.getCurrent();
|
||||||
if (currentUser->isAnon())
|
if (currentUser->isAnon())
|
||||||
{
|
{
|
||||||
channel->addSystemMessage("You must be logged in to send shoutout.");
|
channel->addSystemMessage("You must be logged in to send shoutout.");
|
||||||
|
|
|
@ -98,7 +98,7 @@ QString startCommercial(const CommandContext &ctx)
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
auto user = getIApp()->getAccounts()->twitch.getCurrent();
|
auto user = getApp()->getAccounts()->twitch.getCurrent();
|
||||||
|
|
||||||
// Avoid Helix calls without Client ID and/or OAuth Token
|
// Avoid Helix calls without Client ID and/or OAuth Token
|
||||||
if (user->isAnon())
|
if (user->isAnon())
|
||||||
|
|
|
@ -108,7 +108,7 @@ QString unbanUser(const CommandContext &ctx)
|
||||||
|
|
||||||
assert(!actions.value().empty());
|
assert(!actions.value().empty());
|
||||||
|
|
||||||
auto currentUser = getIApp()->getAccounts()->twitch.getCurrent();
|
auto currentUser = getApp()->getAccounts()->twitch.getCurrent();
|
||||||
if (currentUser->isAnon())
|
if (currentUser->isAnon())
|
||||||
{
|
{
|
||||||
ctx.channel->addSystemMessage(
|
ctx.channel->addSystemMessage(
|
||||||
|
|
|
@ -25,7 +25,7 @@ QString updateUserColor(const CommandContext &ctx)
|
||||||
"The /color command only works in Twitch channels.");
|
"The /color command only works in Twitch channels.");
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
auto user = getIApp()->getAccounts()->twitch.getCurrent();
|
auto user = getApp()->getAccounts()->twitch.getCurrent();
|
||||||
|
|
||||||
// Avoid Helix calls without Client ID and/or OAuth Token
|
// Avoid Helix calls without Client ID and/or OAuth Token
|
||||||
if (user->isAnon())
|
if (user->isAnon())
|
||||||
|
|
|
@ -104,7 +104,7 @@ QString sendWarn(const CommandContext &ctx)
|
||||||
|
|
||||||
assert(!actions.value().empty());
|
assert(!actions.value().empty());
|
||||||
|
|
||||||
auto currentUser = getIApp()->getAccounts()->twitch.getCurrent();
|
auto currentUser = getApp()->getAccounts()->twitch.getCurrent();
|
||||||
if (currentUser->isAnon())
|
if (currentUser->isAnon())
|
||||||
{
|
{
|
||||||
ctx.channel->addSystemMessage("You must be logged in to warn someone!");
|
ctx.channel->addSystemMessage("You must be logged in to warn someone!");
|
||||||
|
|
|
@ -39,7 +39,7 @@ void TabCompletionModel::updateResults(const QString &query,
|
||||||
// Try plugins first
|
// Try plugins first
|
||||||
bool done{};
|
bool done{};
|
||||||
std::tie(done, results) =
|
std::tie(done, results) =
|
||||||
getIApp()->getPlugins()->updateCustomCompletions(
|
getApp()->getPlugins()->updateCustomCompletions(
|
||||||
query, fullTextContent, cursorPosition, isFirstWord);
|
query, fullTextContent, cursorPosition, isFirstWord);
|
||||||
if (done)
|
if (done)
|
||||||
{
|
{
|
||||||
|
|
|
@ -71,20 +71,20 @@ void CommandSource::initializeItems()
|
||||||
std::vector<CommandItem> commands;
|
std::vector<CommandItem> commands;
|
||||||
|
|
||||||
#ifdef CHATTERINO_HAVE_PLUGINS
|
#ifdef CHATTERINO_HAVE_PLUGINS
|
||||||
for (const auto &command : getIApp()->getCommands()->pluginCommands())
|
for (const auto &command : getApp()->getCommands()->pluginCommands())
|
||||||
{
|
{
|
||||||
addCommand(command, commands);
|
addCommand(command, commands);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Custom Chatterino commands
|
// Custom Chatterino commands
|
||||||
for (const auto &command : getIApp()->getCommands()->items)
|
for (const auto &command : getApp()->getCommands()->items)
|
||||||
{
|
{
|
||||||
addCommand(command.name, commands);
|
addCommand(command.name, commands);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Default Chatterino commands
|
// Default Chatterino commands
|
||||||
auto x = getIApp()->getCommands()->getDefaultChatterinoCommandList();
|
auto x = getApp()->getCommands()->getDefaultChatterinoCommandList();
|
||||||
for (const auto &command : x)
|
for (const auto &command : x)
|
||||||
{
|
{
|
||||||
addCommand(command, commands);
|
addCommand(command, commands);
|
||||||
|
|
|
@ -88,7 +88,7 @@ void EmoteSource::addToStringList(QStringList &list, size_t maxCount,
|
||||||
|
|
||||||
void EmoteSource::initializeFromChannel(const Channel *channel)
|
void EmoteSource::initializeFromChannel(const Channel *channel)
|
||||||
{
|
{
|
||||||
auto *app = getIApp();
|
auto *app = getApp();
|
||||||
|
|
||||||
std::vector<EmoteItem> emotes;
|
std::vector<EmoteItem> emotes;
|
||||||
const auto *tc = dynamic_cast<const TwitchChannel *>(channel);
|
const auto *tc = dynamic_cast<const TwitchChannel *>(channel);
|
||||||
|
|
|
@ -12,7 +12,7 @@ namespace chatterino::filters {
|
||||||
|
|
||||||
ContextMap buildContextMap(const MessagePtr &m, chatterino::Channel *channel)
|
ContextMap buildContextMap(const MessagePtr &m, chatterino::Channel *channel)
|
||||||
{
|
{
|
||||||
auto watchingChannel = getIApp()->getTwitch()->getWatchingChannel().get();
|
auto watchingChannel = getApp()->getTwitch()->getWatchingChannel().get();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Looking to add a new identifier to filters? Here's what to do:
|
* Looking to add a new identifier to filters? Here's what to do:
|
||||||
|
|
|
@ -53,7 +53,7 @@ void BadgeHighlightModel::getRowFromItem(const HighlightBadge &item,
|
||||||
setFilePathItem(row[Column::SoundPath], item.getSoundUrl());
|
setFilePathItem(row[Column::SoundPath], item.getSoundUrl());
|
||||||
setColorItem(row[Column::Color], *item.getColor());
|
setColorItem(row[Column::Color], *item.getColor());
|
||||||
|
|
||||||
getIApp()->getTwitchBadges()->getBadgeIcon(
|
getApp()->getTwitchBadges()->getBadgeIcon(
|
||||||
item.badgeName(), [item, row](QString /*name*/, const QIconPtr pixmap) {
|
item.badgeName(), [item, row](QString /*name*/, const QIconPtr pixmap) {
|
||||||
row[Column::Badge]->setData(QVariant(*pixmap), Qt::DecorationRole);
|
row[Column::Badge]->setData(QVariant(*pixmap), Qt::DecorationRole);
|
||||||
});
|
});
|
||||||
|
|
|
@ -183,7 +183,7 @@ void rebuildReplyThreadHighlight(Settings &settings,
|
||||||
void rebuildMessageHighlights(Settings &settings,
|
void rebuildMessageHighlights(Settings &settings,
|
||||||
std::vector<HighlightCheck> &checks)
|
std::vector<HighlightCheck> &checks)
|
||||||
{
|
{
|
||||||
auto currentUser = getIApp()->getAccounts()->twitch.getCurrent();
|
auto currentUser = getApp()->getAccounts()->twitch.getCurrent();
|
||||||
QString currentUsername = currentUser->getUserName();
|
QString currentUsername = currentUser->getUserName();
|
||||||
|
|
||||||
if (settings.enableSelfHighlight && !currentUsername.isEmpty() &&
|
if (settings.enableSelfHighlight && !currentUsername.isEmpty() &&
|
||||||
|
@ -442,9 +442,11 @@ std::ostream &operator<<(std::ostream &os, const HighlightResult &result)
|
||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
|
|
||||||
void HighlightController::initialize(Settings &settings,
|
HighlightController::HighlightController(Settings &settings,
|
||||||
const Paths & /*paths*/)
|
AccountController *accounts)
|
||||||
{
|
{
|
||||||
|
assert(accounts != nullptr);
|
||||||
|
|
||||||
this->rebuildListener_.addSetting(settings.enableSelfHighlight);
|
this->rebuildListener_.addSetting(settings.enableSelfHighlight);
|
||||||
this->rebuildListener_.addSetting(settings.enableSelfHighlightSound);
|
this->rebuildListener_.addSetting(settings.enableSelfHighlightSound);
|
||||||
this->rebuildListener_.addSetting(settings.enableSelfHighlightTaskbar);
|
this->rebuildListener_.addSetting(settings.enableSelfHighlightTaskbar);
|
||||||
|
@ -507,12 +509,12 @@ void HighlightController::initialize(Settings &settings,
|
||||||
this->rebuildChecks(settings);
|
this->rebuildChecks(settings);
|
||||||
});
|
});
|
||||||
|
|
||||||
getIApp()->getAccounts()->twitch.currentUserChanged.connect(
|
this->bConnections.emplace_back(
|
||||||
[this, &settings] {
|
accounts->twitch.currentUserChanged.connect([this, &settings] {
|
||||||
qCDebug(chatterinoHighlights)
|
qCDebug(chatterinoHighlights)
|
||||||
<< "Rebuild checks because user swapped accounts";
|
<< "Rebuild checks because user swapped accounts";
|
||||||
this->rebuildChecks(settings);
|
this->rebuildChecks(settings);
|
||||||
});
|
}));
|
||||||
|
|
||||||
this->rebuildChecks(settings);
|
this->rebuildChecks(settings);
|
||||||
}
|
}
|
||||||
|
@ -550,7 +552,7 @@ std::pair<bool, HighlightResult> HighlightController::check(
|
||||||
// Access for checking
|
// Access for checking
|
||||||
const auto checks = this->checks_.accessConst();
|
const auto checks = this->checks_.accessConst();
|
||||||
|
|
||||||
auto currentUser = getIApp()->getAccounts()->twitch.getCurrent();
|
auto currentUser = getApp()->getAccounts()->twitch.getCurrent();
|
||||||
auto self = (senderName == currentUser->getUserName());
|
auto self = (senderName == currentUser->getUserName());
|
||||||
|
|
||||||
for (const auto &check : *checks)
|
for (const auto &check : *checks)
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "common/FlagsEnum.hpp"
|
#include "common/FlagsEnum.hpp"
|
||||||
#include "common/Singleton.hpp"
|
|
||||||
#include "common/UniqueAccess.hpp"
|
#include "common/UniqueAccess.hpp"
|
||||||
|
#include "singletons/Settings.hpp"
|
||||||
|
|
||||||
|
#include <boost/signals2/connection.hpp>
|
||||||
#include <pajlada/settings.hpp>
|
#include <pajlada/settings.hpp>
|
||||||
#include <pajlada/settings/settinglistener.hpp>
|
#include <pajlada/settings/settinglistener.hpp>
|
||||||
#include <QColor>
|
#include <QColor>
|
||||||
|
@ -20,6 +21,7 @@ class Badge;
|
||||||
struct MessageParseArgs;
|
struct MessageParseArgs;
|
||||||
enum class MessageFlag : int64_t;
|
enum class MessageFlag : int64_t;
|
||||||
using MessageFlags = FlagsEnum<MessageFlag>;
|
using MessageFlags = FlagsEnum<MessageFlag>;
|
||||||
|
class AccountController;
|
||||||
|
|
||||||
struct HighlightResult {
|
struct HighlightResult {
|
||||||
HighlightResult(bool _alert, bool _playSound,
|
HighlightResult(bool _alert, bool _playSound,
|
||||||
|
@ -83,10 +85,10 @@ struct HighlightCheck {
|
||||||
Checker cb;
|
Checker cb;
|
||||||
};
|
};
|
||||||
|
|
||||||
class HighlightController final : public Singleton
|
class HighlightController final
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
void initialize(Settings &settings, const Paths &paths) override;
|
HighlightController(Settings &settings, AccountController *accounts);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Checks the given message parameters if it matches our internal checks, and returns a result
|
* @brief Checks the given message parameters if it matches our internal checks, and returns a result
|
||||||
|
@ -108,6 +110,7 @@ private:
|
||||||
|
|
||||||
pajlada::SettingListener rebuildListener_;
|
pajlada::SettingListener rebuildListener_;
|
||||||
pajlada::Signals::SignalHolder signalHolder_;
|
pajlada::Signals::SignalHolder signalHolder_;
|
||||||
|
std::vector<boost::signals2::scoped_connection> bConnections;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace chatterino
|
} // namespace chatterino
|
||||||
|
|
|
@ -519,7 +519,7 @@ void HighlightModel::customRowSetData(const std::vector<QStandardItem *> &row,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
getIApp()->getWindows()->forceLayoutChannelViews();
|
getApp()->getWindows()->forceLayoutChannelViews();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace chatterino
|
} // namespace chatterino
|
||||||
|
|
|
@ -109,7 +109,7 @@ void UserHighlightModel::customRowSetData(
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
getIApp()->getWindows()->forceLayoutChannelViews();
|
getApp()->getWindows()->forceLayoutChannelViews();
|
||||||
}
|
}
|
||||||
|
|
||||||
// row into vector item
|
// row into vector item
|
||||||
|
|
|
@ -58,7 +58,7 @@ std::vector<QString> Hotkey::arguments() const
|
||||||
|
|
||||||
QString Hotkey::getCategory() const
|
QString Hotkey::getCategory() const
|
||||||
{
|
{
|
||||||
return getIApp()->getHotkeys()->categoryDisplayName(this->category_);
|
return getApp()->getHotkeys()->categoryDisplayName(this->category_);
|
||||||
}
|
}
|
||||||
|
|
||||||
Qt::ShortcutContext Hotkey::getContext() const
|
Qt::ShortcutContext Hotkey::getContext() const
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "common/SignalVector.hpp"
|
#include "common/SignalVector.hpp"
|
||||||
#include "common/Singleton.hpp"
|
|
||||||
#include "controllers/hotkeys/HotkeyCategory.hpp"
|
#include "controllers/hotkeys/HotkeyCategory.hpp"
|
||||||
|
|
||||||
#include <pajlada/signals/signal.hpp>
|
#include <pajlada/signals/signal.hpp>
|
||||||
|
@ -18,7 +17,7 @@ class Hotkey;
|
||||||
|
|
||||||
class HotkeyModel;
|
class HotkeyModel;
|
||||||
|
|
||||||
class HotkeyController final : public Singleton
|
class HotkeyController final
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
using HotkeyFunction = std::function<QString(std::vector<QString>)>;
|
using HotkeyFunction = std::function<QString(std::vector<QString>)>;
|
||||||
|
@ -31,7 +30,7 @@ public:
|
||||||
HotkeyMap actionMap,
|
HotkeyMap actionMap,
|
||||||
QWidget *parent);
|
QWidget *parent);
|
||||||
|
|
||||||
void save() override;
|
void save();
|
||||||
std::shared_ptr<Hotkey> getHotkeyByName(QString name);
|
std::shared_ptr<Hotkey> getHotkeyByName(QString name);
|
||||||
/**
|
/**
|
||||||
* @brief returns a QKeySequence that perfoms the actions requested.
|
* @brief returns a QKeySequence that perfoms the actions requested.
|
||||||
|
|
|
@ -32,7 +32,7 @@ bool isIgnoredMessage(IgnoredMessageParameters &¶ms)
|
||||||
{
|
{
|
||||||
auto sourceUserID = params.twitchUserID;
|
auto sourceUserID = params.twitchUserID;
|
||||||
|
|
||||||
bool isBlocked = getIApp()
|
bool isBlocked = getApp()
|
||||||
->getAccounts()
|
->getAccounts()
|
||||||
->twitch.getCurrent()
|
->twitch.getCurrent()
|
||||||
->blockedUserIds()
|
->blockedUserIds()
|
||||||
|
|
|
@ -95,7 +95,7 @@ bool IgnorePhrase::containsEmote() const
|
||||||
{
|
{
|
||||||
if (!this->emotesChecked_)
|
if (!this->emotesChecked_)
|
||||||
{
|
{
|
||||||
const auto &accvec = getIApp()->getAccounts()->twitch.accounts;
|
const auto &accvec = getApp()->getAccounts()->twitch.accounts;
|
||||||
for (const auto &acc : accvec)
|
for (const auto &acc : accvec)
|
||||||
{
|
{
|
||||||
const auto &accemotes = *acc->accessEmotes();
|
const auto &accemotes = *acc->accessEmotes();
|
||||||
|
|
|
@ -17,9 +17,10 @@
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
|
|
||||||
namespace ranges = std::ranges;
|
namespace ranges = std::ranges;
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
||||||
void NotificationController::initialize(Settings &settings, const Paths &paths)
|
NotificationController::NotificationController()
|
||||||
{
|
{
|
||||||
for (const QString &channelName : this->twitchSetting_.getValue())
|
for (const QString &channelName : this->twitchSetting_.getValue())
|
||||||
{
|
{
|
||||||
|
@ -34,14 +35,17 @@ void NotificationController::initialize(Settings &settings, const Paths &paths)
|
||||||
this->channelMap[Platform::Twitch].raw());
|
this->channelMap[Platform::Twitch].raw());
|
||||||
});
|
});
|
||||||
|
|
||||||
this->fetchFakeChannels();
|
|
||||||
|
|
||||||
QObject::connect(&this->liveStatusTimer_, &QTimer::timeout, [this] {
|
QObject::connect(&this->liveStatusTimer_, &QTimer::timeout, [this] {
|
||||||
this->fetchFakeChannels();
|
this->fetchFakeChannels();
|
||||||
});
|
});
|
||||||
this->liveStatusTimer_.start(60 * 1000);
|
this->liveStatusTimer_.start(60 * 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NotificationController::initialize()
|
||||||
|
{
|
||||||
|
this->fetchFakeChannels();
|
||||||
|
}
|
||||||
|
|
||||||
void NotificationController::updateChannelNotification(
|
void NotificationController::updateChannelNotification(
|
||||||
const QString &channelName, Platform p)
|
const QString &channelName, Platform p)
|
||||||
{
|
{
|
||||||
|
@ -92,7 +96,7 @@ void NotificationController::playSound() const
|
||||||
getSettings()->notificationPathSound.getValue())
|
getSettings()->notificationPathSound.getValue())
|
||||||
: QUrl("qrc:/sounds/ping2.wav");
|
: QUrl("qrc:/sounds/ping2.wav");
|
||||||
|
|
||||||
getIApp()->getSound()->play(highlightSoundUrl);
|
getApp()->getSound()->play(highlightSoundUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
NotificationModel *NotificationController::createModel(QObject *parent,
|
NotificationModel *NotificationController::createModel(QObject *parent,
|
||||||
|
@ -109,7 +113,7 @@ void NotificationController::notifyTwitchChannelLive(
|
||||||
bool showNotification =
|
bool showNotification =
|
||||||
!(getSettings()->suppressInitialLiveNotification &&
|
!(getSettings()->suppressInitialLiveNotification &&
|
||||||
payload.isInitialUpdate) &&
|
payload.isInitialUpdate) &&
|
||||||
!(getIApp()->getStreamerMode()->isEnabled() &&
|
!(getApp()->getStreamerMode()->isEnabled() &&
|
||||||
getSettings()->streamerModeSuppressLiveNotifications);
|
getSettings()->streamerModeSuppressLiveNotifications);
|
||||||
bool playedSound = false;
|
bool playedSound = false;
|
||||||
|
|
||||||
|
@ -118,7 +122,7 @@ void NotificationController::notifyTwitchChannelLive(
|
||||||
{
|
{
|
||||||
if (Toasts::isEnabled())
|
if (Toasts::isEnabled())
|
||||||
{
|
{
|
||||||
getIApp()->getToasts()->sendChannelNotification(
|
getApp()->getToasts()->sendChannelNotification(
|
||||||
payload.channelName, payload.title, Platform::Twitch);
|
payload.channelName, payload.title, Platform::Twitch);
|
||||||
}
|
}
|
||||||
if (getSettings()->notificationPlaySound)
|
if (getSettings()->notificationPlaySound)
|
||||||
|
@ -128,7 +132,7 @@ void NotificationController::notifyTwitchChannelLive(
|
||||||
}
|
}
|
||||||
if (getSettings()->notificationFlashTaskbar)
|
if (getSettings()->notificationFlashTaskbar)
|
||||||
{
|
{
|
||||||
getIApp()->getWindows()->sendAlert();
|
getApp()->getWindows()->sendAlert();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -136,7 +140,7 @@ void NotificationController::notifyTwitchChannelLive(
|
||||||
MessageBuilder builder;
|
MessageBuilder builder;
|
||||||
TwitchMessageBuilder::liveMessage(payload.displayName, &builder);
|
TwitchMessageBuilder::liveMessage(payload.displayName, &builder);
|
||||||
builder.message().id = payload.channelId;
|
builder.message().id = payload.channelId;
|
||||||
getIApp()->getTwitch()->getLiveChannel()->addMessage(
|
getApp()->getTwitch()->getLiveChannel()->addMessage(
|
||||||
builder.release(), MessageContext::Original);
|
builder.release(), MessageContext::Original);
|
||||||
|
|
||||||
// Notify on all channels with a ping sound
|
// Notify on all channels with a ping sound
|
||||||
|
@ -152,7 +156,7 @@ void NotificationController::notifyTwitchChannelOffline(const QString &id) const
|
||||||
{
|
{
|
||||||
// "delete" old 'CHANNEL is live' message
|
// "delete" old 'CHANNEL is live' message
|
||||||
LimitedQueueSnapshot<MessagePtr> snapshot =
|
LimitedQueueSnapshot<MessagePtr> snapshot =
|
||||||
getIApp()->getTwitch()->getLiveChannel()->getMessageSnapshot();
|
getApp()->getTwitch()->getLiveChannel()->getMessageSnapshot();
|
||||||
int snapshotLength = static_cast<int>(snapshot.size());
|
int snapshotLength = static_cast<int>(snapshot.size());
|
||||||
|
|
||||||
int end = std::max(0, snapshotLength - 200);
|
int end = std::max(0, snapshotLength - 200);
|
||||||
|
@ -177,7 +181,7 @@ void NotificationController::fetchFakeChannels()
|
||||||
for (size_t i = 0; i < channelMap[Platform::Twitch].raw().size(); i++)
|
for (size_t i = 0; i < channelMap[Platform::Twitch].raw().size(); i++)
|
||||||
{
|
{
|
||||||
const auto &name = channelMap[Platform::Twitch].raw()[i];
|
const auto &name = channelMap[Platform::Twitch].raw()[i];
|
||||||
auto chan = getIApp()->getTwitchAbstract()->getChannelOrEmpty(name);
|
auto chan = getApp()->getTwitchAbstract()->getChannelOrEmpty(name);
|
||||||
if (chan->isEmpty())
|
if (chan->isEmpty())
|
||||||
{
|
{
|
||||||
channels.push_back(name);
|
channels.push_back(name);
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
#include "common/ChatterinoSetting.hpp"
|
#include "common/ChatterinoSetting.hpp"
|
||||||
#include "common/SignalVector.hpp"
|
#include "common/SignalVector.hpp"
|
||||||
#include "common/Singleton.hpp"
|
|
||||||
#include "util/QCompareCaseInsensitive.hpp"
|
#include "util/QCompareCaseInsensitive.hpp"
|
||||||
|
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
@ -19,10 +18,13 @@ enum class Platform : uint8_t {
|
||||||
Twitch, // 0
|
Twitch, // 0
|
||||||
};
|
};
|
||||||
|
|
||||||
class NotificationController final : public Singleton
|
class NotificationController final
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
void initialize(Settings &settings, const Paths &paths) override;
|
NotificationController();
|
||||||
|
|
||||||
|
// Perform an initial load so we don't have to wait for the timer
|
||||||
|
void initialize();
|
||||||
|
|
||||||
bool isChannelNotified(const QString &channelName, Platform p) const;
|
bool isChannelNotified(const QString &channelName, Platform p) const;
|
||||||
void updateChannelNotification(const QString &channelName, Platform p);
|
void updateChannelNotification(const QString &channelName, Platform p);
|
||||||
|
|
|
@ -65,7 +65,7 @@ namespace chatterino::lua::api {
|
||||||
|
|
||||||
int c2_register_command(lua_State *L)
|
int c2_register_command(lua_State *L)
|
||||||
{
|
{
|
||||||
auto *pl = getIApp()->getPlugins()->getPluginByStatePtr(L);
|
auto *pl = getApp()->getPlugins()->getPluginByStatePtr(L);
|
||||||
if (pl == nullptr)
|
if (pl == nullptr)
|
||||||
{
|
{
|
||||||
luaL_error(L, "internal error: no plugin");
|
luaL_error(L, "internal error: no plugin");
|
||||||
|
@ -99,7 +99,7 @@ int c2_register_command(lua_State *L)
|
||||||
|
|
||||||
int c2_register_callback(lua_State *L)
|
int c2_register_callback(lua_State *L)
|
||||||
{
|
{
|
||||||
auto *pl = getIApp()->getPlugins()->getPluginByStatePtr(L);
|
auto *pl = getApp()->getPlugins()->getPluginByStatePtr(L);
|
||||||
if (pl == nullptr)
|
if (pl == nullptr)
|
||||||
{
|
{
|
||||||
luaL_error(L, "internal error: no plugin");
|
luaL_error(L, "internal error: no plugin");
|
||||||
|
@ -133,7 +133,7 @@ int c2_register_callback(lua_State *L)
|
||||||
|
|
||||||
int c2_log(lua_State *L)
|
int c2_log(lua_State *L)
|
||||||
{
|
{
|
||||||
auto *pl = getIApp()->getPlugins()->getPluginByStatePtr(L);
|
auto *pl = getApp()->getPlugins()->getPluginByStatePtr(L);
|
||||||
if (pl == nullptr)
|
if (pl == nullptr)
|
||||||
{
|
{
|
||||||
luaL_error(L, "c2_log: internal error: no plugin?");
|
luaL_error(L, "c2_log: internal error: no plugin?");
|
||||||
|
@ -154,7 +154,7 @@ int c2_log(lua_State *L)
|
||||||
|
|
||||||
int c2_later(lua_State *L)
|
int c2_later(lua_State *L)
|
||||||
{
|
{
|
||||||
auto *pl = getIApp()->getPlugins()->getPluginByStatePtr(L);
|
auto *pl = getApp()->getPlugins()->getPluginByStatePtr(L);
|
||||||
if (pl == nullptr)
|
if (pl == nullptr)
|
||||||
{
|
{
|
||||||
return luaL_error(L, "c2.later: internal error: no plugin?");
|
return luaL_error(L, "c2.later: internal error: no plugin?");
|
||||||
|
@ -257,7 +257,7 @@ int g_load(lua_State *L)
|
||||||
|
|
||||||
int loadfile(lua_State *L, const QString &str)
|
int loadfile(lua_State *L, const QString &str)
|
||||||
{
|
{
|
||||||
auto *pl = getIApp()->getPlugins()->getPluginByStatePtr(L);
|
auto *pl = getApp()->getPlugins()->getPluginByStatePtr(L);
|
||||||
if (pl == nullptr)
|
if (pl == nullptr)
|
||||||
{
|
{
|
||||||
return luaL_error(L, "loadfile: internal error: no plugin?");
|
return luaL_error(L, "loadfile: internal error: no plugin?");
|
||||||
|
@ -307,7 +307,7 @@ int searcherAbsolute(lua_State *L)
|
||||||
name = name.replace('.', QDir::separator());
|
name = name.replace('.', QDir::separator());
|
||||||
|
|
||||||
QString filename;
|
QString filename;
|
||||||
auto *pl = getIApp()->getPlugins()->getPluginByStatePtr(L);
|
auto *pl = getApp()->getPlugins()->getPluginByStatePtr(L);
|
||||||
if (pl == nullptr)
|
if (pl == nullptr)
|
||||||
{
|
{
|
||||||
return luaL_error(L, "searcherAbsolute: internal error: no plugin?");
|
return luaL_error(L, "searcherAbsolute: internal error: no plugin?");
|
||||||
|
@ -348,7 +348,7 @@ int searcherRelative(lua_State *L)
|
||||||
|
|
||||||
int g_print(lua_State *L)
|
int g_print(lua_State *L)
|
||||||
{
|
{
|
||||||
auto *pl = getIApp()->getPlugins()->getPluginByStatePtr(L);
|
auto *pl = getApp()->getPlugins()->getPluginByStatePtr(L);
|
||||||
if (pl == nullptr)
|
if (pl == nullptr)
|
||||||
{
|
{
|
||||||
luaL_error(L, "c2_print: internal error: no plugin?");
|
luaL_error(L, "c2_print: internal error: no plugin?");
|
||||||
|
|
|
@ -197,7 +197,7 @@ bool Plugin::registerCommand(const QString &name, const QString &functionName)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto ok = getIApp()->getCommands()->registerPluginCommand(name);
|
auto ok = getApp()->getCommands()->registerPluginCommand(name);
|
||||||
if (!ok)
|
if (!ok)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -35,10 +35,8 @@ PluginController::PluginController(const Paths &paths_)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void PluginController::initialize(Settings &settings, const Paths &paths)
|
void PluginController::initialize(Settings &settings)
|
||||||
{
|
{
|
||||||
(void)paths;
|
|
||||||
|
|
||||||
// actuallyInitialize will be called by this connection
|
// actuallyInitialize will be called by this connection
|
||||||
settings.pluginsEnabled.connect([this](bool enabled) {
|
settings.pluginsEnabled.connect([this](bool enabled) {
|
||||||
if (enabled)
|
if (enabled)
|
||||||
|
@ -354,7 +352,7 @@ bool PluginController::reload(const QString &id)
|
||||||
}
|
}
|
||||||
for (const auto &[cmd, _] : it->second->ownedCommands)
|
for (const auto &[cmd, _] : it->second->ownedCommands)
|
||||||
{
|
{
|
||||||
getIApp()->getCommands()->unregisterPluginCommand(cmd);
|
getApp()->getCommands()->unregisterPluginCommand(cmd);
|
||||||
}
|
}
|
||||||
it->second->ownedCommands.clear();
|
it->second->ownedCommands.clear();
|
||||||
QDir loadDir = it->second->loadDirectory_;
|
QDir loadDir = it->second->loadDirectory_;
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
#ifdef CHATTERINO_HAVE_PLUGINS
|
#ifdef CHATTERINO_HAVE_PLUGINS
|
||||||
|
|
||||||
# include "common/Singleton.hpp"
|
|
||||||
# include "controllers/commands/CommandContext.hpp"
|
# include "controllers/commands/CommandContext.hpp"
|
||||||
# include "controllers/plugins/Plugin.hpp"
|
# include "controllers/plugins/Plugin.hpp"
|
||||||
|
|
||||||
|
@ -24,14 +23,14 @@ namespace chatterino {
|
||||||
|
|
||||||
class Paths;
|
class Paths;
|
||||||
|
|
||||||
class PluginController : public Singleton
|
class PluginController
|
||||||
{
|
{
|
||||||
const Paths &paths;
|
const Paths &paths;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit PluginController(const Paths &paths_);
|
explicit PluginController(const Paths &paths_);
|
||||||
|
|
||||||
void initialize(Settings &settings, const Paths &paths) override;
|
void initialize(Settings &settings);
|
||||||
|
|
||||||
QString tryExecPluginCommand(const QString &commandName,
|
QString tryExecPluginCommand(const QString &commandName,
|
||||||
const CommandContext &ctx);
|
const CommandContext &ctx);
|
||||||
|
|
|
@ -174,7 +174,7 @@ int ChannelRef::send_message(lua_State *L)
|
||||||
text = text.replace('\n', ' ');
|
text = text.replace('\n', ' ');
|
||||||
if (execcmds)
|
if (execcmds)
|
||||||
{
|
{
|
||||||
text = getIApp()->getCommands()->execCommand(text, that, false);
|
text = getApp()->getCommands()->execCommand(text, that, false);
|
||||||
}
|
}
|
||||||
that->sendMessage(text);
|
that->sendMessage(text);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -300,7 +300,7 @@ int ChannelRef::get_by_name(lua_State *L)
|
||||||
lua_pushnil(L);
|
lua_pushnil(L);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
auto chn = getIApp()->getTwitchAbstract()->getChannelOrEmpty(name);
|
auto chn = getApp()->getTwitchAbstract()->getChannelOrEmpty(name);
|
||||||
lua::push(L, chn);
|
lua::push(L, chn);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -324,7 +324,7 @@ int ChannelRef::get_by_twitch_id(lua_State *L)
|
||||||
lua_pushnil(L);
|
lua_pushnil(L);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
auto chn = getIApp()->getTwitch()->getChannelOrEmptyByID(id);
|
auto chn = getApp()->getTwitch()->getChannelOrEmptyByID(id);
|
||||||
|
|
||||||
lua::push(L, chn);
|
lua::push(L, chn);
|
||||||
return 1;
|
return 1;
|
||||||
|
|
|
@ -309,7 +309,7 @@ int HTTPRequest::create(lua_State *L)
|
||||||
L, "cannot get method (1st argument of HTTPRequest.create, "
|
L, "cannot get method (1st argument of HTTPRequest.create, "
|
||||||
"expected a string)");
|
"expected a string)");
|
||||||
}
|
}
|
||||||
auto *pl = getIApp()->getPlugins()->getPluginByStatePtr(L);
|
auto *pl = getApp()->getPlugins()->getPluginByStatePtr(L);
|
||||||
if (!pl->hasHTTPPermissionFor(parsedurl))
|
if (!pl->hasHTTPPermissionFor(parsedurl))
|
||||||
{
|
{
|
||||||
return luaL_error(
|
return luaL_error(
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "common/Singleton.hpp"
|
|
||||||
#include "util/QStringHash.hpp"
|
#include "util/QStringHash.hpp"
|
||||||
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
@ -26,7 +25,7 @@ public:
|
||||||
virtual void add(const std::shared_ptr<TwitchChannel> &newChannel) = 0;
|
virtual void add(const std::shared_ptr<TwitchChannel> &newChannel) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
class TwitchLiveController : public ITwitchLiveController, public Singleton
|
class TwitchLiveController : public ITwitchLiveController
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
// Controls how often all channels have their stream status refreshed
|
// Controls how often all channels have their stream status refreshed
|
||||||
|
|
|
@ -50,7 +50,7 @@ Frames::Frames(QList<Frame> &&frames)
|
||||||
DebugCount::increase("animated images");
|
DebugCount::increase("animated images");
|
||||||
|
|
||||||
this->gifTimerConnection_ =
|
this->gifTimerConnection_ =
|
||||||
getIApp()->getEmotes()->getGIFTimer().signal.connect([this] {
|
getApp()->getEmotes()->getGIFTimer().signal.connect([this] {
|
||||||
this->advance();
|
this->advance();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -67,7 +67,7 @@ Frames::Frames(QList<Frame> &&frames)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this->durationOffset_ = std::min<int>(
|
this->durationOffset_ = std::min<int>(
|
||||||
int(getIApp()->getEmotes()->getGIFTimer().position() % totalLength),
|
int(getApp()->getEmotes()->getGIFTimer().position() % totalLength),
|
||||||
60000);
|
60000);
|
||||||
}
|
}
|
||||||
this->processOffset();
|
this->processOffset();
|
||||||
|
@ -242,7 +242,7 @@ void assignFrames(std::weak_ptr<Image> weak, QList<Frame> parsed)
|
||||||
isPushQueued = true;
|
isPushQueued = true;
|
||||||
postToThread([] {
|
postToThread([] {
|
||||||
isPushQueued = false;
|
isPushQueued = false;
|
||||||
getIApp()->getWindows()->forceLayoutChannelViews();
|
getApp()->getWindows()->forceLayoutChannelViews();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -203,7 +203,7 @@ MessageBuilder::MessageBuilder(TimeoutMessageTag, const QString &username,
|
||||||
MessageBuilder::MessageBuilder(const BanAction &action, uint32_t count)
|
MessageBuilder::MessageBuilder(const BanAction &action, uint32_t count)
|
||||||
: MessageBuilder()
|
: MessageBuilder()
|
||||||
{
|
{
|
||||||
auto current = getIApp()->getAccounts()->twitch.getCurrent();
|
auto current = getApp()->getAccounts()->twitch.getCurrent();
|
||||||
|
|
||||||
this->emplace<TimestampElement>();
|
this->emplace<TimestampElement>();
|
||||||
this->message().flags.set(MessageFlag::System);
|
this->message().flags.set(MessageFlag::System);
|
||||||
|
@ -676,7 +676,7 @@ void MessageBuilder::addLink(const linkparser::Parsed &parsedLink,
|
||||||
MessageElementFlag::Text, this->textColor_);
|
MessageElementFlag::Text, this->textColor_);
|
||||||
}
|
}
|
||||||
|
|
||||||
getIApp()->getLinkResolver()->resolve(el->linkInfo());
|
getApp()->getLinkResolver()->resolve(el->linkInfo());
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessageBuilder::addIrcMessageText(const QString &text)
|
void MessageBuilder::addIrcMessageText(const QString &text)
|
||||||
|
@ -686,7 +686,7 @@ void MessageBuilder::addIrcMessageText(const QString &text)
|
||||||
auto words = text.split(' ');
|
auto words = text.split(' ');
|
||||||
MessageColor defaultColorType = MessageColor::Text;
|
MessageColor defaultColorType = MessageColor::Text;
|
||||||
const auto &defaultColor =
|
const auto &defaultColor =
|
||||||
defaultColorType.getColor(*getIApp()->getThemes());
|
defaultColorType.getColor(*getApp()->getThemes());
|
||||||
QColor textColor = defaultColor;
|
QColor textColor = defaultColor;
|
||||||
int fg = -1;
|
int fg = -1;
|
||||||
int bg = -1;
|
int bg = -1;
|
||||||
|
@ -728,7 +728,7 @@ void MessageBuilder::addIrcMessageText(const QString &text)
|
||||||
if (fg >= 0 && fg <= 98)
|
if (fg >= 0 && fg <= 98)
|
||||||
{
|
{
|
||||||
textColor = IRC_COLORS[fg];
|
textColor = IRC_COLORS[fg];
|
||||||
getIApp()->getThemes()->normalizeColor(textColor);
|
getApp()->getThemes()->normalizeColor(textColor);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -768,7 +768,7 @@ void MessageBuilder::addIrcMessageText(const QString &text)
|
||||||
if (fg >= 0 && fg <= 98)
|
if (fg >= 0 && fg <= 98)
|
||||||
{
|
{
|
||||||
textColor = IRC_COLORS[fg];
|
textColor = IRC_COLORS[fg];
|
||||||
getIApp()->getThemes()->normalizeColor(textColor);
|
getApp()->getThemes()->normalizeColor(textColor);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -810,7 +810,7 @@ void MessageBuilder::addIrcWord(const QString &text, const QColor &color,
|
||||||
bool addSpace)
|
bool addSpace)
|
||||||
{
|
{
|
||||||
this->textColor_ = color;
|
this->textColor_ = color;
|
||||||
for (auto &variant : getIApp()->getEmotes()->getEmojis()->parse(text))
|
for (auto &variant : getApp()->getEmotes()->getEmojis()->parse(text))
|
||||||
{
|
{
|
||||||
boost::apply_visitor(
|
boost::apply_visitor(
|
||||||
[&](auto &&arg) {
|
[&](auto &&arg) {
|
||||||
|
|
|
@ -454,7 +454,7 @@ TextElement::TextElement(const QString &text, MessageElementFlags flags,
|
||||||
void TextElement::addToContainer(MessageLayoutContainer &container,
|
void TextElement::addToContainer(MessageLayoutContainer &container,
|
||||||
MessageElementFlags flags)
|
MessageElementFlags flags)
|
||||||
{
|
{
|
||||||
auto *app = getIApp();
|
auto *app = getApp();
|
||||||
|
|
||||||
if (flags.hasAny(this->getFlags()))
|
if (flags.hasAny(this->getFlags()))
|
||||||
{
|
{
|
||||||
|
@ -566,7 +566,7 @@ SingleLineTextElement::SingleLineTextElement(const QString &text,
|
||||||
void SingleLineTextElement::addToContainer(MessageLayoutContainer &container,
|
void SingleLineTextElement::addToContainer(MessageLayoutContainer &container,
|
||||||
MessageElementFlags flags)
|
MessageElementFlags flags)
|
||||||
{
|
{
|
||||||
auto *app = getIApp();
|
auto *app = getApp();
|
||||||
|
|
||||||
if (flags.hasAny(this->getFlags()))
|
if (flags.hasAny(this->getFlags()))
|
||||||
{
|
{
|
||||||
|
|
|
@ -156,7 +156,7 @@ void SharedMessageBuilder::parseHighlights()
|
||||||
}
|
}
|
||||||
|
|
||||||
auto badges = SharedMessageBuilder::parseBadgeTag(this->tags);
|
auto badges = SharedMessageBuilder::parseBadgeTag(this->tags);
|
||||||
auto [highlighted, highlightResult] = getIApp()->getHighlights()->check(
|
auto [highlighted, highlightResult] = getApp()->getHighlights()->check(
|
||||||
this->args, badges, this->message().loginName, this->originalMessage_,
|
this->args, badges, this->message().loginName, this->originalMessage_,
|
||||||
this->message().flags);
|
this->message().flags);
|
||||||
|
|
||||||
|
@ -203,7 +203,7 @@ void SharedMessageBuilder::triggerHighlights(
|
||||||
const QString &channelName, bool playSound,
|
const QString &channelName, bool playSound,
|
||||||
const std::optional<QUrl> &customSoundUrl, bool windowAlert)
|
const std::optional<QUrl> &customSoundUrl, bool windowAlert)
|
||||||
{
|
{
|
||||||
if (getIApp()->getStreamerMode()->isEnabled() &&
|
if (getApp()->getStreamerMode()->isEnabled() &&
|
||||||
getSettings()->streamerModeMuteMentions)
|
getSettings()->streamerModeMuteMentions)
|
||||||
{
|
{
|
||||||
// We are in streamer mode with muting mention sounds enabled. Do nothing.
|
// We are in streamer mode with muting mention sounds enabled. Do nothing.
|
||||||
|
@ -232,12 +232,12 @@ void SharedMessageBuilder::triggerHighlights(
|
||||||
{
|
{
|
||||||
soundUrl = getFallbackHighlightSound();
|
soundUrl = getFallbackHighlightSound();
|
||||||
}
|
}
|
||||||
getIApp()->getSound()->play(soundUrl);
|
getApp()->getSound()->play(soundUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (windowAlert)
|
if (windowAlert)
|
||||||
{
|
{
|
||||||
getIApp()->getWindows()->sendAlert();
|
getApp()->getWindows()->sendAlert();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -88,7 +88,7 @@ bool MessageLayout::layout(int width, float scale, float imageScale,
|
||||||
this->currentLayoutWidth_ = width;
|
this->currentLayoutWidth_ = width;
|
||||||
|
|
||||||
// check if layout state changed
|
// check if layout state changed
|
||||||
const auto layoutGeneration = getIApp()->getWindows()->getGeneration();
|
const auto layoutGeneration = getApp()->getWindows()->getGeneration();
|
||||||
if (this->layoutState_ != layoutGeneration)
|
if (this->layoutState_ != layoutGeneration)
|
||||||
{
|
{
|
||||||
layoutRequired = true;
|
layoutRequired = true;
|
||||||
|
@ -166,7 +166,7 @@ void MessageLayout::actuallyLayout(int width, MessageElementFlags flags)
|
||||||
{
|
{
|
||||||
if (hideModerationActions ||
|
if (hideModerationActions ||
|
||||||
(getSettings()->streamerModeHideModActions &&
|
(getSettings()->streamerModeHideModActions &&
|
||||||
getIApp()->getStreamerMode()->isEnabled()))
|
getApp()->getStreamerMode()->isEnabled()))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,7 +48,7 @@ void MessageLayoutContainer::beginLayout(int width, float scale,
|
||||||
this->imageScale_ = imageScale;
|
this->imageScale_ = imageScale;
|
||||||
this->flags_ = flags;
|
this->flags_ = flags;
|
||||||
auto mediumFontMetrics =
|
auto mediumFontMetrics =
|
||||||
getIApp()->getFonts()->getFontMetrics(FontStyle::ChatMedium, scale);
|
getApp()->getFonts()->getFontMetrics(FontStyle::ChatMedium, scale);
|
||||||
this->textLineHeight_ = mediumFontMetrics.height();
|
this->textLineHeight_ = mediumFontMetrics.height();
|
||||||
this->spaceWidth_ = mediumFontMetrics.horizontalAdvance(' ');
|
this->spaceWidth_ = mediumFontMetrics.horizontalAdvance(' ');
|
||||||
this->dotdotdotWidth_ = mediumFontMetrics.horizontalAdvance("...");
|
this->dotdotdotWidth_ = mediumFontMetrics.horizontalAdvance("...");
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#include "FfzBadges.hpp"
|
#include "providers/ffz/FfzBadges.hpp"
|
||||||
|
|
||||||
#include "common/network/NetworkRequest.hpp"
|
#include "common/network/NetworkRequest.hpp"
|
||||||
#include "common/network/NetworkResult.hpp"
|
#include "common/network/NetworkResult.hpp"
|
||||||
|
@ -17,11 +17,6 @@
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
||||||
void FfzBadges::initialize(Settings &settings, const Paths &paths)
|
|
||||||
{
|
|
||||||
this->load();
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<FfzBadges::Badge> FfzBadges::getUserBadges(const UserId &id)
|
std::vector<FfzBadges::Badge> FfzBadges::getUserBadges(const UserId &id)
|
||||||
{
|
{
|
||||||
std::vector<Badge> badges;
|
std::vector<Badge> badges;
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "common/Aliases.hpp"
|
#include "common/Aliases.hpp"
|
||||||
#include "common/Singleton.hpp"
|
|
||||||
#include "util/QStringHash.hpp"
|
#include "util/QStringHash.hpp"
|
||||||
#include "util/ThreadGuard.hpp"
|
#include "util/ThreadGuard.hpp"
|
||||||
|
|
||||||
|
@ -19,10 +18,9 @@ namespace chatterino {
|
||||||
struct Emote;
|
struct Emote;
|
||||||
using EmotePtr = std::shared_ptr<const Emote>;
|
using EmotePtr = std::shared_ptr<const Emote>;
|
||||||
|
|
||||||
class FfzBadges : public Singleton
|
class FfzBadges
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
void initialize(Settings &settings, const Paths &paths) override;
|
|
||||||
FfzBadges() = default;
|
FfzBadges() = default;
|
||||||
|
|
||||||
struct Badge {
|
struct Badge {
|
||||||
|
@ -33,9 +31,9 @@ public:
|
||||||
std::vector<Badge> getUserBadges(const UserId &id);
|
std::vector<Badge> getUserBadges(const UserId &id);
|
||||||
std::optional<Badge> getBadge(int badgeID) const;
|
std::optional<Badge> getBadge(int badgeID) const;
|
||||||
|
|
||||||
private:
|
|
||||||
void load();
|
void load();
|
||||||
|
|
||||||
|
private:
|
||||||
std::shared_mutex mutex_;
|
std::shared_mutex mutex_;
|
||||||
|
|
||||||
// userBadges points a user ID to the list of badges they have
|
// userBadges points a user ID to the list of badges they have
|
||||||
|
|
|
@ -22,7 +22,7 @@ namespace {
|
||||||
|
|
||||||
QString configPath()
|
QString configPath()
|
||||||
{
|
{
|
||||||
return combinePath(getIApp()->getPaths().settingsDirectory, "irc.json");
|
return combinePath(getApp()->getPaths().settingsDirectory, "irc.json");
|
||||||
}
|
}
|
||||||
|
|
||||||
class Model : public SignalVectorModel<IrcServerData>
|
class Model : public SignalVectorModel<IrcServerData>
|
||||||
|
|
|
@ -245,7 +245,7 @@ void IrcServer::privateMessageReceived(Communi::IrcPrivateMessage *message)
|
||||||
|
|
||||||
if (highlighted && showInMentions)
|
if (highlighted && showInMentions)
|
||||||
{
|
{
|
||||||
getIApp()->getTwitch()->getMentionsChannel()->addMessage(
|
getApp()->getTwitch()->getMentionsChannel()->addMessage(
|
||||||
msg, MessageContext::Original);
|
msg, MessageContext::Original);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "common/Singleton.hpp"
|
|
||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
|
||||||
class QString;
|
class QString;
|
||||||
|
@ -11,7 +9,7 @@ namespace chatterino {
|
||||||
|
|
||||||
class NetworkResult;
|
class NetworkResult;
|
||||||
|
|
||||||
class SeventvAPI : public Singleton
|
class SeventvAPI final
|
||||||
{
|
{
|
||||||
using ErrorCallback = std::function<void(const NetworkResult &)>;
|
using ErrorCallback = std::function<void(const NetworkResult &)>;
|
||||||
template <typename... T>
|
template <typename... T>
|
||||||
|
@ -19,7 +17,7 @@ class SeventvAPI : public Singleton
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SeventvAPI() = default;
|
SeventvAPI() = default;
|
||||||
~SeventvAPI() override = default;
|
~SeventvAPI() = default;
|
||||||
|
|
||||||
SeventvAPI(const SeventvAPI &) = delete;
|
SeventvAPI(const SeventvAPI &) = delete;
|
||||||
SeventvAPI(SeventvAPI &&) = delete;
|
SeventvAPI(SeventvAPI &&) = delete;
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "common/Aliases.hpp"
|
#include "common/Aliases.hpp"
|
||||||
#include "common/Singleton.hpp"
|
|
||||||
#include "util/QStringHash.hpp"
|
#include "util/QStringHash.hpp"
|
||||||
|
|
||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
|
@ -16,7 +15,7 @@ namespace chatterino {
|
||||||
struct Emote;
|
struct Emote;
|
||||||
using EmotePtr = std::shared_ptr<const Emote>;
|
using EmotePtr = std::shared_ptr<const Emote>;
|
||||||
|
|
||||||
class SeventvBadges : public Singleton
|
class SeventvBadges
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
// Return the badge, if any, that is assigned to the user
|
// Return the badge, if any, that is assigned to the user
|
||||||
|
|
|
@ -217,7 +217,7 @@ void SeventvEmotes::loadGlobalEmotes()
|
||||||
|
|
||||||
qCDebug(chatterinoSeventv) << "Loading 7TV Global Emotes";
|
qCDebug(chatterinoSeventv) << "Loading 7TV Global Emotes";
|
||||||
|
|
||||||
getIApp()->getSeventvAPI()->getEmoteSet(
|
getApp()->getSeventvAPI()->getEmoteSet(
|
||||||
u"global"_s,
|
u"global"_s,
|
||||||
[this](const auto &json) {
|
[this](const auto &json) {
|
||||||
QJsonArray parsedEmotes = json["emotes"].toArray();
|
QJsonArray parsedEmotes = json["emotes"].toArray();
|
||||||
|
@ -246,7 +246,7 @@ void SeventvEmotes::loadChannelEmotes(
|
||||||
qCDebug(chatterinoSeventv)
|
qCDebug(chatterinoSeventv)
|
||||||
<< "Reloading 7TV Channel Emotes" << channelId << manualRefresh;
|
<< "Reloading 7TV Channel Emotes" << channelId << manualRefresh;
|
||||||
|
|
||||||
getIApp()->getSeventvAPI()->getUserByTwitchID(
|
getApp()->getSeventvAPI()->getUserByTwitchID(
|
||||||
channelId,
|
channelId,
|
||||||
[callback = std::move(callback), channel, channelId,
|
[callback = std::move(callback), channel, channelId,
|
||||||
manualRefresh](const auto &json) {
|
manualRefresh](const auto &json) {
|
||||||
|
@ -405,7 +405,7 @@ void SeventvEmotes::getEmoteSet(
|
||||||
{
|
{
|
||||||
qCDebug(chatterinoSeventv) << "Loading 7TV Emote Set" << emoteSetId;
|
qCDebug(chatterinoSeventv) << "Loading 7TV Emote Set" << emoteSetId;
|
||||||
|
|
||||||
getIApp()->getSeventvAPI()->getEmoteSet(
|
getApp()->getSeventvAPI()->getEmoteSet(
|
||||||
emoteSetId,
|
emoteSetId,
|
||||||
[callback = std::move(successCallback), emoteSetId](const auto &json) {
|
[callback = std::move(successCallback), emoteSetId](const auto &json) {
|
||||||
auto parsedEmotes = json["emotes"].toArray();
|
auto parsedEmotes = json["emotes"].toArray();
|
||||||
|
|
|
@ -348,7 +348,7 @@ void SeventvEventAPI::onUserUpdate(const Dispatch &dispatch)
|
||||||
|
|
||||||
void SeventvEventAPI::onCosmeticCreate(const CosmeticCreateDispatch &cosmetic)
|
void SeventvEventAPI::onCosmeticCreate(const CosmeticCreateDispatch &cosmetic)
|
||||||
{
|
{
|
||||||
auto *badges = getIApp()->getSeventvBadges();
|
auto *badges = getApp()->getSeventvBadges();
|
||||||
switch (cosmetic.kind)
|
switch (cosmetic.kind)
|
||||||
{
|
{
|
||||||
case CosmeticKind::Badge: {
|
case CosmeticKind::Badge: {
|
||||||
|
@ -363,7 +363,7 @@ void SeventvEventAPI::onCosmeticCreate(const CosmeticCreateDispatch &cosmetic)
|
||||||
void SeventvEventAPI::onEntitlementCreate(
|
void SeventvEventAPI::onEntitlementCreate(
|
||||||
const EntitlementCreateDeleteDispatch &entitlement)
|
const EntitlementCreateDeleteDispatch &entitlement)
|
||||||
{
|
{
|
||||||
auto *badges = getIApp()->getSeventvBadges();
|
auto *badges = getApp()->getSeventvBadges();
|
||||||
switch (entitlement.kind)
|
switch (entitlement.kind)
|
||||||
{
|
{
|
||||||
case CosmeticKind::Badge: {
|
case CosmeticKind::Badge: {
|
||||||
|
@ -379,7 +379,7 @@ void SeventvEventAPI::onEntitlementCreate(
|
||||||
void SeventvEventAPI::onEntitlementDelete(
|
void SeventvEventAPI::onEntitlementDelete(
|
||||||
const EntitlementCreateDeleteDispatch &entitlement)
|
const EntitlementCreateDeleteDispatch &entitlement)
|
||||||
{
|
{
|
||||||
auto *badges = getIApp()->getSeventvBadges();
|
auto *badges = getApp()->getSeventvBadges();
|
||||||
switch (entitlement.kind)
|
switch (entitlement.kind)
|
||||||
{
|
{
|
||||||
case CosmeticKind::Badge: {
|
case CosmeticKind::Badge: {
|
||||||
|
|
|
@ -132,7 +132,7 @@ void updateReplyParticipatedStatus(const QVariantMap &tags,
|
||||||
bool isNew)
|
bool isNew)
|
||||||
{
|
{
|
||||||
const auto ¤tLogin =
|
const auto ¤tLogin =
|
||||||
getIApp()->getAccounts()->twitch.getCurrent()->getUserName();
|
getApp()->getAccounts()->twitch.getCurrent()->getUserName();
|
||||||
|
|
||||||
if (thread->subscribed())
|
if (thread->subscribed())
|
||||||
{
|
{
|
||||||
|
@ -390,7 +390,7 @@ std::vector<MessagePtr> parseNoticeMessage(Communi::IrcNoticeMessage *message)
|
||||||
{
|
{
|
||||||
const auto linkColor = MessageColor(MessageColor::Link);
|
const auto linkColor = MessageColor(MessageColor::Link);
|
||||||
const auto accountsLink = Link(Link::OpenAccountsPage, QString());
|
const auto accountsLink = Link(Link::OpenAccountsPage, QString());
|
||||||
const auto curUser = getIApp()->getAccounts()->twitch.getCurrent();
|
const auto curUser = getApp()->getAccounts()->twitch.getCurrent();
|
||||||
const auto expirationText = QString("Login expired for user \"%1\"!")
|
const auto expirationText = QString("Login expired for user \"%1\"!")
|
||||||
.arg(curUser->getUserName());
|
.arg(curUser->getUserName());
|
||||||
const auto loginPromptText = QString("Try adding your account again.");
|
const auto loginPromptText = QString("Try adding your account again.");
|
||||||
|
@ -692,7 +692,7 @@ void IrcMessageHandler::handlePrivMessage(Communi::IrcPrivateMessage *message,
|
||||||
|
|
||||||
if (twitchChannel != nullptr)
|
if (twitchChannel != nullptr)
|
||||||
{
|
{
|
||||||
auto currentUser = getIApp()->getAccounts()->twitch.getCurrent();
|
auto currentUser = getApp()->getAccounts()->twitch.getCurrent();
|
||||||
if (message->tag("user-id") == currentUser->getUserId())
|
if (message->tag("user-id") == currentUser->getUserId())
|
||||||
{
|
{
|
||||||
auto badgesTag = message->tag("badges");
|
auto badgesTag = message->tag("badges");
|
||||||
|
@ -736,7 +736,7 @@ void IrcMessageHandler::handleRoomStateMessage(Communi::IrcMessage *message)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto chan = getIApp()->getTwitchAbstract()->getChannelOrEmpty(chanName);
|
auto chan = getApp()->getTwitchAbstract()->getChannelOrEmpty(chanName);
|
||||||
|
|
||||||
auto *twitchChannel = dynamic_cast<TwitchChannel *>(chan.get());
|
auto *twitchChannel = dynamic_cast<TwitchChannel *>(chan.get());
|
||||||
if (!twitchChannel)
|
if (!twitchChannel)
|
||||||
|
@ -798,7 +798,7 @@ void IrcMessageHandler::handleClearChatMessage(Communi::IrcMessage *message)
|
||||||
}
|
}
|
||||||
|
|
||||||
// get channel
|
// get channel
|
||||||
auto chan = getIApp()->getTwitchAbstract()->getChannelOrEmpty(chanName);
|
auto chan = getApp()->getTwitchAbstract()->getChannelOrEmpty(chanName);
|
||||||
|
|
||||||
if (chan->isEmpty())
|
if (chan->isEmpty())
|
||||||
{
|
{
|
||||||
|
@ -821,10 +821,10 @@ void IrcMessageHandler::handleClearChatMessage(Communi::IrcMessage *message)
|
||||||
chan->addOrReplaceTimeout(std::move(clearChat.message));
|
chan->addOrReplaceTimeout(std::move(clearChat.message));
|
||||||
|
|
||||||
// refresh all
|
// refresh all
|
||||||
getIApp()->getWindows()->repaintVisibleChatWidgets(chan.get());
|
getApp()->getWindows()->repaintVisibleChatWidgets(chan.get());
|
||||||
if (getSettings()->hideModerated)
|
if (getSettings()->hideModerated)
|
||||||
{
|
{
|
||||||
getIApp()->getWindows()->forceLayoutChannelViews();
|
getApp()->getWindows()->forceLayoutChannelViews();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -843,7 +843,7 @@ void IrcMessageHandler::handleClearMessageMessage(Communi::IrcMessage *message)
|
||||||
}
|
}
|
||||||
|
|
||||||
// get channel
|
// get channel
|
||||||
auto chan = getIApp()->getTwitchAbstract()->getChannelOrEmpty(chanName);
|
auto chan = getApp()->getTwitchAbstract()->getChannelOrEmpty(chanName);
|
||||||
|
|
||||||
if (chan->isEmpty())
|
if (chan->isEmpty())
|
||||||
{
|
{
|
||||||
|
@ -875,7 +875,7 @@ void IrcMessageHandler::handleClearMessageMessage(Communi::IrcMessage *message)
|
||||||
|
|
||||||
void IrcMessageHandler::handleUserStateMessage(Communi::IrcMessage *message)
|
void IrcMessageHandler::handleUserStateMessage(Communi::IrcMessage *message)
|
||||||
{
|
{
|
||||||
auto currentUser = getIApp()->getAccounts()->twitch.getCurrent();
|
auto currentUser = getApp()->getAccounts()->twitch.getCurrent();
|
||||||
|
|
||||||
// set received emote-sets, used in TwitchAccount::loadUserstateEmotes
|
// set received emote-sets, used in TwitchAccount::loadUserstateEmotes
|
||||||
bool emoteSetsChanged = currentUser->setUserstateEmoteSets(
|
bool emoteSetsChanged = currentUser->setUserstateEmoteSets(
|
||||||
|
@ -892,7 +892,7 @@ void IrcMessageHandler::handleUserStateMessage(Communi::IrcMessage *message)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto c = getIApp()->getTwitchAbstract()->getChannelOrEmpty(channelName);
|
auto c = getApp()->getTwitchAbstract()->getChannelOrEmpty(channelName);
|
||||||
if (c->isEmpty())
|
if (c->isEmpty())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
|
@ -927,7 +927,7 @@ void IrcMessageHandler::handleUserStateMessage(Communi::IrcMessage *message)
|
||||||
void IrcMessageHandler::handleGlobalUserStateMessage(
|
void IrcMessageHandler::handleGlobalUserStateMessage(
|
||||||
Communi::IrcMessage *message)
|
Communi::IrcMessage *message)
|
||||||
{
|
{
|
||||||
auto currentUser = getIApp()->getAccounts()->twitch.getCurrent();
|
auto currentUser = getApp()->getAccounts()->twitch.getCurrent();
|
||||||
|
|
||||||
// set received emote-sets, this time used to initially load emotes
|
// set received emote-sets, this time used to initially load emotes
|
||||||
// NOTE: this should always return true unless we reconnect
|
// NOTE: this should always return true unless we reconnect
|
||||||
|
@ -947,7 +947,7 @@ void IrcMessageHandler::handleWhisperMessage(Communi::IrcMessage *ircMessage)
|
||||||
|
|
||||||
args.isReceivedWhisper = true;
|
args.isReceivedWhisper = true;
|
||||||
|
|
||||||
auto *c = getIApp()->getTwitch()->getWhispersChannel().get();
|
auto *c = getApp()->getTwitch()->getWhispersChannel().get();
|
||||||
|
|
||||||
TwitchMessageBuilder builder(
|
TwitchMessageBuilder builder(
|
||||||
c, ircMessage, args,
|
c, ircMessage, args,
|
||||||
|
@ -963,11 +963,11 @@ void IrcMessageHandler::handleWhisperMessage(Communi::IrcMessage *ircMessage)
|
||||||
MessagePtr message = builder.build();
|
MessagePtr message = builder.build();
|
||||||
builder.triggerHighlights();
|
builder.triggerHighlights();
|
||||||
|
|
||||||
getIApp()->getTwitch()->setLastUserThatWhisperedMe(builder.userName);
|
getApp()->getTwitch()->setLastUserThatWhisperedMe(builder.userName);
|
||||||
|
|
||||||
if (message->flags.has(MessageFlag::ShowInMentions))
|
if (message->flags.has(MessageFlag::ShowInMentions))
|
||||||
{
|
{
|
||||||
getIApp()->getTwitch()->getMentionsChannel()->addMessage(
|
getApp()->getTwitch()->getMentionsChannel()->addMessage(
|
||||||
message, MessageContext::Original);
|
message, MessageContext::Original);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -979,13 +979,12 @@ void IrcMessageHandler::handleWhisperMessage(Communi::IrcMessage *ircMessage)
|
||||||
|
|
||||||
if (getSettings()->inlineWhispers &&
|
if (getSettings()->inlineWhispers &&
|
||||||
!(getSettings()->streamerModeSuppressInlineWhispers &&
|
!(getSettings()->streamerModeSuppressInlineWhispers &&
|
||||||
getIApp()->getStreamerMode()->isEnabled()))
|
getApp()->getStreamerMode()->isEnabled()))
|
||||||
{
|
{
|
||||||
getIApp()->getTwitchAbstract()->forEachChannel(
|
getApp()->getTwitchAbstract()->forEachChannel([&message, overrideFlags](
|
||||||
[&message, overrideFlags](ChannelPtr channel) {
|
ChannelPtr channel) {
|
||||||
channel->addMessage(message, MessageContext::Repost,
|
channel->addMessage(message, MessageContext::Repost, overrideFlags);
|
||||||
overrideFlags);
|
});
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1118,7 +1117,7 @@ void IrcMessageHandler::handleNoticeMessage(Communi::IrcNoticeMessage *message)
|
||||||
{
|
{
|
||||||
// Notice wasn't targeted at a single channel, send to all twitch
|
// Notice wasn't targeted at a single channel, send to all twitch
|
||||||
// channels
|
// channels
|
||||||
getIApp()->getTwitch()->forEachChannelAndSpecialChannels(
|
getApp()->getTwitch()->forEachChannelAndSpecialChannels(
|
||||||
[msg](const auto &c) {
|
[msg](const auto &c) {
|
||||||
c->addMessage(msg, MessageContext::Original);
|
c->addMessage(msg, MessageContext::Original);
|
||||||
});
|
});
|
||||||
|
@ -1127,7 +1126,7 @@ void IrcMessageHandler::handleNoticeMessage(Communi::IrcNoticeMessage *message)
|
||||||
}
|
}
|
||||||
|
|
||||||
auto channel =
|
auto channel =
|
||||||
getIApp()->getTwitchAbstract()->getChannelOrEmpty(channelName);
|
getApp()->getTwitchAbstract()->getChannelOrEmpty(channelName);
|
||||||
|
|
||||||
if (channel->isEmpty())
|
if (channel->isEmpty())
|
||||||
{
|
{
|
||||||
|
@ -1210,7 +1209,7 @@ void IrcMessageHandler::handleNoticeMessage(Communi::IrcNoticeMessage *message)
|
||||||
|
|
||||||
void IrcMessageHandler::handleJoinMessage(Communi::IrcMessage *message)
|
void IrcMessageHandler::handleJoinMessage(Communi::IrcMessage *message)
|
||||||
{
|
{
|
||||||
auto channel = getIApp()->getTwitchAbstract()->getChannelOrEmpty(
|
auto channel = getApp()->getTwitchAbstract()->getChannelOrEmpty(
|
||||||
message->parameter(0).remove(0, 1));
|
message->parameter(0).remove(0, 1));
|
||||||
|
|
||||||
auto *twitchChannel = dynamic_cast<TwitchChannel *>(channel.get());
|
auto *twitchChannel = dynamic_cast<TwitchChannel *>(channel.get());
|
||||||
|
@ -1220,7 +1219,7 @@ void IrcMessageHandler::handleJoinMessage(Communi::IrcMessage *message)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (message->nick() ==
|
if (message->nick() ==
|
||||||
getIApp()->getAccounts()->twitch.getCurrent()->getUserName())
|
getApp()->getAccounts()->twitch.getCurrent()->getUserName())
|
||||||
{
|
{
|
||||||
twitchChannel->addSystemMessage("joined channel");
|
twitchChannel->addSystemMessage("joined channel");
|
||||||
twitchChannel->joined.invoke();
|
twitchChannel->joined.invoke();
|
||||||
|
@ -1233,7 +1232,7 @@ void IrcMessageHandler::handleJoinMessage(Communi::IrcMessage *message)
|
||||||
|
|
||||||
void IrcMessageHandler::handlePartMessage(Communi::IrcMessage *message)
|
void IrcMessageHandler::handlePartMessage(Communi::IrcMessage *message)
|
||||||
{
|
{
|
||||||
auto channel = getIApp()->getTwitchAbstract()->getChannelOrEmpty(
|
auto channel = getApp()->getTwitchAbstract()->getChannelOrEmpty(
|
||||||
message->parameter(0).remove(0, 1));
|
message->parameter(0).remove(0, 1));
|
||||||
|
|
||||||
auto *twitchChannel = dynamic_cast<TwitchChannel *>(channel.get());
|
auto *twitchChannel = dynamic_cast<TwitchChannel *>(channel.get());
|
||||||
|
@ -1243,7 +1242,7 @@ void IrcMessageHandler::handlePartMessage(Communi::IrcMessage *message)
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto selfAccountName =
|
const auto selfAccountName =
|
||||||
getIApp()->getAccounts()->twitch.getCurrent()->getUserName();
|
getApp()->getAccounts()->twitch.getCurrent()->getUserName();
|
||||||
if (message->nick() != selfAccountName &&
|
if (message->nick() != selfAccountName &&
|
||||||
getSettings()->showParts.getValue())
|
getSettings()->showParts.getValue())
|
||||||
{
|
{
|
||||||
|
@ -1296,7 +1295,7 @@ void IrcMessageHandler::setSimilarityFlags(const MessagePtr &message,
|
||||||
{
|
{
|
||||||
bool isMyself =
|
bool isMyself =
|
||||||
message->loginName ==
|
message->loginName ==
|
||||||
getIApp()->getAccounts()->twitch.getCurrent()->getUserName();
|
getApp()->getAccounts()->twitch.getCurrent()->getUserName();
|
||||||
bool hideMyself = getSettings()->hideSimilarMyself;
|
bool hideMyself = getSettings()->hideSimilarMyself;
|
||||||
|
|
||||||
if (isMyself && !hideMyself)
|
if (isMyself && !hideMyself)
|
||||||
|
|
|
@ -109,7 +109,7 @@ void TwitchAccount::loadBlocks()
|
||||||
this->ignoresUserIds_.clear();
|
this->ignoresUserIds_.clear();
|
||||||
|
|
||||||
getHelix()->loadBlocks(
|
getHelix()->loadBlocks(
|
||||||
getIApp()->getAccounts()->twitch.getCurrent()->userId_,
|
getApp()->getAccounts()->twitch.getCurrent()->userId_,
|
||||||
[this](const std::vector<HelixBlock> &blocks) {
|
[this](const std::vector<HelixBlock> &blocks) {
|
||||||
assertInGuiThread();
|
assertInGuiThread();
|
||||||
|
|
||||||
|
@ -325,7 +325,7 @@ void TwitchAccount::loadUserstateEmotes(std::weak_ptr<Channel> weakChannel)
|
||||||
|
|
||||||
emoteSet->emotes.push_back(TwitchEmote{id, code});
|
emoteSet->emotes.push_back(TwitchEmote{id, code});
|
||||||
|
|
||||||
auto emote = getIApp()
|
auto emote = getApp()
|
||||||
->getEmotes()
|
->getEmotes()
|
||||||
->getTwitchEmotes()
|
->getTwitchEmotes()
|
||||||
->getOrCreateEmote(id, code);
|
->getOrCreateEmote(id, code);
|
||||||
|
@ -493,7 +493,7 @@ void TwitchAccount::loadSeventvUserID()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto *seventv = getIApp()->getSeventvAPI();
|
auto *seventv = getApp()->getSeventvAPI();
|
||||||
if (!seventv)
|
if (!seventv)
|
||||||
{
|
{
|
||||||
qCWarning(chatterinoSeventv)
|
qCWarning(chatterinoSeventv)
|
||||||
|
|
|
@ -91,7 +91,7 @@ TwitchChannel::TwitchChannel(const QString &name)
|
||||||
qCDebug(chatterinoTwitch) << "[TwitchChannel" << name << "] Opened";
|
qCDebug(chatterinoTwitch) << "[TwitchChannel" << name << "] Opened";
|
||||||
|
|
||||||
this->bSignals_.emplace_back(
|
this->bSignals_.emplace_back(
|
||||||
getIApp()->getAccounts()->twitch.currentUserChanged.connect([this] {
|
getApp()->getAccounts()->twitch.currentUserChanged.connect([this] {
|
||||||
this->setMod(false);
|
this->setMod(false);
|
||||||
this->refreshPubSub();
|
this->refreshPubSub();
|
||||||
}));
|
}));
|
||||||
|
@ -143,18 +143,18 @@ TwitchChannel::TwitchChannel(const QString &name)
|
||||||
|
|
||||||
TwitchChannel::~TwitchChannel()
|
TwitchChannel::~TwitchChannel()
|
||||||
{
|
{
|
||||||
getIApp()->getTwitch()->dropSeventvChannel(this->seventvUserID_,
|
getApp()->getTwitch()->dropSeventvChannel(this->seventvUserID_,
|
||||||
this->seventvEmoteSetID_);
|
this->seventvEmoteSetID_);
|
||||||
|
|
||||||
if (getIApp()->getTwitch()->getBTTVLiveUpdates())
|
if (getApp()->getTwitch()->getBTTVLiveUpdates())
|
||||||
{
|
{
|
||||||
getIApp()->getTwitch()->getBTTVLiveUpdates()->partChannel(
|
getApp()->getTwitch()->getBTTVLiveUpdates()->partChannel(
|
||||||
this->roomId());
|
this->roomId());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getIApp()->getTwitch()->getSeventvEventAPI())
|
if (getApp()->getTwitch()->getSeventvEventAPI())
|
||||||
{
|
{
|
||||||
getIApp()->getTwitch()->getSeventvEventAPI()->unsubscribeTwitchChannel(
|
getApp()->getTwitch()->getSeventvEventAPI()->unsubscribeTwitchChannel(
|
||||||
this->roomId());
|
this->roomId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -332,7 +332,7 @@ void TwitchChannel::addChannelPointReward(const ChannelPointReward &reward)
|
||||||
<< "] Channel point reward added:" << reward.id << ","
|
<< "] Channel point reward added:" << reward.id << ","
|
||||||
<< reward.title << "," << reward.isUserInputRequired;
|
<< reward.title << "," << reward.isUserInputRequired;
|
||||||
|
|
||||||
auto *server = getIApp()->getTwitch();
|
auto *server = getApp()->getTwitch();
|
||||||
auto it = std::remove_if(
|
auto it = std::remove_if(
|
||||||
this->waitingRedemptions_.begin(), this->waitingRedemptions_.end(),
|
this->waitingRedemptions_.begin(), this->waitingRedemptions_.end(),
|
||||||
[&](const QueuedRedemption &msg) {
|
[&](const QueuedRedemption &msg) {
|
||||||
|
@ -426,7 +426,7 @@ void TwitchChannel::onLiveStatusChanged(bool isLive, bool isInitialUpdate)
|
||||||
qCDebug(chatterinoTwitch).nospace().noquote()
|
qCDebug(chatterinoTwitch).nospace().noquote()
|
||||||
<< "[TwitchChannel " << this->getName() << "] Online";
|
<< "[TwitchChannel " << this->getName() << "] Online";
|
||||||
|
|
||||||
getIApp()->getNotifications()->notifyTwitchChannelLive({
|
getApp()->getNotifications()->notifyTwitchChannelLive({
|
||||||
.channelId = this->roomId(),
|
.channelId = this->roomId(),
|
||||||
.channelName = this->getName(),
|
.channelName = this->getName(),
|
||||||
.displayName = this->getDisplayName(),
|
.displayName = this->getDisplayName(),
|
||||||
|
@ -452,7 +452,7 @@ void TwitchChannel::onLiveStatusChanged(bool isLive, bool isInitialUpdate)
|
||||||
&builder);
|
&builder);
|
||||||
this->addMessage(builder.release(), MessageContext::Original);
|
this->addMessage(builder.release(), MessageContext::Original);
|
||||||
|
|
||||||
getIApp()->getNotifications()->notifyTwitchChannelOffline(
|
getApp()->getNotifications()->notifyTwitchChannelOffline(
|
||||||
this->roomId());
|
this->roomId());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -509,7 +509,7 @@ void TwitchChannel::showLoginMessage()
|
||||||
{
|
{
|
||||||
const auto linkColor = MessageColor(MessageColor::Link);
|
const auto linkColor = MessageColor(MessageColor::Link);
|
||||||
const auto accountsLink = Link(Link::OpenAccountsPage, QString());
|
const auto accountsLink = Link(Link::OpenAccountsPage, QString());
|
||||||
const auto currentUser = getIApp()->getAccounts()->twitch.getCurrent();
|
const auto currentUser = getApp()->getAccounts()->twitch.getCurrent();
|
||||||
const auto expirationText =
|
const auto expirationText =
|
||||||
QStringLiteral("You need to log in to send messages. You can link your "
|
QStringLiteral("You need to log in to send messages. You can link your "
|
||||||
"Twitch account");
|
"Twitch account");
|
||||||
|
@ -532,7 +532,7 @@ void TwitchChannel::showLoginMessage()
|
||||||
|
|
||||||
void TwitchChannel::roomIdChanged()
|
void TwitchChannel::roomIdChanged()
|
||||||
{
|
{
|
||||||
if (getIApp()->isTest())
|
if (getApp()->isTest())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -544,7 +544,7 @@ void TwitchChannel::roomIdChanged()
|
||||||
this->refreshSevenTVChannelEmotes(false);
|
this->refreshSevenTVChannelEmotes(false);
|
||||||
this->joinBttvChannel();
|
this->joinBttvChannel();
|
||||||
this->listenSevenTVCosmetics();
|
this->listenSevenTVCosmetics();
|
||||||
getIApp()->getTwitchLiveController()->add(
|
getApp()->getTwitchLiveController()->add(
|
||||||
std::dynamic_pointer_cast<TwitchChannel>(shared_from_this()));
|
std::dynamic_pointer_cast<TwitchChannel>(shared_from_this()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -710,7 +710,7 @@ void TwitchChannel::setStaff(bool value)
|
||||||
|
|
||||||
bool TwitchChannel::isBroadcaster() const
|
bool TwitchChannel::isBroadcaster() const
|
||||||
{
|
{
|
||||||
auto *app = getIApp();
|
auto *app = getApp();
|
||||||
|
|
||||||
return this->getName() ==
|
return this->getName() ==
|
||||||
app->getAccounts()->twitch.getCurrent()->getUserName();
|
app->getAccounts()->twitch.getCurrent()->getUserName();
|
||||||
|
@ -728,7 +728,7 @@ bool TwitchChannel::canReconnect() const
|
||||||
|
|
||||||
void TwitchChannel::reconnect()
|
void TwitchChannel::reconnect()
|
||||||
{
|
{
|
||||||
getIApp()->getTwitchAbstract()->connect();
|
getApp()->getTwitchAbstract()->connect();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString TwitchChannel::getCurrentStreamID() const
|
QString TwitchChannel::getCurrentStreamID() const
|
||||||
|
@ -753,7 +753,7 @@ void TwitchChannel::setRoomId(const QString &id)
|
||||||
{
|
{
|
||||||
*this->roomID_.access() = id;
|
*this->roomID_.access() = id;
|
||||||
// This is intended for tests and benchmarks. See comment in constructor.
|
// This is intended for tests and benchmarks. See comment in constructor.
|
||||||
if (!getIApp()->isTest())
|
if (!getApp()->isTest())
|
||||||
{
|
{
|
||||||
this->roomIdChanged();
|
this->roomIdChanged();
|
||||||
this->loadRecentMessages();
|
this->loadRecentMessages();
|
||||||
|
@ -854,17 +854,17 @@ const QString &TwitchChannel::seventvEmoteSetID() const
|
||||||
|
|
||||||
void TwitchChannel::joinBttvChannel() const
|
void TwitchChannel::joinBttvChannel() const
|
||||||
{
|
{
|
||||||
if (getIApp()->getTwitch()->getBTTVLiveUpdates())
|
if (getApp()->getTwitch()->getBTTVLiveUpdates())
|
||||||
{
|
{
|
||||||
const auto currentAccount =
|
const auto currentAccount =
|
||||||
getIApp()->getAccounts()->twitch.getCurrent();
|
getApp()->getAccounts()->twitch.getCurrent();
|
||||||
QString userName;
|
QString userName;
|
||||||
if (currentAccount && !currentAccount->isAnon())
|
if (currentAccount && !currentAccount->isAnon())
|
||||||
{
|
{
|
||||||
userName = currentAccount->getUserName();
|
userName = currentAccount->getUserName();
|
||||||
}
|
}
|
||||||
getIApp()->getTwitch()->getBTTVLiveUpdates()->joinChannel(
|
getApp()->getTwitch()->getBTTVLiveUpdates()->joinChannel(this->roomId(),
|
||||||
this->roomId(), userName);
|
userName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1012,14 +1012,14 @@ void TwitchChannel::updateSeventvData(const QString &newUserID,
|
||||||
this->seventvUserID_ = newUserID;
|
this->seventvUserID_ = newUserID;
|
||||||
this->seventvEmoteSetID_ = newEmoteSetID;
|
this->seventvEmoteSetID_ = newEmoteSetID;
|
||||||
runInGuiThread([this, oldUserID, oldEmoteSetID]() {
|
runInGuiThread([this, oldUserID, oldEmoteSetID]() {
|
||||||
if (getIApp()->getTwitch()->getSeventvEventAPI())
|
if (getApp()->getTwitch()->getSeventvEventAPI())
|
||||||
{
|
{
|
||||||
getIApp()->getTwitch()->getSeventvEventAPI()->subscribeUser(
|
getApp()->getTwitch()->getSeventvEventAPI()->subscribeUser(
|
||||||
this->seventvUserID_, this->seventvEmoteSetID_);
|
this->seventvUserID_, this->seventvEmoteSetID_);
|
||||||
|
|
||||||
if (oldUserID || oldEmoteSetID)
|
if (oldUserID || oldEmoteSetID)
|
||||||
{
|
{
|
||||||
getIApp()->getTwitch()->dropSeventvChannel(
|
getApp()->getTwitch()->dropSeventvChannel(
|
||||||
oldUserID.value_or(QString()),
|
oldUserID.value_or(QString()),
|
||||||
oldEmoteSetID.value_or(QString()));
|
oldEmoteSetID.value_or(QString()));
|
||||||
}
|
}
|
||||||
|
@ -1215,7 +1215,7 @@ void TwitchChannel::loadRecentMessages()
|
||||||
tc->addRecentChatter(msg->displayName);
|
tc->addRecentChatter(msg->displayName);
|
||||||
}
|
}
|
||||||
|
|
||||||
getIApp()->getTwitch()->getMentionsChannel()->fillInMissingMessages(
|
getApp()->getTwitch()->getMentionsChannel()->fillInMissingMessages(
|
||||||
msgs);
|
msgs);
|
||||||
},
|
},
|
||||||
[weak]() {
|
[weak]() {
|
||||||
|
@ -1303,7 +1303,7 @@ void TwitchChannel::loadRecentMessagesReconnect()
|
||||||
|
|
||||||
void TwitchChannel::refreshPubSub()
|
void TwitchChannel::refreshPubSub()
|
||||||
{
|
{
|
||||||
if (getIApp()->isTest())
|
if (getApp()->isTest())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1314,17 +1314,17 @@ void TwitchChannel::refreshPubSub()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto currentAccount = getIApp()->getAccounts()->twitch.getCurrent();
|
auto currentAccount = getApp()->getAccounts()->twitch.getCurrent();
|
||||||
|
|
||||||
getIApp()->getTwitchPubSub()->setAccount(currentAccount);
|
getApp()->getTwitchPubSub()->setAccount(currentAccount);
|
||||||
|
|
||||||
getIApp()->getTwitchPubSub()->listenToChannelModerationActions(roomId);
|
getApp()->getTwitchPubSub()->listenToChannelModerationActions(roomId);
|
||||||
if (this->hasModRights())
|
if (this->hasModRights())
|
||||||
{
|
{
|
||||||
getIApp()->getTwitchPubSub()->listenToAutomod(roomId);
|
getApp()->getTwitchPubSub()->listenToAutomod(roomId);
|
||||||
getIApp()->getTwitchPubSub()->listenToLowTrustUsers(roomId);
|
getApp()->getTwitchPubSub()->listenToLowTrustUsers(roomId);
|
||||||
}
|
}
|
||||||
getIApp()->getTwitchPubSub()->listenToChannelPointRewards(roomId);
|
getApp()->getTwitchPubSub()->listenToChannelPointRewards(roomId);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TwitchChannel::refreshChatters()
|
void TwitchChannel::refreshChatters()
|
||||||
|
@ -1350,7 +1350,7 @@ void TwitchChannel::refreshChatters()
|
||||||
// Get chatter list via helix api
|
// Get chatter list via helix api
|
||||||
getHelix()->getChatters(
|
getHelix()->getChatters(
|
||||||
this->roomId(),
|
this->roomId(),
|
||||||
getIApp()->getAccounts()->twitch.getCurrent()->getUserId(),
|
getApp()->getAccounts()->twitch.getCurrent()->getUserId(),
|
||||||
MAX_CHATTERS_TO_FETCH,
|
MAX_CHATTERS_TO_FETCH,
|
||||||
[this, weak = weakOf<Channel>(this)](auto result) {
|
[this, weak = weakOf<Channel>(this)](auto result) {
|
||||||
if (auto shared = weak.lock())
|
if (auto shared = weak.lock())
|
||||||
|
@ -1710,7 +1710,7 @@ std::vector<FfzBadges::Badge> TwitchChannel::ffzChannelBadges(
|
||||||
|
|
||||||
std::vector<FfzBadges::Badge> badges;
|
std::vector<FfzBadges::Badge> badges;
|
||||||
|
|
||||||
const auto *ffzBadges = getIApp()->getFfzBadges();
|
const auto *ffzBadges = getApp()->getFfzBadges();
|
||||||
|
|
||||||
for (const auto &badgeID : it->second)
|
for (const auto &badgeID : it->second)
|
||||||
{
|
{
|
||||||
|
@ -1769,7 +1769,7 @@ void TwitchChannel::updateSevenTVActivity()
|
||||||
QStringLiteral("https://7tv.io/v3/users/%1/presences");
|
QStringLiteral("https://7tv.io/v3/users/%1/presences");
|
||||||
|
|
||||||
const auto currentSeventvUserID =
|
const auto currentSeventvUserID =
|
||||||
getIApp()->getAccounts()->twitch.getCurrent()->getSeventvUserID();
|
getApp()->getAccounts()->twitch.getCurrent()->getSeventvUserID();
|
||||||
if (currentSeventvUserID.isEmpty())
|
if (currentSeventvUserID.isEmpty())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
|
@ -1791,7 +1791,7 @@ void TwitchChannel::updateSevenTVActivity()
|
||||||
|
|
||||||
qCDebug(chatterinoSeventv) << "Sending activity in" << this->getName();
|
qCDebug(chatterinoSeventv) << "Sending activity in" << this->getName();
|
||||||
|
|
||||||
getIApp()->getSeventvAPI()->updatePresence(
|
getApp()->getSeventvAPI()->updatePresence(
|
||||||
this->roomId(), currentSeventvUserID,
|
this->roomId(), currentSeventvUserID,
|
||||||
[chan = weakOf<Channel>(this)]() {
|
[chan = weakOf<Channel>(this)]() {
|
||||||
const auto self =
|
const auto self =
|
||||||
|
@ -1811,9 +1811,9 @@ void TwitchChannel::updateSevenTVActivity()
|
||||||
|
|
||||||
void TwitchChannel::listenSevenTVCosmetics() const
|
void TwitchChannel::listenSevenTVCosmetics() const
|
||||||
{
|
{
|
||||||
if (getIApp()->getTwitch()->getSeventvEventAPI())
|
if (getApp()->getTwitch()->getSeventvEventAPI())
|
||||||
{
|
{
|
||||||
getIApp()->getTwitch()->getSeventvEventAPI()->subscribeTwitchChannel(
|
getApp()->getTwitch()->getSeventvEventAPI()->subscribeTwitchChannel(
|
||||||
this->roomId());
|
this->roomId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,7 +51,7 @@ void sendHelixMessage(const std::shared_ptr<TwitchChannel> &channel,
|
||||||
{
|
{
|
||||||
.broadcasterID = broadcasterID,
|
.broadcasterID = broadcasterID,
|
||||||
.senderID =
|
.senderID =
|
||||||
getIApp()->getAccounts()->twitch.getCurrent()->getUserId(),
|
getApp()->getAccounts()->twitch.getCurrent()->getUserId(),
|
||||||
.message = message,
|
.message = message,
|
||||||
.replyParentMessageID = replyParentId,
|
.replyParentMessageID = replyParentId,
|
||||||
},
|
},
|
||||||
|
@ -167,7 +167,7 @@ TwitchIrcServer::TwitchIrcServer()
|
||||||
|
|
||||||
void TwitchIrcServer::initialize()
|
void TwitchIrcServer::initialize()
|
||||||
{
|
{
|
||||||
getIApp()->getAccounts()->twitch.currentUserChanged.connect([this]() {
|
getApp()->getAccounts()->twitch.currentUserChanged.connect([this]() {
|
||||||
postToThread([this] {
|
postToThread([this] {
|
||||||
this->connect();
|
this->connect();
|
||||||
});
|
});
|
||||||
|
@ -182,7 +182,7 @@ void TwitchIrcServer::initializeConnection(IrcConnection *connection,
|
||||||
ConnectionType type)
|
ConnectionType type)
|
||||||
{
|
{
|
||||||
std::shared_ptr<TwitchAccount> account =
|
std::shared_ptr<TwitchAccount> account =
|
||||||
getIApp()->getAccounts()->twitch.getCurrent();
|
getApp()->getAccounts()->twitch.getCurrent();
|
||||||
|
|
||||||
qCDebug(chatterinoTwitch) << "logging in as" << account->getUserName();
|
qCDebug(chatterinoTwitch) << "logging in as" << account->getUserName();
|
||||||
|
|
||||||
|
@ -690,7 +690,7 @@ void TwitchIrcServer::setLastUserThatWhisperedMe(const QString &user)
|
||||||
|
|
||||||
void TwitchIrcServer::reloadBTTVGlobalEmotes()
|
void TwitchIrcServer::reloadBTTVGlobalEmotes()
|
||||||
{
|
{
|
||||||
getIApp()->getBttvEmotes()->loadEmotes();
|
getApp()->getBttvEmotes()->loadEmotes();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TwitchIrcServer::reloadAllBTTVChannelEmotes()
|
void TwitchIrcServer::reloadAllBTTVChannelEmotes()
|
||||||
|
@ -705,7 +705,7 @@ void TwitchIrcServer::reloadAllBTTVChannelEmotes()
|
||||||
|
|
||||||
void TwitchIrcServer::reloadFFZGlobalEmotes()
|
void TwitchIrcServer::reloadFFZGlobalEmotes()
|
||||||
{
|
{
|
||||||
getIApp()->getFfzEmotes()->loadEmotes();
|
getApp()->getFfzEmotes()->loadEmotes();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TwitchIrcServer::reloadAllFFZChannelEmotes()
|
void TwitchIrcServer::reloadAllFFZChannelEmotes()
|
||||||
|
@ -720,7 +720,7 @@ void TwitchIrcServer::reloadAllFFZChannelEmotes()
|
||||||
|
|
||||||
void TwitchIrcServer::reloadSevenTVGlobalEmotes()
|
void TwitchIrcServer::reloadSevenTVGlobalEmotes()
|
||||||
{
|
{
|
||||||
getIApp()->getSeventvEmotes()->loadGlobalEmotes();
|
getApp()->getSeventvEmotes()->loadGlobalEmotes();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TwitchIrcServer::reloadAllSevenTVChannelEmotes()
|
void TwitchIrcServer::reloadAllSevenTVChannelEmotes()
|
||||||
|
|
|
@ -92,7 +92,7 @@ namespace {
|
||||||
const QString &originalMessage,
|
const QString &originalMessage,
|
||||||
int messageOffset)
|
int messageOffset)
|
||||||
{
|
{
|
||||||
auto *app = getIApp();
|
auto *app = getApp();
|
||||||
if (!emote.contains(':'))
|
if (!emote.contains(':'))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
|
@ -167,7 +167,7 @@ namespace {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (auto globalBadge =
|
if (auto globalBadge =
|
||||||
getIApp()->getTwitchBadges()->badge(badge.key_, badge.value_))
|
getApp()->getTwitchBadges()->badge(badge.key_, badge.value_))
|
||||||
{
|
{
|
||||||
return globalBadge;
|
return globalBadge;
|
||||||
}
|
}
|
||||||
|
@ -673,7 +673,7 @@ void TwitchMessageBuilder::addWords(
|
||||||
// 1. Add text before the emote
|
// 1. Add text before the emote
|
||||||
QString preText = word.left(currentTwitchEmote.start - cursor);
|
QString preText = word.left(currentTwitchEmote.start - cursor);
|
||||||
for (auto &variant :
|
for (auto &variant :
|
||||||
getIApp()->getEmotes()->getEmojis()->parse(preText))
|
getApp()->getEmotes()->getEmojis()->parse(preText))
|
||||||
{
|
{
|
||||||
boost::apply_visitor(
|
boost::apply_visitor(
|
||||||
[&](auto &&arg) {
|
[&](auto &&arg) {
|
||||||
|
@ -693,7 +693,7 @@ void TwitchMessageBuilder::addWords(
|
||||||
}
|
}
|
||||||
|
|
||||||
// split words
|
// split words
|
||||||
for (auto &variant : getIApp()->getEmotes()->getEmojis()->parse(word))
|
for (auto &variant : getApp()->getEmotes()->getEmojis()->parse(word))
|
||||||
{
|
{
|
||||||
boost::apply_visitor(
|
boost::apply_visitor(
|
||||||
[&](auto &&arg) {
|
[&](auto &&arg) {
|
||||||
|
@ -937,7 +937,7 @@ void TwitchMessageBuilder::parseThread()
|
||||||
|
|
||||||
void TwitchMessageBuilder::parseUsernameColor()
|
void TwitchMessageBuilder::parseUsernameColor()
|
||||||
{
|
{
|
||||||
const auto *userData = getIApp()->getUserData();
|
const auto *userData = getApp()->getUserData();
|
||||||
assert(userData != nullptr);
|
assert(userData != nullptr);
|
||||||
|
|
||||||
if (const auto &user = userData->getUser(this->userId_))
|
if (const auto &user = userData->getUser(this->userId_))
|
||||||
|
@ -991,7 +991,7 @@ void TwitchMessageBuilder::parseUsername()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update current user color if this is our message
|
// Update current user color if this is our message
|
||||||
auto currentUser = getIApp()->getAccounts()->twitch.getCurrent();
|
auto currentUser = getApp()->getAccounts()->twitch.getCurrent();
|
||||||
if (this->ircMessage->nick() == currentUser->getUserName())
|
if (this->ircMessage->nick() == currentUser->getUserName())
|
||||||
{
|
{
|
||||||
currentUser->setColor(this->usernameColor_);
|
currentUser->setColor(this->usernameColor_);
|
||||||
|
@ -1000,7 +1000,7 @@ void TwitchMessageBuilder::parseUsername()
|
||||||
|
|
||||||
void TwitchMessageBuilder::appendUsername()
|
void TwitchMessageBuilder::appendUsername()
|
||||||
{
|
{
|
||||||
auto *app = getIApp();
|
auto *app = getApp();
|
||||||
|
|
||||||
QString username = this->userName;
|
QString username = this->userName;
|
||||||
this->message().loginName = username;
|
this->message().loginName = username;
|
||||||
|
@ -1256,7 +1256,7 @@ void TwitchMessageBuilder::processIgnorePhrases(
|
||||||
|
|
||||||
Outcome TwitchMessageBuilder::tryAppendEmote(const EmoteName &name)
|
Outcome TwitchMessageBuilder::tryAppendEmote(const EmoteName &name)
|
||||||
{
|
{
|
||||||
auto *app = getIApp();
|
auto *app = getApp();
|
||||||
|
|
||||||
const auto *globalBttvEmotes = app->getBttvEmotes();
|
const auto *globalBttvEmotes = app->getBttvEmotes();
|
||||||
const auto *globalFfzEmotes = app->getFfzEmotes();
|
const auto *globalFfzEmotes = app->getFfzEmotes();
|
||||||
|
@ -1410,8 +1410,7 @@ void TwitchMessageBuilder::appendTwitchBadges()
|
||||||
|
|
||||||
void TwitchMessageBuilder::appendChatterinoBadges()
|
void TwitchMessageBuilder::appendChatterinoBadges()
|
||||||
{
|
{
|
||||||
if (auto badge =
|
if (auto badge = getApp()->getChatterinoBadges()->getBadge({this->userId_}))
|
||||||
getIApp()->getChatterinoBadges()->getBadge({this->userId_}))
|
|
||||||
{
|
{
|
||||||
this->emplace<BadgeElement>(*badge,
|
this->emplace<BadgeElement>(*badge,
|
||||||
MessageElementFlag::BadgeChatterino);
|
MessageElementFlag::BadgeChatterino);
|
||||||
|
@ -1421,7 +1420,7 @@ void TwitchMessageBuilder::appendChatterinoBadges()
|
||||||
void TwitchMessageBuilder::appendFfzBadges()
|
void TwitchMessageBuilder::appendFfzBadges()
|
||||||
{
|
{
|
||||||
for (const auto &badge :
|
for (const auto &badge :
|
||||||
getIApp()->getFfzBadges()->getUserBadges({this->userId_}))
|
getApp()->getFfzBadges()->getUserBadges({this->userId_}))
|
||||||
{
|
{
|
||||||
this->emplace<FfzBadgeElement>(
|
this->emplace<FfzBadgeElement>(
|
||||||
badge.emote, MessageElementFlag::BadgeFfz, badge.color);
|
badge.emote, MessageElementFlag::BadgeFfz, badge.color);
|
||||||
|
@ -1442,7 +1441,7 @@ void TwitchMessageBuilder::appendFfzBadges()
|
||||||
|
|
||||||
void TwitchMessageBuilder::appendSeventvBadges()
|
void TwitchMessageBuilder::appendSeventvBadges()
|
||||||
{
|
{
|
||||||
if (auto badge = getIApp()->getSeventvBadges()->getBadge({this->userId_}))
|
if (auto badge = getApp()->getSeventvBadges()->getBadge({this->userId_}))
|
||||||
{
|
{
|
||||||
this->emplace<BadgeElement>(*badge, MessageElementFlag::BadgeSevenTV);
|
this->emplace<BadgeElement>(*badge, MessageElementFlag::BadgeSevenTV);
|
||||||
}
|
}
|
||||||
|
@ -1585,7 +1584,7 @@ void TwitchMessageBuilder::appendChannelPointRewardMessage(
|
||||||
if (reward.id == "CELEBRATION")
|
if (reward.id == "CELEBRATION")
|
||||||
{
|
{
|
||||||
const auto emotePtr =
|
const auto emotePtr =
|
||||||
getIApp()->getEmotes()->getTwitchEmotes()->getOrCreateEmote(
|
getApp()->getEmotes()->getTwitchEmotes()->getOrCreateEmote(
|
||||||
EmoteId{reward.emoteId}, EmoteName{reward.emoteName});
|
EmoteId{reward.emoteId}, EmoteName{reward.emoteName});
|
||||||
builder->emplace<EmoteElement>(emotePtr,
|
builder->emplace<EmoteElement>(emotePtr,
|
||||||
MessageElementFlag::ChannelPointReward,
|
MessageElementFlag::ChannelPointReward,
|
||||||
|
@ -2060,7 +2059,7 @@ std::pair<MessagePtr, MessagePtr> TwitchMessageBuilder::makeAutomodMessage(
|
||||||
// Normally highlights would be checked & triggered during the builder parse steps
|
// Normally highlights would be checked & triggered during the builder parse steps
|
||||||
// and when the message is added to the channel
|
// and when the message is added to the channel
|
||||||
// We do this a bit weird since the message comes in from PubSub and not the normal message route
|
// We do this a bit weird since the message comes in from PubSub and not the normal message route
|
||||||
auto [highlighted, highlightResult] = getIApp()->getHighlights()->check(
|
auto [highlighted, highlightResult] = getApp()->getHighlights()->check(
|
||||||
{}, {}, action.target.login, action.message, message2->flags);
|
{}, {}, action.target.login, action.message, message2->flags);
|
||||||
if (highlighted)
|
if (highlighted)
|
||||||
{
|
{
|
||||||
|
@ -2256,7 +2255,7 @@ std::pair<MessagePtr, MessagePtr> TwitchMessageBuilder::makeLowTrustUserMessage(
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const auto emotePtr =
|
const auto emotePtr =
|
||||||
getIApp()->getEmotes()->getTwitchEmotes()->getOrCreateEmote(
|
getApp()->getEmotes()->getTwitchEmotes()->getOrCreateEmote(
|
||||||
EmoteId{fragment.emoteID}, EmoteName{fragment.text});
|
EmoteId{fragment.emoteID}, EmoteName{fragment.text});
|
||||||
builder2.emplace<EmoteElement>(
|
builder2.emplace<EmoteElement>(
|
||||||
emotePtr, MessageElementFlag::TwitchEmote, MessageColor::Text);
|
emotePtr, MessageElementFlag::TwitchEmote, MessageColor::Text);
|
||||||
|
|
|
@ -1,9 +0,0 @@
|
||||||
#include "Badges.hpp"
|
|
||||||
|
|
||||||
namespace chatterino {
|
|
||||||
|
|
||||||
Badges::Badges()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace chatterino
|
|
|
@ -1,13 +0,0 @@
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "common/Singleton.hpp"
|
|
||||||
|
|
||||||
namespace chatterino {
|
|
||||||
|
|
||||||
class Badges : public Singleton
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
Badges();
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace chatterino
|
|
|
@ -130,10 +130,6 @@ using namespace std::string_literals;
|
||||||
|
|
||||||
CrashHandler::CrashHandler(const Paths &paths_)
|
CrashHandler::CrashHandler(const Paths &paths_)
|
||||||
: paths(paths_)
|
: paths(paths_)
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void CrashHandler::initialize(Settings & /*settings*/, const Paths &paths_)
|
|
||||||
{
|
{
|
||||||
auto optSettings = readRecoverySettings(paths);
|
auto optSettings = readRecoverySettings(paths);
|
||||||
if (optSettings)
|
if (optSettings)
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "common/Singleton.hpp"
|
|
||||||
|
|
||||||
#include <QtGlobal>
|
#include <QtGlobal>
|
||||||
|
|
||||||
#ifdef CHATTERINO_WITH_CRASHPAD
|
#ifdef CHATTERINO_WITH_CRASHPAD
|
||||||
|
@ -15,7 +13,7 @@ namespace chatterino {
|
||||||
class Args;
|
class Args;
|
||||||
class Paths;
|
class Paths;
|
||||||
|
|
||||||
class CrashHandler : public Singleton
|
class CrashHandler
|
||||||
{
|
{
|
||||||
const Paths &paths;
|
const Paths &paths;
|
||||||
|
|
||||||
|
@ -30,8 +28,6 @@ public:
|
||||||
/// Sets and saves whether Chatterino should restart on a crash
|
/// Sets and saves whether Chatterino should restart on a crash
|
||||||
void saveShouldRecover(bool value);
|
void saveShouldRecover(bool value);
|
||||||
|
|
||||||
void initialize(Settings &settings, const Paths &paths) override;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool shouldRecover_ = false;
|
bool shouldRecover_ = false;
|
||||||
};
|
};
|
||||||
|
|
|
@ -3,19 +3,10 @@
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
||||||
Emotes::Emotes()
|
Emotes::Emotes()
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void Emotes::initialize(Settings &settings, const Paths &paths)
|
|
||||||
{
|
{
|
||||||
this->emojis.load();
|
this->emojis.load();
|
||||||
|
|
||||||
this->gifTimer.initialize();
|
this->gifTimer.initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Emotes::isIgnoredEmote(const QString &)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace chatterino
|
} // namespace chatterino
|
||||||
|
|
|
@ -1,15 +1,11 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "common/Singleton.hpp"
|
|
||||||
#include "providers/emoji/Emojis.hpp"
|
#include "providers/emoji/Emojis.hpp"
|
||||||
#include "providers/twitch/TwitchEmotes.hpp"
|
#include "providers/twitch/TwitchEmotes.hpp"
|
||||||
#include "singletons/helper/GifTimer.hpp"
|
#include "singletons/helper/GifTimer.hpp"
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
||||||
class Settings;
|
|
||||||
class Paths;
|
|
||||||
|
|
||||||
class IEmotes
|
class IEmotes
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -20,15 +16,11 @@ public:
|
||||||
virtual GIFTimer &getGIFTimer() = 0;
|
virtual GIFTimer &getGIFTimer() = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
class Emotes final : public IEmotes, public Singleton
|
class Emotes final : public IEmotes
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Emotes();
|
Emotes();
|
||||||
|
|
||||||
void initialize(Settings &settings, const Paths &paths) override;
|
|
||||||
|
|
||||||
bool isIgnoredEmote(const QString &emote);
|
|
||||||
|
|
||||||
ITwitchEmotes *getTwitchEmotes() final
|
ITwitchEmotes *getTwitchEmotes() final
|
||||||
{
|
{
|
||||||
return &this->twitch;
|
return &this->twitch;
|
||||||
|
|
|
@ -54,7 +54,7 @@ void ImageUploader::logToFile(const QString &originalFilePath,
|
||||||
{
|
{
|
||||||
const QString logFileName =
|
const QString logFileName =
|
||||||
combinePath((getSettings()->logPath.getValue().isEmpty()
|
combinePath((getSettings()->logPath.getValue().isEmpty()
|
||||||
? getIApp()->getPaths().messageLogDirectory
|
? getApp()->getPaths().messageLogDirectory
|
||||||
: getSettings()->logPath),
|
: getSettings()->logPath),
|
||||||
"ImageUploader.json");
|
"ImageUploader.json");
|
||||||
|
|
||||||
|
@ -123,10 +123,6 @@ QString getLinkFromResponse(NetworkResult response, QString pattern)
|
||||||
return pattern;
|
return pattern;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImageUploader::save()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void ImageUploader::sendImageUploadRequest(RawImageData imageData,
|
void ImageUploader::sendImageUploadRequest(RawImageData imageData,
|
||||||
ChannelPtr channel,
|
ChannelPtr channel,
|
||||||
QPointer<ResizingTextEdit> textEdit)
|
QPointer<ResizingTextEdit> textEdit)
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "common/Singleton.hpp"
|
|
||||||
|
|
||||||
#include <QMimeData>
|
#include <QMimeData>
|
||||||
#include <QMutex>
|
#include <QMutex>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
@ -22,7 +20,7 @@ struct RawImageData {
|
||||||
QString filePath;
|
QString filePath;
|
||||||
};
|
};
|
||||||
|
|
||||||
class ImageUploader final : public Singleton
|
class ImageUploader final
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
|
@ -33,7 +31,6 @@ public:
|
||||||
std::pair<std::queue<RawImageData>, QString> getImages(
|
std::pair<std::queue<RawImageData>, QString> getImages(
|
||||||
const QMimeData *source) const;
|
const QMimeData *source) const;
|
||||||
|
|
||||||
void save() override;
|
|
||||||
void upload(std::queue<RawImageData> images, ChannelPtr channel,
|
void upload(std::queue<RawImageData> images, ChannelPtr channel,
|
||||||
QPointer<ResizingTextEdit> outputTextEdit);
|
QPointer<ResizingTextEdit> outputTextEdit);
|
||||||
|
|
||||||
|
|
|
@ -238,11 +238,10 @@ void NativeMessagingServer::ReceiverThread::handleSelect(
|
||||||
postToThread([=] {
|
postToThread([=] {
|
||||||
if (!name.isEmpty())
|
if (!name.isEmpty())
|
||||||
{
|
{
|
||||||
auto channel =
|
auto channel = getApp()->getTwitchAbstract()->getOrAddChannel(name);
|
||||||
getIApp()->getTwitchAbstract()->getOrAddChannel(name);
|
if (getApp()->getTwitch()->getWatchingChannel().get() != channel)
|
||||||
if (getIApp()->getTwitch()->getWatchingChannel().get() != channel)
|
|
||||||
{
|
{
|
||||||
getIApp()->getTwitch()->setWatchingChannel(channel);
|
getApp()->getTwitch()->setWatchingChannel(channel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -253,7 +252,7 @@ void NativeMessagingServer::ReceiverThread::handleSelect(
|
||||||
if (!name.isEmpty())
|
if (!name.isEmpty())
|
||||||
{
|
{
|
||||||
window->setChannel(
|
window->setChannel(
|
||||||
getIApp()->getTwitchAbstract()->getOrAddChannel(name));
|
getApp()->getTwitchAbstract()->getOrAddChannel(name));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -305,7 +304,7 @@ void NativeMessagingServer::syncChannels(const QJsonArray &twitchChannels)
|
||||||
}
|
}
|
||||||
// the deduping is done on the extension side
|
// the deduping is done on the extension side
|
||||||
updated.emplace_back(
|
updated.emplace_back(
|
||||||
getIApp()->getTwitchAbstract()->getOrAddChannel(name));
|
getApp()->getTwitchAbstract()->getOrAddChannel(name));
|
||||||
}
|
}
|
||||||
|
|
||||||
// This will destroy channels that aren't used anymore.
|
// This will destroy channels that aren't used anymore.
|
||||||
|
|
|
@ -74,7 +74,7 @@ bool isBroadcasterSoftwareActive()
|
||||||
shouldShowTimeoutWarning = false;
|
shouldShowTimeoutWarning = false;
|
||||||
|
|
||||||
postToThread([] {
|
postToThread([] {
|
||||||
getIApp()->getTwitchAbstract()->addGlobalSystemMessage(
|
getApp()->getTwitchAbstract()->addGlobalSystemMessage(
|
||||||
"Streamer Mode is set to Automatic, but pgrep timed "
|
"Streamer Mode is set to Automatic, but pgrep timed "
|
||||||
"out. This can happen if your system lagged at the "
|
"out. This can happen if your system lagged at the "
|
||||||
"wrong moment. If Streamer Mode continues to not work, "
|
"wrong moment. If Streamer Mode continues to not work, "
|
||||||
|
@ -94,7 +94,7 @@ bool isBroadcasterSoftwareActive()
|
||||||
shouldShowWarning = false;
|
shouldShowWarning = false;
|
||||||
|
|
||||||
postToThread([] {
|
postToThread([] {
|
||||||
getIApp()->getTwitchAbstract()->addGlobalSystemMessage(
|
getApp()->getTwitchAbstract()->addGlobalSystemMessage(
|
||||||
"Streamer Mode is set to Automatic, but pgrep is "
|
"Streamer Mode is set to Automatic, but pgrep is "
|
||||||
"missing. "
|
"missing. "
|
||||||
"Install it to fix the issue or set Streamer Mode to "
|
"Install it to fix the issue or set Streamer Mode to "
|
||||||
|
|
|
@ -282,7 +282,7 @@ bool Theme::isSystemTheme() const
|
||||||
return this->themeName == u"System"_s;
|
return this->themeName == u"System"_s;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Theme::initialize(Settings &settings, const Paths &paths)
|
Theme::Theme(const Paths &paths)
|
||||||
{
|
{
|
||||||
this->themeName.connect(
|
this->themeName.connect(
|
||||||
[this](auto themeName) {
|
[this](auto themeName) {
|
||||||
|
@ -307,7 +307,7 @@ void Theme::initialize(Settings &settings, const Paths &paths)
|
||||||
if (this->isSystemTheme())
|
if (this->isSystemTheme())
|
||||||
{
|
{
|
||||||
this->update();
|
this->update();
|
||||||
getIApp()->getWindows()->forceLayoutChannelViews();
|
getApp()->getWindows()->forceLayoutChannelViews();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
#endif
|
#endif
|
||||||
|
@ -597,7 +597,7 @@ void Theme::normalizeColor(QColor &color) const
|
||||||
|
|
||||||
Theme *getTheme()
|
Theme *getTheme()
|
||||||
{
|
{
|
||||||
return getIApp()->getThemes();
|
return getApp()->getThemes();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace chatterino
|
} // namespace chatterino
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "common/ChatterinoSetting.hpp"
|
#include "common/ChatterinoSetting.hpp"
|
||||||
#include "common/Singleton.hpp"
|
#include "singletons/Paths.hpp"
|
||||||
#include "util/RapidJsonSerializeQString.hpp"
|
#include "util/RapidJsonSerializeQString.hpp"
|
||||||
|
|
||||||
#include <pajlada/settings/setting.hpp>
|
#include <pajlada/settings/setting.hpp>
|
||||||
|
@ -33,7 +33,7 @@ struct ThemeDescriptor {
|
||||||
bool custom{};
|
bool custom{};
|
||||||
};
|
};
|
||||||
|
|
||||||
class Theme final : public Singleton
|
class Theme final
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static const std::vector<ThemeDescriptor> builtInThemes;
|
static const std::vector<ThemeDescriptor> builtInThemes;
|
||||||
|
@ -43,7 +43,7 @@ public:
|
||||||
|
|
||||||
static const int AUTO_RELOAD_INTERVAL_MS = 500;
|
static const int AUTO_RELOAD_INTERVAL_MS = 500;
|
||||||
|
|
||||||
void initialize(Settings &settings, const Paths &paths) final;
|
Theme(const Paths &paths);
|
||||||
|
|
||||||
bool isLightTheme() const;
|
bool isLightTheme() const;
|
||||||
bool isSystemTheme() const;
|
bool isSystemTheme() const;
|
||||||
|
|
|
@ -35,7 +35,7 @@ using namespace literals;
|
||||||
QString avatarFilePath(const QString &channelName)
|
QString avatarFilePath(const QString &channelName)
|
||||||
{
|
{
|
||||||
// TODO: cleanup channel (to be used as a file) and use combinePath
|
// TODO: cleanup channel (to be used as a file) and use combinePath
|
||||||
return getIApp()->getPaths().twitchProfileAvatars % '/' % channelName %
|
return getApp()->getPaths().twitchProfileAvatars % '/' % channelName %
|
||||||
u".png";
|
u".png";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,7 +74,7 @@ bool Toasts::isEnabled()
|
||||||
{
|
{
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
return WinToast::isCompatible() && getSettings()->notificationToast &&
|
return WinToast::isCompatible() && getSettings()->notificationToast &&
|
||||||
!(getIApp()->getStreamerMode()->isEnabled() &&
|
!(getApp()->getStreamerMode()->isEnabled() &&
|
||||||
getSettings()->streamerModeSuppressLiveNotifications);
|
getSettings()->streamerModeSuppressLiveNotifications);
|
||||||
#else
|
#else
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "common/Singleton.hpp"
|
|
||||||
|
|
||||||
#include <pajlada/settings/setting.hpp>
|
#include <pajlada/settings/setting.hpp>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
|
@ -16,7 +14,7 @@ enum class ToastReaction {
|
||||||
DontOpen = 3
|
DontOpen = 3
|
||||||
};
|
};
|
||||||
|
|
||||||
class Toasts final : public Singleton
|
class Toasts final
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
void sendChannelNotification(const QString &channelName,
|
void sendChannelNotification(const QString &channelName,
|
||||||
|
|
|
@ -118,7 +118,7 @@ WindowManager::WindowManager(const Paths &paths)
|
||||||
this->saveTimer->setSingleShot(true);
|
this->saveTimer->setSingleShot(true);
|
||||||
|
|
||||||
QObject::connect(this->saveTimer, &QTimer::timeout, [] {
|
QObject::connect(this->saveTimer, &QTimer::timeout, [] {
|
||||||
getIApp()->getWindows()->save();
|
getApp()->getWindows()->save();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -341,21 +341,18 @@ void WindowManager::setEmotePopupBounds(QRect bounds)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowManager::initialize(Settings &settings, const Paths &paths)
|
void WindowManager::initialize(Settings &settings)
|
||||||
{
|
{
|
||||||
(void)paths;
|
|
||||||
assertInGuiThread();
|
assertInGuiThread();
|
||||||
|
|
||||||
// We can safely ignore this signal connection since both Themes and WindowManager
|
// We can safely ignore this signal connection since both Themes and WindowManager
|
||||||
// share the Application state lifetime
|
// share the Application state lifetime
|
||||||
// NOTE: APPLICATION_LIFETIME
|
// NOTE: APPLICATION_LIFETIME
|
||||||
std::ignore =
|
std::ignore =
|
||||||
getIApp()->getThemes()->repaintVisibleChatWidgets_.connect([this] {
|
getApp()->getThemes()->repaintVisibleChatWidgets_.connect([this] {
|
||||||
this->repaintVisibleChatWidgets();
|
this->repaintVisibleChatWidgets();
|
||||||
});
|
});
|
||||||
|
|
||||||
assert(!this->initialized_);
|
|
||||||
|
|
||||||
{
|
{
|
||||||
WindowLayout windowLayout;
|
WindowLayout windowLayout;
|
||||||
|
|
||||||
|
@ -368,7 +365,7 @@ void WindowManager::initialize(Settings &settings, const Paths &paths)
|
||||||
windowLayout = this->loadWindowLayoutFromFile();
|
windowLayout = this->loadWindowLayoutFromFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto desired = getIApp()->getArgs().activateChannel;
|
auto desired = getApp()->getArgs().activateChannel;
|
||||||
if (desired)
|
if (desired)
|
||||||
{
|
{
|
||||||
windowLayout.activateOrAddChannel(desired->provider, desired->name);
|
windowLayout.activateOrAddChannel(desired->provider, desired->name);
|
||||||
|
@ -428,8 +425,6 @@ void WindowManager::initialize(Settings &settings, const Paths &paths)
|
||||||
settings.boldUsernames.connect([this](auto, auto) {
|
settings.boldUsernames.connect([this](auto, auto) {
|
||||||
this->forceLayoutChannelViews();
|
this->forceLayoutChannelViews();
|
||||||
});
|
});
|
||||||
|
|
||||||
this->initialized_ = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowManager::save()
|
void WindowManager::save()
|
||||||
|
@ -687,28 +682,28 @@ IndirectChannel WindowManager::decodeChannel(const SplitDescriptor &descriptor)
|
||||||
|
|
||||||
if (descriptor.type_ == "twitch")
|
if (descriptor.type_ == "twitch")
|
||||||
{
|
{
|
||||||
return getIApp()->getTwitchAbstract()->getOrAddChannel(
|
return getApp()->getTwitchAbstract()->getOrAddChannel(
|
||||||
descriptor.channelName_);
|
descriptor.channelName_);
|
||||||
}
|
}
|
||||||
else if (descriptor.type_ == "mentions")
|
else if (descriptor.type_ == "mentions")
|
||||||
{
|
{
|
||||||
return getIApp()->getTwitch()->getMentionsChannel();
|
return getApp()->getTwitch()->getMentionsChannel();
|
||||||
}
|
}
|
||||||
else if (descriptor.type_ == "watching")
|
else if (descriptor.type_ == "watching")
|
||||||
{
|
{
|
||||||
return getIApp()->getTwitch()->getWatchingChannel();
|
return getApp()->getTwitch()->getWatchingChannel();
|
||||||
}
|
}
|
||||||
else if (descriptor.type_ == "whispers")
|
else if (descriptor.type_ == "whispers")
|
||||||
{
|
{
|
||||||
return getIApp()->getTwitch()->getWhispersChannel();
|
return getApp()->getTwitch()->getWhispersChannel();
|
||||||
}
|
}
|
||||||
else if (descriptor.type_ == "live")
|
else if (descriptor.type_ == "live")
|
||||||
{
|
{
|
||||||
return getIApp()->getTwitch()->getLiveChannel();
|
return getApp()->getTwitch()->getLiveChannel();
|
||||||
}
|
}
|
||||||
else if (descriptor.type_ == "automod")
|
else if (descriptor.type_ == "automod")
|
||||||
{
|
{
|
||||||
return getIApp()->getTwitch()->getAutomodChannel();
|
return getApp()->getTwitch()->getAutomodChannel();
|
||||||
}
|
}
|
||||||
else if (descriptor.type_ == "irc")
|
else if (descriptor.type_ == "irc")
|
||||||
{
|
{
|
||||||
|
@ -717,7 +712,7 @@ IndirectChannel WindowManager::decodeChannel(const SplitDescriptor &descriptor)
|
||||||
}
|
}
|
||||||
else if (descriptor.type_ == "misc")
|
else if (descriptor.type_ == "misc")
|
||||||
{
|
{
|
||||||
return getIApp()->getTwitchAbstract()->getChannelOrEmpty(
|
return getApp()->getTwitchAbstract()->getChannelOrEmpty(
|
||||||
descriptor.channelName_);
|
descriptor.channelName_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "common/FlagsEnum.hpp"
|
#include "common/FlagsEnum.hpp"
|
||||||
#include "common/Singleton.hpp"
|
|
||||||
#include "widgets/splits/SplitContainer.hpp"
|
#include "widgets/splits/SplitContainer.hpp"
|
||||||
|
|
||||||
#include <pajlada/settings/settinglistener.hpp>
|
#include <pajlada/settings/settinglistener.hpp>
|
||||||
|
@ -32,13 +31,13 @@ enum class WindowType;
|
||||||
enum class SettingsDialogPreference;
|
enum class SettingsDialogPreference;
|
||||||
class FramelessEmbedWindow;
|
class FramelessEmbedWindow;
|
||||||
|
|
||||||
class WindowManager final : public Singleton
|
class WindowManager final
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static const QString WINDOW_LAYOUT_FILENAME;
|
static const QString WINDOW_LAYOUT_FILENAME;
|
||||||
|
|
||||||
explicit WindowManager(const Paths &paths);
|
explicit WindowManager(const Paths &paths);
|
||||||
~WindowManager() override;
|
~WindowManager();
|
||||||
|
|
||||||
WindowManager(const WindowManager &) = delete;
|
WindowManager(const WindowManager &) = delete;
|
||||||
WindowManager(WindowManager &&) = delete;
|
WindowManager(WindowManager &&) = delete;
|
||||||
|
@ -102,8 +101,9 @@ public:
|
||||||
QRect emotePopupBounds() const;
|
QRect emotePopupBounds() const;
|
||||||
void setEmotePopupBounds(QRect bounds);
|
void setEmotePopupBounds(QRect bounds);
|
||||||
|
|
||||||
void initialize(Settings &settings, const Paths &paths) override;
|
// Set up some final signals & actually show the windows
|
||||||
void save() override;
|
void initialize(Settings &settings);
|
||||||
|
void save();
|
||||||
void closeAll();
|
void closeAll();
|
||||||
|
|
||||||
int getGeneration() const;
|
int getGeneration() const;
|
||||||
|
@ -151,7 +151,6 @@ private:
|
||||||
// Contains the full path to the window layout file, e.g. /home/pajlada/.local/share/Chatterino/Settings/window-layout.json
|
// Contains the full path to the window layout file, e.g. /home/pajlada/.local/share/Chatterino/Settings/window-layout.json
|
||||||
const QString windowLayoutFilePath;
|
const QString windowLayoutFilePath;
|
||||||
|
|
||||||
bool initialized_ = false;
|
|
||||||
bool shuttingDown_ = false;
|
bool shuttingDown_ = false;
|
||||||
|
|
||||||
QRect emotePopupBounds_;
|
QRect emotePopupBounds_;
|
||||||
|
|
|
@ -31,7 +31,7 @@ void GIFTimer::initialize()
|
||||||
|
|
||||||
this->position_ += GIF_FRAME_LENGTH;
|
this->position_ += GIF_FRAME_LENGTH;
|
||||||
this->signal.invoke();
|
this->signal.invoke();
|
||||||
getIApp()->getWindows()->repaintGifEmotes();
|
getApp()->getWindows()->repaintGifEmotes();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -88,7 +88,7 @@ LoggingChannel::LoggingChannel(QString _channelName, QString _platform)
|
||||||
|
|
||||||
getSettings()->logPath.connect([this](const QString &logPath, auto) {
|
getSettings()->logPath.connect([this](const QString &logPath, auto) {
|
||||||
this->baseDirectory = logPath.isEmpty()
|
this->baseDirectory = logPath.isEmpty()
|
||||||
? getIApp()->getPaths().messageLogDirectory
|
? getApp()->getPaths().messageLogDirectory
|
||||||
: logPath;
|
: logPath;
|
||||||
this->openLogFile();
|
this->openLogFile();
|
||||||
});
|
});
|
||||||
|
|
|
@ -41,7 +41,7 @@ void initUpdateButton(Button &button,
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case UpdateDialog::Install: {
|
case UpdateDialog::Install: {
|
||||||
getIApp()->getUpdates().installUpdates();
|
getApp()->getUpdates().installUpdates();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -53,17 +53,17 @@ void initUpdateButton(Button &button,
|
||||||
|
|
||||||
// update image when state changes
|
// update image when state changes
|
||||||
auto updateChange = [&button](auto) {
|
auto updateChange = [&button](auto) {
|
||||||
button.setVisible(getIApp()->getUpdates().shouldShowUpdateButton());
|
button.setVisible(getApp()->getUpdates().shouldShowUpdateButton());
|
||||||
|
|
||||||
const auto *imageUrl = getIApp()->getUpdates().isError()
|
const auto *imageUrl = getApp()->getUpdates().isError()
|
||||||
? ":/buttons/updateError.png"
|
? ":/buttons/updateError.png"
|
||||||
: ":/buttons/update.png";
|
: ":/buttons/update.png";
|
||||||
button.setPixmap(QPixmap(imageUrl));
|
button.setPixmap(QPixmap(imageUrl));
|
||||||
};
|
};
|
||||||
|
|
||||||
updateChange(getIApp()->getUpdates().getStatus());
|
updateChange(getApp()->getUpdates().getStatus());
|
||||||
|
|
||||||
signalHolder.managedConnect(getIApp()->getUpdates().statusUpdated,
|
signalHolder.managedConnect(getApp()->getUpdates().statusUpdated,
|
||||||
[updateChange](auto status) {
|
[updateChange](auto status) {
|
||||||
updateChange(status);
|
updateChange(status);
|
||||||
});
|
});
|
||||||
|
|
|
@ -183,7 +183,7 @@ void openStreamlinkForChannel(const QString &channel)
|
||||||
{
|
{
|
||||||
static const QString INFO_TEMPLATE("Opening %1 in Streamlink ...");
|
static const QString INFO_TEMPLATE("Opening %1 in Streamlink ...");
|
||||||
|
|
||||||
auto *currentPage = dynamic_cast<SplitContainer *>(getIApp()
|
auto *currentPage = dynamic_cast<SplitContainer *>(getApp()
|
||||||
->getWindows()
|
->getWindows()
|
||||||
->getMainWindow()
|
->getMainWindow()
|
||||||
.getNotebook()
|
.getNotebook()
|
||||||
|
|
|
@ -18,7 +18,7 @@ namespace chatterino {
|
||||||
|
|
||||||
BaseWidget::BaseWidget(QWidget *parent, Qt::WindowFlags f)
|
BaseWidget::BaseWidget(QWidget *parent, Qt::WindowFlags f)
|
||||||
: QWidget(parent, f)
|
: QWidget(parent, f)
|
||||||
, theme(getIApp()->getThemes())
|
, theme(getApp()->getThemes())
|
||||||
{
|
{
|
||||||
this->signalHolder_.managedConnect(this->theme->updated, [this]() {
|
this->signalHolder_.managedConnect(this->theme->updated, [this]() {
|
||||||
this->themeChangedEvent();
|
this->themeChangedEvent();
|
||||||
|
|
|
@ -712,7 +712,7 @@ void BaseWindow::resizeEvent(QResizeEvent *)
|
||||||
// Queue up save because: Window resized
|
// Queue up save because: Window resized
|
||||||
if (!flags_.has(DisableLayoutSave))
|
if (!flags_.has(DisableLayoutSave))
|
||||||
{
|
{
|
||||||
getIApp()->getWindows()->queueSave();
|
getApp()->getWindows()->queueSave();
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef USEWINSDK
|
#ifdef USEWINSDK
|
||||||
|
@ -727,7 +727,7 @@ void BaseWindow::moveEvent(QMoveEvent *event)
|
||||||
#ifdef CHATTERINO
|
#ifdef CHATTERINO
|
||||||
if (!flags_.has(DisableLayoutSave))
|
if (!flags_.has(DisableLayoutSave))
|
||||||
{
|
{
|
||||||
getIApp()->getWindows()->queueSave();
|
getApp()->getWindows()->queueSave();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -909,7 +909,7 @@ void BaseWindow::scaleChangedEvent(float scale)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
this->setFont(
|
this->setFont(
|
||||||
getIApp()->getFonts()->getFont(FontStyle::UiTabs, this->scale()));
|
getApp()->getFonts()->getFont(FontStyle::UiTabs, this->scale()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void BaseWindow::paintEvent(QPaintEvent *)
|
void BaseWindow::paintEvent(QPaintEvent *)
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue