┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/animatedheightwidget.cpp
diff options
context:
space:
mode:
authorPan Zhang <[email protected]>2026-03-13 16:32:51 +0800
committerMéven Car <[email protected]>2026-03-14 13:37:25 +0000
commitcde91dd71a89d1f82bc87dabe95643cc93853e50 (patch)
tree2f8bb4d30510174016cd0f169ab9b4dc393890b6 /src/animatedheightwidget.cpp
parente59b657debc8aafd4ef119fd712fcd91b705bcbd (diff)
animatedheightwidget: prevent viewport scrolling
The search field moves upwards and becomes obscured when pressing navigation keys like the down arrow. This happens because the underlying QScrollArea processes keyboard navigation events, shifting the visible viewport even when scrollbars are completely hidden and disabled. Move the event filter from the contents container directly to the QScrollArea (m_contentsContainerParent) and its viewport. Update the filter to intercept Qt::Key_Up and Qt::Key_Down events, preventing the scroll area from handling these inputs. BUG: 510469
Diffstat (limited to 'src/animatedheightwidget.cpp')
-rw-r--r--src/animatedheightwidget.cpp20
1 files changed, 16 insertions, 4 deletions
diff --git a/src/animatedheightwidget.cpp b/src/animatedheightwidget.cpp
index c89863b25..ed7e6bdc6 100644
--- a/src/animatedheightwidget.cpp
+++ b/src/animatedheightwidget.cpp
@@ -33,6 +33,11 @@ AnimatedHeightWidget::AnimatedHeightWidget(QWidget *parent)
m_contentsContainerParent->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
m_contentsContainerParent->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
m_contentsContainerParent->setWidgetResizable(true);
+ // Prevent the internal scroll area from reacting to navigation keys and
+ // scrolling the contents (scrollbars are hidden but scrolling still changes
+ // the visible region).
+ m_contentsContainerParent->installEventFilter(this);
+ m_contentsContainerParent->viewport()->installEventFilter(this);
// Disables manual scrolling, for example with mouse scrollwheel.
m_contentsContainerParent->verticalScrollBar()->setEnabled(false);
m_contentsContainerParent->horizontalScrollBar()->setEnabled(false);
@@ -88,7 +93,6 @@ QWidget *AnimatedHeightWidget::prepareContentsContainer(QWidget *contentsContain
contentsContainer->setParent(m_contentsContainerParent);
m_contentsContainerParent->setWidget(contentsContainer);
m_contentsContainerParent->setFocusProxy(contentsContainer);
- contentsContainer->installEventFilter(this);
return contentsContainer;
}
@@ -99,12 +103,20 @@ bool AnimatedHeightWidget::isAnimationRunning() const
bool AnimatedHeightWidget::eventFilter(QObject *obj, QEvent *event)
{
- if (event->type() == QEvent::KeyPress) {
+ if ((obj == m_contentsContainerParent || obj == m_contentsContainerParent->viewport()) && 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) {
+ // Ignore navigation keys to prevent the internal QScrollArea (with
+ // invisible scrollbars) from scrolling and visually moving child bars
+ // such as the search bar.
+ switch (keyEvent->key()) {
+ case Qt::Key_Up:
+ case Qt::Key_Down:
+ case Qt::Key_PageUp:
+ case Qt::Key_PageDown:
keyEvent->accept();
return true;
+ default:
+ break;
}
}
return QWidget::eventFilter(obj, event);