1
Fork 0
mirror of https://github.com/redstrate/Astra.git synced 2025-04-20 11:47:46 +00:00
astra/launcher/src/main.cpp

113 lines
4.1 KiB
C++
Raw Normal View History

// SPDX-FileCopyrightText: 2023 Joshua Goins <josh@redstrate.com>
// SPDX-License-Identifier: GPL-3.0-or-later
#include <KAboutData>
#include <KLocalizedContext>
#include <KLocalizedString>
#include <QApplication>
#include <QCommandLineParser>
#include <QMessageBox>
#include <QQuickStyle>
2023-09-16 17:32:38 -04:00
#include <QtWebView>
2023-09-16 18:37:42 -04:00
#include <qcoroqml.h>
#include "astra-version.h"
#include "compatibilitytoolinstaller.h"
#include "gameinstaller.h"
#include "launchercore.h"
#include "sapphirelauncher.h"
int main(int argc, char *argv[])
{
2023-09-16 17:32:38 -04:00
QtWebView::initialize();
2023-08-18 22:21:38 -04:00
QApplication app(argc, argv);
// Default to org.kde.desktop style unless the user forces another style
if (qEnvironmentVariableIsEmpty("QT_QUICK_CONTROLS_STYLE")) {
QQuickStyle::setStyle(QStringLiteral("org.kde.desktop"));
}
KLocalizedString::setApplicationDomain("astra");
KAboutData about(QStringLiteral("astra"),
i18n("Astra"),
QStringLiteral(ASTRA_VERSION_STRING),
i18n("FFXIV Launcher"),
KAboutLicense::GPL_V3,
i18n("© 2023 Joshua Goins"));
about.addAuthor(i18n("Joshua Goins"),
i18n("Maintainer"),
QStringLiteral("josh@redstrate.com"),
QStringLiteral("https://redstrate.com/"),
QUrl("https://redstrate.com/rss-image.png"));
about.setHomepage(QStringLiteral("https://xiv.zone/astra"));
about.addComponent(QStringLiteral("physis"),
QStringLiteral("Library to access FFXIV data"),
physis_get_physis_version(),
QStringLiteral("https://xiv.zone/physis"),
KAboutLicense::GPL_V3);
about.addComponent(QStringLiteral("libphysis"), QStringLiteral("C bindings for physis"), physis_get_libphysis_version(), {}, KAboutLicense::GPL_V3);
about.setDesktopFileName(QStringLiteral("zone.xiv.astra"));
about.setBugAddress(QByteArrayLiteral("https://lists.sr.ht/~redstrate/public-inbox"));
about.setComponentName(QStringLiteral("astra"));
about.setProgramLogo(QStringLiteral("zone.xiv.astra"));
KAboutData::setApplicationData(about);
QCommandLineParser parser;
parser.setApplicationDescription(i18n("Linux FFXIV Launcher"));
#ifdef ENABLE_STEAM
QCommandLineOption steamOption(QStringLiteral("steam"), QStringLiteral("Used for booting the launcher from Steam."), QStringLiteral("verb"));
steamOption.setFlags(QCommandLineOption::HiddenFromHelp);
parser.addOption(steamOption);
#endif
about.setupCommandLine(&parser);
parser.parse(QCoreApplication::arguments());
about.processCommandLine(&parser);
// We must handle these manually, since we use parse() and not process()
if (parser.isSet("help")) {
parser.showHelp();
}
if (parser.isSet("version")) {
parser.showVersion();
}
if (parser.isSet(steamOption)) {
#ifndef ENABLE_STEAM
QMessageBox::warning(nullptr,
i18n("Warning"),
i18n("You somehow launched Astra through Steam, despite it not being compiled with Steam support. Some features may not work!"));
#endif
const QStringList args = parser.positionalArguments();
// Steam tries to use as a compatibility tool, running installation scripts (like DirectX), so try to ignore it.
if (!args.empty() && !args[0].contains(QLatin1String("ffxivboot.exe"))) {
return 0;
}
}
2023-09-16 18:37:42 -04:00
QCoro::Qml::registerTypes();
QQmlApplicationEngine engine;
2023-09-16 18:01:02 -04:00
auto core = engine.singletonInstance<LauncherCore *>(QStringLiteral("zone.xiv.astra"), QStringLiteral("LauncherCore"));
if (parser.isSet(steamOption)) {
core->initializeSteam();
}
2023-09-16 18:01:02 -04:00
engine.rootContext()->setContextObject(new KLocalizedContext(&engine));
QObject::connect(&engine, &QQmlApplicationEngine::quit, &app, &QCoreApplication::quit);
2023-09-16 17:41:51 -04:00
engine.loadFromModule(QStringLiteral("zone.xiv.astra"), QStringLiteral("Main"));
if (engine.rootObjects().isEmpty()) {
return -1;
}
return QCoreApplication::exec();
}