From 5deb64cd28315ea474204b249f5a3036c9b4650a Mon Sep 17 00:00:00 2001 From: Albert S Date: Tue, 30 Apr 2019 12:40:28 +0200 Subject: [PATCH] ClickLabel: rename clicked to leftClicked and only fire when left mouse button clicked --- gui/clicklabel.cpp | 7 ++++++- gui/clicklabel.h | 2 +- gui/mainwindow.cpp | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/gui/clicklabel.cpp b/gui/clicklabel.cpp index 692ffc1..05d607e 100644 --- a/gui/clicklabel.cpp +++ b/gui/clicklabel.cpp @@ -1,6 +1,11 @@ +#include #include "clicklabel.h" void ClickLabel::mousePressEvent(QMouseEvent *event) { - emit clicked(); + if(event->button() == Qt::LeftButton) + { + emit leftClick(); + } + return QLabel::mousePressEvent(event); } diff --git a/gui/clicklabel.h b/gui/clicklabel.h index 28b6c63..f8b782c 100644 --- a/gui/clicklabel.h +++ b/gui/clicklabel.h @@ -8,7 +8,7 @@ class ClickLabel : public QLabel public: using QLabel::QLabel; signals: - void clicked(); + void leftClick(); protected: void mousePressEvent(QMouseEvent *event); diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index fb7d3f5..e48a250 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -120,7 +120,7 @@ void MainWindow::pdfPreviewReceived(PdfPreview preview) label->setPixmap(QPixmap::fromImage(preview.previewImage)); label->setToolTip(preview.documentPath); ui->scrollAreaWidgetContents->layout()->addWidget(label); - connect(label, &ClickLabel::clicked, + connect(label, &ClickLabel::leftClick, [=]() { QSettings settings;