aboutsummaryrefslogtreecommitdiff
path: root/launcher/ui/dialogs/ExportInstanceDialog.cpp
diff options
context:
space:
mode:
authorTrial97 <alexandru.tripon97@gmail.com>2023-07-16 20:53:58 +0300
committerTrial97 <alexandru.tripon97@gmail.com>2023-07-16 20:53:58 +0300
commit251055302eec0232a89f0466efe3e7e7f3fa7de3 (patch)
tree07dd9da435765f7332c7b65081777f6f8d813da8 /launcher/ui/dialogs/ExportInstanceDialog.cpp
parentb9568279dc364a462e9837ea13bc3c4f61abdda8 (diff)
downloadPrismLauncher-251055302eec0232a89f0466efe3e7e7f3fa7de3.tar.gz
PrismLauncher-251055302eec0232a89f0466efe3e7e7f3fa7de3.tar.bz2
PrismLauncher-251055302eec0232a89f0466efe3e7e7f3fa7de3.zip
format
Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
Diffstat (limited to 'launcher/ui/dialogs/ExportInstanceDialog.cpp')
-rw-r--r--launcher/ui/dialogs/ExportInstanceDialog.cpp70
1 files changed, 25 insertions, 45 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();
}
}