From d017495a9fd1994569e27c28e395756f24d1b436 Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Tue, 7 May 2013 19:33:14 +0200 Subject: [PATCH] Fix positioning of open editors popup Make it position over the editor root view of the active window (of the current editor view if the active window doesn't have editor views) instead of always over the main window. For this to work we should not make the editor manager parentless in the editor manager placeholder. Change-Id: I55d38340939a37960ec619b89f2e768bbfab7f24 Reviewed-by: David Schulz --- .../editormanager/editormanager.cpp | 34 +++++++++++++------ 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/src/plugins/coreplugin/editormanager/editormanager.cpp b/src/plugins/coreplugin/editormanager/editormanager.cpp index 905f8501b55..5251eba61f8 100644 --- a/src/plugins/coreplugin/editormanager/editormanager.cpp +++ b/src/plugins/coreplugin/editormanager/editormanager.cpp @@ -149,15 +149,12 @@ EditorManagerPlaceHolder::~EditorManagerPlaceHolder() void EditorManagerPlaceHolder::currentModeChanged(Core::IMode *mode) { - if (m_current == this) { - m_current = 0; - EditorManager::instance()->setParent(0); - EditorManager::instance()->hide(); - } if (m_mode == mode) { m_current = this; layout()->addWidget(EditorManager::instance()); EditorManager::instance()->show(); + } else if (m_current == this) { + m_current = 0; } } @@ -2065,12 +2062,27 @@ void EditorManager::showPopupOrSelectDocument() const if (QApplication::keyboardModifiers() == Qt::NoModifier) { windowPopup()->selectAndHide(); } else { - // EditorManager is invisible when invoked from Design Mode. - const QPoint p = isVisible() ? - mapToGlobal(QPoint(0, 0)) : - ICore::mainWindow()->mapToGlobal(QPoint(0, 0)); - windowPopup()->move((width()-d->m_windowPopup->width())/2 + p.x(), - (height()-d->m_windowPopup->height())/2 + p.y()); + QWidget *activeWindow = qApp->activeWindow(); + // decide where to show the popup + // if the active window has editors, we want that root as a reference + SplitterOrView *activeRoot = 0; + foreach (SplitterOrView *root, d->m_root) { + if (root->window() == activeWindow) { + activeRoot = root; + break; + } + } + // otherwise we take the "current" root + if (!activeRoot) + activeRoot = findRoot(currentEditorView()); + QTC_ASSERT(activeRoot, activeRoot = d->m_root.first()); + + // root in main window is invisible when invoked from Design Mode. + QWidget *referenceWidget = activeRoot->isVisible() ? activeRoot : activeRoot->window(); + QTC_CHECK(referenceWidget->isVisible()); + const QPoint p = referenceWidget->mapToGlobal(QPoint(0, 0)); + windowPopup()->move((referenceWidget->width() - d->m_windowPopup->width()) / 2 + p.x(), + (referenceWidget->height() - d->m_windowPopup->height()) / 2 + p.y()); windowPopup()->setVisible(true); } }