Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions src/AutoHideSideBar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include <QStyleOption>
#include <QPainter>
#include <QXmlStreamWriter>
#include <QWheelEvent>

#include "DockContainerWidget.h"
#include "DockWidgetTab.h"
Expand Down Expand Up @@ -300,6 +301,13 @@ bool CAutoHideSideBar::eventFilter(QObject *watched, QEvent *event)
}
break;

#if QT_CONFIG(wheelevent)
case QEvent::Wheel:
// the button received the event so pass to the scroll area
wheelEvent(static_cast<QWheelEvent*>(event));
break;
#endif

default:
break;
}
Expand Down Expand Up @@ -433,6 +441,41 @@ QSize CAutoHideSideBar::sizeHint() const
}


//===========================================================================
#if QT_CONFIG(wheelevent)
void CAutoHideSideBar::wheelEvent(QWheelEvent* e)
{
QPoint AngleDelta = e->angleDelta();

// completely ignore the effects if the alt key is being held
// if alt is held on a vertical scroll area, cancel the applied horizontal scroll by forcing a vertical scroll
// if alt is held on a horizontal scroll area, cancel the applied vertical scroll by forcing a horizontal scroll
Comment on lines +450 to +452
if (!d->isHorizontal() && (e->modifiers() & Qt::KeyboardModifier::AltModifier) ||
d->isHorizontal() && (~e->modifiers() & Qt::KeyboardModifier::AltModifier))
{
AngleDelta = e->angleDelta().transposed();
}
Comment on lines +448 to +457

QWheelEvent WheelEvent {
e->position(),
e->globalPosition(),
e->pixelDelta(),
AngleDelta,
e->buttons(),
e->modifiers(),
e->phase(),
e->inverted(),
e->source()
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
,e->pointingDevice()
#endif
};

Super::wheelEvent(&WheelEvent);
}
#endif


//===========================================================================
int CAutoHideSideBar::spacing() const
{
Expand Down
10 changes: 10 additions & 0 deletions src/AutoHideSideBar.h
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,16 @@ class ADS_EXPORT CAutoHideSideBar : public QScrollArea
*/
virtual QSize sizeHint() const override;

#if QT_CONFIG(wheelevent)
/**
* This function handles scroll wheel events and will ignore the
* alt key modifier if applied by the user to make sure vertical
* auto-hide side bars will always scroll vertically and that
* horizontal ones will always scroll horizontally.
*/
virtual void wheelEvent(QWheelEvent* e) override;
#endif

/**
* Getter for spacing property - returns the spacing of the tabs
*/
Expand Down