summaryrefslogtreecommitdiffstats
path: root/application/dialogs/ExportInstanceDialog.cpp
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2019-05-31 21:52:58 +0200
committerPetr Mrázek <peterix@gmail.com>2019-05-31 21:53:58 +0200
commit3470a3df966100d4f1ea6488892ac048118a3131 (patch)
treefc0f649f4bba0859f7f38d2b81876fd52a8266a2 /application/dialogs/ExportInstanceDialog.cpp
parent61913daaf3b21960de13340a6069bc3daca8744a (diff)
downloadMultiMC-3470a3df966100d4f1ea6488892ac048118a3131.tar
MultiMC-3470a3df966100d4f1ea6488892ac048118a3131.tar.gz
MultiMC-3470a3df966100d4f1ea6488892ac048118a3131.tar.lz
MultiMC-3470a3df966100d4f1ea6488892ac048118a3131.tar.xz
MultiMC-3470a3df966100d4f1ea6488892ac048118a3131.zip
NOISSUE improve icon handling while importing and exporting instances
Now it handles formats other than png.
Diffstat (limited to 'application/dialogs/ExportInstanceDialog.cpp')
-rw-r--r--application/dialogs/ExportInstanceDialog.cpp60
1 files changed, 27 insertions, 33 deletions
diff --git a/application/dialogs/ExportInstanceDialog.cpp b/application/dialogs/ExportInstanceDialog.cpp
index 5419b000..49c082e9 100644
--- a/application/dialogs/ExportInstanceDialog.cpp
+++ b/application/dialogs/ExportInstanceDialog.cpp
@@ -343,43 +343,37 @@ void SaveIcon(InstancePtr m_instance)
auto iconKey = m_instance->iconKey();
auto iconList = MMC->icons();
auto mmcIcon = iconList->icon(iconKey);
- if(mmcIcon)
+ 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())) ();
+ return;
+ }
+ auto & image = mmcIcon->m_images[mmcIcon->type()];
+ auto & icon = image.icon;
+ auto sizes = icon.availableSizes();
+ if(sizes.size() == 0)
{
- bool saveIcon = false;
- switch(mmcIcon->type())
- {
- case IconType::FileBased:
- case IconType::Transient:
- saveIcon = true;
- default:
- break;
- }
- if(saveIcon)
+ return;
+ }
+ 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))
{
- auto & image = mmcIcon->m_images[mmcIcon->type()];
- auto & icon = image.icon;
- auto sizes = icon.availableSizes();
- if(sizes.size() == 0)
- {
- return;
- }
- 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))
- {
- largest = size;
- }
- }
- auto pixmap = icon.pixmap(largest);
- pixmap.save(FS::PathCombine(m_instance->instanceRoot(), iconKey + ".png"));
+ largest = size;
}
}
+ auto pixmap = icon.pixmap(largest);
+ pixmap.save(FS::PathCombine(m_instance->instanceRoot(), iconKey + ".png"));
}
bool ExportInstanceDialog::doExport()