mirror-chatterino2/src/application.cpp
Rasmus Karlsson 3bf111a091 More progress on tab-complete
There are missing parts to the "account-based" emotes that needs to be
completed before emote completion can be considered done. For now, when
I've been testing, I've been manually injecting the oauthClient and
oauthToken to the settings file with the `user_subscriptions` scope
2017-07-23 14:16:13 +02:00

67 lines
2 KiB
C++

#include "application.hpp"
#include "colorscheme.hpp"
#include "logging/loggingmanager.hpp"
#include "settingsmanager.hpp"
namespace chatterino {
// this class is responsible for handling the workflow of Chatterino
// It will create the instances of the major classes, and connect their signals to each other
Application::Application()
: completionManager(this->emoteManager)
, windowManager(this->channelManager, this->colorScheme, this->completionManager)
, colorScheme(this->windowManager)
, emoteManager(this->windowManager, this->resources)
, resources(this->emoteManager, this->windowManager)
, channelManager(this->windowManager, this->emoteManager, this->ircManager)
, ircManager(this->channelManager, this->resources, this->emoteManager, this->windowManager)
, messageFactory(this->resources, this->emoteManager, this->windowManager)
{
// TODO(pajlada): Get rid of all singletons
logging::init();
SettingsManager::getInstance().load();
// Initialize everything we need
this->emoteManager.loadGlobalEmotes();
// XXX
SettingsManager::getInstance().updateWordTypeMask();
this->windowManager.load();
this->ircManager.onPrivateMessage.connect([=](Communi::IrcPrivateMessage *message) {
QString channelName = message->target().mid(1);
auto channel = this->channelManager.getChannel(channelName);
if (channel == nullptr) {
// The message doesn't have a channel we listen to
return;
}
messages::MessageParseArgs args;
this->messageFactory.buildMessage(message, *channel.get(), args);
});
}
Application::~Application()
{
this->windowManager.save();
chatterino::SettingsManager::getInstance().save();
}
int Application::run(QApplication &qtApp)
{
// Start connecting to the IRC Servers (Twitch only for now)
this->ircManager.connect();
// Show main window
this->windowManager.getMainWindow().show();
return qtApp.exec();
}
} // namespace chatterino