mirror of
https://github.com/PrismLauncher/PrismLauncher
synced 2026-04-23 09:05:03 +00:00
Add icons to account list
Signed-off-by: TheKodeToad <TheKodeToad@proton.me>
This commit is contained in:
parent
639268798b
commit
fc1e29111b
|
|
@ -295,6 +295,24 @@ QVariant AccountList::data(const QModelIndex& index, int role) const
|
|||
MinecraftAccountPtr account = at(index.row());
|
||||
|
||||
switch (role) {
|
||||
case Qt::SizeHintRole:
|
||||
if (index.column() == ProfileNameColumn) {
|
||||
return QSize(0, 30);
|
||||
}
|
||||
|
||||
return QVariant();
|
||||
case Qt::DecorationRole:
|
||||
if (index.column() == ProfileNameColumn) {
|
||||
auto face = account->getFace(24, 24);
|
||||
|
||||
if (!face.isNull()) {
|
||||
return face;
|
||||
} else {
|
||||
return QIcon::fromTheme("noaccount").pixmap(24, 24);
|
||||
}
|
||||
}
|
||||
|
||||
return QVariant();
|
||||
case Qt::DisplayRole:
|
||||
switch (index.column()) {
|
||||
case ProfileNameColumn:
|
||||
|
|
|
|||
|
|
@ -101,7 +101,7 @@ AccountState MinecraftAccount::accountState() const
|
|||
return data.accountState;
|
||||
}
|
||||
|
||||
QPixmap MinecraftAccount::getFace() const
|
||||
QPixmap MinecraftAccount::getFace(int width, int height) const
|
||||
{
|
||||
QPixmap skinTexture;
|
||||
if (!skinTexture.loadFromData(data.minecraftProfile.skin.data, "PNG")) {
|
||||
|
|
@ -112,7 +112,7 @@ QPixmap MinecraftAccount::getFace() const
|
|||
QPainter painter(&skin);
|
||||
painter.drawPixmap(0, 0, skinTexture.copy(8, 8, 8, 8));
|
||||
painter.drawPixmap(0, 0, skinTexture.copy(40, 8, 8, 8));
|
||||
return skin.scaled(64, 64, Qt::KeepAspectRatio);
|
||||
return skin.scaled(width, height, Qt::KeepAspectRatio);
|
||||
}
|
||||
|
||||
shared_qobject_ptr<AuthFlow> MinecraftAccount::login(bool useDeviceCode)
|
||||
|
|
|
|||
|
|
@ -135,7 +135,7 @@ class MinecraftAccount : public QObject, public Usable {
|
|||
}
|
||||
}
|
||||
|
||||
QPixmap getFace() const;
|
||||
QPixmap getFace(int width = 64, int height = 64) const;
|
||||
|
||||
//! Returns the current state of the account
|
||||
AccountState accountState() const;
|
||||
|
|
|
|||
Loading…
Reference in a new issue