From b5d67f90e4b01483709618b6d88b82aa9e056a12 Mon Sep 17 00:00:00 2001 From: NotTsunami <4589807+NotTsunami@users.noreply.github.com> Date: Tue, 15 Mar 2022 15:05:47 -0400 Subject: [PATCH 1/2] Add horizontal scrolling for tracker list and torrent content --- src/gui/properties/trackerlistwidget.cpp | 17 +++++++++++++++++ src/gui/properties/trackerlistwidget.h | 1 + src/gui/torrentcontenttreeview.cpp | 17 +++++++++++++++++ src/gui/torrentcontenttreeview.h | 1 + 4 files changed, 36 insertions(+) diff --git a/src/gui/properties/trackerlistwidget.cpp b/src/gui/properties/trackerlistwidget.cpp index a56b456b0..0c9b1c226 100644 --- a/src/gui/properties/trackerlistwidget.cpp +++ b/src/gui/properties/trackerlistwidget.cpp @@ -41,6 +41,7 @@ #include #include #include +#include #include "base/bittorrent/peerinfo.h" #include "base/bittorrent/session.h" @@ -683,3 +684,19 @@ void TrackerListWidget::displayColumnHeaderMenu() menu->popup(QCursor::pos()); } + +void TrackerListWidget::wheelEvent(QWheelEvent *event) +{ + if (event->modifiers() & Qt::ShiftModifier) + { + // Shift + scroll = horizontal scroll + event->accept(); + QWheelEvent scrollHEvent {event->position(), event->globalPosition() + , event->pixelDelta(), event->angleDelta().transposed(), event->buttons() + , event->modifiers(), event->phase(), event->inverted(), event->source()}; + QTreeView::wheelEvent(&scrollHEvent); + return; + } + + QTreeView::wheelEvent(event); // event delegated to base class +} diff --git a/src/gui/properties/trackerlistwidget.h b/src/gui/properties/trackerlistwidget.h index 618607214..99f56d6e8 100644 --- a/src/gui/properties/trackerlistwidget.h +++ b/src/gui/properties/trackerlistwidget.h @@ -87,6 +87,7 @@ private slots: private: int visibleColumnsCount() const; + void wheelEvent(QWheelEvent *event) override; static QStringList headerLabels(); diff --git a/src/gui/torrentcontenttreeview.cpp b/src/gui/torrentcontenttreeview.cpp index 20437d044..984baca52 100644 --- a/src/gui/torrentcontenttreeview.cpp +++ b/src/gui/torrentcontenttreeview.cpp @@ -35,6 +35,7 @@ #include #include #include +#include #include "base/bittorrent/abstractfilestorage.h" #include "base/bittorrent/common.h" @@ -152,3 +153,19 @@ QModelIndex TorrentContentTreeView::currentNameCell() return model()->index(current.row(), TorrentContentModelItem::COL_NAME, current.parent()); } + +void TorrentContentTreeView::wheelEvent(QWheelEvent *event) +{ + if (event->modifiers() & Qt::ShiftModifier) + { + // Shift + scroll = horizontal scroll + event->accept(); + QWheelEvent scrollHEvent {event->position(), event->globalPosition() + , event->pixelDelta(), event->angleDelta().transposed(), event->buttons() + , event->modifiers(), event->phase(), event->inverted(), event->source()}; + QTreeView::wheelEvent(&scrollHEvent); + return; + } + + QTreeView::wheelEvent(event); // event delegated to base class +} diff --git a/src/gui/torrentcontenttreeview.h b/src/gui/torrentcontenttreeview.h index a6ee2563b..1e8a5cfa7 100644 --- a/src/gui/torrentcontenttreeview.h +++ b/src/gui/torrentcontenttreeview.h @@ -50,4 +50,5 @@ public: private: QModelIndex currentNameCell(); + void wheelEvent(QWheelEvent *event) override; }; From dd5b16831c9308edd6105b1c7eda3c7f6e99e70a Mon Sep 17 00:00:00 2001 From: NotTsunami <4589807+NotTsunami@users.noreply.github.com> Date: Wed, 16 Mar 2022 21:45:24 -0400 Subject: [PATCH 2/2] Unify coding style --- src/gui/properties/peerlistwidget.cpp | 4 ++-- src/gui/transferlistwidget.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/gui/properties/peerlistwidget.cpp b/src/gui/properties/peerlistwidget.cpp index 96d81008d..3ce1392f1 100644 --- a/src/gui/properties/peerlistwidget.cpp +++ b/src/gui/properties/peerlistwidget.cpp @@ -530,9 +530,9 @@ void PeerListWidget::wheelEvent(QWheelEvent *event) { // Shift + scroll = horizontal scroll event->accept(); - QWheelEvent scrollHEvent(event->position(), event->globalPosition() + QWheelEvent scrollHEvent {event->position(), event->globalPosition() , event->pixelDelta(), event->angleDelta().transposed(), event->buttons() - , event->modifiers(), event->phase(), event->inverted(), event->source()); + , event->modifiers(), event->phase(), event->inverted(), event->source()}; QTreeView::wheelEvent(&scrollHEvent); return; } diff --git a/src/gui/transferlistwidget.cpp b/src/gui/transferlistwidget.cpp index 83f3080b8..7d3e2d6f5 100644 --- a/src/gui/transferlistwidget.cpp +++ b/src/gui/transferlistwidget.cpp @@ -1248,9 +1248,9 @@ void TransferListWidget::wheelEvent(QWheelEvent *event) { // Shift + scroll = horizontal scroll event->accept(); - QWheelEvent scrollHEvent(event->position(), event->globalPosition() + QWheelEvent scrollHEvent {event->position(), event->globalPosition() , event->pixelDelta(), event->angleDelta().transposed(), event->buttons() - , event->modifiers(), event->phase(), event->inverted(), event->source()); + , event->modifiers(), event->phase(), event->inverted(), event->source()}; QTreeView::wheelEvent(&scrollHEvent); return; }