2022-03-21 00:31:08 +05:30
|
|
|
// SPDX-License-Identifier: GPL-3.0-only
|
|
|
|
/*
|
|
|
|
* PolyMC - Minecraft Launcher
|
|
|
|
* Copyright (c) 2022 Jamie Mansfield <jmansfield@cadixdev.org>
|
2022-05-27 02:48:54 +05:30
|
|
|
* Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net>
|
2022-03-21 00:31:08 +05:30
|
|
|
*
|
|
|
|
* 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 <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.
|
|
|
|
*/
|
|
|
|
|
2019-11-04 04:18:12 +05:30
|
|
|
#include "Page.h"
|
|
|
|
#include "ui_Page.h"
|
2018-03-19 07:06:12 +05:30
|
|
|
|
2018-08-02 04:22:31 +05:30
|
|
|
#include <QInputDialog>
|
|
|
|
|
2021-11-20 20:52:22 +05:30
|
|
|
#include "Application.h"
|
2021-11-22 08:25:16 +05:30
|
|
|
|
|
|
|
#include "ui/dialogs/CustomMessageBox.h"
|
|
|
|
#include "ui/dialogs/NewInstanceDialog.h"
|
|
|
|
|
2019-11-04 04:18:12 +05:30
|
|
|
#include "modplatform/legacy_ftb/PackFetchTask.h"
|
|
|
|
#include "modplatform/legacy_ftb/PackInstallTask.h"
|
|
|
|
#include "modplatform/legacy_ftb/PrivatePackManager.h"
|
|
|
|
#include "ListModel.h"
|
2018-03-19 07:06:12 +05:30
|
|
|
|
2019-11-04 04:18:12 +05:30
|
|
|
namespace LegacyFTB {
|
|
|
|
|
|
|
|
Page::Page(NewInstanceDialog* dialog, QWidget *parent)
|
|
|
|
: QWidget(parent), dialog(dialog), ui(new Ui::Page)
|
2018-03-19 07:06:12 +05:30
|
|
|
{
|
2021-11-22 03:51:12 +05:30
|
|
|
ftbFetchTask.reset(new PackFetchTask(APPLICATION->network()));
|
2019-11-04 04:18:12 +05:30
|
|
|
ftbPrivatePacks.reset(new PrivatePackManager());
|
2018-04-01 23:54:28 +05:30
|
|
|
|
2018-07-15 18:21:05 +05:30
|
|
|
ui->setupUi(this);
|
2018-03-19 07:06:12 +05:30
|
|
|
|
2018-07-15 18:21:05 +05:30
|
|
|
{
|
2019-11-04 04:18:12 +05:30
|
|
|
publicFilterModel = new FilterModel(this);
|
|
|
|
publicListModel = new ListModel(this);
|
2018-07-15 18:21:05 +05:30
|
|
|
publicFilterModel->setSourceModel(publicListModel);
|
2018-03-19 07:06:12 +05:30
|
|
|
|
2018-07-15 18:21:05 +05:30
|
|
|
ui->publicPackList->setModel(publicFilterModel);
|
|
|
|
ui->publicPackList->setSortingEnabled(true);
|
|
|
|
ui->publicPackList->header()->hide();
|
|
|
|
ui->publicPackList->setIndentation(0);
|
|
|
|
ui->publicPackList->setIconSize(QSize(42, 42));
|
2018-03-19 07:06:12 +05:30
|
|
|
|
2018-07-15 18:21:05 +05:30
|
|
|
for(int i = 0; i < publicFilterModel->getAvailableSortings().size(); i++)
|
|
|
|
{
|
|
|
|
ui->sortByBox->addItem(publicFilterModel->getAvailableSortings().keys().at(i));
|
|
|
|
}
|
2018-03-19 07:06:12 +05:30
|
|
|
|
2018-07-15 18:21:05 +05:30
|
|
|
ui->sortByBox->setCurrentText(publicFilterModel->translateCurrentSorting());
|
|
|
|
}
|
2018-03-19 07:06:12 +05:30
|
|
|
|
2018-07-15 18:21:05 +05:30
|
|
|
{
|
2019-11-04 04:18:12 +05:30
|
|
|
thirdPartyFilterModel = new FilterModel(this);
|
|
|
|
thirdPartyModel = new ListModel(this);
|
2018-07-15 18:21:05 +05:30
|
|
|
thirdPartyFilterModel->setSourceModel(thirdPartyModel);
|
2018-04-01 23:54:28 +05:30
|
|
|
|
2018-07-15 18:21:05 +05:30
|
|
|
ui->thirdPartyPackList->setModel(thirdPartyFilterModel);
|
|
|
|
ui->thirdPartyPackList->setSortingEnabled(true);
|
|
|
|
ui->thirdPartyPackList->header()->hide();
|
|
|
|
ui->thirdPartyPackList->setIndentation(0);
|
|
|
|
ui->thirdPartyPackList->setIconSize(QSize(42, 42));
|
2018-04-06 18:38:59 +05:30
|
|
|
|
2018-07-15 18:21:05 +05:30
|
|
|
thirdPartyFilterModel->setSorting(publicFilterModel->getCurrentSorting());
|
|
|
|
}
|
2018-03-19 07:06:12 +05:30
|
|
|
|
2018-08-02 04:22:31 +05:30
|
|
|
{
|
2019-11-04 04:18:12 +05:30
|
|
|
privateFilterModel = new FilterModel(this);
|
|
|
|
privateListModel = new ListModel(this);
|
2018-08-02 04:22:31 +05:30
|
|
|
privateFilterModel->setSourceModel(privateListModel);
|
|
|
|
|
|
|
|
ui->privatePackList->setModel(privateFilterModel);
|
|
|
|
ui->privatePackList->setSortingEnabled(true);
|
|
|
|
ui->privatePackList->header()->hide();
|
|
|
|
ui->privatePackList->setIndentation(0);
|
|
|
|
ui->privatePackList->setIconSize(QSize(42, 42));
|
|
|
|
|
|
|
|
privateFilterModel->setSorting(publicFilterModel->getCurrentSorting());
|
|
|
|
}
|
|
|
|
|
|
|
|
ui->versionSelectionBox->view()->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
|
|
|
|
ui->versionSelectionBox->view()->parentWidget()->setMaximumHeight(300);
|
2018-04-07 19:45:58 +05:30
|
|
|
|
2019-11-04 04:18:12 +05:30
|
|
|
connect(ui->sortByBox, &QComboBox::currentTextChanged, this, &Page::onSortingSelectionChanged);
|
|
|
|
connect(ui->versionSelectionBox, &QComboBox::currentTextChanged, this, &Page::onVersionSelectionItemChanged);
|
2018-04-01 23:54:28 +05:30
|
|
|
|
2019-11-04 04:18:12 +05:30
|
|
|
connect(ui->publicPackList->selectionModel(), &QItemSelectionModel::currentChanged, this, &Page::onPublicPackSelectionChanged);
|
|
|
|
connect(ui->thirdPartyPackList->selectionModel(), &QItemSelectionModel::currentChanged, this, &Page::onThirdPartyPackSelectionChanged);
|
|
|
|
connect(ui->privatePackList->selectionModel(), &QItemSelectionModel::currentChanged, this, &Page::onPrivatePackSelectionChanged);
|
2018-08-02 04:22:31 +05:30
|
|
|
|
2019-11-04 04:18:12 +05:30
|
|
|
connect(ui->addPackBtn, &QPushButton::pressed, this, &Page::onAddPackClicked);
|
|
|
|
connect(ui->removePackBtn, &QPushButton::pressed, this, &Page::onRemovePackClicked);
|
2018-03-19 07:06:12 +05:30
|
|
|
|
2019-11-04 04:18:12 +05:30
|
|
|
connect(ui->tabWidget, &QTabWidget::currentChanged, this, &Page::onTabChanged);
|
2018-04-05 23:03:31 +05:30
|
|
|
|
2018-08-02 04:22:31 +05:30
|
|
|
// ui->modpackInfo->setOpenExternalLinks(true);
|
2018-04-05 23:03:31 +05:30
|
|
|
|
2018-07-15 18:21:05 +05:30
|
|
|
ui->publicPackList->selectionModel()->reset();
|
|
|
|
ui->thirdPartyPackList->selectionModel()->reset();
|
2018-08-02 04:22:31 +05:30
|
|
|
ui->privatePackList->selectionModel()->reset();
|
|
|
|
|
|
|
|
onTabChanged(ui->tabWidget->currentIndex());
|
2018-03-19 07:06:12 +05:30
|
|
|
}
|
|
|
|
|
2019-11-04 04:18:12 +05:30
|
|
|
Page::~Page()
|
2018-03-19 07:06:12 +05:30
|
|
|
{
|
2018-07-15 18:21:05 +05:30
|
|
|
delete ui;
|
2018-03-19 07:06:12 +05:30
|
|
|
}
|
|
|
|
|
2019-11-04 04:18:12 +05:30
|
|
|
bool Page::shouldDisplay() const
|
2018-03-19 07:06:12 +05:30
|
|
|
{
|
2018-07-15 18:21:05 +05:30
|
|
|
return true;
|
2018-03-19 07:06:12 +05:30
|
|
|
}
|
|
|
|
|
2019-11-04 04:18:12 +05:30
|
|
|
void Page::openedImpl()
|
2018-03-19 07:06:12 +05:30
|
|
|
{
|
2018-07-15 18:21:05 +05:30
|
|
|
if(!initialized)
|
|
|
|
{
|
2019-11-04 04:18:12 +05:30
|
|
|
connect(ftbFetchTask.get(), &PackFetchTask::finished, this, &Page::ftbPackDataDownloadSuccessfully);
|
|
|
|
connect(ftbFetchTask.get(), &PackFetchTask::failed, this, &Page::ftbPackDataDownloadFailed);
|
2018-08-02 04:22:31 +05:30
|
|
|
|
2019-11-04 04:18:12 +05:30
|
|
|
connect(ftbFetchTask.get(), &PackFetchTask::privateFileDownloadFinished, this, &Page::ftbPrivatePackDataDownloadSuccessfully);
|
|
|
|
connect(ftbFetchTask.get(), &PackFetchTask::privateFileDownloadFailed, this, &Page::ftbPrivatePackDataDownloadFailed);
|
2018-08-02 04:22:31 +05:30
|
|
|
|
2018-07-15 18:21:05 +05:30
|
|
|
ftbFetchTask->fetch();
|
2018-08-02 04:22:31 +05:30
|
|
|
ftbPrivatePacks->load();
|
2022-05-02 22:40:45 +05:30
|
|
|
ftbFetchTask->fetchPrivate(ftbPrivatePacks->getCurrentPackCodes().values());
|
2018-07-15 18:21:05 +05:30
|
|
|
initialized = true;
|
|
|
|
}
|
|
|
|
suggestCurrent();
|
2018-03-19 07:06:12 +05:30
|
|
|
}
|
|
|
|
|
2022-02-22 23:53:53 +05:30
|
|
|
void Page::retranslate()
|
|
|
|
{
|
|
|
|
ui->retranslateUi(this);
|
|
|
|
}
|
|
|
|
|
2019-11-04 04:18:12 +05:30
|
|
|
void Page::suggestCurrent()
|
2018-03-19 07:06:12 +05:30
|
|
|
{
|
2021-06-19 19:49:39 +05:30
|
|
|
if(!isOpened)
|
2018-07-15 18:21:05 +05:30
|
|
|
{
|
2021-06-19 19:49:39 +05:30
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-06-21 02:22:10 +05:30
|
|
|
if(selected.broken || selectedVersion.isEmpty())
|
2021-06-19 19:49:39 +05:30
|
|
|
{
|
|
|
|
dialog->setSuggestedPack();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-07-15 00:43:23 +05:30
|
|
|
dialog->setSuggestedPack(selected.name, selectedVersion, new PackInstallTask(APPLICATION->network(), selected, selectedVersion));
|
2021-06-19 19:49:39 +05:30
|
|
|
QString editedLogoName;
|
|
|
|
if(selected.logo.toLower().startsWith("ftb"))
|
|
|
|
{
|
|
|
|
editedLogoName = selected.logo;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
editedLogoName = "ftb_" + selected.logo;
|
|
|
|
}
|
|
|
|
|
|
|
|
editedLogoName = editedLogoName.left(editedLogoName.lastIndexOf(".png"));
|
|
|
|
|
|
|
|
if(selected.type == PackType::Public)
|
|
|
|
{
|
|
|
|
publicListModel->getLogo(selected.logo, [this, editedLogoName](QString logo)
|
2018-07-15 18:21:05 +05:30
|
|
|
{
|
2021-06-19 19:49:39 +05:30
|
|
|
dialog->setSuggestedIconFromFile(logo, editedLogoName);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
else if (selected.type == PackType::ThirdParty)
|
|
|
|
{
|
|
|
|
thirdPartyModel->getLogo(selected.logo, [this, editedLogoName](QString logo)
|
2018-07-15 18:21:05 +05:30
|
|
|
{
|
2021-06-19 19:49:39 +05:30
|
|
|
dialog->setSuggestedIconFromFile(logo, editedLogoName);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
else if (selected.type == PackType::Private)
|
|
|
|
{
|
|
|
|
privateListModel->getLogo(selected.logo, [this, editedLogoName](QString logo)
|
|
|
|
{
|
|
|
|
dialog->setSuggestedIconFromFile(logo, editedLogoName);
|
|
|
|
});
|
2018-07-15 18:21:05 +05:30
|
|
|
}
|
2018-03-19 07:06:12 +05:30
|
|
|
}
|
|
|
|
|
2019-11-04 04:18:12 +05:30
|
|
|
void Page::ftbPackDataDownloadSuccessfully(ModpackList publicPacks, ModpackList thirdPartyPacks)
|
2018-04-01 23:54:28 +05:30
|
|
|
{
|
2018-07-15 18:21:05 +05:30
|
|
|
publicListModel->fill(publicPacks);
|
|
|
|
thirdPartyModel->fill(thirdPartyPacks);
|
2018-04-01 23:54:28 +05:30
|
|
|
}
|
|
|
|
|
2019-11-04 04:18:12 +05:30
|
|
|
void Page::ftbPackDataDownloadFailed(QString reason)
|
2018-03-19 07:06:12 +05:30
|
|
|
{
|
2018-07-15 18:21:05 +05:30
|
|
|
//TODO: Display the error
|
2018-03-19 07:06:12 +05:30
|
|
|
}
|
|
|
|
|
2019-11-04 04:18:12 +05:30
|
|
|
void Page::ftbPrivatePackDataDownloadSuccessfully(Modpack pack)
|
2018-08-02 04:22:31 +05:30
|
|
|
{
|
|
|
|
privateListModel->addPack(pack);
|
|
|
|
}
|
|
|
|
|
2019-11-04 04:18:12 +05:30
|
|
|
void Page::ftbPrivatePackDataDownloadFailed(QString reason, QString packCode)
|
2018-08-02 04:22:31 +05:30
|
|
|
{
|
|
|
|
auto reply = QMessageBox::question(
|
|
|
|
this,
|
|
|
|
tr("FTB private packs"),
|
|
|
|
tr("Failed to download pack information for code %1.\nShould it be removed now?").arg(packCode)
|
|
|
|
);
|
|
|
|
if(reply == QMessageBox::Yes)
|
|
|
|
{
|
|
|
|
ftbPrivatePacks->remove(packCode);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-04 04:18:12 +05:30
|
|
|
void Page::onPublicPackSelectionChanged(QModelIndex now, QModelIndex prev)
|
2018-03-19 07:06:12 +05:30
|
|
|
{
|
2018-07-15 18:21:05 +05:30
|
|
|
if(!now.isValid())
|
|
|
|
{
|
|
|
|
onPackSelectionChanged();
|
|
|
|
return;
|
|
|
|
}
|
2019-11-04 04:18:12 +05:30
|
|
|
Modpack selectedPack = publicFilterModel->data(now, Qt::UserRole).value<Modpack>();
|
2018-07-15 18:21:05 +05:30
|
|
|
onPackSelectionChanged(&selectedPack);
|
2018-03-19 07:06:12 +05:30
|
|
|
}
|
|
|
|
|
2019-11-04 04:18:12 +05:30
|
|
|
void Page::onThirdPartyPackSelectionChanged(QModelIndex now, QModelIndex prev)
|
2018-03-19 07:06:12 +05:30
|
|
|
{
|
2018-07-15 18:21:05 +05:30
|
|
|
if(!now.isValid())
|
|
|
|
{
|
|
|
|
onPackSelectionChanged();
|
|
|
|
return;
|
|
|
|
}
|
2019-11-04 04:18:12 +05:30
|
|
|
Modpack selectedPack = thirdPartyFilterModel->data(now, Qt::UserRole).value<Modpack>();
|
2018-07-15 18:21:05 +05:30
|
|
|
onPackSelectionChanged(&selectedPack);
|
2018-03-19 07:06:12 +05:30
|
|
|
}
|
|
|
|
|
2019-11-04 04:18:12 +05:30
|
|
|
void Page::onPrivatePackSelectionChanged(QModelIndex now, QModelIndex prev)
|
2018-08-02 04:22:31 +05:30
|
|
|
{
|
|
|
|
if(!now.isValid())
|
|
|
|
{
|
|
|
|
onPackSelectionChanged();
|
|
|
|
return;
|
|
|
|
}
|
2019-11-04 04:18:12 +05:30
|
|
|
Modpack selectedPack = privateFilterModel->data(now, Qt::UserRole).value<Modpack>();
|
2018-08-02 04:22:31 +05:30
|
|
|
onPackSelectionChanged(&selectedPack);
|
|
|
|
}
|
|
|
|
|
2019-11-04 04:18:12 +05:30
|
|
|
void Page::onPackSelectionChanged(Modpack* pack)
|
2018-03-19 07:06:12 +05:30
|
|
|
{
|
2018-08-02 04:22:31 +05:30
|
|
|
ui->versionSelectionBox->clear();
|
2018-07-15 18:21:05 +05:30
|
|
|
if(pack)
|
|
|
|
{
|
2018-08-02 04:22:31 +05:30
|
|
|
currentModpackInfo->setHtml("Pack by <b>" + pack->author + "</b>" +
|
|
|
|
"<br>Minecraft " + pack->mcVersion + "<br>" + "<br>" + pack->description + "<ul><li>" + pack->mods.replace(";", "</li><li>")
|
|
|
|
+ "</li></ul>");
|
2018-07-15 18:21:05 +05:30
|
|
|
bool currentAdded = false;
|
|
|
|
|
|
|
|
for(int i = 0; i < pack->oldVersions.size(); i++)
|
|
|
|
{
|
|
|
|
if(pack->currentVersion == pack->oldVersions.at(i))
|
|
|
|
{
|
|
|
|
currentAdded = true;
|
|
|
|
}
|
2018-08-02 04:22:31 +05:30
|
|
|
ui->versionSelectionBox->addItem(pack->oldVersions.at(i));
|
2018-07-15 18:21:05 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
if(!currentAdded)
|
|
|
|
{
|
2018-08-02 04:22:31 +05:30
|
|
|
ui->versionSelectionBox->addItem(pack->currentVersion);
|
2018-07-15 18:21:05 +05:30
|
|
|
}
|
|
|
|
selected = *pack;
|
|
|
|
}
|
2018-08-02 04:22:31 +05:30
|
|
|
else
|
|
|
|
{
|
|
|
|
currentModpackInfo->setHtml("");
|
|
|
|
ui->versionSelectionBox->clear();
|
|
|
|
if(isOpened)
|
|
|
|
{
|
|
|
|
dialog->setSuggestedPack();
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
2018-07-15 18:21:05 +05:30
|
|
|
suggestCurrent();
|
2018-03-19 07:06:12 +05:30
|
|
|
}
|
|
|
|
|
2019-11-04 04:18:12 +05:30
|
|
|
void Page::onVersionSelectionItemChanged(QString data)
|
2018-03-19 07:06:12 +05:30
|
|
|
{
|
2018-07-15 18:21:05 +05:30
|
|
|
if(data.isNull() || data.isEmpty())
|
|
|
|
{
|
|
|
|
selectedVersion = "";
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
selectedVersion = data;
|
|
|
|
suggestCurrent();
|
2018-03-19 07:06:12 +05:30
|
|
|
}
|
|
|
|
|
2019-11-04 04:18:12 +05:30
|
|
|
void Page::onSortingSelectionChanged(QString data)
|
2018-03-19 07:06:12 +05:30
|
|
|
{
|
2019-11-04 04:18:12 +05:30
|
|
|
FilterModel::Sorting toSet = publicFilterModel->getAvailableSortings().value(data);
|
2018-07-15 18:21:05 +05:30
|
|
|
publicFilterModel->setSorting(toSet);
|
|
|
|
thirdPartyFilterModel->setSorting(toSet);
|
2018-08-02 04:22:31 +05:30
|
|
|
privateFilterModel->setSorting(toSet);
|
2018-03-19 07:06:12 +05:30
|
|
|
}
|
2018-04-05 23:03:31 +05:30
|
|
|
|
2019-11-04 04:18:12 +05:30
|
|
|
void Page::onTabChanged(int tab)
|
2018-04-05 23:03:31 +05:30
|
|
|
{
|
2018-08-02 04:22:31 +05:30
|
|
|
if(tab == 1)
|
2018-07-15 18:21:05 +05:30
|
|
|
{
|
2018-08-02 04:22:31 +05:30
|
|
|
currentModel = thirdPartyFilterModel;
|
|
|
|
currentList = ui->thirdPartyPackList;
|
|
|
|
currentModpackInfo = ui->thirdPartyPackDescription;
|
|
|
|
}
|
|
|
|
else if(tab == 2)
|
|
|
|
{
|
|
|
|
currentModel = privateFilterModel;
|
|
|
|
currentList = ui->privatePackList;
|
|
|
|
currentModpackInfo = ui->privatePackDescription;
|
2018-07-15 18:21:05 +05:30
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-08-02 04:22:31 +05:30
|
|
|
currentModel = publicFilterModel;
|
|
|
|
currentList = ui->publicPackList;
|
|
|
|
currentModpackInfo = ui->publicPackDescription;
|
2018-07-15 18:21:05 +05:30
|
|
|
}
|
2018-08-02 04:22:31 +05:30
|
|
|
|
|
|
|
currentList->selectionModel()->reset();
|
2018-07-15 18:21:05 +05:30
|
|
|
QModelIndex idx = currentList->currentIndex();
|
|
|
|
if(idx.isValid())
|
|
|
|
{
|
2019-11-04 04:18:12 +05:30
|
|
|
auto pack = currentModel->data(idx, Qt::UserRole).value<Modpack>();
|
2018-07-15 18:21:05 +05:30
|
|
|
onPackSelectionChanged(&pack);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
onPackSelectionChanged();
|
|
|
|
}
|
2018-04-05 23:03:31 +05:30
|
|
|
}
|
2018-08-02 04:22:31 +05:30
|
|
|
|
2019-11-04 04:18:12 +05:30
|
|
|
void Page::onAddPackClicked()
|
2018-08-02 04:22:31 +05:30
|
|
|
{
|
|
|
|
bool ok;
|
|
|
|
QString text = QInputDialog::getText(
|
|
|
|
this,
|
|
|
|
tr("Add FTB pack"),
|
|
|
|
tr("Enter pack code:"),
|
|
|
|
QLineEdit::Normal,
|
|
|
|
QString(),
|
|
|
|
&ok
|
|
|
|
);
|
|
|
|
if(ok && !text.isEmpty())
|
|
|
|
{
|
|
|
|
ftbPrivatePacks->add(text);
|
|
|
|
ftbFetchTask->fetchPrivate({text});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-04 04:18:12 +05:30
|
|
|
void Page::onRemovePackClicked()
|
2018-08-02 04:22:31 +05:30
|
|
|
{
|
|
|
|
auto index = ui->privatePackList->currentIndex();
|
|
|
|
if(!index.isValid())
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
auto row = index.row();
|
2019-11-04 04:18:12 +05:30
|
|
|
Modpack pack = privateListModel->at(row);
|
2018-08-02 04:22:31 +05:30
|
|
|
auto answer = QMessageBox::question(
|
|
|
|
this,
|
|
|
|
tr("Remove pack"),
|
|
|
|
tr("Are you sure you want to remove pack %1?").arg(pack.name),
|
|
|
|
QMessageBox::Yes | QMessageBox::No
|
|
|
|
);
|
|
|
|
if(answer != QMessageBox::Yes)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ftbPrivatePacks->remove(pack.packCode);
|
|
|
|
privateListModel->remove(row);
|
|
|
|
onPackSelectionChanged();
|
|
|
|
}
|
2019-11-04 04:18:12 +05:30
|
|
|
|
|
|
|
}
|