diff --git a/include/mainwindow.h b/include/mainwindow.h index fc0007f6..cd04dc7f 100644 --- a/include/mainwindow.h +++ b/include/mainwindow.h @@ -308,6 +308,7 @@ private: void updateTilesetEditor(); QString getEventGroupFromTabWidget(QWidget *tab); void closeSupplementaryWindows(); + void setWindowDisabled(bool); bool isProjectOpen(); void showExportMapImageWindow(bool stitchMode); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 119f3827..26a862bf 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -62,6 +62,21 @@ MainWindow::~MainWindow() delete ui; } +void MainWindow::setWindowDisabled(bool disabled) { + for (auto *child : findChildren(QString(), Qt::FindDirectChildrenOnly)) { + bool disableThis = disabled; + if (child->objectName() == "menuBar") { + // disable all but the menuFile + for (auto *menu : child->findChildren(QString(), Qt::FindDirectChildrenOnly)) { + menu->setDisabled(disabled); + } + child->findChild("menuFile")->setDisabled(false); + disableThis = false; + } + child->setDisabled(disableThis); + } +} + void MainWindow::initWindow() { porymapConfig.load(); this->initCustomUI(); @@ -2314,10 +2329,12 @@ void MainWindow::on_action_Export_Map_Image_triggered() { } void MainWindow::on_actionExport_Stitched_Map_Image_triggered() { - showExportMapImageWindow(true); + showExportMapImageWindow(true); } void MainWindow::showExportMapImageWindow(bool stitchMode) { + if (!editor->project) return; + if (this->mapImageExporter) delete this->mapImageExporter; @@ -2664,7 +2681,7 @@ void MainWindow::closeSupplementaryWindows() { } void MainWindow::closeEvent(QCloseEvent *event) { - if (projectHasUnsavedChanges || editor->map->hasUnsavedChanges()) { + if (projectHasUnsavedChanges || (editor->map && editor->map->hasUnsavedChanges())) { QMessageBox::StandardButton result = QMessageBox::question( this, "porymap", "The project has been modified, save changes?", QMessageBox::No | QMessageBox::Yes | QMessageBox::Cancel, QMessageBox::Yes);