hiro/qt: HexEdit: Match scroll logic with ares

I didn't realize that some of the Qt deprecations were already fixed in
ares. In this case, the change was handled a bit differently, always
considering the y component of scrolling even when the scroll operation
is mostly horizontal. This should work just fine, so we may as well just
adopt that behavior, especially since bsnes doesn't even currently use a
HexEdit.

Backported from ares from:
ffe97222a1

Co-authored-by: Stefan Schlosser <bsdcode@disroot.org>
This commit is contained in:
John Chadwick 2025-09-01 20:05:40 -04:00 committed by Screwtapello
parent 27fdd39e5c
commit 9716212d70
1 changed files with 6 additions and 6 deletions

View File

@ -271,9 +271,9 @@ auto QtHexEdit::keyPressEventAcknowledge(QKeyEvent* event) -> void {
}
auto QtHexEdit::wheelEvent(QWheelEvent* event) -> void {
auto angleDelta = event->angleDelta();
if(qAbs(angleDelta.x()) <= qAbs(angleDelta.y())) {
signed offset = angleDelta.y() < 0 ? +1 : -1;
auto delta = event->angleDelta().y();
if(delta) {
signed offset = delta < 0 ? +1 : -1;
p._scrollTo(p.qtScrollBar->sliderPosition() + offset);
event->accept();
}
@ -282,9 +282,9 @@ auto QtHexEdit::wheelEvent(QWheelEvent* event) -> void {
auto QtHexEditScrollBar::event(QEvent* event) -> bool {
if(event->type() == QEvent::Wheel) {
auto wheelEvent = (QWheelEvent*)event;
auto angleDelta = wheelEvent->angleDelta();
if(qAbs(angleDelta.x()) <= qAbs(angleDelta.y())) {
signed offset = angleDelta.y() < 0 ? +1 : -1;
auto delta = wheelEvent->angleDelta().y();
if(delta) {
signed offset = delta < 0 ? +1 : -1;
p._scrollTo(sliderPosition() + offset);
return true;
}