aboutsummaryrefslogtreecommitdiff
path: root/launcher/ui/pages/modplatform/ResourcePackPage.cpp
diff options
context:
space:
mode:
authorTrial97 <alexandru.tripon97@gmail.com>2023-05-31 20:12:12 +0300
committerTrial97 <alexandru.tripon97@gmail.com>2023-05-31 20:12:12 +0300
commit29c3dc40ef7f5b1fce5ab5970a39613d0f7f5089 (patch)
treece92f8a86d08531879105a16194a14391c0ae2ea /launcher/ui/pages/modplatform/ResourcePackPage.cpp
parente8ee4497f77a571b305a48b70f84c8729b800859 (diff)
parent954d4d701a136e79c25b58f9680d26a555a6e6fe (diff)
downloadPrismLauncher-29c3dc40ef7f5b1fce5ab5970a39613d0f7f5089.tar.gz
PrismLauncher-29c3dc40ef7f5b1fce5ab5970a39613d0f7f5089.tar.bz2
PrismLauncher-29c3dc40ef7f5b1fce5ab5970a39613d0f7f5089.zip
Merge branch 'develop' of https://github.com/PrismLauncher/PrismLauncher into logdir
Diffstat (limited to 'launcher/ui/pages/modplatform/ResourcePackPage.cpp')
-rw-r--r--launcher/ui/pages/modplatform/ResourcePackPage.cpp46
1 files changed, 46 insertions, 0 deletions
diff --git a/launcher/ui/pages/modplatform/ResourcePackPage.cpp b/launcher/ui/pages/modplatform/ResourcePackPage.cpp
new file mode 100644
index 00000000..52fb4802
--- /dev/null
+++ b/launcher/ui/pages/modplatform/ResourcePackPage.cpp
@@ -0,0 +1,46 @@
+// SPDX-FileCopyrightText: 2023 flowln <flowlnlnln@gmail.com>
+//
+// SPDX-License-Identifier: GPL-3.0-only
+
+#include "ResourcePackPage.h"
+#include "ui_ResourcePage.h"
+
+#include "ResourcePackModel.h"
+
+#include "ui/dialogs/ResourceDownloadDialog.h"
+
+#include <QRegularExpression>
+
+namespace ResourceDownload {
+
+ResourcePackResourcePage::ResourcePackResourcePage(ResourceDownloadDialog* dialog, BaseInstance& instance)
+ : ResourcePage(dialog, instance)
+{
+ 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");
+ map.insert(QRegularExpression::anchoredPattern("(?:www\\.)?curseforge\\.com\\/minecraft\\/texture-packs\\/([^\\/]+)\\/?"), "curseforge");
+ map.insert(QRegularExpression::anchoredPattern("minecraft\\.curseforge\\.com\\/projects\\/([^\\/]+)\\/?"), "curseforge");
+ return map;
+}
+
+} // namespace ResourceDownload