mirror-chatterino2/src/main.cpp

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

106 lines
2.7 KiB
C++
Raw Normal View History

2018-08-02 14:23:27 +02:00
#include "BrowserExtension.hpp"
2019-09-22 15:32:36 +02:00
#include "common/Args.hpp"
#include "common/Env.hpp"
#include "common/Modes.hpp"
#include "common/QLogging.hpp"
2019-10-07 18:57:33 +02:00
#include "common/Version.hpp"
#include "providers/Crashpad.hpp"
#include "providers/IvrApi.hpp"
#include "providers/NetworkConfigurationProvider.hpp"
#include "providers/twitch/api/Helix.hpp"
#include "RunGui.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"
#include "util/AttachToConsole.hpp"
2017-01-11 01:08:20 +01:00
#include <QApplication>
#include <QCommandLineParser>
#include <QMessageBox>
#include <QStringList>
#include <memory>
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
{
// TODO: This is a temporary fix (see #4552).
#if defined(Q_OS_WINDOWS) && QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
qputenv("QT_ENABLE_HIGHDPI_SCALING", "0");
#endif
2018-06-13 13:27:10 +02:00
QApplication a(argc, argv);
QCoreApplication::setApplicationName("chatterino");
QCoreApplication::setApplicationVersion(CHATTERINO_VERSION);
QCoreApplication::setOrganizationDomain("chatterino.com");
Paths *paths{};
try
{
paths = new Paths;
}
catch (std::runtime_error &error)
{
QMessageBox box;
if (Modes::instance().isPortable)
{
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;
}
initArgs(a);
2018-04-09 22:59:19 +02:00
#ifdef CHATTERINO_WITH_CRASHPAD
const auto crashpadHandler = installCrashHandler();
#endif
2018-08-02 14:23:27 +02:00
// run in gui mode or browser extension host mode
if (getArgs().shouldRunBrowserExtensionHost)
2018-08-02 14:23:27 +02:00
{
runBrowserExtensionHost();
2018-04-20 00:15:57 +02:00
}
2019-10-07 18:57:33 +02:00
else if (getArgs().printVersion)
{
attachToConsole();
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-04-20 00:15:57 +02:00
else
{
if (getArgs().verbose)
{
attachToConsole();
}
NetworkConfigurationProvider::applyFromEnv(Env::get());
IvrApi::initialize();
Helix::initialize();
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
}