Scenario: Add waiting dialog.

scenarios
Pierre-Antoine Rouby 2024-09-03 11:30:44 +02:00
parent 8f4d233965
commit a412f2f18f
1 changed files with 19 additions and 6 deletions

View File

@ -34,6 +34,8 @@ from PyQt5.QtWidgets import (
QGraphicsItem, QGraphicsTextItem, QMenu, QGraphicsItem, QGraphicsTextItem, QMenu,
) )
from View.WaitingDialog import WaitingDialog
from View.Scenarios.UndoCommand import * from View.Scenarios.UndoCommand import *
from View.Scenarios.ContextMenu import ( from View.Scenarios.ContextMenu import (
DefaultMenu, ScenarioMenu, DefaultMenu, ScenarioMenu,
@ -366,6 +368,14 @@ class GraphWidget(QGraphicsView):
self.update() self.update()
super(GraphWidget, self).mouseMoveEvent(event) super(GraphWidget, self).mouseMoveEvent(event)
def exec_with_waiting_window(self, fn, action_str):
dlg = WaitingDialog(
payload_fn=fn,
title=action_str,
parent=self.parent
)
dlg.exec_()
# Contextual menu # Contextual menu
def contextMenuEvent(self, event): def contextMenuEvent(self, event):
@ -397,15 +407,18 @@ class GraphWidget(QGraphicsView):
if type(item) is not ScenarioItem: if type(item) is not ScenarioItem:
return return
self._study.save() def fn():
self._study.reload_from_scenario(item.scenario) self._study.save()
self._study.reload_from_scenario(item.scenario)
self.exec_with_waiting_window(fn, "select_scenario")
self.changeScenario.emit(self.sender()) self.changeScenario.emit(self.sender())
def new_scenario(self, pos): def new_scenario(self, pos):
self._study.save() def fn():
self._study.save()
scenario = self._study.new_scenario_from_current() scenario = self._study.new_scenario_from_current()
scenario.set_pos(pos.x(), pos.y()) scenario.set_pos(pos.x(), pos.y())
self.exec_with_waiting_window(fn, "new_scenario")
self.changeScenario.emit(self.sender()) self.changeScenario.emit(self.sender())