]> git.lyx.org Git - features.git/commitdiff
Allow click on the 'spinner' to cancel export.
authorRichard Kimberly Heck <rikiheck@lyx.org>
Tue, 28 May 2019 03:20:45 +0000 (23:20 -0400)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Thu, 18 Jun 2020 13:48:30 +0000 (15:48 +0200)
src/frontends/qt4/GuiClickableLabel.cpp [new file with mode: 0644]
src/frontends/qt4/GuiClickableLabel.h [new file with mode: 0644]
src/frontends/qt4/GuiView.cpp
src/frontends/qt4/GuiView.h
src/frontends/qt4/Makefile.am

diff --git a/src/frontends/qt4/GuiClickableLabel.cpp b/src/frontends/qt4/GuiClickableLabel.cpp
new file mode 100644 (file)
index 0000000..31a5be5
--- /dev/null
@@ -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 (file)
index 0000000..4ae4905
--- /dev/null
@@ -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 <QLabel>
+
+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
index 98dba1dfa5544be735f2d36e1ee2bfb0b1de8f8d..8ef8ca5cc96d40c01d48f79e4d62c7b5ef23d479 100644 (file)
@@ -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<GuiWorkArea*> GuiView::GuiViewPrivate::guiWorkAreas()
 {
        QVector<GuiWorkArea*> areas;
index fa36f7ff8b79406883897e6ca3c02c9d1a7e19c0..007e4f9c196e0a14729777e4b241b5b769221f60 100644 (file)
@@ -236,6 +236,8 @@ private Q_SLOTS:
        ///
        void resetWindowTitle();
 
+       ///
+       void checkCancelBackground();
        ///
        void on_currentWorkAreaChanged(GuiWorkArea *);
        ///
index e2e3e1ce5e7aab126dbcef3f3b1977c3fb732aa8..b09e2b9ff61d505a3b35699ce2cd1832f5a1978f 100644 (file)
@@ -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 \