Commit 044f017f authored by Jan Möbius's avatar Jan Möbius
Browse files

Martin Heistermann:

Patch to enable process support without GUI
closes #988

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@14979 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 4fd29369
...@@ -71,46 +71,49 @@ void Core::slotStartJob( QString _jobId, QString _description , int _min , int _ ...@@ -71,46 +71,49 @@ void Core::slotStartJob( QString _jobId, QString _description , int _min , int _
info->minSteps = _min; info->minSteps = _min;
info->maxSteps = _max; info->maxSteps = _max;
info->blocking = _blocking; info->blocking = _blocking;
info->blockingWidget = 0;
// Add job to local job list // Add job to local job list
currentJobs.push_back(info); currentJobs.push_back(info);
// Don't show process status in process manager if (OpenFlipper::Options::gui()) {
// if blocking is enabled // Don't show process status in process manager
if(_blocking) { // if blocking is enabled
// Create blocking widget if(_blocking) {
BlockingWidget* widget = new BlockingWidget(_jobId, _description, // Create blocking widget
_min, _max); BlockingWidget* widget = new BlockingWidget(_jobId, _description,
_min, _max);
// Connect cancel button to local slot for further treatment // Connect cancel button to local slot for further treatment
connect(widget, SIGNAL(cancelRequested(QString)), connect(widget, SIGNAL(cancelRequested(QString)),
this, SLOT(slotJobCancelRequested(QString))); this, SLOT(slotJobCancelRequested(QString)));
info->blockingWidget = widget; info->blockingWidget = widget;
int x = (coreWidget_->width() / 2) - (widget->width() / 2); int x = (coreWidget_->width() / 2) - (widget->width() / 2);
int y = (coreWidget_->height() / 2) - (widget->height() / 2); int y = (coreWidget_->height() / 2) - (widget->height() / 2);
widget->setGeometry( x, y, widget->width(), widget->height()); widget->setGeometry( x, y, widget->width(), widget->height());
// Show blocking widget // Show blocking widget
widget->show(); widget->show();
} else { } else {
// Create process manager window if it has not been created before // Create process manager window if it has not been created before
if(!processManager_) { if(!processManager_) {
processManager_ = new ProcessManagerWidget(); processManager_ = new ProcessManagerWidget();
// Connect cancel buttons to local slot for further treatment // Connect cancel buttons to local slot for further treatment
connect(processManager_, SIGNAL(cancelJobRequested(QString)), connect(processManager_, SIGNAL(cancelJobRequested(QString)),
this, SLOT(slotJobCancelRequested(QString))); this, SLOT(slotJobCancelRequested(QString)));
} }
// Add new item // Add new item
processManager_->addJob(_jobId, _description, _min, _max); processManager_->addJob(_jobId, _description, _min, _max);
// Show window // Show window
processManager_->show(); processManager_->show();
}
} }
} }
...@@ -138,6 +141,8 @@ void Core::slotSetJobState(QString _jobId, int _value ) { ...@@ -138,6 +141,8 @@ void Core::slotSetJobState(QString _jobId, int _value ) {
if ( getJob(_jobId, id) ) { if ( getJob(_jobId, id) ) {
currentJobs[id]->currentStep = _value; currentJobs[id]->currentStep = _value;
if (!OpenFlipper::Options::gui())
return;
// Update gui // Update gui
if(!currentJobs[id]->blocking) if(!currentJobs[id]->blocking)
processManager_->updateStatus(_jobId, _value); processManager_->updateStatus(_jobId, _value);
...@@ -160,6 +165,8 @@ void Core::slotSetJobName(QString _jobId, QString _name ) { ...@@ -160,6 +165,8 @@ void Core::slotSetJobName(QString _jobId, QString _name ) {
if ( getJob(_jobId, id) ) { if ( getJob(_jobId, id) ) {
currentJobs[id]->id = _name; currentJobs[id]->id = _name;
if (!OpenFlipper::Options::gui())
return;
// Update gui // Update gui
if(!currentJobs[id]->blocking) if(!currentJobs[id]->blocking)
processManager_->setJobName(_jobId, _name); processManager_->setJobName(_jobId, _name);
...@@ -181,6 +188,8 @@ void Core::slotSetJobDescription(QString _jobId, QString _text ) { ...@@ -181,6 +188,8 @@ void Core::slotSetJobDescription(QString _jobId, QString _text ) {
if ( getJob(_jobId, id) ) { if ( getJob(_jobId, id) ) {
currentJobs[id]->description = _text; currentJobs[id]->description = _text;
if (!OpenFlipper::Options::gui())
return;
// Update gui // Update gui
if(!currentJobs[id]->blocking) if(!currentJobs[id]->blocking)
processManager_->setJobDescription(_jobId, _text); processManager_->setJobDescription(_jobId, _text);
...@@ -202,17 +211,19 @@ void Core::slotCancelJob(QString _jobId ) { ...@@ -202,17 +211,19 @@ void Core::slotCancelJob(QString _jobId ) {
if ( getJob(_jobId, id) ) { if ( getJob(_jobId, id) ) {
// Update gui if (OpenFlipper::Options::gui()) {
if(!currentJobs[id]->blocking) // Update gui
processManager_->removeJob(_jobId); if(!currentJobs[id]->blocking)
else { processManager_->removeJob(_jobId);
BlockingWidget* w = 0; else {
w = dynamic_cast<BlockingWidget*>(currentJobs[id]->blockingWidget); BlockingWidget* w = 0;
if(w != 0) { w = dynamic_cast<BlockingWidget*>(currentJobs[id]->blockingWidget);
w->hide(); if(w != 0) {
delete w; w->hide();
} delete w;
} }
}
}
currentJobs.removeAt(id); currentJobs.removeAt(id);
} }
...@@ -226,21 +237,23 @@ void Core::slotFinishJob(QString _jobId ) { ...@@ -226,21 +237,23 @@ void Core::slotFinishJob(QString _jobId ) {
if ( getJob(_jobId, id) ) { if ( getJob(_jobId, id) ) {
// Update gui if (OpenFlipper::Options::gui()) {
if(!currentJobs[id]->blocking) { // Update gui
processManager_->removeJob(_jobId); if(!currentJobs[id]->blocking) {
processManager_->removeJob(_jobId);
// Hide widget if there's no job left
if(processManager_->getNumJobs() == 0) processManager_->hide(); // Hide widget if there's no job left
if(processManager_->getNumJobs() == 0) processManager_->hide();
} else {
BlockingWidget* w = 0; } else {
w = dynamic_cast<BlockingWidget*>(currentJobs[id]->blockingWidget); BlockingWidget* w = 0;
if(w != 0) { w = dynamic_cast<BlockingWidget*>(currentJobs[id]->blockingWidget);
w->hide(); if(w != 0) {
delete w; w->hide();
} delete w;
} }
}
}
currentJobs.removeAt(id); currentJobs.removeAt(id);
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment