From f87117b581753ecbe9f31068c166bb3fbc4219d6 Mon Sep 17 00:00:00 2001 From: nordsoft Date: Mon, 5 Sep 2022 20:55:30 +0400 Subject: [PATCH] Fix saving bug and window modality bug --- mapeditor/mainwindow.cpp | 12 +++++++----- mapeditor/mainwindow.ui | 15 +++++++++++++++ mapeditor/mapcontroller.cpp | 5 +++++ mapeditor/mapcontroller.h | 1 + mapeditor/playersettings.ui | 11 ++++++++++- 5 files changed, 38 insertions(+), 6 deletions(-) diff --git a/mapeditor/mainwindow.cpp b/mapeditor/mainwindow.cpp index 16101a07f..aaef9e575 100644 --- a/mapeditor/mainwindow.cpp +++ b/mapeditor/mainwindow.cpp @@ -230,7 +230,7 @@ void MainWindow::saveMap() CMapService mapService; try { - mapService.saveMap(std::unique_ptr(controller.map()), filename.toStdString()); + mapService.saveMap(controller.getMapUniquePtr(), filename.toStdString()); } catch(const std::exception & e) { @@ -762,13 +762,15 @@ void MainWindow::on_inspectorWidget_itemChanged(QTableWidgetItem *item) void MainWindow::on_actionMapSettings_triggered() { - auto mapSettingsDialog = new MapSettings(controller, this); - mapSettingsDialog->setModal(true); + auto settingsDialog = new MapSettings(controller, this); + settingsDialog->setWindowModality(Qt::WindowModal); + settingsDialog->setModal(true); } void MainWindow::on_actionPlayers_settings_triggered() { - auto mapSettingsDialog = new PlayerSettings(*controller.map(), this); - mapSettingsDialog->setModal(true); + auto settingsDialog = new PlayerSettings(*controller.map(), this); + settingsDialog->setWindowModality(Qt::WindowModal); + settingsDialog->setModal(true); } diff --git a/mapeditor/mainwindow.ui b/mapeditor/mainwindow.ui index 62281b603..8464d1967 100644 --- a/mapeditor/mainwindow.ui +++ b/mapeditor/mainwindow.ui @@ -70,8 +70,15 @@ + + + Player + + + + @@ -823,6 +830,14 @@ Players settings + + + true + + + Neutral + + diff --git a/mapeditor/mapcontroller.cpp b/mapeditor/mapcontroller.cpp index 7bc20e59f..879f0b39c 100644 --- a/mapeditor/mapcontroller.cpp +++ b/mapeditor/mapcontroller.cpp @@ -26,6 +26,11 @@ MapController::~MapController() { } +const std::unique_ptr & MapController::getMapUniquePtr() const +{ + return _map; +} + CMap * MapController::map() { return _map.get(); diff --git a/mapeditor/mapcontroller.h b/mapeditor/mapcontroller.h index 3f4cd6c70..181f22d2f 100644 --- a/mapeditor/mapcontroller.h +++ b/mapeditor/mapcontroller.h @@ -17,6 +17,7 @@ public: void setMap(std::unique_ptr); + const std::unique_ptr & getMapUniquePtr() const; //to be used for map saving CMap * map(); MapHandler * mapHandler(); MapScene * scene(int level); diff --git a/mapeditor/playersettings.ui b/mapeditor/playersettings.ui index 881a3eb89..5d111ee04 100644 --- a/mapeditor/playersettings.ui +++ b/mapeditor/playersettings.ui @@ -2,6 +2,9 @@ PlayerSettings + + Qt::WindowModal + 0 @@ -10,8 +13,14 @@ 283 + + Qt::NoFocus + - Dialog + Player settings + + + true