X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fuisupport%2Fuistyle.cpp;h=dd530bd3a02485cb6b433b9f188fd18a9a2947c4;hp=549f5a9fa82598b6cd262d40a5996334c592e952;hb=11d63f3740fd49eb32b5f604c17452913f9ae3d5;hpb=c64a887d0f05222590299fb2bb8d56fa9fadb16d diff --git a/src/uisupport/uistyle.cpp b/src/uisupport/uistyle.cpp index 549f5a9f..dd530bd3 100644 --- a/src/uisupport/uistyle.cpp +++ b/src/uisupport/uistyle.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-2012 by the Quassel Project * + * Copyright (C) 2005-2013 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -561,15 +561,42 @@ UiStyle::StyledString UiStyle::styleString(const QString &s_, quint32 baseFormat QString UiStyle::mircToInternal(const QString &mirc_) { - QString mirc = mirc_; - mirc.replace('%', "%%"); // escape % just to be sure - mirc.replace('\t', " "); // tabs break layout, also this is italics in Konversation - mirc.replace('\x02', "%B"); - mirc.replace('\x0f', "%O"); - mirc.replace('\x12', "%R"); - mirc.replace('\x16', "%R"); - mirc.replace('\x1d', "%S"); - mirc.replace('\x1f', "%U"); + QString mirc; + mirc.reserve(mirc_.size()); + foreach (const QChar &c, mirc_) { + if ((c < '\x20' || c == '\x7f') && c != '\x03') { + switch (c.unicode()) { + case '\x02': + mirc += "%B"; + break; + case '\x0f': + mirc += "%O"; + break; + case '\x09': + mirc += " "; + break; + case '\x12': + case '\x16': + mirc += "%R"; + break; + case '\x1d': + mirc += "%S"; + break; + case '\x1f': + mirc += "%U"; + break; + case '\x7f': + mirc += QChar(0x2421); + break; + default: + mirc += QChar(0x2400 + c.unicode()); + } + } else { + if (c == '%') + mirc += c; + mirc += c; + } + } // Now we bring the color codes (\x03) in a sane format that can be parsed more easily later. // %Dcfxx is foreground, %Dcbxx is background color, where xx is a 2 digit dec number denoting the color code. @@ -688,10 +715,8 @@ void UiStyle::StyledMessage::style() const t = tr("%1").arg(txt); break; case Message::DayChange: { - //: Date format. See http://qt-project.org/doc/qt-4.8/qdate.html#toString - QString newDate = timestamp().toString(tr("MMMM d yyyy")); //: Day Change Message - t = tr("{Day changed to %1}").arg(newDate); + t = tr("{Day changed to %1}").arg(timestamp().date().toString(Qt::DefaultLocaleLongDate)); } break; case Message::Topic: