Merge remote-tracking branch 'upstream/develop' into data-packs
Signed-off-by: TheKodeToad <TheKodeToad@proton.me>
This commit is contained in:
commit
fadbcf2d04
279 changed files with 9562 additions and 2103 deletions
|
@ -44,7 +44,7 @@ ResourceAPI::SearchArgs ModModel::createSearchArguments()
|
|||
};
|
||||
}
|
||||
|
||||
ResourceAPI::VersionSearchArgs ModModel::createVersionsArguments(QModelIndex& entry)
|
||||
ResourceAPI::VersionSearchArgs ModModel::createVersionsArguments(const QModelIndex& entry)
|
||||
{
|
||||
auto& pack = *m_packs[entry.row()];
|
||||
auto profile = static_cast<MinecraftInstance const&>(m_base_instance).getPackProfile();
|
||||
|
@ -62,7 +62,7 @@ ResourceAPI::VersionSearchArgs ModModel::createVersionsArguments(QModelIndex& en
|
|||
return { pack, versions, loaders };
|
||||
}
|
||||
|
||||
ResourceAPI::ProjectInfoArgs ModModel::createInfoArguments(QModelIndex& entry)
|
||||
ResourceAPI::ProjectInfoArgs ModModel::createInfoArguments(const QModelIndex& entry)
|
||||
{
|
||||
auto& pack = *m_packs[entry.row()];
|
||||
return { pack };
|
||||
|
|
|
@ -39,8 +39,8 @@ class ModModel : public ResourceModel {
|
|||
|
||||
public slots:
|
||||
ResourceAPI::SearchArgs createSearchArguments() override;
|
||||
ResourceAPI::VersionSearchArgs createVersionsArguments(QModelIndex&) override;
|
||||
ResourceAPI::ProjectInfoArgs createInfoArguments(QModelIndex&) override;
|
||||
ResourceAPI::VersionSearchArgs createVersionsArguments(const QModelIndex&) override;
|
||||
ResourceAPI::ProjectInfoArgs createInfoArguments(const QModelIndex&) override;
|
||||
|
||||
protected:
|
||||
auto documentToArray(QJsonDocument& obj) const -> QJsonArray override = 0;
|
||||
|
|
|
@ -59,7 +59,6 @@ namespace ResourceDownload {
|
|||
ModPage::ModPage(ModDownloadDialog* dialog, BaseInstance& instance) : ResourcePage(dialog, instance)
|
||||
{
|
||||
connect(m_ui->resourceFilterButton, &QPushButton::clicked, this, &ModPage::filterMods);
|
||||
connect(m_ui->packView, &QListView::doubleClicked, this, &ModPage::onResourceSelected);
|
||||
}
|
||||
|
||||
void ModPage::setFilterWidget(unique_qobject_ptr<ModFilterWidget>& widget)
|
||||
|
|
|
@ -35,8 +35,9 @@ class ModPage : public ResourcePage {
|
|||
page->setFilterWidget(filter_widget);
|
||||
model->setFilter(page->getFilter());
|
||||
|
||||
connect(model, &ResourceModel::versionListUpdated, page, &ResourcePage::updateVersionList);
|
||||
connect(model, &ResourceModel::versionListUpdated, page, &ResourcePage::versionListUpdated);
|
||||
connect(model, &ResourceModel::projectInfoUpdated, page, &ResourcePage::updateUi);
|
||||
connect(model, &QAbstractListModel::modelReset, page, &ResourcePage::modelReset);
|
||||
|
||||
return page;
|
||||
}
|
||||
|
|
|
@ -82,8 +82,8 @@ auto ResourceModel::data(const QModelIndex& index, int role) const -> QVariant
|
|||
return pack->name;
|
||||
case UserDataTypes::DESCRIPTION:
|
||||
return pack->description;
|
||||
case UserDataTypes::SELECTED:
|
||||
return pack->isAnyVersionSelected();
|
||||
case Qt::CheckStateRole:
|
||||
return pack->isAnyVersionSelected() ? Qt::Checked : Qt::Unchecked;
|
||||
case UserDataTypes::INSTALLED:
|
||||
return this->isPackInstalled(pack);
|
||||
default:
|
||||
|
@ -103,7 +103,6 @@ QHash<int, QByteArray> ResourceModel::roleNames() const
|
|||
roles[Qt::UserRole] = "pack";
|
||||
roles[UserDataTypes::TITLE] = "title";
|
||||
roles[UserDataTypes::DESCRIPTION] = "description";
|
||||
roles[UserDataTypes::SELECTED] = "selected";
|
||||
roles[UserDataTypes::INSTALLED] = "installed";
|
||||
|
||||
return roles;
|
||||
|
@ -193,7 +192,7 @@ void ResourceModel::search()
|
|||
runSearchJob(job);
|
||||
}
|
||||
|
||||
void ResourceModel::loadEntry(QModelIndex& entry)
|
||||
void ResourceModel::loadEntry(const QModelIndex& entry)
|
||||
{
|
||||
auto const& pack = m_packs[entry.row()];
|
||||
|
||||
|
@ -504,7 +503,7 @@ void ResourceModel::versionRequestSucceeded(QJsonDocument& doc, ModPlatform::Ind
|
|||
return;
|
||||
}
|
||||
|
||||
emit versionListUpdated();
|
||||
emit versionListUpdated(index);
|
||||
}
|
||||
|
||||
void ResourceModel::infoRequestSucceeded(QJsonDocument& doc, ModPlatform::IndexedPack& pack, const QModelIndex& index)
|
||||
|
@ -531,7 +530,7 @@ void ResourceModel::infoRequestSucceeded(QJsonDocument& doc, ModPlatform::Indexe
|
|||
return;
|
||||
}
|
||||
|
||||
emit projectInfoUpdated();
|
||||
emit projectInfoUpdated(index);
|
||||
}
|
||||
|
||||
void ResourceModel::addPack(ModPlatform::IndexedPack::Ptr pack,
|
||||
|
|
|
@ -80,17 +80,17 @@ class ResourceModel : public QAbstractListModel {
|
|||
virtual ResourceAPI::SearchArgs createSearchArguments() = 0;
|
||||
virtual ResourceAPI::SearchCallbacks createSearchCallbacks() { return {}; }
|
||||
|
||||
virtual ResourceAPI::VersionSearchArgs createVersionsArguments(QModelIndex&) = 0;
|
||||
virtual ResourceAPI::VersionSearchCallbacks createVersionsCallbacks(QModelIndex&) { return {}; }
|
||||
virtual ResourceAPI::VersionSearchArgs createVersionsArguments(const QModelIndex&) = 0;
|
||||
virtual ResourceAPI::VersionSearchCallbacks createVersionsCallbacks(const QModelIndex&) { return {}; }
|
||||
|
||||
virtual ResourceAPI::ProjectInfoArgs createInfoArguments(QModelIndex&) = 0;
|
||||
virtual ResourceAPI::ProjectInfoCallbacks createInfoCallbacks(QModelIndex&) { return {}; }
|
||||
virtual ResourceAPI::ProjectInfoArgs createInfoArguments(const QModelIndex&) = 0;
|
||||
virtual ResourceAPI::ProjectInfoCallbacks createInfoCallbacks(const QModelIndex&) { return {}; }
|
||||
|
||||
/** Requests the API for more entries. */
|
||||
virtual void search();
|
||||
|
||||
/** Applies any processing / extra requests needed to fully load the specified entry's information. */
|
||||
virtual void loadEntry(QModelIndex&);
|
||||
virtual void loadEntry(const QModelIndex&);
|
||||
|
||||
/** Schedule a refresh, clearing the current state. */
|
||||
void refresh();
|
||||
|
@ -170,8 +170,8 @@ class ResourceModel : public QAbstractListModel {
|
|||
void infoRequestSucceeded(QJsonDocument&, ModPlatform::IndexedPack&, const QModelIndex&);
|
||||
|
||||
signals:
|
||||
void versionListUpdated();
|
||||
void projectInfoUpdated();
|
||||
void versionListUpdated(const QModelIndex& index);
|
||||
void projectInfoUpdated(const QModelIndex& index);
|
||||
};
|
||||
|
||||
} // namespace ResourceDownload
|
||||
|
|
|
@ -20,13 +20,13 @@ ResourceAPI::SearchArgs ResourcePackResourceModel::createSearchArguments()
|
|||
return { ModPlatform::ResourceType::RESOURCE_PACK, m_next_search_offset, m_search_term, sort };
|
||||
}
|
||||
|
||||
ResourceAPI::VersionSearchArgs ResourcePackResourceModel::createVersionsArguments(QModelIndex& entry)
|
||||
ResourceAPI::VersionSearchArgs ResourcePackResourceModel::createVersionsArguments(const QModelIndex& entry)
|
||||
{
|
||||
auto& pack = m_packs[entry.row()];
|
||||
return { *pack };
|
||||
}
|
||||
|
||||
ResourceAPI::ProjectInfoArgs ResourcePackResourceModel::createInfoArguments(QModelIndex& entry)
|
||||
ResourceAPI::ProjectInfoArgs ResourcePackResourceModel::createInfoArguments(const QModelIndex& entry)
|
||||
{
|
||||
auto& pack = m_packs[entry.row()];
|
||||
return { *pack };
|
||||
|
|
|
@ -31,8 +31,8 @@ class ResourcePackResourceModel : public ResourceModel {
|
|||
|
||||
public slots:
|
||||
ResourceAPI::SearchArgs createSearchArguments() override;
|
||||
ResourceAPI::VersionSearchArgs createVersionsArguments(QModelIndex&) override;
|
||||
ResourceAPI::ProjectInfoArgs createInfoArguments(QModelIndex&) override;
|
||||
ResourceAPI::VersionSearchArgs createVersionsArguments(const QModelIndex&) override;
|
||||
ResourceAPI::ProjectInfoArgs createInfoArguments(const QModelIndex&) override;
|
||||
|
||||
protected:
|
||||
const BaseInstance& m_base_instance;
|
||||
|
|
|
@ -14,9 +14,7 @@
|
|||
namespace ResourceDownload {
|
||||
|
||||
ResourcePackResourcePage::ResourcePackResourcePage(ResourceDownloadDialog* dialog, BaseInstance& instance) : ResourcePage(dialog, instance)
|
||||
{
|
||||
connect(m_ui->packView, &QListView::doubleClicked, this, &ResourcePackResourcePage::onResourceSelected);
|
||||
}
|
||||
{}
|
||||
|
||||
/******** Callbacks to events in the UI (set up in the derived classes) ********/
|
||||
|
||||
|
|
|
@ -25,8 +25,9 @@ class ResourcePackResourcePage : public ResourcePage {
|
|||
auto page = new T(dialog, instance);
|
||||
auto model = static_cast<ResourcePackResourceModel*>(page->getModel());
|
||||
|
||||
connect(model, &ResourceModel::versionListUpdated, page, &ResourcePage::updateVersionList);
|
||||
connect(model, &ResourceModel::versionListUpdated, page, &ResourcePage::versionListUpdated);
|
||||
connect(model, &ResourceModel::projectInfoUpdated, page, &ResourcePage::updateUi);
|
||||
connect(model, &QAbstractListModel::modelReset, page, &ResourcePage::modelReset);
|
||||
|
||||
return page;
|
||||
}
|
||||
|
|
|
@ -78,10 +78,15 @@ ResourcePage::ResourcePage(ResourceDownloadDialog* parent, BaseInstance& base_in
|
|||
|
||||
m_ui->verticalLayout->insertWidget(1, &m_fetchProgress);
|
||||
|
||||
m_ui->packView->setItemDelegate(new ProjectItemDelegate(this));
|
||||
auto delegate = new ProjectItemDelegate(this);
|
||||
m_ui->packView->setItemDelegate(delegate);
|
||||
m_ui->packView->installEventFilter(this);
|
||||
m_ui->packView->viewport()->installEventFilter(this);
|
||||
|
||||
connect(m_ui->packDescription, &QTextBrowser::anchorClicked, this, &ResourcePage::openUrl);
|
||||
|
||||
connect(m_ui->packView, &QListView::doubleClicked, this, &ResourcePage::onResourceToggle);
|
||||
connect(delegate, &ProjectItemDelegate::checkboxClicked, this, &ResourcePage::onResourceToggle);
|
||||
}
|
||||
|
||||
ResourcePage::~ResourcePage()
|
||||
|
@ -128,17 +133,20 @@ auto ResourcePage::eventFilter(QObject* watched, QEvent* event) -> bool
|
|||
m_searchTimer.start(350);
|
||||
}
|
||||
} else if (watched == m_ui->packView) {
|
||||
// stop the event from going to the confirm button
|
||||
if (keyEvent->key() == Qt::Key_Return) {
|
||||
onResourceSelected();
|
||||
|
||||
// To have the 'select mod' button outlined instead of the 'review and confirm' one
|
||||
m_ui->resourceSelectionButton->setFocus(Qt::FocusReason::ShortcutFocusReason);
|
||||
m_ui->packView->setFocus(Qt::FocusReason::NoFocusReason);
|
||||
|
||||
onResourceToggle(m_ui->packView->currentIndex());
|
||||
keyEvent->accept();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} else if (watched == m_ui->packView->viewport() && event->type() == QEvent::MouseButtonPress) {
|
||||
auto* mouseEvent = static_cast<QMouseEvent*>(event);
|
||||
|
||||
if (mouseEvent->button() == Qt::MiddleButton) {
|
||||
onResourceToggle(m_ui->packView->indexAt(mouseEvent->pos()));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return QWidget::eventFilter(watched, event);
|
||||
|
@ -177,8 +185,11 @@ ModPlatform::IndexedPack::Ptr ResourcePage::getCurrentPack() const
|
|||
return m_model->data(m_ui->packView->currentIndex(), Qt::UserRole).value<ModPlatform::IndexedPack::Ptr>();
|
||||
}
|
||||
|
||||
void ResourcePage::updateUi()
|
||||
void ResourcePage::updateUi(const QModelIndex& index)
|
||||
{
|
||||
if (index != m_ui->packView->currentIndex())
|
||||
return;
|
||||
|
||||
auto current_pack = getCurrentPack();
|
||||
if (!current_pack) {
|
||||
m_ui->packDescription->setHtml({});
|
||||
|
@ -268,39 +279,48 @@ void ResourcePage::updateSelectionButton()
|
|||
}
|
||||
}
|
||||
|
||||
void ResourcePage::updateVersionList()
|
||||
void ResourcePage::versionListUpdated(const QModelIndex& index)
|
||||
{
|
||||
auto current_pack = getCurrentPack();
|
||||
if (index == m_ui->packView->currentIndex()) {
|
||||
auto current_pack = getCurrentPack();
|
||||
|
||||
m_ui->versionSelectionBox->blockSignals(true);
|
||||
m_ui->versionSelectionBox->clear();
|
||||
m_ui->versionSelectionBox->blockSignals(false);
|
||||
m_ui->versionSelectionBox->blockSignals(true);
|
||||
m_ui->versionSelectionBox->clear();
|
||||
m_ui->versionSelectionBox->blockSignals(false);
|
||||
|
||||
if (current_pack) {
|
||||
auto installedVersion = m_model->getInstalledPackVersion(current_pack);
|
||||
if (current_pack) {
|
||||
auto installedVersion = m_model->getInstalledPackVersion(current_pack);
|
||||
|
||||
for (int i = 0; i < current_pack->versions.size(); i++) {
|
||||
auto& version = current_pack->versions[i];
|
||||
if (!m_model->checkVersionFilters(version))
|
||||
continue;
|
||||
for (int i = 0; i < current_pack->versions.size(); i++) {
|
||||
auto& version = current_pack->versions[i];
|
||||
if (!m_model->checkVersionFilters(version))
|
||||
continue;
|
||||
|
||||
auto versionText = version.version;
|
||||
if (version.version_type.isValid()) {
|
||||
versionText += QString(" [%1]").arg(version.version_type.toString());
|
||||
auto versionText = version.version;
|
||||
if (version.version_type.isValid()) {
|
||||
versionText += QString(" [%1]").arg(version.version_type.toString());
|
||||
}
|
||||
if (version.fileId == installedVersion) {
|
||||
versionText += tr(" [installed]", "Mod version select");
|
||||
}
|
||||
|
||||
m_ui->versionSelectionBox->addItem(versionText, QVariant(i));
|
||||
}
|
||||
if (version.fileId == installedVersion) {
|
||||
versionText += tr(" [installed]", "Mod version select");
|
||||
}
|
||||
|
||||
m_ui->versionSelectionBox->addItem(versionText, QVariant(i));
|
||||
}
|
||||
}
|
||||
if (m_ui->versionSelectionBox->count() == 0) {
|
||||
m_ui->versionSelectionBox->addItem(tr("No valid version found."), QVariant(-1));
|
||||
m_ui->resourceSelectionButton->setText(tr("Cannot select invalid version :("));
|
||||
}
|
||||
if (m_ui->versionSelectionBox->count() == 0) {
|
||||
m_ui->versionSelectionBox->addItem(tr("No valid version found."), QVariant(-1));
|
||||
m_ui->resourceSelectionButton->setText(tr("Cannot select invalid version :("));
|
||||
}
|
||||
|
||||
updateSelectionButton();
|
||||
if (m_enableQueue.contains(index.row())) {
|
||||
m_enableQueue.remove(index.row());
|
||||
onResourceToggle(index);
|
||||
} else
|
||||
updateSelectionButton();
|
||||
} else if (m_enableQueue.contains(index.row())) {
|
||||
m_enableQueue.remove(index.row());
|
||||
onResourceToggle(index);
|
||||
}
|
||||
}
|
||||
|
||||
void ResourcePage::onSelectionChanged(QModelIndex curr, [[maybe_unused]] QModelIndex prev)
|
||||
|
@ -318,16 +338,20 @@ void ResourcePage::onSelectionChanged(QModelIndex curr, [[maybe_unused]] QModelI
|
|||
|
||||
request_load = true;
|
||||
} else {
|
||||
updateVersionList();
|
||||
versionListUpdated(curr);
|
||||
}
|
||||
|
||||
if (current_pack && !current_pack->extraDataLoaded)
|
||||
request_load = true;
|
||||
|
||||
// we are already requesting this
|
||||
if (m_enableQueue.contains(curr.row()))
|
||||
request_load = false;
|
||||
|
||||
if (request_load)
|
||||
m_model->loadEntry(curr);
|
||||
|
||||
updateUi();
|
||||
updateUi(curr);
|
||||
}
|
||||
|
||||
void ResourcePage::onVersionSelectionChanged(int index)
|
||||
|
@ -354,6 +378,11 @@ void ResourcePage::addResourceToPage(ModPlatform::IndexedPack::Ptr pack,
|
|||
m_model->addPack(pack, ver, base_model, is_indexed);
|
||||
}
|
||||
|
||||
void ResourcePage::modelReset()
|
||||
{
|
||||
m_enableQueue.clear();
|
||||
}
|
||||
|
||||
void ResourcePage::removeResourceFromPage(const QString& name)
|
||||
{
|
||||
m_model->removePack(name);
|
||||
|
@ -385,6 +414,48 @@ void ResourcePage::onResourceSelected()
|
|||
m_ui->packView->repaint();
|
||||
}
|
||||
|
||||
void ResourcePage::onResourceToggle(const QModelIndex& index)
|
||||
{
|
||||
const bool isSelected = index == m_ui->packView->currentIndex();
|
||||
auto pack = m_model->data(index, Qt::UserRole).value<ModPlatform::IndexedPack::Ptr>();
|
||||
|
||||
if (pack->versionsLoaded) {
|
||||
if (pack->isAnyVersionSelected())
|
||||
removeResourceFromDialog(pack->name);
|
||||
else {
|
||||
auto version = std::find_if(pack->versions.begin(), pack->versions.end(), [this](const ModPlatform::IndexedVersion& version) {
|
||||
return m_model->checkVersionFilters(version);
|
||||
});
|
||||
|
||||
if (version == pack->versions.end()) {
|
||||
auto errorMessage = new QMessageBox(
|
||||
QMessageBox::Warning, tr("No versions available"),
|
||||
tr("No versions for '%1' are available.\nThe author likely blocked third-party launchers.").arg(pack->name),
|
||||
QMessageBox::Ok, this);
|
||||
|
||||
errorMessage->open();
|
||||
} else
|
||||
addResourceToDialog(pack, *version);
|
||||
}
|
||||
|
||||
if (isSelected)
|
||||
updateSelectionButton();
|
||||
|
||||
// force update
|
||||
QVariant variant;
|
||||
variant.setValue(pack);
|
||||
m_model->setData(index, variant, Qt::UserRole);
|
||||
} else {
|
||||
// the model is just 1 dimensional so this is fine
|
||||
m_enableQueue.insert(index.row());
|
||||
|
||||
// we can't be sure that this hasn't already been requested...
|
||||
// but this does the job well enough and there's not much point preventing edgecases
|
||||
if (!isSelected)
|
||||
m_model->loadEntry(index);
|
||||
}
|
||||
}
|
||||
|
||||
void ResourcePage::openUrl(const QUrl& url)
|
||||
{
|
||||
// do not allow other url schemes for security reasons
|
||||
|
|
|
@ -71,15 +71,17 @@ class ResourcePage : public QWidget, public BasePage {
|
|||
void addSortings();
|
||||
|
||||
public slots:
|
||||
virtual void updateUi();
|
||||
virtual void updateUi(const QModelIndex& index);
|
||||
virtual void updateSelectionButton();
|
||||
virtual void updateVersionList();
|
||||
virtual void versionListUpdated(const QModelIndex& index);
|
||||
|
||||
void addResourceToDialog(ModPlatform::IndexedPack::Ptr, ModPlatform::IndexedVersion&);
|
||||
void removeResourceFromDialog(const QString& pack_name);
|
||||
virtual void removeResourceFromPage(const QString& name);
|
||||
virtual void addResourceToPage(ModPlatform::IndexedPack::Ptr, ModPlatform::IndexedVersion&, std::shared_ptr<ResourceFolderModel>);
|
||||
|
||||
virtual void modelReset();
|
||||
|
||||
QList<DownloadTaskPtr> selectedPacks() { return m_model->selectedPacks(); }
|
||||
bool hasSelectedPacks() { return !(m_model->selectedPacks().isEmpty()); }
|
||||
|
||||
|
@ -91,6 +93,7 @@ class ResourcePage : public QWidget, public BasePage {
|
|||
void onSelectionChanged(QModelIndex first, QModelIndex second);
|
||||
void onVersionSelectionChanged(int index);
|
||||
void onResourceSelected();
|
||||
void onResourceToggle(const QModelIndex& index);
|
||||
|
||||
// NOTE: Can't use [[nodiscard]] here because of https://bugreports.qt.io/browse/QTBUG-58628 on Qt 5.12
|
||||
|
||||
|
@ -115,6 +118,8 @@ class ResourcePage : public QWidget, public BasePage {
|
|||
QTimer m_searchTimer;
|
||||
|
||||
bool m_doNotJumpToMod = false;
|
||||
|
||||
QSet<int> m_enableQueue;
|
||||
};
|
||||
|
||||
} // namespace ResourceDownload
|
||||
|
|
|
@ -20,13 +20,13 @@ ResourceAPI::SearchArgs ShaderPackResourceModel::createSearchArguments()
|
|||
return { ModPlatform::ResourceType::SHADER_PACK, m_next_search_offset, m_search_term, sort };
|
||||
}
|
||||
|
||||
ResourceAPI::VersionSearchArgs ShaderPackResourceModel::createVersionsArguments(QModelIndex& entry)
|
||||
ResourceAPI::VersionSearchArgs ShaderPackResourceModel::createVersionsArguments(const QModelIndex& entry)
|
||||
{
|
||||
auto& pack = m_packs[entry.row()];
|
||||
return { *pack };
|
||||
}
|
||||
|
||||
ResourceAPI::ProjectInfoArgs ShaderPackResourceModel::createInfoArguments(QModelIndex& entry)
|
||||
ResourceAPI::ProjectInfoArgs ShaderPackResourceModel::createInfoArguments(const QModelIndex& entry)
|
||||
{
|
||||
auto& pack = m_packs[entry.row()];
|
||||
return { *pack };
|
||||
|
|
|
@ -31,8 +31,8 @@ class ShaderPackResourceModel : public ResourceModel {
|
|||
|
||||
public slots:
|
||||
ResourceAPI::SearchArgs createSearchArguments() override;
|
||||
ResourceAPI::VersionSearchArgs createVersionsArguments(QModelIndex&) override;
|
||||
ResourceAPI::ProjectInfoArgs createInfoArguments(QModelIndex&) override;
|
||||
ResourceAPI::VersionSearchArgs createVersionsArguments(const QModelIndex&) override;
|
||||
ResourceAPI::ProjectInfoArgs createInfoArguments(const QModelIndex&) override;
|
||||
|
||||
protected:
|
||||
const BaseInstance& m_base_instance;
|
||||
|
|
|
@ -15,10 +15,7 @@
|
|||
|
||||
namespace ResourceDownload {
|
||||
|
||||
ShaderPackResourcePage::ShaderPackResourcePage(ShaderPackDownloadDialog* dialog, BaseInstance& instance) : ResourcePage(dialog, instance)
|
||||
{
|
||||
connect(m_ui->packView, &QListView::doubleClicked, this, &ShaderPackResourcePage::onResourceSelected);
|
||||
}
|
||||
ShaderPackResourcePage::ShaderPackResourcePage(ShaderPackDownloadDialog* dialog, BaseInstance& instance) : ResourcePage(dialog, instance) {}
|
||||
|
||||
/******** Callbacks to events in the UI (set up in the derived classes) ********/
|
||||
|
||||
|
|
|
@ -25,8 +25,9 @@ class ShaderPackResourcePage : public ResourcePage {
|
|||
auto page = new T(dialog, instance);
|
||||
auto model = static_cast<ShaderPackResourceModel*>(page->getModel());
|
||||
|
||||
connect(model, &ResourceModel::versionListUpdated, page, &ResourcePage::updateVersionList);
|
||||
connect(model, &ResourceModel::versionListUpdated, page, &ResourcePage::versionListUpdated);
|
||||
connect(model, &ResourceModel::projectInfoUpdated, page, &ResourcePage::updateUi);
|
||||
connect(model, &QAbstractListModel::modelReset, page, &ResourcePage::modelReset);
|
||||
|
||||
return page;
|
||||
}
|
||||
|
|
|
@ -70,7 +70,7 @@ ResourceAPI::SearchArgs TexturePackResourceModel::createSearchArguments()
|
|||
return args;
|
||||
}
|
||||
|
||||
ResourceAPI::VersionSearchArgs TexturePackResourceModel::createVersionsArguments(QModelIndex& entry)
|
||||
ResourceAPI::VersionSearchArgs TexturePackResourceModel::createVersionsArguments(const QModelIndex& entry)
|
||||
{
|
||||
auto args = ResourcePackResourceModel::createVersionsArguments(entry);
|
||||
if (!m_version_list->isLoaded()) {
|
||||
|
|
|
@ -18,7 +18,7 @@ class TexturePackResourceModel : public ResourcePackResourceModel {
|
|||
[[nodiscard]] inline ::Version maximumTexturePackVersion() const { return { "1.6" }; }
|
||||
|
||||
ResourceAPI::SearchArgs createSearchArguments() override;
|
||||
ResourceAPI::VersionSearchArgs createVersionsArguments(QModelIndex&) override;
|
||||
ResourceAPI::VersionSearchArgs createVersionsArguments(const QModelIndex&) override;
|
||||
|
||||
protected:
|
||||
Meta::VersionList::Ptr m_version_list;
|
||||
|
|
|
@ -27,8 +27,9 @@ class TexturePackResourcePage : public ResourcePackResourcePage {
|
|||
auto page = new T(dialog, instance);
|
||||
auto model = static_cast<TexturePackResourceModel*>(page->getModel());
|
||||
|
||||
connect(model, &ResourceModel::versionListUpdated, page, &ResourcePage::updateVersionList);
|
||||
connect(model, &ResourceModel::versionListUpdated, page, &ResourcePage::versionListUpdated);
|
||||
connect(model, &ResourceModel::projectInfoUpdated, page, &ResourcePage::updateUi);
|
||||
connect(model, &QAbstractListModel::modelReset, page, &ResourcePage::modelReset);
|
||||
|
||||
return page;
|
||||
}
|
||||
|
@ -39,10 +40,7 @@ class TexturePackResourcePage : public ResourcePackResourcePage {
|
|||
[[nodiscard]] inline QString resourceString() const override { return tr("texture pack"); }
|
||||
|
||||
protected:
|
||||
TexturePackResourcePage(TexturePackDownloadDialog* dialog, BaseInstance& instance) : ResourcePackResourcePage(dialog, instance)
|
||||
{
|
||||
connect(m_ui->packView, &QListView::doubleClicked, this, &TexturePackResourcePage::onResourceSelected);
|
||||
}
|
||||
TexturePackResourcePage(TexturePackDownloadDialog* dialog, BaseInstance& instance) : ResourcePackResourcePage(dialog, instance) {}
|
||||
};
|
||||
|
||||
} // namespace ResourceDownload
|
||||
|
|
|
@ -82,8 +82,6 @@ QVariant ListModel::data(const QModelIndex& index, int role) const
|
|||
return pack.name;
|
||||
case UserDataTypes::DESCRIPTION:
|
||||
return pack.description;
|
||||
case UserDataTypes::SELECTED:
|
||||
return false;
|
||||
case UserDataTypes::INSTALLED:
|
||||
return false;
|
||||
default:
|
||||
|
|
|
@ -45,7 +45,9 @@
|
|||
|
||||
#include "net/ApiDownload.h"
|
||||
|
||||
AtlOptionalModListModel::AtlOptionalModListModel(QWidget* parent, ATLauncher::PackVersion version, QVector<ATLauncher::VersionMod> mods)
|
||||
AtlOptionalModListModel::AtlOptionalModListModel(QWidget* parent,
|
||||
const ATLauncher::PackVersion& version,
|
||||
QList<ATLauncher::VersionMod> mods)
|
||||
: QAbstractListModel(parent), m_version(version), m_mods(mods)
|
||||
{
|
||||
// fill mod index
|
||||
|
@ -62,9 +64,9 @@ AtlOptionalModListModel::AtlOptionalModListModel(QWidget* parent, ATLauncher::Pa
|
|||
}
|
||||
}
|
||||
|
||||
QVector<QString> AtlOptionalModListModel::getResult()
|
||||
QList<QString> AtlOptionalModListModel::getResult()
|
||||
{
|
||||
QVector<QString> result;
|
||||
QList<QString> result;
|
||||
|
||||
for (const auto& mod : m_mods) {
|
||||
if (m_selection[mod.name]) {
|
||||
|
@ -233,7 +235,7 @@ void AtlOptionalModListModel::clearAll()
|
|||
emit dataChanged(AtlOptionalModListModel::index(0, EnabledColumn), AtlOptionalModListModel::index(m_mods.size() - 1, EnabledColumn));
|
||||
}
|
||||
|
||||
void AtlOptionalModListModel::toggleMod(ATLauncher::VersionMod mod, int index)
|
||||
void AtlOptionalModListModel::toggleMod(const ATLauncher::VersionMod& mod, int index)
|
||||
{
|
||||
auto enable = !m_selection[mod.name];
|
||||
|
||||
|
@ -251,7 +253,7 @@ void AtlOptionalModListModel::toggleMod(ATLauncher::VersionMod mod, int index)
|
|||
setMod(mod, index, enable);
|
||||
}
|
||||
|
||||
void AtlOptionalModListModel::setMod(ATLauncher::VersionMod mod, int index, bool enable, bool shouldEmit)
|
||||
void AtlOptionalModListModel::setMod(const ATLauncher::VersionMod& mod, int index, bool enable, bool shouldEmit)
|
||||
{
|
||||
if (m_selection[mod.name] == enable)
|
||||
return;
|
||||
|
@ -313,7 +315,7 @@ void AtlOptionalModListModel::setMod(ATLauncher::VersionMod mod, int index, bool
|
|||
}
|
||||
}
|
||||
|
||||
AtlOptionalModDialog::AtlOptionalModDialog(QWidget* parent, ATLauncher::PackVersion version, QVector<ATLauncher::VersionMod> mods)
|
||||
AtlOptionalModDialog::AtlOptionalModDialog(QWidget* parent, const ATLauncher::PackVersion& version, QList<ATLauncher::VersionMod> mods)
|
||||
: QDialog(parent), ui(new Ui::AtlOptionalModDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
|
|
@ -55,9 +55,9 @@ class AtlOptionalModListModel : public QAbstractListModel {
|
|||
DescriptionColumn,
|
||||
};
|
||||
|
||||
AtlOptionalModListModel(QWidget* parent, ATLauncher::PackVersion version, QVector<ATLauncher::VersionMod> mods);
|
||||
AtlOptionalModListModel(QWidget* parent, const ATLauncher::PackVersion& version, QList<ATLauncher::VersionMod> mods);
|
||||
|
||||
QVector<QString> getResult();
|
||||
QList<QString> getResult();
|
||||
|
||||
int rowCount(const QModelIndex& parent) const override;
|
||||
int columnCount(const QModelIndex& parent) const override;
|
||||
|
@ -78,29 +78,29 @@ class AtlOptionalModListModel : public QAbstractListModel {
|
|||
void clearAll();
|
||||
|
||||
private:
|
||||
void toggleMod(ATLauncher::VersionMod mod, int index);
|
||||
void setMod(ATLauncher::VersionMod mod, int index, bool enable, bool shouldEmit = true);
|
||||
void toggleMod(const ATLauncher::VersionMod& mod, int index);
|
||||
void setMod(const ATLauncher::VersionMod& mod, int index, bool enable, bool shouldEmit = true);
|
||||
|
||||
private:
|
||||
NetJob::Ptr m_jobPtr;
|
||||
std::shared_ptr<QByteArray> m_response = std::make_shared<QByteArray>();
|
||||
|
||||
ATLauncher::PackVersion m_version;
|
||||
QVector<ATLauncher::VersionMod> m_mods;
|
||||
QList<ATLauncher::VersionMod> m_mods;
|
||||
|
||||
QMap<QString, bool> m_selection;
|
||||
QMap<QString, int> m_index;
|
||||
QMap<QString, QVector<QString>> m_dependents;
|
||||
QMap<QString, QList<QString>> m_dependents;
|
||||
};
|
||||
|
||||
class AtlOptionalModDialog : public QDialog {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
AtlOptionalModDialog(QWidget* parent, ATLauncher::PackVersion version, QVector<ATLauncher::VersionMod> mods);
|
||||
AtlOptionalModDialog(QWidget* parent, const ATLauncher::PackVersion& version, QList<ATLauncher::VersionMod> mods);
|
||||
~AtlOptionalModDialog() override;
|
||||
|
||||
QVector<QString> getResult() { return listModel->getResult(); }
|
||||
QList<QString> getResult() { return listModel->getResult(); }
|
||||
|
||||
void useShareCode();
|
||||
|
||||
|
|
|
@ -41,8 +41,8 @@
|
|||
|
||||
AtlUserInteractionSupportImpl::AtlUserInteractionSupportImpl(QWidget* parent) : m_parent(parent) {}
|
||||
|
||||
std::optional<QVector<QString>> AtlUserInteractionSupportImpl::chooseOptionalMods(ATLauncher::PackVersion version,
|
||||
QVector<ATLauncher::VersionMod> mods)
|
||||
std::optional<QList<QString>> AtlUserInteractionSupportImpl::chooseOptionalMods(const ATLauncher::PackVersion& version,
|
||||
QList<ATLauncher::VersionMod> mods)
|
||||
{
|
||||
AtlOptionalModDialog optionalModDialog(m_parent, version, mods);
|
||||
auto result = optionalModDialog.exec();
|
||||
|
|
|
@ -48,7 +48,7 @@ class AtlUserInteractionSupportImpl : public QObject, public ATLauncher::UserInt
|
|||
|
||||
private:
|
||||
QString chooseVersion(Meta::VersionList::Ptr vlist, QString minecraftVersion) override;
|
||||
std::optional<QVector<QString>> chooseOptionalMods(ATLauncher::PackVersion version, QVector<ATLauncher::VersionMod> mods) override;
|
||||
std::optional<QList<QString>> chooseOptionalMods(const ATLauncher::PackVersion& version, QList<ATLauncher::VersionMod> mods) override;
|
||||
void displayMessage(QString message) override;
|
||||
|
||||
private:
|
||||
|
|
|
@ -65,8 +65,6 @@ QVariant ListModel::data(const QModelIndex& index, int role) const
|
|||
return pack.name;
|
||||
case UserDataTypes::DESCRIPTION:
|
||||
return pack.description;
|
||||
case UserDataTypes::SELECTED:
|
||||
return false;
|
||||
case UserDataTypes::INSTALLED:
|
||||
return false;
|
||||
default:
|
||||
|
|
|
@ -95,7 +95,7 @@ void FlameTexturePackModel::loadIndexedPackVersions(ModPlatform::IndexedPack& m,
|
|||
{
|
||||
FlameMod::loadIndexedPackVersions(m, arr);
|
||||
|
||||
QVector<ModPlatform::IndexedVersion> filtered_versions(m.versions.size());
|
||||
QList<ModPlatform::IndexedVersion> filtered_versions(m.versions.size());
|
||||
|
||||
// FIXME: Client-side version filtering. This won't take into account any user-selected filtering.
|
||||
for (auto const& version : m.versions) {
|
||||
|
@ -122,7 +122,7 @@ ResourceAPI::SearchArgs FlameTexturePackModel::createSearchArguments()
|
|||
return args;
|
||||
}
|
||||
|
||||
ResourceAPI::VersionSearchArgs FlameTexturePackModel::createVersionsArguments(QModelIndex& entry)
|
||||
ResourceAPI::VersionSearchArgs FlameTexturePackModel::createVersionsArguments(const QModelIndex& entry)
|
||||
{
|
||||
auto args = TexturePackResourceModel::createVersionsArguments(entry);
|
||||
|
||||
|
|
|
@ -69,7 +69,7 @@ class FlameTexturePackModel : public TexturePackResourceModel {
|
|||
void loadIndexedPackVersions(ModPlatform::IndexedPack& m, QJsonArray& arr) override;
|
||||
|
||||
ResourceAPI::SearchArgs createSearchArguments() override;
|
||||
ResourceAPI::VersionSearchArgs createVersionsArguments(QModelIndex&) override;
|
||||
ResourceAPI::VersionSearchArgs createVersionsArguments(const QModelIndex&) override;
|
||||
|
||||
auto documentToArray(QJsonDocument& obj) const -> QJsonArray override;
|
||||
};
|
||||
|
|
|
@ -106,9 +106,6 @@ QVariant ListModel::data(const QModelIndex& index, int role) const
|
|||
}
|
||||
|
||||
auto pack = m_modpacks.at(pos);
|
||||
if (role == Qt::ToolTipRole) {
|
||||
}
|
||||
|
||||
switch (role) {
|
||||
case Qt::ToolTipRole:
|
||||
return tr("Minecraft %1").arg(pack.mcVersion);
|
||||
|
@ -128,8 +125,6 @@ QVariant ListModel::data(const QModelIndex& index, int role) const
|
|||
return pack.name;
|
||||
case UserDataTypes::DESCRIPTION:
|
||||
return tr("Minecraft %1").arg(pack.mcVersion);
|
||||
case UserDataTypes::SELECTED:
|
||||
return false;
|
||||
case UserDataTypes::INSTALLED:
|
||||
return false;
|
||||
default:
|
||||
|
|
|
@ -195,8 +195,6 @@ QVariant ListModel::data(const QModelIndex& index, int role) const
|
|||
return pack.name;
|
||||
case UserDataTypes::DESCRIPTION:
|
||||
return pack.description;
|
||||
case UserDataTypes::SELECTED:
|
||||
return false;
|
||||
case UserDataTypes::INSTALLED:
|
||||
return false;
|
||||
default:
|
||||
|
@ -213,7 +211,7 @@ void ListModel::fill(ModpackList modpacks_)
|
|||
endResetModel();
|
||||
}
|
||||
|
||||
void ListModel::addPack(Modpack modpack)
|
||||
void ListModel::addPack(const Modpack& modpack)
|
||||
{
|
||||
beginResetModel();
|
||||
this->modpacks.append(modpack);
|
||||
|
|
|
@ -62,7 +62,7 @@ class ListModel : public QAbstractListModel {
|
|||
Qt::ItemFlags flags(const QModelIndex& index) const override;
|
||||
|
||||
void fill(ModpackList modpacks);
|
||||
void addPack(Modpack modpack);
|
||||
void addPack(const Modpack& modpack);
|
||||
void clear();
|
||||
void remove(int row);
|
||||
|
||||
|
|
|
@ -213,7 +213,7 @@ void Page::ftbPackDataDownloadAborted()
|
|||
CustomMessageBox::selectable(this, tr("Task aborted"), tr("The task has been aborted by the user."), QMessageBox::Information)->show();
|
||||
}
|
||||
|
||||
void Page::ftbPrivatePackDataDownloadSuccessfully(Modpack pack)
|
||||
void Page::ftbPrivatePackDataDownloadSuccessfully(const Modpack& pack)
|
||||
{
|
||||
privateListModel->addPack(pack);
|
||||
}
|
||||
|
|
|
@ -85,7 +85,7 @@ class Page : public QWidget, public ModpackProviderBasePage {
|
|||
void ftbPackDataDownloadFailed(QString reason);
|
||||
void ftbPackDataDownloadAborted();
|
||||
|
||||
void ftbPrivatePackDataDownloadSuccessfully(Modpack pack);
|
||||
void ftbPrivatePackDataDownloadSuccessfully(const Modpack& pack);
|
||||
void ftbPrivatePackDataDownloadFailed(QString reason, QString packCode);
|
||||
|
||||
void onSortingSelectionChanged(QString data);
|
||||
|
|
|
@ -106,8 +106,6 @@ auto ModpackListModel::data(const QModelIndex& index, int role) const -> QVarian
|
|||
return pack.name;
|
||||
case UserDataTypes::DESCRIPTION:
|
||||
return pack.description;
|
||||
case UserDataTypes::SELECTED:
|
||||
return false;
|
||||
case UserDataTypes::INSTALLED:
|
||||
return false;
|
||||
default:
|
||||
|
|
|
@ -37,7 +37,6 @@
|
|||
|
||||
#include <QList>
|
||||
#include <QString>
|
||||
#include <QVector>
|
||||
|
||||
namespace Technic {
|
||||
struct Modpack {
|
||||
|
@ -61,7 +60,7 @@ struct Modpack {
|
|||
|
||||
bool versionsLoaded = false;
|
||||
QString recommended;
|
||||
QVector<QString> versions;
|
||||
QList<QString> versions;
|
||||
};
|
||||
} // namespace Technic
|
||||
|
||||
|
|
|
@ -89,8 +89,6 @@ QVariant Technic::ListModel::data(const QModelIndex& index, int role) const
|
|||
return pack.name;
|
||||
case UserDataTypes::DESCRIPTION:
|
||||
return pack.description;
|
||||
case UserDataTypes::SELECTED:
|
||||
return false;
|
||||
case UserDataTypes::INSTALLED:
|
||||
return false;
|
||||
default:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue