[LyX/master] Properly reset on ESC key on LayoutBox/CategorizedCombo
Jean-Marc Lasgouttes
lasgouttes at lyx.org
Sun Dec 4 12:02:30 UTC 2022
commit 7bdf372ecc3129eeb6299ae13331a354467a7000
Author: Daniel Ramoeller <d.lyx at web.de>
Date: Sun Feb 27 20:33:48 2022 +0100
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(+), 0 deletions(-)
diff --git a/src/frontends/qt/CategorizedCombo.cpp b/src/frontends/qt/CategorizedCombo.cpp
index 1548ecf..c4005ac 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 be351ff..9e03449 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 49d3086..5b15e98 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 a3d174e..bbccb74 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
More information about the lyx-cvs
mailing list