From 7bdf372ecc3129eeb6299ae13331a354467a7000 Mon Sep 17 00:00:00 2001 From: Daniel Ramoeller Date: Sun, 27 Feb 2022 20:33:48 +0100 Subject: [PATCH] Properly reset on ESC key on LayoutBox/CategorizedCombo Fix for bug #12497. --- src/frontends/qt/CategorizedCombo.cpp | 2 ++ src/frontends/qt/CategorizedCombo.h | 2 ++ src/frontends/qt/LayoutBox.cpp | 2 ++ src/frontends/qt/LayoutBox.h | 1 + 4 files changed, 7 insertions(+) diff --git a/src/frontends/qt/CategorizedCombo.cpp b/src/frontends/qt/CategorizedCombo.cpp index 1548ecf7e8..c4005ac110 100644 --- a/src/frontends/qt/CategorizedCombo.cpp +++ b/src/frontends/qt/CategorizedCombo.cpp @@ -370,6 +370,7 @@ void CategorizedCombo::Private::countCategories() void CategorizedCombo::showPopup() { + lastCurrentIndex_ = currentIndex(); bool enabled = view()->updatesEnabled(); view()->setUpdatesEnabled(false); @@ -400,6 +401,7 @@ bool CategorizedCombo::eventFilter(QObject * o, QEvent * e) case Qt::Key_Escape: if (!modified && !d->filter_.isEmpty()) { d->resetFilter(); + setCurrentIndex(lastCurrentIndex_); return true; } break; diff --git a/src/frontends/qt/CategorizedCombo.h b/src/frontends/qt/CategorizedCombo.h index be351ff993..9e03449ec7 100644 --- a/src/frontends/qt/CategorizedCombo.h +++ b/src/frontends/qt/CategorizedCombo.h @@ -74,6 +74,8 @@ private: struct Private; /// Private * const d; + /// + int lastCurrentIndex_; }; diff --git a/src/frontends/qt/LayoutBox.cpp b/src/frontends/qt/LayoutBox.cpp index 49d3086415..5b15e98741 100644 --- a/src/frontends/qt/LayoutBox.cpp +++ b/src/frontends/qt/LayoutBox.cpp @@ -401,6 +401,7 @@ void LayoutBox::Private::countCategories() void LayoutBox::showPopup() { + lastCurrentIndex_ = currentIndex(); d->owner_.message(_("Enter characters to filter the layout list.")); bool enabled = view()->updatesEnabled(); @@ -425,6 +426,7 @@ bool LayoutBox::eventFilter(QObject * o, QEvent * e) case Qt::Key_Escape: if (!modified && !d->filter_.isEmpty()) { d->resetFilter(); + setCurrentIndex(lastCurrentIndex_); return true; } break; diff --git a/src/frontends/qt/LayoutBox.h b/src/frontends/qt/LayoutBox.h index a3d174e01a..bbccb74ae8 100644 --- a/src/frontends/qt/LayoutBox.h +++ b/src/frontends/qt/LayoutBox.h @@ -60,6 +60,7 @@ private: friend class LayoutItemDelegate; class Private; Private * const d; + int lastCurrentIndex_; }; } // namespace frontend -- 2.39.5