X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;f=src%2Fqtui%2Ftopicwidget.cpp;h=ed02936efb3e3d2913d0ff8874f78330257239a5;hb=3d3a6b8d34b9d0ab3a2502936c49c0d0d5e91617;hp=827452cc987630467ab132f192afa4eb918d5a65;hpb=2a912804c20a066356db4e156661468ca49bcc57;p=quassel.git diff --git a/src/qtui/topicwidget.cpp b/src/qtui/topicwidget.cpp index 827452cc..ed02936e 100644 --- a/src/qtui/topicwidget.cpp +++ b/src/qtui/topicwidget.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-2013 by the Quassel Project * + * Copyright (C) 2005-2014 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -32,7 +32,7 @@ TopicWidget::TopicWidget(QWidget *parent) { ui.setupUi(this); ui.topicEditButton->setIcon(SmallIcon("edit-rename")); - ui.topicLineEdit->setWordWrapEnabled(true); + ui.topicLineEdit->setLineWrapEnabled(true); ui.topicLineEdit->installEventFilter(this); connect(ui.topicLabel, SIGNAL(clickableActivated(Clickable)), SLOT(clickableActivated(Clickable))); @@ -156,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(); } @@ -264,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; +}