1
0
mirror of https://github.com/d47081/qBittorrent.git synced 2025-01-11 07:18:08 +00:00

Merge pull request #16647 from NotTsunami/hscroll

Add horizontal scrolling for tracker list and torrent content
This commit is contained in:
Chocobo1 2022-03-18 12:43:32 +08:00 committed by GitHub
commit 5341478036
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 40 additions and 4 deletions

View File

@ -530,9 +530,9 @@ void PeerListWidget::wheelEvent(QWheelEvent *event)
{ {
// Shift + scroll = horizontal scroll // Shift + scroll = horizontal scroll
event->accept(); event->accept();
QWheelEvent scrollHEvent(event->position(), event->globalPosition() QWheelEvent scrollHEvent {event->position(), event->globalPosition()
, event->pixelDelta(), event->angleDelta().transposed(), event->buttons() , 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); QTreeView::wheelEvent(&scrollHEvent);
return; return;
} }

View File

@ -41,6 +41,7 @@
#include <QTreeWidgetItem> #include <QTreeWidgetItem>
#include <QUrl> #include <QUrl>
#include <QVector> #include <QVector>
#include <QWheelEvent>
#include "base/bittorrent/peerinfo.h" #include "base/bittorrent/peerinfo.h"
#include "base/bittorrent/session.h" #include "base/bittorrent/session.h"
@ -683,3 +684,19 @@ void TrackerListWidget::displayColumnHeaderMenu()
menu->popup(QCursor::pos()); 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
}

View File

@ -87,6 +87,7 @@ private slots:
private: private:
int visibleColumnsCount() const; int visibleColumnsCount() const;
void wheelEvent(QWheelEvent *event) override;
static QStringList headerLabels(); static QStringList headerLabels();

View File

@ -35,6 +35,7 @@
#include <QMessageBox> #include <QMessageBox>
#include <QModelIndexList> #include <QModelIndexList>
#include <QThread> #include <QThread>
#include <QWheelEvent>
#include "base/bittorrent/abstractfilestorage.h" #include "base/bittorrent/abstractfilestorage.h"
#include "base/bittorrent/common.h" #include "base/bittorrent/common.h"
@ -152,3 +153,19 @@ QModelIndex TorrentContentTreeView::currentNameCell()
return model()->index(current.row(), TorrentContentModelItem::COL_NAME, current.parent()); 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
}

View File

@ -50,4 +50,5 @@ public:
private: private:
QModelIndex currentNameCell(); QModelIndex currentNameCell();
void wheelEvent(QWheelEvent *event) override;
}; };

View File

@ -1248,9 +1248,9 @@ void TransferListWidget::wheelEvent(QWheelEvent *event)
{ {
// Shift + scroll = horizontal scroll // Shift + scroll = horizontal scroll
event->accept(); event->accept();
QWheelEvent scrollHEvent(event->position(), event->globalPosition() QWheelEvent scrollHEvent {event->position(), event->globalPosition()
, event->pixelDelta(), event->angleDelta().transposed(), event->buttons() , 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); QTreeView::wheelEvent(&scrollHEvent);
return; return;
} }