diff --git a/launcher/include/account.h b/launcher/include/account.h index 9d6438e..af20d99 100644 --- a/launcher/include/account.h +++ b/launcher/include/account.h @@ -5,6 +5,7 @@ #include #include +#include #include "accountconfig.h" @@ -13,6 +14,8 @@ class LauncherCore; class Account : public QObject { Q_OBJECT + QML_ELEMENT + QML_UNCREATABLE("Use from AccountManager") Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) Q_PROPERTY(int language READ language WRITE setLanguage NOTIFY languageChanged) diff --git a/launcher/include/accountmanager.h b/launcher/include/accountmanager.h index 3fe4f21..ab159ab 100644 --- a/launcher/include/accountmanager.h +++ b/launcher/include/accountmanager.h @@ -4,12 +4,15 @@ #pragma once #include +#include #include "account.h" class AccountManager : public QAbstractListModel { Q_OBJECT + QML_ELEMENT + QML_UNCREATABLE("Use LauncherCore.accountManager") public: explicit AccountManager(LauncherCore &launcher, QObject *parent = nullptr); diff --git a/launcher/include/compatibilitytoolinstaller.h b/launcher/include/compatibilitytoolinstaller.h index e44239a..cfc083a 100644 --- a/launcher/include/compatibilitytoolinstaller.h +++ b/launcher/include/compatibilitytoolinstaller.h @@ -5,12 +5,16 @@ #include #include +#include class LauncherCore; class CompatibilityToolInstaller : public QObject { Q_OBJECT + QML_ELEMENT + QML_UNCREATABLE("Use LauncherCore.createCompatInstaller") + public: CompatibilityToolInstaller(LauncherCore &launcher, QObject *parent = nullptr); diff --git a/launcher/include/gameinstaller.h b/launcher/include/gameinstaller.h index 2ec9cef..8adeb8a 100644 --- a/launcher/include/gameinstaller.h +++ b/launcher/include/gameinstaller.h @@ -5,6 +5,7 @@ #include #include +#include class LauncherCore; class Profile; @@ -12,6 +13,9 @@ class Profile; class GameInstaller : public QObject { Q_OBJECT + QML_ELEMENT + QML_UNCREATABLE("Use Launchercore.createInstaller") + public: GameInstaller(LauncherCore &launcher, Profile &profile, QObject *parent = nullptr); diff --git a/launcher/include/launchercore.h b/launcher/include/launchercore.h index fa0f87c..027138c 100755 --- a/launcher/include/launchercore.h +++ b/launcher/include/launchercore.h @@ -54,6 +54,8 @@ struct LoginAuth { class LauncherCore : public QObject { Q_OBJECT + QML_ELEMENT + QML_SINGLETON Q_PROPERTY(bool loadingFinished READ isLoadingFinished NOTIFY loadingFinished) Q_PROPERTY(bool hasAccount READ hasAccount NOTIFY accountChanged) @@ -72,13 +74,15 @@ class LauncherCore : public QObject Q_PROPERTY(Headline *headline READ headline NOTIFY newsChanged) public: - explicit LauncherCore(bool isSteam); + LauncherCore(); QNetworkAccessManager *mgr; ProfileManager *profileManager(); AccountManager *accountManager(); + void setIsSteam(bool isSteam); + /* * Begins the login process, and may call SquareBoot or SapphireLauncher depending on the profile type. * It's designed to be opaque as possible to the caller. diff --git a/launcher/include/profile.h b/launcher/include/profile.h index 0625829..2bf2858 100644 --- a/launcher/include/profile.h +++ b/launcher/include/profile.h @@ -4,6 +4,7 @@ #pragma once #include +#include #include "squareboot.h" @@ -13,6 +14,8 @@ class ProfileConfig; class Profile : public QObject { Q_OBJECT + QML_ELEMENT + QML_UNCREATABLE("Use from ProfileManager") Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) Q_PROPERTY(QString gamePath READ gamePath WRITE setGamePath NOTIFY gamePathChanged) diff --git a/launcher/include/profilemanager.h b/launcher/include/profilemanager.h index 98654e2..9bd15a7 100644 --- a/launcher/include/profilemanager.h +++ b/launcher/include/profilemanager.h @@ -4,12 +4,15 @@ #pragma once #include +#include #include "profile.h" class ProfileManager : public QAbstractListModel { Q_OBJECT + QML_ELEMENT + QML_UNCREATABLE("Use LauncherCore.profileManager") public: explicit ProfileManager(LauncherCore &launcher, QObject *parent = nullptr); diff --git a/launcher/src/launchercore.cpp b/launcher/src/launchercore.cpp index b961e8c..56da83a 100755 --- a/launcher/src/launchercore.cpp +++ b/launcher/src/launchercore.cpp @@ -371,8 +371,7 @@ void LauncherCore::readInitialInformation() Q_EMIT loadingFinished(); } -LauncherCore::LauncherCore(bool isSteam) - : m_isSteam(isSteam) +LauncherCore::LauncherCore() { mgr = new QNetworkAccessManager(this); sapphireLauncher = new SapphireLauncher(*this, this); @@ -704,3 +703,8 @@ bool LauncherCore::isSteamDeck() const { return steamApi->isDeck(); } + +void LauncherCore::setIsSteam(bool isSteam) +{ + m_isSteam = isSteam; +} diff --git a/launcher/src/main.cpp b/launcher/src/main.cpp index abd2338..6a29dba 100755 --- a/launcher/src/main.cpp +++ b/launcher/src/main.cpp @@ -65,32 +65,13 @@ int main(int argc, char *argv[]) return 0; } } - - LauncherCore c(parser.isSet(steamOption)); -#else - LauncherCore c(false); #endif - qmlRegisterSingletonInstance("zone.xiv.astra", 1, 0, "LauncherCore", &c); - qmlRegisterUncreatableType("zone.xiv.astra", 1, 0, "GameInstaller", QStringLiteral("Use LauncherCore::createInstaller")); - qmlRegisterUncreatableType("zone.xiv.astra", - 1, - 0, - "CompatibilityToolInstaller", - QStringLiteral("Use LauncherCore::createCompatInstaller")); - qmlRegisterUncreatableType("zone.xiv.astra", 1, 0, "AccountManager", QStringLiteral("Use LauncherCore::accountManager")); - qmlRegisterUncreatableType("zone.xiv.astra", 1, 0, "ProfileManager", QStringLiteral("Use LauncherCore::profileManager")); - qmlRegisterUncreatableType("zone.xiv.astra", 1, 0, "Profile", QStringLiteral("Use from ProfileManager")); - qmlRegisterUncreatableType("zone.xiv.astra", 1, 0, "Account", QStringLiteral("Use from AccountManager")); - qmlRegisterSingletonType("zone.xiv.astra", 1, 0, "About", [](QQmlEngine *engine, QJSEngine *) -> QJSValue { - return engine->toScriptValue(KAboutData::applicationData()); - }); - qmlRegisterUncreatableType("zone.xiv.astra", 1, 0, "Headline", QStringLiteral("Use from AccountManager")); - qRegisterMetaType("Banner"); - qRegisterMetaType>("QList"); - qRegisterMetaType>("QList"); - QQmlApplicationEngine engine; + + auto core = engine.singletonInstance("zone.xiv.astra", "LauncherCore"); + core->setIsSteam(parser.isSet(steamOption)); + engine.rootContext()->setContextObject(new KLocalizedContext(&engine)); QObject::connect(&engine, &QQmlApplicationEngine::quit, &app, &QCoreApplication::quit);