mirror-chatterino2/main.cpp

97 lines
2.2 KiB
C++
Raw Normal View History

2017-04-12 17:46:44 +02:00
#include "channelmanager.h"
2016-12-30 19:20:04 +01:00
#include "colorscheme.h"
#include "common.h"
2017-01-06 23:28:48 +01:00
#include "emojis.h"
2017-04-12 17:46:44 +02:00
#include "emotemanager.h"
2017-01-13 18:59:11 +01:00
#include "ircmanager.h"
#include "logging/loggingmanager.h"
2017-01-13 18:59:11 +01:00
#include "resources.h"
2017-04-12 17:46:44 +02:00
#include "settingsmanager.h"
2017-01-18 21:30:23 +01:00
#include "widgets/mainwindow.h"
2017-04-12 17:46:44 +02:00
#include "windowmanager.h"
2017-01-11 01:08:20 +01:00
#include <QApplication>
2017-01-07 20:43:55 +01:00
#include <QClipboard>
#include <QDir>
#include <QStandardPaths>
2017-02-02 01:23:26 +01:00
#include <boost/signals2.hpp>
#include <pajlada/settings/settingmanager.hpp>
2016-12-29 17:31:07 +01:00
2017-04-14 17:52:22 +02:00
using namespace chatterino;
using namespace chatterino::widgets;
2017-01-18 21:30:23 +01:00
namespace {
inline bool initSettings(bool portable)
{
QString settingsPath;
if (portable) {
settingsPath.append(QDir::currentPath());
} else {
// Get settings path
settingsPath.append(QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation));
if (settingsPath.isEmpty()) {
printf("Error finding writable location for settings\n");
return false;
}
}
if (!QDir().mkpath(settingsPath)) {
printf("Error creating directories for settings: %s\n", qPrintable(settingsPath));
return false;
}
settingsPath.append("/settings.json");
pajlada::Settings::SettingManager::load(qPrintable(settingsPath));
return true;
}
} // namespace
int main(int argc, char *argv[])
2016-12-29 17:31:07 +01:00
{
QApplication a(argc, argv);
2016-12-30 19:20:04 +01:00
// Options
bool portable = false;
for (int i = 1; i < argc; ++i) {
if (strcmp(argv[i], "portable") == 0) {
portable = true;
}
}
// Initialize settings
if (!initSettings(portable)) {
printf("Error initializing settings\n");
return 1;
}
chatterino::logging::init();
2017-04-12 17:46:44 +02:00
SettingsManager::getInstance().load();
2017-01-13 18:59:11 +01:00
Resources::load();
Emojis::loadEmojis();
2017-04-12 17:46:44 +02:00
EmoteManager::getInstance().loadGlobalEmotes();
2017-01-06 23:28:48 +01:00
2017-02-02 01:23:26 +01:00
ColorScheme::getInstance().init();
2016-12-30 19:20:04 +01:00
2017-04-13 19:25:33 +02:00
WindowManager::getInstance().load();
2017-04-13 19:25:33 +02:00
MainWindow &w = WindowManager::getInstance().getMainWindow();
2016-12-29 17:31:07 +01:00
w.show();
2017-04-12 17:46:44 +02:00
IrcManager::getInstance().connect();
2017-01-03 21:19:33 +01:00
2017-01-23 09:49:30 +01:00
int ret = a.exec();
2017-04-12 17:46:44 +02:00
SettingsManager::getInstance().save();
2017-01-23 09:49:30 +01:00
// Save settings
pajlada::Settings::SettingManager::save();
2017-04-13 19:25:33 +02:00
WindowManager::getInstance().save();
2017-01-23 09:49:30 +01:00
return ret;
2016-12-29 17:31:07 +01:00
}