# HG changeset patch # User Chris Cannam # Date 1330642434 0 # Node ID 012ba1b83328fc7795e31cd9644a76471c619f8b # Parent e0d734fad735ed31e7612da5fb4e8a2e36d35d86 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) diff -r e0d734fad735 -r 012ba1b83328 src/hgaction.h --- a/src/hgaction.h Wed Feb 29 15:24:10 2012 +0000 +++ b/src/hgaction.h Thu Mar 01 22:53:54 2012 +0000 @@ -118,6 +118,20 @@ return false; } } + + bool makesSenseToCancel() const { + switch (action) { + case ACT_INCOMING: + case ACT_PUSH: + case ACT_PULL: + case ACT_CLONEFROMREMOTE: + case ACT_FOLDERDIFF: + case ACT_CHGSETDIFF: + return true; + default: + return false; + } + } }; #endif diff -r e0d734fad735 -r 012ba1b83328 src/hgrunner.cpp --- 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 #include #include -#include +#include #include #include @@ -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 = ""; diff -r e0d734fad735 -r 012ba1b83328 src/hgrunner.h --- a/src/hgrunner.h Wed Feb 29 15:24:10 2012 +0000 +++ b/src/hgrunner.h Thu Mar 01 22:53:54 2012 +0000 @@ -24,7 +24,7 @@ #include class QProgressBar; -class QToolButton; +class QPushButton; class QFile; #include @@ -88,7 +88,7 @@ QString unbundleExtension(); QProgressBar *m_progress; - QToolButton *m_cancel; + QPushButton *m_cancel; QStringList addExtensionOptions(QStringList);