forked from qt-creator/qt-creator
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
This commit is contained in:
@@ -827,21 +827,29 @@ void MainWindow::openFiles(const QStringList &fileNames)
|
|||||||
|
|
||||||
void MainWindow::setFocusToEditor()
|
void MainWindow::setFocusToEditor()
|
||||||
{
|
{
|
||||||
QWidget *focusWidget = qApp->focusWidget();
|
bool focusWasMovedToEditor = false;
|
||||||
if (!EditorManager::instance()->isVisible())
|
|
||||||
{
|
// give focus to the editor if we have one
|
||||||
m_coreImpl->modeManager()->activateMode(QLatin1String(Constants::MODE_EDIT));
|
if (IEditor *editor = m_editorManager->currentEditor()) {
|
||||||
|
if (qApp->focusWidget() != editor->widget()) {
|
||||||
|
editor->widget()->setFocus();
|
||||||
|
focusWasMovedToEditor = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IEditor *editor = m_editorManager->currentEditor())
|
// check for some maximized pane which we want to unmaximize
|
||||||
editor->widget()->setFocus();
|
if (OutputPanePlaceHolder::getCurrent()
|
||||||
|
&& OutputPanePlaceHolder::getCurrent()->isVisible()
|
||||||
bool focusWasAlreadyInEditor = (focusWidget && focusWidget == qApp->focusWidget());
|
&& OutputPanePlaceHolder::getCurrent()->isMaximized()) {
|
||||||
if (!focusWasAlreadyInEditor) {
|
|
||||||
if (OutputPanePlaceHolder::getCurrent() &&
|
|
||||||
OutputPanePlaceHolder::getCurrent()->isVisible())
|
|
||||||
OutputPanePlaceHolder::getCurrent()->unmaximize();
|
OutputPanePlaceHolder::getCurrent()->unmaximize();
|
||||||
} else {
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (focusWasMovedToEditor)
|
||||||
|
return;
|
||||||
|
|
||||||
|
|
||||||
|
// check for some visible bar which we want to hide
|
||||||
bool stuffVisible =
|
bool stuffVisible =
|
||||||
(FindToolBarPlaceHolder::getCurrent() &&
|
(FindToolBarPlaceHolder::getCurrent() &&
|
||||||
FindToolBarPlaceHolder::getCurrent()->isVisible())
|
FindToolBarPlaceHolder::getCurrent()->isVisible())
|
||||||
@@ -854,10 +862,12 @@ void MainWindow::setFocusToEditor()
|
|||||||
FindToolBarPlaceHolder::getCurrent()->hide();
|
FindToolBarPlaceHolder::getCurrent()->hide();
|
||||||
OutputPaneManager::instance()->slotHide();
|
OutputPaneManager::instance()->slotHide();
|
||||||
RightPaneWidget::instance()->setShown(false);
|
RightPaneWidget::instance()->setShown(false);
|
||||||
} else {
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// switch to edit mode if necessary
|
||||||
m_coreImpl->modeManager()->activateMode(QLatin1String(Constants::MODE_EDIT));
|
m_coreImpl->modeManager()->activateMode(QLatin1String(Constants::MODE_EDIT));
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList MainWindow::showNewItemDialog(const QString &title,
|
QStringList MainWindow::showNewItemDialog(const QString &title,
|
||||||
|
Reference in New Issue
Block a user