Browse Source

Merge pull request #16647 from NotTsunami/hscroll

Add horizontal scrolling for tracker list and torrent content
adaptive-webui-19844
Chocobo1 3 years ago committed by GitHub
parent
commit
5341478036
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      src/gui/properties/peerlistwidget.cpp
  2. 17
      src/gui/properties/trackerlistwidget.cpp
  3. 1
      src/gui/properties/trackerlistwidget.h
  4. 17
      src/gui/torrentcontenttreeview.cpp
  5. 1
      src/gui/torrentcontenttreeview.h
  6. 4
      src/gui/transferlistwidget.cpp

4
src/gui/properties/peerlistwidget.cpp

@ -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;
} }

17
src/gui/properties/trackerlistwidget.cpp

@ -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
}

1
src/gui/properties/trackerlistwidget.h

@ -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();

17
src/gui/torrentcontenttreeview.cpp

@ -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
}

1
src/gui/torrentcontenttreeview.h

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

4
src/gui/transferlistwidget.cpp

@ -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;
} }

Loading…
Cancel
Save