X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fqtui%2Ftopicwidget.cpp;h=13987e6c6e14c43d6d7a9578acb88ff1e262a8d2;hp=4af94b6b95c9e3a2c5e0ebe4ba089c6a167c8b72;hb=f04db2cb802b1296ca739c823495930c71d3b4ab;hpb=5b686746c880e5cda6d5de3e08180ea4332ff222 diff --git a/src/qtui/topicwidget.cpp b/src/qtui/topicwidget.cpp index 4af94b6b..13987e6c 100644 --- a/src/qtui/topicwidget.cpp +++ b/src/qtui/topicwidget.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 * @@ -24,6 +24,8 @@ #include "iconloader.h" #include "networkmodel.h" #include "uisettings.h" +#include "graphicalui.h" +#include "uistyle.h" TopicWidget::TopicWidget(QWidget *parent) : AbstractItemView(parent) @@ -154,12 +156,12 @@ void TopicWidget::setTopic(const QModelIndex &index) } } - _topic = newtopic; + _topic = sanitizeTopic(newtopic); _readonly = readonly; ui.topicEditButton->setVisible(!_readonly); - ui.topicLabel->setText(newtopic); - ui.topicLineEdit->setPlainText(newtopic); + ui.topicLabel->setText(_topic); + ui.topicLineEdit->setPlainText(_topic); switchPlain(); } @@ -191,7 +193,8 @@ void TopicWidget::updateResizeMode() void TopicWidget::clickableActivated(const Clickable &click) { NetworkId networkId = selectionModel()->currentIndex().data(NetworkModel::NetworkIdRole).value(); - click.activate(networkId, _topic); + UiStyle::StyledString sstr = GraphicalUi::uiStyle()->styleString(GraphicalUi::uiStyle()->mircToInternal(_topic), UiStyle::PlainMsg); + click.activate(networkId, sstr.plainText); } @@ -261,3 +264,16 @@ bool TopicWidget::eventFilter(QObject *obj, QEvent *event) return false; } + +QString TopicWidget::sanitizeTopic(const QString& topic) +{ + // Normally, you don't have new lines in topic messages + // But the use of "plain text" functionnality from Qt replaces + // some unicode characters with a new line, which then triggers + // a stack overflow later + QString result(topic); + result.replace(QChar::ParagraphSeparator, " "); + result.replace(QChar::LineSeparator, " "); + + return result; +}