Skip to content

Commit

Permalink
Re #4282. Improving floating windows performance
Browse files Browse the repository at this point in the history
  • Loading branch information
mantid-roman committed Jan 5, 2012
1 parent a1c58bf commit cf90b6e
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 70 deletions.
70 changes: 11 additions & 59 deletions Code/Mantid/MantidPlot/src/ApplicationWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,13 +215,11 @@ blockWindowActivation(false),
#ifdef SHARED_MENUBAR
if (settings.value("/General/SharedMenuBar",false).toBool())
{
std::cerr << "Shared" << std::endl;
m_sharedMenuBar = new QMenuBar(NULL);
setMenuBar(m_sharedMenuBar);
}
else
{
std::cerr << "Not shared" << std::endl;
m_sharedMenuBar = NULL;
}
#endif
Expand Down Expand Up @@ -442,9 +440,6 @@ void ApplicationWindow::init(bool factorySettings)
showFirstTimeSetup();
}

QTimer *timer = new QTimer(this);
connect(timer,SIGNAL(timeout()),this,SLOT(showActiveWindowInTitle()));
timer->start(100);
}

void ApplicationWindow::showLogWindowContextMenu(const QPoint & p)
Expand Down Expand Up @@ -5938,7 +5933,6 @@ void ApplicationWindow::renameWindow(Q3ListViewItem *item, int, const QString &t
bool ApplicationWindow::setWindowName(MdiSubWindow *w, const QString &text)
{

std::cerr << "setWindowName:" << text.toStdString() << std::endl;
if (!w)
return false;

Expand Down Expand Up @@ -8368,35 +8362,15 @@ void ApplicationWindow::activateWindow(MdiSubWindow *w)

if( d_active_window == w ) return;

//FloatingWindow* fw = getActiveFloating();
//if (fw)
//{
// blockWindowActivation = true;
// removeStaysOnTopFlag(fw);
// blockWindowActivation = false;
//}

d_active_window = w;

if (!w) return;

//fw = getActiveFloating();
//if (fw)
//{
// blockWindowActivation = true;
// setStaysOnTopFlag(fw);
// blockWindowActivation = false;
//}

QMdiSubWindow* qw = dynamic_cast<QMdiSubWindow*>(w->parent());
//if (qw)
//{
w->setNormal();
//}
w->setNormal();

updateWindowLists(w);

//----------------------------------------------------
customToolBars(w);
customMenu(w);

Expand All @@ -8418,7 +8392,16 @@ void ApplicationWindow::activateWindow(MdiSubWindow *w)
f->setActiveWindow(w);

blockWindowActivation = true;
w->parentWidget()->setFocus();
//w->parentWidget()->setFocus();
FloatingWindow* fw = d_active_window->getFloatingWindow();
if (fw)
{
fw->activateWindow();
}
else
{
QMainWindow::activateWindow();
}
blockWindowActivation = false;

emit modified();
Expand Down Expand Up @@ -8946,24 +8929,6 @@ void ApplicationWindow::windowsMenuActivated( int id )
if ( w )
{
this->activateWindow(w);
//QMdiSubWindow* mdi = dynamic_cast<QMdiSubWindow*>(w->parent());
//if (mdi)
//{
// mdi->showNormal();
// mdi->setFocus();
// if(hidden(w)){
// hiddenWindows->takeAt(hiddenWindows->indexOf(w));
// setListView(w->objectName(), tr("Normal"));
// }
//}
//else
//{// floating window
// QMdiSubWindow* mdi = dynamic_cast<QMdiSubWindow*>(d_active_window->parent());
// if (mdi)
// {
// mdi->clearFocus();
// }
//}
}
}

Expand Down Expand Up @@ -17412,19 +17377,6 @@ void ApplicationWindow::updateOnTopFlags()
{
}

void ApplicationWindow::showActiveWindowInTitle()
{
if (d_active_window)
{
QString title = d_active_window->name();
this->setWindowTitle(title);
}
else
{
this->setWindowTitle("No active window");
}
}

/**
* Activate a subwindow (docked or floating) other than current active one.
* This is required when the current window is closing.
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 @@ -89,7 +89,7 @@ class AssociationsDialog;
class MantidMatrix;
class FloatingWindow;

// On Mac and Ubuntu 11 Unity the menubar must be shared between the main window and other floating windows.
// On Mac (and Ubuntu 11 Unity) the menubar must be shared between the main window and other floating windows.
#ifndef Q_OS_WIN32
#define SHARED_MENUBAR
#endif
Expand Down Expand Up @@ -1036,7 +1036,6 @@ public slots:
void changeToDocked(MdiSubWindow* w);
void removeFloatingWindow(FloatingWindow* w);
FloatingWindow* getActiveFloating() const;
void showActiveWindowInTitle(); // temporary
QMenuBar* myMenuBar();
#ifdef SHARED_MENUBAR
bool isMenuBarShared() const {return m_sharedMenuBar != NULL;}
Expand Down
12 changes: 6 additions & 6 deletions Code/Mantid/MantidPlot/src/ConfigDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -605,27 +605,27 @@ void ConfigDialog::initAppPage()
floatLayout->addWidget(floatBox);
QGridLayout *floatPageLayout = new QGridLayout(floatBox);

boxFloatingGraph = new QCheckBox("Floating Graphs");
boxFloatingGraph = new QCheckBox("Graphs");
boxFloatingGraph->setChecked(app->settings.value("/General/FloatingWindows/MultiLayer",false).toBool());
floatPageLayout->addWidget(boxFloatingGraph,0,0);

boxFloatingTable = new QCheckBox("Floating Tables");
boxFloatingTable = new QCheckBox("Tables");
boxFloatingTable->setChecked(app->settings.value("/General/FloatingWindows/Table",false).toBool());
floatPageLayout->addWidget(boxFloatingTable,1,0);

boxFloatingInstrumentWindow = new QCheckBox("Floating Instrument views");
boxFloatingInstrumentWindow = new QCheckBox("Instrument views");
boxFloatingInstrumentWindow->setChecked(app->settings.value("/General/FloatingWindows/InstrumentWindow",false).toBool());
floatPageLayout->addWidget(boxFloatingInstrumentWindow,2,0);

boxFloatingMantidMatrix = new QCheckBox("Floating MantidMatrix");
boxFloatingMantidMatrix = new QCheckBox("Mantid Matrices");
boxFloatingMantidMatrix->setChecked(app->settings.value("/General/FloatingWindows/MantidMatrix",false).toBool());
floatPageLayout->addWidget(boxFloatingMantidMatrix,3,0);

boxFloatingNote = new QCheckBox("Floating Notes");
boxFloatingNote = new QCheckBox("Notes");
boxFloatingNote->setChecked(app->settings.value("/General/FloatingWindows/Note",false).toBool());
floatPageLayout->addWidget(boxFloatingNote,4,0);

boxFloatingMatrix = new QCheckBox("Floating Matrix");
boxFloatingMatrix = new QCheckBox("Matrices");
boxFloatingMatrix->setChecked(app->settings.value("/General/FloatingWindows/Matrix",false).toBool());
floatPageLayout->addWidget(boxFloatingMatrix,5,0);

Expand Down
6 changes: 3 additions & 3 deletions Code/Mantid/MantidPlot/src/Mantid/MantidUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -357,13 +357,13 @@ bool MantidUI::menuAboutToShow(MdiSubWindow *w)

if (w && w->isA("MantidMatrix"))
{
appWindow()->menuBar()->insertItem(tr("3D &Plot"), appWindow()->plot3DMenu);
appWindow()->myMenuBar()->insertItem(tr("3D &Plot"), appWindow()->plot3DMenu);
appWindow()->actionCopySelection->setEnabled(true);
appWindow()->actionPasteSelection->setEnabled(false);
appWindow()->actionClearSelection->setEnabled(false);
appWindow()->plotMatrixBar->setEnabled (true);

appWindow()->menuBar()->insertItem(tr("&Workspace"),menuMantidMatrix);
appWindow()->myMenuBar()->insertItem(tr("&Workspace"),menuMantidMatrix);
return true;
}

Expand Down Expand Up @@ -1857,7 +1857,7 @@ void MantidUI::mantidMenuAboutToShow()

void MantidUI::insertMenu()
{
appWindow()->menuBar()->insertItem(tr("Man&tid"), mantidMenu);
appWindow()->myMenuBar()->insertItem(tr("Man&tid"), mantidMenu);
}

void MantidUI::clearAllMemory()
Expand Down

0 comments on commit cf90b6e

Please sign in to comment.