summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArno <arno@disconnect.de>2018-07-30 20:53:40 +0200
committerArno <arno@disconnect.de>2018-07-30 21:06:45 +0200
commit2d812d3ef8caae2470862f3ff6fd01723d46d388 (patch)
tree54f0f3ba917481fd92f7470def6db77d297c2c49
parent598cb833aec9a404271a99eac6f7d360e62ce5c4 (diff)
downloadShemovCleaner-2d812d3ef8caae2470862f3ff6fd01723d46d388.tar.gz
ShemovCleaner-2d812d3ef8caae2470862f3ff6fd01723d46d388.tar.bz2
ShemovCleaner-2d812d3ef8caae2470862f3ff6fd01723d46d388.zip
Cancel copying when clicking on status bar item
-rw-r--r--shemovcleaner.cpp18
-rw-r--r--shemovcleaner.h1
2 files changed, 19 insertions, 0 deletions
diff --git a/shemovcleaner.cpp b/shemovcleaner.cpp
index fa21934..1a46c96 100644
--- a/shemovcleaner.cpp
+++ b/shemovcleaner.cpp
@@ -16,6 +16,7 @@
#include <QStorageInfo>
#include <QPainter>
#include <QSplashScreen>
+#include <QEvent>
#include "shemovcleaner.h"
#include "torrentwidget.h"
@@ -68,6 +69,8 @@ ShemovCleaner::ShemovCleaner(QWidget *parent, Qt::WindowFlags f) : QMainWindow(p
connect(this, &ShemovCleaner::configurationChanged, mFileTab, &FileWidget::readSettings);
connect(mFileTab->fileCopier(), &FileCopier::copying, this, &ShemovCleaner::updateCopying);
connect(mFileTab->fileCopier(), &FileCopier::finished, [=] { updateCopying(false, QString());} );
+ mCopying->installEventFilter(this);
+ updateCopying(false, QString());
QMenu *helpMenu = new QMenu(tr("&Help"));
QAction *aboutThisA = new QAction(tr("About ShemovCleaner..."), this);
@@ -185,6 +188,21 @@ void ShemovCleaner::closeEvent(QCloseEvent *e){
}
}
+bool ShemovCleaner::eventFilter(QObject *watched, QEvent *event){
+ if(watched == mCopying){
+ if(event->type() == QEvent::MouseButtonPress){
+ if(mFileTab->fileCopier()->isRunning()){
+ int retval = QMessageBox::question(this, tr("Cancel copy?"), tr("Cancel copying?"));
+ if(retval == QMessageBox::Yes){
+ mFileTab->fileCopier()->cancel();
+ return true;
+ }
+ }
+ }
+ }
+ return QMainWindow::eventFilter(watched, event);
+}
+
void ShemovCleaner::createStatusBar(){
QLabel *l1 = new QLabel(tr("Sel."));
mSelected = new QLabel("000/000");
diff --git a/shemovcleaner.h b/shemovcleaner.h
index 47a763a..90ba2cd 100644
--- a/shemovcleaner.h
+++ b/shemovcleaner.h
@@ -28,6 +28,7 @@ class ShemovCleaner : public QMainWindow {
protected:
virtual void closeEvent(QCloseEvent *e);
+ bool eventFilter(QObject *watched, QEvent *event);
signals:
void configurationChanged();