X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fqtui%2Ftopicwidget.cpp;h=5426b08b2b4b603bd93023955ecc1ee3a0e571e9;hp=8b8e16d4f8e960fb1231b2fda7c34ac9370df8d6;hb=00e1a9c29e792ba4d65dba21b7ba04131bcb13bc;hpb=04315f46a16fc3627218377071e008b6b9744992 diff --git a/src/qtui/topicwidget.cpp b/src/qtui/topicwidget.cpp index 8b8e16d4..5426b08b 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-2018 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -21,16 +21,18 @@ #include "topicwidget.h" #include "client.h" -#include "iconloader.h" +#include "icon.h" #include "networkmodel.h" #include "uisettings.h" +#include "graphicalui.h" +#include "uistyle.h" TopicWidget::TopicWidget(QWidget *parent) : AbstractItemView(parent) { ui.setupUi(this); - ui.topicEditButton->setIcon(SmallIcon("edit-rename")); - ui.topicLineEdit->setWordWrapEnabled(true); + ui.topicEditButton->setIcon(icon::get("edit-rename")); + ui.topicLineEdit->setLineWrapEnabled(true); ui.topicLineEdit->installEventFilter(this); connect(ui.topicLabel, SIGNAL(clickableActivated(Clickable)), SLOT(clickableActivated(Clickable))); @@ -65,7 +67,7 @@ void TopicWidget::dataChanged(const QModelIndex &topLeft, const QModelIndex &bot QModelIndex currentTopicIndex = selectionModel()->currentIndex().sibling(selectionModel()->currentIndex().row(), 1); if (changedArea.contains(currentTopicIndex)) setTopic(selectionModel()->currentIndex()); -}; +} void TopicWidget::setUseCustomFont(const QVariant &v) { @@ -113,8 +115,8 @@ void TopicWidget::setTopic(const QModelIndex &index) case BufferInfo::StatusBuffer: if (network) { newtopic = QString("%1 (%2) | %3 | %4") - .arg(Qt::escape(network->networkName())) - .arg(Qt::escape(network->currentServer())) + .arg(network->networkName().toHtmlEscaped()) + .arg(network->currentServer().toHtmlEscaped()) .arg(tr("Users: %1").arg(network->ircUsers().count())) .arg(tr("Lag: %1 msecs").arg(network->latency())); } @@ -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::FormatType::PlainMsg); + click.activate(networkId, sstr.plainText); } @@ -261,3 +264,17 @@ 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::CarriageReturn, " "); + result.replace(QChar::ParagraphSeparator, " "); + result.replace(QChar::LineSeparator, " "); + + return result; +}