mirror of
https://github.com/redstrate/Astra.git
synced 2025-04-24 21:37:46 +00:00
Disable the account switcher when there's only one account
This commit is contained in:
parent
4abe56ea82
commit
5078da4e84
3 changed files with 9 additions and 0 deletions
|
@ -14,6 +14,8 @@ class AccountManager : public QAbstractListModel
|
|||
QML_ELEMENT
|
||||
QML_UNCREATABLE("Use LauncherCore.accountManager")
|
||||
|
||||
Q_PROPERTY(int numAccounts READ numAccounts NOTIFY accountsChanged)
|
||||
|
||||
public:
|
||||
explicit AccountManager(LauncherCore &launcher, QObject *parent = nullptr);
|
||||
|
||||
|
@ -40,6 +42,9 @@ public:
|
|||
Q_INVOKABLE [[nodiscard]] bool hasAnyAccounts() const;
|
||||
Q_INVOKABLE [[nodiscard]] int numAccounts() const;
|
||||
|
||||
Q_SIGNALS:
|
||||
void accountsChanged();
|
||||
|
||||
private:
|
||||
void insertAccount(Account *account);
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@ void AccountManager::load()
|
|||
|
||||
auto account = new Account(m_launcher, uuid, this);
|
||||
m_accounts.append(account);
|
||||
Q_EMIT accountsChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -105,6 +106,7 @@ void AccountManager::deleteAccount(Account *account)
|
|||
beginRemoveRows(QModelIndex(), row, row);
|
||||
m_accounts.removeAll(account);
|
||||
endRemoveRows();
|
||||
Q_EMIT accountsChanged();
|
||||
}
|
||||
|
||||
void AccountManager::insertAccount(Account *account)
|
||||
|
@ -112,6 +114,7 @@ void AccountManager::insertAccount(Account *account)
|
|||
beginInsertRows(QModelIndex(), static_cast<int>(m_accounts.size()), static_cast<int>(m_accounts.size()));
|
||||
m_accounts.append(account);
|
||||
endInsertRows();
|
||||
Q_EMIT accountsChanged();
|
||||
}
|
||||
|
||||
bool AccountManager::hasAnyAccounts() const
|
||||
|
|
|
@ -165,6 +165,7 @@ QQC2.Control {
|
|||
FormCard.FormButtonDelegate {
|
||||
id: currentAccountDelegate
|
||||
|
||||
enabled: LauncherCore.accountManager.numAccounts > 1
|
||||
text: LauncherCore.currentProfile.account.name
|
||||
|
||||
leading: Components.Avatar {
|
||||
|
|
Loading…
Add table
Reference in a new issue