]> git.lyx.org Git - features.git/commitdiff
Properly reset on ESC key on LayoutBox/CategorizedCombo
authorDaniel Ramoeller <d.lyx@web.de>
Sun, 27 Feb 2022 19:33:48 +0000 (20:33 +0100)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Sun, 4 Dec 2022 12:45:49 +0000 (13:45 +0100)
Fix for bug #12497.

src/frontends/qt/CategorizedCombo.cpp
src/frontends/qt/CategorizedCombo.h
src/frontends/qt/LayoutBox.cpp
src/frontends/qt/LayoutBox.h

index 1548ecf7e8d1182744a991af75d620909a51d06b..c4005ac110da9d7c59793c806b65fec32aacb4fd 100644 (file)
@@ -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;
index be351ff9930d5caf28124be009dfb84b99bfb398..9e03449ec78ba650a82e19abbdd70faa668b620b 100644 (file)
@@ -74,6 +74,8 @@ private:
        struct Private;
        ///
        Private * const d;
+       ///
+       int lastCurrentIndex_;
 };
 
 
index 49d308641599a6b29087df2a1ffc65d7ed6df736..5b15e98741e8d4cc301714ae08f9aebfd63d06b4 100644 (file)
@@ -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;
index a3d174e01a4f60875d552a3f0b06d6a003404b44..bbccb74ae8bfb1b6c2840a043ce879ef6ec962fe 100644 (file)
@@ -60,6 +60,7 @@ private:
        friend class LayoutItemDelegate;
        class Private;
        Private * const d;
+       int lastCurrentIndex_;
 };
 
 } // namespace frontend