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 <QAbstractListModel>
|
2023-09-16 18:01:02 -04:00
|
|
|
#include <QtQml/qqmlregistration.h>
|
2023-07-30 08:49:34 -04:00
|
|
|
|
|
|
|
#include "profile.h"
|
|
|
|
|
|
|
|
class ProfileManager : public QAbstractListModel
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
2023-09-16 18:01:02 -04:00
|
|
|
QML_ELEMENT
|
|
|
|
QML_UNCREATABLE("Use LauncherCore.profileManager")
|
2023-07-30 08:49:34 -04:00
|
|
|
|
2023-12-31 17:28:31 -05:00
|
|
|
Q_PROPERTY(int numProfiles READ numProfiles NOTIFY profilesChanged)
|
|
|
|
|
2023-07-30 08:49:34 -04:00
|
|
|
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-07-30 08:49:34 -04:00
|
|
|
|
2023-09-17 08:52:48 -04:00
|
|
|
[[nodiscard]] QVariant data(const QModelIndex &index, int role) const override;
|
2023-07-30 08:49:34 -04:00
|
|
|
|
2023-09-17 08:52:48 -04:00
|
|
|
[[nodiscard]] QHash<int, QByteArray> roleNames() const override;
|
2023-07-30 08:49:34 -04:00
|
|
|
|
|
|
|
Q_INVOKABLE Profile *getProfile(int index);
|
2023-09-17 19:20:41 -04:00
|
|
|
Profile *getProfileByUUID(const QString &uuid);
|
2023-07-30 08:49:34 -04:00
|
|
|
|
|
|
|
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;
|
2023-10-08 20:24:35 -04:00
|
|
|
[[nodiscard]] Q_INVOKABLE int numProfiles() const;
|
2023-07-30 08:49:34 -04:00
|
|
|
|
|
|
|
Q_INVOKABLE bool canDelete(Profile *account) const;
|
|
|
|
|
2023-12-17 10:27:07 -05:00
|
|
|
[[nodiscard]] Q_INVOKABLE bool hasAnyExistingInstallations() const;
|
2023-10-08 20:01:17 -04:00
|
|
|
|
2023-08-18 14:52:06 -04:00
|
|
|
static QString getDefaultGamePath(const QString &uuid);
|
2023-10-08 18:15:41 -04:00
|
|
|
static QString getDefaultWinePrefixPath(const QString &uuid);
|
2023-08-18 12:59:07 -04:00
|
|
|
|
2023-12-31 17:28:31 -05:00
|
|
|
Q_SIGNALS:
|
|
|
|
void profilesChanged();
|
|
|
|
|
2023-07-30 08:49:34 -04:00
|
|
|
private:
|
|
|
|
void insertProfile(Profile *profile);
|
|
|
|
|
2023-12-17 11:07:34 -05:00
|
|
|
QList<Profile *> m_profiles;
|
2023-07-30 08:49:34 -04:00
|
|
|
|
|
|
|
LauncherCore &m_launcher;
|
|
|
|
};
|