From 333fe69dd8414fe834d5df76172fa8a3999ba9ee Mon Sep 17 00:00:00 2001 From: garakmon Date: Sun, 26 Apr 2020 18:55:18 -0400 Subject: [PATCH] keep selected tool when switching tabs --- include/editor.h | 1 - src/editor.cpp | 2 ++ src/mainwindow.cpp | 6 +++--- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/include/editor.h b/include/editor.h index 8a02898d..1f9d9232 100644 --- a/include/editor.h +++ b/include/editor.h @@ -128,7 +128,6 @@ public: QList *selected_events = nullptr; QString map_edit_mode; - QString prev_edit_mode; int scale_exp = 0; double scale_base = sqrt(2); // adjust scale factor with this diff --git a/src/editor.cpp b/src/editor.cpp index 4d994c9e..1124c699 100644 --- a/src/editor.cpp +++ b/src/editor.cpp @@ -133,6 +133,8 @@ void Editor::setEditingObjects() { } if (map_item) { map_item->paintingMode = MapPixmapItem::PaintMode::EventObjects; + displayMapConnections(); + map_item->draw(); map_item->setVisible(true); setConnectionsVisibility(ui->checkBox_ToggleBorder->isChecked()); } diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 69594192..2a8cbd77 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -1216,12 +1216,12 @@ void MainWindow::on_mainTabBar_tabBarClicked(int index) if (index == 0) { ui->stackedWidget_MapEvents->setCurrentIndex(0); on_tabWidget_2_currentChanged(ui->tabWidget_2->currentIndex()); - clickToolButtonFromEditMode(editor->prev_edit_mode); } else if (index == 1) { ui->stackedWidget_MapEvents->setCurrentIndex(1); - editor->prev_edit_mode = editor->map_edit_mode; editor->setEditingObjects(); - clickToolButtonFromEditMode("select"); + QStringList validOptions = {"select", "move", "paint", "shift"}; + QString newEditMode = validOptions.contains(editor->map_edit_mode) ? editor->map_edit_mode : "select"; + clickToolButtonFromEditMode(newEditMode); } else if (index == 3) { editor->setEditingConnections(); }