From: Richard Kimberly Heck Date: Tue, 28 May 2019 03:20:45 +0000 (-0400) Subject: Allow click on the 'spinner' to cancel export. X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=e78e4f1de19f425e4fc7832af625db1881f75d28;p=features.git Allow click on the 'spinner' to cancel export. --- diff --git a/src/frontends/qt4/GuiClickableLabel.cpp b/src/frontends/qt4/GuiClickableLabel.cpp new file mode 100644 index 0000000000..31a5be5105 --- /dev/null +++ b/src/frontends/qt4/GuiClickableLabel.cpp @@ -0,0 +1,31 @@ +// -*- C++ -*- +/** + * \file GuiClickableLabel.h + * This file is part of LyX, the document processor. + * Licence details can be found in the file COPYING. + * + * Full author contact details are available in file CREDITS. + */ + +#include "config.h" + +#include "GuiClickableLabel.h" + +namespace lyx { +namespace frontend { + +GuiClickableLabel::GuiClickableLabel(QWidget * parent) + : QLabel(parent) +{} + +GuiClickableLabel::~GuiClickableLabel() +{} + +void GuiClickableLabel::mouseReleaseEvent(QMouseEvent *) { + Q_EMIT clicked(); + } + +} +} + +#include "moc_GuiClickableLabel.cpp" diff --git a/src/frontends/qt4/GuiClickableLabel.h b/src/frontends/qt4/GuiClickableLabel.h new file mode 100644 index 0000000000..4ae49055ee --- /dev/null +++ b/src/frontends/qt4/GuiClickableLabel.h @@ -0,0 +1,35 @@ +// -*- C++ -*- +/** + * \file GuiClickableLabel.h + * This file is part of LyX, the document processor. + * Licence details can be found in the file COPYING. + * + * Full author contact details are available in file CREDITS. + */ + +#ifndef GUICLICKABLELABEL_H +#define GUICLICKABLELABEL_H + +#include + +namespace lyx { +namespace frontend { + +// see https://wiki.qt.io/Clickable_QLabel +class GuiClickableLabel : public QLabel { + Q_OBJECT +public: + explicit GuiClickableLabel(QWidget * parent); + + ~GuiClickableLabel(); + +Q_SIGNALS: + void clicked(); + +protected: + void mouseReleaseEvent(QMouseEvent *); +}; + +} +} +#endif diff --git a/src/frontends/qt4/GuiView.cpp b/src/frontends/qt4/GuiView.cpp index 98dba1dfa5..8ef8ca5cc9 100644 --- a/src/frontends/qt4/GuiView.cpp +++ b/src/frontends/qt4/GuiView.cpp @@ -19,6 +19,7 @@ #include "FileDialog.h" #include "FontLoader.h" #include "GuiApplication.h" +#include "GuiClickableLabel.h" #include "GuiCommandBuffer.h" #include "GuiCompleter.h" #include "GuiKeySymbol.h" @@ -610,7 +611,7 @@ GuiView::GuiView(int id) setAcceptDrops(true); // add busy indicator to statusbar - QLabel * busylabel = new QLabel(statusBar()); + GuiClickableLabel * busylabel = new GuiClickableLabel(statusBar()); statusBar()->addPermanentWidget(busylabel); search_mode mode = theGuiApp()->imageSearchMode(); QString fn = toqstr(lyx::libFileSearch("images", "busy", "gif", mode).absFileName()); @@ -623,6 +624,7 @@ GuiView::GuiView(int id) busylabel, SLOT(show())); connect(&d.processing_thread_watcher_, SIGNAL(finished()), busylabel, SLOT(hide())); + connect(busylabel, SIGNAL(clicked()), this, SLOT(checkCancelBackground())); QFontMetrics const fm(statusBar()->fontMetrics()); int const iconheight = max(int(d.normalIconSize), fm.height()); @@ -713,6 +715,18 @@ void GuiView::disableShellEscape() } +void GuiView::checkCancelBackground() +{ + docstring const ttl = _("Cancel Export?"); + docstring const msg = _("Do you want to cancel the background export process?"); + int const ret = + Alert::prompt(ttl, msg, 1, 1, + _("&Cancel export"), _("Co&ntinue")); + if (ret == 0) + Systemcall::killscript(); +} + + QVector GuiView::GuiViewPrivate::guiWorkAreas() { QVector areas; diff --git a/src/frontends/qt4/GuiView.h b/src/frontends/qt4/GuiView.h index fa36f7ff8b..007e4f9c19 100644 --- a/src/frontends/qt4/GuiView.h +++ b/src/frontends/qt4/GuiView.h @@ -236,6 +236,8 @@ private Q_SLOTS: /// void resetWindowTitle(); + /// + void checkCancelBackground(); /// void on_currentWorkAreaChanged(GuiWorkArea *); /// diff --git a/src/frontends/qt4/Makefile.am b/src/frontends/qt4/Makefile.am index e2e3e1ce5e..b09e2b9ff6 100644 --- a/src/frontends/qt4/Makefile.am +++ b/src/frontends/qt4/Makefile.am @@ -80,6 +80,7 @@ SOURCEFILES = \ GuiChanges.cpp \ GuiCharacter.cpp \ GuiCitation.cpp \ + GuiClickableLabel.cpp \ GuiClipboard.cpp \ GuiCommandBuffer.cpp \ GuiCommandEdit.cpp \ @@ -197,6 +198,7 @@ MOCHEADER = \ GuiChanges.h \ GuiCharacter.h \ GuiCitation.h \ + GuiClickableLabel.h \ GuiClipboard.h \ GuiCommandBuffer.h \ GuiCommandEdit.h \