diff options
author | Janrupf <werbung.janrupf@t-online.de> | 2018-04-07 16:15:58 +0200 |
---|---|---|
committer | Petr Mrázek <peterix@gmail.com> | 2018-04-07 22:09:19 +0200 |
commit | 7e1c5d439a2ef6ce1346a3581776f58508a22afe (patch) | |
tree | ed9e037feaee01e100cee36369274492155a8833 /application/dialogs | |
parent | 38ed0c2a1ff5839cc5b7a1addd25932a7c88b4de (diff) | |
download | MultiMC-7e1c5d439a2ef6ce1346a3581776f58508a22afe.tar MultiMC-7e1c5d439a2ef6ce1346a3581776f58508a22afe.tar.gz MultiMC-7e1c5d439a2ef6ce1346a3581776f58508a22afe.tar.lz MultiMC-7e1c5d439a2ef6ce1346a3581776f58508a22afe.tar.xz MultiMC-7e1c5d439a2ef6ce1346a3581776f58508a22afe.zip |
#2228, #2229 - Auto import pack icons and fixed to big version selection - Closes #2228, Closes #2229
Diffstat (limited to 'application/dialogs')
-rw-r--r-- | application/dialogs/NewInstanceDialog.cpp | 23 | ||||
-rw-r--r-- | application/dialogs/NewInstanceDialog.h | 8 |
2 files changed, 31 insertions, 0 deletions
diff --git a/application/dialogs/NewInstanceDialog.cpp b/application/dialogs/NewInstanceDialog.cpp index 900b33f7..b3ce5c6c 100644 --- a/application/dialogs/NewInstanceDialog.cpp +++ b/application/dialogs/NewInstanceDialog.cpp @@ -100,6 +100,7 @@ void NewInstanceDialog::reject() void NewInstanceDialog::accept() { MMC->settings()->set("NewInstanceGeometry", saveGeometry().toBase64()); + importIconNow(); QDialog::accept(); } @@ -135,6 +136,16 @@ void NewInstanceDialog::setSuggestedPack(const QString& name, InstanceTask* task m_buttons->button(QDialogButtonBox::Ok)->setEnabled(allowOK); } +void NewInstanceDialog::setSuggestedIconFromFile(const QString &path, const QString &name) +{ + importIcon = true; + importIconPath = path; + importIconName = name; + + //Hmm, for some reason they can be to small + ui->iconButton->setIcon(QIcon(path)); +} + InstanceTask * NewInstanceDialog::extractTask() { InstanceTask * extracted = creationTask.get(); @@ -177,6 +188,7 @@ QString NewInstanceDialog::iconKey() const void NewInstanceDialog::on_iconButton_clicked() { + importIconNow(); //so the user can switch back IconPickerDialog dlg(this); dlg.execWithSelection(InstIconKey); @@ -184,6 +196,7 @@ void NewInstanceDialog::on_iconButton_clicked() { InstIconKey = dlg.selectedIconKey; ui->iconButton->setIcon(MMC->icons()->getIcon(InstIconKey)); + importIcon = false; } } @@ -191,3 +204,13 @@ void NewInstanceDialog::on_instNameTextBox_textChanged(const QString &arg1) { updateDialogState(); } + +void NewInstanceDialog::importIconNow() +{ + if(importIcon) { + MMC->icons()->installIcon(importIconPath, importIconName); + InstIconKey = importIconName; + importIcon = false; + } + MMC->settings()->set("NewInstanceGeometry", saveGeometry().toBase64()); +} diff --git a/application/dialogs/NewInstanceDialog.h b/application/dialogs/NewInstanceDialog.h index 9d7cab01..1448d225 100644 --- a/application/dialogs/NewInstanceDialog.h +++ b/application/dialogs/NewInstanceDialog.h @@ -41,6 +41,8 @@ public: void updateDialogState(); void setSuggestedPack(const QString & name = QString(), InstanceTask * task = nullptr); + void setSuggestedIconFromFile(const QString &path, const QString &name); + InstanceTask * extractTask(); QString dialogTitle() override; @@ -66,4 +68,10 @@ private: QString InstIconKey; ImportPage *importPage = nullptr; std::unique_ptr<InstanceTask> creationTask; + + bool importIcon = false; + QString importIconPath; + QString importIconName; + + void importIconNow(); }; |