comparison src/hgrunner.cpp @ 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 39cac58b4f92
comparison
equal deleted inserted replaced
560:533519ebc0cb 561:1ff2a1bf0a40
18 #include "hgrunner.h" 18 #include "hgrunner.h"
19 #include "common.h" 19 #include "common.h"
20 #include "debug.h" 20 #include "debug.h"
21 #include "settingsdialog.h" 21 #include "settingsdialog.h"
22 22
23 #include <QPushButton>
24 #include <QListWidget>
25 #include <QDialog>
26 #include <QLabel>
27 #include <QVBoxLayout>
28 #include <QSettings> 23 #include <QSettings>
29 #include <QInputDialog> 24 #include <QInputDialog>
30 #include <QDesktopServices> 25 #include <QDesktopServices>
31 #include <QTemporaryFile> 26 #include <QTemporaryFile>
32 #include <QDir> 27 #include <QDir>
28 #include <QProgressBar>
29 #include <QToolButton>
30 #include <QGridLayout>
33 31
34 #include <iostream> 32 #include <iostream>
35 #include <errno.h> 33 #include <errno.h>
36 #include <stdio.h> 34 #include <stdio.h>
37 #include <stdlib.h> 35 #include <stdlib.h>
42 #include <fcntl.h> 40 #include <fcntl.h>
43 #else 41 #else
44 #include <process.h> 42 #include <process.h>
45 #endif 43 #endif
46 44
47 HgRunner::HgRunner(QString myDirPath, QWidget * parent) : 45 HgRunner::HgRunner(QString myDirPath, QWidget *parent) :
48 QProgressBar(parent), 46 QWidget(parent),
49 m_myDirPath(myDirPath) 47 m_myDirPath(myDirPath)
50 { 48 {
49 QGridLayout *layout = new QGridLayout(this);
50 layout->setMargin(0);
51
52 m_progress = new QProgressBar;
53 layout->addWidget(m_progress, 0, 0);
54
55 m_cancel = new QToolButton;
56 m_cancel->setIcon(QIcon(":images/cancel-small.png"));
57 m_cancel->setToolButtonStyle(Qt::ToolButtonIconOnly);
58 m_cancel->setAutoRaise(true);
59 connect(m_cancel, SIGNAL(clicked()), this, SLOT(killCurrentActions()));
60 layout->addWidget(m_cancel, 0, 1);
61
51 m_proc = 0; 62 m_proc = 0;
52 63
53 // Always unbundle the extension: even if it already exists (in 64 // Always unbundle the extension: even if it already exists (in
54 // case we're upgrading) and even if we're not going to use it (so 65 // case we're upgrading) and even if we're not going to use it (so
55 // that it's available in case someone wants to use it later, 66 // that it's available in case someone wants to use it later,
57 // prefer is the one in the settings first, if it exists; then the 68 // prefer is the one in the settings first, if it exists; then the
58 // unbundled one; then anything in the path if for some reason 69 // unbundled one; then anything in the path if for some reason
59 // unbundling failed 70 // unbundling failed
60 unbundleExtension(); 71 unbundleExtension();
61 72
62 setTextVisible(false); 73 m_progress->setTextVisible(false);
63 setVisible(false); 74 hide();
64 m_isRunning = false; 75 m_isRunning = false;
65 } 76 }
66 77
67 HgRunner::~HgRunner() 78 HgRunner::~HgRunner()
68 { 79 {
522 533
523 //!!! want an option to use the mercurial_keyring extension as well 534 //!!! want an option to use the mercurial_keyring extension as well
524 } 535 }
525 536
526 m_isRunning = true; 537 m_isRunning = true;
527 setRange(0, 0); 538 m_progress->setRange(0, 0);
528 if (!action.shouldBeFast()) show(); 539 if (!action.shouldBeFast()) show();
529 m_stdout.clear(); 540 m_stdout.clear();
530 m_stderr.clear(); 541 m_stderr.clear();
531 m_realm = ""; 542 m_realm = "";
532 m_userName = ""; 543 m_userName = "";