diff src/hgrunner.cpp @ 571:012ba1b83328

Show cancel button with progress bar only when running an operation that it makes sense to cancel (we don't really want people cancelling e.g. initial folder scan because it would leave things in an inconsistent state)
author Chris Cannam
date Thu, 01 Mar 2012 22:53:54 +0000
parents 39cac58b4f92
children ab92f695f776
line wrap: on
line diff
--- a/src/hgrunner.cpp	Wed Feb 29 15:24:10 2012 +0000
+++ b/src/hgrunner.cpp	Thu Mar 01 22:53:54 2012 +0000
@@ -26,7 +26,7 @@
 #include <QTemporaryFile>
 #include <QDir>
 #include <QProgressBar>
-#include <QToolButton>
+#include <QPushButton>
 #include <QGridLayout>
 
 #include <iostream>
@@ -52,10 +52,11 @@
     m_progress = new QProgressBar;
     layout->addWidget(m_progress, 0, 0);
 
-    m_cancel = new QToolButton;
+    m_cancel = new QPushButton;
     m_cancel->setIcon(QIcon(":images/cancel-small.png"));
-    m_cancel->setToolButtonStyle(Qt::ToolButtonIconOnly);
-    m_cancel->setAutoRaise(true);
+    m_cancel->setFlat(true);
+    m_cancel->setFixedHeight(m_progress->sizeHint().height());
+    m_cancel->setFixedWidth(m_progress->sizeHint().height());
     connect(m_cancel, SIGNAL(clicked()), this, SLOT(killCurrentActions()));
     layout->addWidget(m_cancel, 0, 1);
 
@@ -538,7 +539,10 @@
 
     m_isRunning = true;
     m_progress->setRange(0, 0);
-    if (!action.shouldBeFast()) show();
+    if (!action.shouldBeFast()) {
+        show();
+        m_cancel->setVisible(action.makesSenseToCancel());
+    }
     m_stdout.clear();
     m_stderr.clear();
     m_realm = "";