mirror-chatterino2/src/main.cpp
apa420 1a4a468ab1
Set the application name, version, and domain (#1680)
This helps window and desktop managers figure out what to do with Chatterino
2020-05-10 10:54:55 +02:00

80 lines
2.1 KiB
C++

#include <QApplication>
#include <QDebug>
#include <QMessageBox>
#include <QStringList>
#include <memory>
#include "BrowserExtension.hpp"
#include "RunGui.hpp"
#include "common/Args.hpp"
#include "common/Modes.hpp"
#include "common/Version.hpp"
#include "providers/twitch/api/Helix.hpp"
#include "providers/twitch/api/Kraken.hpp"
#include "singletons/Paths.hpp"
#include "singletons/Settings.hpp"
#include "util/IncognitoBrowser.hpp"
using namespace chatterino;
int main(int argc, char **argv)
{
QApplication a(argc, argv);
QCoreApplication::setApplicationName("chatterino");
QCoreApplication::setApplicationVersion(CHATTERINO_VERSION);
QCoreApplication::setOrganizationDomain("https://www.chatterino.com");
// convert char** to QStringList
auto args = QStringList();
std::transform(argv + 1, argv + argc, std::back_inserter(args),
[&](auto s) { return s; });
initArgs(args);
// run in gui mode or browser extension host mode
if (shouldRunBrowserExtensionHost(args))
{
runBrowserExtensionHost();
}
else if (getArgs().printVersion)
{
qInfo().noquote() << Version::instance().fullVersion();
}
else
{
Helix::initialize();
Kraken::initialize();
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;
}
Settings settings(paths->settingsDirectory);
runGui(a, *paths, settings);
}
return 0;
}