From: Shane Synan Date: Tue, 14 Jun 2016 14:16:08 +0000 (-0400) Subject: Center-align tooltips, fix QML, italicize unknown X-Git-Tag: travis-deploy-test~447 X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=commitdiff_plain;h=e7d44b7bcbe523f75aa7d674c1f69fd8709072b0 Center-align tooltips, fix QML, italicize unknown Center-align the "No information available" and "Not active" tooltip messages to keep them consistent with the centered table layouts. Fix and simplify tooltip QML formatting. Use italics when displaying an unknown away message. This avoids clashing with someone having the literal away message "(unknown)" Resolves GH-214. --- diff --git a/src/client/networkmodel.cpp b/src/client/networkmodel.cpp index bba21756..599b7108 100644 --- a/src/client/networkmodel.cpp +++ b/src/client/networkmodel.cpp @@ -76,7 +76,7 @@ QVariant NetworkItem::data(int column, int role) const QString NetworkItem::escapeHTML(const QString &string, bool useNonbreakingSpaces) { - // QString.replace() doesn't guarentee the source string will remain constant. + // QString.replace() doesn't guarantee the source string will remain constant. // Use a local variable to avoid compiler errors. #if QT_VERSION < 0x050000 QString formattedString = Qt::escape(string); @@ -522,8 +522,7 @@ QString QueryBufferItem::toolTip(int column) const Q_UNUSED(column); QString strTooltip; QTextStream tooltip( &strTooltip, QIODevice::WriteOnly ); - tooltip << "" - << ""; + tooltip << ""; // Keep track of whether or not information has been added bool infoAdded = false; @@ -552,11 +551,13 @@ QString QueryBufferItem::toolTip(int column) const tooltip << ""; if (_ircUser->isAway()) { - QString awayMessage(tr("(unknown)")); - if(!_ircUser->awayMessage().isEmpty()) { - awayMessage = _ircUser->awayMessage(); + QString awayMessageHTML = QString("

%1

").arg(tr("Unknown")); + + // If away message is known, replace with the escaped message. + if (!_ircUser->awayMessage().isEmpty()) { + awayMessageHTML = NetworkItem::escapeHTML(_ircUser->awayMessage()); } - addRow(NetworkItem::escapeHTML(tr("Away message"), true), NetworkItem::escapeHTML(awayMessage), true); + addRow(NetworkItem::escapeHTML(tr("Away message"), true), awayMessageHTML, true); } addRow(tr("Realname"), NetworkItem::escapeHTML(_ircUser->realName()), @@ -629,7 +630,7 @@ QString QueryBufferItem::toolTip(int column) const // If no further information found, offer an explanatory message if (!infoAdded) - tooltip << "

" << tr("No information available") << "

"; + tooltip << "

" << tr("No information available") << "

"; tooltip << ""; return strTooltip; @@ -690,8 +691,7 @@ QString ChannelBufferItem::toolTip(int column) const Q_UNUSED(column); QString strTooltip; QTextStream tooltip( &strTooltip, QIODevice::WriteOnly ); - tooltip << "" - << ""; + tooltip << ""; // Function to add a row to the tooltip table auto addRow = [&](const QString& key, const QString& value, bool condition) { @@ -726,7 +726,7 @@ QString ChannelBufferItem::toolTip(int column) const tooltip << "
"; } else { - tooltip << "

" << tr("Not active, double-click to join") << "

"; + tooltip << "

" << tr("Not active, double-click to join") << "

"; } tooltip << "
"; @@ -1076,8 +1076,7 @@ QString IrcUserItem::toolTip(int column) const Q_UNUSED(column); QString strTooltip; QTextStream tooltip( &strTooltip, QIODevice::WriteOnly ); - tooltip << "" - << ""; + tooltip << ""; // Keep track of whether or not information has been added bool infoAdded = false; @@ -1103,11 +1102,13 @@ QString IrcUserItem::toolTip(int column) const NetworkItem::escapeHTML(channelModes()), !channelModes().isEmpty()); if (_ircUser->isAway()) { - QString awayMessage(tr("(unknown)")); - if(!_ircUser->awayMessage().isEmpty()) { - awayMessage = _ircUser->awayMessage(); + QString awayMessageHTML = QString("

%1

").arg(tr("Unknown")); + + // If away message is known, replace with the escaped message. + if (!_ircUser->awayMessage().isEmpty()) { + awayMessageHTML = NetworkItem::escapeHTML(_ircUser->awayMessage()); } - addRow(NetworkItem::escapeHTML(tr("Away message"), true), NetworkItem::escapeHTML(awayMessage), true); + addRow(NetworkItem::escapeHTML(tr("Away message"), true), awayMessageHTML, true); } addRow(tr("Realname"), NetworkItem::escapeHTML(_ircUser->realName()), @@ -1180,7 +1181,7 @@ QString IrcUserItem::toolTip(int column) const // If no further information found, offer an explanatory message if (!infoAdded) - tooltip << "

" << tr("No information available") << "

"; + tooltip << "

" << tr("No information available") << "

"; tooltip << "
"; return strTooltip;