Commit d017495a authored by Eike Ziller's avatar Eike Ziller
Browse files

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: default avatarDavid Schulz <david.schulz@digia.com>
parent 0d9bf5e5
......@@ -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);
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment