aboutsummaryrefslogtreecommitdiff
path: root/launcher/ui
diff options
context:
space:
mode:
Diffstat (limited to 'launcher/ui')
-rw-r--r--launcher/ui/dialogs/ExportInstanceDialog.cpp70
-rw-r--r--launcher/ui/dialogs/ExportInstanceDialog.h22
2 files changed, 35 insertions, 57 deletions
diff --git a/launcher/ui/dialogs/ExportInstanceDialog.cpp b/launcher/ui/dialogs/ExportInstanceDialog.cpp
index cc41c394..379ec79f 100644
--- a/launcher/ui/dialogs/ExportInstanceDialog.cpp
+++ b/launcher/ui/dialogs/ExportInstanceDialog.cpp
@@ -72,7 +72,7 @@ ExportInstanceDialog::ExportInstanceDialog(InstancePtr instance, QWidget* parent
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);
@@ -92,32 +92,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;
}
}
@@ -129,11 +123,9 @@ bool 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())
- {
+ 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;
}
@@ -146,8 +138,7 @@ bool ExportInstanceDialog::doExport()
return false;
}
- if (!MMCZip::compressDirFiles(output, m_instance->instanceRoot(), files, true))
- {
+ if (!MMCZip::compressDirFiles(output, m_instance->instanceRoot(), files, true)) {
QMessageBox::warning(this, tr("Error"), tr("Unable to export instance"));
return false;
}
@@ -157,15 +148,11 @@ bool ExportInstanceDialog::doExport()
void ExportInstanceDialog::done(int result)
{
savePackIgnore();
- if (result == QDialog::Accepted)
- {
- if (doExport())
- {
+ if (result == QDialog::Accepted) {
+ if (doExport()) {
QDialog::done(QDialog::Accepted);
return;
- }
- else
- {
+ } else {
return;
}
}
@@ -174,15 +161,12 @@ void ExportInstanceDialog::done(int 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);
@@ -199,8 +183,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();
@@ -216,12 +199,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..20a92807 100644
--- a/launcher/ui/dialogs/ExportInstanceDialog.h
+++ b/launcher/ui/dialogs/ExportInstanceDialog.h
@@ -38,39 +38,37 @@
#include <QDialog>
#include <QModelIndex>
#include <memory>
-#include "FileIgnoreProxy.h"
#include "FastFileIconProvider.h"
+#include "FileIgnoreProxy.h"
class BaseInstance;
typedef std::shared_ptr<BaseInstance> InstancePtr;
-namespace Ui
-{
+namespace Ui {
class ExportInstanceDialog;
}
-class ExportInstanceDialog : public QDialog
-{
+class ExportInstanceDialog : public QDialog {
Q_OBJECT
-public:
- explicit ExportInstanceDialog(InstancePtr instance, QWidget *parent = 0);
+ public:
+ explicit ExportInstanceDialog(InstancePtr instance, QWidget* parent = 0);
~ExportInstanceDialog();
virtual void done(int result);
-private:
+ private:
bool doExport();
void loadPackIgnore();
void savePackIgnore();
QString ignoreFileName();
-private:
- Ui::ExportInstanceDialog *ui;
+ private:
+ Ui::ExportInstanceDialog* ui;
InstancePtr m_instance;
- FileIgnoreProxy * proxyModel;
+ FileIgnoreProxy* proxyModel;
FastFileIconProvider icons;
-private slots:
+ private slots:
void rowsInserted(QModelIndex parent, int top, int bottom);
};