UI Improvement: Display account type (#33)

* Add account type column in accounts page

* Show account type in account chooser

* Allow set skin and delete skin only on mojang accounts

* Rename Offline mode to Local
This commit is contained in:
Max
2021-06-11 22:18:35 +03:00
committed by GitHub
parent 915a85f00f
commit 576d78fb7f
7 changed files with 41 additions and 13 deletions

View File

@@ -194,6 +194,18 @@ QString MojangAccount::authEndpoint() const
return BuildConfig.AUTH_BASE_MOJANG;
}
QString MojangAccount::displayLoginType() const
{
if(m_loginType == "mojang")
return "Mojang";
if(m_loginType == "dummy")
return "Local";
if(m_loginType == "elyby")
return "Ely.by";
return "Unknown";
}
std::shared_ptr<YggdrasilTask> MojangAccount::login(AuthSessionPtr session, QString password)
{
Q_ASSERT(m_currentTask.get() == nullptr);

View File

@@ -141,8 +141,12 @@ public: /* queries */
//! Returns whether the account is NotVerified, Verified or Online
AccountStatus accountStatus() const;
//! Returns endpoint for authentication
QString authEndpoint() const;
// ! Returns login type to display in account list or account chooser
QString displayLoginType() const;
signals:
/**
* This signal is emitted when the account changes

View File

@@ -194,6 +194,9 @@ QVariant MojangAccountList::data(const QModelIndex &index, int role) const
case NameColumn:
return account->username();
case TypeColumn:
return account->displayLoginType();
default:
return QVariant();
}
@@ -229,6 +232,9 @@ QVariant MojangAccountList::headerData(int section, Qt::Orientation orientation,
case NameColumn:
return tr("Name");
case TypeColumn:
return tr("Account type");
default:
return QVariant();
}
@@ -256,7 +262,7 @@ int MojangAccountList::rowCount(const QModelIndex &) const
int MojangAccountList::columnCount(const QModelIndex &) const
{
return 2;
return 3;
}
Qt::ItemFlags MojangAccountList::flags(const QModelIndex &index) const

View File

@@ -51,6 +51,9 @@ public:
// Second column - Name
NameColumn,
// Third column - account type
TypeColumn,
};
explicit MojangAccountList(QObject *parent = 0);