From fc1e29111bff46ebe9c12277d4edadf7f5f29d8a Mon Sep 17 00:00:00 2001 From: TheKodeToad Date: Tue, 6 Jan 2026 21:53:28 +0000 Subject: [PATCH 1/2] Add icons to account list Signed-off-by: TheKodeToad --- launcher/minecraft/auth/AccountList.cpp | 18 ++++++++++++++++++ launcher/minecraft/auth/MinecraftAccount.cpp | 4 ++-- launcher/minecraft/auth/MinecraftAccount.h | 2 +- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/launcher/minecraft/auth/AccountList.cpp b/launcher/minecraft/auth/AccountList.cpp index cef79d200..2c8f9e5ec 100644 --- a/launcher/minecraft/auth/AccountList.cpp +++ b/launcher/minecraft/auth/AccountList.cpp @@ -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: diff --git a/launcher/minecraft/auth/MinecraftAccount.cpp b/launcher/minecraft/auth/MinecraftAccount.cpp index ca052c378..3a7de8a19 100644 --- a/launcher/minecraft/auth/MinecraftAccount.cpp +++ b/launcher/minecraft/auth/MinecraftAccount.cpp @@ -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 MinecraftAccount::login(bool useDeviceCode) diff --git a/launcher/minecraft/auth/MinecraftAccount.h b/launcher/minecraft/auth/MinecraftAccount.h index a82d3f134..95f76ec9a 100644 --- a/launcher/minecraft/auth/MinecraftAccount.h +++ b/launcher/minecraft/auth/MinecraftAccount.h @@ -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; From 9be292b845bb62ed879f5067cf86f20749d00fc0 Mon Sep 17 00:00:00 2001 From: TheKodeToad Date: Wed, 7 Jan 2026 00:22:27 +0000 Subject: [PATCH 2/2] Use AccountList as model in ProfileSelectDialog Signed-off-by: TheKodeToad --- launcher/ui/dialogs/ProfileSelectDialog.cpp | 52 +++++++++------------ launcher/ui/dialogs/ProfileSelectDialog.ui | 10 +--- 2 files changed, 23 insertions(+), 39 deletions(-) diff --git a/launcher/ui/dialogs/ProfileSelectDialog.cpp b/launcher/ui/dialogs/ProfileSelectDialog.cpp index 90588ce05..d3168d0e3 100644 --- a/launcher/ui/dialogs/ProfileSelectDialog.cpp +++ b/launcher/ui/dialogs/ProfileSelectDialog.cpp @@ -17,12 +17,25 @@ #include "ui_ProfileSelectDialog.h" #include +#include #include #include #include "Application.h" -#include "ui/dialogs/ProgressDialog.h" +// HACK: hide checkboxes from AccountList +class HideCheckboxProxyModel : public QIdentityProxyModel { + public: + using QIdentityProxyModel::QIdentityProxyModel; + + QVariant data(const QModelIndex& index, int role) const override { + if (role == Qt::CheckStateRole) { + return {}; + } + + return QIdentityProxyModel::data(index, role); + } +}; ProfileSelectDialog::ProfileSelectDialog(const QString& message, int flags, QWidget* parent) : QDialog(parent), ui(new Ui::ProfileSelectDialog) @@ -30,33 +43,10 @@ ProfileSelectDialog::ProfileSelectDialog(const QString& message, int flags, QWid ui->setupUi(this); m_accounts = APPLICATION->accounts(); - auto view = ui->listView; - // view->setModel(m_accounts.get()); - // view->hideColumn(AccountList::ActiveColumn); - view->setColumnCount(1); - view->setRootIsDecorated(false); - // FIXME: use a real model, not this - if (QTreeWidgetItem* header = view->headerItem()) { - header->setText(0, tr("Name")); - } else { - view->setHeaderLabel(tr("Name")); - } - QList items; - for (int i = 0; i < m_accounts->count(); i++) { - MinecraftAccountPtr account = m_accounts->at(i); - QString profileLabel; - if (account->isInUse()) { - profileLabel = tr("%1 (in use)").arg(account->profileName()); - } else { - profileLabel = account->profileName(); - } - auto item = new QTreeWidgetItem(view); - item->setText(0, profileLabel); - item->setIcon(0, account->getFace()); - item->setData(0, AccountList::PointerRole, QVariant::fromValue(account)); - items.append(item); - } - view->addTopLevelItems(items); + + auto proxy = new HideCheckboxProxyModel(ui->view); + proxy->setSourceModel(m_accounts.get()); + ui->view->setModel(proxy); // Set the message label. ui->msgLabel->setVisible(!message.isEmpty()); @@ -68,9 +58,9 @@ ProfileSelectDialog::ProfileSelectDialog(const QString& message, int flags, QWid qDebug() << flags; // Select the first entry in the list. - ui->listView->setCurrentIndex(ui->listView->model()->index(0, 0)); + ui->view->setCurrentIndex(ui->view->model()->index(0, 0)); - connect(ui->listView, &QAbstractItemView::doubleClicked, this, &ProfileSelectDialog::on_buttonBox_accepted); + connect(ui->view, &QAbstractItemView::doubleClicked, this, &ProfileSelectDialog::on_buttonBox_accepted); ui->buttonBox->button(QDialogButtonBox::Cancel)->setText(tr("Cancel")); ui->buttonBox->button(QDialogButtonBox::Ok)->setText(tr("OK")); @@ -98,7 +88,7 @@ bool ProfileSelectDialog::useAsInstDefaullt() const void ProfileSelectDialog::on_buttonBox_accepted() { - QModelIndexList selection = ui->listView->selectionModel()->selectedIndexes(); + QModelIndexList selection = ui->view->selectionModel()->selectedIndexes(); if (selection.size() > 0) { QModelIndex selected = selection.first(); m_selected = selected.data(AccountList::PointerRole).value(); diff --git a/launcher/ui/dialogs/ProfileSelectDialog.ui b/launcher/ui/dialogs/ProfileSelectDialog.ui index e779b51bf..a72b3e2e0 100644 --- a/launcher/ui/dialogs/ProfileSelectDialog.ui +++ b/launcher/ui/dialogs/ProfileSelectDialog.ui @@ -22,13 +22,7 @@ - - - - 1 - - - + @@ -51,7 +45,7 @@ - QDialogButtonBox::Cancel|QDialogButtonBox::Ok + QDialogButtonBox::StandardButton::Cancel|QDialogButtonBox::StandardButton::Ok