Editor: Add feature for set/unset UTF-8 BOM

Change-Id: Iec7e36b1d7a526d7fa8a8096110b91f9c4cc44f9
Reviewed-by: Leandro Melo <leandro.melo@nokia.com>
Reviewed-by: Eike Ziller <eike.ziller@nokia.com>
This commit is contained in:
Yuchen Deng
2012-03-02 08:16:23 +08:00
committed by Eike Ziller
parent a2d3d7f3bf
commit 012ff2d22a
7 changed files with 35 additions and 0 deletions

View File

@@ -5838,6 +5838,11 @@ void BaseTextEditorWidget::circularPaste()
QPlainTextEdit::copy();
}
void BaseTextEditorWidget::switchUtf8bom()
{
baseTextDocument()->switchUtf8Bom();
}
QMimeData *BaseTextEditorWidget::createMimeDataFromSelection() const
{
if (d->m_inBlockSelectionMode) {
@@ -6087,6 +6092,17 @@ void BaseTextEditorWidget::appendStandardContextMenuActions(QMenu *menu)
a = am->command(Constants::CIRCULAR_PASTE)->action();
if (a && a->isEnabled())
menu->addAction(a);
BaseTextDocument *doc = baseTextDocument();
if (doc->codec()->name() == QString(QLatin1String("UTF-8"))) {
a = am->command(Constants::SWITCH_UTF8BOM)->action();
if (a && a->isEnabled()) {
a->setText(doc->format().hasUtf8Bom ? tr("Delete UTF-8 BOM on Save")
: tr("Add UTF-8 BOM on Save"));
menu->addSeparator();
menu->addAction(a);
}
}
}