TextEditors: Generalize update mechanism when editors become visible

Generalizes the special handling of font settings, which should only be
applied (on the document) when an editor is or becomes visible.

Change-Id: Icd1e3ba4355e1ff4a837c9679b537cc3f5ed7ea9
Reviewed-by: Fawzi Mohamed <fawzi.mohamed@digia.com>
This commit is contained in:
Eike Ziller
2014-02-06 12:41:29 +01:00
parent 757a5a2867
commit 99dec87406
4 changed files with 16 additions and 14 deletions

View File

@@ -5337,24 +5337,28 @@ void BaseTextEditorWidget::unCommentSelection()
void BaseTextEditorWidget::showEvent(QShowEvent* e)
{
if (d->m_fontSettingsNeedsApply) {
applyFontSettings();
d->m_fontSettingsNeedsApply = false;
}
triggerPendingUpdates();
QPlainTextEdit::showEvent(e);
}
void BaseTextEditorWidget::applyFontSettingsDelayed()
{
d->m_fontSettingsNeedsApply = true;
if (isVisible())
triggerPendingUpdates();
}
void BaseTextEditorWidget::triggerPendingUpdates()
{
if (d->m_fontSettingsNeedsApply)
applyFontSettings();
else
d->m_fontSettingsNeedsApply = true;
baseTextDocument()->triggerPendingUpdates();
}
void BaseTextEditorWidget::applyFontSettings()
{
d->m_fontSettingsNeedsApply = false;
const FontSettings &fs = baseTextDocument()->fontSettings();
const QTextCharFormat textFormat = fs.toTextCharFormat(C_TEXT);
const QTextCharFormat selectionFormat = fs.toTextCharFormat(C_SELECTION);
@@ -5388,8 +5392,6 @@ void BaseTextEditorWidget::applyFontSettings()
slotUpdateExtraAreaWidth(); // Adjust to new font width
updateCurrentLineHighlight(); // Make sure it takes the new color
baseTextDocument()->ensureFontSettingsApplied();
}
void BaseTextEditorWidget::setDisplaySettings(const DisplaySettings &ds)