From 31d3f56b0e09d96e1ea71bedac8ee9077dafbe76 Mon Sep 17 00:00:00 2001
From: Gemma Guest <gemma.guest@stfc.ac.uk>
Date: Fri, 16 Aug 2019 17:01:33 +0100
Subject: [PATCH] Add tools menu to main window menu bar

Add menu items for showing the Options dialog and the Slit Calculator
tool.

Re #26533
---
 .../GUI/MainWindow/IMainWindowView.h          |  2 ++
 .../GUI/MainWindow/MainWindowPresenter.cpp    |  4 +++
 .../GUI/MainWindow/MainWindowPresenter.h      |  2 ++
 .../GUI/MainWindow/MainWindowWidget.ui        | 28 +++++++++++++++----
 .../GUI/MainWindow/QtMainWindowView.cpp       | 12 ++++++++
 .../GUI/MainWindow/QtMainWindowView.h         |  2 ++
 6 files changed, 45 insertions(+), 5 deletions(-)

diff --git a/qt/scientific_interfaces/ISISReflectometry/GUI/MainWindow/IMainWindowView.h b/qt/scientific_interfaces/ISISReflectometry/GUI/MainWindow/IMainWindowView.h
index d7885459759..84e931e7790 100644
--- a/qt/scientific_interfaces/ISISReflectometry/GUI/MainWindow/IMainWindowView.h
+++ b/qt/scientific_interfaces/ISISReflectometry/GUI/MainWindow/IMainWindowView.h
@@ -29,6 +29,8 @@ public:
   virtual void notifyCloseBatchRequested(int) = 0;
   virtual void notifySaveBatchRequested(int) = 0;
   virtual void notifyLoadBatchRequested(int) = 0;
+  virtual void notifyShowOptionsRequested() = 0;
+  virtual void notifyShowSlitCalculatorRequested() = 0;
   virtual ~MainWindowSubscriber() = default;
 };
 
diff --git a/qt/scientific_interfaces/ISISReflectometry/GUI/MainWindow/MainWindowPresenter.cpp b/qt/scientific_interfaces/ISISReflectometry/GUI/MainWindow/MainWindowPresenter.cpp
index 8e5fba32eee..f705a96d57f 100644
--- a/qt/scientific_interfaces/ISISReflectometry/GUI/MainWindow/MainWindowPresenter.cpp
+++ b/qt/scientific_interfaces/ISISReflectometry/GUI/MainWindow/MainWindowPresenter.cpp
@@ -77,6 +77,10 @@ void MainWindowPresenter::notifyCloseBatchRequested(int batchIndex) {
   }
 }
 
+void MainWindowPresenter::notifyShowOptionsRequested() {}
+
+void MainWindowPresenter::notifyShowSlitCalculatorRequested() {}
+
 void MainWindowPresenter::notifyAnyBatchAutoreductionResumed() {
   for (const auto &batchPresenter : m_batchPresenters) {
     batchPresenter->notifyAnyBatchAutoreductionResumed();
diff --git a/qt/scientific_interfaces/ISISReflectometry/GUI/MainWindow/MainWindowPresenter.h b/qt/scientific_interfaces/ISISReflectometry/GUI/MainWindow/MainWindowPresenter.h
index 52b32f7f589..f7703674a97 100644
--- a/qt/scientific_interfaces/ISISReflectometry/GUI/MainWindow/MainWindowPresenter.h
+++ b/qt/scientific_interfaces/ISISReflectometry/GUI/MainWindow/MainWindowPresenter.h
@@ -60,6 +60,8 @@ public:
   void notifyCloseBatchRequested(int batchIndex) override;
   void notifySaveBatchRequested(int batchIndex) override;
   void notifyLoadBatchRequested(int batchIndex) override;
+  void notifyShowOptionsRequested() override;
+  void notifyShowSlitCalculatorRequested() override;
 
 protected:
   IMainWindowView *m_view;
diff --git a/qt/scientific_interfaces/ISISReflectometry/GUI/MainWindow/MainWindowWidget.ui b/qt/scientific_interfaces/ISISReflectometry/GUI/MainWindow/MainWindowWidget.ui
index b62220972d6..2f82e5a5491 100644
--- a/qt/scientific_interfaces/ISISReflectometry/GUI/MainWindow/MainWindowWidget.ui
+++ b/qt/scientific_interfaces/ISISReflectometry/GUI/MainWindow/MainWindowWidget.ui
@@ -67,25 +67,43 @@
      <height>31</height>
     </rect>
    </property>
-   <widget class="QMenu" name="menuReflectometry">
+   <widget class="QMenu" name="menuBatch">
     <property name="title">
-     <string>Batch</string>
+     <string>&amp;Batch</string>
     </property>
     <addaction name="newBatch"/>
     <addaction name="separator"/>
     <addaction name="loadBatch"/>
     <addaction name="saveBatch"/>
    </widget>
-   <addaction name="menuReflectometry"/>
+   <widget class="QMenu" name="menuTools">
+    <property name="title">
+     <string>&amp;Tools</string>
+    </property>
+    <addaction name="showOptions"/>
+    <addaction name="showSlitCalculator"/>
+   </widget>
+   <addaction name="menuBatch"/>
+   <addaction name="menuTools"/>
   </widget>
   <action name="newBatch">
    <property name="text">
-    <string>New</string>
+    <string>&amp;New</string>
    </property>
   </action>
   <action name="loadBatch">
    <property name="text">
-    <string>Load</string>
+    <string>&amp;Load</string>
+   </property>
+  </action>
+  <action name="showOptions">
+   <property name="text">
+    <string>&amp;Options</string>
+   </property>
+  </action>
+  <action name="showSlitCalculator">
+   <property name="text">
+    <string>&amp;Slit Calculator</string>
    </property>
   </action>
   <action name="saveBatch">
diff --git a/qt/scientific_interfaces/ISISReflectometry/GUI/MainWindow/QtMainWindowView.cpp b/qt/scientific_interfaces/ISISReflectometry/GUI/MainWindow/QtMainWindowView.cpp
index bc16c9cb993..59be273fcb1 100644
--- a/qt/scientific_interfaces/ISISReflectometry/GUI/MainWindow/QtMainWindowView.cpp
+++ b/qt/scientific_interfaces/ISISReflectometry/GUI/MainWindow/QtMainWindowView.cpp
@@ -62,6 +62,10 @@ void QtMainWindowView::initLayout() {
           SLOT(onLoadBatchRequested(bool)));
   connect(m_ui.saveBatch, SIGNAL(triggered(bool)), this,
           SLOT(onSaveBatchRequested(bool)));
+  connect(m_ui.showOptions, SIGNAL(triggered(bool)), this,
+          SLOT(onShowOptionsRequested(bool)));
+  connect(m_ui.showSlitCalculator, SIGNAL(triggered(bool)), this,
+          SLOT(onShowSlitCalculatorRequested(bool)));
 
   auto instruments = std::vector<std::string>(
       {{"INTER", "SURF", "CRISP", "POLREF", "OFFSPEC"}});
@@ -114,6 +118,14 @@ void QtMainWindowView::onSaveBatchRequested(bool) {
   m_notifyee->notifySaveBatchRequested(m_ui.mainTabs->currentIndex());
 }
 
+void QtMainWindowView::onShowOptionsRequested(bool) {
+  m_notifyee->notifyShowOptionsRequested();
+}
+
+void QtMainWindowView::onShowSlitCalculatorRequested(bool) {
+  m_notifyee->notifyShowSlitCalculatorRequested();
+}
+
 void QtMainWindowView::subscribe(MainWindowSubscriber *notifyee) {
   m_notifyee = notifyee;
 }
diff --git a/qt/scientific_interfaces/ISISReflectometry/GUI/MainWindow/QtMainWindowView.h b/qt/scientific_interfaces/ISISReflectometry/GUI/MainWindow/QtMainWindowView.h
index 400af1ad752..550abdcf358 100644
--- a/qt/scientific_interfaces/ISISReflectometry/GUI/MainWindow/QtMainWindowView.h
+++ b/qt/scientific_interfaces/ISISReflectometry/GUI/MainWindow/QtMainWindowView.h
@@ -65,6 +65,8 @@ public slots:
   void onNewBatchRequested(bool);
   void onLoadBatchRequested(bool);
   void onSaveBatchRequested(bool);
+  void onShowOptionsRequested(bool);
+  void onShowSlitCalculatorRequested(bool);
 
 private:
   /// Initializes the interface
-- 
GitLab