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