diff --git a/launcher/ui/MainWindow.cpp b/launcher/ui/MainWindow.cpp
index 1da982dad..3ae80ebb6 100644
--- a/launcher/ui/MainWindow.cpp
+++ b/launcher/ui/MainWindow.cpp
@@ -96,7 +96,6 @@
#include "ui/dialogs/CustomMessageBox.h"
#include "ui/dialogs/ExportInstanceDialog.h"
#include "ui/dialogs/ExportPackDialog.h"
-#include "ui/dialogs/ExportToModListDialog.h"
#include "ui/dialogs/IconPickerDialog.h"
#include "ui/dialogs/ImportResourceDialog.h"
#include "ui/dialogs/NewInstanceDialog.h"
@@ -208,7 +207,6 @@ MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent), ui(new Ui::MainWi
exportInstanceMenu->addAction(ui->actionExportInstanceZip);
exportInstanceMenu->addAction(ui->actionExportInstanceMrPack);
exportInstanceMenu->addAction(ui->actionExportInstanceFlamePack);
- exportInstanceMenu->addAction(ui->actionExportInstanceToModList);
ui->actionExportInstance->setMenu(exportInstanceMenu);
}
@@ -1390,14 +1388,6 @@ void MainWindow::on_actionExportInstanceMrPack_triggered()
}
}
-void MainWindow::on_actionExportInstanceToModList_triggered()
-{
- if (m_selectedInstance) {
- ExportToModListDialog dlg(m_selectedInstance, this);
- dlg.exec();
- }
-}
-
void MainWindow::on_actionExportInstanceFlamePack_triggered()
{
if (m_selectedInstance) {
diff --git a/launcher/ui/MainWindow.h b/launcher/ui/MainWindow.h
index 0b7287404..7935ddf56 100644
--- a/launcher/ui/MainWindow.h
+++ b/launcher/ui/MainWindow.h
@@ -156,7 +156,6 @@ class MainWindow : public QMainWindow {
void on_actionExportInstanceZip_triggered();
void on_actionExportInstanceMrPack_triggered();
void on_actionExportInstanceFlamePack_triggered();
- void on_actionExportInstanceToModList_triggered();
void on_actionRenameInstance_triggered();
diff --git a/launcher/ui/MainWindow.ui b/launcher/ui/MainWindow.ui
index 91b2c2703..ee90eeba1 100644
--- a/launcher/ui/MainWindow.ui
+++ b/launcher/ui/MainWindow.ui
@@ -479,15 +479,6 @@
CurseForge (zip)
-
-
-
- ..
-
-
- Mod List
-
-
diff --git a/launcher/ui/dialogs/ExportToModListDialog.cpp b/launcher/ui/dialogs/ExportToModListDialog.cpp
index a343f555a..f767727d7 100644
--- a/launcher/ui/dialogs/ExportToModListDialog.cpp
+++ b/launcher/ui/dialogs/ExportToModListDialog.cpp
@@ -22,8 +22,6 @@
#include
#include "FileSystem.h"
#include "Markdown.h"
-#include "minecraft/MinecraftInstance.h"
-#include "minecraft/mod/ModFolderModel.h"
#include "modplatform/helpers/ExportToModList.h"
#include "ui_ExportToModListDialog.h"
@@ -41,21 +39,12 @@ const QHash ExportToModListDialog::exampleLin
{ ExportToModList::CSV, "{name},{url},{version},\"{authors}\"" },
};
-ExportToModListDialog::ExportToModListDialog(InstancePtr instance, QWidget* parent)
- : QDialog(parent), m_template_changed(false), name(instance->name()), ui(new Ui::ExportToModListDialog)
+ExportToModListDialog::ExportToModListDialog(QString name, QList mods, QWidget* parent)
+ : QDialog(parent), m_mods(mods), m_template_changed(false), m_name(name), ui(new Ui::ExportToModListDialog)
{
ui->setupUi(this);
enableCustom(false);
- MinecraftInstance* mcInstance = dynamic_cast(instance.get());
- if (mcInstance) {
- mcInstance->loaderModList()->update();
- connect(mcInstance->loaderModList().get(), &ModFolderModel::updateFinished, this, [this, mcInstance]() {
- m_allMods = mcInstance->loaderModList()->allMods();
- triggerImp();
- });
- }
-
connect(ui->formatComboBox, QOverload::of(&QComboBox::currentIndexChanged), this, &ExportToModListDialog::formatChanged);
connect(ui->authorsCheckBox, &QCheckBox::stateChanged, this, &ExportToModListDialog::trigger);
connect(ui->versionCheckBox, &QCheckBox::stateChanged, this, &ExportToModListDialog::trigger);
@@ -64,7 +53,7 @@ ExportToModListDialog::ExportToModListDialog(InstancePtr instance, QWidget* pare
connect(ui->versionButton, &QPushButton::clicked, this, [this](bool) { addExtra(ExportToModList::Version); });
connect(ui->urlButton, &QPushButton::clicked, this, [this](bool) { addExtra(ExportToModList::Url); });
connect(ui->templateText, &QTextEdit::textChanged, this, [this] {
- if (ui->templateText->toPlainText() != exampleLines[format])
+ if (ui->templateText->toPlainText() != exampleLines[m_format])
ui->formatComboBox->setCurrentIndex(5);
else
triggerImp();
@@ -73,6 +62,7 @@ ExportToModListDialog::ExportToModListDialog(InstancePtr instance, QWidget* pare
this->ui->finalText->selectAll();
this->ui->finalText->copy();
});
+ triggerImp();
}
ExportToModListDialog::~ExportToModListDialog()
@@ -86,38 +76,38 @@ void ExportToModListDialog::formatChanged(int index)
case 0: {
enableCustom(false);
ui->resultText->show();
- format = ExportToModList::HTML;
+ m_format = ExportToModList::HTML;
break;
}
case 1: {
enableCustom(false);
ui->resultText->show();
- format = ExportToModList::MARKDOWN;
+ m_format = ExportToModList::MARKDOWN;
break;
}
case 2: {
enableCustom(false);
ui->resultText->hide();
- format = ExportToModList::PLAINTXT;
+ m_format = ExportToModList::PLAINTXT;
break;
}
case 3: {
enableCustom(false);
ui->resultText->hide();
- format = ExportToModList::JSON;
+ m_format = ExportToModList::JSON;
break;
}
case 4: {
enableCustom(false);
ui->resultText->hide();
- format = ExportToModList::CSV;
+ m_format = ExportToModList::CSV;
break;
}
case 5: {
m_template_changed = true;
enableCustom(true);
ui->resultText->hide();
- format = ExportToModList::CUSTOM;
+ m_format = ExportToModList::CUSTOM;
break;
}
}
@@ -126,8 +116,8 @@ void ExportToModListDialog::formatChanged(int index)
void ExportToModListDialog::triggerImp()
{
- if (format == ExportToModList::CUSTOM) {
- ui->finalText->setPlainText(ExportToModList::exportToModList(m_allMods, ui->templateText->toPlainText()));
+ if (m_format == ExportToModList::CUSTOM) {
+ ui->finalText->setPlainText(ExportToModList::exportToModList(m_mods, ui->templateText->toPlainText()));
return;
}
auto opt = 0;
@@ -137,9 +127,9 @@ void ExportToModListDialog::triggerImp()
opt |= ExportToModList::Version;
if (ui->urlCheckBox->isChecked())
opt |= ExportToModList::Url;
- auto txt = ExportToModList::exportToModList(m_allMods, format, static_cast(opt));
+ auto txt = ExportToModList::exportToModList(m_mods, m_format, static_cast(opt));
ui->finalText->setPlainText(txt);
- switch (format) {
+ switch (m_format) {
case ExportToModList::CUSTOM:
return;
case ExportToModList::HTML:
@@ -155,7 +145,7 @@ void ExportToModListDialog::triggerImp()
case ExportToModList::CSV:
break;
}
- auto exampleLine = exampleLines[format];
+ auto exampleLine = exampleLines[m_format];
if (!m_template_changed && ui->templateText->toPlainText() != exampleLine)
ui->templateText->setPlainText(exampleLine);
}
@@ -163,9 +153,9 @@ void ExportToModListDialog::triggerImp()
void ExportToModListDialog::done(int result)
{
if (result == Accepted) {
- const QString filename = FS::RemoveInvalidFilenameChars(name);
+ const QString filename = FS::RemoveInvalidFilenameChars(m_name);
const QString output =
- QFileDialog::getSaveFileName(this, tr("Export %1").arg(name), FS::PathCombine(QDir::homePath(), filename + extension()),
+ QFileDialog::getSaveFileName(this, tr("Export %1").arg(m_name), FS::PathCombine(QDir::homePath(), filename + extension()),
"File (*.txt *.html *.md *.json *.csv)", nullptr);
if (output.isEmpty())
@@ -178,7 +168,7 @@ void ExportToModListDialog::done(int result)
QString ExportToModListDialog::extension()
{
- switch (format) {
+ switch (m_format) {
case ExportToModList::HTML:
return ".html";
case ExportToModList::MARKDOWN:
@@ -197,7 +187,7 @@ QString ExportToModListDialog::extension()
void ExportToModListDialog::addExtra(ExportToModList::OptionalData option)
{
- if (format != ExportToModList::CUSTOM)
+ if (m_format != ExportToModList::CUSTOM)
return;
switch (option) {
case ExportToModList::Authors:
diff --git a/launcher/ui/dialogs/ExportToModListDialog.h b/launcher/ui/dialogs/ExportToModListDialog.h
index 9886ae5a0..4ebe203f7 100644
--- a/launcher/ui/dialogs/ExportToModListDialog.h
+++ b/launcher/ui/dialogs/ExportToModListDialog.h
@@ -20,7 +20,6 @@
#include
#include
-#include "BaseInstance.h"
#include "minecraft/mod/Mod.h"
#include "modplatform/helpers/ExportToModList.h"
@@ -32,7 +31,7 @@ class ExportToModListDialog : public QDialog {
Q_OBJECT
public:
- explicit ExportToModListDialog(InstancePtr instance, QWidget* parent = nullptr);
+ explicit ExportToModListDialog(QString name, QList mods, QWidget* parent = nullptr);
~ExportToModListDialog();
void done(int result) override;
@@ -46,10 +45,11 @@ class ExportToModListDialog : public QDialog {
private:
QString extension();
void enableCustom(bool enabled);
- QList m_allMods;
+
+ QList m_mods;
bool m_template_changed;
- QString name;
- ExportToModList::Formats format = ExportToModList::Formats::HTML;
+ QString m_name;
+ ExportToModList::Formats m_format = ExportToModList::Formats::HTML;
Ui::ExportToModListDialog* ui;
static const QHash exampleLines;
};
diff --git a/launcher/ui/pages/instance/ModFolderPage.cpp b/launcher/ui/pages/instance/ModFolderPage.cpp
index a38e608f2..31fb49d0c 100644
--- a/launcher/ui/pages/instance/ModFolderPage.cpp
+++ b/launcher/ui/pages/instance/ModFolderPage.cpp
@@ -37,6 +37,7 @@
*/
#include "ModFolderPage.h"
+#include "ui/dialogs/ExportToModListDialog.h"
#include "ui_ExternalResourcesPage.h"
#include
@@ -111,6 +112,10 @@ ModFolderPage::ModFolderPage(BaseInstance* inst, std::shared_ptr
connect(actionRemoveItemMetadata, &QAction::triggered, this, &ModFolderPage::deleteModMetadata);
actionRemoveItemMetadata->setEnabled(false);
+ auto actionExportMetadata = updateMenu->addAction(tr("Export metadata"));
+ actionExportMetadata->setToolTip(tr("Export mod's metadata to text"));
+ connect(actionExportMetadata, &QAction::triggered, this, &ModFolderPage::exportModMetadata);
+
ui->actionUpdateItem->setMenu(updateMenu);
ui->actionUpdateItem->setToolTip(tr("Try to check or update all selected mods (all mods if none are selected)"));
@@ -124,7 +129,7 @@ ModFolderPage::ModFolderPage(BaseInstance* inst, std::shared_ptr
auto check_allow_update = [this] { return ui->treeView->selectionModel()->hasSelection() || !m_model->empty(); };
connect(ui->treeView->selectionModel(), &QItemSelectionModel::selectionChanged, this,
- [this, check_allow_update, actionRemoveItemMetadata] {
+ [this, check_allow_update, actionRemoveItemMetadata, actionExportMetadata] {
ui->actionUpdateItem->setEnabled(check_allow_update());
auto selection = m_filterModel->mapSelectionToSource(ui->treeView->selectionModel()->selection()).indexes();
@@ -360,3 +365,14 @@ void ModFolderPage::deleteModMetadata()
m_model->deleteModsMetadata(selection);
}
+
+void ModFolderPage::exportModMetadata()
+{
+ auto selection = m_filterModel->mapSelectionToSource(ui->treeView->selectionModel()->selection()).indexes();
+ auto selectedMods = m_model->selectedMods(selection);
+ if (selectedMods.length() == 0)
+ selectedMods = m_model->allMods();
+
+ ExportToModListDialog dlg(m_instance->name(), selectedMods, this);
+ dlg.exec();
+}
diff --git a/launcher/ui/pages/instance/ModFolderPage.h b/launcher/ui/pages/instance/ModFolderPage.h
index 4672350c6..928f5ca7e 100644
--- a/launcher/ui/pages/instance/ModFolderPage.h
+++ b/launcher/ui/pages/instance/ModFolderPage.h
@@ -62,6 +62,7 @@ class ModFolderPage : public ExternalResourcesPage {
private slots:
void removeItems(const QItemSelection& selection) override;
void deleteModMetadata();
+ void exportModMetadata();
void installMods();
void updateMods(bool includeDeps = false);