Commit ac36fac1 authored by mae's avatar mae
Browse files

reduce startup flicker with editor toolbars.

parent 364a869e
......@@ -871,6 +871,7 @@ IEditor *EditorManager::openEditor(const QString &fileName, const QString &edito
restoreEditorState(editor);
QApplication::restoreOverrideCursor();
ensureEditorManagerVisible();
setCurrentEditor(editor);
return editor;
}
......@@ -1351,6 +1352,8 @@ bool EditorManager::restoreState(const QByteArray &state)
if (!success)
return false;
QApplication::setOverrideCursor(Qt::WaitCursor);
bool editorChangesSuppressed = m_d->m_suppressEditorChanges;
m_d->m_suppressEditorChanges = true;
......@@ -1366,6 +1369,8 @@ bool EditorManager::restoreState(const QByteArray &state)
m_d->m_suppressEditorChanges = editorChangesSuppressed;
if (currentEditor())
setCurrentEditor(currentEditor());// looks like a null-op but is not
QApplication::restoreOverrideCursor();
return true;
}
......
......@@ -225,12 +225,11 @@ void StackedEditorGroup::insertEditor(int index, IEditor *editor)
m_widgetEditorMap.insert(editor->widget(), editor);
QToolBar *toolBar = editor->toolBar();
if (toolBar)
if (toolBar) {
toolBar->setVisible(false); // will be made visible in setCurrentEditor
m_toolBar->layout()->addWidget(toolBar);
connect(editor, SIGNAL(changed()), this, SLOT(updateEditorStatus()));
updateEditorStatus(editor);
updateToolBar(editor);
}
connect(editor, SIGNAL(changed()), this, SLOT(checkEditorStatus()));
emit editorAdded(editor);
}
......@@ -284,23 +283,26 @@ void StackedEditorGroup::setCurrentEditor(IEditor *editor)
const bool block = m_editorList->blockSignals(true);
m_editorList->setCurrentIndex(indexOf(editor));
m_editorList->blockSignals(block);
updateEditorStatus(editor);
updateToolBar(editor);
}
setEditorFocus(idx);
updateEditorStatus(editor);
updateToolBar(editor);
if (editor != m_editorForInfoWidget) {
m_infoWidget->hide();
m_editorForInfoWidget = 0;
}
}
void StackedEditorGroup::updateEditorStatus(IEditor *editor)
void StackedEditorGroup::checkEditorStatus()
{
if (!editor)
editor = qobject_cast<IEditor *>(sender());
QTC_ASSERT(editor, return);
IEditor *editor = qobject_cast<IEditor *>(sender());
if (editor == currentEditor())
updateEditorStatus(editor);
}
void StackedEditorGroup::updateEditorStatus(IEditor *editor)
{
static const QIcon lockedIcon(QLatin1String(":/qworkbench/images/locked.png"));
static const QIcon unlockedIcon(QLatin1String(":/qworkbench/images/unlocked.png"));
......@@ -325,8 +327,8 @@ void StackedEditorGroup::updateToolBar(IEditor *editor)
toolBar = m_defaultToolBar;
if (m_activeToolBar == toolBar)
return;
m_activeToolBar->setVisible(false);
toolBar->setVisible(true);
m_activeToolBar->setVisible(false);
m_activeToolBar = toolBar;
}
......
......@@ -80,6 +80,7 @@ protected:
private slots:
void sendCloseRequest();
void updateEditorStatus(Core::IEditor *editor = 0);
void checkEditorStatus();
void setEditorFocus(int index);
void makeEditorWritable();
void listSelectionChanged(int index);
......
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