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

Modernize ProfileManager

This commit is contained in:
Joshua Goins 2023-09-17 08:52:48 -04:00
parent 8d103c33d8
commit f990b9dd75
2 changed files with 10 additions and 10 deletions

View file

@ -23,11 +23,11 @@ public:
ProfileRole = Qt::UserRole,
};
int rowCount(const QModelIndex &index = QModelIndex()) const override;
[[nodiscard]] int rowCount(const QModelIndex &index) const override;
QVariant data(const QModelIndex &index, int role) const override;
[[nodiscard]] QVariant data(const QModelIndex &index, int role) const override;
QHash<int, QByteArray> roleNames() const override;
[[nodiscard]] QHash<int, QByteArray> roleNames() const override;
Q_INVOKABLE Profile *getProfile(int index);
@ -35,7 +35,7 @@ public:
Q_INVOKABLE Profile *addProfile();
Q_INVOKABLE void deleteProfile(Profile *profile);
QVector<Profile *> profiles() const;
[[nodiscard]] QVector<Profile *> profiles() const;
Q_INVOKABLE bool canDelete(Profile *account) const;

View file

@ -31,7 +31,7 @@ int ProfileManager::getProfileIndex(const QString &name)
Profile *ProfileManager::addProfile()
{
auto newProfile = new Profile(m_launcher, QUuid::createUuid().toString(), this);
newProfile->setName("New Profile");
newProfile->setName(QStringLiteral("New Profile"));
newProfile->readWineInfo();
@ -45,7 +45,7 @@ Profile *ProfileManager::addProfile()
void ProfileManager::deleteProfile(Profile *profile)
{
auto config = KSharedConfig::openStateConfig();
config->deleteGroup(QString("profile-%1").arg(profile->uuid()));
config->deleteGroup(QStringLiteral("profile-%1").arg(profile->uuid()));
config->sync();
const int row = m_profiles.indexOf(profile);
@ -61,7 +61,7 @@ QString ProfileManager::getDefaultWinePrefixPath()
#endif
#if defined(Q_OS_LINUX)
return QDir::homePath() + "/.wine";
return QDir::homePath() + QStringLiteral("/.wine");
#endif
return "";
@ -81,7 +81,7 @@ QString ProfileManager::getDefaultGamePath(const QString &uuid)
#if defined(Q_OS_LINUX)
const QDir appData = QStandardPaths::standardLocations(QStandardPaths::StandardLocation::AppDataLocation)[0];
const QDir gameDir = appData.absoluteFilePath("game");
const QDir gameDir = appData.absoluteFilePath(QStringLiteral("game"));
return gameDir.absoluteFilePath(uuid);
#endif
}
@ -90,8 +90,8 @@ void ProfileManager::load()
{
auto config = KSharedConfig::openStateConfig();
for (const auto &id : config->groupList()) {
if (id.contains("profile-")) {
auto profile = new Profile(m_launcher, QString(id).remove("profile-"), this);
if (id.contains(QLatin1String("profile-"))) {
auto profile = new Profile(m_launcher, QString(id).remove(QLatin1String("profile-")), this);
insertProfile(profile);
}
}