[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] r12681: Test running executables from QT (in torpedo/trunk/src: . processtest)



Author: sjm217
Date: 2007-12-05 11:55:58 -0500 (Wed, 05 Dec 2007)
New Revision: 12681

Added:
   torpedo/trunk/src/processtest/
   torpedo/trunk/src/processtest/README
   torpedo/trunk/src/processtest/browserprocess.cpp
   torpedo/trunk/src/processtest/browserprocess.h
   torpedo/trunk/src/processtest/main.cpp
   torpedo/trunk/src/processtest/processtest.cpp
   torpedo/trunk/src/processtest/processtest.h
   torpedo/trunk/src/processtest/processtest.pro
Log:
Test running executables from QT

Added: torpedo/trunk/src/processtest/README
===================================================================
--- torpedo/trunk/src/processtest/README	                        (rev 0)
+++ torpedo/trunk/src/processtest/README	2007-12-05 16:55:58 UTC (rev 12681)
@@ -0,0 +1,13 @@
+###
+### Test invoking Firefox from QT
+### Steven J. Murdoch <http://www.cl.cam.ac.uk/users/sjm217/>
+### $Id$
+###
+
+Build instructions
+------------------
+
+For mingw32 on Windows:
+
+$ qmake
+$ mingw32-make


Property changes on: torpedo/trunk/src/processtest/README
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Added: torpedo/trunk/src/processtest/browserprocess.cpp
===================================================================
--- torpedo/trunk/src/processtest/browserprocess.cpp	                        (rev 0)
+++ torpedo/trunk/src/processtest/browserprocess.cpp	2007-12-05 16:55:58 UTC (rev 12681)
@@ -0,0 +1,32 @@
+/**
+ ** Test invoking Firefox from QT
+ ** Steven J. Murdoch <http://www.cl.cam.ac.uk/users/sjm217/>
+ ** $Id$
+ **/
+
+#include <QString>
+  
+#include "browserprocess.h"
+
+BrowserProcess::BrowserProcess(QObject *parent)
+: QProcess(parent)
+{
+  // Call error handling routine on errors
+  QObject::connect(this, SIGNAL(error(QProcess::ProcessError)), this, SLOT(onError(QProcess::ProcessError)));
+}
+
+void
+BrowserProcess::start(QString app, QStringList args) 
+{
+  // Start the specified application
+  QProcess::start(app, args, QIODevice::ReadOnly | QIODevice::Text);
+}
+
+void
+BrowserProcess::onError(QProcess::ProcessError error)
+{
+  // Pass up error messages on startup, but ignore the rest
+  if (error == QProcess::FailedToStart) {
+    emit startFailed(errorString());
+  }
+}


Property changes on: torpedo/trunk/src/processtest/browserprocess.cpp
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Added: torpedo/trunk/src/processtest/browserprocess.h
===================================================================
--- torpedo/trunk/src/processtest/browserprocess.h	                        (rev 0)
+++ torpedo/trunk/src/processtest/browserprocess.h	2007-12-05 16:55:58 UTC (rev 12681)
@@ -0,0 +1,31 @@
+/**
+ ** Test invoking Firefox from QT
+ ** Steven J. Murdoch <http://www.cl.cam.ac.uk/users/sjm217/>
+ ** $Id$
+ **/
+
+#ifndef _BROWSERPROCESS_H
+#define _BROWSERPROCESS_H
+
+#include <QProcess>
+
+class BrowserProcess : public QProcess
+{
+  Q_OBJECT
+
+public:
+  // Default constructor
+  BrowserProcess(QObject *parent = 0);
+  // Start the specified application
+  void start(QString app, QStringList args);
+
+private slots:
+  // Invoked when underlying QProcess fails
+  void onError(QProcess::ProcessError error);
+
+signals:
+  // Invoked when start() fails
+  void startFailed(QString errorMessage);
+};
+
+#endif


Property changes on: torpedo/trunk/src/processtest/browserprocess.h
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Added: torpedo/trunk/src/processtest/main.cpp
===================================================================
--- torpedo/trunk/src/processtest/main.cpp	                        (rev 0)
+++ torpedo/trunk/src/processtest/main.cpp	2007-12-05 16:55:58 UTC (rev 12681)
@@ -0,0 +1,31 @@
+/**
+ ** Test invoking Firefox from QT
+ ** Steven J. Murdoch <http://www.cl.cam.ac.uk/users/sjm217/>
+ ** $Id$
+ **/
+
+#include <QApplication>
+#include <QCoreApplication>
+#include <iostream>
+
+#include "processtest.h"
+
+int main(int argc, char *argv[])
+{
+  // Initialize QT
+  QApplication app(argc, argv);
+
+  // Check that a command has been specified
+  if(QCoreApplication::arguments().size() < 2)
+  {
+    std::cerr << "Usage: processtest COMMANDLINE\n";
+    return 1;
+  }
+
+  // Initialize the main window
+  ProcessTest test;
+  test.show();
+
+  // Start the application
+  return app.exec();
+}


Property changes on: torpedo/trunk/src/processtest/main.cpp
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Added: torpedo/trunk/src/processtest/processtest.cpp
===================================================================
--- torpedo/trunk/src/processtest/processtest.cpp	                        (rev 0)
+++ torpedo/trunk/src/processtest/processtest.cpp	2007-12-05 16:55:58 UTC (rev 12681)
@@ -0,0 +1,62 @@
+/**
+ ** Test invoking Firefox from QT
+ ** Steven J. Murdoch <http://www.cl.cam.ac.uk/users/sjm217/>
+ ** $Id$
+ **/
+
+#include <QPushButton>
+#include <QStringList>
+#include <QCoreApplication>
+
+#include "processtest.h"
+#include "browserprocess.h"
+
+ProcessTest::ProcessTest(QWidget *parent)
+    : QWidget(parent)
+{
+    // Set the window size
+    setFixedSize(200, 50);
+
+    // Get the command line (main.cpp already checked the size
+    _cmd = QCoreApplication::arguments().at(1);
+
+    // Display the button
+    _button = new QPushButton(tr("Go"), this);
+    _button->setGeometry(10, 10, 180, 30);
+
+    // Initialize the process handler
+    _browser = new BrowserProcess();
+ 
+    // Connect up the button
+    QObject::connect(_button, SIGNAL(clicked()), this, SLOT(onClicked()));
+    
+    // Connect up the process handler
+    QObject::connect(_browser, SIGNAL(started()), this, SLOT(onStarted()));
+    QObject::connect(_browser, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(onFinished()));
+    QObject::connect(_browser, SIGNAL(startFailed(QString)), this, SLOT(onFailed()));
+}
+
+void ProcessTest::onClicked()
+{
+    // Start the application
+    _button->setText(tr("Starting...") + _cmd);
+    _browser->start(_cmd, QStringList());
+}
+
+void ProcessTest::onStarted()
+{
+    // Application has started
+    _button->setText(tr("Running..."));
+}
+
+void ProcessTest::onFinished()
+{
+    // Application has finished
+    _button->setText(tr("Stopped"));
+}
+
+void ProcessTest::onFailed()
+{
+    // Application failed to start
+    _button->setText(tr("Failed"));
+}


Property changes on: torpedo/trunk/src/processtest/processtest.cpp
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Added: torpedo/trunk/src/processtest/processtest.h
===================================================================
--- torpedo/trunk/src/processtest/processtest.h	                        (rev 0)
+++ torpedo/trunk/src/processtest/processtest.h	2007-12-05 16:55:58 UTC (rev 12681)
@@ -0,0 +1,39 @@
+/**
+ ** Test invoking Firefox from QT
+ ** Steven J. Murdoch <http://www.cl.cam.ac.uk/users/sjm217/>
+ ** $Id$
+ **/
+
+#ifndef PROCESSTEST_H
+#define PROCESSTEST_H
+
+#include <QWidget>
+#include <QPushButton>
+
+#include "browserprocess.h"
+
+class ProcessTest : public QWidget
+{
+    Q_OBJECT
+
+public:
+    ProcessTest(QWidget *parent = 0);
+private slots:
+    // App has started
+    void onStarted();
+    // App has exited
+    void onFinished();
+    // App startup failed
+    void onFailed();
+    // Button was clicked
+    void onClicked();
+private:
+    // The push button
+    QPushButton *_button;
+    // Process handler
+    BrowserProcess *_browser;
+    // Command line to start
+    QString _cmd;
+};
+
+#endif


Property changes on: torpedo/trunk/src/processtest/processtest.h
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Added: torpedo/trunk/src/processtest/processtest.pro
===================================================================
--- torpedo/trunk/src/processtest/processtest.pro	                        (rev 0)
+++ torpedo/trunk/src/processtest/processtest.pro	2007-12-05 16:55:58 UTC (rev 12681)
@@ -0,0 +1,14 @@
+###
+### Test invoking Firefox from QT
+### Steven J. Murdoch <http://www.cl.cam.ac.uk/users/sjm217/>
+### $Id$
+###
+
+TEMPLATE = app
+TARGET = 
+DEPENDPATH += .
+INCLUDEPATH += .
+
+# Input
+HEADERS += browserprocess.h processtest.h
+SOURCES += browserprocess.cpp main.cpp processtest.cpp


Property changes on: torpedo/trunk/src/processtest/processtest.pro
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native