1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-18 17:40:48 +02:00

Fix saving bug and window modality bug

This commit is contained in:
nordsoft 2022-09-05 20:55:30 +04:00
parent 8903d2edaf
commit f87117b581
5 changed files with 38 additions and 6 deletions

View File

@ -230,7 +230,7 @@ void MainWindow::saveMap()
CMapService mapService; CMapService mapService;
try try
{ {
mapService.saveMap(std::unique_ptr<CMap>(controller.map()), filename.toStdString()); mapService.saveMap(controller.getMapUniquePtr(), filename.toStdString());
} }
catch(const std::exception & e) catch(const std::exception & e)
{ {
@ -762,13 +762,15 @@ void MainWindow::on_inspectorWidget_itemChanged(QTableWidgetItem *item)
void MainWindow::on_actionMapSettings_triggered() void MainWindow::on_actionMapSettings_triggered()
{ {
auto mapSettingsDialog = new MapSettings(controller, this); auto settingsDialog = new MapSettings(controller, this);
mapSettingsDialog->setModal(true); settingsDialog->setWindowModality(Qt::WindowModal);
settingsDialog->setModal(true);
} }
void MainWindow::on_actionPlayers_settings_triggered() void MainWindow::on_actionPlayers_settings_triggered()
{ {
auto mapSettingsDialog = new PlayerSettings(*controller.map(), this); auto settingsDialog = new PlayerSettings(*controller.map(), this);
mapSettingsDialog->setModal(true); settingsDialog->setWindowModality(Qt::WindowModal);
settingsDialog->setModal(true);
} }

View File

@ -70,8 +70,15 @@
<addaction name="actionMapSettings"/> <addaction name="actionMapSettings"/>
<addaction name="actionPlayers_settings"/> <addaction name="actionPlayers_settings"/>
</widget> </widget>
<widget class="QMenu" name="menuPlayer">
<property name="title">
<string>Player</string>
</property>
<addaction name="actionNeutral"/>
</widget>
<addaction name="menuFile"/> <addaction name="menuFile"/>
<addaction name="menuMap"/> <addaction name="menuMap"/>
<addaction name="menuPlayer"/>
</widget> </widget>
<widget class="QToolBar" name="toolBar"> <widget class="QToolBar" name="toolBar">
<property name="windowTitle"> <property name="windowTitle">
@ -823,6 +830,14 @@
<string>Players settings</string> <string>Players settings</string>
</property> </property>
</action> </action>
<action name="actionNeutral">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>Neutral</string>
</property>
</action>
</widget> </widget>
<customwidgets> <customwidgets>
<customwidget> <customwidget>

View File

@ -26,6 +26,11 @@ MapController::~MapController()
{ {
} }
const std::unique_ptr<CMap> & MapController::getMapUniquePtr() const
{
return _map;
}
CMap * MapController::map() CMap * MapController::map()
{ {
return _map.get(); return _map.get();

View File

@ -17,6 +17,7 @@ public:
void setMap(std::unique_ptr<CMap>); void setMap(std::unique_ptr<CMap>);
const std::unique_ptr<CMap> & getMapUniquePtr() const; //to be used for map saving
CMap * map(); CMap * map();
MapHandler * mapHandler(); MapHandler * mapHandler();
MapScene * scene(int level); MapScene * scene(int level);

View File

@ -2,6 +2,9 @@
<ui version="4.0"> <ui version="4.0">
<class>PlayerSettings</class> <class>PlayerSettings</class>
<widget class="QDialog" name="PlayerSettings"> <widget class="QDialog" name="PlayerSettings">
<property name="windowModality">
<enum>Qt::WindowModal</enum>
</property>
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
@ -10,8 +13,14 @@
<height>283</height> <height>283</height>
</rect> </rect>
</property> </property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="windowTitle"> <property name="windowTitle">
<string>Dialog</string> <string>Player settings</string>
</property>
<property name="modal">
<bool>true</bool>
</property> </property>
<layout class="QGridLayout" name="gridLayout"> <layout class="QGridLayout" name="gridLayout">
<item row="1" column="0" colspan="8"> <item row="1" column="0" colspan="8">