aboutsummaryrefslogtreecommitdiff
path: root/launcher/ui
diff options
context:
space:
mode:
Diffstat (limited to 'launcher/ui')
-rw-r--r--launcher/ui/pages/instance/ExternalResourcesPage.ui11
-rw-r--r--launcher/ui/pages/instance/ModFolderPage.cpp47
-rw-r--r--launcher/ui/pages/instance/ModFolderPage.h4
-rw-r--r--launcher/ui/widgets/InfoFrame.cpp111
-rw-r--r--launcher/ui/widgets/InfoFrame.h45
5 files changed, 150 insertions, 68 deletions
diff --git a/launcher/ui/pages/instance/ExternalResourcesPage.ui b/launcher/ui/pages/instance/ExternalResourcesPage.ui
index 33a03336..b110dbfd 100644
--- a/launcher/ui/pages/instance/ExternalResourcesPage.ui
+++ b/launcher/ui/pages/instance/ExternalResourcesPage.ui
@@ -154,6 +154,17 @@
<string>Try to check or update all selected resources (all resources if none are selected)</string>
</property>
</action>
+ <action name="actionVisitItemPage">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>Visit on mod's page</string>
+ </property>
+ <property name="toolTip">
+ <string>Go to mods home page</string>
+ </property>
+ </action>
</widget>
<customwidgets>
<customwidget>
diff --git a/launcher/ui/pages/instance/ModFolderPage.cpp b/launcher/ui/pages/instance/ModFolderPage.cpp
index 90e7d0d6..9722d483 100644
--- a/launcher/ui/pages/instance/ModFolderPage.cpp
+++ b/launcher/ui/pages/instance/ModFolderPage.cpp
@@ -45,6 +45,7 @@
#include <QMenu>
#include <QMessageBox>
#include <QSortFilterProxyModel>
+#include <algorithm>
#include "Application.h"
@@ -60,6 +61,7 @@
#include "minecraft/mod/Mod.h"
#include "minecraft/mod/ModFolderModel.h"
+#include "modplatform/ModIndex.h"
#include "modplatform/ResourceAPI.h"
#include "Version.h"
@@ -86,12 +88,30 @@ ModFolderPage::ModFolderPage(BaseInstance* inst, std::shared_ptr<ModFolderModel>
ui->actionsToolbar->insertActionAfter(ui->actionAddItem, ui->actionUpdateItem);
connect(ui->actionUpdateItem, &QAction::triggered, this, &ModFolderPage::updateMods);
+ ui->actionVisitItemPage->setToolTip(tr("Go to mod's home page"));
+ ui->actionsToolbar->insertActionAfter(ui->actionViewFolder, ui->actionVisitItemPage);
+ connect(ui->actionVisitItemPage, &QAction::triggered, this, &ModFolderPage::visitModPages);
+
auto check_allow_update = [this] {
return (!m_instance || !m_instance->isRunning()) && (ui->treeView->selectionModel()->hasSelection() || !m_model->empty());
};
- connect(ui->treeView->selectionModel(), &QItemSelectionModel::selectionChanged, this,
- [this, check_allow_update] { ui->actionUpdateItem->setEnabled(check_allow_update()); });
+ connect(ui->treeView->selectionModel(), &QItemSelectionModel::selectionChanged, this, [this, check_allow_update] {
+ ui->actionUpdateItem->setEnabled(check_allow_update());
+
+ auto selection = m_filterModel->mapSelectionToSource(ui->treeView->selectionModel()->selection()).indexes();
+ auto mods_list = m_model->selectedMods(selection);
+ auto selected = std::count_if(mods_list.cbegin(), mods_list.cend(),
+ [](Mod* v) { return v->metadata() != nullptr || v->homeurl().size() != 0; });
+ if (selected <= 1) {
+ ui->actionVisitItemPage->setText(tr("Visit on mod's page"));
+ ui->actionVisitItemPage->setToolTip(tr("Go to mod's home page"));
+ } else {
+ ui->actionVisitItemPage->setText(tr("Visit the pages of the selected mods"));
+ ui->actionVisitItemPage->setToolTip(tr("Go to the pages of the selected mods"));
+ }
+ ui->actionVisitItemPage->setEnabled(selected != 0);
+ });
connect(mods.get(), &ModFolderModel::rowsInserted, this,
[this, check_allow_update] { ui->actionUpdateItem->setEnabled(check_allow_update()); });
@@ -133,7 +153,7 @@ bool ModFolderPage::onSelectionChanged(const QModelIndex& current, const QModelI
return true;
}
-void ModFolderPage::removeItems(const QItemSelection &selection)
+void ModFolderPage::removeItems(const QItemSelection& selection)
{
m_model->deleteMods(selection.indexes());
}
@@ -207,8 +227,7 @@ void ModFolderPage::updateMods()
message = tr("All selected mods are up-to-date! :)");
}
}
- CustomMessageBox::selectable(this, tr("Update checker"), message)
- ->exec();
+ CustomMessageBox::selectable(this, tr("Update checker"), message)->exec();
return;
}
@@ -275,3 +294,21 @@ bool NilModFolderPage::shouldDisplay() const
{
return m_model->dir().exists();
}
+
+void ModFolderPage::visitModPages()
+{
+ auto selection = m_filterModel->mapSelectionToSource(ui->treeView->selectionModel()->selection()).indexes();
+ for (auto mod : m_model->selectedMods(selection))
+ if (auto meta = mod->metadata(); meta != nullptr) {
+ auto slug = meta->slug.remove(".pw.toml");
+ switch (meta->provider) {
+ case ModPlatform::ResourceProvider::MODRINTH:
+ DesktopServices::openUrl(QString("https://modrinth.com/mod/%1").arg(slug));
+ break;
+ case ModPlatform::ResourceProvider::FLAME:
+ DesktopServices::openUrl(QString("https://www.curseforge.com/minecraft/mc-mods/%1").arg(slug));
+ break;
+ }
+ } else if (mod->homeurl().size() != 0)
+ DesktopServices::openUrl(mod->homeurl());
+} \ No newline at end of file
diff --git a/launcher/ui/pages/instance/ModFolderPage.h b/launcher/ui/pages/instance/ModFolderPage.h
index 2fc7b574..2c1a9c77 100644
--- a/launcher/ui/pages/instance/ModFolderPage.h
+++ b/launcher/ui/pages/instance/ModFolderPage.h
@@ -4,6 +4,7 @@
* Copyright (c) 2022 Jamie Mansfield <jmansfield@cadixdev.org>
* Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net>
* Copyright (C) 2022 TheKodeToad <TheKodeToad@proton.me>
+ * Copyright (c) 2023 Trial97 <alexandru.tripon97@gmail.com>
*
* 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
@@ -60,10 +61,11 @@ class ModFolderPage : public ExternalResourcesPage {
private slots:
void runningStateChanged(bool running);
- void removeItems(const QItemSelection &selection) override;
+ void removeItems(const QItemSelection& selection) override;
void installMods();
void updateMods();
+ void visitModPages();
protected:
std::shared_ptr<ModFolderModel> m_model;
diff --git a/launcher/ui/widgets/InfoFrame.cpp b/launcher/ui/widgets/InfoFrame.cpp
index fdc581b4..d0b55c0b 100644
--- a/launcher/ui/widgets/InfoFrame.cpp
+++ b/launcher/ui/widgets/InfoFrame.cpp
@@ -1,37 +1,38 @@
// SPDX-License-Identifier: GPL-3.0-only
/*
-* PolyMC - Minecraft Launcher
-* Copyright (c) 2022 flowln <flowlnlnln@gmail.com>
-*
-* 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.
-*/
+ * Prism Launcher - Minecraft Launcher
+ * Copyright (c) 2022 flowln <flowlnlnln@gmail.com>
+ * Copyright (c) 2023 Trial97 <alexandru.tripon97@gmail.com>
+ *
+ * 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.
+ */
#include <QMessageBox>
@@ -57,34 +58,47 @@ InfoFrame::~InfoFrame()
void InfoFrame::updateWithMod(Mod const& m)
{
- if (m.type() == ResourceType::FOLDER)
- {
+ if (m.type() == ResourceType::FOLDER) {
clear();
return;
}
QString text = "";
QString name = "";
+ QString link = "";
+ QString toolTip = "";
if (m.name().isEmpty())
name = m.internal_id();
else
name = m.name();
- if (m.homeurl().isEmpty())
+ if (auto meta = m.metadata(); meta != nullptr) {
+ auto slug = meta->slug.remove(".pw.toml");
+ switch (meta->provider) {
+ case ModPlatform::ResourceProvider::MODRINTH:
+ link = QString("https://modrinth.com/mod/%1").arg(slug);
+ break;
+ case ModPlatform::ResourceProvider::FLAME:
+ link = QString("https://www.curseforge.com/minecraft/mc-mods/%1").arg(slug);
+ break;
+ }
+ } else if (!m.homeurl().isEmpty())
+ link = m.homeurl();
+
+ if (link.isEmpty())
text = name;
- else
- text = "<a href=\"" + m.homeurl() + "\">" + name + "</a>";
+ else {
+ text = "<a href=\"" + link + "\">" + name + "</a>";
+ toolTip = tr("Go to mod's home page");
+ }
if (!m.authors().isEmpty())
text += " by " + m.authors().join(", ");
- setName(text);
+ setName(text, toolTip);
- if (m.description().isEmpty())
- {
+ if (m.description().isEmpty()) {
setDescription(QString());
- }
- else
- {
+ } else {
setDescription(m.description());
}
@@ -191,16 +205,15 @@ void InfoFrame::updateHiddenState()
}
}
-void InfoFrame::setName(QString text)
+void InfoFrame::setName(QString text, QString toolTip)
{
- if(text.isEmpty())
- {
+ if (text.isEmpty()) {
ui->nameLabel->setHidden(true);
- }
- else
- {
+ ui->nameLabel->setToolTip({});
+ } else {
ui->nameLabel->setText(text);
ui->nameLabel->setHidden(false);
+ ui->nameLabel->setToolTip(toolTip);
}
updateHiddenState();
}
diff --git a/launcher/ui/widgets/InfoFrame.h b/launcher/ui/widgets/InfoFrame.h
index 84523e28..4f6adc6d 100644
--- a/launcher/ui/widgets/InfoFrame.h
+++ b/launcher/ui/widgets/InfoFrame.h
@@ -1,16 +1,36 @@
-/* Copyright 2013-2021 MultiMC Contributors
+// SPDX-License-Identifier: GPL-3.0-only
+/*
+ * Prism Launcher - Minecraft Launcher
+ * Copyright (c) 2023 Trial97 <alexandru.tripon97@gmail.com>
*
- * 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
+ * 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.
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * 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.
*
- * 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.
+ * 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.
*/
#pragma once
@@ -21,8 +41,7 @@
#include "minecraft/mod/ResourcePack.h"
#include "minecraft/mod/TexturePack.h"
-namespace Ui
-{
+namespace Ui {
class InfoFrame;
}
@@ -33,7 +52,7 @@ class InfoFrame : public QFrame {
InfoFrame(QWidget* parent = nullptr);
~InfoFrame() override;
- void setName(QString text = {});
+ void setName(QString text = {}, QString toolTip = {});
void setDescription(QString text = {});
void setImage(QPixmap img = {});