annotate src/hgrunner.h @ 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
rev   line source
Chris@57 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
Chris@57 2
Chris@57 3 /*
Chris@57 4 EasyMercurial
Chris@57 5
Chris@57 6 Based on HgExplorer by Jari Korhonen
Chris@57 7 Copyright (c) 2010 Jari Korhonen
Chris@560 8 Copyright (c) 2012 Chris Cannam
Chris@560 9 Copyright (c) 2012 Queen Mary, University of London
Chris@57 10
Chris@57 11 This program is free software; you can redistribute it and/or
Chris@57 12 modify it under the terms of the GNU General Public License as
Chris@57 13 published by the Free Software Foundation; either version 2 of the
Chris@57 14 License, or (at your option) any later version. See the file
Chris@57 15 COPYING included with this distribution for more information.
Chris@57 16 */
Chris@57 17
jtkorhonen@0 18 #ifndef HGRUNNER_H
jtkorhonen@0 19 #define HGRUNNER_H
jtkorhonen@0 20
Chris@109 21 #include "hgaction.h"
Chris@109 22
Chris@561 23 #include <QWidget>
jtkorhonen@0 24 #include <QProcess>
Chris@561 25
Chris@561 26 class QProgressBar;
Chris@561 27 class QToolButton;
Chris@561 28 class QFile;
jtkorhonen@0 29
Chris@109 30 #include <deque>
Chris@109 31
Chris@561 32 class HgRunner : public QWidget
jtkorhonen@0 33 {
jtkorhonen@0 34 Q_OBJECT
jtkorhonen@0 35
Chris@62 36 public:
Chris@561 37 HgRunner(QString myDirPath, QWidget *parent = 0);
Chris@62 38 ~HgRunner();
jtkorhonen@0 39
Chris@561 40 public slots:
Chris@109 41 void requestAction(HgAction action);
Chris@182 42 void killCurrentActions(); // kill anything running; clear the queue
jtkorhonen@0 43
Chris@109 44 signals:
Chris@238 45 void commandStarting(HgAction action);
Chris@142 46 void commandCompleted(HgAction action, QString stdOut);
Chris@537 47 void commandFailed(HgAction action, QString stdErr, QString stdOut);
jtkorhonen@0 48
Chris@109 49 private slots:
Chris@109 50 void started();
Chris@189 51 void error(QProcess::ProcessError);
Chris@109 52 void finished(int procExitCode, QProcess::ExitStatus procExitStatus);
Chris@110 53 void dataReadyStdout();
Chris@110 54 void dataReadyStderr();
Chris@113 55 void dataReadyPty();
Chris@62 56
Chris@62 57 private:
Chris@109 58 void checkQueue();
Chris@109 59 void startCommand(HgAction action);
Chris@84 60 void closeProcInput();
Chris@109 61 void killCurrentCommand();
Chris@75 62
Chris@84 63 void noteUsername(QString);
Chris@84 64 void noteRealm(QString);
Chris@84 65 void getUsername();
Chris@84 66 void getPassword();
Chris@113 67 bool checkPrompts(QString);
Chris@84 68
Chris@111 69 void openTerminal();
Chris@111 70 void closeTerminal();
chris@406 71
Chris@239 72 QString getHgBinaryName();
chris@406 73 QString getSshBinaryName();
Chris@239 74 QString getExtensionLocation();
Chris@239 75
Chris@455 76 QString getAuthFilePath();
Chris@455 77 QString getAuthKey();
Chris@455 78 void pruneOldAuthFiles();
Chris@455 79
Chris@188 80 QString getUnbundledFileName();
Chris@180 81 QString unbundleExtension();
Chris@161 82
Chris@561 83 QProgressBar *m_progress;
Chris@561 84 QToolButton *m_cancel;
Chris@561 85
Chris@444 86 QStringList addExtensionOptions(QStringList);
Chris@444 87
Chris@84 88 int m_ptyMasterFd;
Chris@84 89 int m_ptySlaveFd;
Chris@84 90 QString m_ptySlaveFilename;
Chris@113 91 QFile *m_ptyFile;
Chris@62 92
Chris@84 93 bool m_isRunning;
Chris@84 94 QProcess *m_proc;
Chris@110 95 QString m_stdout;
Chris@110 96 QString m_stderr;
Chris@84 97
Chris@84 98 QString m_userName;
Chris@84 99 QString m_realm;
Chris@172 100
Chris@172 101 QString m_myDirPath;
Chris@161 102 QString m_extensionPath;
Chris@62 103
Chris@444 104 QString m_authKey;
Chris@444 105 QString m_authFilePath;
Chris@444 106
Chris@109 107 typedef std::deque<HgAction> ActionQueue;
Chris@109 108 ActionQueue m_queue;
Chris@109 109 HgAction m_currentAction;
jtkorhonen@0 110 };
jtkorhonen@0 111
jtkorhonen@0 112 #endif // HGRUNNER_H