1
Fork 0
mirror of https://github.com/redstrate/Astra.git synced 2025-04-21 20:27:45 +00:00
astra/launcher/include/accountmanager.h
Joshua Goins 67dcd90058 Overhaul initial setup flow, again
This improves the flow drastically, first by porting it from MobileForm
to FormCard. Next, it fixes some of the annoying bugs such as the
profile not switching properly when adding a new profile. Selecting an
existing game path is now possible, and it's less likely you can enter
in invalid account credentials. The overall look and behavior of some
of the pages is improved.
2023-10-08 20:01:17 -04:00

48 lines
No EOL
1.3 KiB
C++

// SPDX-FileCopyrightText: 2023 Joshua Goins <josh@redstrate.com>
// SPDX-License-Identifier: GPL-3.0-or-later
#pragma once
#include <QAbstractListModel>
#include <QtQml/qqmlregistration.h>
#include "account.h"
class AccountManager : public QAbstractListModel
{
Q_OBJECT
QML_ELEMENT
QML_UNCREATABLE("Use LauncherCore.accountManager")
public:
explicit AccountManager(LauncherCore &launcher, QObject *parent = nullptr);
void load();
enum CustomRoles {
AccountRole = Qt::UserRole,
};
[[nodiscard]] int rowCount(const QModelIndex &index) const override;
[[nodiscard]] QVariant data(const QModelIndex &index, int role) const override;
[[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);
[[nodiscard]] Account *getByUuid(const QString &uuid) const;
Q_INVOKABLE bool canDelete(Account *account) const;
Q_INVOKABLE void deleteAccount(Account *account);
Q_INVOKABLE bool hasAnyAccounts() const;
private:
void insertAccount(Account *account);
QVector<Account *> m_accounts;
LauncherCore &m_launcher;
};