Commit c1c25a07 authored by Orgad Shaneh's avatar Orgad Shaneh Committed by Orgad Shaneh

TextEditor: Allow only a single "select encoding" infobar entry

Change-Id: I2e8ac37b2e980bed88e270ccd10cb7319f1f9ffd
Reviewed-by: default avatarDavid Schulz <david.schulz@digia.com>
parent e2d24a8b
......@@ -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("<b>Error:</b> 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);
}
}
......
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