mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
106 lines
2.7 KiB
C++
106 lines
2.7 KiB
C++
#include "BrowserExtension.hpp"
|
|
#include "common/Args.hpp"
|
|
#include "common/Env.hpp"
|
|
#include "common/Modes.hpp"
|
|
#include "common/QLogging.hpp"
|
|
#include "common/Version.hpp"
|
|
#include "providers/IvrApi.hpp"
|
|
#include "providers/NetworkConfigurationProvider.hpp"
|
|
#include "providers/twitch/api/Helix.hpp"
|
|
#include "RunGui.hpp"
|
|
#include "singletons/CrashHandler.hpp"
|
|
#include "singletons/Paths.hpp"
|
|
#include "singletons/Settings.hpp"
|
|
#include "singletons/Updates.hpp"
|
|
#include "util/AttachToConsole.hpp"
|
|
#include "util/IpcQueue.hpp"
|
|
|
|
#include <QApplication>
|
|
#include <QCommandLineParser>
|
|
#include <QMessageBox>
|
|
#include <QStringList>
|
|
|
|
#include <memory>
|
|
|
|
using namespace chatterino;
|
|
|
|
int main(int argc, char **argv)
|
|
{
|
|
QApplication a(argc, argv);
|
|
|
|
QCoreApplication::setApplicationName("chatterino");
|
|
QCoreApplication::setApplicationVersion(CHATTERINO_VERSION);
|
|
QCoreApplication::setOrganizationDomain("chatterino.com");
|
|
|
|
std::unique_ptr<Paths> paths;
|
|
|
|
try
|
|
{
|
|
paths = std::make_unique<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;
|
|
}
|
|
ipc::initPaths(paths.get());
|
|
|
|
const Args args(a, *paths);
|
|
|
|
#ifdef CHATTERINO_WITH_CRASHPAD
|
|
const auto crashpadHandler = installCrashHandler(args, *paths);
|
|
#endif
|
|
|
|
// run in gui mode or browser extension host mode
|
|
if (args.shouldRunBrowserExtensionHost)
|
|
{
|
|
runBrowserExtensionHost();
|
|
}
|
|
else if (args.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()
|
|
: "");
|
|
}
|
|
else
|
|
{
|
|
if (args.verbose)
|
|
{
|
|
attachToConsole();
|
|
}
|
|
|
|
Updates updates(*paths);
|
|
|
|
NetworkConfigurationProvider::applyFromEnv(Env::get());
|
|
|
|
IvrApi::initialize();
|
|
Helix::initialize();
|
|
|
|
Settings settings(paths->settingsDirectory);
|
|
|
|
runGui(a, *paths, settings, args, updates);
|
|
}
|
|
return 0;
|
|
}
|