X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;f=src%2Fuisupport%2Fuistyle.cpp;h=99325dc119e0e2d79aaa9f2a541435608899a876;hb=761a147545864782a79570dbaf8f4cc25de7423d;hp=b0a2a3ab65daecfd7cbd601cb9173f842aa210fb;hpb=10c6dbcf23305cc57e2f577600a289cfc0b12c2a;p=quassel.git diff --git a/src/uisupport/uistyle.cpp b/src/uisupport/uistyle.cpp index b0a2a3ab..99325dc1 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_) { @@ -179,7 +193,7 @@ UiStyle::StyledString UiStyle::styleString(const QString &s_) { quint32 curfmt = (quint32)None; int pos = 0; quint16 length = 0; for(;;) { - int pos = s.indexOf('%', pos); + pos = s.indexOf('%', pos); if(pos < 0) break; if(s[pos+1] == '%') { // escaped %, we just remove one and continue s.remove(pos, 1); @@ -228,7 +242,7 @@ UiStyle::StyledString UiStyle::styleString(const QString &s_) { return result; } -QString UiStyle::mircToInternal(const QString &mirc_) { +QString UiStyle::mircToInternal(const QString &mirc_) const { QString mirc = mirc_; mirc.replace('%', "%%"); // escape % just to be sure mirc.replace('\x02', "%B");