comparison 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
comparison
equal deleted inserted replaced
570:e0d734fad735 571:012ba1b83328
24 #include <QInputDialog> 24 #include <QInputDialog>
25 #include <QDesktopServices> 25 #include <QDesktopServices>
26 #include <QTemporaryFile> 26 #include <QTemporaryFile>
27 #include <QDir> 27 #include <QDir>
28 #include <QProgressBar> 28 #include <QProgressBar>
29 #include <QToolButton> 29 #include <QPushButton>
30 #include <QGridLayout> 30 #include <QGridLayout>
31 31
32 #include <iostream> 32 #include <iostream>
33 #include <errno.h> 33 #include <errno.h>
34 #include <stdio.h> 34 #include <stdio.h>
50 layout->setMargin(0); 50 layout->setMargin(0);
51 51
52 m_progress = new QProgressBar; 52 m_progress = new QProgressBar;
53 layout->addWidget(m_progress, 0, 0); 53 layout->addWidget(m_progress, 0, 0);
54 54
55 m_cancel = new QToolButton; 55 m_cancel = new QPushButton;
56 m_cancel->setIcon(QIcon(":images/cancel-small.png")); 56 m_cancel->setIcon(QIcon(":images/cancel-small.png"));
57 m_cancel->setToolButtonStyle(Qt::ToolButtonIconOnly); 57 m_cancel->setFlat(true);
58 m_cancel->setAutoRaise(true); 58 m_cancel->setFixedHeight(m_progress->sizeHint().height());
59 m_cancel->setFixedWidth(m_progress->sizeHint().height());
59 connect(m_cancel, SIGNAL(clicked()), this, SLOT(killCurrentActions())); 60 connect(m_cancel, SIGNAL(clicked()), this, SLOT(killCurrentActions()));
60 layout->addWidget(m_cancel, 0, 1); 61 layout->addWidget(m_cancel, 0, 1);
61 62
62 m_proc = 0; 63 m_proc = 0;
63 64
536 //!!! want an option to use the mercurial_keyring extension as well 537 //!!! want an option to use the mercurial_keyring extension as well
537 } 538 }
538 539
539 m_isRunning = true; 540 m_isRunning = true;
540 m_progress->setRange(0, 0); 541 m_progress->setRange(0, 0);
541 if (!action.shouldBeFast()) show(); 542 if (!action.shouldBeFast()) {
543 show();
544 m_cancel->setVisible(action.makesSenseToCancel());
545 }
542 m_stdout.clear(); 546 m_stdout.clear();
543 m_stderr.clear(); 547 m_stderr.clear();
544 m_realm = ""; 548 m_realm = "";
545 m_userName = ""; 549 m_userName = "";
546 550