@@ -168,14 +168,16 @@ ScenarioRunWidget::ScenarioRunWidget(
168168 const safecrowd::domain::ScenarioDraft& scenario,
169169 std::function<void ()> saveProjectHandler,
170170 std::function<void ()> openProjectHandler,
171+ std::function<void ()> backToLayoutReviewHandler,
171172 QWidget* parent)
172173 : QWidget(parent),
173174 projectName_ (projectName),
174175 layout_(layout),
175176 scenario_(scenario),
176177 runner_(layout_, scenario_),
177178 saveProjectHandler_(std::move(saveProjectHandler)),
178- openProjectHandler_(std::move(openProjectHandler)) {
179+ openProjectHandler_(std::move(openProjectHandler)),
180+ backToLayoutReviewHandler_(std::move(backToLayoutReviewHandler)) {
179181 auto * rootLayout = new QVBoxLayout (this );
180182 rootLayout->setContentsMargins (0 , 0 , 0 , 0 );
181183 rootLayout->setSpacing (0 );
@@ -189,13 +191,15 @@ ScenarioRunWidget::ScenarioRunWidget(
189191 shell_->setTools ({" Project" });
190192 shell_->setSaveProjectHandler (saveProjectHandler_);
191193 shell_->setOpenProjectHandler (openProjectHandler_);
194+ shell_->setBackHandler ([this ]() {
195+ returnToAuthoring ();
196+ });
192197 canvas_ = new SimulationCanvasWidget (layout_, shell_);
193198 canvas_->setFrame (runner_.frame ());
194199 shell_->setCanvas (canvas_);
195200 shell_->setReviewPanel (createRunPanel ());
196201 shell_->setReviewPanelVisible (true );
197202 rootLayout->addWidget (shell_);
198- addBackToAuthoringButton ();
199203
200204 timer_ = new QTimer (this );
201205 timer_->setInterval (33 );
@@ -282,36 +286,6 @@ QWidget* ScenarioRunWidget::createRunPanel() {
282286 return panel;
283287}
284288
285- void ScenarioRunWidget::addBackToAuthoringButton () {
286- if (canvas_ == nullptr ) {
287- return ;
288- }
289-
290- auto * button = new QPushButton (" <" , canvas_);
291- button->setToolTip (" Back to scenario editor" );
292- button->setAccessibleName (" Back to scenario editor" );
293- button->setFixedSize (40 , 36 );
294- button->move (16 , 16 );
295- button->raise ();
296- button->setStyleSheet (
297- " QPushButton {"
298- " background: rgba(255, 255, 255, 232);"
299- " border: 1px solid #c9d5e2;"
300- " border-radius: 10px;"
301- " color: #16202b;"
302- " font-size: 18px;"
303- " font-weight: 700;"
304- " padding-bottom: 2px;"
305- " }"
306- " QPushButton:hover {"
307- " background: #eef3f8;"
308- " border-color: #b8c6d6;"
309- " }" );
310- connect (button, &QPushButton::clicked, this , [this ]() {
311- returnToAuthoring ();
312- });
313- }
314-
315289void ScenarioRunWidget::returnToAuthoring () {
316290 if (timer_ != nullptr ) {
317291 timer_->stop ();
@@ -334,6 +308,7 @@ void ScenarioRunWidget::returnToAuthoring() {
334308 std::move (initial),
335309 saveProjectHandler_,
336310 openProjectHandler_,
311+ backToLayoutReviewHandler_,
337312 this );
338313
339314 rootLayout->replaceWidget (shell_, authoringWidget);
@@ -451,6 +426,7 @@ void ScenarioRunWidget::showResults() {
451426 openProjectHandler_ ();
452427 }
453428 },
429+ backToLayoutReviewHandler_,
454430 this );
455431 rootLayout->replaceWidget (shell_, resultWidget);
456432 shell_->hide ();
0 commit comments