Skip to content

Commit

Permalink
Re #4282. Removed wrapper widget from FloatingWindow
Browse files Browse the repository at this point in the history
  • Loading branch information
mantid-roman committed Dec 21, 2011
1 parent baff030 commit 4cdcf1f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 23 deletions.
23 changes: 9 additions & 14 deletions Code/Mantid/MantidPlot/src/ApplicationWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17273,9 +17273,7 @@ void ApplicationWindow::goFloat(MdiSubWindow* w)

// create the outer floating window. It is not a child of ApplicationWindow.
FloatingWindow* fw =new FloatingWindow(this);//, Qt::WindowStaysOnTopHint);
MdiSubWindowParent_t* wrapper = new MdiSubWindowParent_t(fw,0);
wrapper->setWidget(w);
fw->setCentralWidget(wrapper);
fw->setWidget(w);
fw->resize(sz);
fw->move(p);
fw->show();
Expand All @@ -17297,18 +17295,15 @@ void ApplicationWindow::goMdi(FloatingWindow* fw)
QAction* res = systemMenu.exec(QCursor::pos());
if (res == goMdiAction)
{
MdiSubWindowParent_t* wrapper = dynamic_cast<MdiSubWindowParent_t*>(fw->centralWidget());
if (wrapper)
//fw->setWidget(NULL);
MdiSubWindow* w = dynamic_cast<MdiSubWindow*>(fw->widget());
if (w)
{
fw->setCentralWidget(NULL);
MdiSubWindow* w = dynamic_cast<MdiSubWindow*>(wrapper->widget());
if (w)
{
addSubWindowToMdiArea(w);
// main window must be closed or application will freeze
fw->close();
return;
}
addSubWindowToMdiArea(w);
removeFloatingWindow(fw);
// main window must be closed or application will freeze
fw->close();
return;
}
throw std::runtime_error("Mdi window mishandling");
}
Expand Down
15 changes: 7 additions & 8 deletions Code/Mantid/MantidPlot/src/MdiSubWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ void MdiSubWindow::goMdi()
* Constructor.
*/
FloatingWindow::FloatingWindow(ApplicationWindow* appWindow, Qt::WindowFlags f):
QMainWindow(appWindow,f),
MdiSubWindowParent_t(appWindow,f | Qt::Window),
d_app(appWindow)
{
setFocusPolicy(Qt::StrongFocus);
Expand All @@ -371,12 +371,7 @@ bool FloatingWindow::event(QEvent * e)
{
if (e->type() == QEvent::WindowActivate)
{
MdiSubWindowParent_t* w_t = dynamic_cast<MdiSubWindowParent_t*>(this->centralWidget());
MdiSubWindow* w = NULL;
if (w_t)
{
w = dynamic_cast<MdiSubWindow*>(w_t->widget());
}
MdiSubWindow* w = dynamic_cast<MdiSubWindow*>(widget());
if (w && this != w->d_app->getActiveFloating())
{
w->d_app->activateWindow(w);
Expand All @@ -402,7 +397,11 @@ bool FloatingWindow::event(QEvent * e)
this->showMaximized();
}
}
return QMainWindow::event(e);
else if (e->type() == QEvent::Close)
{
d_app->removeFloatingWindow(this);
}
return MdiSubWindowParent_t::event(e);
}

void FloatingWindow::setStaysOnTopFlag()
Expand Down
2 changes: 1 addition & 1 deletion Code/Mantid/MantidPlot/src/MdiSubWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ typedef QList<MdiSubWindow*> MDIWindowList;
/**
* Floating wrapper widget for a MdiSubWindow.
*/
class FloatingWindow: public QMainWindow
class FloatingWindow: public MdiSubWindowParent_t
{
Q_OBJECT
public:
Expand Down

0 comments on commit 4cdcf1f

Please sign in to comment.