Mercurial > hg > easyhg
changeset 561:1ff2a1bf0a40
Add a cancel button to the progress bar
author | Chris Cannam |
---|---|
date | Mon, 27 Feb 2012 17:25:50 +0000 |
parents | 533519ebc0cb |
children | 65d77437b5e8 |
files | easyhg.qrc images/cancel-small.png src/findwidget.cpp src/hgrunner.cpp src/hgrunner.h |
diffstat | 5 files changed, 33 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- 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 @@ <file>images/home.png</file> <file>images/back.png</file> <file>images/forward.png</file> + <file>images/cancel-small.png</file> <file>help/topics.html</file> <file>help/help.css</file> <file>help/a-04.html</file>
--- 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();
--- 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 <QPushButton> -#include <QListWidget> -#include <QDialog> -#include <QLabel> -#include <QVBoxLayout> #include <QSettings> #include <QInputDialog> #include <QDesktopServices> #include <QTemporaryFile> #include <QDir> +#include <QProgressBar> +#include <QToolButton> +#include <QGridLayout> #include <iostream> #include <errno.h> @@ -44,10 +42,23 @@ #include <process.h> #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();
--- 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 <QProgressBar> +#include <QWidget> #include <QProcess> -#include <QByteArray> -#include <QRect> -#include <QFile> + +class QProgressBar; +class QToolButton; +class QFile; #include <deque> -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;