added qt application for cqtdeployer process

This commit is contained in:
Andrei Yankovich 2020-01-20 13:24:01 +03:00
parent 3d3f26973c
commit 68df18719b
5 changed files with 61 additions and 21 deletions

View File

@ -32,7 +32,7 @@ int main(int argc, char *argv[]) {
QCoreApplication app(argc, argv);
Deploy deploy;
if (deploy.run()) {
if (deploy.run(true)) {
app.exit(1);
}

View File

@ -18,22 +18,16 @@ Deploy::Deploy() {
_packing = new Packing();
_paramsParser = new ConfigParser(_fileManager, _scaner, _packing);
connect(this, &Deploy::sigStart, this, &Deploy::handleStart, Qt::QueuedConnection);
}
int Deploy::run() {
if (!prepare()) {
return 1;
int Deploy::run(bool async) {
if (async) {
emit sigStart();
return 0;
}
if (!deploy()) {
return 2;
}
if (!packing())
return 3;
return 0;
return runPrivate();
}
Deploy::~Deploy() {
@ -86,7 +80,31 @@ bool Deploy::deploy() {
return true;
}
bool Deploy::packing() {
bool Deploy::packing(bool async) {
if (async) {
connect(_packing, &Packing::sigFinished, this, &Deploy::sigFinish, Qt::QueuedConnection);
}
return _packing->create();
return _packing->create(async);
}
int Deploy::runPrivate(bool async) {
if (!prepare()) {
return 1;
}
if (!deploy()) {
return 2;
}
if (!packing(async))
return 3;
return 0;
}
void Deploy::handleStart() {
if (int exit = runPrivate(true)) {
emit sigFinish(exit);
}
}

View File

@ -10,14 +10,17 @@
#include "deploy_global.h"
#include <QObject>
class ConfigParser;
class Extracter;
class FileManager;
class DependenciesScanner;
class Packing;
class DEPLOYSHARED_EXPORT Deploy
class DEPLOYSHARED_EXPORT Deploy : public QObject
{
Q_OBJECT
private:
ConfigParser * _paramsParser = nullptr;
@ -28,11 +31,19 @@ private:
bool prepare();
bool deploy();
bool packing();
bool packing(bool async);
int runPrivate(bool async = false);
private slots:
void handleStart();
signals:
void sigFinish(int code);
void sigStart();
public:
Deploy();
int run();
int run(bool async = false);
~Deploy();

View File

@ -15,6 +15,9 @@ Packing::Packing() {
connect(_proc, &QProcess::readyReadStandardOutput,
this, &Packing::handleOutputUpdate, Qt::QueuedConnection);
connect(_proc, qOverload<int, QProcess::ExitStatus>(&QProcess::finished),
this, &Packing::handleFinished, Qt::QueuedConnection);
moveToThread( new QThread(this));
}
@ -26,7 +29,7 @@ void Packing::setDistribution(iDistribution *pakage) {
_pakage = pakage;
}
bool Packing::create() {
bool Packing::create(bool async) {
if (!_pakage)
return false;
@ -50,7 +53,7 @@ bool Packing::create() {
return false;
}
if (!_proc->waitForFinished(-1)) {
if (async && !_proc->waitForFinished(-1)) {
return false;
}
@ -80,3 +83,7 @@ void Packing::handleOutputUpdate() {
qInfo() << erroutLog;
}
void Packing::handleFinished(int exitCode, QProcess::ExitStatus ) {
emit sigFinished(exitCode);
}

View File

@ -21,13 +21,17 @@ public:
Packing();
~Packing();
void setDistribution(iDistribution *pakage);
bool create();
bool create(bool async);
private:
iDistribution *_pakage = nullptr;
QProcess *_proc = nullptr;
private slots:
void handleOutputUpdate();
void handleFinished(int exitCode, QProcess::ExitStatus);
signals:
void sigFinished(int code);
};
#endif // PACKING_H