X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fuisupport%2Fuistyle.cpp;h=3b55d68b5a0c1b5bfd1b0056ea746209330b6f60;hp=b0a2a3ab65daecfd7cbd601cb9173f842aa210fb;hb=7e051ca7bf165df865b61fe07a80699e5ea0503e;hpb=b8af0b4fe92cd17d69c41df613dd660d48d5fca6 diff --git a/src/uisupport/uistyle.cpp b/src/uisupport/uistyle.cpp index b0a2a3ab..3b55d68b 100644 --- a/src/uisupport/uistyle.cpp +++ b/src/uisupport/uistyle.cpp @@ -40,7 +40,7 @@ UiStyle::UiStyle(const QString &settingsKey) : _settingsKey(settingsKey) { _defaultPlainFormat.font().setFixedPitch(true); _defaultPlainFormat.font().setStyleHint(QFont::TypeWriter); setFormat(None, _defaultPlainFormat, Settings::Default); - + // Load saved custom formats UiStyleSettings s(_settingsKey); foreach(FormatType type, s.availableFormats()) { @@ -166,6 +166,20 @@ QString UiStyle::formatCode(FormatType ftype) const { return _formatCodes.key(ftype); } +QList UiStyle::toTextLayoutList(const FormatList &formatList, int textLength) { + QList formatRanges; + QTextLayout::FormatRange range; + int i = 0; + for(i = 0; i < formatList.count(); i++) { + range.format = mergedFormat(formatList.at(i).second); + range.start = formatList.at(i).first; + if(i > 0) formatRanges.last().length = range.start - formatRanges.last().start; + formatRanges.append(range); + } + if(i > 0) formatRanges.last().length = textLength - formatRanges.last().start; + return formatRanges; +} + // This method expects a well-formatted string, there is no error checking! // Since we create those ourselves, we should be pretty safe that nobody does something crappy here. UiStyle::StyledString UiStyle::styleString(const QString &s_) {