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

60 lines
1.6 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 "profile.h"
class ProfileManager : public QAbstractListModel
{
Q_OBJECT
2023-09-16 18:01:02 -04:00
QML_ELEMENT
QML_UNCREATABLE("Use LauncherCore.profileManager")
Q_PROPERTY(int numProfiles READ numProfiles NOTIFY profilesChanged)
public:
explicit ProfileManager(LauncherCore &launcher, QObject *parent = nullptr);
void load();
enum CustomRoles {
ProfileRole = Qt::UserRole,
};
2023-09-17 08:52:48 -04:00
[[nodiscard]] int rowCount(const QModelIndex &index) const override;
2023-09-17 08:52:48 -04:00
[[nodiscard]] QVariant data(const QModelIndex &index, int role) const override;
2023-09-17 08:52:48 -04:00
[[nodiscard]] QHash<int, QByteArray> roleNames() const override;
Q_INVOKABLE Profile *getProfile(int index);
2023-09-17 19:20:41 -04:00
Profile *getProfileByUUID(const QString &uuid);
int getProfileIndex(const QString &name);
Q_INVOKABLE Profile *addProfile();
Q_INVOKABLE void deleteProfile(Profile *profile);
2023-12-17 11:07:34 -05:00
[[nodiscard]] QList<Profile *> profiles() const;
[[nodiscard]] Q_INVOKABLE int numProfiles() const;
Q_INVOKABLE bool canDelete(Profile *account) const;
[[nodiscard]] Q_INVOKABLE bool hasAnyExistingInstallations() const;
static QString getDefaultGamePath(const QString &uuid);
static QString getDefaultWinePrefixPath(const QString &uuid);
Q_SIGNALS:
void profilesChanged();
private:
void insertProfile(Profile *profile);
2023-12-17 11:07:34 -05:00
QList<Profile *> m_profiles;
LauncherCore &m_launcher;
};