1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
| void FenPrincipale::runProj()
{
#if defined(Q_WS_WIN)
QFile f(QFileInfo(projet.pathToProjFile).dir().path() + "/Makefile." + projet.compilMode);
#elif defined(Q_WS_X11)
QFile f(QFileInfo(projet.pathToProjFile).dir().path() + "/Makefile");
#else
QFile f(QFileInfo(projet.pathToProjFile).dir().path() + "/Makefile");
#endif
if(!f.exists() || !f.open(QIODevice::ReadOnly | QIODevice::Text))
return;
QStringList tmp = QString(f.readAll()).split("\n");
f.close();
#if defined(Q_WS_WIN)
QRegExp regexp("DESTDIR_TARGET = \"[^\n](.*)\"");
#elif defined(Q_WS_X11)
QRegExp regexp("TARGET(\\s*)= (\"?)[^\n](.*)(\"?)");
#else
QRegExp regexp("TARGET(\\s*)= (\"?)[^\n](.*)(\"?)");
#endif
if(tmp.indexOf(regexp) == -1)
{
QMessageBox::critical(this, "Erreur", "Impossible de lancer l'application.");
return;
}
QString line = tmp[tmp.indexOf(regexp)];
QStringList prepath = line.split(QRegExp(" = (\"?)"));
QString path = QFileInfo(projet.pathToProjFile).dir().path() + "/" + prepath[1];
if(path.right(1) == "\"")
path.chop(1);
path.replace("/", "\\");
QProcess *p = new QProcess(this);
p->setWorkingDirectory(pathQt);
p->startDetached(path, QProcess::systemEnvironment(), "");
} |
Partager