#ifndef CPROGRESSDIALOG_H #define CPROGRESSDIALOG_H #include "IProgressNotifierUI.h" #include "UICommon.h" #include #include #include #include #include #ifdef WIN32 #include #include #endif namespace Ui { class CProgressDialog; } class CProgressDialog : public IProgressNotifierUI { Q_OBJECT Ui::CProgressDialog *mpUI; bool mUseBusyIndicator; bool mAlertOnFinish; bool mFinished; bool mCanceled; #ifdef WIN32 QWinTaskbarProgress *mpTaskbarProgress; #endif public: explicit CProgressDialog(QString OperationName, bool UseBusyIndicator, bool AlertOnFinish, QWidget *pParent = 0); ~CProgressDialog(); void DisallowCanceling(); // IProgressNotifier interface virtual bool ShouldCancel() const; // Slots public slots: void closeEvent(QCloseEvent *pEvent); void FinishAndClose(); void CancelButtonClicked(); void UpdateUI(const QString& rkTaskDesc, const QString& rkStepDesc, float ProgressPercent); // Results protected: template void InternalWaitForResults(QFuture Future) { gpEdApp->SetEditorTicksEnabled(false); QFutureWatcher Watcher; connect(&Watcher, SIGNAL(finished()), this, SLOT(FinishAndClose())); Watcher.setFuture(Future); exec(); gpEdApp->SetEditorTicksEnabled(true); if (mAlertOnFinish) gpEdApp->alert(parentWidget()); } public: template RetType WaitForResults(QFuture Future) { InternalWaitForResults(Future); return Future.result(); } }; template<> inline void CProgressDialog::WaitForResults(QFuture Future) { InternalWaitForResults(Future); } #endif // CPROGRESSDIALOG_H