diff --git a/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Reflectometry/IReflMainWindowView.h b/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Reflectometry/IReflMainWindowView.h index 55dac0b680e5b91c094aa545afb36a5531f665ee..d53151432840aef7ddb9027be9d33c3bf632a587 100644 --- a/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Reflectometry/IReflMainWindowView.h +++ b/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Reflectometry/IReflMainWindowView.h @@ -52,9 +52,6 @@ public: virtual void giveUserInfo(const std::string &prompt, const std::string &title) = 0; virtual std::string runPythonAlgorithm(const std::string &pythonCode) = 0; - - /// Close window handler - virtual void confirmCloseWindow() = 0; }; } } diff --git a/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Reflectometry/IReflRunsTabPresenter.h b/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Reflectometry/IReflRunsTabPresenter.h index 44337f670fcea46b452770713863d920dd9fe432..28202fe730807f088909b9d3dfb1987607c6700b 100644 --- a/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Reflectometry/IReflRunsTabPresenter.h +++ b/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Reflectometry/IReflRunsTabPresenter.h @@ -46,7 +46,8 @@ public: GroupChangedFlag, PauseReductionFlag, ResumeReductionFlag, - ConfirmReductionPausedFlag + ConfirmReductionPausedFlag, + ConfirmReductionResumedFlag }; // Tell the presenter something happened diff --git a/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Reflectometry/QtReflMainWindowView.h b/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Reflectometry/QtReflMainWindowView.h index d8cf3bd25bb793c8aebba1c533f2517898427e0b..5d810adf83c994dfdcb0359c7e09abedc94ae735 100644 --- a/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Reflectometry/QtReflMainWindowView.h +++ b/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Reflectometry/QtReflMainWindowView.h @@ -67,8 +67,7 @@ public: const std::string &title) override; std::string runPythonAlgorithm(const std::string &pythonCode) override; - /// Close window handlers - void confirmCloseWindow() override; + /// Close window handler void closeEvent(QCloseEvent *event) override; private: diff --git a/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Reflectometry/ReflMainWindowPresenter.h b/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Reflectometry/ReflMainWindowPresenter.h index d1cad87f95277ae2783a0bb2e76a558adb9e03b7..2e1d29daf0181ff8a6989932bce5a3538d8ff3e8 100644 --- a/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Reflectometry/ReflMainWindowPresenter.h +++ b/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Reflectometry/ReflMainWindowPresenter.h @@ -93,10 +93,6 @@ private: void pauseReduction() const; /// Resumes reduction in the Runs Tab void resumeReduction() const; - /// Confirm reduction in the Runs Tab is paused - void confirmReductionPaused() const; - /// Confirm reduction in the Runs Tab is resumed - void confirmReductionResumed() const; /// The view we are handling IReflMainWindowView *m_view; /// The presenter of tab 'Runs' diff --git a/MantidQt/CustomInterfaces/src/Reflectometry/QtReflMainWindowView.cpp b/MantidQt/CustomInterfaces/src/Reflectometry/QtReflMainWindowView.cpp index c3e7b2e211721f1801b52c75d61706d6c805ee00..f657b3e31076ab4788882025ec462c8f93c33a10 100644 --- a/MantidQt/CustomInterfaces/src/Reflectometry/QtReflMainWindowView.cpp +++ b/MantidQt/CustomInterfaces/src/Reflectometry/QtReflMainWindowView.cpp @@ -170,31 +170,16 @@ QtReflMainWindowView::runPythonAlgorithm(const std::string &pythonCode) { return output.toStdString(); } -/** -Ask the user to confirm if they want to close the main window -*/ -void QtReflMainWindowView::confirmCloseWindow() { - - if (askUserYesNo("Runs are still being processed, are you sure you want to " - "close and stop processing?", - "Confirm Close")) - parentWidget()->parentWidget()->parentWidget()->close(); - else - m_presenter->notify(IReflMainWindowPresenter::ResumeReductionFlag); -} - /** Handles attempt to close main window * @param event : [input] The close event */ void QtReflMainWindowView::closeEvent(QCloseEvent *event) { + // Close only if reduction has been paused if (!m_presenter->checkIfProcessing()) { - // No runs are being processed, close window event->accept(); } else { - // Otherwise send message to pause the reduction and store the close event - m_presenter->notify(IReflMainWindowPresenter::PauseReductionFlag); event->ignore(); } } diff --git a/MantidQt/CustomInterfaces/src/Reflectometry/ReflMainWindowPresenter.cpp b/MantidQt/CustomInterfaces/src/Reflectometry/ReflMainWindowPresenter.cpp index fd70891adc5ecb2d74b50ea7159072d197691165..0a765e718cfeda20ce4a768a5c1aa10c5c4a8790 100644 --- a/MantidQt/CustomInterfaces/src/Reflectometry/ReflMainWindowPresenter.cpp +++ b/MantidQt/CustomInterfaces/src/Reflectometry/ReflMainWindowPresenter.cpp @@ -51,10 +51,10 @@ void ReflMainWindowPresenter::notify(IReflMainWindowPresenter::Flag flag) { resumeReduction(); break; case IReflMainWindowPresenter::ConfirmReductionPausedFlag: - confirmReductionPaused(); + m_isProcessing = false; break; case IReflMainWindowPresenter::ConfirmReductionResumedFlag: - confirmReductionResumed(); + m_isProcessing = true; break; } // Not having a 'default' case is deliberate. gcc issues a warning if there's @@ -265,20 +265,5 @@ void ReflMainWindowPresenter::resumeReduction() const { m_isProcessing = true; m_runsPresenter->notify(IReflRunsTabPresenter::ResumeReductionFlag); } - -/** Confirm that reduction in the runs tab has been paused -*/ -void ReflMainWindowPresenter::confirmReductionPaused() const { - - m_isProcessing = false; - m_view->confirmCloseWindow(); -} - -/** Confirm that reduction in the runs tab has been resumed -*/ -void ReflMainWindowPresenter::confirmReductionResumed() const { - - m_isProcessing = true; -} } } diff --git a/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorMainPresenter.h b/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorMainPresenter.h index e68f5f72abb54baedf49f546c0e3384a51412076..526bd373df5d99fc90c6c41fe22b3aa4bdc769b2 100644 --- a/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorMainPresenter.h +++ b/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorMainPresenter.h @@ -74,9 +74,8 @@ public: /// Return time-slicing type virtual std::string getTimeSlicingType() const = 0; - /// Handle data reduction pause confirmation + /// Handle data reduction paused/resumed confirmation virtual void confirmReductionPaused() const = 0; - /// Handle data reduction resume confirmation virtual void confirmReductionResumed() const = 0; }; } diff --git a/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorView.h b/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorView.h index 7c4058bfa07cad326d5aca977564a4f0697dd8ca..8eab04f93bbc11ace1c0cd54c10e68f41033c64b 100644 --- a/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorView.h +++ b/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/DataProcessorView.h @@ -83,6 +83,7 @@ public: int column) = 0; virtual void setClipboard(const std::string &text) = 0; virtual void setModel(const std::string &name) = 0; + virtual void setToolbarActionEnabled(int index, bool enabled) = 0; // Accessor methods virtual std::map<int, std::set<int>> getSelectedChildren() const = 0; diff --git a/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/QDataProcessorWidget.h b/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/QDataProcessorWidget.h index 57c12b6132db183e809d21f36785b29df63bac53..aab10562695a3dcf4dc692172b43e61528421f77 100644 --- a/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/QDataProcessorWidget.h +++ b/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/DataProcessorUI/QDataProcessorWidget.h @@ -85,6 +85,7 @@ public: setOptionsHintStrategy(MantidQt::MantidWidgets::HintStrategy *hintStrategy, int column) override; void setClipboard(const std::string &text) override; + void setToolbarActionEnabled(int index, bool enabled) override; // Accessor methods std::map<int, std::set<int>> getSelectedChildren() const override; diff --git a/MantidQt/MantidWidgets/src/DataProcessorUI/GenericDataProcessorPresenter.cpp b/MantidQt/MantidWidgets/src/DataProcessorUI/GenericDataProcessorPresenter.cpp index 8c6a9ac03b55461b006a1f1b3620a1a8a877da65..b4be2b18f7ef64c5c75021d8413c88301f3153ad 100644 --- a/MantidQt/MantidWidgets/src/DataProcessorUI/GenericDataProcessorPresenter.cpp +++ b/MantidQt/MantidWidgets/src/DataProcessorUI/GenericDataProcessorPresenter.cpp @@ -187,6 +187,9 @@ void GenericDataProcessorPresenter::acceptViews( // Start with a blank table newTable(); + + // Reduction is currently paused + pause(); } /** @@ -220,9 +223,9 @@ void GenericDataProcessorPresenter::process() { m_gqueue.push(std::make_pair(item.first, rowQueue)); } - m_mainPresenter->notify( - DataProcessorMainPresenter::ConfirmReductionResumedFlag); - + m_nextActionFlag = GenericDataProcessorPresenter::ReduceGroupFlag; + resume(); + // Start processing the first group nextGroup(); @@ -969,7 +972,7 @@ void GenericDataProcessorPresenter::notify(DataProcessorPresenter::Flag flag) { collapseAll(); break; case DataProcessorPresenter::PauseFlag: - //pause(); + pause(); break; case DataProcessorPresenter::ResumeFlag: resume(); @@ -1392,6 +1395,9 @@ the current thread for reducing a row or group has finished */ void GenericDataProcessorPresenter::pause() { + // Disable pause button + m_view->setToolbarActionEnabled(1, false); + if (m_reductionPaused) m_mainPresenter->notify( DataProcessorMainPresenter::ConfirmReductionPausedFlag); @@ -1403,9 +1409,11 @@ void GenericDataProcessorPresenter::pause() { */ void GenericDataProcessorPresenter::resume() { - m_reductionPaused = false; + // Enable pause button + m_view->setToolbarActionEnabled(1, true); + m_mainPresenter->notify( - DataProcessorMainPresenter::ConfirmReductionResumedFlag); + DataProcessorMainPresenter::ConfirmReductionPausedFlag); switch (m_nextActionFlag) { case GenericDataProcessorPresenter::ReduceRowFlag: @@ -1415,6 +1423,8 @@ void GenericDataProcessorPresenter::resume() { nextGroup(); break; } + + m_reductionPaused = false; } /** diff --git a/MantidQt/MantidWidgets/src/DataProcessorUI/QDataProcessorWidget.cpp b/MantidQt/MantidWidgets/src/DataProcessorUI/QDataProcessorWidget.cpp index 24a0dfc24b33ffdfbe52e0c9cb095120b873f60d..8153226d165c3441df2dc627c99888c5a4d6b2d4 100644 --- a/MantidQt/MantidWidgets/src/DataProcessorUI/QDataProcessorWidget.cpp +++ b/MantidQt/MantidWidgets/src/DataProcessorUI/QDataProcessorWidget.cpp @@ -322,6 +322,15 @@ void QDataProcessorWidget::setClipboard(const std::string &text) { QApplication::clipboard()->setText(QString::fromStdString(text)); } +/** +Sets a specific action in the row toolbar enabled or disabled +@param index : The index of the action in the toolbar +@param enabled : Whether to enable or disable the action +*/ +void QDataProcessorWidget::setToolbarActionEnabled(int index, bool enabled) { + ui.rowToolBar->actions()[index]->setEnabled(enabled); +} + /** Get the selected instrument for processing @returns the selected instrument to process with