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
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "account.h"
|
|
|
|
|
|
|
|
class AccountManager : public QAbstractListModel
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
2023-09-16 18:01:02 -04:00
|
|
|
QML_ELEMENT
|
|
|
|
QML_UNCREATABLE("Use LauncherCore.accountManager")
|
2023-07-30 08:49:34 -04:00
|
|
|
|
2024-04-01 15:15:30 -04:00
|
|
|
Q_PROPERTY(int numAccounts READ numAccounts NOTIFY accountsChanged)
|
|
|
|
|
2023-07-30 08:49:34 -04:00
|
|
|
public:
|
2024-08-22 18:53:46 -04:00
|
|
|
explicit AccountManager(QObject *parent = nullptr);
|
2023-07-30 08:49:34 -04:00
|
|
|
|
|
|
|
void load();
|
|
|
|
|
|
|
|
enum CustomRoles {
|
|
|
|
AccountRole = Qt::UserRole,
|
|
|
|
};
|
|
|
|
|
2023-09-16 21:23:58 -04:00
|
|
|
[[nodiscard]] int rowCount(const QModelIndex &index) const override;
|
2023-07-30 08:49:34 -04:00
|
|
|
|
2023-09-16 21:23:58 -04:00
|
|
|
[[nodiscard]] QVariant data(const QModelIndex &index, int role) const override;
|
2023-07-30 08:49:34 -04:00
|
|
|
|
2023-09-16 21:23:58 -04:00
|
|
|
[[nodiscard]] QHash<int, QByteArray> roleNames() const override;
|
2023-07-30 08:49:34 -04:00
|
|
|
|
|
|
|
Q_INVOKABLE Account *createSquareEnixAccount(const QString &username, int licenseType, bool isFreeTrial);
|
|
|
|
|
2023-09-16 21:23:58 -04:00
|
|
|
[[nodiscard]] Account *getByUuid(const QString &uuid) const;
|
2023-07-30 08:49:34 -04:00
|
|
|
|
2024-07-04 20:53:06 -04:00
|
|
|
Q_INVOKABLE bool canDelete(const Account *account) const;
|
2023-07-30 08:49:34 -04:00
|
|
|
Q_INVOKABLE void deleteAccount(Account *account);
|
|
|
|
|
2023-10-08 20:24:35 -04:00
|
|
|
Q_INVOKABLE [[nodiscard]] bool hasAnyAccounts() const;
|
|
|
|
Q_INVOKABLE [[nodiscard]] int numAccounts() const;
|
2023-10-08 20:01:17 -04:00
|
|
|
|
2024-04-01 15:15:30 -04:00
|
|
|
Q_SIGNALS:
|
|
|
|
void accountsChanged();
|
2024-08-22 18:46:45 -04:00
|
|
|
void accountAdded(Account *account);
|
|
|
|
void accountLodestoneIdChanged(Account *account);
|
2024-04-01 15:15:30 -04:00
|
|
|
|
2023-07-30 08:49:34 -04:00
|
|
|
private:
|
|
|
|
void insertAccount(Account *account);
|
|
|
|
|
2023-12-17 11:07:34 -05:00
|
|
|
QList<Account *> m_accounts;
|
2025-03-17 19:40:27 -04:00
|
|
|
};
|