aboutsummaryrefslogtreecommitdiff
path: root/launcher/ui/dialogs
diff options
context:
space:
mode:
Diffstat (limited to 'launcher/ui/dialogs')
-rw-r--r--launcher/ui/dialogs/AboutDialog.cpp65
-rw-r--r--launcher/ui/dialogs/AboutDialog.h17
-rw-r--r--launcher/ui/dialogs/BlockedModsDialog.cpp2
-rw-r--r--launcher/ui/dialogs/CopyInstanceDialog.cpp6
-rw-r--r--launcher/ui/dialogs/CustomMessageBox.cpp14
-rw-r--r--launcher/ui/dialogs/CustomMessageBox.h7
-rw-r--r--launcher/ui/dialogs/EditAccountDialog.cpp11
-rw-r--r--launcher/ui/dialogs/EditAccountDialog.h26
-rw-r--r--launcher/ui/dialogs/ExportInstanceDialog.cpp129
-rw-r--r--launcher/ui/dialogs/ExportInstanceDialog.h25
-rw-r--r--launcher/ui/dialogs/ExportPackDialog.cpp (renamed from launcher/ui/dialogs/ExportMrPackDialog.cpp)66
-rw-r--r--launcher/ui/dialogs/ExportPackDialog.h (renamed from launcher/ui/dialogs/ExportMrPackDialog.h)14
-rw-r--r--launcher/ui/dialogs/ExportPackDialog.ui (renamed from launcher/ui/dialogs/ExportMrPackDialog.ui)15
-rw-r--r--launcher/ui/dialogs/ExportToModListDialog.cpp223
-rw-r--r--launcher/ui/dialogs/ExportToModListDialog.h55
-rw-r--r--launcher/ui/dialogs/ExportToModListDialog.ui240
-rw-r--r--launcher/ui/dialogs/IconPickerDialog.cpp39
-rw-r--r--launcher/ui/dialogs/IconPickerDialog.h23
-rw-r--r--launcher/ui/dialogs/ImportResourceDialog.h2
-rw-r--r--launcher/ui/dialogs/LoginDialog.cpp28
-rw-r--r--launcher/ui/dialogs/LoginDialog.h31
-rw-r--r--launcher/ui/dialogs/MSALoginDialog.cpp43
-rw-r--r--launcher/ui/dialogs/MSALoginDialog.h32
-rw-r--r--launcher/ui/dialogs/ModUpdateDialog.h4
-rw-r--r--launcher/ui/dialogs/NewComponentDialog.cpp30
-rw-r--r--launcher/ui/dialogs/NewComponentDialog.h16
-rw-r--r--launcher/ui/dialogs/NewInstanceDialog.cpp68
-rw-r--r--launcher/ui/dialogs/NewInstanceDialog.h42
-rw-r--r--launcher/ui/dialogs/OfflineLoginDialog.cpp23
-rw-r--r--launcher/ui/dialogs/OfflineLoginDialog.h29
-rw-r--r--launcher/ui/dialogs/ProfileSelectDialog.cpp30
-rw-r--r--launcher/ui/dialogs/ProfileSelectDialog.h22
-rw-r--r--launcher/ui/dialogs/ProfileSetupDialog.cpp97
-rw-r--r--launcher/ui/dialogs/ProfileSetupDialog.h56
-rw-r--r--launcher/ui/dialogs/ProgressDialog.cpp68
-rw-r--r--launcher/ui/dialogs/ProgressDialog.h49
-rw-r--r--launcher/ui/dialogs/ResourceDownloadDialog.cpp9
-rw-r--r--launcher/ui/dialogs/ScrollMessageBox.cpp9
-rw-r--r--launcher/ui/dialogs/ScrollMessageBox.h15
-rw-r--r--launcher/ui/dialogs/SkinUploadDialog.cpp84
-rw-r--r--launcher/ui/dialogs/SkinUploadDialog.h21
-rw-r--r--launcher/ui/dialogs/VersionSelectDialog.cpp13
-rw-r--r--launcher/ui/dialogs/VersionSelectDialog.h37
43 files changed, 1138 insertions, 697 deletions
diff --git a/launcher/ui/dialogs/AboutDialog.cpp b/launcher/ui/dialogs/AboutDialog.cpp
index 88739463..3c6f6ef1 100644
--- a/launcher/ui/dialogs/AboutDialog.cpp
+++ b/launcher/ui/dialogs/AboutDialog.cpp
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-3.0-only
/*
- * PolyMC - Minecraft Launcher
+ * Prism Launcher - Minecraft Launcher
* Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net>
*
* This program is free software: you can redistribute it and/or modify
@@ -34,26 +34,28 @@
*/
#include "AboutDialog.h"
-#include "BuildConfig.h"
-#include "ui_AboutDialog.h"
#include <QIcon>
#include "Application.h"
#include "BuildConfig.h"
#include "Markdown.h"
+#include "ui_AboutDialog.h"
#include <net/NetJob.h>
#include <qobject.h>
namespace {
-QString getLink(QString link, QString name) {
+QString getLink(QString link, QString name)
+{
return QString("&lt;<a href='%1'>%2</a>&gt;").arg(link).arg(name);
}
-QString getWebsite(QString link) {
+QString getWebsite(QString link)
+{
return getLink(link, QObject::tr("Website"));
}
-QString getGitHub(QString username) {
+QString getGitHub(QString username)
+{
return getLink("https://github.com/" + username, "GitHub");
}
@@ -70,19 +72,19 @@ QString getCreditsHtml()
//: %1 is the name of the launcher, determined at build time, e.g. "Prism Launcher Developers"
stream << "<h3>" << QObject::tr("%1 Developers", "About Credits").arg(BuildConfig.LAUNCHER_DISPLAYNAME) << "</h3>\n";
- stream << QString("<p>Sefa Eyeoglu (Scrumplex) %1</p>\n") .arg(getWebsite("https://scrumplex.net"));
- stream << QString("<p>d-513 %1</p>\n") .arg(getGitHub("d-513"));
- stream << QString("<p>txtsd %1</p>\n") .arg(getWebsite("https://ihavea.quest"));
- stream << QString("<p>timoreo %1</p>\n") .arg(getGitHub("timoreo22"));
- stream << QString("<p>Ezekiel Smith (ZekeSmith) %1</p>\n") .arg(getGitHub("ZekeSmith"));
- stream << QString("<p>cozyGalvinism %1</p>\n") .arg(getGitHub("cozyGalvinism"));
- stream << QString("<p>DioEgizio %1</p>\n") .arg(getGitHub("DioEgizio"));
- stream << QString("<p>flowln %1</p>\n") .arg(getGitHub("flowln"));
- stream << QString("<p>ViRb3 %1</p>\n") .arg(getGitHub("ViRb3"));
- stream << QString("<p>Rachel Powers (Ryex) %1</p>\n") .arg(getGitHub("Ryex"));
- stream << QString("<p>TayouVR %1</p>\n") .arg(getGitHub("TayouVR"));
- stream << QString("<p>TheKodeToad %1</p>\n") .arg(getGitHub("TheKodeToad"));
- stream << QString("<p>getchoo %1</p>\n") .arg(getGitHub("getchoo"));
+ stream << QString("<p>Sefa Eyeoglu (Scrumplex) %1</p>\n").arg(getWebsite("https://scrumplex.net"));
+ stream << QString("<p>d-513 %1</p>\n").arg(getGitHub("d-513"));
+ stream << QString("<p>txtsd %1</p>\n").arg(getWebsite("https://ihavea.quest"));
+ stream << QString("<p>timoreo %1</p>\n").arg(getGitHub("timoreo22"));
+ stream << QString("<p>Ezekiel Smith (ZekeSmith) %1</p>\n").arg(getGitHub("ZekeSmith"));
+ stream << QString("<p>cozyGalvinism %1</p>\n").arg(getGitHub("cozyGalvinism"));
+ stream << QString("<p>DioEgizio %1</p>\n").arg(getGitHub("DioEgizio"));
+ stream << QString("<p>flowln %1</p>\n").arg(getGitHub("flowln"));
+ stream << QString("<p>ViRb3 %1</p>\n").arg(getGitHub("ViRb3"));
+ stream << QString("<p>Rachel Powers (Ryex) %1</p>\n").arg(getGitHub("Ryex"));
+ stream << QString("<p>TayouVR %1</p>\n").arg(getGitHub("TayouVR"));
+ stream << QString("<p>TheKodeToad %1</p>\n").arg(getGitHub("TheKodeToad"));
+ stream << QString("<p>getchoo %1</p>\n").arg(getGitHub("getchoo"));
stream << "<br />\n";
// TODO: possibly retrieve from git history at build time?
@@ -96,20 +98,21 @@ QString getCreditsHtml()
stream << "<br />\n";
stream << "<h3>" << QObject::tr("With thanks to", "About Credits") << "</h3>\n";
- stream << QString("<p>Boba %1</p>\n") .arg(getWebsite("https://bobaonline.neocities.org/"));
- stream << QString("<p>Davi Rafael %1</p>\n") .arg(getWebsite("https://auti.one/"));
- stream << QString("<p>Fulmine %1</p>\n") .arg(getWebsite("https://www.fulmine.xyz/"));
- stream << QString("<p>ely %1</p>\n") .arg(getGitHub("elyrodso"));
- stream << QString("<p>gon sawa %1</p>\n") .arg(getGitHub("gonsawa"));
+ stream << QString("<p>Boba %1</p>\n").arg(getWebsite("https://bobaonline.neocities.org/"));
+ stream << QString("<p>Davi Rafael %1</p>\n").arg(getWebsite("https://auti.one/"));
+ stream << QString("<p>Fulmine %1</p>\n").arg(getWebsite("https://www.fulmine.xyz/"));
+ stream << QString("<p>ely %1</p>\n").arg(getGitHub("elyrodso"));
+ stream << QString("<p>gon sawa %1</p>\n").arg(getGitHub("gonsawa"));
stream << QString("<p>Pankakes</p>\n");
- stream << QString("<p>tobimori %1</p>\n") .arg(getGitHub("tobimori"));
+ stream << QString("<p>tobimori %1</p>\n").arg(getGitHub("tobimori"));
stream << "<p>Orochimarufan &lt;<a href='mailto:orochimarufan.x3@gmail.com'>orochimarufan.x3@gmail.com</a>&gt;</p>\n";
stream << "<p>TakSuyu &lt;<a href='mailto:taksuyu@gmail.com'>taksuyu@gmail.com</a>&gt;</p>\n";
stream << "<p>Kilobyte &lt;<a href='mailto:stiepen22@gmx.de'>stiepen22@gmx.de</a>&gt;</p>\n";
stream << "<p>Rootbear75 &lt;<a href='https://twitter.com/rootbear75'>@rootbear75</a>&gt;</p>\n";
stream << "<p>Zeker Zhayard &lt;<a href='https://twitter.com/zeker_zhayard'>@Zeker_Zhayard</a>&gt;</p>\n";
stream << "<p>Everyone who helped establish our branding!</p>\n";
- stream << "<p>And everyone else who <a href='https://github.com/PrismLauncher/PrismLauncher/graphs/contributors'>contributed</a>!</p>\n";
+ stream
+ << "<p>And everyone else who <a href='https://github.com/PrismLauncher/PrismLauncher/graphs/contributors'>contributed</a>!</p>\n";
stream << "<br />\n";
stream << "</center>\n";
@@ -124,9 +127,9 @@ QString getLicenseHtml()
return output;
}
-}
+} // namespace
-AboutDialog::AboutDialog(QWidget *parent) : QDialog(parent), ui(new Ui::AboutDialog)
+AboutDialog::AboutDialog(QWidget* parent) : QDialog(parent), ui(new Ui::AboutDialog)
{
ui->setupUi(this);
@@ -148,7 +151,7 @@ AboutDialog::AboutDialog(QWidget *parent) : QDialog(parent), ui(new Ui::AboutDia
ui->versionLabel->setText(BuildConfig.printableVersionString());
if (!BuildConfig.BUILD_PLATFORM.isEmpty())
- ui->platformLabel->setText(tr("Platform") +": " + BuildConfig.BUILD_PLATFORM);
+ ui->platformLabel->setText(tr("Platform") + ": " + BuildConfig.BUILD_PLATFORM);
else
ui->platformLabel->setVisible(false);
@@ -163,14 +166,14 @@ AboutDialog::AboutDialog(QWidget *parent) : QDialog(parent), ui(new Ui::AboutDia
ui->buildDateLabel->setVisible(false);
if (!BuildConfig.VERSION_CHANNEL.isEmpty())
- ui->channelLabel->setText(tr("Channel") +": " + BuildConfig.VERSION_CHANNEL);
+ ui->channelLabel->setText(tr("Channel") + ": " + BuildConfig.VERSION_CHANNEL);
else
ui->channelLabel->setVisible(false);
QString urlText("<html><head/><body><p><a href=\"%1\">%1</a></p></body></html>");
ui->urlLabel->setText(urlText.arg(BuildConfig.LAUNCHER_GIT));
- QString copyText("© 2022 %1");
+ QString copyText("© 2022-2023 %1");
ui->copyLabel->setText(copyText.arg(BuildConfig.LAUNCHER_COPYRIGHT));
connect(ui->closeButton, SIGNAL(clicked()), SLOT(close()));
diff --git a/launcher/ui/dialogs/AboutDialog.h b/launcher/ui/dialogs/AboutDialog.h
index 814fd98c..356f005e 100644
--- a/launcher/ui/dialogs/AboutDialog.h
+++ b/launcher/ui/dialogs/AboutDialog.h
@@ -15,26 +15,23 @@
#pragma once
-#include <QDialog>
#include <net/NetJob.h>
+#include <QDialog>
-namespace Ui
-{
+namespace Ui {
class AboutDialog;
}
-class AboutDialog : public QDialog
-{
+class AboutDialog : public QDialog {
Q_OBJECT
-public:
- explicit AboutDialog(QWidget *parent = 0);
+ public:
+ explicit AboutDialog(QWidget* parent = 0);
~AboutDialog();
-private:
- Ui::AboutDialog *ui;
+ private:
+ Ui::AboutDialog* ui;
NetJob::Ptr netJob;
QByteArray dataSink;
};
-
diff --git a/launcher/ui/dialogs/BlockedModsDialog.cpp b/launcher/ui/dialogs/BlockedModsDialog.cpp
index fdfae597..727c0614 100644
--- a/launcher/ui/dialogs/BlockedModsDialog.cpp
+++ b/launcher/ui/dialogs/BlockedModsDialog.cpp
@@ -313,7 +313,7 @@ bool BlockedModsDialog::checkValidPath(QString path)
// efectivly compare two strings ignoring all separators and case
auto laxCompare = [](QString fsfilename, QString metadataFilename) {
// allowed character seperators
- QList<QChar> allowedSeperators = { '-', '+', '.' , '_'};
+ QList<QChar> allowedSeperators = { '-', '+', '.', '_' };
// copy in lowercase
auto fsName = fsfilename.toLower();
diff --git a/launcher/ui/dialogs/CopyInstanceDialog.cpp b/launcher/ui/dialogs/CopyInstanceDialog.cpp
index d75bb5fe..0e410027 100644
--- a/launcher/ui/dialogs/CopyInstanceDialog.cpp
+++ b/launcher/ui/dialogs/CopyInstanceDialog.cpp
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-3.0-only
/*
- * PolyMC - Minecraft Launcher
+ * Prism Launcher - Minecraft Launcher
* Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net>
*
* This program is free software: you can redistribute it and/or modify
@@ -107,8 +107,8 @@ CopyInstanceDialog::CopyInstanceDialog(InstancePtr original, QWidget* parent)
#if defined(Q_OS_WIN)
ui->symbolicLinksCheckbox->setIcon(style()->standardIcon(QStyle::SP_VistaShield));
- ui->symbolicLinksCheckbox->setToolTip(tr("Use symbolic links instead of copying files.") +
- "\n" + tr("On Windows, symbolic links may require admin permission to create."));
+ ui->symbolicLinksCheckbox->setToolTip(tr("Use symbolic links instead of copying files.") + "\n" +
+ tr("On Windows, symbolic links may require admin permission to create."));
#endif
updateLinkOptions();
diff --git a/launcher/ui/dialogs/CustomMessageBox.cpp b/launcher/ui/dialogs/CustomMessageBox.cpp
index 19029f68..1af47a44 100644
--- a/launcher/ui/dialogs/CustomMessageBox.cpp
+++ b/launcher/ui/dialogs/CustomMessageBox.cpp
@@ -15,13 +15,15 @@
#include "CustomMessageBox.h"
-namespace CustomMessageBox
-{
-QMessageBox *selectable(QWidget *parent, const QString &title, const QString &text,
- QMessageBox::Icon icon, QMessageBox::StandardButtons buttons,
+namespace CustomMessageBox {
+QMessageBox* selectable(QWidget* parent,
+ const QString& title,
+ const QString& text,
+ QMessageBox::Icon icon,
+ QMessageBox::StandardButtons buttons,
QMessageBox::StandardButton defaultButton)
{
- QMessageBox *messageBox = new QMessageBox(parent);
+ QMessageBox* messageBox = new QMessageBox(parent);
messageBox->setWindowTitle(title);
messageBox->setText(text);
messageBox->setStandardButtons(buttons);
@@ -32,4 +34,4 @@ QMessageBox *selectable(QWidget *parent, const QString &title, const QString &te
return messageBox;
}
-}
+} // namespace CustomMessageBox
diff --git a/launcher/ui/dialogs/CustomMessageBox.h b/launcher/ui/dialogs/CustomMessageBox.h
index 712c6518..a9bc6a24 100644
--- a/launcher/ui/dialogs/CustomMessageBox.h
+++ b/launcher/ui/dialogs/CustomMessageBox.h
@@ -17,9 +17,10 @@
#include <QMessageBox>
-namespace CustomMessageBox
-{
-QMessageBox *selectable(QWidget *parent, const QString &title, const QString &text,
+namespace CustomMessageBox {
+QMessageBox* selectable(QWidget* parent,
+ const QString& title,
+ const QString& text,
QMessageBox::Icon icon = QMessageBox::NoIcon,
QMessageBox::StandardButtons buttons = QMessageBox::Ok,
QMessageBox::StandardButton defaultButton = QMessageBox::NoButton);
diff --git a/launcher/ui/dialogs/EditAccountDialog.cpp b/launcher/ui/dialogs/EditAccountDialog.cpp
index 002c064b..58036fd8 100644
--- a/launcher/ui/dialogs/EditAccountDialog.cpp
+++ b/launcher/ui/dialogs/EditAccountDialog.cpp
@@ -14,12 +14,11 @@
*/
#include "EditAccountDialog.h"
-#include "ui_EditAccountDialog.h"
#include <DesktopServices.h>
#include <QUrl>
+#include "ui_EditAccountDialog.h"
-EditAccountDialog::EditAccountDialog(const QString &text, QWidget *parent, int flags)
- : QDialog(parent), ui(new Ui::EditAccountDialog)
+EditAccountDialog::EditAccountDialog(const QString& text, QWidget* parent, int flags) : QDialog(parent), ui(new Ui::EditAccountDialog)
{
ui->setupUi(this);
@@ -35,12 +34,12 @@ EditAccountDialog::~EditAccountDialog()
delete ui;
}
-void EditAccountDialog::on_label_linkActivated(const QString &link)
+void EditAccountDialog::on_label_linkActivated(const QString& link)
{
DesktopServices::openUrl(QUrl(link));
}
-void EditAccountDialog::setUsername(const QString & user) const
+void EditAccountDialog::setUsername(const QString& user) const
{
ui->userTextBox->setText(user);
}
@@ -50,7 +49,7 @@ QString EditAccountDialog::username() const
return ui->userTextBox->text();
}
-void EditAccountDialog::setPassword(const QString & pass) const
+void EditAccountDialog::setPassword(const QString& pass) const
{
ui->passTextBox->setText(pass);
}
diff --git a/launcher/ui/dialogs/EditAccountDialog.h b/launcher/ui/dialogs/EditAccountDialog.h
index 6b5eb4aa..7a9ccba7 100644
--- a/launcher/ui/dialogs/EditAccountDialog.h
+++ b/launcher/ui/dialogs/EditAccountDialog.h
@@ -17,28 +17,24 @@
#include <QDialog>
-namespace Ui
-{
+namespace Ui {
class EditAccountDialog;
}
-class EditAccountDialog : public QDialog
-{
+class EditAccountDialog : public QDialog {
Q_OBJECT
-public:
- explicit EditAccountDialog(const QString &text = "", QWidget *parent = 0,
- int flags = UsernameField | PasswordField);
+ public:
+ explicit EditAccountDialog(const QString& text = "", QWidget* parent = 0, int flags = UsernameField | PasswordField);
~EditAccountDialog();
- void setUsername(const QString & user) const;
- void setPassword(const QString & pass) const;
+ void setUsername(const QString& user) const;
+ void setPassword(const QString& pass) const;
QString username() const;
QString password() const;
- enum Flags
- {
+ enum Flags {
NoFlags = 0,
//! Specifies that the dialog should have a username field.
@@ -48,9 +44,9 @@ public:
PasswordField,
};
-private slots:
- void on_label_linkActivated(const QString &link);
+ private slots:
+ void on_label_linkActivated(const QString& link);
-private:
- Ui::EditAccountDialog *ui;
+ private:
+ Ui::EditAccountDialog* ui;
};
diff --git a/launcher/ui/dialogs/ExportInstanceDialog.cpp b/launcher/ui/dialogs/ExportInstanceDialog.cpp
index 8ecd91a9..d6a503cc 100644
--- a/launcher/ui/dialogs/ExportInstanceDialog.cpp
+++ b/launcher/ui/dialogs/ExportInstanceDialog.cpp
@@ -3,6 +3,7 @@
* Prism Launcher - Minecraft Launcher
* Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net>
* Copyright (C) 2023 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
@@ -35,24 +36,29 @@
*/
#include "ExportInstanceDialog.h"
-#include "ui_ExportInstanceDialog.h"
#include <BaseInstance.h>
#include <MMCZip.h>
#include <QFileDialog>
-#include <QMessageBox>
#include <QFileSystemModel>
+#include <QMessageBox>
+#include "FileIgnoreProxy.h"
+#include "QObjectPtr.h"
+#include "ui/dialogs/CustomMessageBox.h"
+#include "ui/dialogs/ProgressDialog.h"
+#include "ui_ExportInstanceDialog.h"
-#include <QSortFilterProxyModel>
+#include <FileSystem.h>
+#include <icons/IconList.h>
#include <QDebug>
+#include <QFileInfo>
#include <QSaveFile>
+#include <QSortFilterProxyModel>
#include <QStack>
-#include <QFileInfo>
-#include "SeparatorPrefixTree.h"
+#include <functional>
#include "Application.h"
-#include <icons/IconList.h>
-#include <FileSystem.h>
+#include "SeparatorPrefixTree.h"
-ExportInstanceDialog::ExportInstanceDialog(InstancePtr instance, QWidget *parent)
+ExportInstanceDialog::ExportInstanceDialog(InstancePtr instance, QWidget* parent)
: QDialog(parent), ui(new Ui::ExportInstanceDialog), m_instance(instance)
{
ui->setupUi(this);
@@ -60,13 +66,19 @@ ExportInstanceDialog::ExportInstanceDialog(InstancePtr instance, QWidget *parent
model->setIconProvider(&icons);
auto root = instance->instanceRoot();
proxyModel = new FileIgnoreProxy(root, this);
- loadPackIgnore();
proxyModel->setSourceModel(model);
+ auto prefix = QDir(instance->instanceRoot()).relativeFilePath(instance->gameRoot());
+ proxyModel->ignoreFilesWithPath().insert({ FS::PathCombine(prefix, "logs"), FS::PathCombine(prefix, "crash-reports") });
+ proxyModel->ignoreFilesWithName().append({ ".DS_Store", "thumbs.db", "Thumbs.db" });
+ proxyModel->ignoreFilesWithPath().insert(
+ { FS::PathCombine(prefix, ".cache"), FS::PathCombine(prefix, ".fabric"), FS::PathCombine(prefix, ".quilt") });
+ loadPackIgnore();
+
ui->treeView->setModel(proxyModel);
ui->treeView->setRootIndex(proxyModel->mapFromSource(model->index(root)));
ui->treeView->sortByColumn(0, Qt::AscendingOrder);
- connect(proxyModel, SIGNAL(rowsInserted(QModelIndex,int,int)), SLOT(rowsInserted(QModelIndex,int,int)));
+ connect(proxyModel, SIGNAL(rowsInserted(QModelIndex, int, int)), SLOT(rowsInserted(QModelIndex, int, int)));
model->setFilter(QDir::AllEntries | QDir::NoDotAndDotDot | QDir::AllDirs | QDir::Hidden);
model->setRootPath(root);
@@ -86,32 +98,26 @@ void SaveIcon(InstancePtr m_instance)
auto iconKey = m_instance->iconKey();
auto iconList = APPLICATION->icons();
auto mmcIcon = iconList->icon(iconKey);
- if(!mmcIcon || mmcIcon->isBuiltIn()) {
+ if (!mmcIcon || mmcIcon->isBuiltIn()) {
return;
}
auto path = mmcIcon->getFilePath();
- if(!path.isNull()) {
- QFileInfo inInfo (path);
- FS::copy(path, FS::PathCombine(m_instance->instanceRoot(), inInfo.fileName())) ();
+ if (!path.isNull()) {
+ QFileInfo inInfo(path);
+ FS::copy(path, FS::PathCombine(m_instance->instanceRoot(), inInfo.fileName()))();
return;
}
- auto & image = mmcIcon->m_images[mmcIcon->type()];
- auto & icon = image.icon;
+ auto& image = mmcIcon->m_images[mmcIcon->type()];
+ auto& icon = image.icon;
auto sizes = icon.availableSizes();
- if(sizes.size() == 0)
- {
+ if (sizes.size() == 0) {
return;
}
- auto areaOf = [](QSize size)
- {
- return size.width() * size.height();
- };
+ auto areaOf = [](QSize size) { return size.width() * size.height(); };
QSize largest = sizes[0];
// find variant with largest area
- for(auto size: sizes)
- {
- if(areaOf(largest) < areaOf(size))
- {
+ for (auto size : sizes) {
+ if (areaOf(largest) < areaOf(size)) {
largest = size;
}
}
@@ -119,66 +125,57 @@ void SaveIcon(InstancePtr m_instance)
pixmap.save(FS::PathCombine(m_instance->instanceRoot(), iconKey + ".png"));
}
-bool ExportInstanceDialog::doExport()
+void ExportInstanceDialog::doExport()
{
auto name = FS::RemoveInvalidFilenameChars(m_instance->name());
- const QString output = QFileDialog::getSaveFileName(
- this, tr("Export %1").arg(m_instance->name()),
- FS::PathCombine(QDir::homePath(), name + ".zip"), "Zip (*.zip)", nullptr);
- if (output.isEmpty())
- {
- return false;
+ const QString output = QFileDialog::getSaveFileName(this, tr("Export %1").arg(m_instance->name()),
+ FS::PathCombine(QDir::homePath(), name + ".zip"), "Zip (*.zip)", nullptr);
+ if (output.isEmpty()) {
+ QDialog::done(QDialog::Rejected);
+ return;
}
SaveIcon(m_instance);
- auto & blocked = proxyModel->blockedPaths();
- using std::placeholders::_1;
auto files = QFileInfoList();
if (!MMCZip::collectFileListRecursively(m_instance->instanceRoot(), nullptr, &files,
- std::bind(&SeparatorPrefixTree<'/'>::covers, blocked, _1))) {
+ std::bind(&FileIgnoreProxy::filterFile, proxyModel, std::placeholders::_1))) {
QMessageBox::warning(this, tr("Error"), tr("Unable to export instance"));
- return false;
+ QDialog::done(QDialog::Rejected);
+ return;
}
- if (!MMCZip::compressDirFiles(output, m_instance->instanceRoot(), files, true))
- {
- QMessageBox::warning(this, tr("Error"), tr("Unable to export instance"));
- return false;
- }
- return true;
+ auto task = makeShared<MMCZip::ExportToZipTask>(output, m_instance->instanceRoot(), files, "", true);
+
+ connect(task.get(), &Task::failed, this,
+ [this, output](QString reason) { CustomMessageBox::selectable(this, tr("Error"), reason, QMessageBox::Critical)->show(); });
+ connect(task.get(), &Task::finished, this, [task] { task->deleteLater(); });
+
+ ProgressDialog progress(this);
+ progress.setSkipButton(true, tr("Abort"));
+ auto result = progress.execWithTask(task.get());
+ QDialog::done(result);
}
void ExportInstanceDialog::done(int result)
{
savePackIgnore();
- if (result == QDialog::Accepted)
- {
- if (doExport())
- {
- QDialog::done(QDialog::Accepted);
- return;
- }
- else
- {
- return;
- }
+ if (result == QDialog::Accepted) {
+ doExport();
+ return;
}
QDialog::done(result);
}
void ExportInstanceDialog::rowsInserted(QModelIndex parent, int top, int bottom)
{
- //WARNING: possible off-by-one?
- for(int i = top; i < bottom; i++)
- {
+ // WARNING: possible off-by-one?
+ for (int i = top; i < bottom; i++) {
auto node = proxyModel->index(i, 0, parent);
- if(proxyModel->shouldExpand(node))
- {
+ if (proxyModel->shouldExpand(node)) {
auto expNode = node.parent();
- if(!expNode.isValid())
- {
+ if (!expNode.isValid()) {
continue;
}
ui->treeView->expand(node);
@@ -195,8 +192,7 @@ void ExportInstanceDialog::loadPackIgnore()
{
auto filename = ignoreFileName();
QFile ignoreFile(filename);
- if(!ignoreFile.open(QIODevice::ReadOnly))
- {
+ if (!ignoreFile.open(QIODevice::ReadOnly)) {
return;
}
auto data = ignoreFile.readAll();
@@ -212,12 +208,9 @@ void ExportInstanceDialog::savePackIgnore()
{
auto data = proxyModel->blockedPaths().toStringList().join('\n').toUtf8();
auto filename = ignoreFileName();
- try
- {
+ try {
FS::write(filename, data);
- }
- catch (const Exception &e)
- {
+ } catch (const Exception& e) {
qWarning() << e.cause();
}
}
diff --git a/launcher/ui/dialogs/ExportInstanceDialog.h b/launcher/ui/dialogs/ExportInstanceDialog.h
index 5e801875..02f38f63 100644
--- a/launcher/ui/dialogs/ExportInstanceDialog.h
+++ b/