Skip to content

Commit

Permalink
Refs #10376 Try creating menu bar programatically
Browse files Browse the repository at this point in the history
  • Loading branch information
Harry Jeffery committed Oct 22, 2014
1 parent b16c6e6 commit 4724bb6
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 37 deletions.
Expand Up @@ -81,6 +81,7 @@ namespace MantidQt
boost::shared_ptr<IReflPresenter> m_presenter;
//the interface
Ui::reflMainWidget ui;
QMenu* m_openMenu;
//the workspace the user selected to open
std::string m_toOpen;
QSignalMapper* m_openMap;
Expand Down
Expand Up @@ -366,38 +366,6 @@
</item>
</layout>
</widget>
<widget class="QMenuBar" name="menuBar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>825</width>
<height>23</height>
</rect>
</property>
<property name="nativeMenuBar">
<bool>false</bool>
</property>
<widget class="QMenu" name="menuTable">
<property name="title">
<string>Table</string>
</property>
<widget class="QMenu" name="menuOpenTable">
<property name="title">
<string>Open Table</string>
</property>
<property name="icon">
<iconset resource="../../../../MantidPlot/icons/icons.qrc">
<normaloff>:/multiload.png</normaloff>:/multiload.png</iconset>
</property>
</widget>
<addaction name="menuOpenTable"/>
<addaction name="actionNewTable"/>
<addaction name="actionSaveTable"/>
<addaction name="actionSaveTableAs"/>
</widget>
<addaction name="menuTable"/>
</widget>
<action name="actionNewTable">
<property name="icon">
<iconset resource="../../../../MantidPlot/icons/icons.qrc">
Expand Down
22 changes: 17 additions & 5 deletions Code/Mantid/MantidQt/CustomInterfaces/src/QtReflMainView.cpp
Expand Up @@ -3,8 +3,12 @@
#include "MantidQtCustomInterfaces/ReflMainViewPresenter.h"
#include "MantidAPI/ITableWorkspace.h"
#include "MantidKernel/ConfigService.h"
#include <qinputdialog.h>
#include <qmessagebox.h>

#include <QInputDialog>
#include <QMenu>
#include <QMenuBar>
#include <QMessageBox>
#include <QtGlobal>

namespace MantidQt
{
Expand All @@ -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))
{
}

Expand Down Expand Up @@ -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<IReflPresenter>(new ReflMainViewPresenter(this));
}
Expand Down Expand Up @@ -88,11 +100,11 @@ namespace MantidQt
*/
void QtReflMainView::setTableList(const std::set<std::string>& 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));
Expand Down

0 comments on commit 4724bb6

Please sign in to comment.