2023-08-05 22:14:05 -04:00
|
|
|
// SPDX-FileCopyrightText: 2023 Joshua Goins <josh@redstrate.com>
|
|
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
2023-07-30 08:49:34 -04:00
|
|
|
#include <KAboutData>
|
|
|
|
#include <KLocalizedContext>
|
|
|
|
#include <KLocalizedString>
|
|
|
|
#include <QApplication>
|
|
|
|
#include <QCommandLineParser>
|
|
|
|
#include <QQuickStyle>
|
2023-09-16 17:32:38 -04:00
|
|
|
#include <QtWebView>
|
2023-07-30 08:49:34 -04:00
|
|
|
|
2023-07-30 10:33:07 -04:00
|
|
|
#include "astra-version.h"
|
2023-08-18 23:27:29 -04:00
|
|
|
#include "compatibilitytoolinstaller.h"
|
2023-07-30 08:49:34 -04:00
|
|
|
#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
|
|
|
|
2023-07-30 08:49:34 -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");
|
|
|
|
|
2023-07-30 10:33:07 -04:00
|
|
|
KAboutData about(QStringLiteral("astra"),
|
|
|
|
i18n("Astra"),
|
|
|
|
QStringLiteral(ASTRA_VERSION_STRING),
|
|
|
|
i18n("FFXIV Launcher"),
|
|
|
|
KAboutLicense::GPL_V3,
|
|
|
|
i18n("© 2023 Joshua Goins"));
|
2023-08-02 19:44:02 -04:00
|
|
|
about.addAuthor(i18n("Joshua Goins"), i18n("Maintainer"), QStringLiteral("josh@redstrate.com"), QStringLiteral("https://redstrate.com/"));
|
2023-07-30 08:49:34 -04:00
|
|
|
about.setHomepage("https://xiv.zone/astra");
|
2023-07-30 10:33:07 -04:00
|
|
|
about.addComponent("physis", "Library to access FFXIV data", physis_get_physis_version(), "https://xiv.zone/physis", KAboutLicense::GPL_V3);
|
|
|
|
about.addComponent("libphysis", "C bindings for physis", physis_get_libphysis_version(), "", KAboutLicense::GPL_V3);
|
2023-08-06 11:52:35 -04:00
|
|
|
about.setDesktopFileName("zone.xiv.astra");
|
2023-07-30 09:51:34 -04:00
|
|
|
about.setBugAddress("https://lists.sr.ht/~redstrate/public-inbox");
|
2023-07-30 10:11:24 -04:00
|
|
|
about.setComponentName("astra");
|
2023-08-06 11:52:35 -04:00
|
|
|
about.setProgramLogo("zone.xiv.astra");
|
2023-07-30 08:49:34 -04:00
|
|
|
|
|
|
|
KAboutData::setApplicationData(about);
|
|
|
|
|
|
|
|
QCommandLineParser parser;
|
|
|
|
parser.setApplicationDescription(i18n("Linux FFXIV Launcher"));
|
|
|
|
|
|
|
|
#ifdef ENABLE_STEAM
|
|
|
|
QCommandLineOption steamOption("steam", "Used for booting the launcher from Steam.", "verb");
|
|
|
|
steamOption.setFlags(QCommandLineOption::HiddenFromHelp);
|
|
|
|
parser.addOption(steamOption);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
about.setupCommandLine(&parser);
|
|
|
|
parser.parse(QCoreApplication::arguments());
|
|
|
|
about.processCommandLine(&parser);
|
|
|
|
|
|
|
|
#ifdef ENABLE_STEAM
|
|
|
|
if (parser.isSet(steamOption)) {
|
|
|
|
const QStringList args = parser.positionalArguments();
|
|
|
|
// Steam tries to use as a compatibiltiy tool, running install scripts (like DirectX), so try to ignore it.
|
|
|
|
if (!args[0].contains("ffxivboot.exe")) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
LauncherCore c(parser.isSet(steamOption));
|
|
|
|
#else
|
|
|
|
LauncherCore c(false);
|
|
|
|
#endif
|
|
|
|
|
2023-08-06 11:52:35 -04:00
|
|
|
qmlRegisterSingletonInstance("zone.xiv.astra", 1, 0, "LauncherCore", &c);
|
|
|
|
qmlRegisterUncreatableType<GameInstaller>("zone.xiv.astra", 1, 0, "GameInstaller", QStringLiteral("Use LauncherCore::createInstaller"));
|
2023-08-18 23:27:29 -04:00
|
|
|
qmlRegisterUncreatableType<CompatibilityToolInstaller>("zone.xiv.astra",
|
|
|
|
1,
|
|
|
|
0,
|
|
|
|
"CompatibilityToolInstaller",
|
|
|
|
QStringLiteral("Use LauncherCore::createCompatInstaller"));
|
2023-08-06 11:52:35 -04:00
|
|
|
qmlRegisterUncreatableType<AccountManager>("zone.xiv.astra", 1, 0, "AccountManager", QStringLiteral("Use LauncherCore::accountManager"));
|
|
|
|
qmlRegisterUncreatableType<ProfileManager>("zone.xiv.astra", 1, 0, "ProfileManager", QStringLiteral("Use LauncherCore::profileManager"));
|
|
|
|
qmlRegisterUncreatableType<Profile>("zone.xiv.astra", 1, 0, "Profile", QStringLiteral("Use from ProfileManager"));
|
|
|
|
qmlRegisterUncreatableType<Account>("zone.xiv.astra", 1, 0, "Account", QStringLiteral("Use from AccountManager"));
|
|
|
|
qmlRegisterSingletonType("zone.xiv.astra", 1, 0, "About", [](QQmlEngine *engine, QJSEngine *) -> QJSValue {
|
2023-07-30 08:49:34 -04:00
|
|
|
return engine->toScriptValue(KAboutData::applicationData());
|
|
|
|
});
|
2023-08-06 11:52:35 -04:00
|
|
|
qmlRegisterUncreatableType<Headline>("zone.xiv.astra", 1, 0, "Headline", QStringLiteral("Use from AccountManager"));
|
2023-07-30 08:49:34 -04:00
|
|
|
qRegisterMetaType<Banner>("Banner");
|
|
|
|
qRegisterMetaType<QList<Banner>>("QList<Banner>");
|
|
|
|
qRegisterMetaType<QList<News>>("QList<News>");
|
|
|
|
|
|
|
|
QQmlApplicationEngine engine;
|
|
|
|
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"));
|
2023-07-30 08:49:34 -04:00
|
|
|
if (engine.rootObjects().isEmpty()) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return QCoreApplication::exec();
|
|
|
|
}
|