2023-01-29 23:40:55 +00:00
|
|
|
// SPDX-FileCopyrightText: 2023 flowln <flowlnlnln@gmail.com>
|
|
|
|
//
|
|
|
|
// SPDX-License-Identifier: GPL-3.0-only
|
|
|
|
|
2022-12-16 23:26:10 +00:00
|
|
|
#include "ResourcePackPage.h"
|
|
|
|
#include "ui_ResourcePage.h"
|
|
|
|
|
|
|
|
#include "ResourcePackModel.h"
|
|
|
|
|
|
|
|
#include "ui/dialogs/ResourceDownloadDialog.h"
|
|
|
|
|
|
|
|
#include <QRegularExpression>
|
|
|
|
|
|
|
|
namespace ResourceDownload {
|
|
|
|
|
2023-08-14 17:16:53 +01:00
|
|
|
ResourcePackResourcePage::ResourcePackResourcePage(ResourceDownloadDialog* dialog, BaseInstance& instance) : ResourcePage(dialog, instance)
|
2022-12-16 23:26:10 +00:00
|
|
|
{
|
|
|
|
connect(m_ui->searchButton, &QPushButton::clicked, this, &ResourcePackResourcePage::triggerSearch);
|
|
|
|
connect(m_ui->packView, &QListView::doubleClicked, this, &ResourcePackResourcePage::onResourceSelected);
|
|
|
|
}
|
|
|
|
|
|
|
|
/******** Callbacks to events in the UI (set up in the derived classes) ********/
|
|
|
|
|
|
|
|
void ResourcePackResourcePage::triggerSearch()
|
|
|
|
{
|
|
|
|
m_ui->packView->clearSelection();
|
|
|
|
m_ui->packDescription->clear();
|
|
|
|
m_ui->versionSelectionBox->clear();
|
|
|
|
|
|
|
|
updateSelectionButton();
|
|
|
|
|
|
|
|
static_cast<ResourcePackResourceModel*>(m_model)->searchWithTerm(getSearchTerm(), m_ui->sortByBox->currentData().toUInt());
|
|
|
|
m_fetch_progress.watch(m_model->activeSearchJob().get());
|
|
|
|
}
|
|
|
|
|
|
|
|
QMap<QString, QString> ResourcePackResourcePage::urlHandlers() const
|
|
|
|
{
|
|
|
|
QMap<QString, QString> map;
|
|
|
|
map.insert(QRegularExpression::anchoredPattern("(?:www\\.)?modrinth\\.com\\/resourcepack\\/([^\\/]+)\\/?"), "modrinth");
|
2023-08-14 17:16:53 +01:00
|
|
|
map.insert(QRegularExpression::anchoredPattern("(?:www\\.)?curseforge\\.com\\/minecraft\\/texture-packs\\/([^\\/]+)\\/?"),
|
|
|
|
"curseforge");
|
2022-12-16 23:26:10 +00:00
|
|
|
map.insert(QRegularExpression::anchoredPattern("minecraft\\.curseforge\\.com\\/projects\\/([^\\/]+)\\/?"), "curseforge");
|
|
|
|
return map;
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace ResourceDownload
|