Fix scrolling in SubTabs.

This commit is contained in:
John Preston
2025-08-01 16:42:27 +04:00
parent 62c9666013
commit 22fb456d13
2 changed files with 22 additions and 1 deletions
+21 -1
View File
@@ -192,8 +192,28 @@ void SubTabs::mouseMoveEvent(QMouseEvent *e) {
void SubTabs::wheelEvent(QWheelEvent *e) {
const auto delta = ScrollDeltaF(e);
if (std::abs(delta.x()) > std::abs(delta.y())) {
const auto phase = e->phase();
const auto horizontal = (std::abs(delta.x()) > std::abs(delta.y()));
if (phase == Qt::NoScrollPhase) {
_locked = std::nullopt;
} else if (phase == Qt::ScrollBegin) {
_locked = std::nullopt;
} else if (!_locked) {
_locked = horizontal ? Qt::Horizontal : Qt::Vertical;
}
if (horizontal) {
if (_locked == Qt::Vertical) {
return;
}
e->accept();
} else {
if (_locked == Qt::Horizontal) {
e->accept();
} else {
e->ignore();
}
return;
}
_scrollAnimation.stop();
_scroll = std::clamp(_scroll - delta.x(), 0., _scrollMax * 1.);
@@ -69,6 +69,7 @@ private:
std::vector<Button> _buttons;
rpl::event_stream<QString> _activated;
rpl::event_stream<QString> _contextMenuRequests;
std::optional<Qt::Orientation> _locked;
int _dragx = 0;
int _pressx = 0;
float64 _dragscroll = 0.;