From 405cea177877234981019c6916f6f97d818dfd51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Mon, 1 Jun 2015 01:19:12 +0200 Subject: GH-1031 include icon in exported instance if it is custom --- application/MainWindow.cpp | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'application/MainWindow.cpp') diff --git a/application/MainWindow.cpp b/application/MainWindow.cpp index 6c5aa3af..9ff120bd 100644 --- a/application/MainWindow.cpp +++ b/application/MainWindow.cpp @@ -1137,7 +1137,27 @@ void MainWindow::instanceFromZipPack(QString instName, QString instGroup, QStrin } newInstance->setName(instName); - newInstance->setIconKey(instIcon); + if(instIcon != "default") + { + newInstance->setIconKey(instIcon); + } + else + { + instIcon = newInstance->iconKey(); + auto importIconPath = PathCombine(newInstance->instanceRoot(), instIcon + ".png"); + if (QFile::exists(importIconPath)) + { + // import icon + auto iconList = ENV.icons(); + // FIXME: check if the file is OK before removing the existing one... + if(iconList->iconFileExists(instIcon)) + { + //FIXME: ask if icon should be overwritten. Show difference in the question dialog. + iconList->deleteIcon(instIcon); + } + iconList->installIcons({importIconPath}); + } + } newInstance->setGroupInitial(instGroup); MMC->instances()->add(InstancePtr(newInstance)); MMC->instances()->saveGroupList(); @@ -1225,7 +1245,6 @@ void MainWindow::on_actionAddInstance_triggered() const QUrl modpackUrl = newInstDlg.modpackUrl(); - if (modpackUrl.isValid()) { instanceFromZipPack(newInstDlg.instName(), newInstDlg.instGroup(), newInstDlg.iconKey(), modpackUrl); -- cgit v1.2.3