┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/animatedheightwidget.cpp
diff options
context:
space:
mode:
authorPan Zhang <[email protected]>2025-09-17 00:39:35 +0800
committerAkseli Lahtinen <[email protected]>2025-09-16 19:39:35 +0300
commit407ce0706a18b9e1245f7c52246a76b0e54939dc (patch)
tree90284f0ad33784cfcb3d2893e3c7e46b2dd08d96 /src/animatedheightwidget.cpp
parent3b802845381d353dcbbeb06a12bd21b4b038874f (diff)
animatedheightwidget: ignore PageUp/PageDown to avoid invisible scroll
When typing in the search bar (or other widgets using AnimatedHeightWidget), pressing PageUp or PageDown would cause the internal QScrollArea (with hidden scrollbars) to react and scroll. This made the entered text appear to disappear even though focus stayed in the input field. PageUp and PageDown are now intercepted in AnimatedHeightWidget to prevent the underlying QScrollArea from handling them, ensuring input remains visible across all users of AnimatedHeightWidget. BUG: 508835
Diffstat (limited to 'src/animatedheightwidget.cpp')
-rw-r--r--src/animatedheightwidget.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/animatedheightwidget.cpp b/src/animatedheightwidget.cpp
index cd62f3971..c89863b25 100644
--- a/src/animatedheightwidget.cpp
+++ b/src/animatedheightwidget.cpp
@@ -7,7 +7,9 @@
#include "animatedheightwidget.h"
+#include <QEvent>
#include <QGridLayout>
+#include <QKeyEvent>
#include <QPropertyAnimation>
#include <QScrollArea>
#include <QScrollBar>
@@ -86,6 +88,7 @@ QWidget *AnimatedHeightWidget::prepareContentsContainer(QWidget *contentsContain
contentsContainer->setParent(m_contentsContainerParent);
m_contentsContainerParent->setWidget(contentsContainer);
m_contentsContainerParent->setFocusProxy(contentsContainer);
+ contentsContainer->installEventFilter(this);
return contentsContainer;
}
@@ -93,3 +96,16 @@ bool AnimatedHeightWidget::isAnimationRunning() const
{
return m_heightAnimation && m_heightAnimation->state() == QAbstractAnimation::Running;
}
+
+bool AnimatedHeightWidget::eventFilter(QObject *obj, QEvent *event)
+{
+ if (event->type() == QEvent::KeyPress) {
+ auto *keyEvent = static_cast<QKeyEvent *>(event);
+ // Ignore PageUp/PageDown to prevent QScrollArea (invisible scrollbar) from scrolling
+ if (keyEvent->key() == Qt::Key_PageUp || keyEvent->key() == Qt::Key_PageDown) {
+ keyEvent->accept();
+ return true;
+ }
+ }
+ return QWidget::eventFilter(obj, event);
+} \ No newline at end of file