1
Fork 0
mirror of https://github.com/redstrate/Astra.git synced 2025-04-20 11:47:46 +00:00
astra/launcher/include/accountmanager.h

54 lines
1.5 KiB
C
Raw Normal View History

// SPDX-FileCopyrightText: 2023 Joshua Goins <josh@redstrate.com>
// SPDX-License-Identifier: GPL-3.0-or-later
#pragma once
#include <QAbstractListModel>
2023-09-16 18:01:02 -04:00
#include <QtQml/qqmlregistration.h>
#include "account.h"
class AccountManager : public QAbstractListModel
{
Q_OBJECT
2023-09-16 18:01:02 -04:00
QML_ELEMENT
QML_UNCREATABLE("Use LauncherCore.accountManager")
Q_PROPERTY(int numAccounts READ numAccounts NOTIFY accountsChanged)
public:
explicit AccountManager(LauncherCore &launcher, QObject *parent = nullptr);
void load();
enum CustomRoles {
AccountRole = Qt::UserRole,
};
2023-09-16 21:23:58 -04:00
[[nodiscard]] int rowCount(const QModelIndex &index) const override;
2023-09-16 21:23:58 -04:00
[[nodiscard]] QVariant data(const QModelIndex &index, int role) const override;
2023-09-16 21:23:58 -04:00
[[nodiscard]] QHash<int, QByteArray> roleNames() const override;
Q_INVOKABLE Account *createSquareEnixAccount(const QString &username, int licenseType, bool isFreeTrial);
Q_INVOKABLE Account *createSapphireAccount(const QString &lobbyUrl, const QString &username);
2023-09-16 21:23:58 -04:00
[[nodiscard]] Account *getByUuid(const QString &uuid) const;
Q_INVOKABLE bool canDelete(Account *account) const;
Q_INVOKABLE void deleteAccount(Account *account);
Q_INVOKABLE [[nodiscard]] bool hasAnyAccounts() const;
Q_INVOKABLE [[nodiscard]] int numAccounts() const;
Q_SIGNALS:
void accountsChanged();
private:
void insertAccount(Account *account);
2023-12-17 11:07:34 -05:00
QList<Account *> m_accounts;
LauncherCore &m_launcher;
};