# HG changeset patch # User Chris Cannam # Date 1330363550 0 # Node ID 1ff2a1bf0a40f18d50e994a5f2ef90cab5c9d511 # Parent 533519ebc0cb5b4755c7d59f36477e2915a1bf70 Add a cancel button to the progress bar diff -r 533519ebc0cb -r 1ff2a1bf0a40 easyhg.qrc --- a/easyhg.qrc Mon Feb 27 17:14:03 2012 +0000 +++ b/easyhg.qrc Mon Feb 27 17:25:50 2012 +0000 @@ -27,6 +27,7 @@ images/home.png images/back.png images/forward.png + images/cancel-small.png help/topics.html help/help.css help/a-04.html diff -r 533519ebc0cb -r 1ff2a1bf0a40 images/cancel-small.png Binary file images/cancel-small.png has changed diff -r 533519ebc0cb -r 1ff2a1bf0a40 src/findwidget.cpp --- a/src/findwidget.cpp Mon Feb 27 17:14:03 2012 +0000 +++ b/src/findwidget.cpp Mon Feb 27 17:25:50 2012 +0000 @@ -33,7 +33,6 @@ layout->addWidget(button, 0, 0); button->setText(tr("Find...")); button->setToolButtonStyle(Qt::ToolButtonTextOnly); -// button->setAutoRaise(true); connect(button, SIGNAL(clicked()), this, SLOT(buttonPressed())); m_lineEdit = new QLineEdit(); diff -r 533519ebc0cb -r 1ff2a1bf0a40 src/hgrunner.cpp --- a/src/hgrunner.cpp Mon Feb 27 17:14:03 2012 +0000 +++ b/src/hgrunner.cpp Mon Feb 27 17:25:50 2012 +0000 @@ -20,16 +20,14 @@ #include "debug.h" #include "settingsdialog.h" -#include -#include -#include -#include -#include #include #include #include #include #include +#include +#include +#include #include #include @@ -44,10 +42,23 @@ #include #endif -HgRunner::HgRunner(QString myDirPath, QWidget * parent) : - QProgressBar(parent), +HgRunner::HgRunner(QString myDirPath, QWidget *parent) : + QWidget(parent), m_myDirPath(myDirPath) { + QGridLayout *layout = new QGridLayout(this); + layout->setMargin(0); + + m_progress = new QProgressBar; + layout->addWidget(m_progress, 0, 0); + + m_cancel = new QToolButton; + m_cancel->setIcon(QIcon(":images/cancel-small.png")); + m_cancel->setToolButtonStyle(Qt::ToolButtonIconOnly); + m_cancel->setAutoRaise(true); + connect(m_cancel, SIGNAL(clicked()), this, SLOT(killCurrentActions())); + layout->addWidget(m_cancel, 0, 1); + m_proc = 0; // Always unbundle the extension: even if it already exists (in @@ -59,8 +70,8 @@ // unbundling failed unbundleExtension(); - setTextVisible(false); - setVisible(false); + m_progress->setTextVisible(false); + hide(); m_isRunning = false; } @@ -524,7 +535,7 @@ } m_isRunning = true; - setRange(0, 0); + m_progress->setRange(0, 0); if (!action.shouldBeFast()) show(); m_stdout.clear(); m_stderr.clear(); diff -r 533519ebc0cb -r 1ff2a1bf0a40 src/hgrunner.h --- a/src/hgrunner.h Mon Feb 27 17:14:03 2012 +0000 +++ b/src/hgrunner.h Mon Feb 27 17:25:50 2012 +0000 @@ -20,22 +20,24 @@ #include "hgaction.h" -#include +#include #include -#include -#include -#include + +class QProgressBar; +class QToolButton; +class QFile; #include -class HgRunner : public QProgressBar +class HgRunner : public QWidget { Q_OBJECT public: - HgRunner(QString myDirPath, QWidget * parent = 0); + HgRunner(QString myDirPath, QWidget *parent = 0); ~HgRunner(); +public slots: void requestAction(HgAction action); void killCurrentActions(); // kill anything running; clear the queue @@ -78,6 +80,9 @@ QString getUnbundledFileName(); QString unbundleExtension(); + QProgressBar *m_progress; + QToolButton *m_cancel; + QStringList addExtensionOptions(QStringList); int m_ptyMasterFd;