Commit fa421fa0 authored by Jasem Mutlaq's avatar Jasem Mutlaq

KProcess --> QProcess

parent ee0e48af
......@@ -29,7 +29,7 @@
#include <KMessageBox>
#include <QPushButton>
#include <QLineEdit>
#include <KProcess>
#include <QProcess>
#include <QAction>
#include <KActionCollection>
#include <KNotifications/KNotification>
......
......@@ -18,7 +18,7 @@
#include <QTcpSocket>
#include <QTextEdit>
#include <KProcess>
#include <QProcess>
#include <QLocale>
#include <QDebug>
#include <KMessageBox>
......@@ -62,41 +62,41 @@ ServerManager::~ServerManager()
}
bool ServerManager::start()
{
{
bool connected=false;
int fd=0;
serverProcess = new KProcess(this);
*serverProcess << Options::indiServer();
*serverProcess << "-v" << "-p" << port;
*serverProcess << "-m" << "100";
if (serverProcess == NULL)
serverProcess = new QProcess(this);
QStringList args;
args << "-v" << "-p" << port << "-m" << "100";
QString fifoFile = QString("/tmp/indififo%1").arg(QUuid::createUuid().toString().mid(1, 8));
if ( (fd = mkfifo (fifoFile.toLatin1(), S_IRUSR| S_IWUSR) < 0))
{
KMessageBox::error(NULL, i18n("Error making FIFO file %1: %2.", fifoFile, strerror(errno)));
return false;
}
KMessageBox::error(NULL, i18n("Error making FIFO file %1: %2.", fifoFile, strerror(errno)));
return false;
}
indiFIFO.setFileName(fifoFile);
driverCrashed = false;
if (!indiFIFO.open(QIODevice::ReadWrite | QIODevice::Text))
{
qDebug() << "Unable to create INDI FIFO file: " << fifoFile << endl;
return false;
}
if (!indiFIFO.open(QIODevice::ReadWrite | QIODevice::Text))
{
qDebug() << "Unable to create INDI FIFO file: " << fifoFile << endl;
return false;
}
*serverProcess << "-f" << fifoFile;
args << "-f" << fifoFile;
serverProcess->setOutputChannelMode(KProcess::SeparateChannels);
serverProcess->setProcessChannelMode(QProcess::SeparateChannels);
serverProcess->setReadChannel(QProcess::StandardError);
serverProcess->start();
serverProcess->start(Options::indiServer(), args);
connected = serverProcess->waitForStarted();
......@@ -107,11 +107,10 @@ bool ServerManager::start()
emit started();
}
else
KMessageBox::error(0, i18n("INDI server failed to start: %1", serverProcess->errorString()));
return connected;
}
bool ServerManager::startDriver(DriverInfo *dv)
......
......@@ -13,7 +13,7 @@
#include <QObject>
#include <QTcpSocket>
#include <KProcess>
#include <QProcess>
#include <QFile>
#include <lilxml.h>
......@@ -68,7 +68,7 @@ private:
QString host;
QString port;
QString serverBuffer;
KProcess *serverProcess;
QProcess *serverProcess;
ServerMode mode;
bool driverCrashed;
......
......@@ -81,7 +81,7 @@
#include "starhopperdialog.h"
#ifdef HAVE_XPLANET
#include <KProcess>
#include <QProcess>
#include <QFileDialog>
#endif
......@@ -1167,11 +1167,11 @@ void SkyMap::startXplanet( const QString & outputFile ) {
if ( seconde.setNum( data->ut().time().second() ).size() == 1 ) seconde.push_front( '0' );
// Create xplanet process
KProcess *xplanetProc = new KProcess;
QProcess *xplanetProc = new QProcess;
// Add some options
*xplanetProc << Options::xplanetPath()
<< "-body" << clickedObject()->name().toLower()
QStringList args;
args << "-body" << clickedObject()->name().toLower()
<< "-geometry" << Options::xplanetWidth() + 'x' + Options::xplanetHeight()
<< "-date" << year + month + day + '.' + hour + minute + seconde
<< "-glare" << Options::xplanetGlare()
......@@ -1181,86 +1181,86 @@ void SkyMap::startXplanet( const QString & outputFile ) {
// General options
if ( ! Options::xplanetTitle().isEmpty() )
*xplanetProc << "-window_title" << "\"" + Options::xplanetTitle() + "\"";
args << "-window_title" << "\"" + Options::xplanetTitle() + "\"";
if ( Options::xplanetFOV() )
*xplanetProc << "-fov" << fov.setNum( this->fov() ).replace( '.', ',' );
args << "-fov" << fov.setNum( this->fov() ).replace( '.', ',' );
if ( Options::xplanetConfigFile() )
*xplanetProc << "-config" << Options::xplanetConfigFilePath();
args << "-config" << Options::xplanetConfigFilePath();
if ( Options::xplanetStarmap() )
*xplanetProc << "-starmap" << Options::xplanetStarmapPath();
args << "-starmap" << Options::xplanetStarmapPath();
if ( Options::xplanetArcFile() )
*xplanetProc << "-arc_file" << Options::xplanetArcFilePath();
args << "-arc_file" << Options::xplanetArcFilePath();
if ( Options::xplanetWait() )
*xplanetProc << "-wait" << Options::xplanetWaitValue();
args << "-wait" << Options::xplanetWaitValue();
if ( !outputFile.isEmpty() )
*xplanetProc << "-output" << outputFile << "-quality" << Options::xplanetQuality();
args << "-output" << outputFile << "-quality" << Options::xplanetQuality();
// Labels
if ( Options::xplanetLabel() ) {
*xplanetProc << "-fontsize" << Options::xplanetFontSize()
args << "-fontsize" << Options::xplanetFontSize()
<< "-color" << "0x" + Options::xplanetColor().mid( 1 )
<< "-date_format" << Options::xplanetDateFormat();
if ( Options::xplanetLabelGMT() )
*xplanetProc << "-gmtlabel";
args << "-gmtlabel";
else
*xplanetProc << "-label";
args << "-label";
if ( !Options::xplanetLabelString().isEmpty() )
*xplanetProc << "-label_string" << "\"" + Options::xplanetLabelString() + "\"";
args << "-label_string" << "\"" + Options::xplanetLabelString() + "\"";
if ( Options::xplanetLabelTL() )
*xplanetProc << "-labelpos" << "+15+15";
args << "-labelpos" << "+15+15";
else if ( Options::xplanetLabelTR() )
*xplanetProc << "-labelpos" << "-15+15";
args << "-labelpos" << "-15+15";
else if ( Options::xplanetLabelBR() )
*xplanetProc << "-labelpos" << "-15-15";
args << "-labelpos" << "-15-15";
else if ( Options::xplanetLabelBL() )
*xplanetProc << "-labelpos" << "+15-15";
args << "-labelpos" << "+15-15";
}
// Markers
if ( Options::xplanetMarkerFile() )
*xplanetProc << "-marker_file" << Options::xplanetMarkerFilePath();
args << "-marker_file" << Options::xplanetMarkerFilePath();
if ( Options::xplanetMarkerBounds() )
*xplanetProc << "-markerbounds" << Options::xplanetMarkerBoundsPath();
args << "-markerbounds" << Options::xplanetMarkerBoundsPath();
// Position
if ( Options::xplanetRandom() )
*xplanetProc << "-random";
args << "-random";
else
*xplanetProc << "-latitude" << Options::xplanetLatitude() << "-longitude" << Options::xplanetLongitude();
args << "-latitude" << Options::xplanetLatitude() << "-longitude" << Options::xplanetLongitude();
// Projection
if ( Options::xplanetProjection() ) {
switch ( Options::xplanetProjection() ) {
case 1 : *xplanetProc << "-projection" << "ancient"; break;
case 2 : *xplanetProc << "-projection" << "azimuthal"; break;
case 3 : *xplanetProc << "-projection" << "bonne"; break;
case 4 : *xplanetProc << "-projection" << "gnomonic"; break;
case 5 : *xplanetProc << "-projection" << "hemisphere"; break;
case 6 : *xplanetProc << "-projection" << "lambert"; break;
case 7 : *xplanetProc << "-projection" << "mercator"; break;
case 8 : *xplanetProc << "-projection" << "mollweide"; break;
case 9 : *xplanetProc << "-projection" << "orthographic"; break;
case 10 : *xplanetProc << "-projection" << "peters"; break;
case 11 : *xplanetProc << "-projection" << "polyconic"; break;
case 12 : *xplanetProc << "-projection" << "rectangular"; break;
case 13 : *xplanetProc << "-projection" << "tsc"; break;
case 1 : args << "-projection" << "ancient"; break;
case 2 : args << "-projection" << "azimuthal"; break;
case 3 : args << "-projection" << "bonne"; break;
case 4 : args << "-projection" << "gnomonic"; break;
case 5 : args << "-projection" << "hemisphere"; break;
case 6 : args << "-projection" << "lambert"; break;
case 7 : args << "-projection" << "mercator"; break;
case 8 : args << "-projection" << "mollweide"; break;
case 9 : args << "-projection" << "orthographic"; break;
case 10 : args << "-projection" << "peters"; break;
case 11 : args << "-projection" << "polyconic"; break;
case 12 : args << "-projection" << "rectangular"; break;
case 13 : args << "-projection" << "tsc"; break;
default : break;
}
if ( Options::xplanetBackground() ) {
if ( Options::xplanetBackgroundImage() )
*xplanetProc << "-background" << Options::xplanetBackgroundImagePath();
args << "-background" << Options::xplanetBackgroundImagePath();
else
*xplanetProc << "-background" << "0x" + Options::xplanetBackgroundColorValue().mid( 1 );
args << "-background" << "0x" + Options::xplanetBackgroundColorValue().mid( 1 );
}
}
// We add this option at the end otherwise it does not work (???)
*xplanetProc << "-origin" << "earth";
args << "-origin" << "earth";
// Run xplanet
qDebug() << "Run:" << xplanetProc->program().join(" ");
xplanetProc->start();
//qDebug() << "Run:" << xplanetProc->program().join(" ");
xplanetProc->start(Options::xplanetPath(), args);
}
void SkyMap::slotXplanetToScreen() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment