From 9e883a8a2f3368defcd1d28c9086c799bd502408 Mon Sep 17 00:00:00 2001 From: garakmon Date: Tue, 21 Apr 2020 15:12:20 -0400 Subject: [PATCH] remember edit mode in map tab --- include/mainwindow.h | 1 + src/editor.cpp | 4 ++++ src/mainwindow.cpp | 19 +++++++++++++++++++ 3 files changed, 24 insertions(+) diff --git a/include/mainwindow.h b/include/mainwindow.h index db42d478..1e5a65be 100644 --- a/include/mainwindow.h +++ b/include/mainwindow.h @@ -211,6 +211,7 @@ private: void displayMapProperties(); void checkToolButtons(); + void clickToolButtonFromEditMode(QString editMode); void initWindow(); void initCustomUI(); diff --git a/src/editor.cpp b/src/editor.cpp index 6b7b22e6..4d994c9e 100644 --- a/src/editor.cpp +++ b/src/editor.cpp @@ -1868,6 +1868,10 @@ void Editor::deleteEvent(Event *event) { // variable "selectingEvent" so that we can detect whether or not the user // is clicking on the background instead of an event. void Editor::objectsView_onMousePress(QMouseEvent *event) { + // make sure we are in object editing mode + if (map_item && map_item->paintingMode != MapPixmapItem::PaintMode::EventObjects) { + return; + } if (this->map_edit_mode == "paint" && event->buttons() & Qt::RightButton) { this->map_edit_mode = "select"; this->settings->mapCursor = QCursor(); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 8f8978d8..2e90506a 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -1214,9 +1214,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"); } else if (index == 3) { editor->setEditingConnections(); } @@ -2115,6 +2118,22 @@ void MainWindow::checkToolButtons() { ui->toolButton_Shift->setChecked(editor->map_edit_mode == "shift"); } +void MainWindow::clickToolButtonFromEditMode(QString editMode) { + if (editMode == "paint") { + on_toolButton_Paint_clicked(); + } else if (editMode == "select") { + on_toolButton_Select_clicked(); + } else if (editMode == "fill") { + on_toolButton_Fill_clicked(); + } else if (editMode == "pick") { + on_toolButton_Dropper_clicked(); + } else if (editMode == "move") { + on_toolButton_Move_clicked(); + } else if (editMode == "shift") { + on_toolButton_Shift_clicked(); + } +} + void MainWindow::onLoadMapRequested(QString mapName, QString fromMapName) { if (!setMap(mapName, true)) { QMessageBox msgBox(this);