|
@@ -1,6 +1,9 @@
|
|
|
#include "mainwindow.h"
|
|
|
#include "ui_mainwindow.h"
|
|
|
|
|
|
+#include <QFile>
|
|
|
+#include <iostream>
|
|
|
+#include <QFileDialog>
|
|
|
|
|
|
MainWindow::MainWindow(QWidget *parent)
|
|
|
: QMainWindow(parent)
|
|
@@ -10,7 +13,16 @@ MainWindow::MainWindow(QWidget *parent)
|
|
|
|
|
|
setWindowTitle("IV Make Tool");
|
|
|
|
|
|
- ThreadFindQMake * px = new ThreadFindQMake();
|
|
|
+ ui->lineEdit_qmakepath->setText("qmake");
|
|
|
+
|
|
|
+ mstrqmakepath = "./findqmake.sh";
|
|
|
+ QStringList arg;
|
|
|
+ arg.append(mstrqmakepath);
|
|
|
+ marg_proc = arg;
|
|
|
+ connect(&mProc,SIGNAL(readyReadStandardOutput()),this,SLOT(onReadStandardOutput()));
|
|
|
+ connect(&mProc,SIGNAL(readyReadStandardError()),this,SLOT(onReadStandardError()));
|
|
|
+ connect(&mProc,SIGNAL(finished(int)),this,SLOT(onfinish()));
|
|
|
+ Checkqmakesh();
|
|
|
}
|
|
|
|
|
|
MainWindow::~MainWindow()
|
|
@@ -22,5 +34,126 @@ MainWindow::~MainWindow()
|
|
|
void MainWindow::on_pushButton_findqmake_clicked()
|
|
|
{
|
|
|
ui->pushButton_findqmake->setEnabled(false);
|
|
|
+ mProc.start("/bin/bash",marg_proc);
|
|
|
+ mstrfindqmake = "";
|
|
|
+}
|
|
|
+
|
|
|
+void MainWindow::onReadStandardOutput()
|
|
|
+{
|
|
|
+ QProcess * proc = (QProcess *)sender();
|
|
|
+ QByteArray ba = proc->readAllStandardOutput();
|
|
|
+ // qDebug("out:");
|
|
|
+ mstrfindqmake = mstrfindqmake + QString(ba);
|
|
|
+// qDebug("%s",ba.toStdString().data());
|
|
|
+}
|
|
|
+
|
|
|
+void MainWindow::onReadStandardError()
|
|
|
+{
|
|
|
+ // QProcess * proc = (QProcess *)sender();
|
|
|
+ // QByteArray ba = proc->readAllStandardError();
|
|
|
+ // QString str = QString(ba);
|
|
|
+ // qDebug("error: %s",str.toLatin1().data());
|
|
|
+}
|
|
|
+
|
|
|
+void MainWindow::Checkqmakesh()
|
|
|
+{
|
|
|
+ QFile xFile;
|
|
|
+ xFile.setFileName(mstrqmakepath);
|
|
|
+ if(xFile.exists())
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ // qDebug("not found findqmake.sh.");
|
|
|
+ std::cout<<"not found findqmake.sh. so use res file creat one."<<std::endl;
|
|
|
+ QFile xFileres;
|
|
|
+ xFileres.setFileName(":/findqmake.sh");
|
|
|
+ if(xFileres.open(QIODevice::ReadOnly))
|
|
|
+ {
|
|
|
+ std::cout<<" open file success."<<std::endl;
|
|
|
+ QByteArray ba = xFileres.readAll();
|
|
|
+ if(xFile.open(QIODevice::ReadWrite))
|
|
|
+ {
|
|
|
+ xFile.write(ba);
|
|
|
+ xFile.close();
|
|
|
+ std::cout<<" create findqmake.sh success. "<<std::endl;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ std::cout<<" can't create findqmake.sh."<<std::endl;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ std::cout<<" open rc file findqmake.sh fail."<<std::endl;
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+void MainWindow::onfinish()
|
|
|
+{
|
|
|
+ ui->pushButton_findqmake->setEnabled(true);
|
|
|
+// qDebug("outputs:\n %s",mstrfindqmake.toLatin1().data());
|
|
|
+
|
|
|
+ QByteArray ba = QByteArray(mstrfindqmake.toLatin1().data());
|
|
|
+ QList<QByteArray> balist = ba.split('\n');
|
|
|
+// qDebug("ba len %d",balist.size());
|
|
|
+
|
|
|
+ int nsize = static_cast<int>(balist.size());
|
|
|
+ int i;
|
|
|
+ for(i=0;i<nsize;i++)
|
|
|
+ {
|
|
|
+ QString strline = QString(balist[i]);
|
|
|
+ if(strline.indexOf("---qmake---:")>=0)
|
|
|
+ {
|
|
|
+ std::cout<<" find qmake."<<std::endl;
|
|
|
+ QString strqmake = strline.mid(12);
|
|
|
+ std::cout<<" qmake path: "<<strqmake.toLatin1().data()<<std::endl;
|
|
|
+ ui->lineEdit_qmakepath->setText(strqmake);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+void MainWindow::on_pushButton_SelectPro_clicked()
|
|
|
+{
|
|
|
+ QString str = QFileDialog::getOpenFileName(this,tr("Please Select .pro file"),".","*.pro");
|
|
|
+
|
|
|
+ if(str.isEmpty())return;
|
|
|
+
|
|
|
+
|
|
|
+ ui->pushButton_SelectPro->setEnabled(false);
|
|
|
+
|
|
|
+
|
|
|
+ BuildProgram(str);
|
|
|
+}
|
|
|
+
|
|
|
+void MainWindow::BuildProgram(QString & strpropath)
|
|
|
+{
|
|
|
+ MakeBuildSH(strpropath);
|
|
|
+ //make build sh
|
|
|
+
|
|
|
+ //build
|
|
|
+}
|
|
|
+
|
|
|
+QString MainWindow::MakeBuildSH(QString & strpropath)
|
|
|
+{
|
|
|
+ int64_t nnow = std::chrono::system_clock::now().time_since_epoch().count();
|
|
|
+ char strpath[1000];
|
|
|
+ snprintf(strpath,1000,"%lld.sh",nnow);
|
|
|
+ QString strshpath = QString(strpath);
|
|
|
+ int npos = strpropath.lastIndexOf('/');
|
|
|
+ if(npos < 0)
|
|
|
+ {
|
|
|
+ std::cout<<" find folder fail."<<std::endl;
|
|
|
+ return QString("");
|
|
|
+ }
|
|
|
+ QString strprodir = strpropath.left(npos);
|
|
|
+ std::cout<<" dir path: "<<strprodir.toLatin1().data()<<std::endl;
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
|