Skip to content

Commit

Permalink
Re #4282. Improved window handling by project explorer
Browse files Browse the repository at this point in the history
  • Loading branch information
mantid-roman committed Jan 20, 2012
1 parent 833e29c commit c70caee
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 36 deletions.
49 changes: 31 additions & 18 deletions Code/Mantid/MantidPlot/src/ApplicationWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ void ApplicationWindow::init(bool factorySettings)
connect(d_workspace, SIGNAL(subWindowActivated(QMdiSubWindow *)),
this, SLOT(windowActivated(QMdiSubWindow*)));
connect(lv, SIGNAL(doubleClicked(Q3ListViewItem *)),
this, SLOT(maximizeWindow(Q3ListViewItem *)));
this, SLOT(activateWindow(Q3ListViewItem *)));
connect(lv, SIGNAL(doubleClicked(Q3ListViewItem *)),
this, SLOT(folderItemDoubleClicked(Q3ListViewItem *)));
connect(lv, SIGNAL(contextMenuRequested(Q3ListViewItem *, const QPoint &, int)),
Expand Down Expand Up @@ -8429,6 +8429,7 @@ void ApplicationWindow::hideWindow(MdiSubWindow* w)
{
hiddenWindows->append(w);
w->setHidden();
activateNewWindow();
emit modified();
}

Expand Down Expand Up @@ -8500,27 +8501,23 @@ bool ApplicationWindow::existsWindow(MdiSubWindow* w) const
*/
MdiSubWindow* ApplicationWindow::getActiveWindow() const
{
//m_active_window_mutex.lock();
if (!existsWindow(d_active_window))
{
d_active_window = NULL;
}
return d_active_window;
//m_active_window_mutex.unlock();
}

/**
* Sets internal pointer to a new active sub-window.
*/
void ApplicationWindow::setActiveWindow(MdiSubWindow* w)
{
//m_active_window_mutex.lock();
d_active_window = w;
if (!existsWindow(d_active_window))
{
d_active_window = NULL;
}
//m_active_window_mutex.unlock();
}


Expand Down Expand Up @@ -8549,7 +8546,7 @@ void ApplicationWindow::activateWindow(MdiSubWindow *w, bool activateOuterWindow
if(getActiveWindow() == w )
{
// this can happen
if (w->status() == MdiSubWindow::Minimized)
if (w->status() == MdiSubWindow::Minimized || w->status() == MdiSubWindow::Hidden)
{
w->setNormal();
}
Expand Down Expand Up @@ -8593,8 +8590,7 @@ void ApplicationWindow::activateWindow(MdiSubWindow *w, bool activateOuterWindow
{
if (activateOuterWindow)
{
fw->showNormal();
fw->activateWindow();
w->setNormal();
}
}
else
Expand All @@ -8607,6 +8603,17 @@ void ApplicationWindow::activateWindow(MdiSubWindow *w, bool activateOuterWindow
emit modified();
}

void ApplicationWindow::activateWindow(Q3ListViewItem * lbi)
{
if (!lbi)
lbi = lv->currentItem();

if (!lbi || lbi->rtti() == FolderListItem::RTTI)
return;

activateWindow(dynamic_cast<WindowListItem*>(lbi)->window());
}

void ApplicationWindow::maximizeWindow(Q3ListViewItem * lbi)
{
if (!lbi)
Expand Down Expand Up @@ -15165,19 +15172,19 @@ void ApplicationWindow::showAllFolderWindows()
switch (w->status())
{
case MdiSubWindow::Hidden:
w->showNormal();
w->setNormal();
break;

case MdiSubWindow::Normal:
w->showNormal();
w->setNormal();
break;

case MdiSubWindow::Minimized:
w->showMinimized();
w->setMinimized();
break;

case MdiSubWindow::Maximized:
w->showMaximized();
w->setMaximized();
break;
}
}
Expand All @@ -15198,19 +15205,19 @@ void ApplicationWindow::showAllFolderWindows()
switch (w->status())
{
case MdiSubWindow::Hidden:
w->showNormal();
w->setNormal();
break;

case MdiSubWindow::Normal:
w->showNormal();
w->setNormal();
break;

case MdiSubWindow::Minimized:
w->showMinimized();
w->setMinimized();
break;

case MdiSubWindow::Maximized:
w->showMaximized();
w->setMaximized();
break;
}
}
Expand Down Expand Up @@ -17723,7 +17730,10 @@ void ApplicationWindow::activateNewWindow()
if (w->widget() != static_cast<QWidget*>(current))
{
MdiSubWindow* sw = dynamic_cast<MdiSubWindow*>(w->widget());
if (sw && sw->status() != MdiSubWindow::Minimized && folder->hasWindow(sw))
if (sw &&
sw->status() != MdiSubWindow::Minimized &&
sw->status() != MdiSubWindow::Hidden &&
folder->hasWindow(sw))
{
newone = sw;
break;
Expand All @@ -17739,7 +17749,10 @@ void ApplicationWindow::activateNewWindow()
MdiSubWindow* sw = w->mdiSubWindow();
if (sw != current)
{
if (sw && sw->status() != MdiSubWindow::Minimized && folder->hasWindow(sw))
if (sw &&
sw->status() != MdiSubWindow::Minimized &&
sw->status() != MdiSubWindow::Hidden &&
folder->hasWindow(sw))
{
newone = sw;
break;
Expand Down
3 changes: 1 addition & 2 deletions Code/Mantid/MantidPlot/src/ApplicationWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ Description : QtiPlot's main window
#include <QLocale>
#include <QSet>
#include <QSettings>
#include <QMutex>

#include "Table.h"
#include "ScriptingEnv.h"
Expand Down Expand Up @@ -518,6 +517,7 @@ public slots:
bool setWindowName(MdiSubWindow *w, const QString &text);

void maximizeWindow(Q3ListViewItem * lbi = 0);
void activateWindow(Q3ListViewItem * lbi);
void maximizeWindow(MdiSubWindow *w);
void minimizeWindow(MdiSubWindow *w = 0);
//! Changes the geometry of the active MDI window
Expand Down Expand Up @@ -1462,7 +1462,6 @@ public slots:
QList<FloatingWindow*> m_floatingWindows;
// To block activating new window when a floating window is in process of resetting flags
bool blockWindowActivation;
mutable QMutex m_active_window_mutex;

#ifdef SHARED_MENUBAR
QMenuBar* m_sharedMenuBar; ///< Pointer to the shared menubar
Expand Down
28 changes: 12 additions & 16 deletions Code/Mantid/MantidPlot/src/MdiSubWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,27 +109,15 @@ void MdiSubWindow::resizeEvent( QResizeEvent* e )
*/
void MdiSubWindow::show()
{
QWidget* pw = getWrapperWindow();
if (!pw)
{
MdiSubWindowParent_t::show();
return;
}
pw->show();
setNormal();
}

/**
* Override the QWidget's hide() slot to hide the wrapper window instead.
*/
void MdiSubWindow::hide()
{
QWidget* pw = getWrapperWindow();
if (!pw)
{
MdiSubWindowParent_t::hide();
return;
}
pw->hide();
setHidden();
}

/**
Expand Down Expand Up @@ -268,8 +256,16 @@ void MdiSubWindow::setStatus(Status s)

void MdiSubWindow::setHidden()
{
setStatus(Hidden);
hide();
QWidget* pw = getWrapperWindow();
if (!pw)
{
MdiSubWindowParent_t::hide();
}
else
{
pw->hide();
}
setStatus(Hidden);
}

void MdiSubWindow::setNormal()
Expand Down

0 comments on commit c70caee

Please sign in to comment.