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.
QString NetworkItem::escapeHTML(const QString &string, bool useNonbreakingSpaces)
{
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);
// Use a local variable to avoid compiler errors.
#if QT_VERSION < 0x050000
QString formattedString = Qt::escape(string);
Q_UNUSED(column);
QString strTooltip;
QTextStream tooltip( &strTooltip, QIODevice::WriteOnly );
Q_UNUSED(column);
QString strTooltip;
QTextStream tooltip( &strTooltip, QIODevice::WriteOnly );
- tooltip << "<qt><style>.bold { font-weight: bold; }</style>"
- << "<style>.italic { font-style: italic; }</style>";
+ tooltip << "<qt><style>.bold { font-weight: bold; } .italic { font-style: italic; }</style>";
// Keep track of whether or not information has been added
bool infoAdded = false;
// Keep track of whether or not information has been added
bool infoAdded = false;
tooltip << "<table cellspacing='5' cellpadding='0'>";
if (_ircUser->isAway()) {
tooltip << "<table cellspacing='5' cellpadding='0'>";
if (_ircUser->isAway()) {
- QString awayMessage(tr("(unknown)"));
- if(!_ircUser->awayMessage().isEmpty()) {
- awayMessage = _ircUser->awayMessage();
+ QString awayMessageHTML = QString("<p class='italic'>%1</p>").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()),
}
addRow(tr("Realname"),
NetworkItem::escapeHTML(_ircUser->realName()),
// If no further information found, offer an explanatory message
if (!infoAdded)
// If no further information found, offer an explanatory message
if (!infoAdded)
- tooltip << "<p class='italic'>" << tr("No information available") << "</p>";
+ tooltip << "<p class='italic' align='center'>" << tr("No information available") << "</p>";
tooltip << "</qt>";
return strTooltip;
tooltip << "</qt>";
return strTooltip;
Q_UNUSED(column);
QString strTooltip;
QTextStream tooltip( &strTooltip, QIODevice::WriteOnly );
Q_UNUSED(column);
QString strTooltip;
QTextStream tooltip( &strTooltip, QIODevice::WriteOnly );
- tooltip << "<qt><style>.bold { font-weight: bold; }</style>"
- << "<qt><style>.italic { font-style: italic; }</style>";
+ tooltip << "<qt><style>.bold { font-weight: bold; } .italic { font-style: italic; }</style>";
// Function to add a row to the tooltip table
auto addRow = [&](const QString& key, const QString& value, bool condition) {
// Function to add a row to the tooltip table
auto addRow = [&](const QString& key, const QString& value, bool condition) {
tooltip << "</table>";
} else {
tooltip << "</table>";
} else {
- tooltip << "<p class='italic'>" << tr("Not active, double-click to join") << "</p>";
+ tooltip << "<p class='italic' align='center'>" << tr("Not active, double-click to join") << "</p>";
Q_UNUSED(column);
QString strTooltip;
QTextStream tooltip( &strTooltip, QIODevice::WriteOnly );
Q_UNUSED(column);
QString strTooltip;
QTextStream tooltip( &strTooltip, QIODevice::WriteOnly );
- tooltip << "<qt><style>.bold { font-weight: bold; }</style>"
- << "<style>.italic { font-style: italic; }</style>";
+ tooltip << "<qt><style>.bold { font-weight: bold; } .italic { font-style: italic; }</style>";
// Keep track of whether or not information has been added
bool infoAdded = false;
// Keep track of whether or not information has been added
bool infoAdded = false;
NetworkItem::escapeHTML(channelModes()),
!channelModes().isEmpty());
if (_ircUser->isAway()) {
NetworkItem::escapeHTML(channelModes()),
!channelModes().isEmpty());
if (_ircUser->isAway()) {
- QString awayMessage(tr("(unknown)"));
- if(!_ircUser->awayMessage().isEmpty()) {
- awayMessage = _ircUser->awayMessage();
+ QString awayMessageHTML = QString("<p class='italic'>%1</p>").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()),
}
addRow(tr("Realname"),
NetworkItem::escapeHTML(_ircUser->realName()),
// If no further information found, offer an explanatory message
if (!infoAdded)
// If no further information found, offer an explanatory message
if (!infoAdded)
- tooltip << "<p class='italic'>" << tr("No information available") << "</p>";
+ tooltip << "<p class='italic' align='center'>" << tr("No information available") << "</p>";
tooltip << "</qt>";
return strTooltip;
tooltip << "</qt>";
return strTooltip;