From 0b251fa7545dbe7e61a2a57f5f3e0ff2198b2314 Mon Sep 17 00:00:00 2001 From: Redson Date: Mon, 8 May 2023 19:57:30 -0300 Subject: [PATCH 01/35] feat: Add the launcher root folder to the Folders menu Signed-off-by: Redson --- launcher/ui/MainWindow.cpp | 8 ++++++++ launcher/ui/MainWindow.h | 2 ++ launcher/ui/MainWindow.ui | 13 +++++++++++++ 3 files changed, 23 insertions(+) diff --git a/launcher/ui/MainWindow.cpp b/launcher/ui/MainWindow.cpp index 72b7db641..8d62dcd60 100644 --- a/launcher/ui/MainWindow.cpp +++ b/launcher/ui/MainWindow.cpp @@ -1201,6 +1201,14 @@ void MainWindow::on_actionViewInstanceFolder_triggered() DesktopServices::openDirectory(str); } +void MainWindow::on_actionViewLauncherRootFolder_triggered() +{ + QDir rootDir(FS::PathCombine(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation), "..")); + QString DataPath = rootDir.absolutePath(); + + DesktopServices::openDirectory(DataPath); +} + void MainWindow::refreshInstances() { APPLICATION->instances()->loadList(); diff --git a/launcher/ui/MainWindow.h b/launcher/ui/MainWindow.h index 3a42c34e1..08efb8a1c 100644 --- a/launcher/ui/MainWindow.h +++ b/launcher/ui/MainWindow.h @@ -112,6 +112,8 @@ private slots: void on_actionViewInstanceFolder_triggered(); + void on_actionViewLauncherRootFolder_triggered(); + void on_actionViewSelectedInstFolder_triggered(); void refreshInstances(); diff --git a/launcher/ui/MainWindow.ui b/launcher/ui/MainWindow.ui index 2b6a10b10..7c53e294d 100644 --- a/launcher/ui/MainWindow.ui +++ b/launcher/ui/MainWindow.ui @@ -187,6 +187,7 @@ true + @@ -528,6 +529,18 @@ Open the instance folder in a file browser. + + + + .. + + + &View Launcher Root Folder + + + Open the launcher's root folder in a file browser. + + From 475761b295b3c77aa852af254f783340055090f6 Mon Sep 17 00:00:00 2001 From: Redson Date: Tue, 9 May 2023 06:36:21 -0300 Subject: [PATCH 02/35] fix: Prism sets the data dir to the working directory. Signed-off-by: Redson --- launcher/ui/MainWindow.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/launcher/ui/MainWindow.cpp b/launcher/ui/MainWindow.cpp index 8d62dcd60..629ace830 100644 --- a/launcher/ui/MainWindow.cpp +++ b/launcher/ui/MainWindow.cpp @@ -1203,10 +1203,10 @@ void MainWindow::on_actionViewInstanceFolder_triggered() void MainWindow::on_actionViewLauncherRootFolder_triggered() { - QDir rootDir(FS::PathCombine(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation), "..")); - QString DataPath = rootDir.absolutePath(); + QDir dataDir = QDir::current(); + QString dataPath = dataDir.absolutePath(); - DesktopServices::openDirectory(DataPath); + DesktopServices::openDirectory(dataPath); } void MainWindow::refreshInstances() From 961285d6abad3e70a0ab748007349ef67632f138 Mon Sep 17 00:00:00 2001 From: TheKodeToad Date: Mon, 5 Jun 2023 20:49:47 +0100 Subject: [PATCH 03/35] Add a search bar to version lists Signed-off-by: TheKodeToad --- launcher/VersionProxyModel.cpp | 21 ++++++++- launcher/VersionProxyModel.h | 3 ++ launcher/ui/dialogs/VersionSelectDialog.cpp | 47 +++++++++++++------- launcher/ui/widgets/JavaSettingsWidget.cpp | 2 +- launcher/ui/widgets/VersionSelectWidget.cpp | 34 ++++++++++++++- launcher/ui/widgets/VersionSelectWidget.h | 48 +++++++++++++++------ 6 files changed, 122 insertions(+), 33 deletions(-) diff --git a/launcher/VersionProxyModel.cpp b/launcher/VersionProxyModel.cpp index 6aba268d8..d5d14c246 100644 --- a/launcher/VersionProxyModel.cpp +++ b/launcher/VersionProxyModel.cpp @@ -1,7 +1,8 @@ // SPDX-License-Identifier: GPL-3.0-only /* - * PolyMC - Minecraft Launcher + * Prism Launcher - Minecraft Launcher * Copyright (C) 2022 Sefa Eyeoglu + * Copyright (C) 2023 TheKodeToad * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -54,9 +55,14 @@ public: bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const { const auto &filters = m_parent->filters(); + const QString &search = m_parent->search(); + const QModelIndex idx = sourceModel()->index(source_row, 0, source_parent); + + if (!search.isEmpty() && !sourceModel()->data(idx, BaseVersionList::VersionRole).toString().contains(search)) + return false; + for (auto it = filters.begin(); it != filters.end(); ++it) { - auto idx = sourceModel()->index(source_row, 0, source_parent); auto data = sourceModel()->data(idx, it.key()); auto match = data.toString(); if(!it.value()->accepts(match)) @@ -431,6 +437,7 @@ QModelIndex VersionProxyModel::getVersion(const QString& version) const void VersionProxyModel::clearFilters() { m_filters.clear(); + m_search.clear(); filterModel->filterChanged(); } @@ -440,11 +447,21 @@ void VersionProxyModel::setFilter(const BaseVersionList::ModelRoles column, Filt filterModel->filterChanged(); } +void VersionProxyModel::setSearch(const QString &search) { + m_search = search; + filterModel->filterChanged(); +} + const VersionProxyModel::FilterMap &VersionProxyModel::filters() const { return m_filters; } +const QString &VersionProxyModel::search() const +{ + return m_search; +} + void VersionProxyModel::sourceAboutToBeReset() { beginResetModel(); diff --git a/launcher/VersionProxyModel.h b/launcher/VersionProxyModel.h index 8991c31b0..6434376c6 100644 --- a/launcher/VersionProxyModel.h +++ b/launcher/VersionProxyModel.h @@ -38,7 +38,9 @@ public: virtual void setSourceModel(QAbstractItemModel *sourceModel) override; const FilterMap &filters() const; + const QString &search() const; void setFilter(const BaseVersionList::ModelRoles column, Filter * filter); + void setSearch(const QString &search); void clearFilters(); QModelIndex getRecommended() const; QModelIndex getVersion(const QString & version) const; @@ -59,6 +61,7 @@ private slots: private: QList m_columns; FilterMap m_filters; + QString m_search; BaseVersionList::RoleList roles; VersionFilterModel * filterModel; bool hasRecommended = false; diff --git a/launcher/ui/dialogs/VersionSelectDialog.cpp b/launcher/ui/dialogs/VersionSelectDialog.cpp index d7880334f..5feb70d20 100644 --- a/launcher/ui/dialogs/VersionSelectDialog.cpp +++ b/launcher/ui/dialogs/VersionSelectDialog.cpp @@ -1,16 +1,36 @@ -/* Copyright 2013-2021 MultiMC Contributors +// SPDX-License-Identifier: GPL-3.0-only +/* + * Prism Launcher - Minecraft Launcher + * Copyright (C) 2023 TheKodeToad * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3. * - * http://www.apache.org/licenses/LICENSE-2.0 + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * This file incorporates work covered by the following copyright and + * permission notice: + * + * Copyright 2013-2021 MultiMC Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ #include "VersionSelectDialog.h" @@ -22,15 +42,10 @@ #include #include -#include "ui/dialogs/ProgressDialog.h" #include "ui/widgets/VersionSelectWidget.h" -#include "ui/dialogs/CustomMessageBox.h" #include "BaseVersion.h" #include "BaseVersionList.h" -#include "tasks/Task.h" -#include "Application.h" -#include "VersionProxyModel.h" VersionSelectDialog::VersionSelectDialog(BaseVersionList *vlist, QString title, QWidget *parent, bool cancelable) : QDialog(parent) @@ -40,7 +55,7 @@ VersionSelectDialog::VersionSelectDialog(BaseVersionList *vlist, QString title, m_verticalLayout = new QVBoxLayout(this); m_verticalLayout->setObjectName(QStringLiteral("verticalLayout")); - m_versionWidget = new VersionSelectWidget(parent); + m_versionWidget = new VersionSelectWidget(true, parent); m_verticalLayout->addWidget(m_versionWidget); m_horizontalLayout = new QHBoxLayout(); diff --git a/launcher/ui/widgets/JavaSettingsWidget.cpp b/launcher/ui/widgets/JavaSettingsWidget.cpp index 159943198..c94fdd8d5 100644 --- a/launcher/ui/widgets/JavaSettingsWidget.cpp +++ b/launcher/ui/widgets/JavaSettingsWidget.cpp @@ -46,7 +46,7 @@ void JavaSettingsWidget::setupUi() m_verticalLayout = new QVBoxLayout(this); m_verticalLayout->setObjectName(QStringLiteral("verticalLayout")); - m_versionWidget = new VersionSelectWidget(this); + m_versionWidget = new VersionSelectWidget(true, this); m_verticalLayout->addWidget(m_versionWidget); m_horizontalLayout = new QHBoxLayout(); diff --git a/launcher/ui/widgets/VersionSelectWidget.cpp b/launcher/ui/widgets/VersionSelectWidget.cpp index 404860d90..252e2719e 100644 --- a/launcher/ui/widgets/VersionSelectWidget.cpp +++ b/launcher/ui/widgets/VersionSelectWidget.cpp @@ -8,8 +8,10 @@ #include "ui/dialogs/CustomMessageBox.h" -VersionSelectWidget::VersionSelectWidget(QWidget* parent) - : QWidget(parent) +VersionSelectWidget::VersionSelectWidget(QWidget* parent) : VersionSelectWidget(false, parent) {} + +VersionSelectWidget::VersionSelectWidget(bool focusSearch, QWidget* parent) + : QWidget(parent), focusSearch(focusSearch) { setObjectName(QStringLiteral("VersionSelectWidget")); verticalLayout = new QVBoxLayout(this); @@ -30,6 +32,12 @@ VersionSelectWidget::VersionSelectWidget(QWidget* parent) listView->setModel(m_proxyModel); verticalLayout->addWidget(listView); + search = new QLineEdit(this); + search->setPlaceholderText(tr("Search")); + search->setClearButtonEnabled(true); + verticalLayout->addWidget(search); + connect(search, &QLineEdit::textEdited, this, &VersionSelectWidget::updateSearch); + sneakyProgressBar = new QProgressBar(this); sneakyProgressBar->setObjectName(QStringLiteral("sneakyProgressBar")); sneakyProgressBar->setFormat(QStringLiteral("%p%")); @@ -89,6 +97,8 @@ void VersionSelectWidget::initialize(BaseVersionList *vlist) { listView->setEmptyMode(VersionListView::String); } + search->setFocus(); + focusSearch = false; preselect(); } } @@ -114,6 +124,7 @@ void VersionSelectWidget::loadList() loadTask->start(); } sneakyProgressBar->setHidden(false); + search->setHidden(true); } void VersionSelectWidget::onTaskSucceeded() @@ -123,6 +134,14 @@ void VersionSelectWidget::onTaskSucceeded() listView->setEmptyMode(VersionListView::String); } sneakyProgressBar->setHidden(true); + search->setHidden(false); + + if (focusSearch) + { + search->setFocus(); + focusSearch = false; + } + preselect(); loadTask = nullptr; } @@ -155,6 +174,17 @@ void VersionSelectWidget::preselect() selectRecommended(); } +void VersionSelectWidget::updateSearch(const QString &value) { + m_proxyModel->setSearch(value); + // if nothing is selected, pick the first result + if (!value.isEmpty()) { + listView->selectionModel()->setCurrentIndex( + listView->model()->index(0, 0), QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows); + listView->scrollToTop(); + } else + listView->scrollTo(listView->selectionModel()->currentIndex(), QAbstractItemView::PositionAtCenter); +} + void VersionSelectWidget::selectCurrent() { if(m_currentVersion.isEmpty()) diff --git a/launcher/ui/widgets/VersionSelectWidget.h b/launcher/ui/widgets/VersionSelectWidget.h index e75efc6f6..df9c8a628 100644 --- a/launcher/ui/widgets/VersionSelectWidget.h +++ b/launcher/ui/widgets/VersionSelectWidget.h @@ -1,22 +1,43 @@ -/* Copyright 2013-2021 MultiMC Contributors +// SPDX-License-Identifier: GPL-3.0-only +/* + * Prism Launcher - Minecraft Launcher + * Copyright (C) 2023 TheKodeToad * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3. * - * http://www.apache.org/licenses/LICENSE-2.0 + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * This file incorporates work covered by the following copyright and + * permission notice: + * + * Copyright 2013-2021 MultiMC Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ #pragma once #include #include +#include #include "BaseVersionList.h" #include "VersionListView.h" @@ -30,7 +51,8 @@ class VersionSelectWidget: public QWidget { Q_OBJECT public: - explicit VersionSelectWidget(QWidget *parent = 0); + explicit VersionSelectWidget(QWidget *parent); + explicit VersionSelectWidget(bool focusSearch = false, QWidget *parent = 0); ~VersionSelectWidget(); //! loads the list if needed. @@ -67,6 +89,7 @@ private slots: private: void preselect(); + void updateSearch(const QString &value); private: QString m_currentVersion; @@ -75,9 +98,10 @@ private: int resizeOnColumn = 0; Task * loadTask; bool preselectedAlready = false; + bool focusSearch; -private: QVBoxLayout *verticalLayout = nullptr; VersionListView *listView = nullptr; + QLineEdit *search; QProgressBar *sneakyProgressBar = nullptr; }; From 7c5047b2acd25708063056cff547dc1b8fcfbb41 Mon Sep 17 00:00:00 2001 From: TheKodeToad Date: Mon, 5 Jun 2023 23:10:41 +0100 Subject: [PATCH 04/35] cAsE iNsEnSiTiVe Signed-off-by: TheKodeToad --- launcher/VersionProxyModel.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/launcher/VersionProxyModel.cpp b/launcher/VersionProxyModel.cpp index d5d14c246..47cfa5ba3 100644 --- a/launcher/VersionProxyModel.cpp +++ b/launcher/VersionProxyModel.cpp @@ -58,7 +58,7 @@ public: const QString &search = m_parent->search(); const QModelIndex idx = sourceModel()->index(source_row, 0, source_parent); - if (!search.isEmpty() && !sourceModel()->data(idx, BaseVersionList::VersionRole).toString().contains(search)) + if (!search.isEmpty() && !sourceModel()->data(idx, BaseVersionList::VersionRole).toString().contains(search, Qt::CaseInsensitive)) return false; for (auto it = filters.begin(); it != filters.end(); ++it) From c343036d3bfd60cb24477fcd2ae1286276236a68 Mon Sep 17 00:00:00 2001 From: TheKodeToad Date: Tue, 6 Jun 2023 12:24:53 +0100 Subject: [PATCH 05/35] Simplify Signed-off-by: TheKodeToad --- launcher/ui/widgets/VersionSelectWidget.cpp | 29 +++++++-------------- launcher/ui/widgets/VersionSelectWidget.h | 1 - 2 files changed, 9 insertions(+), 21 deletions(-) diff --git a/launcher/ui/widgets/VersionSelectWidget.cpp b/launcher/ui/widgets/VersionSelectWidget.cpp index 252e2719e..6aaffaaca 100644 --- a/launcher/ui/widgets/VersionSelectWidget.cpp +++ b/launcher/ui/widgets/VersionSelectWidget.cpp @@ -36,7 +36,15 @@ VersionSelectWidget::VersionSelectWidget(bool focusSearch, QWidget* parent) search->setPlaceholderText(tr("Search")); search->setClearButtonEnabled(true); verticalLayout->addWidget(search); - connect(search, &QLineEdit::textEdited, this, &VersionSelectWidget::updateSearch); + connect(search, &QLineEdit::textEdited, [this](const QString& value) { + m_proxyModel->setSearch(value); + if (!value.isEmpty() || !listView->selectionModel()->hasSelection()) { + const QModelIndex first = listView->model()->index(0, 0); + listView->selectionModel()->setCurrentIndex(first, QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows); + listView->scrollToTop(); + } else + listView->scrollTo(listView->selectionModel()->currentIndex(), QAbstractItemView::PositionAtCenter); + }); sneakyProgressBar = new QProgressBar(this); sneakyProgressBar->setObjectName(QStringLiteral("sneakyProgressBar")); @@ -124,7 +132,6 @@ void VersionSelectWidget::loadList() loadTask->start(); } sneakyProgressBar->setHidden(false); - search->setHidden(true); } void VersionSelectWidget::onTaskSucceeded() @@ -134,13 +141,6 @@ void VersionSelectWidget::onTaskSucceeded() listView->setEmptyMode(VersionListView::String); } sneakyProgressBar->setHidden(true); - search->setHidden(false); - - if (focusSearch) - { - search->setFocus(); - focusSearch = false; - } preselect(); loadTask = nullptr; @@ -174,17 +174,6 @@ void VersionSelectWidget::preselect() selectRecommended(); } -void VersionSelectWidget::updateSearch(const QString &value) { - m_proxyModel->setSearch(value); - // if nothing is selected, pick the first result - if (!value.isEmpty()) { - listView->selectionModel()->setCurrentIndex( - listView->model()->index(0, 0), QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows); - listView->scrollToTop(); - } else - listView->scrollTo(listView->selectionModel()->currentIndex(), QAbstractItemView::PositionAtCenter); -} - void VersionSelectWidget::selectCurrent() { if(m_currentVersion.isEmpty()) diff --git a/launcher/ui/widgets/VersionSelectWidget.h b/launcher/ui/widgets/VersionSelectWidget.h index df9c8a628..8d2c900c8 100644 --- a/launcher/ui/widgets/VersionSelectWidget.h +++ b/launcher/ui/widgets/VersionSelectWidget.h @@ -89,7 +89,6 @@ private slots: private: void preselect(); - void updateSearch(const QString &value); private: QString m_currentVersion; From a2d0d5a71d37f39535154df1e6f740625817a9eb Mon Sep 17 00:00:00 2001 From: TheKodeToad Date: Tue, 6 Jun 2023 18:25:09 +0100 Subject: [PATCH 06/35] Allow arrow key movement, fix auto-focus Signed-off-by: TheKodeToad --- launcher/ui/widgets/VersionSelectWidget.cpp | 29 ++++++++++++++++++--- launcher/ui/widgets/VersionSelectWidget.h | 1 + 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/launcher/ui/widgets/VersionSelectWidget.cpp b/launcher/ui/widgets/VersionSelectWidget.cpp index 6aaffaaca..a956ddb3c 100644 --- a/launcher/ui/widgets/VersionSelectWidget.cpp +++ b/launcher/ui/widgets/VersionSelectWidget.cpp @@ -1,8 +1,11 @@ #include "VersionSelectWidget.h" +#include +#include +#include +#include #include #include -#include #include "VersionProxyModel.h" @@ -45,6 +48,7 @@ VersionSelectWidget::VersionSelectWidget(bool focusSearch, QWidget* parent) } else listView->scrollTo(listView->selectionModel()->currentIndex(), QAbstractItemView::PositionAtCenter); }); + search->installEventFilter(this); sneakyProgressBar = new QProgressBar(this); sneakyProgressBar->setObjectName(QStringLiteral("sneakyProgressBar")); @@ -88,6 +92,23 @@ void VersionSelectWidget::setResizeOn(int column) listView->header()->setSectionResizeMode(resizeOnColumn, QHeaderView::Stretch); } +bool VersionSelectWidget::eventFilter(QObject *watched, QEvent *event) { + if (watched == search && event->type() == QEvent::KeyPress) { + const QKeyEvent* keyEvent = (QKeyEvent*)event; + const bool up = keyEvent->key() == Qt::Key_Up; + const bool down = keyEvent->key() == Qt::Key_Down; + if (up || down) { + const QModelIndex index = listView->model()->index(listView->currentIndex().row() + (up ? -1 : 1), 0); + if (index.row() >= 0 && index.row() < listView->model()->rowCount()) { + listView->selectionModel()->setCurrentIndex(index, QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows); + return true; + } + } + } + + return QObject::eventFilter(watched, event); +} + void VersionSelectWidget::initialize(BaseVersionList *vlist) { m_vlist = vlist; @@ -95,6 +116,9 @@ void VersionSelectWidget::initialize(BaseVersionList *vlist) listView->header()->setSectionResizeMode(QHeaderView::ResizeToContents); listView->header()->setSectionResizeMode(resizeOnColumn, QHeaderView::Stretch); + if (focusSearch) + search->setFocus(); + if (!m_vlist->isLoaded()) { loadList(); @@ -105,8 +129,6 @@ void VersionSelectWidget::initialize(BaseVersionList *vlist) { listView->setEmptyMode(VersionListView::String); } - search->setFocus(); - focusSearch = false; preselect(); } } @@ -141,7 +163,6 @@ void VersionSelectWidget::onTaskSucceeded() listView->setEmptyMode(VersionListView::String); } sneakyProgressBar->setHidden(true); - preselect(); loadTask = nullptr; } diff --git a/launcher/ui/widgets/VersionSelectWidget.h b/launcher/ui/widgets/VersionSelectWidget.h index 8d2c900c8..be4ba768d 100644 --- a/launcher/ui/widgets/VersionSelectWidget.h +++ b/launcher/ui/widgets/VersionSelectWidget.h @@ -74,6 +74,7 @@ public: void setEmptyErrorString(QString emptyErrorString); void setEmptyMode(VersionListView::EmptyMode mode); void setResizeOn(int column); + bool eventFilter(QObject* watched, QEvent* event) override; signals: void selectedVersionChanged(BaseVersion::Ptr version); From 1e702ee40f211286f85fa5353704e358e7fe14a9 Mon Sep 17 00:00:00 2001 From: Trial97 Date: Wed, 7 Jun 2023 00:16:23 +0300 Subject: [PATCH 07/35] Added dynamic page extra info Signed-off-by: Trial97 --- launcher/ui/pages/BasePage.h | 24 +++++++++---------- .../pages/instance/ExternalResourcesPage.cpp | 19 ++++++++++++++- .../ui/pages/instance/ExternalResourcesPage.h | 1 + launcher/ui/widgets/PageContainer.cpp | 4 ++++ 4 files changed, 35 insertions(+), 13 deletions(-) diff --git a/launcher/ui/pages/BasePage.h b/launcher/ui/pages/BasePage.h index ceb240401..5537c28f7 100644 --- a/launcher/ui/pages/BasePage.h +++ b/launcher/ui/pages/BasePage.h @@ -35,15 +35,16 @@ #pragma once -#include #include +#include +#include #include #include "BasePageContainer.h" -class BasePage -{ -public: +class BasePage { + public: + using updateExtraInfoFunc = std::function; virtual ~BasePage() {} virtual QString id() const = 0; virtual QString displayName() const = 0; @@ -63,17 +64,16 @@ public: } virtual void openedImpl() {} virtual void closedImpl() {} - virtual void setParentContainer(BasePageContainer * container) - { - m_container = container; - }; - virtual void retranslate() { } + virtual void setParentContainer(BasePageContainer* container) { m_container = container; }; + virtual void retranslate() {} -public: + public: int stackIndex = -1; int listIndex = -1; -protected: - BasePageContainer * m_container = nullptr; + updateExtraInfoFunc updateExtraInfo; + + protected: + BasePageContainer* m_container = nullptr; bool isOpened = false; }; diff --git a/launcher/ui/pages/instance/ExternalResourcesPage.cpp b/launcher/ui/pages/instance/ExternalResourcesPage.cpp index 1115ddc3b..e5567c804 100644 --- a/launcher/ui/pages/instance/ExternalResourcesPage.cpp +++ b/launcher/ui/pages/instance/ExternalResourcesPage.cpp @@ -9,6 +9,7 @@ #include #include +#include ExternalResourcesPage::ExternalResourcesPage(BaseInstance* instance, std::shared_ptr model, QWidget* parent) : QMainWindow(parent), m_instance(instance), ui(new Ui::ExternalResourcesPage), m_model(model) @@ -43,6 +44,13 @@ ExternalResourcesPage::ExternalResourcesPage(BaseInstance* instance, std::shared auto selection_model = ui->treeView->selectionModel(); connect(selection_model, &QItemSelectionModel::currentChanged, this, &ExternalResourcesPage::current); + auto updateExtra = [this]() { + if (updateExtraInfo) + updateExtraInfo(extraHeaderInfoString()); + }; + connect(selection_model, &QItemSelectionModel::selectionChanged, this, updateExtra); + connect(model.get(), &ResourceFolderModel::updateFinished, this, updateExtra); + connect(ui->filterEdit, &QLineEdit::textChanged, this, &ExternalResourcesPage::filterTextChanged); } @@ -248,6 +256,15 @@ bool ExternalResourcesPage::onSelectionChanged(const QModelIndex& current, const int row = sourceCurrent.row(); Resource const& resource = m_model->at(row); ui->frame->updateWithResource(resource); - return true; } + +QString ExternalResourcesPage::extraHeaderInfoString() +{ + if (ui && ui->treeView && ui->treeView->selectionModel()) { + auto selection = m_filterModel->mapSelectionToSource(ui->treeView->selectionModel()->selection()).indexes(); + if (auto count = std::count_if(selection.cbegin(), selection.cend(), [](auto v) { return v.column() == 0; }); count != 0) + return tr("[%1 installed, %2 selected]").arg(m_model->size()).arg(count); + } + return tr("[%1 installed]").arg(m_model->size()); +} diff --git a/launcher/ui/pages/instance/ExternalResourcesPage.h b/launcher/ui/pages/instance/ExternalResourcesPage.h index d17fbb7f1..fd2001938 100644 --- a/launcher/ui/pages/instance/ExternalResourcesPage.h +++ b/launcher/ui/pages/instance/ExternalResourcesPage.h @@ -29,6 +29,7 @@ class ExternalResourcesPage : public QMainWindow, public BasePage { virtual QString helpPage() const override = 0; virtual bool shouldDisplay() const override = 0; + QString extraHeaderInfoString(); void openedImpl() override; void closedImpl() override; diff --git a/launcher/ui/widgets/PageContainer.cpp b/launcher/ui/widgets/PageContainer.cpp index 38a228973..34df42ece 100644 --- a/launcher/ui/widgets/PageContainer.cpp +++ b/launcher/ui/widgets/PageContainer.cpp @@ -93,6 +93,10 @@ PageContainer::PageContainer(BasePageProvider *pageProvider, QString defaultId, page->listIndex = counter; page->setParentContainer(this); counter++; + page->updateExtraInfo = [this](QString info) { + if (m_currentPage) + m_header->setText(m_currentPage->displayName() + info); + }; } m_model->setPages(pages); From 52054469cd351002143b30d5bb1d8160cdf4b085 Mon Sep 17 00:00:00 2001 From: TheKodeToad Date: Wed, 7 Jun 2023 22:39:12 +0100 Subject: [PATCH 08/35] Fix *bug* lol Signed-off-by: TheKodeToad --- launcher/java/JavaInstallList.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/launcher/java/JavaInstallList.cpp b/launcher/java/JavaInstallList.cpp index b29af8576..9277203a4 100644 --- a/launcher/java/JavaInstallList.cpp +++ b/launcher/java/JavaInstallList.cpp @@ -98,6 +98,8 @@ QVariant JavaInstallList::data(const QModelIndex &index, int role) const auto version = std::dynamic_pointer_cast(m_vlist[index.row()]); switch (role) { + case SortRole: + return -index.row(); case VersionPointerRole: return QVariant::fromValue(m_vlist[index.row()]); case VersionIdRole: @@ -117,7 +119,7 @@ QVariant JavaInstallList::data(const QModelIndex &index, int role) const BaseVersionList::RoleList JavaInstallList::providesRoles() const { - return {VersionPointerRole, VersionIdRole, VersionRole, RecommendedRole, PathRole, ArchitectureRole}; + return {VersionPointerRole, VersionIdRole, VersionRole, RecommendedRole, LatestRole, PathRole, ArchitectureRole}; } From 1191c33c2b40d3fdb4ee66871f8cac4eb8aaf77d Mon Sep 17 00:00:00 2001 From: TheKodeToad Date: Wed, 7 Jun 2023 22:40:36 +0100 Subject: [PATCH 09/35] Remove flawed implementation This seems to add the latest icon (bug) as a fallback if not provided... but it mainly seems to cause problems... :shrug: I swear I did `git add .`. Signed-off-by: TheKodeToad --- launcher/VersionProxyModel.cpp | 8 -------- launcher/java/JavaInstallList.cpp | 2 +- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/launcher/VersionProxyModel.cpp b/launcher/VersionProxyModel.cpp index 47cfa5ba3..e5c665662 100644 --- a/launcher/VersionProxyModel.cpp +++ b/launcher/VersionProxyModel.cpp @@ -212,10 +212,6 @@ QVariant VersionProxyModel::data(const QModelIndex &index, int role) const return tr("Latest"); } } - else if(index.row() == 0) - { - return tr("Latest"); - } } } default: @@ -245,10 +241,6 @@ QVariant VersionProxyModel::data(const QModelIndex &index, int role) const return APPLICATION->getThemedIcon("bug"); } } - else if(index.row() == 0) - { - return APPLICATION->getThemedIcon("bug"); - } QPixmap pixmap; QPixmapCache::find("placeholder", &pixmap); if(!pixmap) diff --git a/launcher/java/JavaInstallList.cpp b/launcher/java/JavaInstallList.cpp index 9277203a4..04eb2e0f3 100644 --- a/launcher/java/JavaInstallList.cpp +++ b/launcher/java/JavaInstallList.cpp @@ -119,7 +119,7 @@ QVariant JavaInstallList::data(const QModelIndex &index, int role) const BaseVersionList::RoleList JavaInstallList::providesRoles() const { - return {VersionPointerRole, VersionIdRole, VersionRole, RecommendedRole, LatestRole, PathRole, ArchitectureRole}; + return {VersionPointerRole, VersionIdRole, VersionRole, RecommendedRole, PathRole, ArchitectureRole}; } From 0b4807dc1fd723ac2f511a935649ae3a858aa388 Mon Sep 17 00:00:00 2001 From: TheKodeToad Date: Wed, 7 Jun 2023 22:55:37 +0100 Subject: [PATCH 10/35] Questionable fix two Signed-off-by: TheKodeToad --- launcher/ui/widgets/VersionListView.cpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/launcher/ui/widgets/VersionListView.cpp b/launcher/ui/widgets/VersionListView.cpp index 0e126c65b..69f881552 100644 --- a/launcher/ui/widgets/VersionListView.cpp +++ b/launcher/ui/widgets/VersionListView.cpp @@ -125,14 +125,9 @@ void VersionListView::paintEvent(QPaintEvent *event) QString VersionListView::currentEmptyString() const { - if(m_itemCount) { - return QString(); - } switch(m_emptyMode) { default: - case VersionListView::Empty: - return QString(); case VersionListView::String: return m_emptyString; case VersionListView::ErrorString: From f96b135ef72a762220941681cf1b314a3b2db266 Mon Sep 17 00:00:00 2001 From: Trial97 Date: Thu, 8 Jun 2023 20:26:09 +0300 Subject: [PATCH 11/35] Higlight installed mods Signed-off-by: Trial97 --- launcher/minecraft/MinecraftInstance.cpp | 40 ++++++++----------- launcher/minecraft/MinecraftInstance.h | 16 ++++---- launcher/minecraft/WorldList.cpp | 3 +- launcher/minecraft/WorldList.h | 4 +- launcher/minecraft/mod/ModFolderModel.cpp | 2 +- launcher/minecraft/mod/ModFolderModel.h | 2 +- .../minecraft/mod/ResourceFolderModel.cpp | 2 +- launcher/minecraft/mod/ResourceFolderModel.h | 4 +- .../minecraft/mod/ResourcePackFolderModel.cpp | 2 +- .../minecraft/mod/ResourcePackFolderModel.h | 2 +- .../minecraft/mod/ShaderPackFolderModel.h | 4 +- .../minecraft/mod/TexturePackFolderModel.cpp | 3 +- .../minecraft/mod/TexturePackFolderModel.h | 4 +- launcher/ui/pages/modplatform/ModModel.cpp | 12 ++++++ launcher/ui/pages/modplatform/ModModel.h | 1 + .../ui/pages/modplatform/ResourceModel.cpp | 3 ++ launcher/ui/pages/modplatform/ResourceModel.h | 2 + .../ui/pages/modplatform/flame/FlameModel.cpp | 2 + .../modplatform/modrinth/ModrinthModel.cpp | 2 + launcher/ui/widgets/ProjectItem.cpp | 5 +++ launcher/ui/widgets/ProjectItem.h | 3 +- 21 files changed, 67 insertions(+), 51 deletions(-) diff --git a/launcher/minecraft/MinecraftInstance.cpp b/launcher/minecraft/MinecraftInstance.cpp index 2c624a365..76ff5723c 100644 --- a/launcher/minecraft/MinecraftInstance.cpp +++ b/launcher/minecraft/MinecraftInstance.cpp @@ -1109,10 +1109,9 @@ JavaVersion MinecraftInstance::getJavaVersion() return JavaVersion(settings()->get("JavaVersion").toString()); } -std::shared_ptr MinecraftInstance::loaderModList() +std::shared_ptr MinecraftInstance::loaderModList() const { - if (!m_loader_mod_list) - { + if (!m_loader_mod_list) { bool is_indexed = !APPLICATION->settings()->get("ModMetadataDisabled").toBool(); m_loader_mod_list.reset(new ModFolderModel(modsRoot(), this, is_indexed)); m_loader_mod_list->disableInteraction(isRunning()); @@ -1121,10 +1120,9 @@ std::shared_ptr MinecraftInstance::loaderModList() return m_loader_mod_list; } -std::shared_ptr MinecraftInstance::coreModList() +std::shared_ptr MinecraftInstance::coreModList() const { - if (!m_core_mod_list) - { + if (!m_core_mod_list) { bool is_indexed = !APPLICATION->settings()->get("ModMetadataDisabled").toBool(); m_core_mod_list.reset(new ModFolderModel(coreModsDir(), this, is_indexed)); m_core_mod_list->disableInteraction(isRunning()); @@ -1133,10 +1131,9 @@ std::shared_ptr MinecraftInstance::coreModList() return m_core_mod_list; } -std::shared_ptr MinecraftInstance::nilModList() +std::shared_ptr MinecraftInstance::nilModList() const { - if (!m_nil_mod_list) - { + if (!m_nil_mod_list) { bool is_indexed = !APPLICATION->settings()->get("ModMetadataDisabled").toBool(); m_nil_mod_list.reset(new ModFolderModel(nilModsDir(), this, is_indexed, false)); m_nil_mod_list->disableInteraction(isRunning()); @@ -1145,46 +1142,41 @@ std::shared_ptr MinecraftInstance::nilModList() return m_nil_mod_list; } -std::shared_ptr MinecraftInstance::resourcePackList() +std::shared_ptr MinecraftInstance::resourcePackList() const { - if (!m_resource_pack_list) - { + if (!m_resource_pack_list) { m_resource_pack_list.reset(new ResourcePackFolderModel(resourcePacksDir(), this)); } return m_resource_pack_list; } -std::shared_ptr MinecraftInstance::texturePackList() +std::shared_ptr MinecraftInstance::texturePackList() const { - if (!m_texture_pack_list) - { + if (!m_texture_pack_list) { m_texture_pack_list.reset(new TexturePackFolderModel(texturePacksDir(), this)); } return m_texture_pack_list; } -std::shared_ptr MinecraftInstance::shaderPackList() +std::shared_ptr MinecraftInstance::shaderPackList() const { - if (!m_shader_pack_list) - { + if (!m_shader_pack_list) { m_shader_pack_list.reset(new ShaderPackFolderModel(shaderPacksDir(), this)); } return m_shader_pack_list; } -std::shared_ptr MinecraftInstance::worldList() +std::shared_ptr MinecraftInstance::worldList() const { - if (!m_world_list) - { + if (!m_world_list) { m_world_list.reset(new WorldList(worldDir(), this)); } return m_world_list; } -std::shared_ptr MinecraftInstance::gameOptionsModel() +std::shared_ptr MinecraftInstance::gameOptionsModel() const { - if (!m_game_options) - { + if (!m_game_options) { m_game_options.reset(new GameOptions(FS::PathCombine(gameRoot(), "options.txt"))); } return m_game_options; diff --git a/launcher/minecraft/MinecraftInstance.h b/launcher/minecraft/MinecraftInstance.h index 068b30082..a75fa4813 100644 --- a/launcher/minecraft/MinecraftInstance.h +++ b/launcher/minecraft/MinecraftInstance.h @@ -115,14 +115,14 @@ public: std::shared_ptr getPackProfile() const; ////// Mod Lists ////// - std::shared_ptr loaderModList(); - std::shared_ptr coreModList(); - std::shared_ptr nilModList(); - std::shared_ptr resourcePackList(); - std::shared_ptr texturePackList(); - std::shared_ptr shaderPackList(); - std::shared_ptr worldList(); - std::shared_ptr gameOptionsModel(); + std::shared_ptr loaderModList() const; + std::shared_ptr coreModList() const; + std::shared_ptr nilModList() const; + std::shared_ptr resourcePackList() const; + std::shared_ptr texturePackList() const; + std::shared_ptr shaderPackList() const; + std::shared_ptr worldList() const; + std::shared_ptr gameOptionsModel() const; ////// Launch stuff ////// Task::Ptr createUpdateTask(Net::Mode mode) override; diff --git a/launcher/minecraft/WorldList.cpp b/launcher/minecraft/WorldList.cpp index 0feee2999..42772df5a 100644 --- a/launcher/minecraft/WorldList.cpp +++ b/launcher/minecraft/WorldList.cpp @@ -45,8 +45,7 @@ #include #include -WorldList::WorldList(const QString &dir, BaseInstance* instance) - : QAbstractListModel(), m_instance(instance), m_dir(dir) +WorldList::WorldList(const QString& dir, const BaseInstance* instance) : QAbstractListModel(), m_instance(instance), m_dir(dir) { FS::ensureFolderPathExists(m_dir.absolutePath()); m_dir.setFilter(QDir::Readable | QDir::NoDotAndDotDot | QDir::Files | QDir::Dirs); diff --git a/launcher/minecraft/WorldList.h b/launcher/minecraft/WorldList.h index 96b64193f..92d02b9be 100644 --- a/launcher/minecraft/WorldList.h +++ b/launcher/minecraft/WorldList.h @@ -50,7 +50,7 @@ public: IconFileRole }; - WorldList(const QString &dir, BaseInstance* instance); + WorldList(const QString& dir, const BaseInstance* instance); virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; @@ -128,7 +128,7 @@ signals: void changed(); protected: - BaseInstance* m_instance; + const BaseInstance* m_instance; QFileSystemWatcher *m_watcher; bool is_watching; QDir m_dir; diff --git a/launcher/minecraft/mod/ModFolderModel.cpp b/launcher/minecraft/mod/ModFolderModel.cpp index 5e3b31e08..eccfe4aea 100644 --- a/launcher/minecraft/mod/ModFolderModel.cpp +++ b/launcher/minecraft/mod/ModFolderModel.cpp @@ -54,7 +54,7 @@ #include "minecraft/mod/tasks/ModFolderLoadTask.h" #include "modplatform/ModIndex.h" -ModFolderModel::ModFolderModel(const QString& dir, BaseInstance* instance, bool is_indexed, bool create_dir) +ModFolderModel::ModFolderModel(const QString& dir, const BaseInstance* instance, bool is_indexed, bool create_dir) : ResourceFolderModel(QDir(dir), instance, nullptr, create_dir), m_is_indexed(is_indexed) { m_column_sort_keys = { SortType::ENABLED, SortType::NAME, SortType::VERSION, SortType::DATE, SortType::PROVIDER }; diff --git a/launcher/minecraft/mod/ModFolderModel.h b/launcher/minecraft/mod/ModFolderModel.h index d337fe296..261a007a5 100644 --- a/launcher/minecraft/mod/ModFolderModel.h +++ b/launcher/minecraft/mod/ModFolderModel.h @@ -75,7 +75,7 @@ public: Enable, Toggle }; - ModFolderModel(const QString &dir, BaseInstance* instance, bool is_indexed = false, bool create_dir = true); + ModFolderModel(const QString& dir, const BaseInstance* instance, bool is_indexed = false, bool create_dir = true); QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; diff --git a/launcher/minecraft/mod/ResourceFolderModel.cpp b/launcher/minecraft/mod/ResourceFolderModel.cpp index d2d875e48..5664ea859 100644 --- a/launcher/minecraft/mod/ResourceFolderModel.cpp +++ b/launcher/minecraft/mod/ResourceFolderModel.cpp @@ -16,7 +16,7 @@ #include "tasks/Task.h" -ResourceFolderModel::ResourceFolderModel(QDir dir, BaseInstance* instance, QObject* parent, bool create_dir) +ResourceFolderModel::ResourceFolderModel(QDir dir, const BaseInstance* instance, QObject* parent, bool create_dir) : QAbstractListModel(parent), m_dir(dir), m_instance(instance), m_watcher(this) { if (create_dir) { diff --git a/launcher/minecraft/mod/ResourceFolderModel.h b/launcher/minecraft/mod/ResourceFolderModel.h index 0a35e1bca..d853b4434 100644 --- a/launcher/minecraft/mod/ResourceFolderModel.h +++ b/launcher/minecraft/mod/ResourceFolderModel.h @@ -26,7 +26,7 @@ class QSortFilterProxyModel; class ResourceFolderModel : public QAbstractListModel { Q_OBJECT public: - ResourceFolderModel(QDir, BaseInstance* instance, QObject* parent = nullptr, bool create_dir = true); + ResourceFolderModel(QDir, const BaseInstance* instance, QObject* parent = nullptr, bool create_dir = true); ~ResourceFolderModel() override; /** Starts watching the paths for changes. @@ -191,7 +191,7 @@ class ResourceFolderModel : public QAbstractListModel { bool m_can_interact = true; QDir m_dir; - BaseInstance* m_instance; + const BaseInstance* m_instance; QFileSystemWatcher m_watcher; bool m_is_watching = false; diff --git a/launcher/minecraft/mod/ResourcePackFolderModel.cpp b/launcher/minecraft/mod/ResourcePackFolderModel.cpp index c12d1f237..8036292ba 100644 --- a/launcher/minecraft/mod/ResourcePackFolderModel.cpp +++ b/launcher/minecraft/mod/ResourcePackFolderModel.cpp @@ -45,7 +45,7 @@ #include "minecraft/mod/tasks/BasicFolderLoadTask.h" #include "minecraft/mod/tasks/LocalResourcePackParseTask.h" -ResourcePackFolderModel::ResourcePackFolderModel(const QString& dir, BaseInstance* instance) +ResourcePackFolderModel::ResourcePackFolderModel(const QString& dir, const BaseInstance* instance) : ResourceFolderModel(QDir(dir), instance) { m_column_sort_keys = { SortType::ENABLED, SortType::NAME, SortType::PACK_FORMAT, SortType::DATE }; diff --git a/launcher/minecraft/mod/ResourcePackFolderModel.h b/launcher/minecraft/mod/ResourcePackFolderModel.h index db4b14fb0..9d96253a2 100644 --- a/launcher/minecraft/mod/ResourcePackFolderModel.h +++ b/launcher/minecraft/mod/ResourcePackFolderModel.h @@ -17,7 +17,7 @@ public: NUM_COLUMNS }; - explicit ResourcePackFolderModel(const QString &dir, BaseInstance* instance); + explicit ResourcePackFolderModel(const QString& dir, const BaseInstance* instance); [[nodiscard]] QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; diff --git a/launcher/minecraft/mod/ShaderPackFolderModel.h b/launcher/minecraft/mod/ShaderPackFolderModel.h index dc5acf80f..c05bec1d3 100644 --- a/launcher/minecraft/mod/ShaderPackFolderModel.h +++ b/launcher/minecraft/mod/ShaderPackFolderModel.h @@ -6,7 +6,5 @@ class ShaderPackFolderModel : public ResourceFolderModel { Q_OBJECT public: - explicit ShaderPackFolderModel(const QString& dir, BaseInstance* instance) - : ResourceFolderModel(QDir(dir), instance) - {} + explicit ShaderPackFolderModel(const QString& dir, const BaseInstance* instance) : ResourceFolderModel(QDir(dir), instance) {} }; diff --git a/launcher/minecraft/mod/TexturePackFolderModel.cpp b/launcher/minecraft/mod/TexturePackFolderModel.cpp index c6609ed1e..dadf8f77d 100644 --- a/launcher/minecraft/mod/TexturePackFolderModel.cpp +++ b/launcher/minecraft/mod/TexturePackFolderModel.cpp @@ -39,8 +39,7 @@ #include "minecraft/mod/tasks/BasicFolderLoadTask.h" #include "minecraft/mod/tasks/LocalTexturePackParseTask.h" -TexturePackFolderModel::TexturePackFolderModel(const QString& dir, BaseInstance* instance) - : ResourceFolderModel(QDir(dir), instance) +TexturePackFolderModel::TexturePackFolderModel(const QString& dir, const BaseInstance* instance) : ResourceFolderModel(QDir(dir), instance) {} Task* TexturePackFolderModel::createUpdateTask() diff --git a/launcher/minecraft/mod/TexturePackFolderModel.h b/launcher/minecraft/mod/TexturePackFolderModel.h index 425a71e46..a1492f8b4 100644 --- a/launcher/minecraft/mod/TexturePackFolderModel.h +++ b/launcher/minecraft/mod/TexturePackFolderModel.h @@ -42,8 +42,8 @@ class TexturePackFolderModel : public ResourceFolderModel { Q_OBJECT -public: - explicit TexturePackFolderModel(const QString &dir, BaseInstance* instance); + public: + explicit TexturePackFolderModel(const QString& dir, const BaseInstance* instance); [[nodiscard]] Task* createUpdateTask() override; [[nodiscard]] Task* createParseTask(Resource&) override; }; diff --git a/launcher/ui/pages/modplatform/ModModel.cpp b/launcher/ui/pages/modplatform/ModModel.cpp index afd8b2921..1579bbf4c 100644 --- a/launcher/ui/pages/modplatform/ModModel.cpp +++ b/launcher/ui/pages/modplatform/ModModel.cpp @@ -6,8 +6,10 @@ #include "minecraft/MinecraftInstance.h" #include "minecraft/PackProfile.h" +#include "minecraft/mod/ModFolderModel.h" #include +#include namespace ResourceDownload { @@ -67,4 +69,14 @@ void ModModel::searchWithTerm(const QString& term, unsigned int sort, bool filte refresh(); } +bool ModModel::isPackInstalled(ModPlatform::IndexedPack::Ptr pack) const +{ + auto allMods = static_cast(m_base_instance).loaderModList()->allMods(); + return std::any_of(allMods.cbegin(), allMods.cend(), [pack](Mod* mod) { + if (auto meta = mod->metadata(); meta) + return meta->provider == pack->provider && meta->project_id == pack->addonId; + return false; + }); +} + } // namespace ResourceDownload diff --git a/launcher/ui/pages/modplatform/ModModel.h b/launcher/ui/pages/modplatform/ModModel.h index 5d4a77859..938ce32ea 100644 --- a/launcher/ui/pages/modplatform/ModModel.h +++ b/launcher/ui/pages/modplatform/ModModel.h @@ -42,6 +42,7 @@ class ModModel : public ResourceModel { protected: auto documentToArray(QJsonDocument& obj) const -> QJsonArray override = 0; + virtual bool isPackInstalled(ModPlatform::IndexedPack::Ptr) const override; protected: const BaseInstance& m_base_instance; diff --git a/launcher/ui/pages/modplatform/ResourceModel.cpp b/launcher/ui/pages/modplatform/ResourceModel.cpp index a5ea1ca9f..49405a02b 100644 --- a/launcher/ui/pages/modplatform/ResourceModel.cpp +++ b/launcher/ui/pages/modplatform/ResourceModel.cpp @@ -77,6 +77,8 @@ auto ResourceModel::data(const QModelIndex& index, int role) const -> QVariant return pack->description; case UserDataTypes::SELECTED: return pack->isAnyVersionSelected(); + case UserDataTypes::INSTALLED: + return this->isPackInstalled(pack); default: break; } @@ -95,6 +97,7 @@ QHash ResourceModel::roleNames() const roles[UserDataTypes::TITLE] = "title"; roles[UserDataTypes::DESCRIPTION] = "description"; roles[UserDataTypes::SELECTED] = "selected"; + roles[UserDataTypes::INSTALLED] = "installed"; return roles; } diff --git a/launcher/ui/pages/modplatform/ResourceModel.h b/launcher/ui/pages/modplatform/ResourceModel.h index 69e234730..6533d9c6a 100644 --- a/launcher/ui/pages/modplatform/ResourceModel.h +++ b/launcher/ui/pages/modplatform/ResourceModel.h @@ -116,6 +116,8 @@ class ResourceModel : public QAbstractListModel { virtual void loadExtraPackInfo(ModPlatform::IndexedPack&, QJsonObject&); virtual void loadIndexedPackVersions(ModPlatform::IndexedPack&, QJsonArray&); + virtual bool isPackInstalled(ModPlatform::IndexedPack::Ptr) const { return false; } + protected: /* Basic search parameters */ enum class SearchState { None, CanFetchMore, ResetRequested, Finished } m_search_state = SearchState::None; diff --git a/launcher/ui/pages/modplatform/flame/FlameModel.cpp b/launcher/ui/pages/modplatform/flame/FlameModel.cpp index 5961ea026..d9d5ef5b3 100644 --- a/launcher/ui/pages/modplatform/flame/FlameModel.cpp +++ b/launcher/ui/pages/modplatform/flame/FlameModel.cpp @@ -60,6 +60,8 @@ QVariant ListModel::data(const QModelIndex& index, int role) const return pack.description; case UserDataTypes::SELECTED: return false; + case UserDataTypes::INSTALLED: + return false; default: break; } diff --git a/launcher/ui/pages/modplatform/modrinth/ModrinthModel.cpp b/launcher/ui/pages/modplatform/modrinth/ModrinthModel.cpp index 346a00b0e..55d287b09 100644 --- a/launcher/ui/pages/modplatform/modrinth/ModrinthModel.cpp +++ b/launcher/ui/pages/modplatform/modrinth/ModrinthModel.cpp @@ -106,6 +106,8 @@ auto ModpackListModel::data(const QModelIndex& index, int role) const -> QVarian return pack.description; case UserDataTypes::SELECTED: return false; + case UserDataTypes::INSTALLED: + return false; default: break; } diff --git a/launcher/ui/widgets/ProjectItem.cpp b/launcher/ui/widgets/ProjectItem.cpp index d1ff9dbc0..e8349c106 100644 --- a/launcher/ui/widgets/ProjectItem.cpp +++ b/launcher/ui/widgets/ProjectItem.cpp @@ -64,6 +64,11 @@ void ProjectItemDelegate::paint(QPainter* painter, const QStyleOptionViewItem& o font.setBold(true); font.setUnderline(true); } + if (index.data(UserDataTypes::INSTALLED).toBool()) { + // Set nice font + font.setItalic(true); + font.setOverline(true); + } font.setPointSize(font.pointSize() + 2); painter->setFont(font); diff --git a/launcher/ui/widgets/ProjectItem.h b/launcher/ui/widgets/ProjectItem.h index f668edf66..196055ea4 100644 --- a/launcher/ui/widgets/ProjectItem.h +++ b/launcher/ui/widgets/ProjectItem.h @@ -6,7 +6,8 @@ enum UserDataTypes { TITLE = 257, // QString DESCRIPTION = 258, // QString - SELECTED = 259 // bool + SELECTED = 259, // bool + INSTALLED = 260 // bool }; /** This is an item delegate composed of: From b7d82354cbf4d13c428555c5625db183dffd15d7 Mon Sep 17 00:00:00 2001 From: TheKodeToad Date: Sat, 10 Jun 2023 14:42:27 +0100 Subject: [PATCH 12/35] [ci skip] License headers!! (yay) Signed-off-by: TheKodeToad --- launcher/java/JavaInstallList.cpp | 3 ++- launcher/ui/widgets/VersionListView.cpp | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/launcher/java/JavaInstallList.cpp b/launcher/java/JavaInstallList.cpp index 04eb2e0f3..3407fdf72 100644 --- a/launcher/java/JavaInstallList.cpp +++ b/launcher/java/JavaInstallList.cpp @@ -1,7 +1,8 @@ // SPDX-License-Identifier: GPL-3.0-only /* - * PolyMC - Minecraft Launcher + * Prism Launcher - Minecraft Launcher * Copyright (C) 2022 Sefa Eyeoglu + * Copyright (C) 2023 TheKodeToad * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/launcher/ui/widgets/VersionListView.cpp b/launcher/ui/widgets/VersionListView.cpp index 69f881552..06e58d221 100644 --- a/launcher/ui/widgets/VersionListView.cpp +++ b/launcher/ui/widgets/VersionListView.cpp @@ -1,7 +1,8 @@ // SPDX-License-Identifier: GPL-3.0-only /* - * PolyMC - Minecraft Launcher + * Prism Launcher - Minecraft Launcher * Copyright (C) 2022 Sefa Eyeoglu + * Copyright (C) 2023 TheKodeToad * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by From ae9e8dbafd457ef5be2b02529647c8b974488f7a Mon Sep 17 00:00:00 2001 From: Trial97 Date: Sat, 10 Jun 2023 22:04:08 +0300 Subject: [PATCH 13/35] Removed const specification Signed-off-by: Trial97 --- launcher/minecraft/MinecraftInstance.cpp | 40 +++++++++++-------- launcher/minecraft/MinecraftInstance.h | 16 ++++---- launcher/minecraft/WorldList.cpp | 3 +- launcher/minecraft/WorldList.h | 4 +- launcher/minecraft/mod/ModFolderModel.cpp | 2 +- launcher/minecraft/mod/ModFolderModel.h | 2 +- .../minecraft/mod/ResourceFolderModel.cpp | 2 +- launcher/minecraft/mod/ResourceFolderModel.h | 4 +- .../minecraft/mod/ResourcePackFolderModel.cpp | 2 +- .../minecraft/mod/ResourcePackFolderModel.h | 2 +- .../minecraft/mod/ShaderPackFolderModel.h | 4 +- .../minecraft/mod/TexturePackFolderModel.cpp | 3 +- .../minecraft/mod/TexturePackFolderModel.h | 4 +- launcher/ui/pages/modplatform/ModModel.cpp | 6 +-- launcher/ui/pages/modplatform/ModModel.h | 4 +- .../modplatform/flame/FlameResourceModels.cpp | 2 +- .../modplatform/flame/FlameResourceModels.h | 2 +- .../modrinth/ModrinthResourceModels.cpp | 2 +- .../modrinth/ModrinthResourceModels.h | 2 +- 19 files changed, 59 insertions(+), 47 deletions(-) diff --git a/launcher/minecraft/MinecraftInstance.cpp b/launcher/minecraft/MinecraftInstance.cpp index 76ff5723c..2c624a365 100644 --- a/launcher/minecraft/MinecraftInstance.cpp +++ b/launcher/minecraft/MinecraftInstance.cpp @@ -1109,9 +1109,10 @@ JavaVersion MinecraftInstance::getJavaVersion() return JavaVersion(settings()->get("JavaVersion").toString()); } -std::shared_ptr MinecraftInstance::loaderModList() const +std::shared_ptr MinecraftInstance::loaderModList() { - if (!m_loader_mod_list) { + if (!m_loader_mod_list) + { bool is_indexed = !APPLICATION->settings()->get("ModMetadataDisabled").toBool(); m_loader_mod_list.reset(new ModFolderModel(modsRoot(), this, is_indexed)); m_loader_mod_list->disableInteraction(isRunning()); @@ -1120,9 +1121,10 @@ std::shared_ptr MinecraftInstance::loaderModList() const return m_loader_mod_list; } -std::shared_ptr MinecraftInstance::coreModList() const +std::shared_ptr MinecraftInstance::coreModList() { - if (!m_core_mod_list) { + if (!m_core_mod_list) + { bool is_indexed = !APPLICATION->settings()->get("ModMetadataDisabled").toBool(); m_core_mod_list.reset(new ModFolderModel(coreModsDir(), this, is_indexed)); m_core_mod_list->disableInteraction(isRunning()); @@ -1131,9 +1133,10 @@ std::shared_ptr MinecraftInstance::coreModList() const return m_core_mod_list; } -std::shared_ptr MinecraftInstance::nilModList() const +std::shared_ptr MinecraftInstance::nilModList() { - if (!m_nil_mod_list) { + if (!m_nil_mod_list) + { bool is_indexed = !APPLICATION->settings()->get("ModMetadataDisabled").toBool(); m_nil_mod_list.reset(new ModFolderModel(nilModsDir(), this, is_indexed, false)); m_nil_mod_list->disableInteraction(isRunning()); @@ -1142,41 +1145,46 @@ std::shared_ptr MinecraftInstance::nilModList() const return m_nil_mod_list; } -std::shared_ptr MinecraftInstance::resourcePackList() const +std::shared_ptr MinecraftInstance::resourcePackList() { - if (!m_resource_pack_list) { + if (!m_resource_pack_list) + { m_resource_pack_list.reset(new ResourcePackFolderModel(resourcePacksDir(), this)); } return m_resource_pack_list; } -std::shared_ptr MinecraftInstance::texturePackList() const +std::shared_ptr MinecraftInstance::texturePackList() { - if (!m_texture_pack_list) { + if (!m_texture_pack_list) + { m_texture_pack_list.reset(new TexturePackFolderModel(texturePacksDir(), this)); } return m_texture_pack_list; } -std::shared_ptr MinecraftInstance::shaderPackList() const +std::shared_ptr MinecraftInstance::shaderPackList() { - if (!m_shader_pack_list) { + if (!m_shader_pack_list) + { m_shader_pack_list.reset(new ShaderPackFolderModel(shaderPacksDir(), this)); } return m_shader_pack_list; } -std::shared_ptr MinecraftInstance::worldList() const +std::shared_ptr MinecraftInstance::worldList() { - if (!m_world_list) { + if (!m_world_list) + { m_world_list.reset(new WorldList(worldDir(), this)); } return m_world_list; } -std::shared_ptr MinecraftInstance::gameOptionsModel() const +std::shared_ptr MinecraftInstance::gameOptionsModel() { - if (!m_game_options) { + if (!m_game_options) + { m_game_options.reset(new GameOptions(FS::PathCombine(gameRoot(), "options.txt"))); } return m_game_options; diff --git a/launcher/minecraft/MinecraftInstance.h b/launcher/minecraft/MinecraftInstance.h index a75fa4813..068b30082 100644 --- a/launcher/minecraft/MinecraftInstance.h +++ b/launcher/minecraft/MinecraftInstance.h @@ -115,14 +115,14 @@ public: std::shared_ptr getPackProfile() const; ////// Mod Lists ////// - std::shared_ptr loaderModList() const; - std::shared_ptr coreModList() const; - std::shared_ptr nilModList() const; - std::shared_ptr resourcePackList() const; - std::shared_ptr texturePackList() const; - std::shared_ptr shaderPackList() const; - std::shared_ptr worldList() const; - std::shared_ptr gameOptionsModel() const; + std::shared_ptr loaderModList(); + std::shared_ptr coreModList(); + std::shared_ptr nilModList(); + std::shared_ptr resourcePackList(); + std::shared_ptr texturePackList(); + std::shared_ptr shaderPackList(); + std::shared_ptr worldList(); + std::shared_ptr gameOptionsModel(); ////// Launch stuff ////// Task::Ptr createUpdateTask(Net::Mode mode) override; diff --git a/launcher/minecraft/WorldList.cpp b/launcher/minecraft/WorldList.cpp index 42772df5a..0feee2999 100644 --- a/launcher/minecraft/WorldList.cpp +++ b/launcher/minecraft/WorldList.cpp @@ -45,7 +45,8 @@ #include #include -WorldList::WorldList(const QString& dir, const BaseInstance* instance) : QAbstractListModel(), m_instance(instance), m_dir(dir) +WorldList::WorldList(const QString &dir, BaseInstance* instance) + : QAbstractListModel(), m_instance(instance), m_dir(dir) { FS::ensureFolderPathExists(m_dir.absolutePath()); m_dir.setFilter(QDir::Readable | QDir::NoDotAndDotDot | QDir::Files | QDir::Dirs); diff --git a/launcher/minecraft/WorldList.h b/launcher/minecraft/WorldList.h index 92d02b9be..96b64193f 100644 --- a/launcher/minecraft/WorldList.h +++ b/launcher/minecraft/WorldList.h @@ -50,7 +50,7 @@ public: IconFileRole }; - WorldList(const QString& dir, const BaseInstance* instance); + WorldList(const QString &dir, BaseInstance* instance); virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; @@ -128,7 +128,7 @@ signals: void changed(); protected: - const BaseInstance* m_instance; + BaseInstance* m_instance; QFileSystemWatcher *m_watcher; bool is_watching; QDir m_dir; diff --git a/launcher/minecraft/mod/ModFolderModel.cpp b/launcher/minecraft/mod/ModFolderModel.cpp index eccfe4aea..5e3b31e08 100644 --- a/launcher/minecraft/mod/ModFolderModel.cpp +++ b/launcher/minecraft/mod/ModFolderModel.cpp @@ -54,7 +54,7 @@ #include "minecraft/mod/tasks/ModFolderLoadTask.h" #include "modplatform/ModIndex.h" -ModFolderModel::ModFolderModel(const QString& dir, const BaseInstance* instance, bool is_indexed, bool create_dir) +ModFolderModel::ModFolderModel(const QString& dir, BaseInstance* instance, bool is_indexed, bool create_dir) : ResourceFolderModel(QDir(dir), instance, nullptr, create_dir), m_is_indexed(is_indexed) { m_column_sort_keys = { SortType::ENABLED, SortType::NAME, SortType::VERSION, SortType::DATE, SortType::PROVIDER }; diff --git a/launcher/minecraft/mod/ModFolderModel.h b/launcher/minecraft/mod/ModFolderModel.h index 261a007a5..d337fe296 100644 --- a/launcher/minecraft/mod/ModFolderModel.h +++ b/launcher/minecraft/mod/ModFolderModel.h @@ -75,7 +75,7 @@ public: Enable, Toggle }; - ModFolderModel(const QString& dir, const BaseInstance* instance, bool is_indexed = false, bool create_dir = true); + ModFolderModel(const QString &dir, BaseInstance* instance, bool is_indexed = false, bool create_dir = true); QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; diff --git a/launcher/minecraft/mod/ResourceFolderModel.cpp b/launcher/minecraft/mod/ResourceFolderModel.cpp index 5664ea859..d2d875e48 100644 --- a/launcher/minecraft/mod/ResourceFolderModel.cpp +++ b/launcher/minecraft/mod/ResourceFolderModel.cpp @@ -16,7 +16,7 @@ #include "tasks/Task.h" -ResourceFolderModel::ResourceFolderModel(QDir dir, const BaseInstance* instance, QObject* parent, bool create_dir) +ResourceFolderModel::ResourceFolderModel(QDir dir, BaseInstance* instance, QObject* parent, bool create_dir) : QAbstractListModel(parent), m_dir(dir), m_instance(instance), m_watcher(this) { if (create_dir) { diff --git a/launcher/minecraft/mod/ResourceFolderModel.h b/launcher/minecraft/mod/ResourceFolderModel.h index d853b4434..0a35e1bca 100644 --- a/launcher/minecraft/mod/ResourceFolderModel.h +++ b/launcher/minecraft/mod/ResourceFolderModel.h @@ -26,7 +26,7 @@ class QSortFilterProxyModel; class ResourceFolderModel : public QAbstractListModel { Q_OBJECT public: - ResourceFolderModel(QDir, const BaseInstance* instance, QObject* parent = nullptr, bool create_dir = true); + ResourceFolderModel(QDir, BaseInstance* instance, QObject* parent = nullptr, bool create_dir = true); ~ResourceFolderModel() override; /** Starts watching the paths for changes. @@ -191,7 +191,7 @@ class ResourceFolderModel : public QAbstractListModel { bool m_can_interact = true; QDir m_dir; - const BaseInstance* m_instance; + BaseInstance* m_instance; QFileSystemWatcher m_watcher; bool m_is_watching = false; diff --git a/launcher/minecraft/mod/ResourcePackFolderModel.cpp b/launcher/minecraft/mod/ResourcePackFolderModel.cpp index 8036292ba..c12d1f237 100644 --- a/launcher/minecraft/mod/ResourcePackFolderModel.cpp +++ b/launcher/minecraft/mod/ResourcePackFolderModel.cpp @@ -45,7 +45,7 @@ #include "minecraft/mod/tasks/BasicFolderLoadTask.h" #include "minecraft/mod/tasks/LocalResourcePackParseTask.h" -ResourcePackFolderModel::ResourcePackFolderModel(const QString& dir, const BaseInstance* instance) +ResourcePackFolderModel::ResourcePackFolderModel(const QString& dir, BaseInstance* instance) : ResourceFolderModel(QDir(dir), instance) { m_column_sort_keys = { SortType::ENABLED, SortType::NAME, SortType::PACK_FORMAT, SortType::DATE }; diff --git a/launcher/minecraft/mod/ResourcePackFolderModel.h b/launcher/minecraft/mod/ResourcePackFolderModel.h index 9d96253a2..db4b14fb0 100644 --- a/launcher/minecraft/mod/ResourcePackFolderModel.h +++ b/launcher/minecraft/mod/ResourcePackFolderModel.h @@ -17,7 +17,7 @@ public: NUM_COLUMNS }; - explicit ResourcePackFolderModel(const QString& dir, const BaseInstance* instance); + explicit ResourcePackFolderModel(const QString &dir, BaseInstance* instance); [[nodiscard]] QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; diff --git a/launcher/minecraft/mod/ShaderPackFolderModel.h b/launcher/minecraft/mod/ShaderPackFolderModel.h index c05bec1d3..dc5acf80f 100644 --- a/launcher/minecraft/mod/ShaderPackFolderModel.h +++ b/launcher/minecraft/mod/ShaderPackFolderModel.h @@ -6,5 +6,7 @@ class ShaderPackFolderModel : public ResourceFolderModel { Q_OBJECT public: - explicit ShaderPackFolderModel(const QString& dir, const BaseInstance* instance) : ResourceFolderModel(QDir(dir), instance) {} + explicit ShaderPackFolderModel(const QString& dir, BaseInstance* instance) + : ResourceFolderModel(QDir(dir), instance) + {} }; diff --git a/launcher/minecraft/mod/TexturePackFolderModel.cpp b/launcher/minecraft/mod/TexturePackFolderModel.cpp index dadf8f77d..c6609ed1e 100644 --- a/launcher/minecraft/mod/TexturePackFolderModel.cpp +++ b/launcher/minecraft/mod/TexturePackFolderModel.cpp @@ -39,7 +39,8 @@ #include "minecraft/mod/tasks/BasicFolderLoadTask.h" #include "minecraft/mod/tasks/LocalTexturePackParseTask.h" -TexturePackFolderModel::TexturePackFolderModel(const QString& dir, const BaseInstance* instance) : ResourceFolderModel(QDir(dir), instance) +TexturePackFolderModel::TexturePackFolderModel(const QString& dir, BaseInstance* instance) + : ResourceFolderModel(QDir(dir), instance) {} Task* TexturePackFolderModel::createUpdateTask() diff --git a/launcher/minecraft/mod/TexturePackFolderModel.h b/launcher/minecraft/mod/TexturePackFolderModel.h index a1492f8b4..425a71e46 100644 --- a/launcher/minecraft/mod/TexturePackFolderModel.h +++ b/launcher/minecraft/mod/TexturePackFolderModel.h @@ -42,8 +42,8 @@ class TexturePackFolderModel : public ResourceFolderModel { Q_OBJECT - public: - explicit TexturePackFolderModel(const QString& dir, const BaseInstance* instance); +public: + explicit TexturePackFolderModel(const QString &dir, BaseInstance* instance); [[nodiscard]] Task* createUpdateTask() override; [[nodiscard]] Task* createParseTask(Resource&) override; }; diff --git a/launcher/ui/pages/modplatform/ModModel.cpp b/launcher/ui/pages/modplatform/ModModel.cpp index 1579bbf4c..b75378905 100644 --- a/launcher/ui/pages/modplatform/ModModel.cpp +++ b/launcher/ui/pages/modplatform/ModModel.cpp @@ -13,7 +13,7 @@ namespace ResourceDownload { -ModModel::ModModel(BaseInstance const& base_inst, ResourceAPI* api) : ResourceModel(api), m_base_instance(base_inst) {} +ModModel::ModModel(BaseInstance& base_inst, ResourceAPI* api) : ResourceModel(api), m_base_instance(base_inst) {} /******** Make data requests ********/ @@ -26,7 +26,7 @@ ResourceAPI::SearchArgs ModModel::createSearchArguments() std::optional> versions{}; - { // Version filter + { // Version filter if (!m_filter->versions.empty()) versions = m_filter->versions; } @@ -71,7 +71,7 @@ void ModModel::searchWithTerm(const QString& term, unsigned int sort, bool filte bool ModModel::isPackInstalled(ModPlatform::IndexedPack::Ptr pack) const { - auto allMods = static_cast(m_base_instance).loaderModList()->allMods(); + auto allMods = static_cast(m_base_instance).loaderModList()->allMods(); return std::any_of(allMods.cbegin(), allMods.cend(), [pack](Mod* mod) { if (auto meta = mod->metadata(); meta) return meta->provider == pack->provider && meta->project_id == pack->addonId; diff --git a/launcher/ui/pages/modplatform/ModModel.h b/launcher/ui/pages/modplatform/ModModel.h index 938ce32ea..805d8b9ad 100644 --- a/launcher/ui/pages/modplatform/ModModel.h +++ b/launcher/ui/pages/modplatform/ModModel.h @@ -24,7 +24,7 @@ class ModModel : public ResourceModel { Q_OBJECT public: - ModModel(const BaseInstance&, ResourceAPI* api); + ModModel(BaseInstance&, ResourceAPI* api); /* Ask the API for more information */ void searchWithTerm(const QString& term, unsigned int sort, bool filter_changed); @@ -45,7 +45,7 @@ class ModModel : public ResourceModel { virtual bool isPackInstalled(ModPlatform::IndexedPack::Ptr) const override; protected: - const BaseInstance& m_base_instance; + BaseInstance& m_base_instance; std::shared_ptr m_filter = nullptr; }; diff --git a/launcher/ui/pages/modplatform/flame/FlameResourceModels.cpp b/launcher/ui/pages/modplatform/flame/FlameResourceModels.cpp index e3d0bc144..667a52d06 100644 --- a/launcher/ui/pages/modplatform/flame/FlameResourceModels.cpp +++ b/launcher/ui/pages/modplatform/flame/FlameResourceModels.cpp @@ -11,7 +11,7 @@ namespace ResourceDownload { -FlameModModel::FlameModModel(BaseInstance const& base) : ModModel(base, new FlameAPI) {} +FlameModModel::FlameModModel(BaseInstance& base) : ModModel(base, new FlameAPI) {} void FlameModModel::loadIndexedPack(ModPlatform::IndexedPack& m, QJsonObject& obj) { diff --git a/launcher/ui/pages/modplatform/flame/FlameResourceModels.h b/launcher/ui/pages/modplatform/flame/FlameResourceModels.h index 0252ac403..221c8f7a8 100644 --- a/launcher/ui/pages/modplatform/flame/FlameResourceModels.h +++ b/launcher/ui/pages/modplatform/flame/FlameResourceModels.h @@ -14,7 +14,7 @@ class FlameModModel : public ModModel { Q_OBJECT public: - FlameModModel(const BaseInstance&); + FlameModModel(BaseInstance&); ~FlameModModel() override = default; private: diff --git a/launcher/ui/pages/modplatform/modrinth/ModrinthResourceModels.cpp b/launcher/ui/pages/modplatform/modrinth/ModrinthResourceModels.cpp index f5d1cc282..7f8574852 100644 --- a/launcher/ui/pages/modplatform/modrinth/ModrinthResourceModels.cpp +++ b/launcher/ui/pages/modplatform/modrinth/ModrinthResourceModels.cpp @@ -25,7 +25,7 @@ namespace ResourceDownload { -ModrinthModModel::ModrinthModModel(BaseInstance const& base) : ModModel(base, new ModrinthAPI) {} +ModrinthModModel::ModrinthModModel(BaseInstance& base) : ModModel(base, new ModrinthAPI) {} void ModrinthModModel::loadIndexedPack(ModPlatform::IndexedPack& m, QJsonObject& obj) { diff --git a/launcher/ui/pages/modplatform/modrinth/ModrinthResourceModels.h b/launcher/ui/pages/modplatform/modrinth/ModrinthResourceModels.h index b351b19b9..66461807a 100644 --- a/launcher/ui/pages/modplatform/modrinth/ModrinthResourceModels.h +++ b/launcher/ui/pages/modplatform/modrinth/ModrinthResourceModels.h @@ -30,7 +30,7 @@ class ModrinthModModel : public ModModel { Q_OBJECT public: - ModrinthModModel(const BaseInstance&); + ModrinthModModel(BaseInstance&); ~ModrinthModModel() override = default; private: From ad0493390b051c27ee8d16b323a9c71b9d697097 Mon Sep 17 00:00:00 2001 From: seth Date: Sun, 11 Jun 2023 14:02:36 -0400 Subject: [PATCH 14/35] fix(nix): use prismlauncher-unwrapped in devShell Signed-off-by: seth --- nix/dev.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nix/dev.nix b/nix/dev.nix index a4ff2cc49..635c6bb41 100644 --- a/nix/dev.nix +++ b/nix/dev.nix @@ -37,7 +37,7 @@ nil ]; - inputsFrom = [self.packages.${system}.default]; + inputsFrom = [self.packages.${system}.prismlauncher-unwrapped]; buildInputs = with pkgs; [ccache ninja]; }; From d4f2059b78bd53fccb20657d11b3386e427ec795 Mon Sep 17 00:00:00 2001 From: clickdevin Date: Wed, 14 Jun 2023 10:42:37 -0400 Subject: [PATCH 15/35] Fix bugs when updating curseforge modpacks Signed-off-by: clickdevin --- launcher/modplatform/flame/FlameInstanceCreationTask.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/launcher/modplatform/flame/FlameInstanceCreationTask.cpp b/launcher/modplatform/flame/FlameInstanceCreationTask.cpp index dae93d1c6..35443e71c 100644 --- a/launcher/modplatform/flame/FlameInstanceCreationTask.cpp +++ b/launcher/modplatform/flame/FlameInstanceCreationTask.cpp @@ -153,6 +153,9 @@ bool FlameCreationTask::updateInstance() old_files.remove(file.key()); files_iterator = files.erase(files_iterator); + + if (files_iterator != files.begin()) + files_iterator--; } } From e8b0a7c6f02772dbe3fc1a205595f5fa30003ec3 Mon Sep 17 00:00:00 2001 From: seth Date: Wed, 14 Jun 2023 12:45:08 -0400 Subject: [PATCH 16/35] chore: bump to 8.0 Signed-off-by: seth --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6bd12630d..70a553190 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -138,7 +138,7 @@ set(Launcher_NEWS_OPEN_URL "https://prismlauncher.org/news" CACHE STRING "URL th set(Launcher_HELP_URL "https://prismlauncher.org/wiki/help-pages/%1" CACHE STRING "URL (with arg %1 to be substituted with page-id) that gets opened when the user requests help") ######## Set version numbers ######## -set(Launcher_VERSION_MAJOR 7) +set(Launcher_VERSION_MAJOR 8) set(Launcher_VERSION_MINOR 0) set(Launcher_VERSION_NAME "${Launcher_VERSION_MAJOR}.${Launcher_VERSION_MINOR}") From e0b901169aaa5ebc7b74c15cd3f01f08ee98c4f1 Mon Sep 17 00:00:00 2001 From: Trial97 Date: Thu, 15 Jun 2023 00:27:20 +0300 Subject: [PATCH 17/35] Added new migration for special characters Signed-off-by: Trial97 --- launcher/settings/INIFile.cpp | 19 ++++++++-- tests/INIFile_test.cpp | 67 +++++++++++++++++++++++++++++++++-- 2 files changed, 82 insertions(+), 4 deletions(-) diff --git a/launcher/settings/INIFile.cpp b/launcher/settings/INIFile.cpp index cb909ae75..1d2f9611f 100644 --- a/launcher/settings/INIFile.cpp +++ b/launcher/settings/INIFile.cpp @@ -50,7 +50,7 @@ INIFile::INIFile() {} bool INIFile::saveFile(QString fileName) { if (!contains("ConfigVersion")) - insert("ConfigVersion", "1.1"); + insert("ConfigVersion", "1.2"); QSettings _settings_obj{ fileName, QSettings::Format::IniFormat }; _settings_obj.setFallbacksEnabled(false); @@ -125,6 +125,10 @@ bool parseOldFileFormat(QIODevice& device, QSettings::SettingsMap& map) QString valueStr = line.right(line.length() - eqPos - 1).trimmed(); valueStr = unescape(valueStr); + if ((valueStr.contains(QChar(';')) || valueStr.contains(QChar('=')) || valueStr.contains(QChar(','))) && valueStr.endsWith("\"") && + valueStr.startsWith("\"")) { + valueStr = valueStr.removeFirst().removeLast(); + } QVariant value(valueStr); map.insert(key, value); @@ -154,7 +158,18 @@ bool INIFile::loadFile(QString fileName) file.close(); for (auto&& key : map.keys()) insert(key, map.value(key)); - insert("ConfigVersion", "1.1"); + insert("ConfigVersion", "1.2"); + } else if (_settings_obj.value("ConfigVersion").toString() == "1.1") { + for (auto&& key : _settings_obj.allKeys()) { + if (auto valueStr = _settings_obj.value(key).toString(); + (valueStr.contains(QChar(';')) || valueStr.contains(QChar('=')) || valueStr.contains(QChar(','))) && + valueStr.endsWith("\"") && valueStr.startsWith("\"")) { + valueStr = valueStr.removeFirst().removeLast(); + insert(key, valueStr); + } else + insert(key, _settings_obj.value(key)); + } + insert("ConfigVersion", "1.2"); } else for (auto&& key : _settings_obj.allKeys()) insert(key, _settings_obj.value(key)); diff --git a/tests/INIFile_test.cpp b/tests/INIFile_test.cpp index 2f49e573d..5d9c9cd8a 100644 --- a/tests/INIFile_test.cpp +++ b/tests/INIFile_test.cpp @@ -2,7 +2,9 @@ #include #include +#include #include +#include "FileSystem.h" #include @@ -80,7 +82,10 @@ iconKey=vanillia_icon name=Minecraft Vanillia OverrideCommands=true PreLaunchCommand="$INST_JAVA" -jar packwiz-installer-bootstrap.jar link -)"; +Wrapperommand=)"; + fileContent += "\""; + fileContent += +R"(\"$INST_JAVA\" -jar packwiz-installer-bootstrap.jar link =)"; + fileContent += "\"\n"; QFile file(fileName); if (file.open(QFile::WriteOnly | QFile::Text)) { @@ -93,11 +98,69 @@ PreLaunchCommand="$INST_JAVA" -jar packwiz-installer-bootstrap.jar link INIFile f1; f1.loadFile(fileName); QCOMPARE(f1.get("PreLaunchCommand", "NOT SET").toString(), "\"$INST_JAVA\" -jar packwiz-installer-bootstrap.jar link"); + QCOMPARE(f1.get("Wrapperommand", "NOT SET").toString(), "\"$INST_JAVA\" -jar packwiz-installer-bootstrap.jar link ="); f1.saveFile(fileName); INIFile f2; f2.loadFile(fileName); QCOMPARE(f2.get("PreLaunchCommand", "NOT SET").toString(), "\"$INST_JAVA\" -jar packwiz-installer-bootstrap.jar link"); - QCOMPARE(f2.get("ConfigVersion", "NOT SET").toString(), "1.1"); + QCOMPARE(f2.get("Wrapperommand", "NOT SET").toString(), "\"$INST_JAVA\" -jar packwiz-installer-bootstrap.jar link ="); + QCOMPARE(f2.get("ConfigVersion", "NOT SET").toString(), "1.2"); + } + + void test_SaveAleardyExistingFileWithSpecialChars() + { + QString fileName = "test_SaveAleardyExistingFileWithSpecialChars.ini"; + FS::deletePath(fileName); // just to clean the previous test run + QSettings settings{ fileName, QSettings::Format::IniFormat }; + settings.setFallbacksEnabled(false); + + settings.setValue("simple", "value1"); + settings.setValue("withQuotes", R"("value2" with quotes)"); + settings.setValue("withSpecialCharacters", "env mesa=true"); + settings.setValue("withSpecialCharacters2", "1,2,3,4"); + settings.setValue("withSpecialCharacters2", "1;2;3;4"); + settings.setValue("withAll", "val=\"$INST_JAVA\" -jar; ls "); + + settings.sync(); + + QCOMPARE(settings.status(), QSettings::Status::NoError); + + // load + INIFile f1; + f1.loadFile(fileName); + for (auto key : settings.allKeys()) + QCOMPARE(f1.get(key, "NOT SET").toString(), settings.value(key).toString()); + f1.saveFile(fileName); + INIFile f2; + f2.loadFile(fileName); + for (auto key : settings.allKeys()) + QCOMPARE(f2.get(key, "NOT SET").toString(), settings.value(key).toString()); + QCOMPARE(f2.get("ConfigVersion", "NOT SET").toString(), "1.2"); + } + + void test_SaveAleardyExistingFileWithSpecialCharsV1() + { + QString fileName = "test_SaveAleardyExistingFileWithSpecialCharsV1.ini"; + QString fileContent = R"(InstanceType=OneSix +ConfigVersion=1.1 +iconKey=vanillia_icon +name=Minecraft Vanillia +OverrideCommands=true +PreLaunchCommand=)"; + fileContent += "\"\\\"env mesa=true\\\"\"\n"; + QFile file(fileName); + + if (file.open(QFile::WriteOnly | QFile::Text)) { + QTextStream stream(&file); + stream << fileContent; + file.close(); + } + + // load + INIFile f1; + f1.loadFile(fileName); + QCOMPARE(f1.get("PreLaunchCommand", "NOT SET").toString(), "env mesa=true"); + QCOMPARE(f1.get("ConfigVersion", "NOT SET").toString(), "1.2"); } }; From cf4c1605ebe2f1db302928f847398e23236aed16 Mon Sep 17 00:00:00 2001 From: Trial97 Date: Thu, 15 Jun 2023 00:37:32 +0300 Subject: [PATCH 18/35] Fixed qt5 build Signed-off-by: Trial97 --- launcher/settings/INIFile.cpp | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/launcher/settings/INIFile.cpp b/launcher/settings/INIFile.cpp index 1d2f9611f..37846d112 100644 --- a/launcher/settings/INIFile.cpp +++ b/launcher/settings/INIFile.cpp @@ -97,6 +97,20 @@ QString unescape(QString orig) } return out; } + +QString unquete(QString str) +{ + if ((str.contains(QChar(';')) || str.contains(QChar('=')) || str.contains(QChar(','))) && str.endsWith("\"") && str.startsWith("\"")) { +#if QT_VERSION <= QT_VERSION_CHECK(6, 0, 0) + str = str.remove(0, 1); + str = str.remove(str.size() - 1, 1); +#else + str = str.removeFirst().removeLast(); +#endif + } + return str; +} + bool parseOldFileFormat(QIODevice& device, QSettings::SettingsMap& map) { QTextStream in(device.readAll()); @@ -124,11 +138,7 @@ bool parseOldFileFormat(QIODevice& device, QSettings::SettingsMap& map) QString key = line.left(eqPos).trimmed(); QString valueStr = line.right(line.length() - eqPos - 1).trimmed(); - valueStr = unescape(valueStr); - if ((valueStr.contains(QChar(';')) || valueStr.contains(QChar('=')) || valueStr.contains(QChar(','))) && valueStr.endsWith("\"") && - valueStr.startsWith("\"")) { - valueStr = valueStr.removeFirst().removeLast(); - } + valueStr = unquete(unescape(valueStr)); QVariant value(valueStr); map.insert(key, value); @@ -164,8 +174,7 @@ bool INIFile::loadFile(QString fileName) if (auto valueStr = _settings_obj.value(key).toString(); (valueStr.contains(QChar(';')) || valueStr.contains(QChar('=')) || valueStr.contains(QChar(','))) && valueStr.endsWith("\"") && valueStr.startsWith("\"")) { - valueStr = valueStr.removeFirst().removeLast(); - insert(key, valueStr); + insert(key, unquete(valueStr)); } else insert(key, _settings_obj.value(key)); } From 811c79423fa048c5f4dd567b1121630d16aa3b0c Mon Sep 17 00:00:00 2001 From: Trial97 Date: Thu, 15 Jun 2023 00:43:05 +0300 Subject: [PATCH 19/35] Fixed version comparation Signed-off-by: Trial97 --- launcher/settings/INIFile.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/launcher/settings/INIFile.cpp b/launcher/settings/INIFile.cpp index 37846d112..ad600ab91 100644 --- a/launcher/settings/INIFile.cpp +++ b/launcher/settings/INIFile.cpp @@ -101,7 +101,7 @@ QString unescape(QString orig) QString unquete(QString str) { if ((str.contains(QChar(';')) || str.contains(QChar('=')) || str.contains(QChar(','))) && str.endsWith("\"") && str.startsWith("\"")) { -#if QT_VERSION <= QT_VERSION_CHECK(6, 0, 0) +#if QT_VERSION < QT_VERSION_CHECK(6, 5, 0) str = str.remove(0, 1); str = str.remove(str.size() - 1, 1); #else From 6667ff9330cc080ca3c5fc2dd90af6b8420bf3fc Mon Sep 17 00:00:00 2001 From: Trial97 Date: Thu, 15 Jun 2023 12:32:48 +0300 Subject: [PATCH 20/35] Updated text and fixed mod page text update Signed-off-by: Trial97 --- .../pages/instance/ExternalResourcesPage.cpp | 39 ++++++++++++++++++- launcher/ui/pages/instance/ModFolderPage.cpp | 27 +++++-------- 2 files changed, 47 insertions(+), 19 deletions(-) diff --git a/launcher/ui/pages/instance/ExternalResourcesPage.cpp b/launcher/ui/pages/instance/ExternalResourcesPage.cpp index e5567c804..e50fa6353 100644 --- a/launcher/ui/pages/instance/ExternalResourcesPage.cpp +++ b/launcher/ui/pages/instance/ExternalResourcesPage.cpp @@ -1,3 +1,38 @@ +// SPDX-License-Identifier: GPL-3.0-only +/* + * Prism Launcher - Minecraft Launcher + * Copyright (c) 2023 Trial97 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * This file incorporates work covered by the following copyright and + * permission notice: + * + * Copyright 2013-2021 MultiMC Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #include "ExternalResourcesPage.h" #include "ui/dialogs/CustomMessageBox.h" #include "ui_ExternalResourcesPage.h" @@ -264,7 +299,7 @@ QString ExternalResourcesPage::extraHeaderInfoString() if (ui && ui->treeView && ui->treeView->selectionModel()) { auto selection = m_filterModel->mapSelectionToSource(ui->treeView->selectionModel()->selection()).indexes(); if (auto count = std::count_if(selection.cbegin(), selection.cend(), [](auto v) { return v.column() == 0; }); count != 0) - return tr("[%1 installed, %2 selected]").arg(m_model->size()).arg(count); + return tr(" (%1 installed, %2 selected)").arg(m_model->size()).arg(count); } - return tr("[%1 installed]").arg(m_model->size()); + return tr(" (%1 installed)").arg(m_model->size()); } diff --git a/launcher/ui/pages/instance/ModFolderPage.cpp b/launcher/ui/pages/instance/ModFolderPage.cpp index 4548af59a..1d090ef4d 100644 --- a/launcher/ui/pages/instance/ModFolderPage.cpp +++ b/launcher/ui/pages/instance/ModFolderPage.cpp @@ -4,6 +4,7 @@ * Copyright (c) 2022 Jamie Mansfield * Copyright (C) 2022 Sefa Eyeoglu * Copyright (C) 2022 TheKodeToad + * Copyright (c) 2023 Trial97 * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -86,28 +87,20 @@ ModFolderPage::ModFolderPage(BaseInstance* inst, std::shared_ptr connect(ui->actionUpdateItem, &QAction::triggered, this, &ModFolderPage::updateMods); auto check_allow_update = [this] { - return (!m_instance || !m_instance->isRunning()) && - (ui->treeView->selectionModel()->hasSelection() || !m_model->empty()); + return (!m_instance || !m_instance->isRunning()) && (ui->treeView->selectionModel()->hasSelection() || !m_model->empty()); }; - connect(ui->treeView->selectionModel(), &QItemSelectionModel::selectionChanged, this, [this, check_allow_update] { - ui->actionUpdateItem->setEnabled(check_allow_update()); - }); + connect(ui->treeView->selectionModel(), &QItemSelectionModel::selectionChanged, this, + [this, check_allow_update] { ui->actionUpdateItem->setEnabled(check_allow_update()); }); - connect(mods.get(), &ModFolderModel::rowsInserted, this, [this, check_allow_update] { - ui->actionUpdateItem->setEnabled(check_allow_update()); - }); + connect(mods.get(), &ModFolderModel::rowsInserted, this, + [this, check_allow_update] { ui->actionUpdateItem->setEnabled(check_allow_update()); }); - connect(mods.get(), &ModFolderModel::rowsRemoved, this, [this, check_allow_update] { - ui->actionUpdateItem->setEnabled(check_allow_update()); - }); + connect(mods.get(), &ModFolderModel::rowsRemoved, this, + [this, check_allow_update] { ui->actionUpdateItem->setEnabled(check_allow_update()); }); - connect(mods.get(), &ModFolderModel::updateFinished, this, [this, check_allow_update, mods] { - ui->actionUpdateItem->setEnabled(check_allow_update()); - - // Prevent a weird crash when trying to open the mods page twice in a session o.O - disconnect(mods.get(), &ModFolderModel::updateFinished, this, 0); - }); + connect(mods.get(), &ModFolderModel::updateFinished, this, + [this, check_allow_update, mods] { ui->actionUpdateItem->setEnabled(check_allow_update()); }); connect(m_instance, &BaseInstance::runningStatusChanged, this, &ModFolderPage::runningStateChanged); ModFolderPage::runningStateChanged(m_instance && m_instance->isRunning()); From cb52be433d2a55338df2205d2cebbf3e4d2f5eb5 Mon Sep 17 00:00:00 2001 From: Trial97 Date: Thu, 15 Jun 2023 13:20:08 +0300 Subject: [PATCH 21/35] Made the installed mods more apparent Signed-off-by: Trial97 --- launcher/ui/widgets/ProjectItem.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/launcher/ui/widgets/ProjectItem.cpp b/launcher/ui/widgets/ProjectItem.cpp index e8349c106..0b00a9bdf 100644 --- a/launcher/ui/widgets/ProjectItem.cpp +++ b/launcher/ui/widgets/ProjectItem.cpp @@ -65,9 +65,15 @@ void ProjectItemDelegate::paint(QPainter* painter, const QStyleOptionViewItem& o font.setUnderline(true); } if (index.data(UserDataTypes::INSTALLED).toBool()) { + auto rect = opt.rect; + rect.setX(rect.x() + 1); + rect.setY(rect.y() + 1); + rect.setHeight(rect.height() - 2); + rect.setWidth(rect.width() - 2); // Set nice font font.setItalic(true); font.setOverline(true); + painter->drawRect(rect); } font.setPointSize(font.pointSize() + 2); From 7ad9abf9bce2f2d7ec0e9e6848673753fefba3dd Mon Sep 17 00:00:00 2001 From: Sefa Eyeoglu Date: Thu, 15 Jun 2023 12:42:45 +0200 Subject: [PATCH 22/35] fix: add JavaVendor as an instance override This should suppress a critical error that gets printed every time an instance gets launched, as JavaCheck wants to store the vendor in the instance settings. Signed-off-by: Sefa Eyeoglu --- launcher/minecraft/MinecraftInstance.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/launcher/minecraft/MinecraftInstance.cpp b/launcher/minecraft/MinecraftInstance.cpp index 2c624a365..f8ed5214e 100644 --- a/launcher/minecraft/MinecraftInstance.cpp +++ b/launcher/minecraft/MinecraftInstance.cpp @@ -149,9 +149,10 @@ void MinecraftInstance::loadSpecificSettings() // special! m_settings->registerPassthrough(global_settings->getSetting("JavaTimestamp"), javaOrLocation); - m_settings->registerPassthrough(global_settings->getSetting("JavaVersion"), javaOrLocation); m_settings->registerPassthrough(global_settings->getSetting("JavaArchitecture"), javaOrLocation); m_settings->registerPassthrough(global_settings->getSetting("JavaRealArchitecture"), javaOrLocation); + m_settings->registerPassthrough(global_settings->getSetting("JavaVersion"), javaOrLocation); + m_settings->registerPassthrough(global_settings->getSetting("JavaVendor"), javaOrLocation); // Window Size auto windowSetting = m_settings->registerSetting("OverrideWindow", false); From 6812823b55678230dd1fcd14973abc8d9a5d7245 Mon Sep 17 00:00:00 2001 From: Sefa Eyeoglu Date: Thu, 15 Jun 2023 12:48:22 +0200 Subject: [PATCH 23/35] fix: simplify resolving of data path Co-authored-by: TheKodeToad Signed-off-by: Sefa Eyeoglu --- launcher/ui/MainWindow.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/launcher/ui/MainWindow.cpp b/launcher/ui/MainWindow.cpp index 629ace830..6b2191979 100644 --- a/launcher/ui/MainWindow.cpp +++ b/launcher/ui/MainWindow.cpp @@ -1203,9 +1203,7 @@ void MainWindow::on_actionViewInstanceFolder_triggered() void MainWindow::on_actionViewLauncherRootFolder_triggered() { - QDir dataDir = QDir::current(); - QString dataPath = dataDir.absolutePath(); - + const QString dataPath = QDir::currentPath(); DesktopServices::openDirectory(dataPath); } From 98a07da39bbc41529b67cf515849d403280af07c Mon Sep 17 00:00:00 2001 From: Trial97 Date: Thu, 15 Jun 2023 14:12:29 +0300 Subject: [PATCH 24/35] Renamed variable Signed-off-by: Trial97 --- launcher/ui/widgets/ProjectItem.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/launcher/ui/widgets/ProjectItem.cpp b/launcher/ui/widgets/ProjectItem.cpp index 0b00a9bdf..0085d6b2b 100644 --- a/launcher/ui/widgets/ProjectItem.cpp +++ b/launcher/ui/widgets/ProjectItem.cpp @@ -65,15 +65,15 @@ void ProjectItemDelegate::paint(QPainter* painter, const QStyleOptionViewItem& o font.setUnderline(true); } if (index.data(UserDataTypes::INSTALLED).toBool()) { - auto rect = opt.rect; - rect.setX(rect.x() + 1); - rect.setY(rect.y() + 1); - rect.setHeight(rect.height() - 2); - rect.setWidth(rect.width() - 2); + auto hRect = opt.rect; + hRect.setX(hRect.x() + 1); + hRect.setY(hRect.y() + 1); + hRect.setHeight(hRect.height() - 2); + hRect.setWidth(hRect.width() - 2); // Set nice font font.setItalic(true); font.setOverline(true); - painter->drawRect(rect); + painter->drawRect(hRect); } font.setPointSize(font.pointSize() + 2); From 1b42b9a08e5777fcf0d2578f3ffa05e354e47f9a Mon Sep 17 00:00:00 2001 From: Trial97 Date: Thu, 15 Jun 2023 14:25:58 +0300 Subject: [PATCH 25/35] Fixed tests Signed-off-by: Trial97 --- launcher/settings/INIFile.cpp | 6 +++--- tests/INIFile_test.cpp | 39 ++++++++++++++++++----------------- 2 files changed, 23 insertions(+), 22 deletions(-) diff --git a/launcher/settings/INIFile.cpp b/launcher/settings/INIFile.cpp index ad600ab91..d16256b96 100644 --- a/launcher/settings/INIFile.cpp +++ b/launcher/settings/INIFile.cpp @@ -98,7 +98,7 @@ QString unescape(QString orig) return out; } -QString unquete(QString str) +QString unquote(QString str) { if ((str.contains(QChar(';')) || str.contains(QChar('=')) || str.contains(QChar(','))) && str.endsWith("\"") && str.startsWith("\"")) { #if QT_VERSION < QT_VERSION_CHECK(6, 5, 0) @@ -138,7 +138,7 @@ bool parseOldFileFormat(QIODevice& device, QSettings::SettingsMap& map) QString key = line.left(eqPos).trimmed(); QString valueStr = line.right(line.length() - eqPos - 1).trimmed(); - valueStr = unquete(unescape(valueStr)); + valueStr = unquote(unescape(valueStr)); QVariant value(valueStr); map.insert(key, value); @@ -174,7 +174,7 @@ bool INIFile::loadFile(QString fileName) if (auto valueStr = _settings_obj.value(key).toString(); (valueStr.contains(QChar(';')) || valueStr.contains(QChar('=')) || valueStr.contains(QChar(','))) && valueStr.endsWith("\"") && valueStr.startsWith("\"")) { - insert(key, unquete(valueStr)); + insert(key, unquote(valueStr)); } else insert(key, _settings_obj.value(key)); } diff --git a/tests/INIFile_test.cpp b/tests/INIFile_test.cpp index 5d9c9cd8a..eaf077d43 100644 --- a/tests/INIFile_test.cpp +++ b/tests/INIFile_test.cpp @@ -3,6 +3,7 @@ #include #include #include +#include #include #include "FileSystem.h" @@ -74,9 +75,8 @@ class IniFileTest : public QObject { QCOMPARE(out_list_numbers, list_numbers); } - void test_SaveAleardyExistingFile() + void test_SaveAlreadyExistingFile() { - QString fileName = "test_SaveAleardyExistingFile.ini"; QString fileContent = R"(InstanceType=OneSix iconKey=vanillia_icon name=Minecraft Vanillia @@ -86,9 +86,10 @@ Wrapperommand=)"; fileContent += "\""; fileContent += +R"(\"$INST_JAVA\" -jar packwiz-installer-bootstrap.jar link =)"; fileContent += "\"\n"; - QFile file(fileName); + QTemporaryFile file; - if (file.open(QFile::WriteOnly | QFile::Text)) { + // QFile file(fileName); + if (file.open()) { QTextStream stream(&file); stream << fileContent; file.close(); @@ -96,22 +97,23 @@ Wrapperommand=)"; // load INIFile f1; - f1.loadFile(fileName); + f1.loadFile(file.fileName()); QCOMPARE(f1.get("PreLaunchCommand", "NOT SET").toString(), "\"$INST_JAVA\" -jar packwiz-installer-bootstrap.jar link"); QCOMPARE(f1.get("Wrapperommand", "NOT SET").toString(), "\"$INST_JAVA\" -jar packwiz-installer-bootstrap.jar link ="); - f1.saveFile(fileName); + f1.saveFile(file.fileName()); INIFile f2; - f2.loadFile(fileName); + f2.loadFile(file.fileName()); QCOMPARE(f2.get("PreLaunchCommand", "NOT SET").toString(), "\"$INST_JAVA\" -jar packwiz-installer-bootstrap.jar link"); QCOMPARE(f2.get("Wrapperommand", "NOT SET").toString(), "\"$INST_JAVA\" -jar packwiz-installer-bootstrap.jar link ="); QCOMPARE(f2.get("ConfigVersion", "NOT SET").toString(), "1.2"); } - void test_SaveAleardyExistingFileWithSpecialChars() + void test_SaveAlreadyExistingFileWithSpecialChars() { - QString fileName = "test_SaveAleardyExistingFileWithSpecialChars.ini"; - FS::deletePath(fileName); // just to clean the previous test run - QSettings settings{ fileName, QSettings::Format::IniFormat }; + QTemporaryFile file; + file.open(); + file.close(); + QSettings settings{ file.fileName(), QSettings::Format::IniFormat }; settings.setFallbacksEnabled(false); settings.setValue("simple", "value1"); @@ -127,20 +129,20 @@ Wrapperommand=)"; // load INIFile f1; - f1.loadFile(fileName); + f1.loadFile(file.fileName()); for (auto key : settings.allKeys()) QCOMPARE(f1.get(key, "NOT SET").toString(), settings.value(key).toString()); - f1.saveFile(fileName); + f1.saveFile(file.fileName()); INIFile f2; - f2.loadFile(fileName); + f2.loadFile(file.fileName()); for (auto key : settings.allKeys()) QCOMPARE(f2.get(key, "NOT SET").toString(), settings.value(key).toString()); QCOMPARE(f2.get("ConfigVersion", "NOT SET").toString(), "1.2"); } - void test_SaveAleardyExistingFileWithSpecialCharsV1() + void test_SaveAlreadyExistingFileWithSpecialCharsV1() { - QString fileName = "test_SaveAleardyExistingFileWithSpecialCharsV1.ini"; + QTemporaryFile file; QString fileContent = R"(InstanceType=OneSix ConfigVersion=1.1 iconKey=vanillia_icon @@ -148,9 +150,8 @@ name=Minecraft Vanillia OverrideCommands=true PreLaunchCommand=)"; fileContent += "\"\\\"env mesa=true\\\"\"\n"; - QFile file(fileName); - if (file.open(QFile::WriteOnly | QFile::Text)) { + if (file.open()) { QTextStream stream(&file); stream << fileContent; file.close(); @@ -158,7 +159,7 @@ PreLaunchCommand=)"; // load INIFile f1; - f1.loadFile(fileName); + f1.loadFile(file.fileName()); QCOMPARE(f1.get("PreLaunchCommand", "NOT SET").toString(), "env mesa=true"); QCOMPARE(f1.get("ConfigVersion", "NOT SET").toString(), "1.2"); } From 1d354df1f81e3c7f7f82d17bf3fd261eb2d98ee4 Mon Sep 17 00:00:00 2001 From: Trial97 Date: Thu, 15 Jun 2023 16:51:58 +0300 Subject: [PATCH 26/35] Fix tests for window Signed-off-by: Trial97 --- tests/INIFile_test.cpp | 71 +++++++++++++++++++++++++++++------------- 1 file changed, 49 insertions(+), 22 deletions(-) diff --git a/tests/INIFile_test.cpp b/tests/INIFile_test.cpp index eaf077d43..95730e244 100644 --- a/tests/INIFile_test.cpp +++ b/tests/INIFile_test.cpp @@ -86,34 +86,48 @@ Wrapperommand=)"; fileContent += "\""; fileContent += +R"(\"$INST_JAVA\" -jar packwiz-installer-bootstrap.jar link =)"; fileContent += "\"\n"; +#if defined(Q_OS_WIN) + QString fileName = "test_SaveAlreadyExistingFile.ini"; + QFile file(fileName); + QCOMPARE(file.open(QFile::WriteOnly | QFile::Text), true); +#else QTemporaryFile file; - - // QFile file(fileName); - if (file.open()) { - QTextStream stream(&file); - stream << fileContent; - file.close(); - } + QCOMPARE(file.open(), true); + QCOMPARE(file.fileName().isEmpty(), false); + QString fileName = file.fileName(); +#endif + QTextStream stream(&file); + stream << fileContent; + file.close(); // load INIFile f1; - f1.loadFile(file.fileName()); + f1.loadFile(fileName); QCOMPARE(f1.get("PreLaunchCommand", "NOT SET").toString(), "\"$INST_JAVA\" -jar packwiz-installer-bootstrap.jar link"); QCOMPARE(f1.get("Wrapperommand", "NOT SET").toString(), "\"$INST_JAVA\" -jar packwiz-installer-bootstrap.jar link ="); - f1.saveFile(file.fileName()); + f1.saveFile(fileName); INIFile f2; - f2.loadFile(file.fileName()); + f2.loadFile(fileName); QCOMPARE(f2.get("PreLaunchCommand", "NOT SET").toString(), "\"$INST_JAVA\" -jar packwiz-installer-bootstrap.jar link"); QCOMPARE(f2.get("Wrapperommand", "NOT SET").toString(), "\"$INST_JAVA\" -jar packwiz-installer-bootstrap.jar link ="); QCOMPARE(f2.get("ConfigVersion", "NOT SET").toString(), "1.2"); +#if defined(Q_OS_WIN) + FS::deletePath(fileName); +#endif } void test_SaveAlreadyExistingFileWithSpecialChars() { +#if defined(Q_OS_WIN) + QString fileName = "test_SaveAlreadyExistingFileWithSpecialChars.ini"; +#else QTemporaryFile file; - file.open(); + QCOMPARE(file.open(), true); + QCOMPARE(file.fileName().isEmpty(), false); + QString fileName = file.fileName(); file.close(); - QSettings settings{ file.fileName(), QSettings::Format::IniFormat }; +#endif + QSettings settings{ fileName, QSettings::Format::IniFormat }; settings.setFallbacksEnabled(false); settings.setValue("simple", "value1"); @@ -129,20 +143,22 @@ Wrapperommand=)"; // load INIFile f1; - f1.loadFile(file.fileName()); + f1.loadFile(fileName); for (auto key : settings.allKeys()) QCOMPARE(f1.get(key, "NOT SET").toString(), settings.value(key).toString()); - f1.saveFile(file.fileName()); + f1.saveFile(fileName); INIFile f2; - f2.loadFile(file.fileName()); + f2.loadFile(fileName); for (auto key : settings.allKeys()) QCOMPARE(f2.get(key, "NOT SET").toString(), settings.value(key).toString()); QCOMPARE(f2.get("ConfigVersion", "NOT SET").toString(), "1.2"); +#if defined(Q_OS_WIN) + FS::deletePath(fileName); +#endif } void test_SaveAlreadyExistingFileWithSpecialCharsV1() { - QTemporaryFile file; QString fileContent = R"(InstanceType=OneSix ConfigVersion=1.1 iconKey=vanillia_icon @@ -151,17 +167,28 @@ OverrideCommands=true PreLaunchCommand=)"; fileContent += "\"\\\"env mesa=true\\\"\"\n"; - if (file.open()) { - QTextStream stream(&file); - stream << fileContent; - file.close(); - } +#if defined(Q_OS_WIN) + QString fileName = "test_SaveAlreadyExistingFileWithSpecialCharsV1.ini"; + QFile file(fileName); + QCOMPARE(file.open(QFile::WriteOnly | QFile::Text), true); +#else + QTemporaryFile file; + QCOMPARE(file.open(), true); + QCOMPARE(file.fileName().isEmpty(), false); + QString fileName = file.fileName(); +#endif + QTextStream stream(&file); + stream << fileContent; + file.close(); // load INIFile f1; - f1.loadFile(file.fileName()); + f1.loadFile(fileName); QCOMPARE(f1.get("PreLaunchCommand", "NOT SET").toString(), "env mesa=true"); QCOMPARE(f1.get("ConfigVersion", "NOT SET").toString(), "1.2"); +#if defined(Q_OS_WIN) + FS::deletePath(fileName); +#endif } }; From 13804f80de2cef845a917564adff9d9906c0eb5c Mon Sep 17 00:00:00 2001 From: TheKodeToad Date: Thu, 15 Jun 2023 16:37:03 +0100 Subject: [PATCH 27/35] Fix trailing space in instance name Signed-off-by: TheKodeToad --- launcher/InstanceTask.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/launcher/InstanceTask.cpp b/launcher/InstanceTask.cpp index 066827829..b16a40ba6 100644 --- a/launcher/InstanceTask.cpp +++ b/launcher/InstanceTask.cpp @@ -45,7 +45,10 @@ QString InstanceName::name() const { if (!m_modified_name.isEmpty()) return modifiedName(); - return QString("%1 %2").arg(m_original_name, m_original_version); + if (!m_original_version.isEmpty()) + return QString("%1 %2").arg(m_original_name, m_original_version); + + return m_original_name; } QString InstanceName::originalName() const From 45cce1d19a7e83dcb8db35ed1f203a175ce50635 Mon Sep 17 00:00:00 2001 From: seth Date: Fri, 16 Jun 2023 14:34:44 -0400 Subject: [PATCH 28/35] fix(appimage): bundle generic opengl lib Signed-off-by: seth --- .github/workflows/build.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a6a6eceaa..e75c9e742 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -250,6 +250,7 @@ jobs: wget "https://github.com/linuxdeploy/linuxdeploy-plugin-qt/releases/download/continuous/linuxdeploy-plugin-qt-x86_64.AppImage" ${{ github.workspace }}/.github/scripts/prepare_JREs.sh + sudo apt install libopengl0 - name: Add QT_HOST_PATH var (Windows MSVC arm64) if: runner.os == 'Windows' && matrix.architecture == 'arm64' @@ -482,7 +483,8 @@ jobs: cp -r /home/runner/work/PrismLauncher/Qt/${{ matrix.qt_version }}/gcc_64/plugins/iconengines/* ${{ env.INSTALL_APPIMAGE_DIR }}/usr/plugins/iconengines cp /usr/lib/x86_64-linux-gnu/libcrypto.so.1.1 ${{ env.INSTALL_APPIMAGE_DIR }}/usr/lib/ - cp /usr/lib/x86_64-linux-gnu/libssl.so.1.1 ${{ env.INSTALL_APPIMAGE_DIR }}//usr/lib/ + cp /usr/lib/x86_64-linux-gnu/libssl.so.1.1 ${{ env.INSTALL_APPIMAGE_DIR }}/usr/lib/ + cp /usr/lib/x86_64-linux-gnu/libOpenGL.so.0* ${{ env.INSTALL_APPIMAGE_DIR }}/usr/lib/ LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${{ env.INSTALL_APPIMAGE_DIR }}/usr/lib" LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${{ env.INSTALL_APPIMAGE_DIR }}/usr/lib/jvm/java-8-openjdk/lib/amd64/server" From b123f4f9484d0514b5b71c091f47200e5f182984 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 16 Jun 2023 21:58:32 +0000 Subject: [PATCH 29/35] chore(deps): update cachix/install-nix-action action to v22 --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a6a6eceaa..4c1c8a7f6 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -599,7 +599,7 @@ jobs: submodules: 'true' - name: Install nix if: inputs.build_type == 'Debug' - uses: cachix/install-nix-action@v21 + uses: cachix/install-nix-action@v22 with: install_url: https://nixos.org/nix/install extra_nix_config: | From 2d00a727f6ea0ae8c39a1d915b6a9c4db2b84a30 Mon Sep 17 00:00:00 2001 From: flow Date: Sat, 17 Jun 2023 11:04:36 -0300 Subject: [PATCH 30/35] fix: hide git commit when the build doesn't have git stuff support This fixes the Git commit string being "GITDIR-NOTFOUND" on the About page when building a package from the bundled source archive. Signed-off-by: flow --- buildconfig/BuildConfig.cpp.in | 1 + 1 file changed, 1 insertion(+) diff --git a/buildconfig/BuildConfig.cpp.in b/buildconfig/BuildConfig.cpp.in index 353731896..8a412b7ff 100644 --- a/buildconfig/BuildConfig.cpp.in +++ b/buildconfig/BuildConfig.cpp.in @@ -82,6 +82,7 @@ Config::Config() { GIT_REFSPEC = "refs/heads/stable"; GIT_TAG = versionString(); + GIT_COMMIT = ""; } if (GIT_REFSPEC.startsWith("refs/heads/")) From 555cb40efdec7edf6ea66d0177f3c77a6eb29063 Mon Sep 17 00:00:00 2001 From: DioEgizio <83089242+DioEgizio@users.noreply.github.com> Date: Sun, 18 Jun 2023 14:45:35 +0200 Subject: [PATCH 31/35] chore: install appstream in appimage Signed-off-by: DioEgizio <83089242+DioEgizio@users.noreply.github.com> --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 90b6cc76e..b83259b4b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -191,7 +191,7 @@ jobs: if: runner.os == 'Linux' run: | sudo apt-get -y update - sudo apt-get -y install ninja-build extra-cmake-modules scdoc + sudo apt-get -y install ninja-build extra-cmake-modules scdoc appstream - name: Install Dependencies (macOS) if: runner.os == 'macOS' From d5b5f0503cc8d88809f82afc9407f89a4af604c6 Mon Sep 17 00:00:00 2001 From: DioEgizio <83089242+DioEgizio@users.noreply.github.com> Date: Sun, 18 Jun 2023 15:10:11 +0200 Subject: [PATCH 32/35] chore: change xml name to what linuxdeploy wants Signed-off-by: DioEgizio <83089242+DioEgizio@users.noreply.github.com> --- .github/workflows/build.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b83259b4b..c2966abe7 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -468,7 +468,8 @@ jobs: shell: bash run: | cmake --install ${{ env.BUILD_DIR }} --prefix ${{ env.INSTALL_APPIMAGE_DIR }}/usr - + mv ${{ env.INSTALL_APPIMAGE_DIR }}/usr/share/metainfo/org.prismlauncher.PrismLauncher.metainfo.xml ${{ env.INSTALL_APPIMAGE_DIR }}/usr/share/metainfo/org.prismlauncher.PrismLauncher.appdata.xml + export "NO_APPSTREAM=1" # we have to skip appstream checking because appstream on ubuntu 20.04 is outdated export OUTPUT="PrismLauncher-${{ runner.os }}-${{ env.VERSION }}-${{ inputs.build_type }}-x86_64.AppImage" chmod +x linuxdeploy-*.AppImage From 3ee0fec7298d467d5b8b48a5144794f58bc2ce28 Mon Sep 17 00:00:00 2001 From: Trial97 Date: Mon, 19 Jun 2023 12:22:22 +0300 Subject: [PATCH 33/35] Removed mods from lambda Signed-off-by: Trial97 --- launcher/ui/pages/instance/ModFolderPage.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/launcher/ui/pages/instance/ModFolderPage.cpp b/launcher/ui/pages/instance/ModFolderPage.cpp index 1d090ef4d..90e7d0d62 100644 --- a/launcher/ui/pages/instance/ModFolderPage.cpp +++ b/launcher/ui/pages/instance/ModFolderPage.cpp @@ -100,7 +100,7 @@ ModFolderPage::ModFolderPage(BaseInstance* inst, std::shared_ptr [this, check_allow_update] { ui->actionUpdateItem->setEnabled(check_allow_update()); }); connect(mods.get(), &ModFolderModel::updateFinished, this, - [this, check_allow_update, mods] { ui->actionUpdateItem->setEnabled(check_allow_update()); }); + [this, check_allow_update] { ui->actionUpdateItem->setEnabled(check_allow_update()); }); connect(m_instance, &BaseInstance::runningStatusChanged, this, &ModFolderPage::runningStateChanged); ModFolderPage::runningStateChanged(m_instance && m_instance->isRunning()); From f769b0b4c63888ac95416a4cc834aad2395f9b74 Mon Sep 17 00:00:00 2001 From: Alfio Date: Tue, 20 Jun 2023 10:25:11 +0200 Subject: [PATCH 34/35] Remove inconsistent/unneeded question marks in UI Signed-off-by: P2 --- launcher/minecraft/auth/AccountList.cpp | 6 +++--- launcher/ui/pages/global/LauncherPage.ui | 8 ++++---- launcher/ui/pages/global/MinecraftPage.ui | 2 +- launcher/ui/pages/instance/InstanceSettingsPage.ui | 8 ++++---- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/launcher/minecraft/auth/AccountList.cpp b/launcher/minecraft/auth/AccountList.cpp index 9e2fd1113..c27941472 100644 --- a/launcher/minecraft/auth/AccountList.cpp +++ b/launcher/minecraft/auth/AccountList.cpp @@ -333,13 +333,13 @@ QVariant AccountList::data(const QModelIndex &index, int role) const case MigrationColumn: { if(account->isMSA() || account->isOffline()) { - return tr("N/A", "Can Migrate?"); + return tr("N/A", "Can Migrate"); } if (account->canMigrate()) { - return tr("Yes", "Can Migrate?"); + return tr("Yes", "Can Migrate"); } else { - return tr("No", "Can Migrate?"); + return tr("No", "Can Migrate"); } } diff --git a/launcher/ui/pages/global/LauncherPage.ui b/launcher/ui/pages/global/LauncherPage.ui index 55bd3eea7..d9116bfcf 100644 --- a/launcher/ui/pages/global/LauncherPage.ui +++ b/launcher/ui/pages/global/LauncherPage.ui @@ -172,7 +172,7 @@ Disable using metadata provided by mod providers (like Modrinth or Curseforge) for mods. - Disable using metadata for mods? + Disable using metadata for mods @@ -307,21 +307,21 @@ - Show console while the game is &running? + Show console while the game is &running - &Automatically close console when the game quits? + &Automatically close console when the game quits - Show console when the game &crashes? + Show console when the game &crashes diff --git a/launcher/ui/pages/global/MinecraftPage.ui b/launcher/ui/pages/global/MinecraftPage.ui index 103881b57..8f5de725d 100644 --- a/launcher/ui/pages/global/MinecraftPage.ui +++ b/launcher/ui/pages/global/MinecraftPage.ui @@ -51,7 +51,7 @@ - Start Minecraft &maximized? + Start Minecraft &maximized diff --git a/launcher/ui/pages/instance/InstanceSettingsPage.ui b/launcher/ui/pages/instance/InstanceSettingsPage.ui index 19d6dc02d..8427965de 100644 --- a/launcher/ui/pages/instance/InstanceSettingsPage.ui +++ b/launcher/ui/pages/instance/InstanceSettingsPage.ui @@ -269,7 +269,7 @@ - Start Minecraft maximized? + Start Minecraft maximized @@ -341,21 +341,21 @@ - Show console while the game is running? + Show console while the game is running - Automatically close console when the game quits? + Automatically close console when the game quits - Show console when the game crashes? + Show console when the game crashes From a32a3e25adbb20e31749828cca84a3ff3878f094 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Wro=C5=84ski?= Date: Tue, 20 Jun 2023 12:11:28 +0200 Subject: [PATCH 35/35] Fix compiling on FreeBSD MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jakub WroĊ„ski --- launcher/FileSystem.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/launcher/FileSystem.cpp b/launcher/FileSystem.cpp index d98526dfd..835ad925d 100644 --- a/launcher/FileSystem.cpp +++ b/launcher/FileSystem.cpp @@ -102,7 +102,7 @@ namespace fs = ghc::filesystem; #include #include #include -#elif defined(Q_OS_MACOS) || defined(Q_OS_FREEBSD) || defined(Q_OS_OPENBSD) +#elif defined(Q_OS_MACOS) || defined(Q_OS_OPENBSD) #include #include #elif defined(Q_OS_WIN) @@ -1151,7 +1151,7 @@ bool clone_file(const QString& src, const QString& dst, std::error_code& ec) return false; } -#elif defined(Q_OS_MACOS) || defined(Q_OS_FREEBSD) || defined(Q_OS_OPENBSD) +#elif defined(Q_OS_MACOS) || defined(Q_OS_OPENBSD) if (!macos_bsd_clonefile(src_path, dst_path, ec)) { qDebug() << "failed macos_bsd_clonefile:"; @@ -1380,7 +1380,7 @@ bool linux_ficlone(const std::string& src_path, const std::string& dst_path, std return true; } -#elif defined(Q_OS_MACOS) || defined(Q_OS_FREEBSD) || defined(Q_OS_OPENBSD) +#elif defined(Q_OS_MACOS) || defined(Q_OS_OPENBSD) bool macos_bsd_clonefile(const std::string& src_path, const std::string& dst_path, std::error_code& ec) {