On 5/13/19 4:42 AM, Jean-Marc Lasgouttes wrote:
> Le 13/05/2019 à 05:51, Richard Kimberly Heck a écrit :
>> Something like the following ought to work, but it won't link. I'm
>> terrible at linker errors. Help?
>
> Can we have the GuiClickableLabel stuff too?

Not sure why that didn't get included, but here's the full patch again.

Riki


>From a53e829ceaf4aa2f712c642ff1751f76dbe3fd94 Mon Sep 17 00:00:00 2001
From: Richard Kimberly Heck <rikih...@lyx.org>
Date: Mon, 13 May 2019 14:00:43 -0400
Subject: [PATCH] Try to make spinner clickable.

---
 src/frontends/qt4/GuiClickableLabel.h | 42 +++++++++++++++++++++++++++
 src/frontends/qt4/GuiView.cpp         | 16 +++++++++-
 src/frontends/qt4/GuiView.h           |  2 ++
 src/frontends/qt4/Makefile.am         |  1 +
 4 files changed, 60 insertions(+), 1 deletion(-)
 create mode 100644 src/frontends/qt4/GuiClickableLabel.h

diff --git a/src/frontends/qt4/GuiClickableLabel.h b/src/frontends/qt4/GuiClickableLabel.h
new file mode 100644
index 0000000000..5f829c1455
--- /dev/null
+++ b/src/frontends/qt4/GuiClickableLabel.h
@@ -0,0 +1,42 @@
+/**
+ * \file GuiClickableLabel.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Richard Heck
+ *
+ * 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)
+		: QLabel(parent)
+	{}
+
+        ~GuiClickableLabel() {}
+
+Q_SIGNALS:
+	void clicked();
+
+protected:
+	void mousePressEvent(QMouseEvent *) {
+		Q_EMIT clicked();
+	}
+};
+
+
+} // namespace frontend
+} // namespace lyx
+
+#endif  // GUISELECTIONMANAGER
diff --git a/src/frontends/qt4/GuiView.cpp b/src/frontends/qt4/GuiView.cpp
index 98dba1dfa5..2742c3ea1c 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, SLOT(clicked()), this, SIGNAL(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;
diff --git a/src/frontends/qt4/GuiView.h b/src/frontends/qt4/GuiView.h
index fa36f7ff8b..5dd84f3798 100644
--- a/src/frontends/qt4/GuiView.h
+++ b/src/frontends/qt4/GuiView.h
@@ -231,6 +231,8 @@ public Q_SLOTS:
 	void updateWindowTitle(GuiWorkArea * wa);
 	///
 	void disableShellEscape();
+	///
+	void checkCancelBackground();
 
 private Q_SLOTS:
 	///
diff --git a/src/frontends/qt4/Makefile.am b/src/frontends/qt4/Makefile.am
index e2e3e1ce5e..488e8ba224 100644
--- a/src/frontends/qt4/Makefile.am
+++ b/src/frontends/qt4/Makefile.am
@@ -198,6 +198,7 @@ MOCHEADER = \
 	GuiCharacter.h \
 	GuiCitation.h \
 	GuiClipboard.h \
+	GuiClickableLabel.h \
 	GuiCommandBuffer.h \
 	GuiCommandEdit.h \
 	GuiCompare.h \
-- 
2.17.2

Reply via email to