Skip to content
Snippets Groups Projects
Commit 8bfd422f authored by Gemma Guest's avatar Gemma Guest
Browse files

Don't close tab if processing

Re #26025
parent f8d40877
No related branches found
No related tags found
No related merge requests found
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
// & Institut Laue - Langevin // & Institut Laue - Langevin
// SPDX - License - Identifier: GPL - 3.0 + // SPDX - License - Identifier: GPL - 3.0 +
#include "MainWindowPresenter.h" #include "MainWindowPresenter.h"
#include "GUI/Common/IMessageHandler.h"
#include "GUI/Runs/IRunsPresenter.h" #include "GUI/Runs/IRunsPresenter.h"
#include "IMainWindowView.h" #include "IMainWindowView.h"
#include "MantidQtWidgets/Common/HelpWindow.h" #include "MantidQtWidgets/Common/HelpWindow.h"
...@@ -21,8 +22,10 @@ namespace CustomInterfaces { ...@@ -21,8 +22,10 @@ namespace CustomInterfaces {
* we will manage * we will manage
*/ */
MainWindowPresenter::MainWindowPresenter( MainWindowPresenter::MainWindowPresenter(
IMainWindowView *view, BatchPresenterFactory batchPresenterFactory) IMainWindowView *view, IMessageHandler *messageHandler,
: m_view(view), m_batchPresenterFactory(std::move(batchPresenterFactory)) { BatchPresenterFactory batchPresenterFactory)
: m_view(view), m_messageHandler(messageHandler),
m_batchPresenterFactory(std::move(batchPresenterFactory)) {
view->subscribe(this); view->subscribe(this);
for (auto *batchView : m_view->batches()) for (auto *batchView : m_view->batches())
addNewBatch(batchView); addNewBatch(batchView);
...@@ -34,6 +37,14 @@ void MainWindowPresenter::notifyNewBatchRequested() { ...@@ -34,6 +37,14 @@ void MainWindowPresenter::notifyNewBatchRequested() {
} }
void MainWindowPresenter::notifyCloseBatchRequested(int batchIndex) { void MainWindowPresenter::notifyCloseBatchRequested(int batchIndex) {
if (m_batchPresenters[batchIndex]->isAutoreducing() ||
m_batchPresenters[batchIndex]->isProcessing()) {
m_messageHandler->giveUserCritical(
"Cannot close batch while processing or autoprocessing is in progress",
"Error");
return;
}
if (m_batchPresenters[batchIndex]->requestClose()) { if (m_batchPresenters[batchIndex]->requestClose()) {
m_batchPresenters.erase(m_batchPresenters.begin() + batchIndex); m_batchPresenters.erase(m_batchPresenters.begin() + batchIndex);
m_view->removeBatch(batchIndex); m_view->removeBatch(batchIndex);
......
...@@ -17,6 +17,7 @@ namespace MantidQt { ...@@ -17,6 +17,7 @@ namespace MantidQt {
namespace CustomInterfaces { namespace CustomInterfaces {
class IMainWindowView; class IMainWindowView;
class IMessageHandler;
/** @class MainWindowPresenter /** @class MainWindowPresenter
...@@ -28,7 +29,7 @@ class MANTIDQT_ISISREFLECTOMETRY_DLL MainWindowPresenter ...@@ -28,7 +29,7 @@ class MANTIDQT_ISISREFLECTOMETRY_DLL MainWindowPresenter
public IMainWindowPresenter { public IMainWindowPresenter {
public: public:
/// Constructor /// Constructor
MainWindowPresenter(IMainWindowView *view, MainWindowPresenter(IMainWindowView *view, IMessageHandler *messageHandler,
BatchPresenterFactory batchPresenterFactory); BatchPresenterFactory batchPresenterFactory);
// IMainWindowPresenter overrides // IMainWindowPresenter overrides
...@@ -47,6 +48,7 @@ private: ...@@ -47,6 +48,7 @@ private:
void addNewBatch(IBatchView *batchView); void addNewBatch(IBatchView *batchView);
IMainWindowView *m_view; IMainWindowView *m_view;
IMessageHandler *m_messageHandler;
BatchPresenterFactory m_batchPresenterFactory; BatchPresenterFactory m_batchPresenterFactory;
std::vector<std::shared_ptr<IBatchPresenter>> m_batchPresenters; std::vector<std::shared_ptr<IBatchPresenter>> m_batchPresenters;
}; };
......
...@@ -91,14 +91,14 @@ void MainWindowView::initLayout() { ...@@ -91,14 +91,14 @@ void MainWindowView::initLayout() {
// Create the presenter // Create the presenter
m_presenter = std::make_unique<MainWindowPresenter>( m_presenter = std::make_unique<MainWindowPresenter>(
this, std::move(makeBatchPresenter)); this, messageHandler, std::move(makeBatchPresenter));
m_notifyee->notifyNewBatchRequested(); m_notifyee->notifyNewBatchRequested();
m_notifyee->notifyNewBatchRequested(); m_notifyee->notifyNewBatchRequested();
} }
void MainWindowView::onTabCloseRequested(int tabIndex) { void MainWindowView::onTabCloseRequested(int tabIndex) {
m_ui.mainTabs->removeTab(tabIndex); m_notifyee->notifyCloseBatchRequested(tabIndex);
} }
void MainWindowView::onNewBatchRequested(bool) { void MainWindowView::onNewBatchRequested(bool) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment