mirror of
https://github.com/PrismLauncher/PrismLauncher.git
synced 2025-06-12 13:17:41 +02:00
Merge branch 'develop' of https://github.com/PrismLauncher/PrismLauncher into filters
This commit is contained in:
@ -38,6 +38,7 @@
|
||||
#include "Application.h"
|
||||
#include "BuildConfig.h"
|
||||
#include "Markdown.h"
|
||||
#include "StringUtils.h"
|
||||
#include "ui_AboutDialog.h"
|
||||
|
||||
#include <net/NetJob.h>
|
||||
@ -139,10 +140,10 @@ AboutDialog::AboutDialog(QWidget* parent) : QDialog(parent), ui(new Ui::AboutDia
|
||||
setWindowTitle(tr("About %1").arg(launcherName));
|
||||
|
||||
QString chtml = getCreditsHtml();
|
||||
ui->creditsText->setHtml(chtml);
|
||||
ui->creditsText->setHtml(StringUtils::htmlListPatch(chtml));
|
||||
|
||||
QString lhtml = getLicenseHtml();
|
||||
ui->licenseText->setHtml(lhtml);
|
||||
ui->licenseText->setHtml(StringUtils::htmlListPatch(lhtml));
|
||||
|
||||
ui->urlLabel->setOpenExternalLinks(true);
|
||||
|
||||
|
@ -22,8 +22,7 @@
|
||||
#include <QTextEdit>
|
||||
#include "FileSystem.h"
|
||||
#include "Markdown.h"
|
||||
#include "minecraft/MinecraftInstance.h"
|
||||
#include "minecraft/mod/ModFolderModel.h"
|
||||
#include "StringUtils.h"
|
||||
#include "modplatform/helpers/ExportToModList.h"
|
||||
#include "ui_ExportToModListDialog.h"
|
||||
|
||||
@ -41,38 +40,31 @@ const QHash<ExportToModList::Formats, QString> 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<Mod*> 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<MinecraftInstance*>(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<int>::of(&QComboBox::currentIndexChanged), this, &ExportToModListDialog::formatChanged);
|
||||
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->filenameCheckBox, &QCheckBox::stateChanged, this, &ExportToModListDialog::trigger);
|
||||
connect(ui->authorsButton, &QPushButton::clicked, this, [this](bool) { addExtra(ExportToModList::Authors); });
|
||||
connect(ui->versionButton, &QPushButton::clicked, this, [this](bool) { addExtra(ExportToModList::Version); });
|
||||
connect(ui->urlButton, &QPushButton::clicked, this, [this](bool) { addExtra(ExportToModList::Url); });
|
||||
connect(ui->filenameButton, &QPushButton::clicked, this, [this](bool) { addExtra(ExportToModList::FileName); });
|
||||
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();
|
||||
triggerImp();
|
||||
});
|
||||
connect(ui->copyButton, &QPushButton::clicked, this, [this](bool) {
|
||||
this->ui->finalText->selectAll();
|
||||
this->ui->finalText->copy();
|
||||
});
|
||||
triggerImp();
|
||||
}
|
||||
|
||||
ExportToModListDialog::~ExportToModListDialog()
|
||||
@ -86,38 +78,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 +118,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,16 +129,18 @@ void ExportToModListDialog::triggerImp()
|
||||
opt |= ExportToModList::Version;
|
||||
if (ui->urlCheckBox->isChecked())
|
||||
opt |= ExportToModList::Url;
|
||||
auto txt = ExportToModList::exportToModList(m_allMods, format, static_cast<ExportToModList::OptionalData>(opt));
|
||||
if (ui->filenameCheckBox->isChecked())
|
||||
opt |= ExportToModList::FileName;
|
||||
auto txt = ExportToModList::exportToModList(m_mods, m_format, static_cast<ExportToModList::OptionalData>(opt));
|
||||
ui->finalText->setPlainText(txt);
|
||||
switch (format) {
|
||||
switch (m_format) {
|
||||
case ExportToModList::CUSTOM:
|
||||
return;
|
||||
case ExportToModList::HTML:
|
||||
ui->resultText->setHtml(txt);
|
||||
ui->resultText->setHtml(StringUtils::htmlListPatch(txt));
|
||||
break;
|
||||
case ExportToModList::MARKDOWN:
|
||||
ui->resultText->setHtml(markdownToHTML(txt));
|
||||
ui->resultText->setHtml(StringUtils::htmlListPatch(markdownToHTML(txt)));
|
||||
break;
|
||||
case ExportToModList::PLAINTXT:
|
||||
break;
|
||||
@ -155,7 +149,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 +157,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 +172,7 @@ void ExportToModListDialog::done(int result)
|
||||
|
||||
QString ExportToModListDialog::extension()
|
||||
{
|
||||
switch (format) {
|
||||
switch (m_format) {
|
||||
case ExportToModList::HTML:
|
||||
return ".html";
|
||||
case ExportToModList::MARKDOWN:
|
||||
@ -197,7 +191,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:
|
||||
@ -209,6 +203,9 @@ void ExportToModListDialog::addExtra(ExportToModList::OptionalData option)
|
||||
case ExportToModList::Version:
|
||||
ui->templateText->insertPlainText("{version}");
|
||||
break;
|
||||
case ExportToModList::FileName:
|
||||
ui->templateText->insertPlainText("{filename}");
|
||||
break;
|
||||
}
|
||||
}
|
||||
void ExportToModListDialog::enableCustom(bool enabled)
|
||||
@ -221,4 +218,7 @@ void ExportToModListDialog::enableCustom(bool enabled)
|
||||
|
||||
ui->urlCheckBox->setHidden(enabled);
|
||||
ui->urlButton->setHidden(!enabled);
|
||||
|
||||
ui->filenameCheckBox->setHidden(enabled);
|
||||
ui->filenameButton->setHidden(!enabled);
|
||||
}
|
||||
|
@ -20,7 +20,6 @@
|
||||
|
||||
#include <QDialog>
|
||||
#include <QList>
|
||||
#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<Mod*> 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<Mod*> m_allMods;
|
||||
|
||||
QList<Mod*> 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<ExportToModList::Formats, QString> exampleLines;
|
||||
};
|
||||
|
@ -117,6 +117,13 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="filenameCheckBox">
|
||||
<property name="text">
|
||||
<string>Filename</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="versionButton">
|
||||
<property name="text">
|
||||
@ -138,6 +145,13 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="filenameButton">
|
||||
<property name="text">
|
||||
<string>Filename</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include "CustomMessageBox.h"
|
||||
#include "ProgressDialog.h"
|
||||
#include "ScrollMessageBox.h"
|
||||
#include "StringUtils.h"
|
||||
#include "minecraft/mod/tasks/GetModDependenciesTask.h"
|
||||
#include "modplatform/ModIndex.h"
|
||||
#include "modplatform/flame/FlameAPI.h"
|
||||
@ -473,7 +474,7 @@ void ModUpdateDialog::appendMod(CheckUpdateTask::UpdatableMod const& info, QStri
|
||||
break;
|
||||
}
|
||||
|
||||
changelog_area->setHtml(text);
|
||||
changelog_area->setHtml(StringUtils::htmlListPatch(text));
|
||||
changelog_area->setOpenExternalLinks(true);
|
||||
changelog_area->setLineWrapMode(QTextBrowser::LineWrapMode::WidgetWidth);
|
||||
changelog_area->setVerticalScrollBarPolicy(Qt::ScrollBarPolicy::ScrollBarAsNeeded);
|
||||
|
@ -52,6 +52,7 @@
|
||||
#include <QFileDialog>
|
||||
#include <QLayout>
|
||||
#include <QPushButton>
|
||||
#include <QScreen>
|
||||
#include <QValidator>
|
||||
#include <utility>
|
||||
|
||||
@ -63,6 +64,7 @@
|
||||
#include "ui/pages/modplatform/modrinth/ModrinthPage.h"
|
||||
#include "ui/pages/modplatform/technic/TechnicPage.h"
|
||||
#include "ui/widgets/PageContainer.h"
|
||||
|
||||
NewInstanceDialog::NewInstanceDialog(const QString& initialGroup,
|
||||
const QString& url,
|
||||
const QMap<QString, QString>& extra_info,
|
||||
@ -127,7 +129,17 @@ NewInstanceDialog::NewInstanceDialog(const QString& initialGroup,
|
||||
|
||||
updateDialogState();
|
||||
|
||||
restoreGeometry(QByteArray::fromBase64(APPLICATION->settings()->get("NewInstanceGeometry").toByteArray()));
|
||||
if (APPLICATION->settings()->get("NewInstanceGeometry").isValid()) {
|
||||
restoreGeometry(QByteArray::fromBase64(APPLICATION->settings()->get("NewInstanceGeometry").toByteArray()));
|
||||
} else {
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
|
||||
auto screen = parent->screen();
|
||||
#else
|
||||
auto screen = QGuiApplication::primaryScreen();
|
||||
#endif
|
||||
auto geometry = screen->availableSize();
|
||||
resize(width(), qMin(geometry.height() - 50, 710));
|
||||
}
|
||||
}
|
||||
|
||||
void NewInstanceDialog::reject()
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include "Application.h"
|
||||
#include "BuildConfig.h"
|
||||
#include "Markdown.h"
|
||||
#include "StringUtils.h"
|
||||
#include "ui_UpdateAvailableDialog.h"
|
||||
|
||||
UpdateAvailableDialog::UpdateAvailableDialog(const QString& currentVersion,
|
||||
@ -43,7 +44,7 @@ UpdateAvailableDialog::UpdateAvailableDialog(const QString& currentVersion,
|
||||
ui->icon->setPixmap(APPLICATION->getThemedIcon("checkupdate").pixmap(64));
|
||||
|
||||
auto releaseNotesHtml = markdownToHTML(releaseNotes);
|
||||
ui->releaseNotes->setHtml(releaseNotesHtml);
|
||||
ui->releaseNotes->setHtml(StringUtils::htmlListPatch(releaseNotesHtml));
|
||||
ui->releaseNotes->setOpenExternalLinks(true);
|
||||
|
||||
connect(ui->skipButton, &QPushButton::clicked, this, [this]() {
|
||||
|
Reference in New Issue
Block a user