From 4724bb6f97ddc2b6c3a37cce844d24d31216224d Mon Sep 17 00:00:00 2001 From: Harry Jeffery Date: Wed, 22 Oct 2014 09:20:11 +0100 Subject: [PATCH] Refs #10376 Try creating menu bar programatically --- .../MantidQtCustomInterfaces/QtReflMainView.h | 1 + .../ReflMainWidget.ui | 32 ------------------- .../CustomInterfaces/src/QtReflMainView.cpp | 22 ++++++++++--- 3 files changed, 18 insertions(+), 37 deletions(-) diff --git a/Code/Mantid/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/QtReflMainView.h b/Code/Mantid/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/QtReflMainView.h index f8ede7178af7..fe3a5f714157 100644 --- a/Code/Mantid/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/QtReflMainView.h +++ b/Code/Mantid/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/QtReflMainView.h @@ -81,6 +81,7 @@ namespace MantidQt boost::shared_ptr m_presenter; //the interface Ui::reflMainWidget ui; + QMenu* m_openMenu; //the workspace the user selected to open std::string m_toOpen; QSignalMapper* m_openMap; diff --git a/Code/Mantid/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/ReflMainWidget.ui b/Code/Mantid/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/ReflMainWidget.ui index 961e5271ff19..dd1e6f87501b 100644 --- a/Code/Mantid/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/ReflMainWidget.ui +++ b/Code/Mantid/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/ReflMainWidget.ui @@ -366,38 +366,6 @@ - - - - 0 - 0 - 825 - 23 - - - - false - - - - Table - - - - Open Table - - - - :/multiload.png:/multiload.png - - - - - - - - - diff --git a/Code/Mantid/MantidQt/CustomInterfaces/src/QtReflMainView.cpp b/Code/Mantid/MantidQt/CustomInterfaces/src/QtReflMainView.cpp index 47ecd67b4192..cbb6bb522c79 100644 --- a/Code/Mantid/MantidQt/CustomInterfaces/src/QtReflMainView.cpp +++ b/Code/Mantid/MantidQt/CustomInterfaces/src/QtReflMainView.cpp @@ -3,8 +3,12 @@ #include "MantidQtCustomInterfaces/ReflMainViewPresenter.h" #include "MantidAPI/ITableWorkspace.h" #include "MantidKernel/ConfigService.h" -#include -#include + +#include +#include +#include +#include +#include namespace MantidQt { @@ -17,7 +21,7 @@ namespace MantidQt //---------------------------------------------------------------------------------------------- /** Constructor */ - QtReflMainView::QtReflMainView(QWidget *parent) : UserSubWindow(parent), m_openMap(new QSignalMapper(this)) + QtReflMainView::QtReflMainView(QWidget *parent) : UserSubWindow(parent), m_openMenu(0), m_openMap(new QSignalMapper(this)) { } @@ -58,6 +62,14 @@ namespace MantidQt connect(ui.actionProcess, SIGNAL(triggered()), this, SLOT(actionProcess())); connect(ui.actionGroupRows, SIGNAL(triggered()), this, SLOT(actionGroupRows())); + //Create a menu bar + QMenuBar* menuBar = new QMenuBar(this); + QMenu* tableMenu = menuBar->addMenu("Table"); + m_openMenu = tableMenu->addMenu("Open Menu..."); + tableMenu->addAction(ui.actionNewTable); + tableMenu->addAction(ui.actionSaveTable); + tableMenu->addAction(ui.actionSaveTableAs); + //Finally, create a presenter to do the thinking for us m_presenter = boost::shared_ptr(new ReflMainViewPresenter(this)); } @@ -88,11 +100,11 @@ namespace MantidQt */ void QtReflMainView::setTableList(const std::set& tables) { - ui.menuOpenTable->clear(); + m_openMenu->clear(); for(auto it = tables.begin(); it != tables.end(); ++it) { - QAction* openTable = ui.menuOpenTable->addAction(QString::fromStdString(*it)); + QAction* openTable = m_openMenu->addAction(QString::fromStdString(*it)); //Map this action to the table name m_openMap->setMapping(openTable, QString::fromStdString(*it));