2019-09-22 15:32:36 +02:00
|
|
|
#include <QApplication>
|
2020-09-26 16:03:51 +02:00
|
|
|
#include <QCommandLineParser>
|
2019-10-07 18:57:33 +02:00
|
|
|
#include <QDebug>
|
|
|
|
#include <QMessageBox>
|
2019-09-22 15:32:36 +02:00
|
|
|
#include <QStringList>
|
|
|
|
#include <memory>
|
|
|
|
|
2018-08-02 14:23:27 +02:00
|
|
|
#include "BrowserExtension.hpp"
|
|
|
|
#include "RunGui.hpp"
|
2019-09-22 15:32:36 +02:00
|
|
|
#include "common/Args.hpp"
|
2019-10-05 16:40:04 +02:00
|
|
|
#include "common/Modes.hpp"
|
2019-10-07 18:57:33 +02:00
|
|
|
#include "common/Version.hpp"
|
2020-03-14 12:13:57 +01:00
|
|
|
#include "providers/twitch/api/Helix.hpp"
|
|
|
|
#include "providers/twitch/api/Kraken.hpp"
|
2018-06-28 19:46:45 +02:00
|
|
|
#include "singletons/Paths.hpp"
|
2018-08-02 14:23:27 +02:00
|
|
|
#include "singletons/Settings.hpp"
|
2018-10-16 14:13:19 +02:00
|
|
|
#include "util/IncognitoBrowser.hpp"
|
2017-01-11 01:08:20 +01:00
|
|
|
|
2018-08-02 14:23:27 +02:00
|
|
|
using namespace chatterino;
|
2018-04-09 22:59:19 +02:00
|
|
|
|
2018-08-02 14:23:27 +02:00
|
|
|
int main(int argc, char **argv)
|
2018-04-09 22:59:19 +02:00
|
|
|
{
|
2018-06-13 13:27:10 +02:00
|
|
|
QApplication a(argc, argv);
|
|
|
|
|
2020-05-10 10:54:55 +02:00
|
|
|
QCoreApplication::setApplicationName("chatterino");
|
|
|
|
QCoreApplication::setApplicationVersion(CHATTERINO_VERSION);
|
|
|
|
QCoreApplication::setOrganizationDomain("https://www.chatterino.com");
|
|
|
|
|
2020-09-26 16:03:51 +02:00
|
|
|
initArgs(a);
|
2018-04-09 22:59:19 +02:00
|
|
|
|
2018-08-02 14:23:27 +02:00
|
|
|
// run in gui mode or browser extension host mode
|
2020-09-26 16:03:51 +02:00
|
|
|
if (getArgs().shouldRunBrowserExtensionHost)
|
2018-10-21 13:43:02 +02:00
|
|
|
{
|
2018-08-02 14:23:27 +02:00
|
|
|
runBrowserExtensionHost();
|
2018-10-21 13:43:02 +02:00
|
|
|
}
|
2019-10-07 18:57:33 +02:00
|
|
|
else if (getArgs().printVersion)
|
|
|
|
{
|
2020-06-16 09:30:35 +02:00
|
|
|
auto version = Version::instance();
|
|
|
|
qInfo().noquote() << QString("%1 (commit %2%3)")
|
|
|
|
.arg(version.fullVersion())
|
|
|
|
.arg(version.commitHash())
|
|
|
|
.arg(Modes::instance().isNightly
|
|
|
|
? ", " + version.dateOfBuild()
|
|
|
|
: "");
|
2019-10-07 18:57:33 +02:00
|
|
|
}
|
2018-10-21 13:43:02 +02:00
|
|
|
else
|
|
|
|
{
|
2020-03-14 12:13:57 +01:00
|
|
|
Helix::initialize();
|
|
|
|
Kraken::initialize();
|
|
|
|
|
2019-10-05 16:40:04 +02:00
|
|
|
Paths *paths{};
|
2018-04-20 00:15:57 +02:00
|
|
|
|
2019-10-05 16:40:04 +02:00
|
|
|
try
|
|
|
|
{
|
|
|
|
paths = new Paths;
|
|
|
|
}
|
|
|
|
catch (std::runtime_error &error)
|
|
|
|
{
|
|
|
|
QMessageBox box;
|
2019-10-07 22:42:34 +02:00
|
|
|
if (Modes::instance().isPortable)
|
2019-10-05 16:40:04 +02:00
|
|
|
{
|
|
|
|
box.setText(
|
|
|
|
error.what() +
|
|
|
|
QStringLiteral(
|
|
|
|
"\n\nInfo: Portable mode requires the application to "
|
|
|
|
"be in a writeable location. If you don't want "
|
|
|
|
"portable mode reinstall the application. "
|
|
|
|
"https://chatterino.com."));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
box.setText(error.what());
|
|
|
|
}
|
|
|
|
box.exec();
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
Settings settings(paths->settingsDirectory);
|
|
|
|
|
|
|
|
runGui(a, *paths, settings);
|
2018-05-28 18:25:19 +02:00
|
|
|
}
|
2019-10-07 18:57:33 +02:00
|
|
|
return 0;
|
2018-05-28 18:25:19 +02:00
|
|
|
}
|