1
Fork 0
mirror of https://github.com/redstrate/Astra.git synced 2025-04-23 12:57:45 +00:00
astra/launcher/include/profilemanager.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

54 lines
No EOL
1.4 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 "profile.h"
class ProfileManager : public QAbstractListModel
{
Q_OBJECT
QML_ELEMENT
QML_UNCREATABLE("Use LauncherCore.profileManager")
public:
explicit ProfileManager(LauncherCore &launcher, QObject *parent = nullptr);
void load();
enum CustomRoles {
ProfileRole = 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 Profile *getProfile(int index);
Profile *getProfileByUUID(const QString &uuid);
int getProfileIndex(const QString &name);
Q_INVOKABLE Profile *addProfile();
Q_INVOKABLE void deleteProfile(Profile *profile);
[[nodiscard]] QVector<Profile *> profiles() const;
Q_INVOKABLE bool canDelete(Profile *account) const;
Q_INVOKABLE bool hasAnyExistingInstallations() const;
static QString getDefaultGamePath(const QString &uuid);
static QString getDefaultWinePrefixPath(const QString &uuid);
private:
void insertProfile(Profile *profile);
QVector<Profile *> m_profiles;
LauncherCore &m_launcher;
};