refactor: Remove most raw accesses into Application (#5104)

This commit is contained in:
pajlada 2024-01-19 17:59:55 +01:00 committed by GitHub
parent 326a402710
commit 4380ef8c5f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
82 changed files with 552 additions and 452 deletions

View file

@ -101,6 +101,7 @@
- Dev: Renamed `tools` directory to `scripts`. (#5035) - Dev: Renamed `tools` directory to `scripts`. (#5035)
- Dev: Refactor `ChannelView`, removing a bunch of clang-tidy warnings. (#4926) - Dev: Refactor `ChannelView`, removing a bunch of clang-tidy warnings. (#4926)
- Dev: Refactor `IrcMessageHandler`, removing a bunch of clang-tidy warnings & changing its public API. (#4927) - Dev: Refactor `IrcMessageHandler`, removing a bunch of clang-tidy warnings & changing its public API. (#4927)
- Dev: Removed almost all raw accesses into Application. (#5104)
- Dev: `Details` file properties tab is now populated on Windows. (#4912) - Dev: `Details` file properties tab is now populated on Windows. (#4912)
- Dev: Removed `Outcome` from network requests. (#4959) - Dev: Removed `Outcome` from network requests. (#4959)
- Dev: Added Tests for Windows and MacOS in CI. (#4970, #5032) - Dev: Added Tests for Windows and MacOS in CI. (#4970, #5032)

View file

@ -304,6 +304,20 @@ int Application::run(QApplication &qtApp)
return qtApp.exec(); return qtApp.exec();
} }
Theme *Application::getThemes()
{
assertInGuiThread();
return this->themes;
}
Fonts *Application::getFonts()
{
assertInGuiThread();
return this->fonts;
}
IEmotes *Application::getEmotes() IEmotes *Application::getEmotes()
{ {
assertInGuiThread(); assertInGuiThread();
@ -311,6 +325,77 @@ IEmotes *Application::getEmotes()
return this->emotes; return this->emotes;
} }
AccountController *Application::getAccounts()
{
assertInGuiThread();
return this->accounts;
}
HotkeyController *Application::getHotkeys()
{
assertInGuiThread();
return this->hotkeys;
}
WindowManager *Application::getWindows()
{
assertInGuiThread();
assert(this->windows);
return this->windows;
}
Toasts *Application::getToasts()
{
assertInGuiThread();
return this->toasts;
}
CrashHandler *Application::getCrashHandler()
{
assertInGuiThread();
return this->crashHandler;
}
CommandController *Application::getCommands()
{
assertInGuiThread();
return this->commands;
}
NotificationController *Application::getNotifications()
{
assertInGuiThread();
return this->notifications;
}
HighlightController *Application::getHighlights()
{
assertInGuiThread();
return this->highlights;
}
FfzBadges *Application::getFfzBadges()
{
assertInGuiThread();
return this->ffzBadges;
}
SeventvBadges *Application::getSeventvBadges()
{
// SeventvBadges handles its own locks, so we don't need to assert that this is called in the GUI thread
return this->seventvBadges;
}
IUserDataController *Application::getUserData() IUserDataController *Application::getUserData()
{ {
assertInGuiThread(); assertInGuiThread();
@ -348,6 +433,29 @@ IChatterinoBadges *Application::getChatterinoBadges()
return this->chatterinoBadges.get(); return this->chatterinoBadges.get();
} }
ImageUploader *Application::getImageUploader()
{
assertInGuiThread();
return this->imageUploader;
}
SeventvAPI *Application::getSeventvAPI()
{
assertInGuiThread();
return this->seventvAPI;
}
#ifdef CHATTERINO_HAVE_PLUGINS
PluginController *Application::getPlugins()
{
assertInGuiThread();
return this->plugins;
}
#endif
ITwitchIrcServer *Application::getTwitch() ITwitchIrcServer *Application::getTwitch()
{ {
assertInGuiThread(); assertInGuiThread();

View file

@ -85,6 +85,9 @@ public:
virtual TwitchBadges *getTwitchBadges() = 0; virtual TwitchBadges *getTwitchBadges() = 0;
virtual ImageUploader *getImageUploader() = 0; virtual ImageUploader *getImageUploader() = 0;
virtual SeventvAPI *getSeventvAPI() = 0; virtual SeventvAPI *getSeventvAPI() = 0;
#ifdef CHATTERINO_HAVE_PLUGINS
virtual PluginController *getPlugins() = 0;
#endif
virtual Updates &getUpdates() = 0; virtual Updates &getUpdates() = 0;
}; };
@ -122,9 +125,14 @@ public:
friend void test(); friend void test();
private:
Theme *const themes{}; Theme *const themes{};
Fonts *const fonts{}; Fonts *const fonts{};
public:
Emotes *const emotes{}; Emotes *const emotes{};
private:
AccountController *const accounts{}; AccountController *const accounts{};
HotkeyController *const hotkeys{}; HotkeyController *const hotkeys{};
WindowManager *const windows{}; WindowManager *const windows{};
@ -132,28 +140,28 @@ public:
ImageUploader *const imageUploader{}; ImageUploader *const imageUploader{};
SeventvAPI *const seventvAPI{}; SeventvAPI *const seventvAPI{};
CrashHandler *const crashHandler{}; CrashHandler *const crashHandler{};
CommandController *const commands{}; CommandController *const commands{};
NotificationController *const notifications{}; NotificationController *const notifications{};
HighlightController *const highlights{}; HighlightController *const highlights{};
public:
TwitchIrcServer *const twitch{}; TwitchIrcServer *const twitch{};
private:
FfzBadges *const ffzBadges{}; FfzBadges *const ffzBadges{};
SeventvBadges *const seventvBadges{}; SeventvBadges *const seventvBadges{};
UserDataController *const userData{}; UserDataController *const userData{};
ISoundController *const sound{}; ISoundController *const sound{};
private:
TwitchLiveController *const twitchLiveController{}; TwitchLiveController *const 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;
const std::unique_ptr<Logging> logging; const std::unique_ptr<Logging> logging;
public:
#ifdef CHATTERINO_HAVE_PLUGINS #ifdef CHATTERINO_HAVE_PLUGINS
PluginController *const plugins{}; PluginController *const plugins{};
#endif #endif
public:
const Paths &getPaths() override const Paths &getPaths() override
{ {
return this->paths_; return this->paths_;
@ -162,99 +170,32 @@ public:
{ {
return this->args_; return this->args_;
} }
Theme *getThemes() override Theme *getThemes() override;
{ Fonts *getFonts() override;
assertInGuiThread();
return this->themes;
}
Fonts *getFonts() override
{
assertInGuiThread();
return this->fonts;
}
IEmotes *getEmotes() override; IEmotes *getEmotes() override;
AccountController *getAccounts() override AccountController *getAccounts() override;
{ HotkeyController *getHotkeys() override;
assertInGuiThread(); WindowManager *getWindows() override;
Toasts *getToasts() override;
return this->accounts; CrashHandler *getCrashHandler() override;
} CommandController *getCommands() override;
HotkeyController *getHotkeys() override NotificationController *getNotifications() override;
{ HighlightController *getHighlights() override;
assertInGuiThread();
return this->hotkeys;
}
WindowManager *getWindows() override
{
assertInGuiThread();
return this->windows;
}
Toasts *getToasts() override
{
assertInGuiThread();
return this->toasts;
}
CrashHandler *getCrashHandler() override
{
assertInGuiThread();
return this->crashHandler;
}
CommandController *getCommands() override
{
assertInGuiThread();
return this->commands;
}
NotificationController *getNotifications() override
{
assertInGuiThread();
return this->notifications;
}
HighlightController *getHighlights() override
{
assertInGuiThread();
return this->highlights;
}
ITwitchIrcServer *getTwitch() override; ITwitchIrcServer *getTwitch() override;
PubSub *getTwitchPubSub() override; PubSub *getTwitchPubSub() override;
Logging *getChatLogger() override; Logging *getChatLogger() override;
FfzBadges *getFfzBadges() override FfzBadges *getFfzBadges() override;
{ SeventvBadges *getSeventvBadges() override;
assertInGuiThread();
return this->ffzBadges;
}
SeventvBadges *getSeventvBadges() override
{
assertInGuiThread();
return this->seventvBadges;
}
IUserDataController *getUserData() override; IUserDataController *getUserData() override;
ISoundController *getSound() override; ISoundController *getSound() override;
ITwitchLiveController *getTwitchLiveController() override; ITwitchLiveController *getTwitchLiveController() override;
TwitchBadges *getTwitchBadges() override; TwitchBadges *getTwitchBadges() override;
IChatterinoBadges *getChatterinoBadges() override; IChatterinoBadges *getChatterinoBadges() override;
ImageUploader *getImageUploader() override ImageUploader *getImageUploader() override;
{ SeventvAPI *getSeventvAPI() override;
assertInGuiThread(); #ifdef CHATTERINO_HAVE_PLUGINS
PluginController *getPlugins() override;
return this->imageUploader; #endif
}
SeventvAPI *getSeventvAPI() override
{
assertInGuiThread();
return this->seventvAPI;
}
Updates &getUpdates() override Updates &getUpdates() override
{ {
assertInGuiThread(); assertInGuiThread();

View file

@ -120,7 +120,8 @@ const std::unordered_map<QString, VariableReplacer> COMMAND_VARS{
[](const auto &altText, const auto &channel, const auto *message) { [](const auto &altText, const auto &channel, const auto *message) {
(void)(channel); //unused (void)(channel); //unused
(void)(message); //unused (void)(message); //unused
auto uid = getApp()->accounts->twitch.getCurrent()->getUserId(); auto uid =
getIApp()->getAccounts()->twitch.getCurrent()->getUserId();
return uid.isEmpty() ? altText : uid; return uid.isEmpty() ? altText : uid;
}, },
}, },
@ -129,7 +130,8 @@ const std::unordered_map<QString, VariableReplacer> COMMAND_VARS{
[](const auto &altText, const auto &channel, const auto *message) { [](const auto &altText, const auto &channel, const auto *message) {
(void)(channel); //unused (void)(channel); //unused
(void)(message); //unused (void)(message); //unused
auto name = getApp()->accounts->twitch.getCurrent()->getUserName(); auto name =
getIApp()->getAccounts()->twitch.getCurrent()->getUserName();
return name.isEmpty() ? altText : name; return name.isEmpty() ? altText : name;
}, },
}, },
@ -560,7 +562,7 @@ bool CommandController::registerPluginCommand(const QString &commandName)
} }
this->commands_[commandName] = [commandName](const CommandContext &ctx) { this->commands_[commandName] = [commandName](const CommandContext &ctx) {
return getApp()->plugins->tryExecPluginCommand(commandName, ctx); return getIApp()->getPlugins()->tryExecPluginCommand(commandName, ctx);
}; };
this->pluginCommands_.append(commandName); this->pluginCommands_.append(commandName);
return true; return true;

View file

@ -219,7 +219,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 (getApp()->accounts->twitch.getCurrent()->isAnon()) if (getIApp()->getAccounts()->twitch.getCurrent()->isAnon())
{ {
ctx.channel->addMessage(makeSystemMessage( ctx.channel->addMessage(makeSystemMessage(
"You need to be logged in to create stream markers!")); "You need to be logged in to create stream markers!"));
@ -365,8 +365,12 @@ QString popup(const CommandContext &ctx)
// Popup the current split // Popup the current split
if (target.isEmpty()) if (target.isEmpty())
{ {
auto *currentPage = dynamic_cast<SplitContainer *>( auto *currentPage =
getApp()->windows->getMainWindow().getNotebook().getSelectedPage()); dynamic_cast<SplitContainer *>(getIApp()
->getWindows()
->getMainWindow()
.getNotebook()
.getSelectedPage());
if (currentPage != nullptr) if (currentPage != nullptr)
{ {
auto *currentSplit = currentPage->getSelectedSplit(); auto *currentSplit = currentPage->getSelectedSplit();
@ -385,7 +389,7 @@ QString popup(const CommandContext &ctx)
// Open channel passed as argument in a popup // Open channel passed as argument in a popup
auto *app = getApp(); auto *app = getApp();
auto targetChannel = app->twitch->getOrAddChannel(target); auto targetChannel = app->twitch->getOrAddChannel(target);
app->windows->openInPopup(targetChannel); app->getWindows()->openInPopup(targetChannel);
return ""; return "";
} }
@ -394,8 +398,11 @@ QString clearmessages(const CommandContext &ctx)
{ {
(void)ctx; (void)ctx;
auto *currentPage = dynamic_cast<SplitContainer *>( auto *currentPage = dynamic_cast<SplitContainer *>(getIApp()
getApp()->windows->getMainWindow().getNotebook().getSelectedPage()); ->getWindows()
->getMainWindow()
.getNotebook()
.getSelectedPage());
if (auto *split = currentPage->getSelectedSplit()) if (auto *split = currentPage->getSelectedSplit())
{ {
@ -580,8 +587,11 @@ 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 *>( auto *currentPage = dynamic_cast<SplitContainer *>(getIApp()
getApp()->windows->getMainWindow().getNotebook().getSelectedPage()); ->getWindows()
->getMainWindow()
.getNotebook()
.getSelectedPage());
if (currentPage != nullptr) if (currentPage != nullptr)
{ {
currentSplit = currentPage->getSelectedSplit(); currentSplit = currentPage->getSelectedSplit();
@ -592,7 +602,8 @@ QString openUsercard(const CommandContext &ctx)
if (differentChannel || currentSplit == nullptr) if (differentChannel || currentSplit == nullptr)
{ {
// not possible to use current split, try searching for one // not possible to use current split, try searching for one
const auto &notebook = getApp()->windows->getMainWindow().getNotebook(); const auto &notebook =
getIApp()->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++)
{ {

View file

@ -34,7 +34,7 @@ QString addModerator(const CommandContext &ctx)
return ""; return "";
} }
auto currentUser = getApp()->accounts->twitch.getCurrent(); auto currentUser = getIApp()->getAccounts()->twitch.getCurrent();
if (currentUser->isAnon()) if (currentUser->isAnon())
{ {
ctx.channel->addMessage( ctx.channel->addMessage(

View file

@ -34,7 +34,7 @@ QString addVIP(const CommandContext &ctx)
return ""; return "";
} }
auto currentUser = getApp()->accounts->twitch.getCurrent(); auto currentUser = getIApp()->getAccounts()->twitch.getCurrent();
if (currentUser->isAnon()) if (currentUser->isAnon())
{ {
ctx.channel->addMessage( ctx.channel->addMessage(

View file

@ -33,7 +33,7 @@ QString sendAnnouncement(const CommandContext &ctx)
return ""; return "";
} }
auto user = getApp()->accounts->twitch.getCurrent(); auto user = getIApp()->getAccounts()->twitch.getCurrent();
if (user->isAnon()) if (user->isAnon())
{ {
ctx.channel->addMessage(makeSystemMessage( ctx.channel->addMessage(makeSystemMessage(

View file

@ -147,7 +147,7 @@ QString sendBan(const CommandContext &ctx)
return ""; return "";
} }
auto currentUser = getApp()->accounts->twitch.getCurrent(); auto currentUser = getIApp()->getAccounts()->twitch.getCurrent();
if (currentUser->isAnon()) if (currentUser->isAnon())
{ {
channel->addMessage( channel->addMessage(
@ -210,7 +210,7 @@ QString sendBanById(const CommandContext &ctx)
return ""; return "";
} }
auto currentUser = getApp()->accounts->twitch.getCurrent(); auto currentUser = getIApp()->getAccounts()->twitch.getCurrent();
if (currentUser->isAnon()) if (currentUser->isAnon())
{ {
channel->addMessage( channel->addMessage(
@ -258,7 +258,7 @@ QString sendTimeout(const CommandContext &ctx)
return ""; return "";
} }
auto currentUser = getApp()->accounts->twitch.getCurrent(); auto currentUser = getIApp()->getAccounts()->twitch.getCurrent();
if (currentUser->isAnon()) if (currentUser->isAnon())
{ {
channel->addMessage( channel->addMessage(

View file

@ -37,7 +37,7 @@ QString blockUser(const CommandContext &ctx)
return ""; return "";
} }
auto currentUser = getApp()->accounts->twitch.getCurrent(); auto currentUser = getIApp()->getAccounts()->twitch.getCurrent();
if (currentUser->isAnon()) if (currentUser->isAnon())
{ {
@ -53,7 +53,7 @@ QString blockUser(const CommandContext &ctx)
target, target,
[currentUser, channel{ctx.channel}, [currentUser, channel{ctx.channel},
target](const HelixUser &targetUser) { target](const HelixUser &targetUser) {
getApp()->accounts->twitch.getCurrent()->blockUser( getIApp()->getAccounts()->twitch.getCurrent()->blockUser(
targetUser.id, nullptr, targetUser.id, nullptr,
[channel, target, targetUser] { [channel, target, targetUser] {
channel->addMessage(makeSystemMessage( channel->addMessage(makeSystemMessage(
@ -111,7 +111,7 @@ QString unblockUser(const CommandContext &ctx)
return ""; return "";
} }
auto currentUser = getApp()->accounts->twitch.getCurrent(); auto currentUser = getIApp()->getAccounts()->twitch.getCurrent();
if (currentUser->isAnon()) if (currentUser->isAnon())
{ {
@ -126,7 +126,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) {
getApp()->accounts->twitch.getCurrent()->unblockUser( getIApp()->getAccounts()->twitch.getCurrent()->unblockUser(
targetUser.id, nullptr, targetUser.id, nullptr,
[channel, target, targetUser] { [channel, target, targetUser] {
channel->addMessage(makeSystemMessage( channel->addMessage(makeSystemMessage(

View file

@ -101,7 +101,7 @@ namespace chatterino::commands {
QString emoteOnly(const CommandContext &ctx) QString emoteOnly(const CommandContext &ctx)
{ {
auto currentUser = getApp()->accounts->twitch.getCurrent(); auto currentUser = getIApp()->getAccounts()->twitch.getCurrent();
if (currentUser->isAnon()) if (currentUser->isAnon())
{ {
ctx.channel->addMessage(makeSystemMessage(P_NOT_LOGGED_IN)); ctx.channel->addMessage(makeSystemMessage(P_NOT_LOGGED_IN));
@ -131,7 +131,7 @@ QString emoteOnly(const CommandContext &ctx)
QString emoteOnlyOff(const CommandContext &ctx) QString emoteOnlyOff(const CommandContext &ctx)
{ {
auto currentUser = getApp()->accounts->twitch.getCurrent(); auto currentUser = getIApp()->getAccounts()->twitch.getCurrent();
if (currentUser->isAnon()) if (currentUser->isAnon())
{ {
ctx.channel->addMessage(makeSystemMessage(P_NOT_LOGGED_IN)); ctx.channel->addMessage(makeSystemMessage(P_NOT_LOGGED_IN));
@ -160,7 +160,7 @@ QString emoteOnlyOff(const CommandContext &ctx)
QString subscribers(const CommandContext &ctx) QString subscribers(const CommandContext &ctx)
{ {
auto currentUser = getApp()->accounts->twitch.getCurrent(); auto currentUser = getIApp()->getAccounts()->twitch.getCurrent();
if (currentUser->isAnon()) if (currentUser->isAnon())
{ {
ctx.channel->addMessage(makeSystemMessage(P_NOT_LOGGED_IN)); ctx.channel->addMessage(makeSystemMessage(P_NOT_LOGGED_IN));
@ -190,7 +190,7 @@ QString subscribers(const CommandContext &ctx)
QString subscribersOff(const CommandContext &ctx) QString subscribersOff(const CommandContext &ctx)
{ {
auto currentUser = getApp()->accounts->twitch.getCurrent(); auto currentUser = getIApp()->getAccounts()->twitch.getCurrent();
if (currentUser->isAnon()) if (currentUser->isAnon())
{ {
ctx.channel->addMessage(makeSystemMessage(P_NOT_LOGGED_IN)); ctx.channel->addMessage(makeSystemMessage(P_NOT_LOGGED_IN));
@ -220,7 +220,7 @@ QString subscribersOff(const CommandContext &ctx)
QString slow(const CommandContext &ctx) QString slow(const CommandContext &ctx)
{ {
auto currentUser = getApp()->accounts->twitch.getCurrent(); auto currentUser = getIApp()->getAccounts()->twitch.getCurrent();
if (currentUser->isAnon()) if (currentUser->isAnon())
{ {
ctx.channel->addMessage(makeSystemMessage(P_NOT_LOGGED_IN)); ctx.channel->addMessage(makeSystemMessage(P_NOT_LOGGED_IN));
@ -267,7 +267,7 @@ QString slow(const CommandContext &ctx)
QString slowOff(const CommandContext &ctx) QString slowOff(const CommandContext &ctx)
{ {
auto currentUser = getApp()->accounts->twitch.getCurrent(); auto currentUser = getIApp()->getAccounts()->twitch.getCurrent();
if (currentUser->isAnon()) if (currentUser->isAnon())
{ {
ctx.channel->addMessage(makeSystemMessage(P_NOT_LOGGED_IN)); ctx.channel->addMessage(makeSystemMessage(P_NOT_LOGGED_IN));
@ -297,7 +297,7 @@ QString slowOff(const CommandContext &ctx)
QString followers(const CommandContext &ctx) QString followers(const CommandContext &ctx)
{ {
auto currentUser = getApp()->accounts->twitch.getCurrent(); auto currentUser = getIApp()->getAccounts()->twitch.getCurrent();
if (currentUser->isAnon()) if (currentUser->isAnon())
{ {
ctx.channel->addMessage(makeSystemMessage(P_NOT_LOGGED_IN)); ctx.channel->addMessage(makeSystemMessage(P_NOT_LOGGED_IN));
@ -345,7 +345,7 @@ QString followers(const CommandContext &ctx)
QString followersOff(const CommandContext &ctx) QString followersOff(const CommandContext &ctx)
{ {
auto currentUser = getApp()->accounts->twitch.getCurrent(); auto currentUser = getIApp()->getAccounts()->twitch.getCurrent();
if (currentUser->isAnon()) if (currentUser->isAnon())
{ {
ctx.channel->addMessage(makeSystemMessage(P_NOT_LOGGED_IN)); ctx.channel->addMessage(makeSystemMessage(P_NOT_LOGGED_IN));
@ -375,7 +375,7 @@ QString followersOff(const CommandContext &ctx)
QString uniqueChat(const CommandContext &ctx) QString uniqueChat(const CommandContext &ctx)
{ {
auto currentUser = getApp()->accounts->twitch.getCurrent(); auto currentUser = getIApp()->getAccounts()->twitch.getCurrent();
if (currentUser->isAnon()) if (currentUser->isAnon())
{ {
ctx.channel->addMessage(makeSystemMessage(P_NOT_LOGGED_IN)); ctx.channel->addMessage(makeSystemMessage(P_NOT_LOGGED_IN));
@ -405,7 +405,7 @@ QString uniqueChat(const CommandContext &ctx)
QString uniqueChatOff(const CommandContext &ctx) QString uniqueChatOff(const CommandContext &ctx)
{ {
auto currentUser = getApp()->accounts->twitch.getCurrent(); auto currentUser = getIApp()->getAccounts()->twitch.getCurrent();
if (currentUser->isAnon()) if (currentUser->isAnon())
{ {
ctx.channel->addMessage(makeSystemMessage(P_NOT_LOGGED_IN)); ctx.channel->addMessage(makeSystemMessage(P_NOT_LOGGED_IN));

View file

@ -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(),
getApp()->accounts->twitch.getCurrent()->getUserId(), 1, getIApp()->getAccounts()->twitch.getCurrent()->getUserId(), 1,
[channel{ctx.channel}](auto result) { [channel{ctx.channel}](auto result) {
channel->addMessage( channel->addMessage(
makeSystemMessage(QString("Chatter count: %1.") makeSystemMessage(QString("Chatter count: %1.")
@ -107,7 +107,7 @@ QString testChatters(const CommandContext &ctx)
getHelix()->getChatters( getHelix()->getChatters(
ctx.twitchChannel->roomId(), ctx.twitchChannel->roomId(),
getApp()->accounts->twitch.getCurrent()->getUserId(), 5000, getIApp()->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)

View file

@ -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 = getApp()->accounts->twitch.getCurrent(); auto user = getIApp()->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())

View file

@ -82,7 +82,7 @@ QString getVIPs(const CommandContext &ctx)
return ""; return "";
} }
auto currentUser = getApp()->accounts->twitch.getCurrent(); auto currentUser = getIApp()->getAccounts()->twitch.getCurrent();
if (currentUser->isAnon()) if (currentUser->isAnon())
{ {
ctx.channel->addMessage(makeSystemMessage( ctx.channel->addMessage(makeSystemMessage(

View file

@ -137,7 +137,7 @@ QString startRaid(const CommandContext &ctx)
return ""; return "";
} }
auto currentUser = getApp()->accounts->twitch.getCurrent(); auto currentUser = getIApp()->getAccounts()->twitch.getCurrent();
if (currentUser->isAnon()) if (currentUser->isAnon())
{ {
ctx.channel->addMessage( ctx.channel->addMessage(
@ -195,7 +195,7 @@ QString cancelRaid(const CommandContext &ctx)
return ""; return "";
} }
auto currentUser = getApp()->accounts->twitch.getCurrent(); auto currentUser = getIApp()->getAccounts()->twitch.getCurrent();
if (currentUser->isAnon()) if (currentUser->isAnon())
{ {
ctx.channel->addMessage( ctx.channel->addMessage(

View file

@ -34,7 +34,7 @@ QString removeModerator(const CommandContext &ctx)
return ""; return "";
} }
auto currentUser = getApp()->accounts->twitch.getCurrent(); auto currentUser = getIApp()->getAccounts()->twitch.getCurrent();
if (currentUser->isAnon()) if (currentUser->isAnon())
{ {
ctx.channel->addMessage( ctx.channel->addMessage(

View file

@ -34,7 +34,7 @@ QString removeVIP(const CommandContext &ctx)
return ""; return "";
} }
auto currentUser = getApp()->accounts->twitch.getCurrent(); auto currentUser = getIApp()->getAccounts()->twitch.getCurrent();
if (currentUser->isAnon()) if (currentUser->isAnon())
{ {
ctx.channel->addMessage( ctx.channel->addMessage(

View file

@ -94,15 +94,16 @@ bool appendWhisperMessageWordsLocally(const QStringList &words)
MessageBuilder b; MessageBuilder b;
b.emplace<TimestampElement>(); b.emplace<TimestampElement>();
b.emplace<TextElement>(app->accounts->twitch.getCurrent()->getUserName(), b.emplace<TextElement>(
app->getAccounts()->twitch.getCurrent()->getUserName(),
MessageElementFlag::Text, MessageColor::Text, MessageElementFlag::Text, MessageColor::Text,
FontStyle::ChatMediumBold); FontStyle::ChatMediumBold);
b.emplace<TextElement>("->", MessageElementFlag::Text, b.emplace<TextElement>("->", MessageElementFlag::Text,
getApp()->themes->messages.textColors.system); getIApp()->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);
const auto &acc = app->accounts->twitch.getCurrent(); const auto &acc = app->getAccounts()->twitch.getCurrent();
const auto &accemotes = *acc->accessEmotes(); const auto &accemotes = *acc->accessEmotes();
const auto &bttvemotes = app->twitch->getBttvEmotes(); const auto &bttvemotes = app->twitch->getBttvEmotes();
const auto &ffzemotes = app->twitch->getFfzEmotes(); const auto &ffzemotes = app->twitch->getFfzEmotes();
@ -208,7 +209,7 @@ QString sendWhisper(const CommandContext &ctx)
return ""; return "";
} }
auto currentUser = getApp()->accounts->twitch.getCurrent(); auto currentUser = getIApp()->getAccounts()->twitch.getCurrent();
if (currentUser->isAnon()) if (currentUser->isAnon())
{ {
ctx.channel->addMessage( ctx.channel->addMessage(

View file

@ -23,7 +23,7 @@ QString toggleShieldMode(const CommandContext &ctx, bool isActivating)
return {}; return {};
} }
auto user = getApp()->accounts->twitch.getCurrent(); auto user = getIApp()->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())

View file

@ -24,7 +24,7 @@ QString sendShoutout(const CommandContext &ctx)
return ""; return "";
} }
auto currentUser = getApp()->accounts->twitch.getCurrent(); auto currentUser = getIApp()->getAccounts()->twitch.getCurrent();
if (currentUser->isAnon()) if (currentUser->isAnon())
{ {
channel->addMessage( channel->addMessage(

View file

@ -100,7 +100,7 @@ QString startCommercial(const CommandContext &ctx)
return ""; return "";
} }
auto user = getApp()->accounts->twitch.getCurrent(); auto user = getIApp()->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())

View file

@ -106,7 +106,7 @@ QString unbanUser(const CommandContext &ctx)
return ""; return "";
} }
auto currentUser = getApp()->accounts->twitch.getCurrent(); auto currentUser = getIApp()->getAccounts()->twitch.getCurrent();
if (currentUser->isAnon()) if (currentUser->isAnon())
{ {
ctx.channel->addMessage( ctx.channel->addMessage(

View file

@ -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 = getApp()->accounts->twitch.getCurrent(); auto user = getIApp()->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())

View file

@ -38,7 +38,8 @@ void TabCompletionModel::updateResults(const QString &query,
#ifdef CHATTERINO_HAVE_PLUGINS #ifdef CHATTERINO_HAVE_PLUGINS
// Try plugins first // Try plugins first
bool done{}; bool done{};
std::tie(done, results) = getApp()->plugins->updateCustomCompletions( std::tie(done, results) =
getIApp()->getPlugins()->updateCustomCompletions(
query, fullTextContent, cursorPosition, isFirstWord); query, fullTextContent, cursorPosition, isFirstWord);
if (done) if (done)
{ {

View file

@ -71,7 +71,7 @@ void CommandSource::initializeItems()
std::vector<CommandItem> commands; std::vector<CommandItem> commands;
#ifdef CHATTERINO_HAVE_PLUGINS #ifdef CHATTERINO_HAVE_PLUGINS
for (const auto &command : getApp()->commands->pluginCommands()) for (const auto &command : getIApp()->getCommands()->pluginCommands())
{ {
addCommand(command, commands); addCommand(command, commands);
} }

View file

@ -509,7 +509,7 @@ void HighlightModel::customRowSetData(const std::vector<QStandardItem *> &row,
break; break;
} }
getApp()->windows->forceLayoutChannelViews(); getIApp()->getWindows()->forceLayoutChannelViews();
} }
} // namespace chatterino } // namespace chatterino

View file

@ -113,7 +113,7 @@ void UserHighlightModel::customRowSetData(
break; break;
} }
getApp()->windows->forceLayoutChannelViews(); getIApp()->getWindows()->forceLayoutChannelViews();
} }
// row into vector item // row into vector item

View file

@ -58,7 +58,7 @@ std::vector<QString> Hotkey::arguments() const
QString Hotkey::getCategory() const QString Hotkey::getCategory() const
{ {
return getApp()->hotkeys->categoryDisplayName(this->category_); return getIApp()->getHotkeys()->categoryDisplayName(this->category_);
} }
Qt::ShortcutContext Hotkey::getContext() const Qt::ShortcutContext Hotkey::getContext() const

View file

@ -95,7 +95,7 @@ bool IgnorePhrase::containsEmote() const
{ {
if (!this->emotesChecked_) if (!this->emotesChecked_)
{ {
const auto &accvec = getApp()->accounts->twitch.accounts; const auto &accvec = getIApp()->getAccounts()->twitch.accounts;
for (const auto &acc : accvec) for (const auto &acc : accvec)
{ {
const auto &accemotes = *acc->accessEmotes(); const auto &accemotes = *acc->accessEmotes();

View file

@ -183,20 +183,20 @@ void NotificationController::checkStream(bool live, QString channelName)
if (Toasts::isEnabled()) if (Toasts::isEnabled())
{ {
getApp()->toasts->sendChannelNotification(channelName, QString(), getIApp()->getToasts()->sendChannelNotification(channelName, QString(),
Platform::Twitch); Platform::Twitch);
} }
if (getSettings()->notificationPlaySound && if (getSettings()->notificationPlaySound &&
!(isInStreamerMode() && !(isInStreamerMode() &&
getSettings()->streamerModeSuppressLiveNotifications)) getSettings()->streamerModeSuppressLiveNotifications))
{ {
getApp()->notifications->playSound(); getIApp()->getNotifications()->playSound();
} }
if (getSettings()->notificationFlashTaskbar && if (getSettings()->notificationFlashTaskbar &&
!(isInStreamerMode() && !(isInStreamerMode() &&
getSettings()->streamerModeSuppressLiveNotifications)) getSettings()->streamerModeSuppressLiveNotifications))
{ {
getApp()->windows->sendAlert(); getIApp()->getWindows()->sendAlert();
} }
MessageBuilder builder; MessageBuilder builder;
TwitchMessageBuilder::liveMessage(channelName, &builder); TwitchMessageBuilder::liveMessage(channelName, &builder);

View file

@ -63,7 +63,7 @@ namespace chatterino::lua::api {
int c2_register_command(lua_State *L) int c2_register_command(lua_State *L)
{ {
auto *pl = getApp()->plugins->getPluginByStatePtr(L); auto *pl = getIApp()->getPlugins()->getPluginByStatePtr(L);
if (pl == nullptr) if (pl == nullptr)
{ {
luaL_error(L, "internal error: no plugin"); luaL_error(L, "internal error: no plugin");
@ -97,7 +97,7 @@ int c2_register_command(lua_State *L)
int c2_register_callback(lua_State *L) int c2_register_callback(lua_State *L)
{ {
auto *pl = getApp()->plugins->getPluginByStatePtr(L); auto *pl = getIApp()->getPlugins()->getPluginByStatePtr(L);
if (pl == nullptr) if (pl == nullptr)
{ {
luaL_error(L, "internal error: no plugin"); luaL_error(L, "internal error: no plugin");
@ -155,7 +155,7 @@ int c2_send_msg(lua_State *L)
const auto chn = getApp()->twitch->getChannelOrEmpty(channel); const auto chn = getApp()->twitch->getChannelOrEmpty(channel);
if (chn->isEmpty()) if (chn->isEmpty())
{ {
auto *pl = getApp()->plugins->getPluginByStatePtr(L); auto *pl = getIApp()->getPlugins()->getPluginByStatePtr(L);
qCWarning(chatterinoLua) qCWarning(chatterinoLua)
<< "Plugin" << pl->id << "Plugin" << pl->id
@ -166,7 +166,8 @@ int c2_send_msg(lua_State *L)
} }
QString message = text; QString message = text;
message = message.replace('\n', ' '); message = message.replace('\n', ' ');
QString outText = getApp()->commands->execCommand(message, chn, false); QString outText =
getIApp()->getCommands()->execCommand(message, chn, false);
chn->sendMessage(outText); chn->sendMessage(outText);
lua::push(L, true); lua::push(L, true);
return 1; return 1;
@ -203,7 +204,7 @@ int c2_system_msg(lua_State *L)
const auto chn = getApp()->twitch->getChannelOrEmpty(channel); const auto chn = getApp()->twitch->getChannelOrEmpty(channel);
if (chn->isEmpty()) if (chn->isEmpty())
{ {
auto *pl = getApp()->plugins->getPluginByStatePtr(L); auto *pl = getIApp()->getPlugins()->getPluginByStatePtr(L);
qCWarning(chatterinoLua) qCWarning(chatterinoLua)
<< "Plugin" << pl->id << "Plugin" << pl->id
<< "tried to show a system message (using system_msg) in channel" << "tried to show a system message (using system_msg) in channel"
@ -218,7 +219,7 @@ int c2_system_msg(lua_State *L)
int c2_log(lua_State *L) int c2_log(lua_State *L)
{ {
auto *pl = getApp()->plugins->getPluginByStatePtr(L); auto *pl = getIApp()->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?");
@ -285,7 +286,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 = getApp()->plugins->getPluginByStatePtr(L); auto *pl = getIApp()->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?");
@ -327,7 +328,7 @@ int searcherAbsolute(lua_State *L)
name = name.replace('.', QDir::separator()); name = name.replace('.', QDir::separator());
QString filename; QString filename;
auto *pl = getApp()->plugins->getPluginByStatePtr(L); auto *pl = getIApp()->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?");
@ -368,7 +369,7 @@ int searcherRelative(lua_State *L)
int g_print(lua_State *L) int g_print(lua_State *L)
{ {
auto *pl = getApp()->plugins->getPluginByStatePtr(L); auto *pl = getIApp()->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?");

View file

@ -146,7 +146,7 @@ bool Plugin::registerCommand(const QString &name, const QString &functionName)
return false; return false;
} }
auto ok = getApp()->commands->registerPluginCommand(name); auto ok = getIApp()->getCommands()->registerPluginCommand(name);
if (!ok) if (!ok)
{ {
return false; return false;

View file

@ -281,7 +281,7 @@ bool PluginController::reload(const QString &id)
} }
for (const auto &[cmd, _] : it->second->ownedCommands) for (const auto &[cmd, _] : it->second->ownedCommands)
{ {
getApp()->commands->unregisterPluginCommand(cmd); getIApp()->getCommands()->unregisterPluginCommand(cmd);
} }
it->second->ownedCommands.clear(); it->second->ownedCommands.clear();
QDir loadDir = it->second->loadDirectory_; QDir loadDir = it->second->loadDirectory_;

View file

@ -252,7 +252,7 @@ namespace detail {
} }
} }
getApp()->windows->forceLayoutChannelViews(); getIApp()->getWindows()->forceLayoutChannelViews();
loadedEventQueued = false; loadedEventQueued = false;
} }

View file

@ -204,7 +204,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 = getApp()->accounts->twitch.getCurrent(); auto current = getIApp()->getAccounts()->twitch.getCurrent();
this->emplace<TimestampElement>(); this->emplace<TimestampElement>();
this->message().flags.set(MessageFlag::System); this->message().flags.set(MessageFlag::System);
@ -682,7 +682,8 @@ 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 = defaultColorType.getColor(*getApp()->themes); const auto &defaultColor =
defaultColorType.getColor(*getIApp()->getThemes());
QColor textColor = defaultColor; QColor textColor = defaultColor;
int fg = -1; int fg = -1;
int bg = -1; int bg = -1;
@ -726,7 +727,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];
getApp()->themes->normalizeColor(textColor); getIApp()->getThemes()->normalizeColor(textColor);
} }
else else
{ {
@ -766,7 +767,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];
getApp()->themes->normalizeColor(textColor); getIApp()->getThemes()->normalizeColor(textColor);
} }
else else
{ {

View file

@ -522,14 +522,14 @@ void TextElement::addToContainer(MessageLayoutContainer &container,
if (flags.hasAny(this->getFlags())) if (flags.hasAny(this->getFlags()))
{ {
QFontMetrics metrics = QFontMetrics metrics =
app->fonts->getFontMetrics(this->style_, container.getScale()); app->getFonts()->getFontMetrics(this->style_, container.getScale());
for (Word &word : this->words_) for (Word &word : this->words_)
{ {
auto getTextLayoutElement = [&](QString text, int width, auto getTextLayoutElement = [&](QString text, int width,
bool hasTrailingSpace) { bool hasTrailingSpace) {
auto color = this->color_.getColor(*app->themes); auto color = this->color_.getColor(*app->getThemes());
app->themes->normalizeColor(color); app->getThemes()->normalizeColor(color);
auto *e = (new TextLayoutElement( auto *e = (new TextLayoutElement(
*this, text, QSize(width, metrics.height()), *this, text, QSize(width, metrics.height()),
@ -642,12 +642,12 @@ void SingleLineTextElement::addToContainer(MessageLayoutContainer &container,
if (flags.hasAny(this->getFlags())) if (flags.hasAny(this->getFlags()))
{ {
QFontMetrics metrics = QFontMetrics metrics =
app->fonts->getFontMetrics(this->style_, container.getScale()); app->getFonts()->getFontMetrics(this->style_, container.getScale());
auto getTextLayoutElement = [&](QString text, int width, auto getTextLayoutElement = [&](QString text, int width,
bool hasTrailingSpace) { bool hasTrailingSpace) {
auto color = this->color_.getColor(*app->themes); auto color = this->color_.getColor(*app->getThemes());
app->themes->normalizeColor(color); app->getThemes()->normalizeColor(color);
auto *e = (new TextLayoutElement( auto *e = (new TextLayoutElement(
*this, text, QSize(width, metrics.height()), color, *this, text, QSize(width, metrics.height()), color,

View file

@ -236,7 +236,7 @@ void SharedMessageBuilder::triggerHighlights(
if (windowAlert) if (windowAlert)
{ {
getApp()->windows->sendAlert(); getIApp()->getWindows()->sendAlert();
} }
} }

View file

@ -78,8 +78,6 @@ bool MessageLayout::layout(int width, float scale, MessageElementFlags flags)
{ {
// BenchmarkGuard benchmark("MessageLayout::layout()"); // BenchmarkGuard benchmark("MessageLayout::layout()");
auto *app = getApp();
bool layoutRequired = false; bool layoutRequired = false;
// check if width changed // check if width changed
@ -88,11 +86,12 @@ bool MessageLayout::layout(int width, float scale, MessageElementFlags flags)
this->currentLayoutWidth_ = width; this->currentLayoutWidth_ = width;
// check if layout state changed // check if layout state changed
if (this->layoutState_ != app->windows->getGeneration()) const auto layoutGeneration = getIApp()->getWindows()->getGeneration();
if (this->layoutState_ != layoutGeneration)
{ {
layoutRequired = true; layoutRequired = true;
this->flags.set(MessageLayoutFlag::RequiresBufferUpdate); this->flags.set(MessageLayoutFlag::RequiresBufferUpdate);
this->layoutState_ = app->windows->getGeneration(); this->layoutState_ = layoutGeneration;
} }
// check if work mask changed // check if work mask changed

View file

@ -47,7 +47,7 @@ void MessageLayoutContainer::beginLayout(int width, float scale,
this->scale_ = scale; this->scale_ = scale;
this->flags_ = flags; this->flags_ = flags;
auto mediumFontMetrics = auto mediumFontMetrics =
getApp()->fonts->getFontMetrics(FontStyle::ChatMedium, scale); getIApp()->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("...");

View file

@ -442,7 +442,7 @@ void TextLayoutElement::paint(QPainter &painter,
painter.setPen(this->color_); painter.setPen(this->color_);
painter.setFont(app->fonts->getFont(this->style_, this->scale_)); painter.setFont(app->getFonts()->getFont(this->style_, this->scale_));
painter.drawText( painter.drawText(
QRectF(this->getRect().x(), this->getRect().y(), 10000, 10000), text, QRectF(this->getRect().x(), this->getRect().y(), 10000, 10000), text,
@ -463,7 +463,7 @@ int TextLayoutElement::getMouseOverIndex(const QPoint &abs) const
auto *app = getApp(); auto *app = getApp();
auto metrics = app->fonts->getFontMetrics(this->style_, this->scale_); auto metrics = app->getFonts()->getFontMetrics(this->style_, this->scale_);
auto x = this->getRect().left(); auto x = this->getRect().left();
for (auto i = 0; i < this->getText().size(); i++) for (auto i = 0; i < this->getText().size(); i++)
@ -498,7 +498,7 @@ int TextLayoutElement::getXFromIndex(size_t index)
auto *app = getApp(); auto *app = getApp();
QFontMetrics metrics = QFontMetrics metrics =
app->fonts->getFontMetrics(this->style_, this->scale_); app->getFonts()->getFontMetrics(this->style_, this->scale_);
if (index <= 0) if (index <= 0)
{ {
@ -546,7 +546,7 @@ void TextIconLayoutElement::paint(QPainter &painter,
{ {
auto *app = getApp(); auto *app = getApp();
QFont font = app->fonts->getFont(FontStyle::Tiny, this->scale); QFont font = app->getFonts()->getFont(FontStyle::Tiny, this->scale);
painter.setPen(messageColors.system); painter.setPen(messageColors.system);
painter.setFont(font); painter.setFont(font);

View file

@ -347,9 +347,7 @@ void SeventvEventAPI::onUserUpdate(const Dispatch &dispatch)
void SeventvEventAPI::onCosmeticCreate(const CosmeticCreateDispatch &cosmetic) void SeventvEventAPI::onCosmeticCreate(const CosmeticCreateDispatch &cosmetic)
{ {
// We're using `Application::instance` instead of getApp(), because we're not in the GUI thread. auto *badges = getIApp()->getSeventvBadges();
// `seventvBadges` does its own locking.
auto *badges = Application::instance->seventvBadges;
switch (cosmetic.kind) switch (cosmetic.kind)
{ {
case CosmeticKind::Badge: { case CosmeticKind::Badge: {
@ -364,9 +362,7 @@ void SeventvEventAPI::onCosmeticCreate(const CosmeticCreateDispatch &cosmetic)
void SeventvEventAPI::onEntitlementCreate( void SeventvEventAPI::onEntitlementCreate(
const EntitlementCreateDeleteDispatch &entitlement) const EntitlementCreateDeleteDispatch &entitlement)
{ {
// We're using `Application::instance` instead of getApp(), because we're not in the GUI thread. auto *badges = getIApp()->getSeventvBadges();
// `seventvBadges` does its own locking.
auto *badges = Application::instance->seventvBadges;
switch (entitlement.kind) switch (entitlement.kind)
{ {
case CosmeticKind::Badge: { case CosmeticKind::Badge: {
@ -382,9 +378,7 @@ void SeventvEventAPI::onEntitlementCreate(
void SeventvEventAPI::onEntitlementDelete( void SeventvEventAPI::onEntitlementDelete(
const EntitlementCreateDeleteDispatch &entitlement) const EntitlementCreateDeleteDispatch &entitlement)
{ {
// We're using `Application::instance` instead of getApp(), because we're not in the GUI thread. auto *badges = getIApp()->getSeventvBadges();
// `seventvBadges` does its own locking.
auto *badges = Application::instance->seventvBadges;
switch (entitlement.kind) switch (entitlement.kind)
{ {
case CosmeticKind::Badge: { case CosmeticKind::Badge: {

View file

@ -386,7 +386,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 = getApp()->accounts->twitch.getCurrent(); const auto curUser = getIApp()->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.");
@ -774,10 +774,10 @@ void IrcMessageHandler::handleClearChatMessage(Communi::IrcMessage *message)
chan->addOrReplaceTimeout(std::move(clearChat.message)); chan->addOrReplaceTimeout(std::move(clearChat.message));
// refresh all // refresh all
getApp()->windows->repaintVisibleChatWidgets(chan.get()); getIApp()->getWindows()->repaintVisibleChatWidgets(chan.get());
if (getSettings()->hideModerated) if (getSettings()->hideModerated)
{ {
getApp()->windows->forceLayoutChannelViews(); getIApp()->getWindows()->forceLayoutChannelViews();
} }
} }
@ -828,7 +828,7 @@ void IrcMessageHandler::handleClearMessageMessage(Communi::IrcMessage *message)
void IrcMessageHandler::handleUserStateMessage(Communi::IrcMessage *message) void IrcMessageHandler::handleUserStateMessage(Communi::IrcMessage *message)
{ {
auto currentUser = getApp()->accounts->twitch.getCurrent(); auto currentUser = getIApp()->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(
@ -880,7 +880,7 @@ void IrcMessageHandler::handleUserStateMessage(Communi::IrcMessage *message)
void IrcMessageHandler::handleGlobalUserStateMessage( void IrcMessageHandler::handleGlobalUserStateMessage(
Communi::IrcMessage *message) Communi::IrcMessage *message)
{ {
auto currentUser = getApp()->accounts->twitch.getCurrent(); auto currentUser = getIApp()->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
@ -1134,7 +1134,7 @@ void IrcMessageHandler::handleJoinMessage(Communi::IrcMessage *message)
} }
if (message->nick() == if (message->nick() ==
getApp()->accounts->twitch.getCurrent()->getUserName()) getIApp()->getAccounts()->twitch.getCurrent()->getUserName())
{ {
twitchChannel->addMessage(makeSystemMessage("joined channel")); twitchChannel->addMessage(makeSystemMessage("joined channel"));
twitchChannel->joined.invoke(); twitchChannel->joined.invoke();
@ -1157,7 +1157,7 @@ void IrcMessageHandler::handlePartMessage(Communi::IrcMessage *message)
} }
const auto selfAccountName = const auto selfAccountName =
getApp()->accounts->twitch.getCurrent()->getUserName(); getIApp()->getAccounts()->twitch.getCurrent()->getUserName();
if (message->nick() != selfAccountName && if (message->nick() != selfAccountName &&
getSettings()->showParts.getValue()) getSettings()->showParts.getValue())
{ {
@ -1207,8 +1207,9 @@ void IrcMessageHandler::setSimilarityFlags(const MessagePtr &message,
{ {
if (getSettings()->similarityEnabled) if (getSettings()->similarityEnabled)
{ {
bool isMyself = message->loginName == bool isMyself =
getApp()->accounts->twitch.getCurrent()->getUserName(); message->loginName ==
getIApp()->getAccounts()->twitch.getCurrent()->getUserName();
bool hideMyself = getSettings()->hideSimilarMyself; bool hideMyself = getSettings()->hideSimilarMyself;
if (isMyself && !hideMyself) if (isMyself && !hideMyself)

View file

@ -94,7 +94,7 @@ TwitchChannel::TwitchChannel(const QString &name)
} }
this->bSignals_.emplace_back( this->bSignals_.emplace_back(
getApp()->accounts->twitch.currentUserChanged.connect([this] { getIApp()->getAccounts()->twitch.currentUserChanged.connect([this] {
this->setMod(false); this->setMod(false);
this->refreshPubSub(); this->refreshPubSub();
})); }));
@ -141,22 +141,22 @@ TwitchChannel::TwitchChannel(const QString &name)
{ {
qCDebug(chatterinoTwitch) qCDebug(chatterinoTwitch)
<< "[TwitchChannel" << this->getName() << "] Online"; << "[TwitchChannel" << this->getName() << "] Online";
if (getApp()->notifications->isChannelNotified(this->getName(), if (getIApp()->getNotifications()->isChannelNotified(
Platform::Twitch)) this->getName(), Platform::Twitch))
{ {
if (Toasts::isEnabled()) if (Toasts::isEnabled())
{ {
getApp()->toasts->sendChannelNotification( getIApp()->getToasts()->sendChannelNotification(
this->getName(), this->accessStreamStatus()->title, this->getName(), this->accessStreamStatus()->title,
Platform::Twitch); Platform::Twitch);
} }
if (getSettings()->notificationPlaySound) if (getSettings()->notificationPlaySound)
{ {
getApp()->notifications->playSound(); getIApp()->getNotifications()->playSound();
} }
if (getSettings()->notificationFlashTaskbar) if (getSettings()->notificationFlashTaskbar)
{ {
getApp()->windows->sendAlert(); getIApp()->getWindows()->sendAlert();
} }
} }
// Channel live message // Channel live message
@ -176,7 +176,7 @@ TwitchChannel::TwitchChannel(const QString &name)
!(isInStreamerMode() && !(isInStreamerMode() &&
getSettings()->streamerModeSuppressLiveNotifications)) getSettings()->streamerModeSuppressLiveNotifications))
{ {
getApp()->notifications->playSound(); getIApp()->getNotifications()->playSound();
} }
} }
else else
@ -538,7 +538,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 = getApp()->accounts->twitch.getCurrent(); const auto currentUser = getIApp()->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");
@ -622,7 +622,7 @@ QString TwitchChannel::prepareMessage(const QString &message) const
void TwitchChannel::sendMessage(const QString &message) void TwitchChannel::sendMessage(const QString &message)
{ {
auto *app = getApp(); auto *app = getApp();
if (!app->accounts->twitch.isLoggedIn()) if (!app->getAccounts()->twitch.isLoggedIn())
{ {
if (!message.isEmpty()) if (!message.isEmpty())
{ {
@ -656,7 +656,7 @@ void TwitchChannel::sendMessage(const QString &message)
void TwitchChannel::sendReply(const QString &message, const QString &replyId) void TwitchChannel::sendReply(const QString &message, const QString &replyId)
{ {
auto *app = getApp(); auto *app = getApp();
if (!app->accounts->twitch.isLoggedIn()) if (!app->getAccounts()->twitch.isLoggedIn())
{ {
if (!message.isEmpty()) if (!message.isEmpty())
{ {
@ -864,7 +864,8 @@ void TwitchChannel::joinBttvChannel() const
{ {
if (getApp()->twitch->bttvLiveUpdates) if (getApp()->twitch->bttvLiveUpdates)
{ {
const auto currentAccount = getApp()->accounts->twitch.getCurrent(); const auto currentAccount =
getIApp()->getAccounts()->twitch.getCurrent();
QString userName; QString userName;
if (currentAccount && !currentAccount->isAnon()) if (currentAccount && !currentAccount->isAnon())
{ {
@ -1307,7 +1308,7 @@ void TwitchChannel::refreshPubSub()
return; return;
} }
auto currentAccount = getApp()->accounts->twitch.getCurrent(); auto currentAccount = getIApp()->getAccounts()->twitch.getCurrent();
getIApp()->getTwitchPubSub()->setAccount(currentAccount); getIApp()->getTwitchPubSub()->setAccount(currentAccount);
@ -1342,7 +1343,8 @@ void TwitchChannel::refreshChatters()
// Get chatter list via helix api // Get chatter list via helix api
getHelix()->getChatters( getHelix()->getChatters(
this->roomId(), getApp()->accounts->twitch.getCurrent()->getUserId(), this->roomId(),
getIApp()->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())
@ -1731,7 +1733,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 =
getApp()->accounts->twitch.getCurrent()->getSeventvUserID(); getIApp()->getAccounts()->twitch.getCurrent()->getSeventvUserID();
if (currentSeventvUserID.isEmpty()) if (currentSeventvUserID.isEmpty())
{ {
return; return;

View file

@ -66,7 +66,7 @@ TwitchIrcServer::TwitchIrcServer()
void TwitchIrcServer::initialize(Settings &settings, const Paths &paths) void TwitchIrcServer::initialize(Settings &settings, const Paths &paths)
{ {
getApp()->accounts->twitch.currentUserChanged.connect([this]() { getIApp()->getAccounts()->twitch.currentUserChanged.connect([this]() {
postToThread([this] { postToThread([this] {
this->connect(); this->connect();
}); });
@ -81,7 +81,7 @@ void TwitchIrcServer::initializeConnection(IrcConnection *connection,
ConnectionType type) ConnectionType type)
{ {
std::shared_ptr<TwitchAccount> account = std::shared_ptr<TwitchAccount> account =
getApp()->accounts->twitch.getCurrent(); getIApp()->getAccounts()->twitch.getCurrent();
qCDebug(chatterinoTwitch) << "logging in as" << account->getUserName(); qCDebug(chatterinoTwitch) << "logging in as" << account->getUserName();

View file

@ -111,7 +111,7 @@ void Fonts::initialize(Settings &, const Paths &)
assertInGuiThread(); assertInGuiThread();
// REMOVED // REMOVED
getApp()->windows->incGeneration(); getIApp()->getWindows()->incGeneration();
for (auto &map : this->fontsByType_) for (auto &map : this->fontsByType_)
{ {

View file

@ -121,7 +121,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, [] {
getApp()->windows->save(); getIApp()->getWindows()->save();
}); });
} }
@ -346,7 +346,8 @@ void WindowManager::initialize(Settings &settings, const Paths &paths)
// 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 = getApp()->themes->repaintVisibleChatWidgets_.connect([this] { std::ignore =
getIApp()->getThemes()->repaintVisibleChatWidgets_.connect([this] {
this->repaintVisibleChatWidgets(); this->repaintVisibleChatWidgets();
}); });

View file

@ -31,7 +31,7 @@ void GIFTimer::initialize()
this->position_ += GIF_FRAME_LENGTH; this->position_ += GIF_FRAME_LENGTH;
this->signal.invoke(); this->signal.invoke();
getApp()->windows->repaintGifEmotes(); getIApp()->getWindows()->repaintGifEmotes();
}); });
} }

View file

@ -184,8 +184,11 @@ 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 *>( auto *currentPage = dynamic_cast<SplitContainer *>(getIApp()
getApp()->windows->getMainWindow().getNotebook().getSelectedPage()); ->getWindows()
->getMainWindow()
.getNotebook()
.getSelectedPage());
if (currentPage != nullptr) if (currentPage != nullptr)
{ {
auto *currentSplit = currentPage->getSelectedSplit(); auto *currentSplit = currentPage->getSelectedSplit();

View file

@ -15,20 +15,21 @@ AccountSwitchWidget::AccountSwitchWidget(QWidget *parent)
this->addItem(ANONYMOUS_USERNAME_LABEL); this->addItem(ANONYMOUS_USERNAME_LABEL);
for (const auto &userName : app->accounts->twitch.getUsernames()) for (const auto &userName : app->getAccounts()->twitch.getUsernames())
{ {
this->addItem(userName); this->addItem(userName);
} }
this->managedConnections_.managedConnect( this->managedConnections_.managedConnect(
app->accounts->twitch.userListUpdated, [=, this]() { app->getAccounts()->twitch.userListUpdated, [=, this]() {
this->blockSignals(true); this->blockSignals(true);
this->clear(); this->clear();
this->addItem(ANONYMOUS_USERNAME_LABEL); this->addItem(ANONYMOUS_USERNAME_LABEL);
for (const auto &userName : app->accounts->twitch.getUsernames()) for (const auto &userName :
app->getAccounts()->twitch.getUsernames())
{ {
this->addItem(userName); this->addItem(userName);
} }
@ -47,11 +48,11 @@ AccountSwitchWidget::AccountSwitchWidget(QWidget *parent)
if (newUsername.compare(ANONYMOUS_USERNAME_LABEL, if (newUsername.compare(ANONYMOUS_USERNAME_LABEL,
Qt::CaseInsensitive) == 0) Qt::CaseInsensitive) == 0)
{ {
app->accounts->twitch.currentUsername = ""; app->getAccounts()->twitch.currentUsername = "";
} }
else else
{ {
app->accounts->twitch.currentUsername = newUsername; app->getAccounts()->twitch.currentUsername = newUsername;
} }
} }
}); });
@ -71,7 +72,7 @@ void AccountSwitchWidget::refreshSelection()
{ {
auto *app = getApp(); auto *app = getApp();
auto currentUser = app->accounts->twitch.getCurrent(); auto currentUser = app->getAccounts()->twitch.getCurrent();
if (currentUser->isAnon()) if (currentUser->isAnon())
{ {

View file

@ -508,7 +508,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))
{ {
getApp()->windows->queueSave(); getIApp()->getWindows()->queueSave();
} }
#ifdef USEWINSDK #ifdef USEWINSDK
@ -540,7 +540,7 @@ void BaseWindow::moveEvent(QMoveEvent *event)
#ifdef CHATTERINO #ifdef CHATTERINO
if (!flags_.has(DisableLayoutSave)) if (!flags_.has(DisableLayoutSave))
{ {
getApp()->windows->queueSave(); getIApp()->getWindows()->queueSave();
} }
#endif #endif

View file

@ -70,7 +70,7 @@ Notebook::Notebook(QWidget *parent)
NotebookTab *Notebook::addPage(QWidget *page, QString title, bool select) NotebookTab *Notebook::addPage(QWidget *page, QString title, bool select)
{ {
// Queue up save because: Tab added // Queue up save because: Tab added
getApp()->windows->queueSave(); getIApp()->getWindows()->queueSave();
auto *tab = new NotebookTab(this); auto *tab = new NotebookTab(this);
tab->page = page; tab->page = page;
@ -100,7 +100,7 @@ NotebookTab *Notebook::addPage(QWidget *page, QString title, bool select)
void Notebook::removePage(QWidget *page) void Notebook::removePage(QWidget *page)
{ {
// Queue up save because: Tab removed // Queue up save because: Tab removed
getApp()->windows->queueSave(); getIApp()->getWindows()->queueSave();
int removingIndex = this->indexOf(page); int removingIndex = this->indexOf(page);
assert(removingIndex != -1); assert(removingIndex != -1);
@ -491,7 +491,7 @@ void Notebook::rearrangePage(QWidget *page, int index)
} }
// Queue up save because: Tab rearranged // Queue up save because: Tab rearranged
getApp()->windows->queueSave(); getIApp()->getWindows()->queueSave();
this->items_.move(this->indexOf(page), index); this->items_.move(this->indexOf(page), index);
@ -532,16 +532,16 @@ void Notebook::setShowTabs(bool value)
void Notebook::showTabVisibilityInfoPopup() void Notebook::showTabVisibilityInfoPopup()
{ {
auto unhideSeq = getApp()->hotkeys->getDisplaySequence( auto unhideSeq = getIApp()->getHotkeys()->getDisplaySequence(
HotkeyCategory::Window, "setTabVisibility", {std::vector<QString>()}); HotkeyCategory::Window, "setTabVisibility", {std::vector<QString>()});
if (unhideSeq.isEmpty()) if (unhideSeq.isEmpty())
{ {
unhideSeq = getApp()->hotkeys->getDisplaySequence( unhideSeq = getIApp()->getHotkeys()->getDisplaySequence(
HotkeyCategory::Window, "setTabVisibility", {{"toggle"}}); HotkeyCategory::Window, "setTabVisibility", {{"toggle"}});
} }
if (unhideSeq.isEmpty()) if (unhideSeq.isEmpty())
{ {
unhideSeq = getApp()->hotkeys->getDisplaySequence( unhideSeq = getIApp()->getHotkeys()->getDisplaySequence(
HotkeyCategory::Window, "setTabVisibility", {{"on"}}); HotkeyCategory::Window, "setTabVisibility", {{"on"}});
} }
QString hotkeyInfo = "(currently unbound)"; QString hotkeyInfo = "(currently unbound)";
@ -1293,7 +1293,7 @@ SplitNotebook::SplitNotebook(Window *parent)
this->signalHolder_, true); this->signalHolder_, true);
this->signalHolder_.managedConnect( this->signalHolder_.managedConnect(
getApp()->windows->selectSplit, [this](Split *split) { getIApp()->getWindows()->selectSplit, [this](Split *split) {
for (auto &&item : this->items()) for (auto &&item : this->items())
{ {
if (auto *sc = dynamic_cast<SplitContainer *>(item.page)) if (auto *sc = dynamic_cast<SplitContainer *>(item.page))
@ -1310,13 +1310,14 @@ SplitNotebook::SplitNotebook(Window *parent)
} }
}); });
this->signalHolder_.managedConnect(getApp()->windows->selectSplitContainer, this->signalHolder_.managedConnect(
getIApp()->getWindows()->selectSplitContainer,
[this](SplitContainer *sc) { [this](SplitContainer *sc) {
this->select(sc); this->select(sc);
}); });
this->signalHolder_.managedConnect( this->signalHolder_.managedConnect(
getApp()->windows->scrollToMessageSignal, getIApp()->getWindows()->scrollToMessageSignal,
[this](const MessagePtr &message) { [this](const MessagePtr &message) {
for (auto &&item : this->items()) for (auto &&item : this->items())
{ {
@ -1382,7 +1383,7 @@ void SplitNotebook::addCustomButtons()
settingsBtn->setIcon(NotebookButton::Settings); settingsBtn->setIcon(NotebookButton::Settings);
QObject::connect(settingsBtn, &NotebookButton::leftClicked, [this] { QObject::connect(settingsBtn, &NotebookButton::leftClicked, [this] {
getApp()->windows->showSettingsDialog(this); getIApp()->getWindows()->showSettingsDialog(this);
}); });
// account // account
@ -1396,7 +1397,7 @@ void SplitNotebook::addCustomButtons()
userBtn->setIcon(NotebookButton::User); userBtn->setIcon(NotebookButton::User);
QObject::connect(userBtn, &NotebookButton::leftClicked, [this, userBtn] { QObject::connect(userBtn, &NotebookButton::leftClicked, [this, userBtn] {
getApp()->windows->showAccountSelectPopup( getIApp()->getWindows()->showAccountSelectPopup(
this->mapToGlobal(userBtn->rect().bottomRight())); this->mapToGlobal(userBtn->rect().bottomRight()));
}); });
@ -1409,7 +1410,7 @@ void SplitNotebook::addCustomButtons()
this->streamerModeIcon_ = this->addCustomButton(); this->streamerModeIcon_ = this->addCustomButton();
QObject::connect(this->streamerModeIcon_, &NotebookButton::leftClicked, QObject::connect(this->streamerModeIcon_, &NotebookButton::leftClicked,
[this] { [this] {
getApp()->windows->showSettingsDialog( getIApp()->getWindows()->showSettingsDialog(
this, SettingsDialogPreference::StreamerMode); this, SettingsDialogPreference::StreamerMode);
}); });
this->signalHolder_.managedConnect(getApp()->streamerModeChanged, [this]() { this->signalHolder_.managedConnect(getApp()->streamerModeChanged, [this]() {

View file

@ -52,7 +52,7 @@ TooltipWidget::TooltipWidget(BaseWidget *parent)
}); });
this->updateFont(); this->updateFont();
auto *windows = getApp()->windows; auto *windows = getIApp()->getWindows();
this->connections_.managedConnect(windows->gifRepaintRequested, [this] { this->connections_.managedConnect(windows->gifRepaintRequested, [this] {
if (!this->isVisible()) if (!this->isVisible())
{ {

View file

@ -61,7 +61,7 @@ Window::Window(WindowType type, QWidget *parent)
#endif #endif
this->bSignals_.emplace_back( this->bSignals_.emplace_back(
getApp()->accounts->twitch.currentUserChanged.connect([this] { getIApp()->getAccounts()->twitch.currentUserChanged.connect([this] {
this->onAccountSelected(); this->onAccountSelected();
})); }));
this->onAccountSelected(); this->onAccountSelected();
@ -75,7 +75,7 @@ Window::Window(WindowType type, QWidget *parent)
this->resize(int(300 * this->scale()), int(500 * this->scale())); this->resize(int(300 * this->scale()), int(500 * this->scale()));
} }
this->signalHolder_.managedConnect(getApp()->hotkeys->onItemsUpdated, this->signalHolder_.managedConnect(getIApp()->getHotkeys()->onItemsUpdated,
[this]() { [this]() {
this->clearShortcuts(); this->clearShortcuts();
this->addShortcuts(); this->addShortcuts();
@ -105,7 +105,7 @@ bool Window::event(QEvent *event)
switch (event->type()) switch (event->type())
{ {
case QEvent::WindowActivate: { case QEvent::WindowActivate: {
getApp()->windows->selectedWindow_ = this; getIApp()->getWindows()->selectedWindow_ = this;
break; break;
} }
@ -136,15 +136,14 @@ void Window::closeEvent(QCloseEvent *)
{ {
if (this->type_ == WindowType::Main) if (this->type_ == WindowType::Main)
{ {
auto *app = getApp(); getIApp()->getWindows()->save();
app->windows->save(); getIApp()->getWindows()->closeAll();
app->windows->closeAll();
} }
// Ensure selectedWindow_ is never an invalid pointer. // Ensure selectedWindow_ is never an invalid pointer.
// WindowManager will return the main window if no window is pointed to by // WindowManager will return the main window if no window is pointed to by
// `selectedWindow_`. // `selectedWindow_`.
getApp()->windows->selectedWindow_ = nullptr; getIApp()->getWindows()->selectedWindow_ = nullptr;
this->closed.invoke(); this->closed.invoke();
@ -181,7 +180,7 @@ void Window::addCustomTitlebarButtons()
// settings // settings
this->addTitleBarButton(TitleBarButtonStyle::Settings, [this] { this->addTitleBarButton(TitleBarButtonStyle::Settings, [this] {
getApp()->windows->showSettingsDialog(this); getIApp()->getWindows()->showSettingsDialog(this);
}); });
// updates // updates
@ -191,7 +190,8 @@ void Window::addCustomTitlebarButtons()
// account // account
this->userLabel_ = this->addTitleBarLabel([this] { this->userLabel_ = this->addTitleBarLabel([this] {
getApp()->windows->showAccountSelectPopup(this->userLabel_->mapToGlobal( getIApp()->getWindows()->showAccountSelectPopup(
this->userLabel_->mapToGlobal(
this->userLabel_->rect().bottomLeft())); this->userLabel_->rect().bottomLeft()));
}); });
this->userLabel_->setMinimumWidth(20 * scale()); this->userLabel_->setMinimumWidth(20 * scale());
@ -199,7 +199,7 @@ void Window::addCustomTitlebarButtons()
// streamer mode // streamer mode
this->streamerModeTitlebarIcon_ = this->streamerModeTitlebarIcon_ =
this->addTitleBarButton(TitleBarButtonStyle::StreamerMode, [this] { this->addTitleBarButton(TitleBarButtonStyle::StreamerMode, [this] {
getApp()->windows->showSettingsDialog( getIApp()->getWindows()->showSettingsDialog(
this, SettingsDialogPreference::StreamerMode); this, SettingsDialogPreference::StreamerMode);
}); });
this->signalHolder_.managedConnect(getApp()->streamerModeChanged, [this]() { this->signalHolder_.managedConnect(getApp()->streamerModeChanged, [this]() {
@ -489,7 +489,7 @@ void Window::addShortcuts()
{"toggleLocalR9K", {"toggleLocalR9K",
[](std::vector<QString>) -> QString { [](std::vector<QString>) -> QString {
getSettings()->hideSimilar.setValue(!getSettings()->hideSimilar); getSettings()->hideSimilar.setValue(!getSettings()->hideSimilar);
getApp()->windows->forceLayoutChannelViews(); getIApp()->getWindows()->forceLayoutChannelViews();
return ""; return "";
}}, }},
{"openQuickSwitcher", {"openQuickSwitcher",
@ -690,7 +690,7 @@ void Window::addShortcuts()
this->addDebugStuff(actions); this->addDebugStuff(actions);
this->shortcuts_ = getApp()->hotkeys->shortcutsForCategory( this->shortcuts_ = getIApp()->getHotkeys()->shortcutsForCategory(
HotkeyCategory::Window, actions, this); HotkeyCategory::Window, actions, this);
} }
@ -725,7 +725,7 @@ void Window::addMenuBar()
void Window::onAccountSelected() void Window::onAccountSelected()
{ {
auto user = getApp()->accounts->twitch.getCurrent(); auto user = getIApp()->getAccounts()->twitch.getCurrent();
// update title (also append username on Linux and MacOS) // update title (also append username on Linux and MacOS)
QString windowTitle = Version::instance().fullVersion(); QString windowTitle = Version::instance().fullVersion();

View file

@ -26,7 +26,8 @@ EditHotkeyDialog::EditHotkeyDialog(const std::shared_ptr<Hotkey> hotkey,
this->ui_->easyArgsPicker->setVisible(false); this->ui_->easyArgsPicker->setVisible(false);
this->ui_->easyArgsLabel->setVisible(false); this->ui_->easyArgsLabel->setVisible(false);
// dynamically add category names to the category picker // dynamically add category names to the category picker
for (const auto &[_, hotkeyCategory] : getApp()->hotkeys->categories()) for (const auto &[_, hotkeyCategory] :
getIApp()->getHotkeys()->categories())
{ {
this->ui_->categoryPicker->addItem(hotkeyCategory.displayName, this->ui_->categoryPicker->addItem(hotkeyCategory.displayName,
hotkeyCategory.name); hotkeyCategory.name);
@ -153,7 +154,7 @@ void EditHotkeyDialog::afterEdit()
auto arguments = auto arguments =
parseHotkeyArguments(this->ui_->argumentsEdit->toPlainText()); parseHotkeyArguments(this->ui_->argumentsEdit->toPlainText());
auto category = getApp()->hotkeys->hotkeyCategoryFromName( auto category = getIApp()->getHotkeys()->hotkeyCategoryFromName(
this->ui_->categoryPicker->currentData().toString()); this->ui_->categoryPicker->currentData().toString());
if (!category) if (!category)
{ {
@ -165,7 +166,7 @@ void EditHotkeyDialog::afterEdit()
// check if another hotkey with this name exists, accounts for editing a hotkey // check if another hotkey with this name exists, accounts for editing a hotkey
bool isEditing = bool(this->data_); bool isEditing = bool(this->data_);
if (getApp()->hotkeys->getHotkeyByName(nameText)) if (getIApp()->getHotkeys()->getHotkeyByName(nameText))
{ {
// A hotkey with this name already exists // A hotkey with this name already exists
if (isEditing && this->data()->name() == nameText) if (isEditing && this->data()->name() == nameText)
@ -242,7 +243,8 @@ void EditHotkeyDialog::afterEdit()
{ {
if (keyComboWasEdited || nameWasEdited) if (keyComboWasEdited || nameWasEdited)
{ {
if (getApp()->hotkeys->isDuplicate(hotkey, this->data()->name())) if (getIApp()->getHotkeys()->isDuplicate(hotkey,
this->data()->name()))
{ {
this->showEditError( this->showEditError(
"Keybinding needs to be unique in the category."); "Keybinding needs to be unique in the category.");
@ -252,7 +254,7 @@ void EditHotkeyDialog::afterEdit()
} }
else else
{ {
if (getApp()->hotkeys->isDuplicate(hotkey, QString())) if (getIApp()->getHotkeys()->isDuplicate(hotkey, QString()))
{ {
this->showEditError( this->showEditError(
"Keybinding needs to be unique in the category."); "Keybinding needs to be unique in the category.");
@ -266,7 +268,7 @@ void EditHotkeyDialog::afterEdit()
void EditHotkeyDialog::updatePossibleActions() void EditHotkeyDialog::updatePossibleActions()
{ {
const auto &hotkeys = getApp()->hotkeys; const auto &hotkeys = getIApp()->getHotkeys();
auto category = hotkeys->hotkeyCategoryFromName( auto category = hotkeys->hotkeyCategoryFromName(
this->ui_->categoryPicker->currentData().toString()); this->ui_->categoryPicker->currentData().toString());
if (!category) if (!category)
@ -318,7 +320,7 @@ void EditHotkeyDialog::updateArgumentsInput()
this->ui_->argumentsEdit->setEnabled(true); this->ui_->argumentsEdit->setEnabled(true);
return; return;
} }
const auto &hotkeys = getApp()->hotkeys; const auto &hotkeys = getIApp()->getHotkeys();
auto category = hotkeys->hotkeyCategoryFromName( auto category = hotkeys->hotkeyCategoryFromName(
this->ui_->categoryPicker->currentData().toString()); this->ui_->categoryPicker->currentData().toString());
if (!category) if (!category)

View file

@ -206,7 +206,7 @@ EmotePopup::EmotePopup(QWidget *parent)
, notebook_(new Notebook(this)) , notebook_(new Notebook(this))
{ {
// this->setStayInScreenRect(true); // this->setStayInScreenRect(true);
this->moveTo(getApp()->windows->emotePopupPos(), this->moveTo(getIApp()->getWindows()->emotePopupPos(),
widgets::BoundsChecking::DesiredPosition); widgets::BoundsChecking::DesiredPosition);
auto *layout = new QVBoxLayout(); auto *layout = new QVBoxLayout();
@ -273,7 +273,7 @@ EmotePopup::EmotePopup(QWidget *parent)
loadEmojis(*this->viewEmojis_, loadEmojis(*this->viewEmojis_,
getApp()->getEmotes()->getEmojis()->getEmojis()); getApp()->getEmotes()->getEmojis()->getEmojis());
this->addShortcuts(); this->addShortcuts();
this->signalHolder_.managedConnect(getApp()->hotkeys->onItemsUpdated, this->signalHolder_.managedConnect(getIApp()->getHotkeys()->onItemsUpdated,
[this]() { [this]() {
this->clearShortcuts(); this->clearShortcuts();
this->addShortcuts(); this->addShortcuts();
@ -371,7 +371,7 @@ void EmotePopup::addShortcuts()
}}, }},
}; };
this->shortcuts_ = getApp()->hotkeys->shortcutsForCategory( this->shortcuts_ = getIApp()->getHotkeys()->shortcutsForCategory(
HotkeyCategory::PopupWindow, actions, this); HotkeyCategory::PopupWindow, actions, this);
} }
@ -394,8 +394,11 @@ void EmotePopup::loadChannel(ChannelPtr channel)
auto channelChannel = std::make_shared<Channel>("", Channel::Type::None); auto channelChannel = std::make_shared<Channel>("", Channel::Type::None);
// twitch // twitch
addTwitchEmoteSets( addTwitchEmoteSets(getIApp()
getApp()->accounts->twitch.getCurrent()->accessEmotes()->emoteSets, ->getAccounts()
->twitch.getCurrent()
->accessEmotes()
->emoteSets,
*globalChannel, *subChannel, this->channel_->getName()); *globalChannel, *subChannel, this->channel_->getName());
// global // global
@ -467,8 +470,11 @@ bool EmotePopup::eventFilter(QObject *object, QEvent *event)
void EmotePopup::filterTwitchEmotes(std::shared_ptr<Channel> searchChannel, void EmotePopup::filterTwitchEmotes(std::shared_ptr<Channel> searchChannel,
const QString &searchText) const QString &searchText)
{ {
auto twitchEmoteSets = auto twitchEmoteSets = getIApp()
getApp()->accounts->twitch.getCurrent()->accessEmotes()->emoteSets; ->getAccounts()
->twitch.getCurrent()
->accessEmotes()
->emoteSets;
std::vector<std::shared_ptr<TwitchAccount::EmoteSet>> twitchGlobalEmotes{}; std::vector<std::shared_ptr<TwitchAccount::EmoteSet>> twitchGlobalEmotes{};
for (const auto &set : twitchEmoteSets) for (const auto &set : twitchEmoteSets)
@ -589,7 +595,7 @@ void EmotePopup::filterEmotes(const QString &searchText)
void EmotePopup::closeEvent(QCloseEvent *event) void EmotePopup::closeEvent(QCloseEvent *event)
{ {
getApp()->windows->setEmotePopupPos(this->pos()); getIApp()->getWindows()->setEmotePopupPos(this->pos());
BaseWindow::closeEvent(event); BaseWindow::closeEvent(event);
} }

View file

@ -66,8 +66,8 @@ namespace {
pajlada::Settings::Setting<QString>::set(basePath + "/oauthToken", pajlada::Settings::Setting<QString>::set(basePath + "/oauthToken",
oauthToken); oauthToken);
getApp()->accounts->twitch.reloadUsers(); getIApp()->getAccounts()->twitch.reloadUsers();
getApp()->accounts->twitch.currentUsername = username; getIApp()->getAccounts()->twitch.currentUsername = username;
return true; return true;
} }

View file

@ -14,7 +14,7 @@ QualityPopup::QualityPopup(const QString &channelURL, QStringList options)
BaseWindow::DisableLayoutSave, BaseWindow::DisableLayoutSave,
BaseWindow::BoundsCheckOnShow, BaseWindow::BoundsCheckOnShow,
}, },
static_cast<QWidget *>(&(getApp()->windows->getMainWindow()))) static_cast<QWidget *>(&(getIApp()->getWindows()->getMainWindow())))
, channelURL_(channelURL) , channelURL_(channelURL)
{ {
this->ui_.selector = new QComboBox(this); this->ui_.selector = new QComboBox(this);

View file

@ -77,7 +77,7 @@ ReplyThreadPopup::ReplyThreadPopup(bool closeAutomatically, Split *split)
{"search", nullptr}, {"search", nullptr},
}; };
this->shortcuts_ = getApp()->hotkeys->shortcutsForCategory( this->shortcuts_ = getIApp()->getHotkeys()->shortcutsForCategory(
HotkeyCategory::PopupWindow, actions, this); HotkeyCategory::PopupWindow, actions, this);
// initialize UI // initialize UI
@ -98,7 +98,7 @@ ReplyThreadPopup::ReplyThreadPopup(bool closeAutomatically, Split *split)
new SplitInput(this, this->split_, this->ui_.threadView, false); new SplitInput(this, this->split_, this->ui_.threadView, false);
this->bSignals_.emplace_back( this->bSignals_.emplace_back(
getApp()->accounts->twitch.currentUserChanged.connect([this] { getIApp()->getAccounts()->twitch.currentUserChanged.connect([this] {
this->updateInputUI(); this->updateInputUI();
})); }));
@ -284,7 +284,7 @@ void ReplyThreadPopup::updateInputUI()
this->ui_.replyInput->setVisible(channel->isWritable()); this->ui_.replyInput->setVisible(channel->isWritable());
auto user = getApp()->accounts->twitch.getCurrent(); auto user = getIApp()->getAccounts()->twitch.getCurrent();
QString placeholderText; QString placeholderText;
if (user->isAnon()) if (user->isAnon())
@ -293,9 +293,11 @@ void ReplyThreadPopup::updateInputUI()
} }
else else
{ {
placeholderText = placeholderText = QStringLiteral("Reply as %1...")
QStringLiteral("Reply as %1...") .arg(getIApp()
.arg(getApp()->accounts->twitch.getCurrent()->getUserName()); ->getAccounts()
->twitch.getCurrent()
->getUserName());
} }
this->ui_.replyInput->setPlaceholderText(placeholderText); this->ui_.replyInput->setPlaceholderText(placeholderText);

View file

@ -615,7 +615,7 @@ void SelectChannelDialog::addShortcuts()
actions.emplace("openTab", nullptr); actions.emplace("openTab", nullptr);
} }
this->shortcuts_ = getApp()->hotkeys->shortcutsForCategory( this->shortcuts_ = getIApp()->getHotkeys()->shortcutsForCategory(
HotkeyCategory::PopupWindow, actions, this); HotkeyCategory::PopupWindow, actions, this);
} }

View file

@ -54,7 +54,7 @@ SettingsDialog::SettingsDialog(QWidget *parent)
this->overrideBackgroundColor_ = QColor("#111111"); this->overrideBackgroundColor_ = QColor("#111111");
this->addShortcuts(); this->addShortcuts();
this->signalHolder_.managedConnect(getApp()->hotkeys->onItemsUpdated, this->signalHolder_.managedConnect(getIApp()->getHotkeys()->onItemsUpdated,
[this]() { [this]() {
this->clearShortcuts(); this->clearShortcuts();
this->addShortcuts(); this->addShortcuts();
@ -78,13 +78,13 @@ void SettingsDialog::addShortcuts()
{"openTab", nullptr}, {"openTab", nullptr},
}; };
this->shortcuts_ = getApp()->hotkeys->shortcutsForCategory( this->shortcuts_ = getIApp()->getHotkeys()->shortcutsForCategory(
HotkeyCategory::PopupWindow, actions, this); HotkeyCategory::PopupWindow, actions, this);
} }
void SettingsDialog::setSearchPlaceholderText() void SettingsDialog::setSearchPlaceholderText()
{ {
QString searchHotkey; QString searchHotkey;
auto searchSeq = getApp()->hotkeys->getDisplaySequence( auto searchSeq = getIApp()->getHotkeys()->getDisplaySequence(
HotkeyCategory::PopupWindow, "search"); HotkeyCategory::PopupWindow, "search");
if (!searchSeq.isEmpty()) if (!searchSeq.isEmpty())
{ {
@ -432,7 +432,7 @@ void SettingsDialog::onOkClicked()
{ {
if (!getApp()->getArgs().dontSaveSettings) if (!getApp()->getArgs().dontSaveSettings)
{ {
getApp()->commands->save(); getIApp()->getCommands()->save();
pajlada::Settings::SettingManager::gSave(); pajlada::Settings::SettingManager::gSave();
} }
this->close(); this->close();

View file

@ -56,7 +56,7 @@ namespace {
{ {
button.assign(copyButton); button.assign(copyButton);
} }
button->setPixmap(getApp()->themes->buttons.copy); button->setPixmap(getIApp()->getThemes()->buttons.copy);
button->setScaleIndependantSize(18, 18); button->setScaleIndependantSize(18, 18);
button->setDim(Button::Dim::Lots); button->setDim(Button::Dim::Lots);
button->setToolTip(tooltip); button->setToolTip(tooltip);
@ -226,7 +226,7 @@ UserInfoPopup::UserInfoPopup(bool closeAutomatically, Split *split)
.arg(calculateTimeoutDuration(button)); .arg(calculateTimeoutDuration(button));
} }
msg = getApp()->commands->execCommand( msg = getIApp()->getCommands()->execCommand(
msg, this->underlyingChannel_, false); msg, this->underlyingChannel_, false);
this->underlyingChannel_->sendMessage(msg); this->underlyingChannel_->sendMessage(msg);
@ -245,7 +245,7 @@ UserInfoPopup::UserInfoPopup(bool closeAutomatically, Split *split)
{"search", nullptr}, {"search", nullptr},
}; };
this->shortcuts_ = getApp()->hotkeys->shortcutsForCategory( this->shortcuts_ = getIApp()->getHotkeys()->shortcutsForCategory(
HotkeyCategory::PopupWindow, actions, this); HotkeyCategory::PopupWindow, actions, this);
auto layers = LayoutCreator<QWidget>(this->getLayoutContainer()) auto layers = LayoutCreator<QWidget>(this->getLayoutContainer())
@ -299,7 +299,7 @@ UserInfoPopup::UserInfoPopup(bool closeAutomatically, Split *split)
"Open channel in a new popup window", this, "Open channel in a new popup window", this,
[loginName] { [loginName] {
auto *app = getApp(); auto *app = getApp();
auto &window = app->windows->createWindow( auto &window = app->getWindows()->createWindow(
WindowType::Popup, true); WindowType::Popup, true);
auto *split = window.getNotebook() auto *split = window.getNotebook()
.getOrAddSelectedPage() .getOrAddSelectedPage()
@ -314,7 +314,8 @@ UserInfoPopup::UserInfoPopup(bool closeAutomatically, Split *split)
getApp()->twitch->getOrAddChannel( getApp()->twitch->getOrAddChannel(
loginName); loginName);
auto &nb = getApp() auto &nb = getApp()
->windows->getMainWindow() ->getWindows()
->getMainWindow()
.getNotebook(); .getNotebook();
SplitContainer *container = nb.addPage(true); SplitContainer *container = nb.addPage(true);
Split *split = new Split(container); Split *split = new Split(container);
@ -414,25 +415,25 @@ UserInfoPopup::UserInfoPopup(bool closeAutomatically, Split *split)
QObject::connect(mod.getElement(), &Button::leftClicked, [this] { QObject::connect(mod.getElement(), &Button::leftClicked, [this] {
QString value = "/mod " + this->userName_; QString value = "/mod " + this->userName_;
value = getApp()->commands->execCommand( value = getIApp()->getCommands()->execCommand(
value, this->underlyingChannel_, false); value, this->underlyingChannel_, false);
this->underlyingChannel_->sendMessage(value); this->underlyingChannel_->sendMessage(value);
}); });
QObject::connect(unmod.getElement(), &Button::leftClicked, [this] { QObject::connect(unmod.getElement(), &Button::leftClicked, [this] {
QString value = "/unmod " + this->userName_; QString value = "/unmod " + this->userName_;
value = getApp()->commands->execCommand( value = getIApp()->getCommands()->execCommand(
value, this->underlyingChannel_, false); value, this->underlyingChannel_, false);
this->underlyingChannel_->sendMessage(value); this->underlyingChannel_->sendMessage(value);
}); });
QObject::connect(vip.getElement(), &Button::leftClicked, [this] { QObject::connect(vip.getElement(), &Button::leftClicked, [this] {
QString value = "/vip " + this->userName_; QString value = "/vip " + this->userName_;
value = getApp()->commands->execCommand( value = getIApp()->getCommands()->execCommand(
value, this->underlyingChannel_, false); value, this->underlyingChannel_, false);
this->underlyingChannel_->sendMessage(value); this->underlyingChannel_->sendMessage(value);
}); });
QObject::connect(unvip.getElement(), &Button::leftClicked, [this] { QObject::connect(unvip.getElement(), &Button::leftClicked, [this] {
QString value = "/unvip " + this->userName_; QString value = "/unvip " + this->userName_;
value = getApp()->commands->execCommand( value = getIApp()->getCommands()->execCommand(
value, this->underlyingChannel_, false); value, this->underlyingChannel_, false);
this->underlyingChannel_->sendMessage(value); this->underlyingChannel_->sendMessage(value);
}); });
@ -450,8 +451,10 @@ UserInfoPopup::UserInfoPopup(bool closeAutomatically, Split *split)
if (twitchChannel) if (twitchChannel)
{ {
bool isMyself = bool isMyself =
QString::compare( QString::compare(getIApp()
getApp()->accounts->twitch.getCurrent()->getUserName(), ->getAccounts()
->twitch.getCurrent()
->getUserName(),
this->userName_, Qt::CaseInsensitive) == 0; this->userName_, Qt::CaseInsensitive) == 0;
visibilityModButtons = visibilityModButtons =
@ -497,7 +500,7 @@ UserInfoPopup::UserInfoPopup(bool closeAutomatically, Split *split)
if (this->underlyingChannel_) if (this->underlyingChannel_)
{ {
QString value = "/ban " + this->userName_; QString value = "/ban " + this->userName_;
value = getApp()->commands->execCommand( value = getIApp()->getCommands()->execCommand(
value, this->underlyingChannel_, false); value, this->underlyingChannel_, false);
this->underlyingChannel_->sendMessage(value); this->underlyingChannel_->sendMessage(value);
@ -508,7 +511,7 @@ UserInfoPopup::UserInfoPopup(bool closeAutomatically, Split *split)
if (this->underlyingChannel_) if (this->underlyingChannel_)
{ {
QString value = "/unban " + this->userName_; QString value = "/unban " + this->userName_;
value = getApp()->commands->execCommand( value = getIApp()->getCommands()->execCommand(
value, this->underlyingChannel_, false); value, this->underlyingChannel_, false);
this->underlyingChannel_->sendMessage(value); this->underlyingChannel_->sendMessage(value);
@ -521,7 +524,7 @@ UserInfoPopup::UserInfoPopup(bool closeAutomatically, Split *split)
QString value = "/timeout " + this->userName_ + " " + QString value = "/timeout " + this->userName_ + " " +
QString::number(arg); QString::number(arg);
value = getApp()->commands->execCommand( value = getIApp()->getCommands()->execCommand(
value, this->underlyingChannel_, false); value, this->underlyingChannel_, false);
this->underlyingChannel_->sendMessage(value); this->underlyingChannel_->sendMessage(value);
@ -594,7 +597,7 @@ void UserInfoPopup::installEvents()
QObject::connect( QObject::connect(
this->ui_.block, &QCheckBox::stateChanged, this->ui_.block, &QCheckBox::stateChanged,
[this](int newState) mutable { [this](int newState) mutable {
auto currentUser = getApp()->accounts->twitch.getCurrent(); auto currentUser = getIApp()->getAccounts()->twitch.getCurrent();
const auto reenableBlockCheckbox = [this] { const auto reenableBlockCheckbox = [this] {
this->ui_.block->setEnabled(true); this->ui_.block->setEnabled(true);
@ -611,7 +614,7 @@ void UserInfoPopup::installEvents()
case Qt::CheckState::Unchecked: { case Qt::CheckState::Unchecked: {
this->ui_.block->setEnabled(false); this->ui_.block->setEnabled(false);
getApp()->accounts->twitch.getCurrent()->unblockUser( getIApp()->getAccounts()->twitch.getCurrent()->unblockUser(
this->userId_, this, this->userId_, this,
[this, reenableBlockCheckbox, currentUser] { [this, reenableBlockCheckbox, currentUser] {
this->channel_->addMessage(makeSystemMessage( this->channel_->addMessage(makeSystemMessage(
@ -638,7 +641,7 @@ void UserInfoPopup::installEvents()
case Qt::CheckState::Checked: { case Qt::CheckState::Checked: {
this->ui_.block->setEnabled(false); this->ui_.block->setEnabled(false);
getApp()->accounts->twitch.getCurrent()->blockUser( getIApp()->getAccounts()->twitch.getCurrent()->blockUser(
this->userId_, this, this->userId_, this,
[this, reenableBlockCheckbox, currentUser] { [this, reenableBlockCheckbox, currentUser] {
this->channel_->addMessage(makeSystemMessage( this->channel_->addMessage(makeSystemMessage(
@ -795,7 +798,7 @@ void UserInfoPopup::updateLatestMessages()
void UserInfoPopup::updateUserData() void UserInfoPopup::updateUserData()
{ {
std::weak_ptr<bool> hack = this->lifetimeHack_; std::weak_ptr<bool> hack = this->lifetimeHack_;
auto currentUser = getApp()->accounts->twitch.getCurrent(); auto currentUser = getIApp()->getAccounts()->twitch.getCurrent();
const auto onUserFetchFailed = [this, hack] { const auto onUserFetchFailed = [this, hack] {
if (!hack.lock()) if (!hack.lock())

View file

@ -21,9 +21,8 @@ NewPopupItem::NewPopupItem(const QString &channelName)
void NewPopupItem::action() void NewPopupItem::action()
{ {
auto *app = getApp(); auto channel = getApp()->twitch->getOrAddChannel(this->channelName_);
auto channel = app->twitch->getOrAddChannel(this->channelName_); getIApp()->getWindows()->openInPopup(channel);
app->windows->openInPopup(channel);
} }
void NewPopupItem::paint(QPainter *painter, const QRect &rect) const void NewPopupItem::paint(QPainter *painter, const QRect &rect) const
@ -32,9 +31,10 @@ void NewPopupItem::paint(QPainter *painter, const QRect &rect) const
painter->setRenderHint(QPainter::Antialiasing, true); painter->setRenderHint(QPainter::Antialiasing, true);
painter->setPen(getApp()->themes->splits.header.text); painter->setPen(getIApp()->getThemes()->splits.header.text);
painter->setBrush(Qt::SolidPattern); painter->setBrush(Qt::SolidPattern);
painter->setFont(getApp()->fonts->getFont(FontStyle::UiMediumBold, 1.0)); painter->setFont(
getIApp()->getFonts()->getFont(FontStyle::UiMediumBold, 1.0));
QRect iconRect(rect.topLeft(), ICON_SIZE); QRect iconRect(rect.topLeft(), ICON_SIZE);
this->icon_.paint(painter, iconRect, Qt::AlignLeft | Qt::AlignVCenter); this->icon_.paint(painter, iconRect, Qt::AlignLeft | Qt::AlignVCenter);

View file

@ -37,9 +37,10 @@ void NewTabItem::paint(QPainter *painter, const QRect &rect) const
painter->setRenderHint(QPainter::Antialiasing, true); painter->setRenderHint(QPainter::Antialiasing, true);
// TODO(leon): Right pen/brush/font settings? // TODO(leon): Right pen/brush/font settings?
painter->setPen(getApp()->themes->splits.header.text); painter->setPen(getIApp()->getThemes()->splits.header.text);
painter->setBrush(Qt::SolidPattern); painter->setBrush(Qt::SolidPattern);
painter->setFont(getApp()->fonts->getFont(FontStyle::UiMediumBold, 1.0)); painter->setFont(
getIApp()->getFonts()->getFont(FontStyle::UiMediumBold, 1.0));
QRect iconRect(rect.topLeft(), ICON_SIZE); QRect iconRect(rect.topLeft(), ICON_SIZE);
this->icon_.paint(painter, iconRect, Qt::AlignLeft | Qt::AlignVCenter); this->icon_.paint(painter, iconRect, Qt::AlignLeft | Qt::AlignVCenter);

View file

@ -21,11 +21,11 @@ void SwitchSplitItem::action()
{ {
if (this->split_) if (this->split_)
{ {
getApp()->windows->select(this->split_); getIApp()->getWindows()->select(this->split_);
} }
else if (this->container_) else if (this->container_)
{ {
getApp()->windows->select(this->container_); getIApp()->getWindows()->select(this->container_);
} }
} }
@ -36,9 +36,10 @@ void SwitchSplitItem::paint(QPainter *painter, const QRect &rect) const
painter->setRenderHint(QPainter::Antialiasing, true); painter->setRenderHint(QPainter::Antialiasing, true);
// TODO(leon): Right pen/brush/font settings? // TODO(leon): Right pen/brush/font settings?
painter->setPen(getApp()->themes->splits.header.text); painter->setPen(getIApp()->getThemes()->splits.header.text);
painter->setBrush(Qt::SolidPattern); painter->setBrush(Qt::SolidPattern);
painter->setFont(getApp()->fonts->getFont(FontStyle::UiMediumBold, 1.0)); painter->setFont(
getIApp()->getFonts()->getFont(FontStyle::UiMediumBold, 1.0));
QRect iconRect(rect.topLeft(), ICON_SIZE); QRect iconRect(rect.topLeft(), ICON_SIZE);
this->icon_.paint(painter, iconRect, Qt::AlignLeft | Qt::AlignVCenter); this->icon_.paint(painter, iconRect, Qt::AlignLeft | Qt::AlignVCenter);
@ -58,7 +59,8 @@ void SwitchSplitItem::paint(QPainter *painter, const QRect &rect) const
QRect(leftTextRect.topRight(), QRect(leftTextRect.topRight(),
QSize(0.7 * availableTextWidth, iconRect.height())); QSize(0.7 * availableTextWidth, iconRect.height()));
painter->setFont(getApp()->fonts->getFont(FontStyle::UiMedium, 1.0)); painter->setFont(
getIApp()->getFonts()->getFont(FontStyle::UiMedium, 1.0));
painter->drawText(rightTextRect, Qt::AlignRight | Qt::AlignVCenter, painter->drawText(rightTextRect, Qt::AlignRight | Qt::AlignVCenter,
this->container_->getTab()->getTitle()); this->container_->getTab()->getTitle());
} }

View file

@ -396,8 +396,8 @@ void ChannelView::initializeScrollbar()
void ChannelView::initializeSignals() void ChannelView::initializeSignals()
{ {
this->signalHolder_.managedConnect(getApp()->windows->wordFlagsChanged, this->signalHolder_.managedConnect(
[this] { getIApp()->getWindows()->wordFlagsChanged, [this] {
this->queueLayout(); this->queueLayout();
this->update(); this->update();
}); });
@ -409,7 +409,7 @@ void ChannelView::initializeSignals()
this->signalHolder_); this->signalHolder_);
this->signalHolder_.managedConnect( this->signalHolder_.managedConnect(
getApp()->windows->gifRepaintRequested, [&] { getIApp()->getWindows()->gifRepaintRequested, [&] {
if (!this->animationArea_.isEmpty()) if (!this->animationArea_.isEmpty())
{ {
this->queueUpdate(this->animationArea_); this->queueUpdate(this->animationArea_);
@ -417,7 +417,7 @@ void ChannelView::initializeSignals()
}); });
this->signalHolder_.managedConnect( this->signalHolder_.managedConnect(
getApp()->windows->layoutRequested, [&](Channel *channel) { getIApp()->getWindows()->layoutRequested, [&](Channel *channel) {
if (this->isVisible() && if (this->isVisible() &&
(channel == nullptr || this->channel_.get() == channel)) (channel == nullptr || this->channel_.get() == channel))
{ {
@ -425,7 +425,8 @@ void ChannelView::initializeSignals()
} }
}); });
this->signalHolder_.managedConnect(getApp()->fonts->fontChanged, [this] { this->signalHolder_.managedConnect(getIApp()->getFonts()->fontChanged,
[this] {
this->queueLayout(); this->queueLayout();
}); });
} }
@ -1023,8 +1024,11 @@ bool ChannelView::shouldIncludeMessage(const MessagePtr &m) const
if (this->channelFilters_) if (this->channelFilters_)
{ {
if (getSettings()->excludeUserMessagesFromFilter && if (getSettings()->excludeUserMessagesFromFilter &&
getApp()->accounts->twitch.getCurrent()->getUserName().compare( getIApp()
m->loginName, Qt::CaseInsensitive) == 0) ->getAccounts()
->twitch.getCurrent()
->getUserName()
.compare(m->loginName, Qt::CaseInsensitive) == 0)
{ {
return true; return true;
} }
@ -1290,7 +1294,7 @@ MessageElementFlags ChannelView::getFlags() const
return *this->overrideFlags_; return *this->overrideFlags_;
} }
MessageElementFlags flags = app->windows->getWordFlags(); MessageElementFlags flags = app->getWindows()->getWordFlags();
auto *split = dynamic_cast<Split *>(this->parentWidget()); auto *split = dynamic_cast<Split *>(this->parentWidget());
@ -1376,7 +1380,7 @@ bool ChannelView::scrollToMessage(const MessagePtr &message)
this->scrollToMessageLayout(messagesSnapshot[messageIdx].get(), messageIdx); this->scrollToMessageLayout(messagesSnapshot[messageIdx].get(), messageIdx);
if (this->split_) if (this->split_)
{ {
getApp()->windows->select(this->split_); getIApp()->getWindows()->select(this->split_);
} }
return true; return true;
} }
@ -1408,7 +1412,7 @@ bool ChannelView::scrollToMessageId(const QString &messageId)
this->scrollToMessageLayout(messagesSnapshot[messageIdx].get(), messageIdx); this->scrollToMessageLayout(messagesSnapshot[messageIdx].get(), messageIdx);
if (this->split_) if (this->split_)
{ {
getApp()->windows->select(this->split_); getIApp()->getWindows()->select(this->split_);
} }
return true; return true;
} }
@ -2444,7 +2448,7 @@ void ChannelView::addMessageContextMenuItems(QMenu *menu,
} }
else if (isMentions || isAutomod) else if (isMentions || isAutomod)
{ {
getApp()->windows->scrollToMessage(messagePtr); getIApp()->getWindows()->scrollToMessage(messagePtr);
} }
else if (isReplyOrUserCard) else if (isReplyOrUserCard)
{ {
@ -2454,7 +2458,7 @@ void ChannelView::addMessageContextMenuItems(QMenu *menu,
if (type == Channel::Type::TwitchMentions || if (type == Channel::Type::TwitchMentions ||
type == Channel::Type::TwitchAutomod) type == Channel::Type::TwitchAutomod)
{ {
getApp()->windows->scrollToMessage(messagePtr); getIApp()->getWindows()->scrollToMessage(messagePtr);
} }
else else
{ {
@ -2535,7 +2539,7 @@ void ChannelView::addCommandExecutionContextMenuItems(
/* Get commands to be displayed in context menu; /* Get commands to be displayed in context menu;
* only those that had the showInMsgContextMenu check box marked in the Commands page */ * only those that had the showInMsgContextMenu check box marked in the Commands page */
std::vector<Command> cmds; std::vector<Command> cmds;
for (const auto &cmd : getApp()->commands->items) for (const auto &cmd : getIApp()->getCommands()->items)
{ {
if (cmd.showInMsgContextMenu) if (cmd.showInMsgContextMenu)
{ {
@ -2582,13 +2586,14 @@ void ChannelView::addCommandExecutionContextMenuItems(
} }
// Execute command through right-clicking a message -> Execute command // Execute command through right-clicking a message -> Execute command
QString value = getApp()->commands->execCustomCommand( QString value = getIApp()->getCommands()->execCustomCommand(
inputText.split(' '), cmd, true, channel, layout->getMessage(), inputText.split(' '), cmd, true, channel, layout->getMessage(),
{ {
{"input.text", userText}, {"input.text", userText},
}); });
value = getApp()->commands->execCommand(value, channel, false); value =
getIApp()->getCommands()->execCommand(value, channel, false);
channel->sendMessage(value); channel->sendMessage(value);
}); });
@ -2753,24 +2758,25 @@ void ChannelView::handleLinkClick(QMouseEvent *event, const Link &link,
} }
// Execute command clicking a moderator button // Execute command clicking a moderator button
value = getApp()->commands->execCustomCommand( value = getIApp()->getCommands()->execCustomCommand(
QStringList(), Command{"(modaction)", value}, true, channel, QStringList(), Command{"(modaction)", value}, true, channel,
layout->getMessage()); layout->getMessage());
value = getApp()->commands->execCommand(value, channel, false); value =
getIApp()->getCommands()->execCommand(value, channel, false);
channel->sendMessage(value); channel->sendMessage(value);
} }
break; break;
case Link::AutoModAllow: { case Link::AutoModAllow: {
getApp()->accounts->twitch.getCurrent()->autoModAllow( getIApp()->getAccounts()->twitch.getCurrent()->autoModAllow(
link.value, this->channel()); link.value, this->channel());
} }
break; break;
case Link::AutoModDeny: { case Link::AutoModDeny: {
getApp()->accounts->twitch.getCurrent()->autoModDeny( getIApp()->getAccounts()->twitch.getCurrent()->autoModDeny(
link.value, this->channel()); link.value, this->channel());
} }
break; break;
@ -2784,7 +2790,7 @@ void ChannelView::handleLinkClick(QMouseEvent *event, const Link &link,
// Get all currently open pages // Get all currently open pages
QList<SplitContainer *> openPages; QList<SplitContainer *> openPages;
auto &nb = getApp()->windows->getMainWindow().getNotebook(); auto &nb = getIApp()->getWindows()->getMainWindow().getNotebook();
for (int i = 0; i < nb.getPageCount(); ++i) for (int i = 0; i < nb.getPageCount(); ++i)
{ {
openPages.push_back( openPages.push_back(

View file

@ -289,7 +289,7 @@ const QString &NotebookTab::getTitle() const
void NotebookTab::titleUpdated() void NotebookTab::titleUpdated()
{ {
// Queue up save because: Tab title changed // Queue up save because: Tab title changed
getApp()->windows->queueSave(); getIApp()->getWindows()->queueSave();
this->notebook_->refresh(); this->notebook_->refresh();
this->updateSize(); this->updateSize();
this->update(); this->update();
@ -429,9 +429,9 @@ void NotebookTab::paintEvent(QPaintEvent *)
auto div = std::max<float>(0.01f, this->logicalDpiX() * deviceDpi(this)); auto div = std::max<float>(0.01f, this->logicalDpiX() * deviceDpi(this));
painter.setFont( painter.setFont(
getApp()->fonts->getFont(FontStyle::UiTabs, scale * 96.f / div)); getIApp()->getFonts()->getFont(FontStyle::UiTabs, scale * 96.f / div));
QFontMetrics metrics = QFontMetrics metrics =
app->fonts->getFontMetrics(FontStyle::UiTabs, scale * 96.f / div); app->getFonts()->getFontMetrics(FontStyle::UiTabs, scale * 96.f / div);
int height = int(scale * NOTEBOOK_TAB_HEIGHT); int height = int(scale * NOTEBOOK_TAB_HEIGHT);
@ -613,7 +613,7 @@ void NotebookTab::paintEvent(QPaintEvent *)
borderRect = QRect(0, 0, this->width(), 1); borderRect = QRect(0, 0, this->width(), 1);
break; break;
} }
painter.fillRect(borderRect, app->themes->window.background); painter.fillRect(borderRect, app->getThemes()->window.background);
} }
} }

View file

@ -103,7 +103,7 @@ void SearchPopup::addShortcuts()
{"scrollPage", nullptr}, {"scrollPage", nullptr},
}; };
this->shortcuts_ = getApp()->hotkeys->shortcutsForCategory( this->shortcuts_ = getIApp()->getHotkeys()->shortcutsForCategory(
HotkeyCategory::PopupWindow, actions, this); HotkeyCategory::PopupWindow, actions, this);
} }
@ -138,7 +138,7 @@ void SearchPopup::goToMessage(const MessagePtr &message)
if (type == Channel::Type::TwitchMentions || if (type == Channel::Type::TwitchMentions ||
type == Channel::Type::TwitchAutomod) type == Channel::Type::TwitchAutomod)
{ {
getApp()->windows->scrollToMessage(message); getIApp()->getWindows()->scrollToMessage(message);
return; return;
} }

View file

@ -26,8 +26,8 @@ AccountsPage::AccountsPage()
EditableModelView *view = EditableModelView *view =
layout layout
.emplace<EditableModelView>(app->accounts->createModel(nullptr), .emplace<EditableModelView>(
false) app->getAccounts()->createModel(nullptr), false)
.getElement(); .getElement();
view->getTableView()->horizontalHeader()->setVisible(false); view->getTableView()->horizontalHeader()->setVisible(false);
@ -63,7 +63,7 @@ AccountsPage::AccountsPage()
// return; // return;
// } // }
// getApp()->accounts->Twitch.removeUser(selectedUser); // getIApp()->getAccounts()->Twitch.removeUser(selectedUser);
// }); // });
} }

View file

@ -38,8 +38,9 @@ CommandPage::CommandPage()
LayoutCreator<CommandPage> layoutCreator(this); LayoutCreator<CommandPage> layoutCreator(this);
auto layout = layoutCreator.setLayoutType<QVBoxLayout>(); auto layout = layoutCreator.setLayoutType<QVBoxLayout>();
EditableModelView *view = EditableModelView *view = layout
layout.emplace<EditableModelView>(app->commands->createModel(nullptr)) .emplace<EditableModelView>(
app->getCommands()->createModel(nullptr))
.getElement(); .getElement();
view->setTitles({"Trigger", "Command", "Show In\nMessage Menu"}); view->setTitles({"Trigger", "Command", "Show In\nMessage Menu"});
@ -47,7 +48,7 @@ CommandPage::CommandPage()
1, QHeaderView::Stretch); 1, QHeaderView::Stretch);
// We can safely ignore this signal connection since we own the view // We can safely ignore this signal connection since we own the view
std::ignore = view->addButtonPressed.connect([] { std::ignore = view->addButtonPressed.connect([] {
getApp()->commands->items.append( getIApp()->getCommands()->items.append(
Command{"/command", "I made a new command HeyGuys"}); Command{"/command", "I made a new command HeyGuys"});
}); });
@ -66,7 +67,7 @@ CommandPage::CommandPage()
{ {
if (int index = line.indexOf(' '); index != -1) if (int index = line.indexOf(' '); index != -1)
{ {
getApp()->commands->items.insert( getIApp()->getCommands()->items.insert(
Command(line.mid(0, index), line.mid(index + 1))); Command(line.mid(0, index), line.mid(index + 1)));
} }
} }

View file

@ -123,8 +123,8 @@ void GeneralPage::initLayout(GeneralPageView &layout)
layout.addTitle("Interface"); layout.addTitle("Interface");
layout.addDropdown<QString>( layout.addDropdown<QString>(
"Theme", getApp()->themes->availableThemes(), "Theme", getIApp()->getThemes()->availableThemes(),
getApp()->themes->themeName, getIApp()->getThemes()->themeName,
[](const auto *combo, const auto &themeKey) { [](const auto *combo, const auto &themeKey) {
return combo->findData(themeKey, Qt::UserRole); return combo->findData(themeKey, Qt::UserRole);
}, },
@ -135,7 +135,7 @@ void GeneralPage::initLayout(GeneralPageView &layout)
layout.addDropdown<QString>( layout.addDropdown<QString>(
"Font", {"Segoe UI", "Arial", "Choose..."}, "Font", {"Segoe UI", "Arial", "Choose..."},
getApp()->fonts->chatFontFamily, getIApp()->getFonts()->chatFontFamily,
[](auto val) { [](auto val) {
return val; return val;
}, },
@ -144,7 +144,7 @@ void GeneralPage::initLayout(GeneralPageView &layout)
}); });
layout.addDropdown<int>( layout.addDropdown<int>(
"Font size", {"9pt", "10pt", "12pt", "14pt", "16pt", "20pt"}, "Font size", {"9pt", "10pt", "12pt", "14pt", "16pt", "20pt"},
getApp()->fonts->chatFontSize, getIApp()->getFonts()->chatFontSize,
[](auto val) { [](auto val) {
return QString::number(val) + "pt"; return QString::number(val) + "pt";
}, },
@ -241,7 +241,7 @@ void GeneralPage::initLayout(GeneralPageView &layout)
layout.addCheckbox("Show message reply button", s.showReplyButton, false, layout.addCheckbox("Show message reply button", s.showReplyButton, false,
"Show a reply button next to every chat message"); "Show a reply button next to every chat message");
auto removeTabSeq = getApp()->hotkeys->getDisplaySequence( auto removeTabSeq = getIApp()->getHotkeys()->getDisplaySequence(
HotkeyCategory::Window, "removeTab"); HotkeyCategory::Window, "removeTab");
QString removeTabShortcut = "an assigned hotkey (Window -> remove tab)"; QString removeTabShortcut = "an assigned hotkey (Window -> remove tab)";
if (!removeTabSeq.isEmpty()) if (!removeTabSeq.isEmpty())
@ -262,7 +262,7 @@ void GeneralPage::initLayout(GeneralPageView &layout)
#endif #endif
if (!BaseWindow::supportsCustomWindowFrame()) if (!BaseWindow::supportsCustomWindowFrame())
{ {
auto settingsSeq = getApp()->hotkeys->getDisplaySequence( auto settingsSeq = getIApp()->getHotkeys()->getDisplaySequence(
HotkeyCategory::Window, "openSettings"); HotkeyCategory::Window, "openSettings");
QString shortcut = " (no key bound to open them otherwise)"; QString shortcut = " (no key bound to open them otherwise)";
// TODO: maybe prevent the user from locking themselves out of the settings? // TODO: maybe prevent the user from locking themselves out of the settings?
@ -858,7 +858,7 @@ void GeneralPage::initLayout(GeneralPageView &layout)
"Show the stream title"); "Show the stream title");
layout.addSubtitle("R9K"); layout.addSubtitle("R9K");
auto toggleLocalr9kSeq = getApp()->hotkeys->getDisplaySequence( auto toggleLocalr9kSeq = getIApp()->getHotkeys()->getDisplaySequence(
HotkeyCategory::Window, "toggleLocalR9K"); HotkeyCategory::Window, "toggleLocalR9K");
QString toggleLocalr9kShortcut = QString toggleLocalr9kShortcut =
"an assigned hotkey (Window -> Toggle local R9K)"; "an assigned hotkey (Window -> Toggle local R9K)";
@ -878,7 +878,7 @@ void GeneralPage::initLayout(GeneralPageView &layout)
s.shownSimilarTriggerHighlights); s.shownSimilarTriggerHighlights);
s.hideSimilar.connect( s.hideSimilar.connect(
[]() { []() {
getApp()->windows->forceLayoutChannelViews(); getIApp()->getWindows()->forceLayoutChannelViews();
}, },
false); false);
layout.addDropdown<float>( layout.addDropdown<float>(
@ -940,10 +940,10 @@ void GeneralPage::initLayout(GeneralPageView &layout)
layout.addCustomCheckbox( layout.addCustomCheckbox(
"Restart on crash (requires restart)", "Restart on crash (requires restart)",
[] { [] {
return getApp()->crashHandler->shouldRecover(); return getIApp()->getCrashHandler()->shouldRecover();
}, },
[](bool on) { [](bool on) {
return getApp()->crashHandler->saveShouldRecover(on); return getIApp()->getCrashHandler()->saveShouldRecover(on);
}, },
"When possible, restart Chatterino if the program crashes"); "When possible, restart Chatterino if the program crashes");
@ -1251,7 +1251,8 @@ QString GeneralPage::getFont(const DropdownArgs &args) const
{ {
args.combobox->setCurrentIndex(0); args.combobox->setCurrentIndex(0);
args.combobox->setEditText("Choosing..."); args.combobox->setEditText("Choosing...");
QFontDialog dialog(getApp()->fonts->getFont(FontStyle::ChatMedium, 1.)); QFontDialog dialog(
getIApp()->getFonts()->getFont(FontStyle::ChatMedium, 1.));
auto ok = bool(); auto ok = bool();
auto font = dialog.getFont(&ok, this->window()); auto font = dialog.getFont(&ok, this->window());

View file

@ -197,7 +197,7 @@ ComboBox *GeneralPageView::addDropdown(
QObject::connect(combo, &QComboBox::currentTextChanged, QObject::connect(combo, &QComboBox::currentTextChanged,
[&setting](const QString &newValue) { [&setting](const QString &newValue) {
setting = newValue; setting = newValue;
getApp()->windows->forceLayoutChannelViews(); getIApp()->getWindows()->forceLayoutChannelViews();
}); });
return combo; return combo;

View file

@ -203,7 +203,7 @@ public:
setValue = std::move(setValue)](const int newIndex) { setValue = std::move(setValue)](const int newIndex) {
setting = setValue(DropdownArgs{combo->itemText(newIndex), setting = setValue(DropdownArgs{combo->itemText(newIndex),
combo->currentIndex(), combo}); combo->currentIndex(), combo});
getApp()->windows->forceLayoutChannelViews(); getIApp()->getWindows()->forceLayoutChannelViews();
}); });
return combo; return combo;
@ -255,7 +255,7 @@ public:
setValue = std::move(setValue)](const int newIndex) { setValue = std::move(setValue)](const int newIndex) {
setting = setValue(DropdownArgs{combo->itemText(newIndex), setting = setValue(DropdownArgs{combo->itemText(newIndex),
combo->currentIndex(), combo}); combo->currentIndex(), combo});
getApp()->windows->forceLayoutChannelViews(); getIApp()->getWindows()->forceLayoutChannelViews();
}); });
return combo; return combo;
@ -300,7 +300,7 @@ public:
// Instead, it's up to the getters to make sure that the setting is legic - see the enum_cast above // Instead, it's up to the getters to make sure that the setting is legic - see the enum_cast above
// You could also use the settings `getEnum` function // You could also use the settings `getEnum` function
setting = newText; setting = newText;
getApp()->windows->forceLayoutChannelViews(); getIApp()->getWindows()->forceLayoutChannelViews();
}); });
return combo; return combo;

View file

@ -120,7 +120,7 @@ void IgnoresPage::onShow()
{ {
auto *app = getApp(); auto *app = getApp();
auto user = app->accounts->twitch.getCurrent(); auto user = app->getAccounts()->twitch.getCurrent();
if (user->isAnon()) if (user->isAnon())
{ {

View file

@ -22,7 +22,7 @@ using namespace chatterino;
void tableCellClicked(const QModelIndex &clicked, EditableModelView *view, void tableCellClicked(const QModelIndex &clicked, EditableModelView *view,
HotkeyModel *model) HotkeyModel *model)
{ {
auto hotkey = getApp()->hotkeys->getHotkeyByName( auto hotkey = getIApp()->getHotkeys()->getHotkeyByName(
clicked.siblingAtColumn(0).data(Qt::EditRole).toString()); clicked.siblingAtColumn(0).data(Qt::EditRole).toString());
if (!hotkey) if (!hotkey)
{ {
@ -34,8 +34,8 @@ void tableCellClicked(const QModelIndex &clicked, EditableModelView *view,
if (wasAccepted) if (wasAccepted)
{ {
auto newHotkey = dialog.data(); auto newHotkey = dialog.data();
getApp()->hotkeys->replaceHotkey(hotkey->name(), newHotkey); getIApp()->getHotkeys()->replaceHotkey(hotkey->name(), newHotkey);
getApp()->hotkeys->save(); getIApp()->getHotkeys()->save();
} }
} }
@ -48,7 +48,7 @@ KeyboardSettingsPage::KeyboardSettingsPage()
LayoutCreator<KeyboardSettingsPage> layoutCreator(this); LayoutCreator<KeyboardSettingsPage> layoutCreator(this);
auto layout = layoutCreator.emplace<QVBoxLayout>(); auto layout = layoutCreator.emplace<QVBoxLayout>();
auto *model = getApp()->hotkeys->createModel(nullptr); auto *model = getIApp()->getHotkeys()->createModel(nullptr);
EditableModelView *view = EditableModelView *view =
layout.emplace<EditableModelView>(model).getElement(); layout.emplace<EditableModelView>(model).getElement();
@ -68,8 +68,8 @@ KeyboardSettingsPage::KeyboardSettingsPage()
if (wasAccepted) if (wasAccepted)
{ {
auto newHotkey = dialog.data(); auto newHotkey = dialog.data();
getApp()->hotkeys->hotkeys_.append(newHotkey); getIApp()->getHotkeys()->hotkeys_.append(newHotkey);
getApp()->hotkeys->save(); getIApp()->getHotkeys()->save();
} }
}); });
@ -87,7 +87,7 @@ KeyboardSettingsPage::KeyboardSettingsPage()
if (reply == QMessageBox::Yes) if (reply == QMessageBox::Yes)
{ {
getApp()->hotkeys->resetToDefaults(); getIApp()->getHotkeys()->resetToDefaults();
} }
}); });
view->addCustomButton(resetEverything); view->addCustomButton(resetEverything);

View file

@ -93,7 +93,7 @@ NotificationPage::NotificationPage()
EditableModelView *view = EditableModelView *view =
twitchChannels twitchChannels
.emplace<EditableModelView>( .emplace<EditableModelView>(
getApp()->notifications->createModel( getIApp()->getNotifications()->createModel(
nullptr, Platform::Twitch)) nullptr, Platform::Twitch))
.getElement(); .getElement();
view->setTitles({"Twitch channels"}); view->setTitles({"Twitch channels"});
@ -112,7 +112,8 @@ NotificationPage::NotificationPage()
// We can safely ignore this signal connection since we own the view // We can safely ignore this signal connection since we own the view
std::ignore = view->addButtonPressed.connect([] { std::ignore = view->addButtonPressed.connect([] {
getApp() getApp()
->notifications->channelMap[Platform::Twitch] ->getNotifications()
->channelMap[Platform::Twitch]
.append("channel"); .append("channel");
}); });
} }

View file

@ -80,7 +80,7 @@ void PluginsPage::rebuildContent()
this->scrollAreaWidget_.append(this->dataFrame_); this->scrollAreaWidget_.append(this->dataFrame_);
auto layout = frame.setLayoutType<QVBoxLayout>(); auto layout = frame.setLayoutType<QVBoxLayout>();
layout->setParent(this->dataFrame_); layout->setParent(this->dataFrame_);
for (const auto &[id, plugin] : getApp()->plugins->plugins()) for (const auto &[id, plugin] : getIApp()->getPlugins()->plugins())
{ {
auto groupHeaderText = auto groupHeaderText =
QString("%1 (%2, from %3)") QString("%1 (%2, from %3)")
@ -185,7 +185,7 @@ void PluginsPage::rebuildContent()
val.push_back(name); val.push_back(name);
} }
getSettings()->enabledPlugins.setValue(val); getSettings()->enabledPlugins.setValue(val);
getApp()->plugins->reload(name); getIApp()->getPlugins()->reload(name);
this->rebuildContent(); this->rebuildContent();
}); });
pluginEntry->addRow(toggleButton); pluginEntry->addRow(toggleButton);
@ -194,7 +194,7 @@ void PluginsPage::rebuildContent()
auto *reloadButton = new QPushButton("Reload", this->dataFrame_); auto *reloadButton = new QPushButton("Reload", this->dataFrame_);
QObject::connect(reloadButton, &QPushButton::pressed, QObject::connect(reloadButton, &QPushButton::pressed,
[name = id, this]() { [name = id, this]() {
getApp()->plugins->reload(name); getIApp()->getPlugins()->reload(name);
this->rebuildContent(); this->rebuildContent();
}); });
pluginEntry->addRow(reloadButton); pluginEntry->addRow(reloadButton);

View file

@ -108,7 +108,7 @@ QCheckBox *SettingsPage::createCheckBox(
QObject::connect(checkbox, &QCheckBox::toggled, this, QObject::connect(checkbox, &QCheckBox::toggled, this,
[&setting](bool state) { [&setting](bool state) {
setting = state; setting = state;
getApp()->windows->forceLayoutChannelViews(); getIApp()->getWindows()->forceLayoutChannelViews();
}); });
return checkbox; return checkbox;

View file

@ -241,7 +241,7 @@ Split::Split(QWidget *parent)
// update placeholder text on Twitch account change and channel change // update placeholder text on Twitch account change and channel change
this->bSignals_.emplace_back( this->bSignals_.emplace_back(
getApp()->accounts->twitch.currentUserChanged.connect([this] { getIApp()->getAccounts()->twitch.currentUserChanged.connect([this] {
this->updateInputPlaceholder(); this->updateInputPlaceholder();
})); }));
this->signalHolder_.managedConnect(channelChanged, [this] { this->signalHolder_.managedConnect(channelChanged, [this] {
@ -427,7 +427,8 @@ Split::Split(QWidget *parent)
} }
} }
QPointer<ResizingTextEdit> edit = this->input_->ui_.textEdit; QPointer<ResizingTextEdit> edit = this->input_->ui_.textEdit;
getApp()->imageUploader->upload(source, this->getChannel(), edit); getIApp()->getImageUploader()->upload(source, this->getChannel(),
edit);
}); });
getSettings()->imageUploaderEnabled.connect( getSettings()->imageUploaderEnabled.connect(
@ -436,7 +437,7 @@ Split::Split(QWidget *parent)
}, },
this->signalHolder_); this->signalHolder_);
this->addShortcuts(); this->addShortcuts();
this->signalHolder_.managedConnect(getApp()->hotkeys->onItemsUpdated, this->signalHolder_.managedConnect(getIApp()->getHotkeys()->onItemsUpdated,
[this]() { [this]() {
this->clearShortcuts(); this->clearShortcuts();
this->addShortcuts(); this->addShortcuts();
@ -689,7 +690,7 @@ void Split::addShortcuts()
<< "runCommand hotkey called without arguments!"; << "runCommand hotkey called without arguments!";
return "runCommand hotkey called without arguments!"; return "runCommand hotkey called without arguments!";
} }
QString command = getApp()->commands->execCommand( QString command = getIApp()->getCommands()->execCommand(
arguments.at(0).replace('\n', ' '), this->getChannel(), false); arguments.at(0).replace('\n', ' '), this->getChannel(), false);
this->getChannel()->sendMessage(command); this->getChannel()->sendMessage(command);
return ""; return "";
@ -724,24 +725,24 @@ void Split::addShortcuts()
if (mode == 0) if (mode == 0)
{ {
getApp()->notifications->removeChannelNotification( getIApp()->getNotifications()->removeChannelNotification(
this->getChannel()->getName(), Platform::Twitch); this->getChannel()->getName(), Platform::Twitch);
} }
else if (mode == 1) else if (mode == 1)
{ {
getApp()->notifications->addChannelNotification( getIApp()->getNotifications()->addChannelNotification(
this->getChannel()->getName(), Platform::Twitch); this->getChannel()->getName(), Platform::Twitch);
} }
else else
{ {
getApp()->notifications->updateChannelNotification( getIApp()->getNotifications()->updateChannelNotification(
this->getChannel()->getName(), Platform::Twitch); this->getChannel()->getName(), Platform::Twitch);
} }
return ""; return "";
}}, }},
}; };
this->shortcuts_ = getApp()->hotkeys->shortcutsForCategory( this->shortcuts_ = getIApp()->getHotkeys()->shortcutsForCategory(
HotkeyCategory::Split, actions, this); HotkeyCategory::Split, actions, this);
} }
@ -770,7 +771,7 @@ void Split::updateInputPlaceholder()
return; return;
} }
auto user = getApp()->accounts->twitch.getCurrent(); auto user = getIApp()->getAccounts()->twitch.getCurrent();
QString placeholderText; QString placeholderText;
if (user->isAnon()) if (user->isAnon())
@ -779,9 +780,11 @@ void Split::updateInputPlaceholder()
} }
else else
{ {
placeholderText = placeholderText = QString("Send message as %1...")
QString("Send message as %1...") .arg(getIApp()
.arg(getApp()->accounts->twitch.getCurrent()->getUserName()); ->getAccounts()
->twitch.getCurrent()
->getUserName());
} }
this->input_->ui_.textEdit->setPlaceholderText(placeholderText); this->input_->ui_.textEdit->setPlaceholderText(placeholderText);
@ -789,7 +792,7 @@ void Split::updateInputPlaceholder()
void Split::joinChannelInNewTab(ChannelPtr channel) void Split::joinChannelInNewTab(ChannelPtr channel)
{ {
auto &nb = getApp()->windows->getMainWindow().getNotebook(); auto &nb = getIApp()->getWindows()->getMainWindow().getNotebook();
SplitContainer *container = nb.addPage(true); SplitContainer *container = nb.addPage(true);
Split *split = new Split(container); Split *split = new Split(container);
@ -889,7 +892,7 @@ void Split::setChannel(IndirectChannel newChannel)
this->actionRequested.invoke(Action::RefreshTab); this->actionRequested.invoke(Action::RefreshTab);
// Queue up save because: Split channel changed // Queue up save because: Split channel changed
getApp()->windows->queueSave(); getIApp()->getWindows()->queueSave();
} }
void Split::setModerationMode(bool value) void Split::setModerationMode(bool value)
@ -983,7 +986,7 @@ void Split::keyReleaseEvent(QKeyEvent *event)
void Split::resizeEvent(QResizeEvent *event) void Split::resizeEvent(QResizeEvent *event)
{ {
// Queue up save because: Split resized // Queue up save because: Split resized
getApp()->windows->queueSave(); getIApp()->getWindows()->queueSave();
BaseWidget::resizeEvent(event); BaseWidget::resizeEvent(event);
@ -1073,7 +1076,7 @@ void Split::explainSplitting()
void Split::popup() void Split::popup()
{ {
auto *app = getApp(); auto *app = getApp();
Window &window = app->windows->createWindow(WindowType::Popup); Window &window = app->getWindows()->createWindow(WindowType::Popup);
Split *split = new Split(static_cast<SplitContainer *>( Split *split = new Split(static_cast<SplitContainer *>(
window.getNotebook().getOrAddSelectedPage())); window.getNotebook().getOrAddSelectedPage()));
@ -1104,7 +1107,8 @@ void Split::openInBrowser()
void Split::openWhispersInBrowser() void Split::openWhispersInBrowser()
{ {
auto userName = getApp()->accounts->twitch.getCurrent()->getUserName(); auto userName =
getIApp()->getAccounts()->twitch.getCurrent()->getUserName();
QDesktopServices::openUrl("https://twitch.tv/popout/moderator/" + userName + QDesktopServices::openUrl("https://twitch.tv/popout/moderator/" + userName +
"/whispers"); "/whispers");
} }
@ -1191,7 +1195,8 @@ void Split::showChatterList()
auto formatListItemText = [](QString text) { auto formatListItemText = [](QString text) {
auto *item = new QListWidgetItem(); auto *item = new QListWidgetItem();
item->setText(text); item->setText(text);
item->setFont(getApp()->fonts->getFont(FontStyle::ChatMedium, 1.0)); item->setFont(
getIApp()->getFonts()->getFont(FontStyle::ChatMedium, 1.0));
return item; return item;
}; };
@ -1241,7 +1246,7 @@ void Split::showChatterList()
auto loadChatters = [=](auto modList, auto vipList, bool isBroadcaster) { auto loadChatters = [=](auto modList, auto vipList, bool isBroadcaster) {
getHelix()->getChatters( getHelix()->getChatters(
twitchChannel->roomId(), twitchChannel->roomId(),
getApp()->accounts->twitch.getCurrent()->getUserId(), 50000, getIApp()->getAccounts()->twitch.getCurrent()->getUserId(), 50000,
[=](auto chatters) { [=](auto chatters) {
auto broadcaster = channel->getName().toLower(); auto broadcaster = channel->getName().toLower();
QStringList chatterList; QStringList chatterList;
@ -1406,7 +1411,7 @@ void Split::showChatterList()
}}, }},
}; };
getApp()->hotkeys->shortcutsForCategory(HotkeyCategory::PopupWindow, getIApp()->getHotkeys()->shortcutsForCategory(HotkeyCategory::PopupWindow,
actions, chatterDock); actions, chatterDock);
dockVbox->addWidget(searchBar); dockVbox->addWidget(searchBar);
@ -1470,7 +1475,7 @@ void Split::showSearch(bool singleChannel)
} }
// Pass every ChannelView for every Split across the app to the search popup // Pass every ChannelView for every Split across the app to the search popup
auto &notebook = getApp()->windows->getMainWindow().getNotebook(); auto &notebook = getIApp()->getWindows()->getMainWindow().getNotebook();
for (int i = 0; i < notebook.getPageCount(); ++i) for (int i = 0; i < notebook.getPageCount(); ++i)
{ {
auto *container = dynamic_cast<SplitContainer *>(notebook.getPageAt(i)); auto *container = dynamic_cast<SplitContainer *>(notebook.getPageAt(i));
@ -1489,7 +1494,7 @@ void Split::showSearch(bool singleChannel)
void Split::reloadChannelAndSubscriberEmotes() void Split::reloadChannelAndSubscriberEmotes()
{ {
auto channel = this->getChannel(); auto channel = this->getChannel();
getApp()->accounts->twitch.getCurrent()->loadEmotes(channel); getIApp()->getAccounts()->twitch.getCurrent()->loadEmotes(channel);
if (auto *twitchChannel = dynamic_cast<TwitchChannel *>(channel.get())) if (auto *twitchChannel = dynamic_cast<TwitchChannel *>(channel.get()))
{ {

View file

@ -131,7 +131,7 @@ Split *SplitContainer::appendNewSplit(bool openChannelNameDialog)
void SplitContainer::insertSplit(Split *split, InsertOptions &&options) void SplitContainer::insertSplit(Split *split, InsertOptions &&options)
{ {
// Queue up save because: Split added // Queue up save because: Split added
getApp()->windows->queueSave(); getIApp()->getWindows()->queueSave();
assertInGuiThread(); assertInGuiThread();
@ -345,7 +345,7 @@ SplitContainer::Position SplitContainer::releaseSplit(Split *split)
SplitContainer::Position SplitContainer::deleteSplit(Split *split) SplitContainer::Position SplitContainer::deleteSplit(Split *split)
{ {
// Queue up save because: Split removed // Queue up save because: Split removed
getApp()->windows->queueSave(); getIApp()->getWindows()->queueSave();
assertInGuiThread(); assertInGuiThread();
assert(split != nullptr); assert(split != nullptr);
@ -614,8 +614,8 @@ void SplitContainer::paintEvent(QPaintEvent * /*event*/)
painter.setPen(this->theme->splits.header.text); painter.setPen(this->theme->splits.header.text);
const auto font = const auto font = getIApp()->getFonts()->getFont(FontStyle::ChatMedium,
getApp()->fonts->getFont(FontStyle::ChatMedium, this->scale()); this->scale());
painter.setFont(font); painter.setFont(font);
QString text = "Click to add a split"; QString text = "Click to add a split";
@ -634,7 +634,7 @@ void SplitContainer::paintEvent(QPaintEvent * /*event*/)
} }
else else
{ {
if (getApp()->themes->isLightTheme()) if (getIApp()->getThemes()->isLightTheme())
{ {
painter.fillRect(rect(), QColor("#999")); painter.fillRect(rect(), QColor("#999"));
} }
@ -646,8 +646,8 @@ void SplitContainer::paintEvent(QPaintEvent * /*event*/)
for (DropRect &dropRect : this->dropRects_) for (DropRect &dropRect : this->dropRects_)
{ {
QColor border = getApp()->themes->splits.dropTargetRectBorder; QColor border = getIApp()->getThemes()->splits.dropTargetRectBorder;
QColor background = getApp()->themes->splits.dropTargetRect; QColor background = getIApp()->getThemes()->splits.dropTargetRect;
if (!dropRect.rect.contains(this->mouseOverPoint_)) if (!dropRect.rect.contains(this->mouseOverPoint_))
{ {
@ -774,7 +774,7 @@ void SplitContainer::applyFromDescriptor(const NodeDescriptor &rootNode)
void SplitContainer::popup() void SplitContainer::popup()
{ {
Window &window = getApp()->windows->createWindow(WindowType::Popup); Window &window = getIApp()->getWindows()->createWindow(WindowType::Popup);
auto *popupContainer = window.getNotebook().getOrAddSelectedPage(); auto *popupContainer = window.getNotebook().getOrAddSelectedPage();
QJsonObject encodedTab; QJsonObject encodedTab;
@ -1436,15 +1436,15 @@ void SplitContainer::DropOverlay::paintEvent(QPaintEvent * /*event*/)
{ {
if (!foundMover && rect.rect.contains(this->mouseOverPoint_)) if (!foundMover && rect.rect.contains(this->mouseOverPoint_))
{ {
painter.setBrush(getApp()->themes->splits.dropPreview); painter.setBrush(getIApp()->getThemes()->splits.dropPreview);
painter.setPen(getApp()->themes->splits.dropPreviewBorder); painter.setPen(getIApp()->getThemes()->splits.dropPreviewBorder);
foundMover = true; foundMover = true;
} }
else else
{ {
painter.setBrush(QColor(0, 0, 0, 0)); painter.setBrush(QColor(0, 0, 0, 0));
painter.setPen(QColor(0, 0, 0, 0)); painter.setPen(QColor(0, 0, 0, 0));
// painter.setPen(getApp()->themes->splits.dropPreviewBorder); // painter.setPen(getIApp()->getThemes()->splits.dropPreviewBorder);
} }
painter.drawRect(rect.rect); painter.drawRect(rect.rect);
@ -1526,10 +1526,10 @@ SplitContainer::ResizeHandle::ResizeHandle(SplitContainer *_parent)
void SplitContainer::ResizeHandle::paintEvent(QPaintEvent * /*event*/) void SplitContainer::ResizeHandle::paintEvent(QPaintEvent * /*event*/)
{ {
QPainter painter(this); QPainter painter(this);
painter.setPen(QPen(getApp()->themes->splits.resizeHandle, 2)); painter.setPen(QPen(getIApp()->getThemes()->splits.resizeHandle, 2));
painter.fillRect(this->rect(), painter.fillRect(this->rect(),
getApp()->themes->splits.resizeHandleBackground); getIApp()->getThemes()->splits.resizeHandleBackground);
if (this->vertical_) if (this->vertical_)
{ {

View file

@ -246,7 +246,7 @@ SplitHeader::SplitHeader(Split *split)
}); });
this->bSignals_.emplace_back( this->bSignals_.emplace_back(
getApp()->accounts->twitch.currentUserChanged.connect([this] { getIApp()->getAccounts()->twitch.currentUserChanged.connect([this] {
this->updateModerationModeIcon(); this->updateModerationModeIcon();
})); }));
@ -295,7 +295,7 @@ void SplitHeader::initializeLayout()
case Qt::LeftButton: case Qt::LeftButton:
if (getSettings()->moderationActions.empty()) if (getSettings()->moderationActions.empty())
{ {
getApp()->windows->showSettingsDialog( getIApp()->getWindows()->showSettingsDialog(
this, SettingsDialogPreference:: this, SettingsDialogPreference::
ModerationActions); ModerationActions);
this->split_->setModerationMode(true); this->split_->setModerationMode(true);
@ -313,7 +313,7 @@ void SplitHeader::initializeLayout()
case Qt::RightButton: case Qt::RightButton:
case Qt::MiddleButton: case Qt::MiddleButton:
getApp()->windows->showSettingsDialog( getIApp()->getWindows()->showSettingsDialog(
this, this,
SettingsDialogPreference::ModerationActions); SettingsDialogPreference::ModerationActions);
break; break;
@ -363,7 +363,7 @@ void SplitHeader::initializeLayout()
std::unique_ptr<QMenu> SplitHeader::createMainMenu() std::unique_ptr<QMenu> SplitHeader::createMainMenu()
{ {
// top level menu // top level menu
const auto &h = getApp()->hotkeys; const auto &h = getIApp()->getHotkeys();
auto menu = std::make_unique<QMenu>(); auto menu = std::make_unique<QMenu>();
menu->addAction( menu->addAction(
"Change channel", this->split_, &Split::changeChannel, "Change channel", this->split_, &Split::changeChannel,
@ -533,11 +533,11 @@ std::unique_ptr<QMenu> SplitHeader::createMainMenu()
action->setShortcut(notifySeq); action->setShortcut(notifySeq);
QObject::connect(moreMenu, &QMenu::aboutToShow, this, [action, this]() { QObject::connect(moreMenu, &QMenu::aboutToShow, this, [action, this]() {
action->setChecked(getApp()->notifications->isChannelNotified( action->setChecked(getIApp()->getNotifications()->isChannelNotified(
this->split_->getChannel()->getName(), Platform::Twitch)); this->split_->getChannel()->getName(), Platform::Twitch));
}); });
QObject::connect(action, &QAction::triggered, this, [this]() { QObject::connect(action, &QAction::triggered, this, [this]() {
getApp()->notifications->updateChannelNotification( getIApp()->getNotifications()->updateChannelNotification(
this->split_->getChannel()->getName(), Platform::Twitch); this->split_->getChannel()->getName(), Platform::Twitch);
}); });
@ -1034,7 +1034,7 @@ void SplitHeader::reloadSubscriberEmotes()
this->lastReloadedSubEmotes_ = now; this->lastReloadedSubEmotes_ = now;
auto channel = this->split_->getChannel(); auto channel = this->split_->getChannel();
getApp()->accounts->twitch.getCurrent()->loadEmotes(channel); getIApp()->getAccounts()->twitch.getCurrent()->loadEmotes(channel);
} }
void SplitHeader::reconnect() void SplitHeader::reconnect()

View file

@ -69,7 +69,7 @@ SplitInput::SplitInput(QWidget *parent, Split *_chatWidget,
this->hideCompletionPopup(); this->hideCompletionPopup();
}); });
this->scaleChangedEvent(this->scale()); this->scaleChangedEvent(this->scale());
this->signalHolder_.managedConnect(getApp()->hotkeys->onItemsUpdated, this->signalHolder_.managedConnect(getIApp()->getHotkeys()->onItemsUpdated,
[this]() { [this]() {
this->clearShortcuts(); this->clearShortcuts();
this->addShortcuts(); this->addShortcuts();
@ -96,7 +96,7 @@ void SplitInput::initLayout()
auto replyLabel = replyHbox.emplace<QLabel>().assign(&this->ui_.replyLabel); auto replyLabel = replyHbox.emplace<QLabel>().assign(&this->ui_.replyLabel);
replyLabel->setAlignment(Qt::AlignLeft); replyLabel->setAlignment(Qt::AlignLeft);
replyLabel->setFont( replyLabel->setFont(
app->fonts->getFont(FontStyle::ChatMedium, this->scale())); app->getFonts()->getFont(FontStyle::ChatMedium, this->scale()));
replyHbox->addStretch(1); replyHbox->addStretch(1);
@ -157,18 +157,18 @@ void SplitInput::initLayout()
// set edit font // set edit font
this->ui_.textEdit->setFont( this->ui_.textEdit->setFont(
app->fonts->getFont(FontStyle::ChatMedium, this->scale())); app->getFonts()->getFont(FontStyle::ChatMedium, this->scale()));
QObject::connect(this->ui_.textEdit, &QTextEdit::cursorPositionChanged, QObject::connect(this->ui_.textEdit, &QTextEdit::cursorPositionChanged,
this, &SplitInput::onCursorPositionChanged); this, &SplitInput::onCursorPositionChanged);
QObject::connect(this->ui_.textEdit, &QTextEdit::textChanged, this, QObject::connect(this->ui_.textEdit, &QTextEdit::textChanged, this,
&SplitInput::onTextChanged); &SplitInput::onTextChanged);
this->managedConnections_.managedConnect( this->managedConnections_.managedConnect(
app->fonts->fontChanged, [=, this]() { app->getFonts()->fontChanged, [=, this]() {
this->ui_.textEdit->setFont( this->ui_.textEdit->setFont(
app->fonts->getFont(FontStyle::ChatMedium, this->scale())); app->getFonts()->getFont(FontStyle::ChatMedium, this->scale()));
this->ui_.replyLabel->setFont( this->ui_.replyLabel->setFont(app->getFonts()->getFont(
app->fonts->getFont(FontStyle::ChatMediumBold, this->scale())); FontStyle::ChatMediumBold, this->scale()));
}); });
// open emote popup // open emote popup
@ -213,11 +213,11 @@ void SplitInput::scaleChangedEvent(float scale)
this->setMaximumHeight(this->scaledMaxHeight()); this->setMaximumHeight(this->scaledMaxHeight());
} }
this->ui_.textEdit->setFont( this->ui_.textEdit->setFont(
app->fonts->getFont(FontStyle::ChatMedium, scale)); app->getFonts()->getFont(FontStyle::ChatMedium, scale));
this->ui_.textEditLength->setFont( this->ui_.textEditLength->setFont(
app->fonts->getFont(FontStyle::ChatMedium, scale)); app->getFonts()->getFont(FontStyle::ChatMedium, scale));
this->ui_.replyLabel->setFont( this->ui_.replyLabel->setFont(
app->fonts->getFont(FontStyle::ChatMediumBold, scale)); app->getFonts()->getFont(FontStyle::ChatMediumBold, scale));
} }
void SplitInput::themeChangedEvent() void SplitInput::themeChangedEvent()
@ -332,7 +332,7 @@ QString SplitInput::handleSendMessage(const std::vector<QString> &arguments)
message = message.replace('\n', ' '); message = message.replace('\n', ' ');
QString sendMessage = QString sendMessage =
getApp()->commands->execCommand(message, c, false); getIApp()->getCommands()->execCommand(message, c, false);
c->sendMessage(sendMessage); c->sendMessage(sendMessage);
@ -363,7 +363,8 @@ QString SplitInput::handleSendMessage(const std::vector<QString> &arguments)
} }
message = message.replace('\n', ' '); message = message.replace('\n', ' ');
QString sendMessage = getApp()->commands->execCommand(message, c, false); QString sendMessage =
getIApp()->getCommands()->execCommand(message, c, false);
// Reply within TwitchChannel // Reply within TwitchChannel
tc->sendReply(sendMessage, this->replyThread_->id); tc->sendReply(sendMessage, this->replyThread_->id);
@ -640,7 +641,7 @@ void SplitInput::addShortcuts()
}}, }},
}; };
this->shortcuts_ = getApp()->hotkeys->shortcutsForCategory( this->shortcuts_ = getIApp()->getHotkeys()->shortcutsForCategory(
HotkeyCategory::SplitInput, actions, this->parentWidget()); HotkeyCategory::SplitInput, actions, this->parentWidget());
} }
@ -947,8 +948,8 @@ void SplitInput::editTextChanged()
this->textChanged.invoke(text); this->textChanged.invoke(text);
text = text.trimmed(); text = text.trimmed();
text = text = app->getCommands()->execCommand(text, this->split_->getChannel(),
app->commands->execCommand(text, this->split_->getChannel(), true); true);
} }
if (text.length() > 0 && if (text.length() > 0 &&

View file

@ -268,8 +268,8 @@ void SplitOverlay::paintEvent(QPaintEvent *event)
{ {
rect.setRight(rect.right() - 1); rect.setRight(rect.right() - 1);
rect.setBottom(rect.bottom() - 1); rect.setBottom(rect.bottom() - 1);
painter.setPen(getApp()->themes->splits.dropPreviewBorder); painter.setPen(getIApp()->getThemes()->splits.dropPreviewBorder);
painter.setBrush(getApp()->themes->splits.dropPreview); painter.setBrush(getIApp()->getThemes()->splits.dropPreview);
painter.drawRect(rect); painter.drawRect(rect);
} }
} }