mirror of
https://github.com/redstrate/Astra.git
synced 2025-04-21 20:27:45 +00:00
Modernize AccountManager
This commit is contained in:
parent
83bed335db
commit
3a471553ab
2 changed files with 8 additions and 8 deletions
|
@ -23,16 +23,16 @@ public:
|
|||
AccountRole = 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 Account *createSquareEnixAccount(const QString &username, int licenseType, bool isFreeTrial);
|
||||
Q_INVOKABLE Account *createSapphireAccount(const QString &lobbyUrl, const QString &username);
|
||||
|
||||
Account *getByUuid(const QString &uuid) const;
|
||||
[[nodiscard]] Account *getByUuid(const QString &uuid) const;
|
||||
|
||||
Q_INVOKABLE bool canDelete(Account *account) const;
|
||||
Q_INVOKABLE void deleteAccount(Account *account);
|
||||
|
|
|
@ -15,8 +15,8 @@ void AccountManager::load()
|
|||
{
|
||||
auto config = KSharedConfig::openStateConfig();
|
||||
for (const auto &id : config->groupList()) {
|
||||
if (id.contains("account-")) {
|
||||
auto account = new Account(m_launcher, QString(id).remove("account-"), this);
|
||||
if (id.contains(QLatin1String("account-"))) {
|
||||
auto account = new Account(m_launcher, QString(id).remove(QLatin1String("account-")), this);
|
||||
m_accounts.append(account);
|
||||
}
|
||||
}
|
||||
|
@ -74,7 +74,7 @@ Account *AccountManager::createSapphireAccount(const QString &lobbyUrl, const QS
|
|||
|
||||
Account *AccountManager::getByUuid(const QString &uuid) const
|
||||
{
|
||||
for (auto &account : m_accounts) {
|
||||
for (const auto &account : m_accounts) {
|
||||
if (account->uuid() == uuid) {
|
||||
return account;
|
||||
}
|
||||
|
@ -92,7 +92,7 @@ bool AccountManager::canDelete(Account *account) const
|
|||
void AccountManager::deleteAccount(Account *account)
|
||||
{
|
||||
auto config = KSharedConfig::openStateConfig();
|
||||
config->deleteGroup(QString("account-%1").arg(account->uuid()));
|
||||
config->deleteGroup(QStringLiteral("account-%1").arg(account->uuid()));
|
||||
config->sync();
|
||||
|
||||
const int row = m_accounts.indexOf(account);
|
||||
|
|
Loading…
Add table
Reference in a new issue