2017-06-13 21:13:58 +02:00
|
|
|
#include "application.hpp"
|
|
|
|
#include "colorscheme.hpp"
|
2017-06-26 16:41:20 +02:00
|
|
|
#include "logging/loggingmanager.hpp"
|
2017-06-13 21:13:58 +02:00
|
|
|
#include "settingsmanager.hpp"
|
|
|
|
|
|
|
|
namespace chatterino {
|
|
|
|
|
2017-06-26 16:41:20 +02:00
|
|
|
// 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
|
|
|
|
|
2017-06-13 21:13:58 +02:00
|
|
|
Application::Application()
|
2017-06-26 16:41:20 +02:00
|
|
|
: windowManager(this->channelManager, this->colorScheme)
|
|
|
|
, colorScheme(this->windowManager)
|
2017-06-13 21:13:58 +02:00
|
|
|
, 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)
|
2017-06-26 16:41:20 +02:00
|
|
|
, messageFactory(this->resources, this->emoteManager, this->windowManager)
|
2017-06-13 21:13:58 +02:00
|
|
|
{
|
|
|
|
// TODO(pajlada): Get rid of all singletons
|
2017-06-26 16:41:20 +02:00
|
|
|
logging::init();
|
|
|
|
SettingsManager::getInstance().load();
|
2017-06-13 21:13:58 +02:00
|
|
|
|
|
|
|
// Initialize everything we need
|
|
|
|
this->emoteManager.loadGlobalEmotes();
|
|
|
|
|
|
|
|
// XXX
|
|
|
|
SettingsManager::getInstance().updateWordTypeMask();
|
|
|
|
|
|
|
|
this->windowManager.load();
|
2017-06-26 16:41:20 +02:00
|
|
|
|
|
|
|
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);
|
|
|
|
});
|
2017-06-13 21:13:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
Application::~Application()
|
|
|
|
{
|
|
|
|
this->windowManager.save();
|
2017-06-26 16:41:20 +02:00
|
|
|
|
|
|
|
chatterino::SettingsManager::getInstance().save();
|
2017-06-13 21:13:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|