mirror of
https://github.com/redstrate/Astra.git
synced 2025-04-24 05:17:46 +00:00
Remove LauncherCore dependency injection in Account/AccountManager
This is no longer needed, and we will need this to test this model standalone.
This commit is contained in:
parent
a22ddd13b7
commit
51d9551667
5 changed files with 8 additions and 21 deletions
|
@ -3,15 +3,12 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <QDir>
|
||||
#include <QObject>
|
||||
#include <QtQml>
|
||||
#include <qcorotask.h>
|
||||
|
||||
#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;
|
||||
};
|
|
@ -3,8 +3,6 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <QAbstractListModel>
|
||||
|
||||
#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<Account *> m_accounts;
|
||||
|
||||
LauncherCore &m_launcher;
|
||||
};
|
|
@ -3,23 +3,19 @@
|
|||
|
||||
#include "account.h"
|
||||
|
||||
#include <QNetworkReply>
|
||||
#include <QNetworkRequest>
|
||||
#include <cotp.h>
|
||||
#include <qcorocore.h>
|
||||
#include <qt6keychain/keychain.h>
|
||||
|
||||
#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();
|
||||
}
|
||||
|
|
|
@ -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<int, QByteArray> 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<Account::GameLicense>(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);
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Add table
Reference in a new issue