diff --git a/src/job.h b/src/job.h --- a/src/job.h +++ b/src/job.h @@ -49,6 +49,7 @@ * Represents the data the job will have available to perform its task */ Q_PROPERTY(QJsonObject data READ data CONSTANT) +Q_PROPERTY(bool hasProgressInfo READ hasProgressInfo CONSTANT) /** * Returns the output generated by the plugin @@ -71,6 +72,9 @@ QJsonObject output() const; void setOutput(const QJsonObject &output); + bool hasProgressInfo() const; + void setHasProgressInfo(bool hasProgressInfo); + Q_SIGNALS: void outputChanged(const QJsonObject& output); diff --git a/src/job.cpp b/src/job.cpp --- a/src/job.cpp +++ b/src/job.cpp @@ -26,6 +26,7 @@ public: QJsonObject m_data; QJsonObject m_output = { {QStringLiteral("uninitialized"), QStringLiteral("true") } }; + bool hasProgressInfo = false; }; Job::Job(QObject* parent) @@ -64,3 +65,15 @@ Q_EMIT outputChanged(output); } } + +bool Job::hasProgressInfo() const +{ + Q_D(const Job); + return d->hasProgressInfo; +} + +void Job::setHasProgressInfo(bool hasProgressInfo) +{ + Q_D(Job); + d->hasProgressInfo = hasProgressInfo; +} diff --git a/src/plugins/youtube/youtubejobcomposite.cpp b/src/plugins/youtube/youtubejobcomposite.cpp --- a/src/plugins/youtube/youtubejobcomposite.cpp +++ b/src/plugins/youtube/youtubejobcomposite.cpp @@ -42,6 +42,7 @@ YoutubeJobComposite::YoutubeJobComposite() : Purpose::Job() { + setHasProgressInfo(true); } void YoutubeJobComposite::start() diff --git a/src/quick/AlternativesView.qml b/src/quick/AlternativesView.qml --- a/src/quick/AlternativesView.qml +++ b/src/quick/AlternativesView.qml @@ -30,6 +30,7 @@ property Component header property Component footer property variant verticalLayoutDirection: ListView.TopToBottom + property var job property Component delegate: Component { RowLayout { width: parent.width @@ -60,15 +61,20 @@ } function startJob(config) { - var job = config.createJob(); + job = config.createJob(); console.log("run!", runningJobComponent, job) if (!job) { console.warn("couldn't start job") return; } - stack.push(runningJobComponent, { job: job }) + + job.result.connect(jobResult) job.start() - stack.running = true; + + if (job.hasProgressInfo) { + stack.push(runningJobComponent, { job: job }) + stack.running = true; + } } /** @@ -141,12 +147,12 @@ } Component { id: runningJobComponent - RunningJob { - onResult: { - stack.running = false; - stack.finished(job.output, job.error, job.errorString); - stack.pop(); - } - } + RunningJob {} + } + + function jobResult() { + stack.running = false; + stack.finished(job.output, job.error, job.errorString); + stack.pop(); } } diff --git a/src/quick/RunningJob.qml b/src/quick/RunningJob.qml --- a/src/quick/RunningJob.qml +++ b/src/quick/RunningJob.qml @@ -24,16 +24,11 @@ id: root property alias job: conn.target - signal result() - Connections { id: conn onInfoMessage: { info.text = rich ? rich : plain } - onResult: { - root.result(); - } } Label { id: info diff --git a/src/widgets/JobDialog.qml b/src/widgets/JobDialog.qml --- a/src/widgets/JobDialog.qml +++ b/src/widgets/JobDialog.qml @@ -33,6 +33,7 @@ property bool finished: false property var configuration property QtObject q + property var job Component.onCompleted: adoptJob() onConfigurationChanged: adoptJob() @@ -46,17 +47,26 @@ function adoptJob() { if (configuration == null) return; + if (configuration.isReady) { startJob() } else { + window.visible = true view.push(configWizardComponent) } } function startJob() { - var job = window.configuration.createJob(); + job = window.configuration.createJob(); + job.result.connect(jobResult) job.start() - view.push(runningJobComponent, { job: job }) + + if (job.hasProgressInfo) { + window.visible = true + view.push(runningJobComponent, { job: job }) + } else { + window.visible = false + } } StackView { @@ -107,11 +117,11 @@ Component { id: runningJobComponent - RunningJob { - onResult: { - window.q.finished(job.output, job.error, job.errorString); - window.visible = false - } - } + RunningJob {} + } + + function jobResult() { + window.q.finished(job.output, job.error, job.errorString); + window.visible = false } } diff --git a/src/widgets/menu.cpp b/src/widgets/menu.cpp --- a/src/widgets/menu.cpp +++ b/src/widgets/menu.cpp @@ -62,7 +62,6 @@ config->setUseSeparateProcess(false); o->setProperty("configuration", QVariant::fromValue(config)); o->setProperty("q", QVariant::fromValue(q)); - o->setProperty("visible", true); o->setParent(q); }