]> git.sesse.net Git - pkanalytics/commitdiff
Make it possible to seek using the 4th and 5th mouse buttons.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Thu, 20 Jul 2023 12:28:47 +0000 (14:28 +0200)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Thu, 20 Jul 2023 12:28:47 +0000 (14:28 +0200)
This makes it a bit more comfortable to seek around when using a mouse,
without having to move the left hand over to the right side of the
keyboard.

main.cpp
video_widget.cpp
video_widget.h

index 65a64e1e9e0196ae683ba41383779ec3d4ea0eee..4caeac38c4d839450dd1db7dd16f28677637943d 100644 (file)
--- a/main.cpp
+++ b/main.cpp
@@ -86,7 +86,6 @@ MainWindow::MainWindow(EventsModel *events, PlayersModel *players,
                position_changed(pos);
        });
 
-
        // It's not really clear whether PgUp should be forwards or backwards,
        // but mpv does at least up = forwards, so that's probably standard.
        QShortcut *pgdown = new QShortcut(QKeySequence(Qt::Key_PageDown), this);
@@ -99,6 +98,8 @@ MainWindow::MainWindow(EventsModel *events, PlayersModel *players,
 
        connect(ui->minus2s, &QPushButton::clicked, [this]() { ui->video->seek(-2000); });
        connect(ui->plus2s, &QPushButton::clicked, [this]() { ui->video->seek(2000); });
+       connect(ui->video, &VideoWidget::mouse_back_clicked, [this]() { ui->video->seek(-2000); });
+       connect(ui->video, &VideoWidget::mouse_forward_clicked, [this]() { ui->video->seek(2000); });
 
        connect(ui->minus1f, &QPushButton::clicked, [this]() { ui->video->seek_frames(-1); });
        connect(ui->plus1f, &QPushButton::clicked, [this]() { ui->video->seek_frames(1); });
index 0a7ff43eb7b2f4f77637e2553b9717e73e3653da..a5b45136537552282d1ec8c118f5cd998de51adb 100644 (file)
@@ -497,7 +497,11 @@ void VideoWidget::wheelEvent(QWheelEvent *event)
 
 void VideoWidget::mousePressEvent(QMouseEvent *e)
 {
-       if (e->button() == Qt::LeftButton) {
+       if (e->button() == Qt::BackButton) {
+               emit mouse_back_clicked();
+       } else if (e->button() == Qt::ForwardButton) {
+               emit mouse_forward_clicked();
+       } else if (e->button() == Qt::LeftButton) {
                dragging = true;
                last_drag_x = e->position().x();
                last_drag_y = e->position().y();
index 56cf92862605d41b82e56caf90f9d834c4ec64e7..1f1ffe2ffb6b8f752fff942a031108dce94f6477 100644 (file)
@@ -39,13 +39,15 @@ public:
        void paintGL() override;
        void wheelEvent(QWheelEvent *event) override;
 
-       // For dragging.
+       // For dragging, and for back/forward button presses.
        void mousePressEvent(QMouseEvent *e);
        void mouseReleaseEvent(QMouseEvent *e);
        void mouseMoveEvent(QMouseEvent *e);
 
 signals:
        void position_changed(uint64_t pos);
+       void mouse_back_clicked();
+       void mouse_forward_clicked();
 
 private:
        // Should really have been persistent and a PBO, but this is OK for now.