From 51d95516679de4afdee144866e1c1a5c07897fc5 Mon Sep 17 00:00:00 2001 From: Joshua Goins Date: Thu, 22 Aug 2024 18:53:46 -0400 Subject: [PATCH] Remove LauncherCore dependency injection in Account/AccountManager This is no longer needed, and we will need this to test this model standalone. --- launcher/include/account.h | 6 +----- launcher/include/accountmanager.h | 6 +----- launcher/src/account.cpp | 6 +----- launcher/src/accountmanager.cpp | 9 ++++----- launcher/src/launchercore.cpp | 2 +- 5 files changed, 8 insertions(+), 21 deletions(-) diff --git a/launcher/include/account.h b/launcher/include/account.h index 3ba0717..ac06745 100644 --- a/launcher/include/account.h +++ b/launcher/include/account.h @@ -3,15 +3,12 @@ #pragma once -#include #include #include #include #include "accountconfig.h" -class LauncherCore; - class Account : public QObject { Q_OBJECT @@ -32,7 +29,7 @@ class Account : public QObject Q_PROPERTY(bool needsPassword READ needsPassword NOTIFY needsPasswordChanged) public: - explicit Account(LauncherCore &launcher, const QString &key, QObject *parent = nullptr); + explicit Account(const QString &key, QObject *parent = nullptr); enum class GameLicense { WindowsStandalone, WindowsSteam, macOS }; Q_ENUM(GameLicense) @@ -115,6 +112,5 @@ private: AccountConfig m_config; QString m_key; QString m_avatarUrl; - LauncherCore &m_launcher; bool m_needsPassword = false; }; \ No newline at end of file diff --git a/launcher/include/accountmanager.h b/launcher/include/accountmanager.h index 8e374fe..3603a2f 100644 --- a/launcher/include/accountmanager.h +++ b/launcher/include/accountmanager.h @@ -3,8 +3,6 @@ #pragma once -#include - #include "account.h" class AccountManager : public QAbstractListModel @@ -16,7 +14,7 @@ class AccountManager : public QAbstractListModel Q_PROPERTY(int numAccounts READ numAccounts NOTIFY accountsChanged) public: - explicit AccountManager(LauncherCore &launcher, QObject *parent = nullptr); + explicit AccountManager(QObject *parent = nullptr); void load(); @@ -50,6 +48,4 @@ private: void insertAccount(Account *account); QList m_accounts; - - LauncherCore &m_launcher; }; \ No newline at end of file diff --git a/launcher/src/account.cpp b/launcher/src/account.cpp index caaa97e..812793c 100644 --- a/launcher/src/account.cpp +++ b/launcher/src/account.cpp @@ -3,23 +3,19 @@ #include "account.h" -#include -#include #include #include #include #include "astra_log.h" -#include "launchercore.h" #include "utility.h" using namespace Qt::StringLiterals; -Account::Account(LauncherCore &launcher, const QString &key, QObject *parent) +Account::Account(const QString &key, QObject *parent) : QObject(parent) , m_config(key) , m_key(key) - , m_launcher(launcher) { fetchPassword(); } diff --git a/launcher/src/accountmanager.cpp b/launcher/src/accountmanager.cpp index aa896a6..b431ee0 100644 --- a/launcher/src/accountmanager.cpp +++ b/launcher/src/accountmanager.cpp @@ -8,9 +8,8 @@ using namespace Qt::StringLiterals; -AccountManager::AccountManager(LauncherCore &launcher, QObject *parent) +AccountManager::AccountManager(QObject *parent) : QAbstractListModel(parent) - , m_launcher(launcher) { } @@ -22,7 +21,7 @@ void AccountManager::load() const QString uuid = QString(id).remove("account-"_L1); qInfo(ASTRA_LOG) << "Loading account" << uuid; - const auto account = new Account(m_launcher, uuid, this); + const auto account = new Account(uuid, this); m_accounts.append(account); Q_EMIT accountsChanged(); } @@ -56,7 +55,7 @@ QHash AccountManager::roleNames() const Account *AccountManager::createSquareEnixAccount(const QString &username, const int licenseType, const bool isFreeTrial) { - const auto account = new Account(m_launcher, QUuid::createUuid().toString(), this); + const auto account = new Account(QUuid::createUuid().toString(), this); account->setIsSapphire(false); account->setLicense(static_cast(licenseType)); account->setIsFreeTrial(isFreeTrial); @@ -69,7 +68,7 @@ Account *AccountManager::createSquareEnixAccount(const QString &username, const Account *AccountManager::createSapphireAccount(const QString &lobbyUrl, const QString &username) { - const auto account = new Account(m_launcher, QUuid::createUuid().toString(), this); + const auto account = new Account(QUuid::createUuid().toString(), this); account->setIsSapphire(true); account->setName(username); account->setLobbyUrl(lobbyUrl); diff --git a/launcher/src/launchercore.cpp b/launcher/src/launchercore.cpp index a70960a..5aa861b 100755 --- a/launcher/src/launchercore.cpp +++ b/launcher/src/launchercore.cpp @@ -37,7 +37,7 @@ LauncherCore::LauncherCore() m_sapphireLogin = new SapphireLogin(*this, this); m_squareEnixLogin = new SquareEnixLogin(*this, this); m_profileManager = new ProfileManager(this); - m_accountManager = new AccountManager(*this, this); + m_accountManager = new AccountManager(this); m_runner = new GameRunner(*this, this); connect(m_accountManager, &AccountManager::accountAdded, this, &LauncherCore::fetchAvatar);