Skip to content
Snippets Groups Projects
Commit 9c824bbe authored by Andreas Schenk's avatar Andreas Schenk
Browse files

Author: Jeff Lovelace

- Fix for data viewer to use main ost menubar: Data viewer menu (labeled Panels) for the active data viewer window will show in the main menu bar.
- Added foxus proxy for the data viewer and its QMdiSubwindow to ensure that the data viewer panel gets the keyboard focus from the beginning.
parent 890f33d5
Branches
Tags
No related merge requests found
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
/* /*
Authors: Ansgar Philippsen, Andreas Schenk Authors: Ansgar Philippsen, Andreas Schenk, Jeff Lovelace
*/ */
#include <cassert> #include <cassert>
...@@ -35,6 +35,9 @@ ...@@ -35,6 +35,9 @@
#include <ost/img/alg/norm.hh> #include <ost/img/alg/norm.hh>
#include <ost/gui/dock_widget.hh> #include <ost/gui/dock_widget.hh>
#include <ost/gui/gosty_app.hh>
#include <ost/gui/perspective.hh>
#include "data_viewer.hh" #include "data_viewer.hh"
#include "data_viewer_panel.hh" #include "data_viewer_panel.hh"
#include "overlay_base.hh" #include "overlay_base.hh"
...@@ -74,10 +77,13 @@ DataViewer::DataViewer(QWidget* p, const ImageHandle& data, const QString& name) ...@@ -74,10 +77,13 @@ DataViewer::DataViewer(QWidget* p, const ImageHandle& data, const QString& name)
connect(ov_manager_gui_,SIGNAL(SettingsChanged()),this,SLOT(UpdateView())); connect(ov_manager_gui_,SIGNAL(SettingsChanged()),this,SLOT(UpdateView()));
setWindowTitle("OpenStructure Data Viewer"); setWindowTitle("OpenStructure Data Viewer");
build(data); build(data);
setFocusProxy(panel_);
} }
DataViewer::~DataViewer() DataViewer::~DataViewer()
{ {
QMenuBar* mainMenu = ost::gui::GostyApp::Instance()->GetPerspective()->GetMenuBar();
mainMenu->removeAction(WindowMenu()->menuAction());
} }
void DataViewer::SetData(const ImageHandle& d) void DataViewer::SetData(const ImageHandle& d)
...@@ -304,8 +310,35 @@ void DataViewer::build(const ImageHandle& data) ...@@ -304,8 +310,35 @@ void DataViewer::build(const ImageHandle& data)
void DataViewer::build_menu() void DataViewer::build_menu()
{ {
menuBar()->addMenu(WindowMenu()); QMenuBar* mainMenu = ost::gui::GostyApp::Instance()->GetPerspective()->GetMenuBar();
} mainMenu->addMenu(WindowMenu());
}
void DataViewer::show_current_window_menu(void)
{
// If the Panel menu for this window is already visible do nothing
if (!WindowMenu()->isVisible())
{
// We need to hide all instances of panels
// Get the Main Menu Bar pointer from OST
QMenuBar* mainMenu = ost::gui::GostyApp::Instance()->GetPerspective()->GetMenuBar();
// Get a list of all the main level menus
QList<QAction*> ActionList=mainMenu->actions();
// Any menus named panels are hidden
for (int i=0;i<ActionList.count();i++)
{
if (ActionList[i]->text()=="Panels")
{
if (ActionList[i]->isVisible())
{
ActionList[i]->setVisible(false);
}
}
}
// Show the panel menu for this object
WindowMenu()->menuAction()->setVisible(true);
}
}
bool DataViewer::eventFilter(QObject * object, QEvent *event) bool DataViewer::eventFilter(QObject * object, QEvent *event)
{ {
...@@ -320,6 +353,19 @@ bool DataViewer::eventFilter(QObject * object, QEvent *event) ...@@ -320,6 +353,19 @@ bool DataViewer::eventFilter(QObject * object, QEvent *event)
} }
} }
break; break;
case QEvent::FocusIn:
{
// Show panels menu when data viewer gets focus
show_current_window_menu();
return true;
}
break;
case QEvent::Show:
{
// Show panels menu when data viewer gets focus
show_current_window_menu();
return true;
}
case QEvent::MouseButtonDblClick: case QEvent::MouseButtonDblClick:
case QEvent::MouseButtonPress: case QEvent::MouseButtonPress:
case QEvent::MouseButtonRelease: case QEvent::MouseButtonRelease:
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
/* /*
Authors: Ansgar Philippsen, Andreas Schenk Authors: Ansgar Philippsen, Andreas Schenk, Jeff Lovelace
*/ */
#ifndef IMG_GUI_DATA_VIEWER_H #ifndef IMG_GUI_DATA_VIEWER_H
...@@ -178,6 +178,9 @@ public slots: ...@@ -178,6 +178,9 @@ public slots:
void build(const ImageHandle& data); void build(const ImageHandle& data);
void show_current_window_menu(void);
void build_menu(); void build_menu();
}; };
......
...@@ -115,6 +115,7 @@ ost::img::gui::DataViewer* GostyApp::CreateDataViewer(const ost::img::ImageHandl ...@@ -115,6 +115,7 @@ ost::img::gui::DataViewer* GostyApp::CreateDataViewer(const ost::img::ImageHandl
QMdiSubWindow* mdi=new QMdiSubWindow(this->GetPerspective()->GetMainArea()); QMdiSubWindow* mdi=new QMdiSubWindow(this->GetPerspective()->GetMainArea());
mdi->setWindowTitle(name); mdi->setWindowTitle(name);
mdi->setWidget(viewer); mdi->setWidget(viewer);
mdi->setFocusProxy(viewer);
viewer->setAttribute(Qt::WA_DeleteOnClose); viewer->setAttribute(Qt::WA_DeleteOnClose);
mdi->setAttribute(Qt::WA_DeleteOnClose); mdi->setAttribute(Qt::WA_DeleteOnClose);
viewer->setParent(mdi); viewer->setParent(mdi);
......
...@@ -31,7 +31,7 @@ namespace ost { namespace gui { ...@@ -31,7 +31,7 @@ namespace ost { namespace gui {
MainWindow::MainWindow(QWidget* parent, Qt::WindowFlags flags): MainWindow::MainWindow(QWidget* parent, Qt::WindowFlags flags):
QMainWindow(parent,flags), QMainWindow(parent,flags),
window_menu_(new QMenu("Windows")), window_menu_(new QMenu("Panels")),
dock_widget_map_() dock_widget_map_()
{ {
connect(window_menu_,SIGNAL(triggered(QAction*)),this,SLOT(OnDockMenu(QAction*))); connect(window_menu_,SIGNAL(triggered(QAction*)),this,SLOT(OnDockMenu(QAction*)));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment