X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fqtui%2Ftopicwidget.cpp;h=007072c790fcb276400875d70ea4c6129a4d29d3;hp=ed02936efb3e3d2913d0ff8874f78330257239a5;hb=2c8434f74c68194d56f2084f637419123e61d18b;hpb=ce26c3770b254362c7bd1e094ba8f8bf22133653 diff --git a/src/qtui/topicwidget.cpp b/src/qtui/topicwidget.cpp index ed02936e..007072c7 100644 --- a/src/qtui/topicwidget.cpp +++ b/src/qtui/topicwidget.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-2014 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,31 +21,32 @@ #include "topicwidget.h" #include "client.h" -#include "iconloader.h" +#include "icon.h" #include "networkmodel.h" #include "uisettings.h" #include "graphicalui.h" #include "uistyle.h" +#include "util.h" TopicWidget::TopicWidget(QWidget *parent) : AbstractItemView(parent) { ui.setupUi(this); - ui.topicEditButton->setIcon(SmallIcon("edit-rename")); + ui.topicEditButton->setIcon(icon::get("edit-rename")); ui.topicLineEdit->setLineWrapEnabled(true); ui.topicLineEdit->installEventFilter(this); - connect(ui.topicLabel, SIGNAL(clickableActivated(Clickable)), SLOT(clickableActivated(Clickable))); - connect(ui.topicLineEdit, SIGNAL(noTextEntered()), SLOT(on_topicLineEdit_textEntered())); + connect(ui.topicLabel, &StyledLabel::clickableActivated, this, &TopicWidget::clickableActivated); + connect(ui.topicLineEdit, &MultiLineEdit::noTextEntered, this, &TopicWidget::on_topicLineEdit_textEntered); UiSettings s("TopicWidget"); - s.notify("DynamicResize", this, SLOT(updateResizeMode())); - s.notify("ResizeOnHover", this, SLOT(updateResizeMode())); + s.notify("DynamicResize", this, &TopicWidget::updateResizeMode); + s.notify("ResizeOnHover", this, &TopicWidget::updateResizeMode); updateResizeMode(); UiStyleSettings fs("Fonts"); - fs.notify("UseCustomTopicWidgetFont", this, SLOT(setUseCustomFont(QVariant))); - fs.notify("TopicWidget", this, SLOT(setCustomFont(QVariant))); + fs.notify("UseCustomTopicWidgetFont", this, &TopicWidget::setUseCustomFont); + fs.notify("TopicWidget", this, selectOverload(&TopicWidget::setCustomFont)); if (fs.value("UseCustomTopicWidgetFont", false).toBool()) setCustomFont(fs.value("TopicWidget", QFont())); @@ -67,7 +68,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) { @@ -115,8 +116,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())); } @@ -193,7 +194,7 @@ void TopicWidget::updateResizeMode() void TopicWidget::clickableActivated(const Clickable &click) { NetworkId networkId = selectionModel()->currentIndex().data(NetworkModel::NetworkIdRole).value(); - UiStyle::StyledString sstr = GraphicalUi::uiStyle()->styleString(GraphicalUi::uiStyle()->mircToInternal(_topic), UiStyle::PlainMsg); + UiStyle::StyledString sstr = GraphicalUi::uiStyle()->styleString(GraphicalUi::uiStyle()->mircToInternal(_topic), UiStyle::FormatType::PlainMsg); click.activate(networkId, sstr.plainText); } @@ -255,7 +256,7 @@ bool TopicWidget::eventFilter(QObject *obj, QEvent *event) if (event->type() != QEvent::KeyRelease) return QObject::eventFilter(obj, event); - QKeyEvent *keyEvent = static_cast(event); + auto *keyEvent = static_cast(event); if (keyEvent->key() == Qt::Key_Escape) { switchPlain(); @@ -272,6 +273,7 @@ QString TopicWidget::sanitizeTopic(const QString& topic) // 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, " ");