Skip to content

Commit

Permalink
Avoid double opening the "save file" menu
Browse files Browse the repository at this point in the history
  • Loading branch information
Atari2 committed Apr 2, 2024
1 parent bcc2132 commit 1a36f67
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions cfgeditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,10 @@ void CFGEditor::setUpMenuBar(QMenuBar* mb) {
"Do you want to save it before opening a new one?",
QMessageBox::Yes | QMessageBox::No | QMessageBox::Abort );
if (res == QMessageBox::Yes) {
sprite->to_file(QFileDialog::getSaveFileName(this, tr("Save file"), sprite->name(), tr("JSON (*.json)")));
auto filename = QFileDialog::getSaveFileName(this, tr("Save file"), sprite->name(), tr("JSON (*.json)"));
if (filename.size() == 0)
return;
sprite->to_file(filename);
} else if (res == QMessageBox::Abort) {
return;
}
Expand All @@ -131,7 +134,10 @@ void CFGEditor::setUpMenuBar(QMenuBar* mb) {
QMessageBox::Yes | QMessageBox::No | QMessageBox::Abort );
if (res == QMessageBox::Yes) {
saveSprite();
sprite->to_file(QFileDialog::getSaveFileName(this, tr("Save file"), sprite->name(), tr("JSON (*.json)")));
auto filename = QFileDialog::getSaveFileName(this, tr("Save file"), sprite->name(), tr("JSON (*.json)"));
if (filename.size() == 0)
return;
sprite->to_file(filename);
} else if (res == QMessageBox::Abort) {
return;
}
Expand All @@ -156,7 +162,10 @@ void CFGEditor::setUpMenuBar(QMenuBar* mb) {

file->addAction("&Save As", Qt::CTRL | Qt::ALT | Qt::Key_S, qApp, [&]() {
saveSprite();
sprite->to_file(QFileDialog::getSaveFileName(this, tr("Save file"), sprite->name(), tr("JSON (*.json);;CFG (*.cfg)")));
auto filename = QFileDialog::getSaveFileName(this, tr("Save file"), sprite->name(), tr("JSON (*.json);;CFG (*.cfg)"));
if (filename.size() == 0)
return;
sprite->to_file(filename);
});

display->addAction("&Load Custom Map16", qApp, [&]() {
Expand Down

0 comments on commit 1a36f67

Please sign in to comment.