X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fuisupport%2Fuistyle.cpp;h=944b604980c2cb48ab702fc9cb28631dced76771;hp=df23a62e52c5bf1a303c26e7001353bde1cbe93e;hb=e50ae7a06fc4e5d3a911c361d30953410deab609;hpb=4c80eeb2d07b5ca75fd399b51c939961fdff1670 diff --git a/src/uisupport/uistyle.cpp b/src/uisupport/uistyle.cpp index df23a62e..944b6049 100644 --- a/src/uisupport/uistyle.cpp +++ b/src/uisupport/uistyle.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-2013 by the Quassel Project * + * Copyright (C) 2005-2015 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -19,9 +19,9 @@ ***************************************************************************/ #include +#include #include "buffersettings.h" -#include "iconloader.h" #include "qssparser.h" #include "quassel.h" #include "uistyle.h" @@ -33,13 +33,13 @@ QString UiStyle::_timestampFormatString; UiStyle::UiStyle(QObject *parent) : QObject(parent), - _channelJoinedIcon(SmallIcon("irc-channel-active")), - _channelPartedIcon(SmallIcon("irc-channel-inactive")), - _userOfflineIcon(SmallIcon("im-user-offline")), - _userOnlineIcon(SmallIcon("im-user")), - _userAwayIcon(SmallIcon("im-user-away")), - _categoryOpIcon(SmallIcon("irc-operator")), - _categoryVoiceIcon(SmallIcon("irc-voice")), + _channelJoinedIcon(QIcon::fromTheme("irc-channel-joined", QIcon(":/icons/irc-channel-joined.png"))), + _channelPartedIcon(QIcon::fromTheme("irc-channel-parted", QIcon(":/icons/irc-channel-parted.png"))), + _userOfflineIcon(QIcon::fromTheme("im-user-offline", QIcon::fromTheme("user-offline", QIcon(":/icons/im-user-offline.png")))), + _userOnlineIcon(QIcon::fromTheme("im-user", QIcon::fromTheme("user-available", QIcon(":/icons/im-user.png")))), // im-user-* are non-standard oxygen extensions + _userAwayIcon(QIcon::fromTheme("im-user-away", QIcon::fromTheme("user-away", QIcon(":/icons/im-user-away.png")))), + _categoryOpIcon(QIcon::fromTheme("irc-operator")), + _categoryVoiceIcon(QIcon::fromTheme("irc-voice")), _opIconLimit(UserCategoryItem::categoryFromModes("o")), _voiceIconLimit(UserCategoryItem::categoryFromModes("v")) { @@ -491,12 +491,16 @@ QList UiStyle::toTextLayoutList(const FormatList &form UiStyle::StyledString UiStyle::styleString(const QString &s_, quint32 baseFormat) { QString s = s_; + StyledString result; + result.formatList.append(qMakePair((quint16)0, baseFormat)); + if (s.length() > 65535) { + // We use quint16 for indexes qWarning() << QString("String too long to be styled: %1").arg(s); - return StyledString(); + result.plainText = s; + return result; } - StyledString result; - result.formatList.append(qMakePair((quint16)0, baseFormat)); + quint32 curfmt = baseFormat; int pos = 0; quint16 length = 0; for (;;) { @@ -572,6 +576,9 @@ QString UiStyle::mircToInternal(const QString &mirc_) case '\x0f': mirc += "%O"; break; + case '\x09': + mirc += " "; + break; case '\x12': case '\x16': mirc += "%R"; @@ -589,10 +596,6 @@ QString UiStyle::mircToInternal(const QString &mirc_) mirc += QChar(0x2400 + c.unicode()); } } else { - if (c == '\t') { - mirc += " "; - continue; - } if (c == '%') mirc += c; mirc += c; @@ -662,14 +665,11 @@ void UiStyle::StyledMessage::style() const QString t; switch (type()) { case Message::Plain: - //: Plain Message - t = tr("%1").arg(txt); break; + t = QString("%1").arg(txt); break; case Message::Notice: - //: Notice Message - t = tr("%1").arg(txt); break; + t = QString("%1").arg(txt); break; case Message::Action: - //: Action Message - t = tr("%DN%1%DN %2").arg(nick).arg(txt); + t = QString("%DN%1%DN %2").arg(nick).arg(txt); break; case Message::Nick: //: Nick Message @@ -706,23 +706,19 @@ void UiStyle::StyledMessage::style() const //case Message::Kill: FIXME case Message::Server: - //: Server Message - t = tr("%1").arg(txt); break; + t = QString("%1").arg(txt); break; case Message::Info: - //: Info Message - t = tr("%1").arg(txt); break; + t = QString("%1").arg(txt); break; case Message::Error: - //: Error Message - t = tr("%1").arg(txt); break; + t = QString("%1").arg(txt); break; case Message::DayChange: { //: Day Change Message - t = tr("{Day changed to %1}").arg(QLocale().toString(timestamp(), QLocale().dateFormat())); + t = tr("{Day changed to %1}").arg(timestamp().date().toString(Qt::DefaultLocaleLongDate)); } break; case Message::Topic: - //: Topic Message - t = tr("%1").arg(txt); break; + t = QString("%1").arg(txt); break; case Message::NetsplitJoin: { QStringList users = txt.split("#:#"); @@ -755,10 +751,9 @@ void UiStyle::StyledMessage::style() const } break; case Message::Invite: - //: Invite Message - t = tr("%1").arg(txt); break; + t = QString("%1").arg(txt); break; default: - t = tr("[%1]").arg(txt); + t = QString("[%1]").arg(txt); } _contents = UiStyle::styleString(t, UiStyle::formatType(type())); } @@ -804,9 +799,9 @@ QString UiStyle::StyledMessage::decoratedSender() const { switch (type()) { case Message::Plain: - return tr("<%1>").arg(plainSender()); break; + return QString("<%1>").arg(plainSender()); break; case Message::Notice: - return tr("[%1]").arg(plainSender()); break; + return QString("[%1]").arg(plainSender()); break; case Message::Action: return "-*-"; break; case Message::Nick: @@ -859,7 +854,7 @@ quint8 UiStyle::StyledMessage::senderHash() const if (chopCount < nick.size()) nick.chop(chopCount); } - quint16 hash = qChecksum(nick.toAscii().data(), nick.toAscii().size()); + quint16 hash = qChecksum(nick.toLatin1().data(), nick.toLatin1().size()); return (_senderHash = (hash & 0xf) + 1); }