From f6ddc0193e78bbe3993c3e77a3120a45d07eeaab Mon Sep 17 00:00:00 2001 From: Joshua Goins Date: Sun, 31 Dec 2023 17:28:31 -0500 Subject: [PATCH] Hide change profile button if only one profile is used --- launcher/include/profilemanager.h | 5 +++++ launcher/src/profilemanager.cpp | 2 ++ launcher/ui/Pages/LoginPage.qml | 1 + 3 files changed, 8 insertions(+) diff --git a/launcher/include/profilemanager.h b/launcher/include/profilemanager.h index c59dd96..c36e604 100644 --- a/launcher/include/profilemanager.h +++ b/launcher/include/profilemanager.h @@ -14,6 +14,8 @@ class ProfileManager : public QAbstractListModel QML_ELEMENT QML_UNCREATABLE("Use LauncherCore.profileManager") + Q_PROPERTY(int numProfiles READ numProfiles NOTIFY profilesChanged) + public: explicit ProfileManager(LauncherCore &launcher, QObject *parent = nullptr); @@ -46,6 +48,9 @@ public: static QString getDefaultGamePath(const QString &uuid); static QString getDefaultWinePrefixPath(const QString &uuid); +Q_SIGNALS: + void profilesChanged(); + private: void insertProfile(Profile *profile); diff --git a/launcher/src/profilemanager.cpp b/launcher/src/profilemanager.cpp index 394c477..3b0ebab 100644 --- a/launcher/src/profilemanager.cpp +++ b/launcher/src/profilemanager.cpp @@ -61,6 +61,7 @@ void ProfileManager::deleteProfile(Profile *profile) beginRemoveRows(QModelIndex(), row, row); m_profiles.removeAll(profile); endRemoveRows(); + Q_EMIT profilesChanged(); } QString ProfileManager::getDefaultGamePath(const QString &uuid) @@ -137,6 +138,7 @@ void ProfileManager::insertProfile(Profile *profile) beginInsertRows(QModelIndex(), static_cast(m_profiles.size()), static_cast(m_profiles.size())); m_profiles.append(profile); endInsertRows(); + Q_EMIT profilesChanged(); } QList ProfileManager::profiles() const diff --git a/launcher/ui/Pages/LoginPage.qml b/launcher/ui/Pages/LoginPage.qml index 75a7830..d29bbf0 100644 --- a/launcher/ui/Pages/LoginPage.qml +++ b/launcher/ui/Pages/LoginPage.qml @@ -105,6 +105,7 @@ QQC2.Control { FormCard.FormCard { maximumWidth: Kirigami.Units.gridUnit * 25 + visible: LauncherCore.profileManager.numProfiles > 1 Layout.fillWidth: true