From c1c25a070482d53be23a3ee5a9e30c30e7c4ab01 Mon Sep 17 00:00:00 2001 From: Orgad Shaneh Date: Thu, 14 Nov 2013 09:41:02 +0200 Subject: [PATCH] TextEditor: Allow only a single "select encoding" infobar entry Change-Id: I2e8ac37b2e980bed88e270ccd10cb7319f1f9ffd Reviewed-by: David Schulz --- src/plugins/texteditor/basetexteditor.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/plugins/texteditor/basetexteditor.cpp b/src/plugins/texteditor/basetexteditor.cpp index 851d61c6a8a..63f2a3d7198 100644 --- a/src/plugins/texteditor/basetexteditor.cpp +++ b/src/plugins/texteditor/basetexteditor.cpp @@ -542,14 +542,18 @@ QString BaseTextEditorWidget::msgTextTooLarge(quint64 size) void BaseTextEditorWidget::updateCannotDecodeInfo() { setReadOnly(d->m_document->hasDecodingError()); + Core::InfoBar *infoBar = d->m_document->infoBar(); + Core::Id selectEncodingId(Constants::SELECT_ENCODING); if (d->m_document->hasDecodingError()) { - Core::InfoBarEntry info(Core::Id(Constants::SELECT_ENCODING), + if (!infoBar->canInfoBeAdded(selectEncodingId)) + return; + Core::InfoBarEntry info(selectEncodingId, tr("Error: Could not decode \"%1\" with \"%2\"-encoding. Editing not possible.") .arg(d->m_document->displayName()).arg(QString::fromLatin1(d->m_document->codec()->name()))); info.setCustomButtonInfo(tr("Select Encoding"), this, SLOT(selectEncoding())); - d->m_document->infoBar()->addInfo(info); + infoBar->addInfo(info); } else { - d->m_document->infoBar()->removeInfo(Core::Id(Constants::SELECT_ENCODING)); + infoBar->removeInfo(selectEncodingId); } }