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

Fix escape key logic when design mode has output panes open



Task-number: QTCREATORBUG-9985

Change-Id: I6b22c92ac8f780b1a9469e9c2fd4a7cfecfef15f
Reviewed-by: default avatarDavid Schulz <david.schulz@digia.com>
parent 63f2e917
...@@ -854,10 +854,13 @@ static void setFocusToEditorViewAndUnmaximizePanes(EditorView *view) ...@@ -854,10 +854,13 @@ static void setFocusToEditorViewAndUnmaximizePanes(EditorView *view)
void EditorManager::doEscapeKeyFocusMoveMagic() void EditorManager::doEscapeKeyFocusMoveMagic()
{ {
// use cases to cover: // use cases to cover:
// 1. if app focus is in mode or external window without editor view (e.g. Projects, ext. Help) // 1. if app focus is in mode or external window without editor view (e.g. Design, Projects, ext. Help)
// activate & raise the current editor view (can be external) // if there are extra views (e.g. output)
// if that is in edit mode // hide them
// activate edit mode and unmaximize output pane // otherwise
// activate & raise the current editor view (can be external)
// if that is in edit mode
// activate edit mode and unmaximize output pane
// 2. if app focus is in external window with editor view // 2. if app focus is in external window with editor view
// hide find if necessary // hide find if necessary
// 2. if app focus is in mode with editor view // 2. if app focus is in mode with editor view
...@@ -874,44 +877,54 @@ void EditorManager::doEscapeKeyFocusMoveMagic() ...@@ -874,44 +877,54 @@ void EditorManager::doEscapeKeyFocusMoveMagic()
// otherwise (i.e. mode is edit mode) // otherwise (i.e. mode is edit mode)
// hide extra views (find, help, output) // hide extra views (find, help, output)
QWidget *activeWindow = qApp->activeWindow();
if (!activeWindow)
return;
QWidget *focus = qApp->focusWidget();
EditorView *editorView = currentEditorView(); EditorView *editorView = currentEditorView();
bool editorViewActive = (qApp->focusWidget() == editorView->focusWidget()); bool editorViewActive = (focus && focus == editorView->focusWidget());
bool editorViewVisible = editorView->isVisible(); bool editorViewVisible = editorView->isVisible();
if (!editorViewActive && editorViewVisible) {
setFocusToEditorViewAndUnmaximizePanes(editorView); if (!( editorViewVisible && !editorViewActive && editorView->window() == activeWindow )) {
return;
}
if (!editorViewActive && !editorViewVisible) {
// assumption is that editorView is in main window then
ModeManager::activateMode(Id(Constants::MODE_EDIT));
QTC_CHECK(editorView->isVisible());
setFocusToEditorViewAndUnmaximizePanes(editorView);
return;
}
if (editorViewActive) {
QTC_CHECK(editorViewVisible);
bool stuffHidden = false; bool stuffHidden = false;
QWidget *findPane = FindToolBarPlaceHolder::getCurrent(); QWidget *findPane = FindToolBarPlaceHolder::getCurrent();
if (findPane && findPane->isVisibleTo(editorView)) { if (findPane && findPane->isVisible() && findPane->window() == activeWindow) {
findPane->hide(); findPane->hide();
stuffHidden = true; stuffHidden = true;
} }
QWidget *outputPane = OutputPanePlaceHolder::getCurrent(); QWidget *outputPane = OutputPanePlaceHolder::getCurrent();
if (outputPane && outputPane->isVisibleTo(editorView)) { if (outputPane && outputPane->isVisible() && outputPane->window() == activeWindow) {
OutputPaneManager::instance()->slotHide(); OutputPaneManager::instance()->slotHide();
stuffHidden = true; stuffHidden = true;
} }
QWidget *rightPane = RightPanePlaceHolder::current(); QWidget *rightPane = RightPanePlaceHolder::current();
if (rightPane && rightPane->isVisibleTo(editorView)) { if (rightPane && rightPane->isVisible() && rightPane->window() == activeWindow) {
RightPaneWidget::instance()->setShown(false); RightPaneWidget::instance()->setShown(false);
stuffHidden = true; stuffHidden = true;
} }
if (!stuffHidden && editorView->window() == ICore::mainWindow()) { if (stuffHidden)
// we are in a editor view and there's nothing to hide, switch to edit return;
ModeManager::activateMode(Id(Constants::MODE_EDIT)); }
// next call works only because editor views in main window are shared between modes
setFocusToEditorViewAndUnmaximizePanes(editorView); if (!editorViewActive && editorViewVisible) {
} setFocusToEditorViewAndUnmaximizePanes(editorView);
return;
}
if (!editorViewActive && !editorViewVisible) {
// assumption is that editorView is in main window then
ModeManager::activateMode(Id(Constants::MODE_EDIT));
QTC_CHECK(editorView->isVisible());
setFocusToEditorViewAndUnmaximizePanes(editorView);
return;
}
if (editorView->window() == ICore::mainWindow()) {
// we are in a editor view and there's nothing to hide, switch to edit
ModeManager::activateMode(Id(Constants::MODE_EDIT));
QTC_CHECK(editorView->isVisible());
// next call works only because editor views in main window are shared between modes
setFocusToEditorViewAndUnmaximizePanes(editorView);
} }
} }
......
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