diff --git a/launcher/modplatform/helpers/ExportToModList.h b/launcher/modplatform/helpers/ExportToModList.h
index abd6e9bc6..49252fc4f 100644
--- a/launcher/modplatform/helpers/ExportToModList.h
+++ b/launcher/modplatform/helpers/ExportToModList.h
@@ -16,7 +16,7 @@
* along with this program. If not, see .
*/
#pragma once
-#include
+#include
#include
#include "minecraft/mod/Mod.h"
diff --git a/launcher/ui/dialogs/ExportToModListDialog.cpp b/launcher/ui/dialogs/ExportToModListDialog.cpp
index cfd28cf85..b86b10561 100644
--- a/launcher/ui/dialogs/ExportToModListDialog.cpp
+++ b/launcher/ui/dialogs/ExportToModListDialog.cpp
@@ -33,11 +33,19 @@
#include
#include
+const QHash ExportToModListDialog::exampleLines = {
+ { ExportToModList::HTML, "{name} [{version}] by {authors}" },
+ { ExportToModList::MARKDOWN, "[{name}]({url}) [{version}] by {authors}" },
+ { ExportToModList::PLAINTXT, "{name} ({url}) [{version}] by {authors}" },
+ { ExportToModList::JSON, "{\"name\":\"{name}\",\"url\":\"{url}\",\"version\":\"{version}\",\"authors\":\"{authors}\"}," },
+ { ExportToModList::CSV, "{name},{url},{version},\"{authors}\"" },
+};
+
ExportToModListDialog::ExportToModListDialog(InstancePtr instance, QWidget* parent)
- : QDialog(parent), m_template_selected(false), name(instance->name()), ui(new Ui::ExportToModListDialog)
+ : QDialog(parent), m_template_changed(false), name(instance->name()), ui(new Ui::ExportToModListDialog)
{
ui->setupUi(this);
- ui->templateGroup->setDisabled(true);
+ ui->optionsGroup->setDisabled(false);
MinecraftInstance* mcInstance = dynamic_cast(instance.get());
if (mcInstance) {
@@ -52,7 +60,12 @@ ExportToModListDialog::ExportToModListDialog(InstancePtr instance, QWidget* pare
connect(ui->authorsCheckBox, &QCheckBox::stateChanged, this, &ExportToModListDialog::trigger);
connect(ui->versionCheckBox, &QCheckBox::stateChanged, this, &ExportToModListDialog::trigger);
connect(ui->urlCheckBox, &QCheckBox::stateChanged, this, &ExportToModListDialog::trigger);
- connect(ui->templateText, &QTextEdit::textChanged, this, &ExportToModListDialog::triggerImp);
+ connect(ui->templateText, &QTextEdit::textChanged, this, [this] {
+ if (ui->templateText->toPlainText() != exampleLines[format])
+ ui->formatComboBox->setCurrentIndex(5);
+ else
+ triggerImp();
+ });
connect(ui->copyButton, &QPushButton::clicked, this, [this](bool) {
this->ui->finalText->selectAll();
this->ui->finalText->copy();
@@ -68,42 +81,37 @@ void ExportToModListDialog::formatChanged(int index)
{
switch (index) {
case 0: {
- ui->templateGroup->setDisabled(true);
ui->optionsGroup->setDisabled(false);
ui->resultText->show();
format = ExportToModList::HTML;
break;
}
case 1: {
- ui->templateGroup->setDisabled(true);
ui->optionsGroup->setDisabled(false);
ui->resultText->show();
format = ExportToModList::MARKDOWN;
break;
}
case 2: {
- ui->templateGroup->setDisabled(true);
ui->optionsGroup->setDisabled(false);
ui->resultText->hide();
format = ExportToModList::PLAINTXT;
break;
}
case 3: {
- ui->templateGroup->setDisabled(true);
ui->optionsGroup->setDisabled(false);
ui->resultText->hide();
format = ExportToModList::JSON;
break;
}
case 4: {
- ui->templateGroup->setDisabled(true);
ui->optionsGroup->setDisabled(false);
ui->resultText->hide();
format = ExportToModList::CSV;
break;
}
case 5: {
- ui->templateGroup->setDisabled(false);
+ m_template_changed = true;
ui->optionsGroup->setDisabled(true);
ui->resultText->hide();
format = ExportToModList::CUSTOM;
@@ -116,7 +124,6 @@ void ExportToModListDialog::formatChanged(int index)
void ExportToModListDialog::triggerImp()
{
if (format == ExportToModList::CUSTOM) {
- m_template_selected = true;
ui->finalText->setPlainText(ExportToModList::ExportToModList(m_allMods, ui->templateText->toPlainText()));
return;
}
@@ -129,35 +136,25 @@ void ExportToModListDialog::triggerImp()
opt |= ExportToModList::Url;
auto txt = ExportToModList::ExportToModList(m_allMods, format, static_cast(opt));
ui->finalText->setPlainText(txt);
- QString exampleLine;
switch (format) {
- case ExportToModList::HTML: {
- exampleLine = "{name} [{version}] by {authors}";
- ui->resultText->setHtml(txt);
- break;
- }
- case ExportToModList::MARKDOWN: {
- exampleLine = "[{name}]({url}) [{version}] by {authors}";
- ui->resultText->setHtml(markdownToHTML(txt));
- break;
- }
- case ExportToModList::PLAINTXT: {
- exampleLine = "{name} ({url}) [{version}] by {authors}";
- break;
- }
case ExportToModList::CUSTOM:
return;
+ case ExportToModList::HTML:
+ ui->resultText->setHtml(txt);
+ break;
+ case ExportToModList::MARKDOWN:
+ ui->resultText->setHtml(markdownToHTML(txt));
+ break;
+ case ExportToModList::PLAINTXT:
+ break;
case ExportToModList::JSON:
- exampleLine = "{\"name\":\"{name}\",\"url\":\"{url}\",\"version\":\"{version}\",\"authors\":\"{authors}\"},";
break;
case ExportToModList::CSV:
- exampleLine = "{name},{url},{version},\"{authors}\"";
break;
}
- if (!m_template_selected) {
- if (ui->templateText->toPlainText() != exampleLine)
- ui->templateText->setPlainText(exampleLine);
- }
+ auto exampleLine = exampleLines[format];
+ if (!m_template_changed && ui->templateText->toPlainText() != exampleLine)
+ ui->templateText->setPlainText(exampleLine);
}
void ExportToModListDialog::done(int result)
diff --git a/launcher/ui/dialogs/ExportToModListDialog.h b/launcher/ui/dialogs/ExportToModListDialog.h
index a7a6bcdce..b8a83d830 100644
--- a/launcher/ui/dialogs/ExportToModListDialog.h
+++ b/launcher/ui/dialogs/ExportToModListDialog.h
@@ -45,8 +45,9 @@ class ExportToModListDialog : public QDialog {
private:
QString extension();
QList m_allMods;
- bool m_template_selected;
+ bool m_template_changed;
QString name;
ExportToModList::Formats format = ExportToModList::Formats::HTML;
Ui::ExportToModListDialog* ui;
+ static const QHash exampleLines;
};
diff --git a/launcher/ui/dialogs/ExportToModListDialog.ui b/launcher/ui/dialogs/ExportToModListDialog.ui
index e0f138f9e..90f179a63 100644
--- a/launcher/ui/dialogs/ExportToModListDialog.ui
+++ b/launcher/ui/dialogs/ExportToModListDialog.ui
@@ -18,7 +18,7 @@
-
-
+
-
@@ -149,6 +149,16 @@
+ -
+
+
+ This depends on the mods meta data. To ensure the meta data run at least one time the mods update on the selected instance(no need to update the mods).
+
+
+ true
+
+
+
-
@@ -189,7 +199,7 @@
-
+
buttonBox
rejected()
ExportToModListDialog