mirror of
https://github.com/QuasarApp/CQtDeployer.git
synced 2025-04-28 18:54:33 +00:00
added qt application for cqtdeployer process
This commit is contained in:
parent
3d3f26973c
commit
68df18719b
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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();
|
||||
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user