From 0e17990583cd99de675a83410c93428e22889d04 Mon Sep 17 00:00:00 2001 From: Martin Kleusberg Date: Sun, 20 Dec 2015 12:15:13 +0100 Subject: [PATCH] EditDialog: Better behaviour when pressing escape key in dock mode See issue #441. --- src/EditDialog.cpp | 12 ++++++++++++ src/EditDialog.h | 1 + src/MainWindow.cpp | 1 + 3 files changed, 14 insertions(+) diff --git a/src/EditDialog.cpp b/src/EditDialog.cpp index 603b26a7..23c0b4fe 100644 --- a/src/EditDialog.cpp +++ b/src/EditDialog.cpp @@ -63,6 +63,18 @@ void EditDialog::showEvent(QShowEvent*) } } +void EditDialog::reject() +{ + // This is called when pressing the cancel button or hitting the escape key + + // If we're in dock mode, move the cursor back to the table view. + // If we're in window mode, call the default implementation to just close the window normally. + if(useInDock) + emit goingAway(); + else + QDialog::reject(); +} + void EditDialog::loadText(const QByteArray& data, int row, int col) { curRow = row; diff --git a/src/EditDialog.h b/src/EditDialog.h index 1928a862..f55ca316 100644 --- a/src/EditDialog.h +++ b/src/EditDialog.h @@ -24,6 +24,7 @@ public slots: virtual void reset(); virtual void loadText(const QByteArray& data, int row, int col); virtual void setFocus(); + virtual void reject(); protected: virtual void closeEvent(QCloseEvent* ev); diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index 42ef4b57..557dcd8d 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -751,6 +751,7 @@ void MainWindow::editWinAway() // Update main window activateWindow(); + ui->dataTable->setFocus(); ui->dataTable->setCurrentIndex(ui->dataTable->currentIndex().sibling(sendingEditDialog->getCurrentRow(), sendingEditDialog->getCurrentCol())); }