mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-14 22:42:14 -07:00
Forward scroll event to scrollable parents if possible in NoScrollFilter.
This commit is contained in:
parent
a07c1badd8
commit
c44febf2ef
1 changed files with 18 additions and 1 deletions
|
|
@ -7,6 +7,8 @@
|
|||
#include "../visual_deck_storage_widget.h"
|
||||
#include "deck_preview_deck_tags_display_widget.h"
|
||||
|
||||
#include <QAbstractItemView>
|
||||
#include <QApplication>
|
||||
#include <QComboBox>
|
||||
#include <QEvent>
|
||||
#include <QVBoxLayout>
|
||||
|
|
@ -74,7 +76,22 @@ protected:
|
|||
bool eventFilter(QObject *obj, QEvent *event) override
|
||||
{
|
||||
if (event->type() == QEvent::Wheel) {
|
||||
return true; // Blocks the event
|
||||
if (auto *combo = qobject_cast<QComboBox *>(obj)) {
|
||||
// If popup is not open, forward event to parent scroll area
|
||||
if (!combo->view()->isVisible()) {
|
||||
// Try to find a scrollable parent and manually send the event
|
||||
QWidget *parent = combo->parentWidget();
|
||||
while (parent) {
|
||||
if (auto *scroll = qobject_cast<QAbstractScrollArea *>(parent)) {
|
||||
QApplication::sendEvent(scroll->viewport(), event);
|
||||
return true; // Mark event as handled
|
||||
}
|
||||
parent = parent->parentWidget();
|
||||
}
|
||||
// If no scrollable parent found, just block
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return QObject::eventFilter(obj, event);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue