]> git.lyx.org Git - features.git/blobdiff - src/frontends/qt/GuiView.cpp
After export-cancel, hide busy and cancel buttons
[features.git] / src / frontends / qt / GuiView.cpp
index b87b494dac6779d8c740ac66830d38c0f0d6c31b..8269ff09cceec5164a8882c2045b17d6992678c4 100644 (file)
@@ -69,6 +69,8 @@
 #include "Toolbars.h"
 #include "version.h"
 
+#include "graphics/PreviewLoader.h"
+
 #include "support/convert.h"
 #include "support/debug.h"
 #include "support/ExceptionMessage.h"
@@ -631,6 +633,10 @@ GuiView::GuiView(int id)
        // For Drag&Drop.
        setAcceptDrops(true);
 
+       QFontMetrics const fm(statusBar()->fontMetrics());
+       int const iconheight = max(int(d.normalIconSize), fm.height());
+       QSize const iconsize(iconheight, iconheight);
+
        // add busy indicator to statusbar
        search_mode mode = theGuiApp()->imageSearchMode();
        QString fn = toqstr(lyx::libFileSearch("images", "busy", "svgz", mode).absFileName());
@@ -639,12 +645,26 @@ GuiView::GuiView(int id)
        // make busy indicator square with 5px margins
        busySVG->setMaximumSize(busySVG->height() - 5, busySVG->height() - 5);
        busySVG->hide();
+       // Add cancel button
+       QPixmap ps = QIcon(getPixmap("images/", "process-stop", "svgz")).pixmap(iconsize);
+       GuiClickableLabel * processStop = new GuiClickableLabel(statusBar());
+       processStop->setPixmap(ps);
+       processStop->setToolTip(qt_("Click here to stop export/output process"));
+       processStop->hide();
+       statusBar()->addPermanentWidget(processStop);
 
        connect(&d.processing_thread_watcher_, SIGNAL(started()),
                busySVG, SLOT(show()));
        connect(&d.processing_thread_watcher_, SIGNAL(finished()),
                busySVG, SLOT(hide()));
-       connect(busySVG, SIGNAL(pressed()), this, SLOT(checkCancelBackground()));
+       connect(&d.processing_thread_watcher_, SIGNAL(started()),
+               processStop, SLOT(show()));
+       connect(&d.processing_thread_watcher_, SIGNAL(finished()),
+               processStop, SLOT(hide()));
+       connect(processStop, SIGNAL(pressed()), this, SLOT(checkCancelBackground()));
+
+       connect(this, SIGNAL(scriptKilled()), busySVG, SLOT(hide()));
+       connect(this, SIGNAL(scriptKilled()), processStop, SLOT(hide()));
 
        stat_counts_ = new GuiClickableLabel(statusBar());
        stat_counts_->setAlignment(Qt::AlignCenter);
@@ -654,9 +674,6 @@ GuiView::GuiView(int id)
 
        connect(stat_counts_, SIGNAL(clicked()), this, SLOT(statsPressed()));
 
-
-       QFontMetrics const fm(statusBar()->fontMetrics());
-
        zoom_slider_ = new QSlider(Qt::Horizontal, statusBar());
        // Small size slider for macOS to prevent the status bar from enlarging
        zoom_slider_->setAttribute(Qt::WA_MacSmallSize);
@@ -706,7 +723,8 @@ GuiView::GuiView(int id)
 
        // QPalette palette = statusBar()->palette();
 
-       zoom_value_ = new QLabel(statusBar());
+       zoom_value_ = new GuiClickableLabel(statusBar());
+       connect(zoom_value_, SIGNAL(pressed()), this, SLOT(showZoomContextMenu()));
        // zoom_value_->setPalette(palette);
        zoom_value_->setForegroundRole(statusBar()->foregroundRole());
        zoom_value_->setFixedHeight(fm.height());
@@ -722,14 +740,11 @@ GuiView::GuiView(int id)
 
        statusBar()->setContextMenuPolicy(Qt::CustomContextMenu);
        connect(statusBar(), SIGNAL(customContextMenuRequested(QPoint)),
-               this, SLOT(showZoomContextMenu()));
+               this, SLOT(showStatusBarContextMenu()));
 
        // enable pinch to zoom
        grabGesture(Qt::PinchGesture);
 
-       int const iconheight = max(int(d.normalIconSize), fm.height());
-       QSize const iconsize(iconheight, iconheight);
-
        QPixmap shellescape = QIcon(getPixmap("images/", "emblem-shellescape", "svgz,png")).pixmap(iconsize);
        shell_escape_ = new QLabel(statusBar());
        shell_escape_->setPixmap(shellescape);
@@ -819,8 +834,12 @@ void GuiView::checkCancelBackground()
        int const ret =
                Alert::prompt(ttl, msg, 1, 1,
                        _("&Cancel export"), _("Co&ntinue"));
-       if (ret == 0)
+       if (ret == 0) {
                Systemcall::killscript();
+               // stop busy signal immediately so that in the subsequent
+               // "Export canceled" prompt the status bar icons are accurate.
+               Q_EMIT scriptKilled();
+       }
 }
 
 void GuiView::statsPressed()
@@ -862,6 +881,15 @@ void GuiView::zoomOutPressed()
 
 
 void GuiView::showZoomContextMenu()
+{
+       QMenu * menu = guiApp->menus().menu(toqstr("context-zoom"), * this);
+       if (!menu)
+               return;
+       menu->exec(QCursor::pos());
+}
+
+
+void GuiView::showStatusBarContextMenu()
 {
        QMenu * menu = guiApp->menus().menu(toqstr("context-statusbar"), * this);
        if (!menu)
@@ -4421,6 +4449,7 @@ void GuiView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
                }
                case LFUN_EXPORT_CANCEL: {
                        Systemcall::killscript();
+                       Q_EMIT scriptKilled();
                        break;
                }
                case LFUN_BUFFER_SWITCH: {
@@ -4881,6 +4910,10 @@ void GuiView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
                                              lyxrc.currentZoom, lyxrc.defaultZoom));
 
                        guiApp->fontLoader().update();
+                       // Regenerate instant previews
+                       if (lyxrc.preview != LyXRC::PREVIEW_OFF
+                           && doc_buffer && doc_buffer->loader())
+                               doc_buffer->loader()->refreshPreviews();
                        dr.screenUpdate(Update::ForceAll | Update::FitCursor);
                        break;
                }