2023-01-14 16:21:52 +00:00
|
|
|
// SPDX-FileCopyrightText: 2022-2023 Sefa Eyeoglu <contact@scrumplex.net>
|
|
|
|
//
|
|
|
|
// SPDX-License-Identifier: GPL-3.0-only AND Apache-2.0
|
|
|
|
|
2022-03-20 19:01:08 +00:00
|
|
|
/*
|
2022-11-08 11:20:13 +00:00
|
|
|
* Prism Launcher - Minecraft Launcher
|
2022-03-20 19:01:08 +00:00
|
|
|
* Copyright (c) 2022 Jamie Mansfield <jmansfield@cadixdev.org>
|
2023-01-14 16:21:52 +00:00
|
|
|
* Copyright (C) 2022-2023 Sefa Eyeoglu <contact@scrumplex.net>
|
2022-11-08 11:20:13 +00:00
|
|
|
* Copyright (C) 2022 TheKodeToad <TheKodeToad@proton.me>
|
2014-06-01 23:49:53 +01:00
|
|
|
*
|
2022-03-20 19:01:08 +00:00
|
|
|
* 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.
|
2014-06-01 23:49:53 +01:00
|
|
|
*
|
2022-03-20 19:01:08 +00:00
|
|
|
* 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.
|
2014-06-01 23:49:53 +01:00
|
|
|
*
|
2022-03-20 19:01:08 +00:00
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
* 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.
|
2014-06-01 23:49:53 +01:00
|
|
|
*/
|
|
|
|
|
2021-11-20 15:22:22 +00:00
|
|
|
#include "Application.h"
|
2014-06-01 23:49:53 +01:00
|
|
|
|
2023-07-09 20:47:38 +01:00
|
|
|
#include <QAbstractItemModel>
|
2014-06-01 23:49:53 +01:00
|
|
|
#include <QEvent>
|
|
|
|
#include <QKeyEvent>
|
2023-07-09 20:47:38 +01:00
|
|
|
#include <QLabel>
|
|
|
|
#include <QListView>
|
2019-07-14 04:37:10 +01:00
|
|
|
#include <QMenu>
|
2014-07-12 22:02:52 +01:00
|
|
|
#include <QMessageBox>
|
|
|
|
#include <QString>
|
|
|
|
#include <QUrl>
|
|
|
|
|
2021-11-22 02:55:16 +00:00
|
|
|
#include "VersionPage.h"
|
|
|
|
#include "ui_VersionPage.h"
|
|
|
|
|
|
|
|
#include "ui/dialogs/CustomMessageBox.h"
|
|
|
|
#include "ui/dialogs/NewComponentDialog.h"
|
|
|
|
#include "ui/dialogs/ProgressDialog.h"
|
2023-07-09 20:47:38 +01:00
|
|
|
#include "ui/dialogs/VersionSelectDialog.h"
|
2021-11-22 02:55:16 +00:00
|
|
|
|
|
|
|
#include "ui/GuiUtil.h"
|
|
|
|
|
2023-07-09 20:47:38 +01:00
|
|
|
#include "DesktopServices.h"
|
|
|
|
#include "Exception.h"
|
|
|
|
#include "Version.h"
|
|
|
|
#include "icons/IconList.h"
|
2020-06-27 11:02:31 +01:00
|
|
|
#include "minecraft/PackProfile.h"
|
2021-07-26 20:44:11 +01:00
|
|
|
#include "minecraft/auth/AccountList.h"
|
2019-08-04 02:27:53 +01:00
|
|
|
#include "minecraft/mod/Mod.h"
|
2014-06-01 23:49:53 +01:00
|
|
|
|
2021-11-22 02:55:16 +00:00
|
|
|
#include "meta/Index.h"
|
|
|
|
#include "meta/VersionList.h"
|
2017-03-24 01:26:06 +00:00
|
|
|
|
2023-07-09 20:47:38 +01:00
|
|
|
class IconProxy : public QIdentityProxyModel {
|
2016-02-21 00:44:27 +00:00
|
|
|
Q_OBJECT
|
2023-07-09 20:47:38 +01:00
|
|
|
public:
|
|
|
|
IconProxy(QWidget* parentWidget) : QIdentityProxyModel(parentWidget)
|
2016-02-21 00:44:27 +00:00
|
|
|
{
|
|
|
|
connect(parentWidget, &QObject::destroyed, this, &IconProxy::widgetGone);
|
|
|
|
m_parentWidget = parentWidget;
|
|
|
|
}
|
2018-07-15 13:51:05 +01:00
|
|
|
|
2023-07-09 20:47:38 +01:00
|
|
|
virtual QVariant data(const QModelIndex& proxyIndex, int role = Qt::DisplayRole) const override
|
2016-02-21 00:44:27 +00:00
|
|
|
{
|
2020-05-17 18:56:59 +01:00
|
|
|
QVariant var = QIdentityProxyModel::data(proxyIndex, role);
|
2016-02-21 00:44:27 +00:00
|
|
|
int column = proxyIndex.column();
|
2023-07-09 20:47:38 +01:00
|
|
|
if (column == 0 && role == Qt::DecorationRole && m_parentWidget) {
|
|
|
|
if (!var.isNull()) {
|
2016-02-21 00:44:27 +00:00
|
|
|
auto string = var.toString();
|
2023-07-09 20:47:38 +01:00
|
|
|
if (string == "warning") {
|
2021-11-20 15:22:22 +00:00
|
|
|
return APPLICATION->getThemedIcon("status-yellow");
|
2023-07-09 20:47:38 +01:00
|
|
|
} else if (string == "error") {
|
2021-11-20 15:22:22 +00:00
|
|
|
return APPLICATION->getThemedIcon("status-bad");
|
2016-02-21 00:44:27 +00:00
|
|
|
}
|
|
|
|
}
|
2021-11-20 15:22:22 +00:00
|
|
|
return APPLICATION->getThemedIcon("status-good");
|
2016-02-21 00:44:27 +00:00
|
|
|
}
|
|
|
|
return var;
|
|
|
|
}
|
2023-07-09 20:47:38 +01:00
|
|
|
private slots:
|
|
|
|
void widgetGone() { m_parentWidget = nullptr; }
|
2016-02-21 00:44:27 +00:00
|
|
|
|
2023-07-09 20:47:38 +01:00
|
|
|
private:
|
|
|
|
QWidget* m_parentWidget = nullptr;
|
2016-02-21 00:44:27 +00:00
|
|
|
};
|
|
|
|
|
2014-07-12 16:58:23 +01:00
|
|
|
QIcon VersionPage::icon() const
|
2014-06-01 23:49:53 +01:00
|
|
|
{
|
2021-11-20 15:22:22 +00:00
|
|
|
return APPLICATION->icons()->getIcon(m_inst->iconKey());
|
2014-06-01 23:49:53 +01:00
|
|
|
}
|
2014-07-12 16:58:23 +01:00
|
|
|
bool VersionPage::shouldDisplay() const
|
2014-06-30 01:02:57 +01:00
|
|
|
{
|
2019-07-15 22:16:34 +01:00
|
|
|
return true;
|
2014-06-30 01:02:57 +01:00
|
|
|
}
|
|
|
|
|
2022-02-22 18:23:53 +00:00
|
|
|
void VersionPage::retranslate()
|
|
|
|
{
|
|
|
|
ui->retranslateUi(this);
|
|
|
|
}
|
|
|
|
|
2022-11-19 20:12:31 +00:00
|
|
|
void VersionPage::openedImpl()
|
|
|
|
{
|
|
|
|
auto const setting_name = QString("WideBarVisibility_%1").arg(id());
|
|
|
|
if (!APPLICATION->settings()->contains(setting_name))
|
|
|
|
m_wide_bar_setting = APPLICATION->settings()->registerSetting(setting_name);
|
|
|
|
else
|
|
|
|
m_wide_bar_setting = APPLICATION->settings()->getSetting(setting_name);
|
|
|
|
|
|
|
|
ui->toolBar->setVisibilityState(m_wide_bar_setting->get().toByteArray());
|
|
|
|
}
|
|
|
|
void VersionPage::closedImpl()
|
|
|
|
{
|
|
|
|
m_wide_bar_setting->set(ui->toolBar->getVisibilityState());
|
|
|
|
}
|
|
|
|
|
2023-07-09 20:47:38 +01:00
|
|
|
QMenu* VersionPage::createPopupMenu()
|
2019-07-14 04:37:10 +01:00
|
|
|
{
|
|
|
|
QMenu* filteredMenu = QMainWindow::createPopupMenu();
|
2023-07-09 20:47:38 +01:00
|
|
|
filteredMenu->removeAction(ui->toolBar->toggleViewAction());
|
2019-07-14 04:37:10 +01:00
|
|
|
return filteredMenu;
|
|
|
|
}
|
|
|
|
|
2023-07-09 20:47:38 +01:00
|
|
|
VersionPage::VersionPage(MinecraftInstance* inst, QWidget* parent) : QMainWindow(parent), ui(new Ui::VersionPage), m_inst(inst)
|
2014-06-01 23:49:53 +01:00
|
|
|
{
|
|
|
|
ui->setupUi(this);
|
2019-07-17 01:01:29 +01:00
|
|
|
|
2019-07-22 23:48:14 +01:00
|
|
|
ui->toolBar->insertSpacer(ui->actionReload);
|
2019-07-14 04:37:10 +01:00
|
|
|
|
2020-06-27 11:02:31 +01:00
|
|
|
m_profile = m_inst->getPackProfile();
|
2018-07-15 13:51:05 +01:00
|
|
|
|
2020-06-27 11:02:31 +01:00
|
|
|
reloadPackProfile();
|
2018-07-15 13:51:05 +01:00
|
|
|
|
2019-07-11 00:01:47 +01:00
|
|
|
auto proxy = new IconProxy(ui->packageView);
|
|
|
|
proxy->setSourceModel(m_profile.get());
|
2021-06-18 23:21:12 +01:00
|
|
|
|
2023-05-21 09:49:13 +01:00
|
|
|
m_filterModel = new QSortFilterProxyModel(this);
|
2021-06-18 23:21:12 +01:00
|
|
|
m_filterModel->setDynamicSortFilter(true);
|
|
|
|
m_filterModel->setFilterCaseSensitivity(Qt::CaseInsensitive);
|
|
|
|
m_filterModel->setSortCaseSensitivity(Qt::CaseInsensitive);
|
|
|
|
m_filterModel->setSourceModel(proxy);
|
|
|
|
m_filterModel->setFilterKeyColumn(-1);
|
|
|
|
|
|
|
|
ui->packageView->setModel(m_filterModel);
|
2019-07-11 00:01:47 +01:00
|
|
|
ui->packageView->installEventFilter(this);
|
|
|
|
ui->packageView->setSelectionMode(QAbstractItemView::SingleSelection);
|
2019-07-25 00:02:30 +01:00
|
|
|
ui->packageView->setContextMenuPolicy(Qt::CustomContextMenu);
|
|
|
|
|
2019-07-11 00:01:47 +01:00
|
|
|
connect(ui->packageView->selectionModel(), &QItemSelectionModel::currentChanged, this, &VersionPage::versionCurrent);
|
|
|
|
auto smodel = ui->packageView->selectionModel();
|
|
|
|
connect(smodel, &QItemSelectionModel::currentChanged, this, &VersionPage::packageCurrent);
|
|
|
|
|
2020-06-27 11:02:31 +01:00
|
|
|
connect(m_profile.get(), &PackProfile::minecraftChanged, this, &VersionPage::updateVersionControls);
|
2019-07-11 00:01:47 +01:00
|
|
|
updateVersionControls();
|
|
|
|
preselect(0);
|
2021-06-18 23:21:12 +01:00
|
|
|
connect(ui->packageView, &ModListView::customContextMenuRequested, this, &VersionPage::showContextMenu);
|
|
|
|
connect(ui->filterEdit, &QLineEdit::textChanged, this, &VersionPage::onFilterTextChanged);
|
2014-06-01 23:49:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
VersionPage::~VersionPage()
|
|
|
|
{
|
|
|
|
delete ui;
|
|
|
|
}
|
|
|
|
|
2021-06-18 23:21:12 +01:00
|
|
|
void VersionPage::showContextMenu(const QPoint& pos)
|
2019-07-25 00:02:30 +01:00
|
|
|
{
|
|
|
|
auto menu = ui->toolBar->createContextMenu(this, tr("Context menu"));
|
|
|
|
menu->exec(ui->packageView->mapToGlobal(pos));
|
|
|
|
delete menu;
|
|
|
|
}
|
|
|
|
|
2023-07-14 04:05:16 +01:00
|
|
|
|
|
|
|
void VersionPage::packageCurrent(const QModelIndex& current, [[maybe_unused]] const QModelIndex& previous)
|
2016-02-21 00:44:27 +00:00
|
|
|
{
|
2023-07-09 20:47:38 +01:00
|
|
|
if (!current.isValid()) {
|
2016-02-21 00:44:27 +00:00
|
|
|
ui->frame->clear();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
int row = current.row();
|
2017-11-11 00:38:31 +00:00
|
|
|
auto patch = m_profile->getComponent(row);
|
2016-02-21 00:44:27 +00:00
|
|
|
auto severity = patch->getProblemSeverity();
|
2023-07-09 20:47:38 +01:00
|
|
|
switch (severity) {
|
2017-03-27 02:34:39 +01:00
|
|
|
case ProblemSeverity::Warning:
|
2022-08-10 18:48:34 +01:00
|
|
|
ui->frame->setName(tr("%1 possibly has issues.").arg(patch->getName()));
|
2016-02-21 00:44:27 +00:00
|
|
|
break;
|
2017-03-27 02:34:39 +01:00
|
|
|
case ProblemSeverity::Error:
|
2022-08-10 18:48:34 +01:00
|
|
|
ui->frame->setName(tr("%1 has issues!").arg(patch->getName()));
|
2016-02-21 00:44:27 +00:00
|
|
|
break;
|
|
|
|
default:
|
2017-03-27 02:34:39 +01:00
|
|
|
case ProblemSeverity::None:
|
2016-02-21 00:44:27 +00:00
|
|
|
ui->frame->clear();
|
|
|
|
return;
|
|
|
|
}
|
2018-07-15 13:51:05 +01:00
|
|
|
|
2023-07-09 20:47:38 +01:00
|
|
|
auto& problems = patch->getProblems();
|
2016-02-21 00:44:27 +00:00
|
|
|
QString problemOut;
|
2023-07-09 20:47:38 +01:00
|
|
|
for (auto& problem : problems) {
|
|
|
|
if (problem.m_severity == ProblemSeverity::Error) {
|
2016-02-21 00:44:27 +00:00
|
|
|
problemOut += tr("Error: ");
|
2023-07-09 20:47:38 +01:00
|
|
|
} else if (problem.m_severity == ProblemSeverity::Warning) {
|
2016-02-21 00:44:27 +00:00
|
|
|
problemOut += tr("Warning: ");
|
|
|
|
}
|
2017-07-29 07:43:34 +01:00
|
|
|
problemOut += problem.m_description;
|
2016-02-21 00:44:27 +00:00
|
|
|
problemOut += "\n";
|
|
|
|
}
|
2022-08-10 18:48:34 +01:00
|
|
|
ui->frame->setDescription(problemOut);
|
2016-02-21 00:44:27 +00:00
|
|
|
}
|
|
|
|
|
2014-06-01 23:49:53 +01:00
|
|
|
void VersionPage::updateVersionControls()
|
|
|
|
{
|
2019-07-10 21:30:42 +01:00
|
|
|
// FIXME: this is a dirty hack
|
2019-07-15 22:16:34 +01:00
|
|
|
auto minecraftVersion = Version(m_profile->getComponentVersion("net.minecraft"));
|
2021-06-30 14:52:00 +01:00
|
|
|
|
|
|
|
bool supportsFabric = minecraftVersion >= Version("1.14");
|
2023-07-09 20:47:38 +01:00
|
|
|
ui->actionInstall_Fabric->setEnabled(supportsFabric);
|
2021-06-30 14:52:00 +01:00
|
|
|
|
2022-04-14 16:20:07 +01:00
|
|
|
bool supportsQuilt = minecraftVersion >= Version("1.14");
|
2023-07-09 20:47:38 +01:00
|
|
|
ui->actionInstall_Quilt->setEnabled(supportsQuilt);
|
2022-02-20 16:51:26 +00:00
|
|
|
|
2021-06-30 14:52:00 +01:00
|
|
|
bool supportsLiteLoader = minecraftVersion <= Version("1.12.2");
|
2023-07-09 20:47:38 +01:00
|
|
|
ui->actionInstall_LiteLoader->setEnabled(supportsLiteLoader);
|
2021-06-30 14:52:00 +01:00
|
|
|
|
2015-05-17 22:38:28 +01:00
|
|
|
updateButtons();
|
2014-06-01 23:49:53 +01:00
|
|
|
}
|
|
|
|
|
2019-07-15 22:16:34 +01:00
|
|
|
void VersionPage::updateButtons(int row)
|
|
|
|
{
|
2023-07-09 20:47:38 +01:00
|
|
|
if (row == -1)
|
2019-07-15 22:16:34 +01:00
|
|
|
row = currentRow();
|
|
|
|
auto patch = m_profile->getComponent(row);
|
2023-07-09 20:47:38 +01:00
|
|
|
ui->actionRemove->setEnabled(patch && patch->isRemovable());
|
|
|
|
ui->actionMove_down->setEnabled(patch && patch->isMoveable());
|
|
|
|
ui->actionMove_up->setEnabled(patch && patch->isMoveable());
|
|
|
|
ui->actionChange_version->setEnabled(patch && patch->isVersionChangeable());
|
|
|
|
ui->actionEdit->setEnabled(patch && patch->isCustom());
|
|
|
|
ui->actionCustomize->setEnabled(patch && patch->isCustomizable());
|
|
|
|
ui->actionRevert->setEnabled(patch && patch->isRevertible());
|
2019-07-15 22:16:34 +01:00
|
|
|
}
|
|
|
|
|
2020-06-27 11:02:31 +01:00
|
|
|
bool VersionPage::reloadPackProfile()
|
2014-06-01 23:49:53 +01:00
|
|
|
{
|
2023-07-09 20:47:38 +01:00
|
|
|
try {
|
2017-11-11 00:38:31 +00:00
|
|
|
m_profile->reload(Net::Mode::Online);
|
2014-06-01 23:49:53 +01:00
|
|
|
return true;
|
2023-07-09 20:47:38 +01:00
|
|
|
} catch (const Exception& e) {
|
2014-06-01 23:49:53 +01:00
|
|
|
QMessageBox::critical(this, tr("Error"), e.cause());
|
|
|
|
return false;
|
2023-07-09 20:47:38 +01:00
|
|
|
} catch (...) {
|
|
|
|
QMessageBox::critical(this, tr("Error"), tr("Couldn't load the instance profile."));
|
2014-06-01 23:49:53 +01:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-07-14 04:37:10 +01:00
|
|
|
void VersionPage::on_actionReload_triggered()
|
2014-06-01 23:49:53 +01:00
|
|
|
{
|
2020-06-27 11:02:31 +01:00
|
|
|
reloadPackProfile();
|
2016-11-06 23:18:27 +00:00
|
|
|
m_container->refreshContainer();
|
2014-06-01 23:49:53 +01:00
|
|
|
}
|
|
|
|
|
2019-07-14 04:37:10 +01:00
|
|
|
void VersionPage::on_actionRemove_triggered()
|
2014-06-01 23:49:53 +01:00
|
|
|
{
|
2023-07-09 20:47:38 +01:00
|
|
|
if (!ui->packageView->currentIndex().isValid()) {
|
2022-12-14 15:36:42 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
int index = ui->packageView->currentIndex().row();
|
|
|
|
auto component = m_profile->getComponent(index);
|
2023-07-09 20:47:38 +01:00
|
|
|
if (component->isCustom()) {
|
2022-12-17 09:26:06 +00:00
|
|
|
auto response = CustomMessageBox::selectable(this, tr("Confirm Removal"),
|
2022-12-26 14:33:50 +00:00
|
|
|
tr("You are about to remove \"%1\".\n"
|
2022-12-14 15:36:42 +00:00
|
|
|
"This is permanent and will completely remove the custom component.\n\n"
|
|
|
|
"Are you sure?")
|
|
|
|
.arg(component->getName()),
|
|
|
|
QMessageBox::Warning, QMessageBox::Yes | QMessageBox::No, QMessageBox::No)
|
|
|
|
->exec();
|
|
|
|
|
|
|
|
if (response != QMessageBox::Yes)
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// FIXME: use actual model, not reloading.
|
2023-07-09 20:47:38 +01:00
|
|
|
if (!m_profile->remove(index)) {
|
2022-12-14 15:36:42 +00:00
|
|
|
QMessageBox::critical(this, tr("Error"), tr("Couldn't remove file"));
|
2014-06-01 23:49:53 +01:00
|
|
|
}
|
2015-05-17 22:38:28 +01:00
|
|
|
updateButtons();
|
2020-06-27 11:02:31 +01:00
|
|
|
reloadPackProfile();
|
2016-11-06 23:18:27 +00:00
|
|
|
m_container->refreshContainer();
|
2014-06-01 23:49:53 +01:00
|
|
|
}
|
|
|
|
|
2019-07-14 04:37:10 +01:00
|
|
|
void VersionPage::on_actionInstall_mods_triggered()
|
2015-05-29 01:22:02 +01:00
|
|
|
{
|
2023-07-09 20:47:38 +01:00
|
|
|
if (m_container) {
|
2015-05-29 01:22:02 +01:00
|
|
|
m_container->selectPage("mods");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-07-14 04:37:10 +01:00
|
|
|
void VersionPage::on_actionAdd_to_Minecraft_jar_triggered()
|
2014-06-01 23:49:53 +01:00
|
|
|
{
|
2023-07-09 20:47:38 +01:00
|
|
|
auto list = GuiUtil::BrowseForFiles("jarmod", tr("Select jar mods"), tr("Minecraft.jar mods (*.zip *.jar)"),
|
|
|
|
APPLICATION->settings()->get("CentralModsDir").toString(), this->parentWidget());
|
|
|
|
if (!list.empty()) {
|
2016-03-13 19:57:01 +00:00
|
|
|
m_profile->installJarMods(list);
|
2017-08-06 23:46:29 +01:00
|
|
|
}
|
|
|
|
updateButtons();
|
|
|
|
}
|
|
|
|
|
2019-07-14 04:37:10 +01:00
|
|
|
void VersionPage::on_actionReplace_Minecraft_jar_triggered()
|
2017-08-06 23:46:29 +01:00
|
|
|
{
|
2023-07-09 20:47:38 +01:00
|
|
|
auto jarPath = GuiUtil::BrowseForFile("jar", tr("Select jar"), tr("Minecraft.jar replacement (*.jar)"),
|
|
|
|
APPLICATION->settings()->get("CentralModsDir").toString(), this->parentWidget());
|
|
|
|
if (!jarPath.isEmpty()) {
|
2017-08-06 23:46:29 +01:00
|
|
|
m_profile->installCustomJar(jarPath);
|
2014-06-01 23:49:53 +01:00
|
|
|
}
|
2015-05-17 22:38:28 +01:00
|
|
|
updateButtons();
|
2014-06-01 23:49:53 +01:00
|
|
|
}
|
|
|
|
|
2023-01-11 12:50:57 +00:00
|
|
|
void VersionPage::on_actionImport_Components_triggered()
|
|
|
|
{
|
|
|
|
QStringList list = GuiUtil::BrowseForFiles("component", tr("Select components"), tr("Components (*.json)"),
|
|
|
|
APPLICATION->settings()->get("CentralModsDir").toString(), this->parentWidget());
|
|
|
|
|
2023-01-25 09:43:23 +00:00
|
|
|
if (!list.isEmpty()) {
|
|
|
|
if (!m_profile->installComponents(list)) {
|
|
|
|
QMessageBox::warning(this, tr("Failed to import components"),
|
|
|
|
tr("Some components could not be imported. Check logs for details"));
|
|
|
|
}
|
|
|
|
}
|
2023-01-11 12:50:57 +00:00
|
|
|
|
|
|
|
updateButtons();
|
|
|
|
}
|
2022-11-08 11:20:13 +00:00
|
|
|
|
|
|
|
void VersionPage::on_actionAdd_Agents_triggered()
|
|
|
|
{
|
|
|
|
QStringList list = GuiUtil::BrowseForFiles("agent", tr("Select agents"), tr("Java agents (*.jar)"),
|
|
|
|
APPLICATION->settings()->get("CentralModsDir").toString(), this->parentWidget());
|
|
|
|
|
|
|
|
if (!list.isEmpty())
|
|
|
|
m_profile->installAgents(list);
|
|
|
|
|
|
|
|
updateButtons();
|
|
|
|
}
|
|
|
|
|
2019-07-14 04:37:10 +01:00
|
|
|
void VersionPage::on_actionMove_up_triggered()
|
2014-06-01 23:49:53 +01:00
|
|
|
{
|
2023-07-09 20:47:38 +01:00
|
|
|
try {
|
2020-06-27 11:02:31 +01:00
|
|
|
m_profile->move(currentRow(), PackProfile::MoveUp);
|
2023-07-09 20:47:38 +01:00
|
|
|
} catch (const Exception& e) {
|
2014-06-01 23:49:53 +01:00
|
|
|
QMessageBox::critical(this, tr("Error"), e.cause());
|
|
|
|
}
|
2015-05-17 22:38:28 +01:00
|
|
|
updateButtons();
|
2014-06-01 23:49:53 +01:00
|
|
|
}
|
|
|
|
|
2019-07-14 04:37:10 +01:00
|
|
|
void VersionPage::on_actionMove_down_triggered()
|
2014-06-01 23:49:53 +01:00
|
|
|
{
|
2023-07-09 20:47:38 +01:00
|
|
|
try {
|
2020-06-27 11:02:31 +01:00
|
|
|
m_profile->move(currentRow(), PackProfile::MoveDown);
|
2023-07-09 20:47:38 +01:00
|
|
|
} catch (const Exception& e) {
|
2014-06-01 23:49:53 +01:00
|
|
|
QMessageBox::critical(this, tr("Error"), e.cause());
|
|
|
|
}
|
2015-05-17 22:38:28 +01:00
|
|
|
updateButtons();
|
2014-06-01 23:49:53 +01:00
|
|
|
}
|
|
|
|
|
2019-07-14 04:37:10 +01:00
|
|
|
void VersionPage::on_actionChange_version_triggered()
|
2014-06-01 23:49:53 +01:00
|
|
|
{
|
2017-03-30 00:05:58 +01:00
|
|
|
auto versionRow = currentRow();
|
2023-07-09 20:47:38 +01:00
|
|
|
if (versionRow == -1) {
|
2017-03-30 00:05:58 +01:00
|
|
|
return;
|
|
|
|
}
|
2017-11-11 00:38:31 +00:00
|
|
|
auto patch = m_profile->getComponent(versionRow);
|
2017-03-30 00:05:58 +01:00
|
|
|
auto name = patch->getName();
|
|
|
|
auto list = patch->getVersionList();
|
2023-07-09 20:47:38 +01:00
|
|
|
if (!list) {
|
2017-03-30 00:05:58 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
auto uid = list->uid();
|
2017-12-04 23:40:45 +00:00
|
|
|
// FIXME: this is a horrible HACK. Get version filtering information from the actual metadata...
|
2023-07-09 20:47:38 +01:00
|
|
|
if (uid == "net.minecraftforge") {
|
2019-07-14 04:37:10 +01:00
|
|
|
on_actionInstall_Forge_triggered();
|
2017-12-04 23:40:45 +00:00
|
|
|
return;
|
2023-07-09 20:47:38 +01:00
|
|
|
} else if (uid == "com.mumfrey.liteloader") {
|
2019-07-14 04:37:10 +01:00
|
|
|
on_actionInstall_LiteLoader_triggered();
|
2017-12-04 23:40:45 +00:00
|
|
|
return;
|
|
|
|
}
|
2017-03-30 00:05:58 +01:00
|
|
|
VersionSelectDialog vselect(list.get(), tr("Change %1 version").arg(name), this);
|
2023-07-09 20:47:38 +01:00
|
|
|
if (uid == "net.fabricmc.intermediary" || uid == "org.quiltmc.hashed") {
|
2020-07-09 17:17:59 +01:00
|
|
|
vselect.setEmptyString(tr("No intermediary mappings versions are currently available."));
|
|
|
|
vselect.setEmptyErrorString(tr("Couldn't load or download the intermediary mappings version lists!"));
|
2019-06-15 21:45:56 +01:00
|
|
|
vselect.setExactFilter(BaseVersionList::ParentVersionRole, m_profile->getComponentVersion("net.minecraft"));
|
|
|
|
}
|
2017-12-09 00:30:23 +00:00
|
|
|
auto currentVersion = patch->getVersion();
|
2023-07-09 20:47:38 +01:00
|
|
|
if (!currentVersion.isEmpty()) {
|
2017-12-09 00:30:23 +00:00
|
|
|
vselect.setCurrentVersion(currentVersion);
|
|
|
|
}
|
2014-06-01 23:49:53 +01:00
|
|
|
if (!vselect.exec() || !vselect.selectedVersion())
|
|
|
|
return;
|
2018-07-15 13:51:05 +01:00
|
|
|
|
2017-03-30 00:05:58 +01:00
|
|
|
qDebug() << "Change" << uid << "to" << vselect.selectedVersion()->descriptor();
|
2017-11-11 00:38:31 +00:00
|
|
|
bool important = false;
|
2023-07-09 20:47:38 +01:00
|
|
|
if (uid == "net.minecraft") {
|
2017-11-11 00:38:31 +00:00
|
|
|
important = true;
|
2014-06-01 23:49:53 +01:00
|
|
|
}
|
2017-11-11 00:38:31 +00:00
|
|
|
m_profile->setComponentVersion(uid, vselect.selectedVersion()->descriptor(), important);
|
2018-01-05 03:26:46 +00:00
|
|
|
m_profile->resolve(Net::Mode::Online);
|
2016-11-06 23:18:27 +00:00
|
|
|
m_container->refreshContainer();
|
2015-05-28 08:36:58 +01:00
|
|
|
}
|
2014-06-01 23:49:53 +01:00
|
|
|
|
2019-08-08 23:11:42 +01:00
|
|
|
void VersionPage::on_actionDownload_All_triggered()
|
2015-05-28 08:36:58 +01:00
|
|
|
{
|
2023-07-09 20:47:38 +01:00
|
|
|
if (!APPLICATION->accounts()->anyAccountIsValid()) {
|
|
|
|
CustomMessageBox::selectable(this, tr("Error"),
|
|
|
|
tr("Cannot download Minecraft or update instances unless you have at least "
|
|
|
|
"one account added.\nPlease add your Mojang or Minecraft account."),
|
|
|
|
QMessageBox::Warning)
|
|
|
|
->show();
|
2018-01-05 03:26:46 +00:00
|
|
|
return;
|
|
|
|
}
|
2018-07-15 13:51:05 +01:00
|
|
|
|
2017-11-11 00:38:31 +00:00
|
|
|
auto updateTask = m_inst->createUpdateTask(Net::Mode::Online);
|
2023-07-09 20:47:38 +01:00
|
|
|
if (!updateTask) {
|
2018-01-05 03:26:46 +00:00
|
|
|
return;
|
2014-06-01 23:49:53 +01:00
|
|
|
}
|
|
|
|
ProgressDialog tDialog(this);
|
2023-04-18 01:51:34 +01:00
|
|
|
connect(updateTask.get(), &Task::failed, this, &VersionPage::onGameUpdateError);
|
2018-02-11 00:21:32 +00:00
|
|
|
// FIXME: unused return value
|
|
|
|
tDialog.execWithTask(updateTask.get());
|
2015-05-17 22:38:28 +01:00
|
|
|
updateButtons();
|
2016-11-06 23:18:27 +00:00
|
|
|
m_container->refreshContainer();
|
2014-06-01 23:49:53 +01:00
|
|
|
}
|
|
|
|
|
2019-07-14 04:37:10 +01:00
|
|
|
void VersionPage::on_actionInstall_Forge_triggered()
|
2014-06-01 23:49:53 +01:00
|
|
|
{
|
2021-11-21 22:21:12 +00:00
|
|
|
auto vlist = APPLICATION->metadataIndex()->get("net.minecraftforge");
|
2023-07-09 20:47:38 +01:00
|
|
|
if (!vlist) {
|
2017-03-12 22:19:45 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
VersionSelectDialog vselect(vlist.get(), tr("Select Forge version"), this);
|
2017-11-11 00:38:31 +00:00
|
|
|
vselect.setExactFilter(BaseVersionList::ParentVersionRole, m_profile->getComponentVersion("net.minecraft"));
|
2023-07-09 20:47:38 +01:00
|
|
|
vselect.setEmptyString(tr("No Forge versions are currently available for Minecraft ") +
|
|
|
|
m_profile->getComponentVersion("net.minecraft"));
|
2015-05-02 22:42:33 +01:00
|
|
|
vselect.setEmptyErrorString(tr("Couldn't load or download the Forge version lists!"));
|
2018-07-15 13:51:05 +01:00
|
|
|
|
2017-12-09 00:30:23 +00:00
|
|
|
auto currentVersion = m_profile->getComponentVersion("net.minecraftforge");
|
2023-07-09 20:47:38 +01:00
|
|
|
if (!currentVersion.isEmpty()) {
|
2017-12-09 00:30:23 +00:00
|
|
|
vselect.setCurrentVersion(currentVersion);
|
|
|
|
}
|
2018-07-15 13:51:05 +01:00
|
|
|
|
2023-07-09 20:47:38 +01:00
|
|
|
if (vselect.exec() && vselect.selectedVersion()) {
|
2017-03-31 22:47:56 +01:00
|
|
|
auto vsn = vselect.selectedVersion();
|
2017-11-11 00:38:31 +00:00
|
|
|
m_profile->setComponentVersion("net.minecraftforge", vsn->descriptor());
|
|
|
|
m_profile->resolve(Net::Mode::Online);
|
2017-03-31 22:47:56 +01:00
|
|
|
// m_profile->installVersion();
|
2023-07-09 20:47:38 +01:00
|
|
|
preselect(m_profile->rowCount(QModelIndex()) - 1);
|
2016-11-06 23:18:27 +00:00
|
|
|
m_container->refreshContainer();
|
2014-06-01 23:49:53 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-07-14 04:37:10 +01:00
|
|
|
void VersionPage::on_actionInstall_Fabric_triggered()
|
2019-06-15 20:25:23 +01:00
|
|
|
{
|
2021-11-21 22:21:12 +00:00
|
|
|
auto vlist = APPLICATION->metadataIndex()->get("net.fabricmc.fabric-loader");
|
2023-07-09 20:47:38 +01:00
|
|
|
if (!vlist) {
|
2019-06-15 20:25:23 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
VersionSelectDialog vselect(vlist.get(), tr("Select Fabric Loader version"), this);
|
|
|
|
vselect.setEmptyString(tr("No Fabric Loader versions are currently available."));
|
|
|
|
vselect.setEmptyErrorString(tr("Couldn't load or download the Fabric Loader version lists!"));
|
|
|
|
|
|
|
|
auto currentVersion = m_profile->getComponentVersion("net.fabricmc.fabric-loader");
|
2023-07-09 20:47:38 +01:00
|
|
|
if (!currentVersion.isEmpty()) {
|
2019-06-15 20:25:23 +01:00
|
|
|
vselect.setCurrentVersion(currentVersion);
|
|
|
|
}
|
|
|
|
|
2023-07-09 20:47:38 +01:00
|
|
|
if (vselect.exec() && vselect.selectedVersion()) {
|
2019-06-15 20:25:23 +01:00
|
|
|
auto vsn = vselect.selectedVersion();
|
|
|
|
m_profile->setComponentVersion("net.fabricmc.fabric-loader", vsn->descriptor());
|
|
|
|
m_profile->resolve(Net::Mode::Online);
|
2023-07-09 20:47:38 +01:00
|
|
|
preselect(m_profile->rowCount(QModelIndex()) - 1);
|
2019-06-15 20:25:23 +01:00
|
|
|
m_container->refreshContainer();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-02-20 16:51:26 +00:00
|
|
|
void VersionPage::on_actionInstall_Quilt_triggered()
|
|
|
|
{
|
|
|
|
auto vlist = APPLICATION->metadataIndex()->get("org.quiltmc.quilt-loader");
|
2023-07-09 20:47:38 +01:00
|
|
|
if (!vlist) {
|
2022-02-20 16:51:26 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
VersionSelectDialog vselect(vlist.get(), tr("Select Quilt Loader version"), this);
|
|
|
|
vselect.setEmptyString(tr("No Quilt Loader versions are currently available."));
|
|
|
|
vselect.setEmptyErrorString(tr("Couldn't load or download the Quilt Loader version lists!"));
|
|
|
|
|
|
|
|
auto currentVersion = m_profile->getComponentVersion("org.quiltmc.quilt-loader");
|
2023-07-09 20:47:38 +01:00
|
|
|
if (!currentVersion.isEmpty()) {
|
2022-02-20 16:51:26 +00:00
|
|
|
vselect.setCurrentVersion(currentVersion);
|
|
|
|
}
|
|
|
|
|
2023-07-09 20:47:38 +01:00
|
|
|
if (vselect.exec() && vselect.selectedVersion()) {
|
2022-02-20 16:51:26 +00:00
|
|
|
auto vsn = vselect.selectedVersion();
|
|
|
|
m_profile->setComponentVersion("org.quiltmc.quilt-loader", vsn->descriptor());
|
|
|
|
m_profile->resolve(Net::Mode::Online);
|
2023-07-09 20:47:38 +01:00
|
|
|
preselect(m_profile->rowCount(QModelIndex()) - 1);
|
2022-02-20 16:51:26 +00:00
|
|
|
m_container->refreshContainer();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-07-14 04:37:10 +01:00
|
|
|
void VersionPage::on_actionAdd_Empty_triggered()
|
2017-12-31 00:37:50 +00:00
|
|
|
{
|
|
|
|
NewComponentDialog compdialog(QString(), QString(), this);
|
|
|
|
QStringList blacklist;
|
2023-07-09 20:47:38 +01:00
|
|
|
for (int i = 0; i < m_profile->rowCount(); i++) {
|
2017-12-31 00:37:50 +00:00
|
|
|
auto comp = m_profile->getComponent(i);
|
|
|
|
blacklist.push_back(comp->getID());
|
|
|
|
}
|
|
|
|
compdialog.setBlacklist(blacklist);
|
2023-07-09 20:47:38 +01:00
|
|
|
if (compdialog.exec()) {
|
2017-12-31 00:37:50 +00:00
|
|
|
qDebug() << "name:" << compdialog.name();
|
|
|
|
qDebug() << "uid:" << compdialog.uid();
|
|
|
|
m_profile->installEmpty(compdialog.uid(), compdialog.name());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-07-14 04:37:10 +01:00
|
|
|
void VersionPage::on_actionInstall_LiteLoader_triggered()
|
2014-06-01 23:49:53 +01:00
|
|
|
{
|
2021-11-21 22:21:12 +00:00
|
|
|
auto vlist = APPLICATION->metadataIndex()->get("com.mumfrey.liteloader");
|
2023-07-09 20:47:38 +01:00
|
|
|
if (!vlist) {
|
2017-03-12 22:19:45 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
VersionSelectDialog vselect(vlist.get(), tr("Select LiteLoader version"), this);
|
2017-11-11 00:38:31 +00:00
|
|
|
vselect.setExactFilter(BaseVersionList::ParentVersionRole, m_profile->getComponentVersion("net.minecraft"));
|
2023-07-09 20:47:38 +01:00
|
|
|
vselect.setEmptyString(tr("No LiteLoader versions are currently available for Minecraft ") +
|
|
|
|
m_profile->getComponentVersion("net.minecraft"));
|
2015-05-02 22:42:33 +01:00
|
|
|
vselect.setEmptyErrorString(tr("Couldn't load or download the LiteLoader version lists!"));
|
2018-07-15 13:51:05 +01:00
|
|
|
|
2017-12-09 00:30:23 +00:00
|
|
|
auto currentVersion = m_profile->getComponentVersion("com.mumfrey.liteloader");
|
2023-07-09 20:47:38 +01:00
|
|
|
if (!currentVersion.isEmpty()) {
|
2017-12-09 00:30:23 +00:00
|
|
|
vselect.setCurrentVersion(currentVersion);
|
|
|
|
}
|
2018-07-15 13:51:05 +01:00
|
|
|
|
2023-07-09 20:47:38 +01:00
|
|
|
if (vselect.exec() && vselect.selectedVersion()) {
|
2017-03-31 22:47:56 +01:00
|
|
|
auto vsn = vselect.selectedVersion();
|
2017-11-11 00:38:31 +00:00
|
|
|
m_profile->setComponentVersion("com.mumfrey.liteloader", vsn->descriptor());
|
|
|
|
m_profile->resolve(Net::Mode::Online);
|
2017-03-31 22:47:56 +01:00
|
|
|
// m_profile->installVersion(vselect.selectedVersion());
|
2023-07-09 20:47:38 +01:00
|
|
|
preselect(m_profile->rowCount(QModelIndex()) - 1);
|
2016-11-06 23:18:27 +00:00
|
|
|
m_container->refreshContainer();
|
2014-06-01 23:49:53 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-01-09 12:45:46 +00:00
|
|
|
void VersionPage::on_actionLibrariesFolder_triggered()
|
|
|
|
{
|
|
|
|
DesktopServices::openDirectory(m_inst->getLocalLibraryPath(), true);
|
|
|
|
}
|
|
|
|
|
|
|
|
void VersionPage::on_actionMinecraftFolder_triggered()
|
|
|
|
{
|
|
|
|
DesktopServices::openDirectory(m_inst->gameRoot(), true);
|
|
|
|
}
|
|
|
|
|
2023-07-14 04:05:16 +01:00
|
|
|
void VersionPage::versionCurrent(const QModelIndex& current, [[maybe_unused]] const QModelIndex& previous)
|
2014-06-01 23:49:53 +01:00
|
|
|
{
|
2015-05-17 22:38:28 +01:00
|
|
|
currentIdx = current.row();
|
|
|
|
updateButtons(currentIdx);
|
|
|
|
}
|
|
|
|
|
|
|
|
void VersionPage::preselect(int row)
|
|
|
|
{
|
2023-07-09 20:47:38 +01:00
|
|
|
if (row < 0) {
|
2015-05-17 22:38:28 +01:00
|
|
|
row = 0;
|
2014-06-01 23:49:53 +01:00
|
|
|
}
|
2023-07-09 20:47:38 +01:00
|
|
|
if (row >= m_profile->rowCount(QModelIndex())) {
|
2016-03-13 19:57:01 +00:00
|
|
|
row = m_profile->rowCount(QModelIndex()) - 1;
|
2015-05-17 22:38:28 +01:00
|
|
|
}
|
2023-07-09 20:47:38 +01:00
|
|
|
if (row < 0) {
|
2015-05-17 22:38:28 +01:00
|
|
|
return;
|
2014-06-01 23:49:53 +01:00
|
|
|
}
|
2016-03-13 19:57:01 +00:00
|
|
|
auto model_index = m_profile->index(row);
|
2015-05-17 22:38:28 +01:00
|
|
|
ui->packageView->selectionModel()->select(model_index, QItemSelectionModel::SelectCurrent | QItemSelectionModel::Rows);
|
|
|
|
updateButtons(row);
|
|
|
|
}
|
|
|
|
|
2015-04-08 12:50:21 +01:00
|
|
|
void VersionPage::onGameUpdateError(QString error)
|
|
|
|
{
|
2019-07-15 22:16:34 +01:00
|
|
|
CustomMessageBox::selectable(this, tr("Error updating instance"), error, QMessageBox::Warning)->show();
|
2015-04-08 12:50:21 +01:00
|
|
|
}
|
2015-05-17 22:38:28 +01:00
|
|
|
|
2023-01-24 19:52:09 +00:00
|
|
|
ComponentPtr VersionPage::current()
|
2015-05-17 22:38:28 +01:00
|
|
|
{
|
|
|
|
auto row = currentRow();
|
2023-07-09 20:47:38 +01:00
|
|
|
if (row < 0) {
|
2015-05-17 22:38:28 +01:00
|
|
|
return nullptr;
|
|
|
|
}
|
2017-11-11 00:38:31 +00:00
|
|
|
return m_profile->getComponent(row);
|
2015-05-17 22:38:28 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
int VersionPage::currentRow()
|
|
|
|
{
|
2023-07-09 20:47:38 +01:00
|
|
|
if (ui->packageView->selectionModel()->selectedRows().isEmpty()) {
|
2015-05-17 22:38:28 +01:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
return ui->packageView->selectionModel()->selectedRows().first().row();
|
|
|
|
}
|
|
|
|
|
2019-07-14 04:37:10 +01:00
|
|
|
void VersionPage::on_actionCustomize_triggered()
|
2015-05-17 22:38:28 +01:00
|
|
|
{
|
|
|
|
auto version = currentRow();
|
2023-07-09 20:47:38 +01:00
|
|
|
if (version == -1) {
|
2015-05-17 22:38:28 +01:00
|
|
|
return;
|
|
|
|
}
|
2017-11-11 00:38:31 +00:00
|
|
|
auto patch = m_profile->getComponent(version);
|
2023-07-09 20:47:38 +01:00
|
|
|
if (!patch->getVersionFile()) {
|
2017-03-19 22:58:54 +00:00
|
|
|
// TODO: wait for the update task to finish here...
|
|
|
|
return;
|
2015-05-28 08:36:58 +01:00
|
|
|
}
|
2023-07-09 20:47:38 +01:00
|
|
|
if (!m_profile->customize(version)) {
|
2015-05-17 22:38:28 +01:00
|
|
|
// TODO: some error box here
|
|
|
|
}
|
|
|
|
updateButtons();
|
|
|
|
preselect(currentIdx);
|
|
|
|
}
|
|
|
|
|
2019-07-14 04:37:10 +01:00
|
|
|
void VersionPage::on_actionEdit_triggered()
|
2015-05-17 22:38:28 +01:00
|
|
|
{
|
|
|
|
auto version = current();
|
2023-07-09 20:47:38 +01:00
|
|
|
if (!version) {
|
2015-05-17 22:38:28 +01:00
|
|
|
return;
|
|
|
|
}
|
2016-03-12 23:23:45 +00:00
|
|
|
auto filename = version->getFilename();
|
2023-07-09 20:47:38 +01:00
|
|
|
if (!QFileInfo::exists(filename)) {
|
2015-05-17 22:38:28 +01:00
|
|
|
qWarning() << "file" << filename << "can't be opened for editing, doesn't exist!";
|
|
|
|
return;
|
|
|
|
}
|
2021-11-20 15:22:22 +00:00
|
|
|
APPLICATION->openJsonEditor(filename);
|
2015-05-17 22:38:28 +01:00
|
|
|
}
|
|
|
|
|
2019-07-14 04:37:10 +01:00
|
|
|
void VersionPage::on_actionRevert_triggered()
|
2015-05-17 22:38:28 +01:00
|
|
|
{
|
|
|
|
auto version = currentRow();
|
2023-07-09 20:47:38 +01:00
|
|
|
if (version == -1) {
|
2015-05-17 22:38:28 +01:00
|
|
|
return;
|
|
|
|
}
|
2022-12-14 15:36:42 +00:00
|
|
|
auto component = m_profile->getComponent(version);
|
|
|
|
|
2022-12-17 09:26:06 +00:00
|
|
|
auto response = CustomMessageBox::selectable(this, tr("Confirm Reversion"),
|
2022-12-26 14:33:50 +00:00
|
|
|
tr("You are about to revert \"%1\".\n"
|
2022-12-14 15:36:42 +00:00
|
|
|
"This is permanent and will completely revert your customizations.\n\n"
|
|
|
|
"Are you sure?")
|
|
|
|
.arg(component->getName()),
|
|
|
|
QMessageBox::Warning, QMessageBox::Yes | QMessageBox::No, QMessageBox::No)
|
|
|
|
->exec();
|
|
|
|
|
|
|
|
if (response != QMessageBox::Yes)
|
|
|
|
return;
|
|
|
|
|
2023-07-09 20:47:38 +01:00
|
|
|
if (!m_profile->revertToBase(version)) {
|
2015-05-17 22:38:28 +01:00
|
|
|
// TODO: some error box here
|
|
|
|
}
|
|
|
|
updateButtons();
|
|
|
|
preselect(currentIdx);
|
2016-11-06 23:18:27 +00:00
|
|
|
m_container->refreshContainer();
|
2015-05-17 22:38:28 +01:00
|
|
|
}
|
2016-02-21 00:44:27 +00:00
|
|
|
|
2023-07-09 20:47:38 +01:00
|
|
|
void VersionPage::onFilterTextChanged(const QString& newContents)
|
2021-06-18 23:21:12 +01:00
|
|
|
{
|
|
|
|
m_filterModel->setFilterFixedString(newContents);
|
|
|
|
}
|
|
|
|
|
2016-02-21 00:44:27 +00:00
|
|
|
#include "VersionPage.moc"
|