From b8e4850a537e2921931926defd7e22d970d080de Mon Sep 17 00:00:00 2001 From: mae Date: Wed, 9 Jun 2010 12:48:32 +0200 Subject: [PATCH] Fix central Esc handling In modes other than Edit mode, we do not want Esc to jump to Edit mode as long as there are still panels (or the find bar) visible. Reviewed-by: dt --- src/plugins/coreplugin/mainwindow.cpp | 64 ++++++++++++++++----------- 1 file changed, 37 insertions(+), 27 deletions(-) diff --git a/src/plugins/coreplugin/mainwindow.cpp b/src/plugins/coreplugin/mainwindow.cpp index ed1d48afb8d..b4410acee84 100644 --- a/src/plugins/coreplugin/mainwindow.cpp +++ b/src/plugins/coreplugin/mainwindow.cpp @@ -827,37 +827,47 @@ void MainWindow::openFiles(const QStringList &fileNames) void MainWindow::setFocusToEditor() { - QWidget *focusWidget = qApp->focusWidget(); - if (!EditorManager::instance()->isVisible()) - { - m_coreImpl->modeManager()->activateMode(QLatin1String(Constants::MODE_EDIT)); - } + bool focusWasMovedToEditor = false; - if (IEditor *editor = m_editorManager->currentEditor()) + // give focus to the editor if we have one + if (IEditor *editor = m_editorManager->currentEditor()) { + if (qApp->focusWidget() != editor->widget()) { editor->widget()->setFocus(); - - bool focusWasAlreadyInEditor = (focusWidget && focusWidget == qApp->focusWidget()); - if (!focusWasAlreadyInEditor) { - if (OutputPanePlaceHolder::getCurrent() && - OutputPanePlaceHolder::getCurrent()->isVisible()) - OutputPanePlaceHolder::getCurrent()->unmaximize(); - } else { - bool stuffVisible = - (FindToolBarPlaceHolder::getCurrent() && - FindToolBarPlaceHolder::getCurrent()->isVisible()) - || (OutputPanePlaceHolder::getCurrent() && - OutputPanePlaceHolder::getCurrent()->isVisible()) - || (RightPanePlaceHolder::current() && - RightPanePlaceHolder::current()->isVisible()); - if (stuffVisible) { - if (FindToolBarPlaceHolder::getCurrent()) - FindToolBarPlaceHolder::getCurrent()->hide(); - OutputPaneManager::instance()->slotHide(); - RightPaneWidget::instance()->setShown(false); - } else { - m_coreImpl->modeManager()->activateMode(QLatin1String(Constants::MODE_EDIT)); + focusWasMovedToEditor = true; } } + + // check for some maximized pane which we want to unmaximize + if (OutputPanePlaceHolder::getCurrent() + && OutputPanePlaceHolder::getCurrent()->isVisible() + && OutputPanePlaceHolder::getCurrent()->isMaximized()) { + OutputPanePlaceHolder::getCurrent()->unmaximize(); + return; + } + + if (focusWasMovedToEditor) + return; + + + // check for some visible bar which we want to hide + bool stuffVisible = + (FindToolBarPlaceHolder::getCurrent() && + FindToolBarPlaceHolder::getCurrent()->isVisible()) + || (OutputPanePlaceHolder::getCurrent() && + OutputPanePlaceHolder::getCurrent()->isVisible()) + || (RightPanePlaceHolder::current() && + RightPanePlaceHolder::current()->isVisible()); + if (stuffVisible) { + if (FindToolBarPlaceHolder::getCurrent()) + FindToolBarPlaceHolder::getCurrent()->hide(); + OutputPaneManager::instance()->slotHide(); + RightPaneWidget::instance()->setShown(false); + return; + } + + // switch to edit mode if necessary + m_coreImpl->modeManager()->activateMode(QLatin1String(Constants::MODE_EDIT)); + } QStringList MainWindow::showNewItemDialog(const QString &title,