diff --git a/src/Gui/ProgressDialog.cpp b/src/Gui/ProgressDialog.cpp index 47e84f44b3..da83fd5044 100644 --- a/src/Gui/ProgressDialog.cpp +++ b/src/Gui/ProgressDialog.cpp @@ -22,10 +22,13 @@ #include "PreCompiled.h" -#include -#include -#include -#include +#ifndef _PreComp_ +# include +# include +# include +# include +# include +#endif #include "ProgressDialog.h" #include "MainWindow.h" @@ -41,6 +44,7 @@ struct SequencerDialogPrivate QTime progressTime; QString text; bool guiThread; + bool canabort; }; } @@ -62,6 +66,7 @@ SequencerDialog::SequencerDialog () d->dlg->reset(); // stops the timer to force showing the dialog d->dlg->hide(); d->guiThread = true; + d->canabort = false; } SequencerDialog::~SequencerDialog() @@ -111,6 +116,7 @@ void SequencerDialog::startStep() void SequencerDialog::nextStep(bool canAbort) { + d->canabort = canAbort; QThread *currentThread = QThread::currentThread(); QThread *thr = d->dlg->thread(); // this is the main thread if (thr != currentThread) { @@ -118,7 +124,7 @@ void SequencerDialog::nextStep(bool canAbort) abort(); } else { - setProgress((int)nProgress + 1); + setValue((int)nProgress + 1); } } else { @@ -134,16 +140,22 @@ void SequencerDialog::nextStep(bool canAbort) abort(); } else { rejectCancel(); - setProgress((int)nProgress+1); + setValue((int)nProgress+1); } } else { - setProgress((int)nProgress+1); + setValue((int)nProgress+1); } } } -void SequencerDialog::setProgress(int step) +void SequencerDialog::setProgress(size_t step) +{ + d->dlg->show(); + setValue((int)step); +} + +void SequencerDialog::setValue(int step) { QThread *currentThread = QThread::currentThread(); QThread *thr = d->dlg->thread(); // this is the main thread @@ -237,6 +249,11 @@ void SequencerDialog::resetData() SequencerBase::resetData(); } +bool SequencerDialog::canAbort() const +{ + return d->canabort; +} + void SequencerDialog::abort() { //resets @@ -302,6 +319,9 @@ bool ProgressDialog::canAbort() const void ProgressDialog::showEvent(QShowEvent* ev) { + QPushButton* btn = findChild(); + if (btn) + btn->setEnabled(sequencer->canAbort()); QProgressDialog::showEvent(ev); } diff --git a/src/Gui/ProgressDialog.h b/src/Gui/ProgressDialog.h index 7411c2a275..65751075cd 100644 --- a/src/Gui/ProgressDialog.h +++ b/src/Gui/ProgressDialog.h @@ -43,6 +43,7 @@ public: void pause(); void resume(); bool isBlocking() const; + bool canAbort() const; protected: /** Construction */ @@ -56,6 +57,8 @@ protected: void startStep(); /** Increase the step indicator of the progress dialog. */ void nextStep(bool canAbort); + /** Sets the progress indicator to a certain position. */ + void setProgress(size_t); /** Resets the sequencer */ void resetData(); void showRemainingTime(); @@ -63,7 +66,7 @@ protected: private: /** @name for internal use only */ //@{ - void setProgress(int step); + void setValue(int step); /** Throws an exception to stop the pending operation. */ void abort(); //@}