[LyX/master] SVG replacement of busy.gif

Jean-Marc Lasgouttes lasgouttes at lyx.org
Wed Sep 29 10:28:45 UTC 2021


commit 0862042b28039159656e8a4d6dea1be5a94cf8b6
Author: Daniel Ramoeller <d.lyx at web.de>
Date:   Wed Sep 29 04:25:58 2021 +0200

    SVG replacement of busy.gif
    
    Fix for bug #10384.
---
 lib/Makefile.am              |    2 +-
 lib/images/busy.gif          |  Bin 1849 -> 0 bytes
 lib/images/busy.svgz         |  Bin 0 -> 327 bytes
 src/frontends/qt/GuiView.cpp |   28 +++++++++++++++++-----------
 src/frontends/qt/GuiView.h   |   14 ++++++++++++++
 5 files changed, 32 insertions(+), 12 deletions(-)

diff --git a/lib/Makefile.am b/lib/Makefile.am
index 71cebde..61d6f1a 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -564,7 +564,7 @@ dist_images_DATA1X = \
 	images/buffer-write-as.svgz \
 	images/buffer-write.svgz \
 	images/build-program.svgz \
-	images/busy.gif \
+	images/busy.svgz \
 	images/change-accept.svgz \
 	images/change-next.svgz \
 	images/change-reject.svgz \
diff --git a/lib/images/busy.gif b/lib/images/busy.gif
deleted file mode 100644
index 5b33f7e..0000000
Binary files a/lib/images/busy.gif and /dev/null differ
diff --git a/lib/images/busy.svgz b/lib/images/busy.svgz
new file mode 100644
index 0000000..2a07dfa
Binary files /dev/null and b/lib/images/busy.svgz differ
diff --git a/src/frontends/qt/GuiView.cpp b/src/frontends/qt/GuiView.cpp
index 3a6a04c..9f7531c 100644
--- a/src/frontends/qt/GuiView.cpp
+++ b/src/frontends/qt/GuiView.cpp
@@ -96,7 +96,6 @@
 #include <QMenu>
 #include <QMenuBar>
 #include <QMimeData>
-#include <QMovie>
 #include <QPainter>
 #include <QPixmap>
 #include <QPoint>
@@ -612,20 +611,19 @@ GuiView::GuiView(int id)
 	setAcceptDrops(true);
 
 	// add busy indicator to statusbar
-	GuiClickableLabel * busylabel = new GuiClickableLabel(statusBar());
-	statusBar()->addPermanentWidget(busylabel);
 	search_mode mode = theGuiApp()->imageSearchMode();
-	QString fn = toqstr(lyx::libFileSearch("images", "busy", "gif", mode).absFileName());
-	QMovie * busyanim = new QMovie(fn, QByteArray(), busylabel);
-	busylabel->setMovie(busyanim);
-	busyanim->start();
-	busylabel->hide();
+	QString fn = toqstr(lyx::libFileSearch("images", "busy", "svgz", mode).absFileName());
+	PressableSvgWidget * busySVG = new PressableSvgWidget(fn);
+	statusBar()->addPermanentWidget(busySVG);
+	// make busy indicator square with 5px margins
+	busySVG->setMaximumSize(busySVG->height() - 5, busySVG->height() - 5);
+	busySVG->hide();
 
 	connect(&d.processing_thread_watcher_, SIGNAL(started()),
-		busylabel, SLOT(show()));
+		busySVG, SLOT(show()));
 	connect(&d.processing_thread_watcher_, SIGNAL(finished()),
-		busylabel, SLOT(hide()));
-	connect(busylabel, SIGNAL(clicked()), this, SLOT(checkCancelBackground()));
+		busySVG, SLOT(hide()));
+	connect(busySVG, SIGNAL(pressed()), this, SLOT(checkCancelBackground()));
 
 	QFontMetrics const fm(statusBar()->fontMetrics());
 
@@ -5130,6 +5128,14 @@ SEMenu::SEMenu(QWidget * parent)
 		parent, SLOT(disableShellEscape()));
 }
 
+
+void PressableSvgWidget::mousePressEvent(QMouseEvent * event)
+{
+	if (event->button() == Qt::LeftButton) {
+        Q_EMIT pressed();
+    }
+}
+
 } // namespace frontend
 } // namespace lyx
 
diff --git a/src/frontends/qt/GuiView.h b/src/frontends/qt/GuiView.h
index 47f5e40..657634c 100644
--- a/src/frontends/qt/GuiView.h
+++ b/src/frontends/qt/GuiView.h
@@ -21,6 +21,7 @@
 
 #include <QMainWindow>
 #include <QMenu>
+#include <QSvgWidget>
 
 class QCloseEvent;
 class QDragEnterEvent;
@@ -534,6 +535,19 @@ public Q_SLOTS:
 	void showMenu(QPoint const &) { exec(QCursor::pos()); }
 };
 
+
+class PressableSvgWidget : public QSvgWidget
+{
+	Q_OBJECT
+public:
+    explicit PressableSvgWidget(const QString &file, QWidget * parent = nullptr)
+	: QSvgWidget(file, parent) {};
+protected:
+    void mousePressEvent(QMouseEvent *event) override;
+Q_SIGNALS:
+    void pressed();
+};
+
 } // namespace frontend
 } // namespace lyx
 


More information about the lyx-cvs mailing list