forked from qt-creator/qt-creator
Editor: Don't change the focus when setting a new view.
Move the focus logic to activateView. Use activateView when it makes sense. Change-Id: I79ad11eea629fc1aaa194ecdd8995f5965d1b806 Reviewed-by: Eike Ziller <eike.ziller@theqtcompany.com>
This commit is contained in:
@@ -1070,13 +1070,16 @@ void EditorManagerPrivate::closeEditorOrDocument(IEditor *editor)
|
||||
void EditorManagerPrivate::activateView(EditorView *view)
|
||||
{
|
||||
QTC_ASSERT(view, return);
|
||||
QWidget *focusWidget;
|
||||
if (IEditor *editor = view->currentEditor()) {
|
||||
setCurrentEditor(editor, true);
|
||||
editor->widget()->setFocus();
|
||||
ICore::raiseWindow(editor->widget());
|
||||
focusWidget = editor->widget();
|
||||
} else {
|
||||
setCurrentView(view);
|
||||
focusWidget = view;
|
||||
}
|
||||
focusWidget->setFocus();
|
||||
ICore::raiseWindow(focusWidget);
|
||||
}
|
||||
|
||||
void EditorManagerPrivate::restoreEditorState(IEditor *editor)
|
||||
@@ -1134,11 +1137,6 @@ void EditorManagerPrivate::setCurrentView(EditorView *view)
|
||||
old->update();
|
||||
if (view)
|
||||
view->update();
|
||||
|
||||
if (view && !view->currentEditor()) {
|
||||
view->setFocus();
|
||||
ICore::raiseWindow(view);
|
||||
}
|
||||
}
|
||||
|
||||
EditorArea *EditorManagerPrivate::findEditorArea(const EditorView *view, int *areaIndex)
|
||||
@@ -1176,12 +1174,8 @@ void EditorManagerPrivate::closeView(EditorView *view)
|
||||
splitter->unsplit();
|
||||
|
||||
EditorView *newCurrent = splitter->findFirstView();
|
||||
if (newCurrent) {
|
||||
if (IEditor *e = newCurrent->currentEditor())
|
||||
EditorManagerPrivate::activateEditor(newCurrent, e);
|
||||
else
|
||||
EditorManagerPrivate::setCurrentView(newCurrent);
|
||||
}
|
||||
if (newCurrent)
|
||||
EditorManagerPrivate::activateView(newCurrent);
|
||||
}
|
||||
|
||||
void EditorManagerPrivate::emptyView(EditorView *view)
|
||||
@@ -1552,10 +1546,7 @@ void EditorManagerPrivate::editorAreaDestroyed(QObject *area)
|
||||
EditorView *focusView = focusSplitterOrView->findFirstView(); // can be just focusSplitterOrView
|
||||
QTC_ASSERT(focusView, focusView = newActiveArea->findFirstView());
|
||||
QTC_ASSERT(focusView, return);
|
||||
if (focusView->currentEditor())
|
||||
setCurrentEditor(focusView->currentEditor());
|
||||
else
|
||||
setCurrentView(focusView);
|
||||
EditorManagerPrivate::activateView(focusView);
|
||||
}
|
||||
|
||||
void EditorManagerPrivate::autoSave()
|
||||
@@ -2168,12 +2159,8 @@ bool EditorManager::closeEditors(const QList<IEditor*> &editorsToClose, bool ask
|
||||
foreach (IEditor *editor, acceptedEditors)
|
||||
delete editor;
|
||||
|
||||
if (currentView && !currentViewHandled) {
|
||||
if (IEditor *editor = currentView->currentEditor())
|
||||
EditorManagerPrivate::activateEditor(currentView, editor);
|
||||
else
|
||||
EditorManagerPrivate::setCurrentView(currentView);
|
||||
}
|
||||
if (currentView && !currentViewHandled)
|
||||
EditorManagerPrivate::activateView(currentView);
|
||||
|
||||
if (!currentEditor()) {
|
||||
emit m_instance->currentEditorChanged(0);
|
||||
|
@@ -97,6 +97,7 @@ public:
|
||||
|
||||
static EditorView *viewForEditor(IEditor *editor);
|
||||
static void setCurrentView(EditorView *view);
|
||||
static void activateView(EditorView *view);
|
||||
|
||||
static MakeWritableResult makeFileWritable(IDocument *document);
|
||||
static void doEscapeKeyFocusMoveMagic();
|
||||
@@ -177,7 +178,6 @@ private:
|
||||
static void addEditor(IEditor *editor);
|
||||
static void removeEditor(IEditor *editor);
|
||||
static IEditor *placeEditor(EditorView *view, IEditor *editor);
|
||||
static void activateView(EditorView *view);
|
||||
static void restoreEditorState(IEditor *editor);
|
||||
static int visibleDocumentsCount();
|
||||
static EditorArea *findEditorArea(const EditorView *view, int *areaIndex = 0);
|
||||
|
@@ -681,10 +681,7 @@ void SplitterOrView::split(Qt::Orientation orientation)
|
||||
otherView->view()->setCloseSplitIcon(QIcon(QLatin1String(Constants::ICON_CLOSE_SPLIT_BOTTOM)));
|
||||
}
|
||||
|
||||
if (e)
|
||||
EditorManagerPrivate::activateEditor(otherView->view(), e);
|
||||
else
|
||||
EditorManagerPrivate::setCurrentView(otherView->view());
|
||||
EditorManagerPrivate::activateView(otherView->view());
|
||||
emit splitStateChanged();
|
||||
}
|
||||
|
||||
@@ -785,7 +782,10 @@ void SplitterOrView::unsplit()
|
||||
m_layout->setCurrentWidget(m_view);
|
||||
}
|
||||
delete oldSplitter;
|
||||
EditorManagerPrivate::setCurrentView(findFirstView());
|
||||
if (EditorView *newCurrent = findFirstView())
|
||||
EditorManagerPrivate::activateView(newCurrent);
|
||||
else
|
||||
EditorManagerPrivate::setCurrentView(0);
|
||||
emit splitStateChanged();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user