Merge branch 'PrismLauncher:develop' into develop

This commit is contained in:
IceYetiWins 2026-06-04 16:46:46 -04:00 committed by GitHub
commit 551f704c0f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 186 additions and 14 deletions

View file

@ -333,11 +333,11 @@ bool LaunchController::reauthenticateAccount(const MinecraftAccountPtr& account,
if (button == QMessageBox::StandardButton::Yes) {
auto* accounts = APPLICATION->accounts();
const bool isDefault = accounts->defaultAccount() == account;
accounts->removeAccount(accounts->index(accounts->findAccountByProfileId(account->profileId())));
if (account->accountType() == AccountType::MSA) {
auto newAccount = MSALoginDialog::newAccount(m_parentWidget);
if (newAccount != nullptr) {
accounts->removeAccount(accounts->index(accounts->findAccountByProfileId(account->profileId())));
accounts->addAccount(newAccount);
if (isDefault) {

View file

@ -648,9 +648,17 @@ void AccountList::tryNext()
while (m_refreshQueue.length()) {
auto accountId = m_refreshQueue.front();
m_refreshQueue.pop_front();
bool found = false;
for (int i = 0; i < count(); i++) {
auto account = at(i);
if (account->internalId() == accountId) {
found = true;
if (!account->shouldRefresh()) {
// Account no longer needs refreshing, skip it.
qDebug() << "RefreshSchedule: Skipping account" << account->profileName() << "with internal ID"
<< accountId << "(no longer needs refresh)";
break;
}
m_currentTask = account->refresh();
if (m_currentTask) {
connect(m_currentTask.get(), &Task::succeeded, this, &AccountList::authSucceeded);
@ -660,9 +668,12 @@ void AccountList::tryNext()
<< accountId;
return;
}
break;
}
}
qDebug() << "RefreshSchedule: Account with internal ID" << accountId << "not found.";
if (!found) {
qDebug() << "RefreshSchedule: Account with internal ID" << accountId << "not found.";
}
}
// if we get here, no account needed refreshing. Schedule refresh in an hour.
m_refreshTimer->start(1000 * 3600);

View file

@ -30,26 +30,106 @@
#include "icons/IconList.h"
#include "icons/IconUtils.h"
class IconProxyModel : public QSortFilterProxyModel
{
public:
explicit IconProxyModel(QObject* parent = nullptr) : QSortFilterProxyModel(parent)
{
}
void setCategory(IconPickerDialog::IconPickerCategory category)
{
if (m_category == category)
return;
m_category = category;
invalidateFilter();
}
protected:
bool filterAcceptsRow(int source_row, const QModelIndex& source_parent) const override
{
if (!QSortFilterProxyModel::filterAcceptsRow(source_row, source_parent))
return false;
if (m_category == IconPickerDialog::Any)
return true;
auto model = static_cast<IconList*>(sourceModel());
QModelIndex index = model->index(source_row, 0, source_parent);
QString key = model->data(index, Qt::UserRole).toString();
const MMCIcon* icon = model->icon(key);
if (!icon)
return false;
bool isModpack = false;
bool isBuiltin = icon->isBuiltIn();
bool isLegacy = isBuiltin && icon->name().endsWith("_legacy", Qt::CaseInsensitive);
if (!isBuiltin) {
const QString& name = icon->name();
if (name.startsWith("curseforge_", Qt::CaseInsensitive) ||
name.startsWith("modrinth_", Qt::CaseInsensitive) ||
name.startsWith("ftb_", Qt::CaseInsensitive) ||
name.startsWith("technic_", Qt::CaseInsensitive) ||
name.startsWith("atl_", Qt::CaseInsensitive)) {
isModpack = true;
}
}
switch (m_category) {
case IconPickerDialog::Legacy:
return isBuiltin && isLegacy;
case IconPickerDialog::Modpacks:
return isModpack;
case IconPickerDialog::Modern:
return isBuiltin && !isLegacy;
case IconPickerDialog::Custom:
return !isBuiltin && !isModpack;
default:
return true;
}
}
private:
IconPickerDialog::IconPickerCategory m_category = IconPickerDialog::Any;
};
IconPickerDialog::IconPickerDialog(QWidget* parent) : QDialog(parent), ui(new Ui::IconPickerDialog)
{
ui->setupUi(this);
setWindowModality(Qt::WindowModal);
searchBar = new QLineEdit(this);
searchBar->setPlaceholderText(tr("Search..."));
ui->verticalLayout->insertWidget(0, searchBar);
static const QString context_text[] = {
tr("All"),
tr("Modern"),
tr("Legacy"),
tr("Modpacks"),
tr("Custom"),
};
static const IconPickerCategory context_id[] = {
Any,
Modern,
Legacy,
Modpacks,
Custom,
};
const int cnt = sizeof(context_text) / sizeof(context_text[0]);
for (int i = 0; i < cnt; ++i) {
ui->contextCombo->addItem(context_text[i], context_id[i]);
if (i == 0) {
ui->contextCombo->insertSeparator(i + 1);
}
}
proxyModel = new QSortFilterProxyModel(this);
proxyModel = new IconProxyModel(this);
proxyModel->setSourceModel(APPLICATION->icons());
proxyModel->setFilterCaseSensitivity(Qt::CaseInsensitive);
ui->iconView->setModel(proxyModel);
auto contentsWidget = ui->iconView;
contentsWidget->setViewMode(QListView::IconMode);
contentsWidget->setFlow(QListView::LeftToRight);
contentsWidget->setIconSize(QSize(48, 48));
contentsWidget->setMovement(QListView::Static);
contentsWidget->setResizeMode(QListView::Adjust);
contentsWidget->setSelectionMode(QAbstractItemView::SingleSelection);
contentsWidget->setSpacing(5);
contentsWidget->setWordWrap(false);
@ -86,7 +166,11 @@ IconPickerDialog::IconPickerDialog(QWidget* parent) : QDialog(parent), ui(new Ui
auto buttonFolder = ui->buttonBox->addButton(tr("Open Folder"), QDialogButtonBox::ResetRole);
connect(buttonFolder, &QPushButton::clicked, this, &IconPickerDialog::openFolder);
connect(searchBar, &QLineEdit::textChanged, this, &IconPickerDialog::filterIcons);
connect(ui->searchLine, &QLineEdit::textChanged, this, &IconPickerDialog::filterIcons);
connect(ui->contextCombo, &QComboBox::currentIndexChanged, this, [this](int index) {
IconPickerCategory category = static_cast<IconPickerCategory>(ui->contextCombo->itemData(index).toInt());
filterIconsByCategory(category);
});
// Prevent incorrect indices from e.g. filesystem changes
connect(APPLICATION->icons(), &IconList::iconUpdated, this, [this]() { proxyModel->invalidate(); });
}
@ -182,3 +266,8 @@ void IconPickerDialog::filterIcons(const QString& query)
{
proxyModel->setFilterFixedString(query);
}
void IconPickerDialog::filterIconsByCategory(IconPickerCategory category)
{
static_cast<IconProxyModel*>(proxyModel)->setCategory(category);
}

View file

@ -32,6 +32,15 @@ class IconPickerDialog : public QDialog {
int execWithSelection(QString selection);
QString selectedIconKey;
enum IconPickerCategory {
Any,
Modern,
Legacy,
Modpacks,
Custom,
};
Q_ENUM(IconPickerCategory)
protected:
virtual bool eventFilter(QObject*, QEvent*);
@ -49,4 +58,5 @@ class IconPickerDialog : public QDialog {
void removeSelectedIcon();
void openFolder();
void filterIcons(const QString& text);
void filterIconsByCategory(IconPickerCategory);
};

View file

@ -15,7 +15,64 @@
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QListView" name="iconView"/>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QComboBox" name="contextCombo">
<property name="accessibleName">
<string>Icon category</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLineEdit" name="searchLine">
<property name="placeholderText">
<string>Search Icons...</string>
</property>
<property name="clearButtonEnabled">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item>
<widget class="QListView" name="iconView">
<property name="iconSize">
<size>
<width>60</width>
<height>60</height>
</size>
</property>
<property name="movement">
<enum>QListView::Static</enum>
</property>
<property name="resizeMode">
<enum>QListView::Adjust</enum>
</property>
<property name="viewMode">
<enum>QListView::IconMode</enum>
</property>
<property name="uniformItemSizes">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">

View file

@ -121,7 +121,7 @@ void WorldListPage::openedImpl()
ui->toolBar->removeAction(ui->actionJoin);
}
auto const setting_name = QString("WideBarVisibility_%1").arg(id());
const auto setting_name = QString("WideBarVisibility_%1").arg(id());
m_wide_bar_setting = APPLICATION->settings()->getOrRegisterSetting(setting_name);
ui->toolBar->setVisibilityState(QByteArray::fromBase64(m_wide_bar_setting->get().toString().toUtf8()));
@ -259,9 +259,12 @@ void WorldListPage::on_actionData_Packs_triggered()
dialog->setLayout(layout);
dialog->exec();
dialog->setAttribute(Qt::WA_DeleteOnClose);
APPLICATION->settings()->set("DataPackDownloadGeometry", dialog->saveGeometry().toBase64());
connect(dialog, &QDialog::finished, this,
[dialog]() { APPLICATION->settings()->set("DataPackDownloadGeometry", dialog->saveGeometry().toBase64()); });
dialog->open();
}
void WorldListPage::on_actionReset_Icon_triggered()

View file

@ -6,6 +6,7 @@
glfw3-minecraft,
jdk17,
jdk21,
jdk25,
jdk8,
kdePackages,
lib,
@ -34,6 +35,7 @@
controllerSupport ? stdenv.hostPlatform.isLinux,
gamemodeSupport ? stdenv.hostPlatform.isLinux,
jdks ? [
jdk25
jdk21
jdk17
jdk8