Editor: Support floating point values for tab stop

Task-number: QTCREATORBUG-833

Change-Id: I76a4b69d6e9402f045a98712531475aff5e8d0ac
Reviewed-by: Eike Ziller <eike.ziller@nokia.com>
This commit is contained in:
Leandro Melo
2011-10-31 13:37:23 +01:00
committed by Eike Ziller
parent 19ea22a2ac
commit 24fc61857c

View File

@@ -5482,8 +5482,13 @@ void BaseTextEditorWidget::setFontSettings(const TextEditor::FontSettings &fs)
void BaseTextEditorWidget::setTabSettings(const TabSettings &ts)
{
d->m_document->setTabSettings(ts);
int charWidth = QFontMetrics(font()).width(QChar(' '));
setTabStopWidth(charWidth * ts.m_tabSize);
// Although the tab stop is stored as qreal the API from QPlainTextEdit only allows it
// to be set as an int. A work around is to access directly the QTextOption.
qreal charWidth = QFontMetricsF(font()).width(QChar(' '));
QTextOption option = document()->defaultTextOption();
option.setTabStop(charWidth * ts.m_tabSize);
document()->setDefaultTextOption(option);
}
void BaseTextEditorWidget::setDisplaySettings(const DisplaySettings &ds)