Summary: | Trouble with channel topic display using hyperlink colour | ||
---|---|---|---|
Product: | [Applications] konversation | Reporter: | Eike Hein <hein> |
Component: | general | Assignee: | Peter Simonsson <peter.simonsson> |
Status: | RESOLVED FIXED | ||
Severity: | normal | ||
Priority: | NOR | ||
Version: | unspecified | ||
Target Milestone: | --- | ||
Platform: | Gentoo Packages | ||
OS: | Linux | ||
Latest Commit: | Version Fixed In: | ||
Attachments: | Screenshot illustrating the problem |
Description
Eike Hein
2005-03-27 17:49:22 UTC
Links should be same color everywhere. Changing link color just in topic is not possible as it would be inconsistency. Why don't you change your link color? Created attachment 10368 [details]
Screenshot illustrating the problem
Because I'd like my link colour to be white in my (black) chat area. The topic display area, however, is not part of the chat area but part of a KDE GUI widget. Shouldn't it use KDE colours specifically to avoid collisions with the selected KDE GUI colour scheme? KDE colour schemes have a link colour, too, after all :). Another possible fix would be to to change the topic display area into a one-line input box and have it use the same background colour as the chat window. (I've added a screenshot to illustrate the problem.) Psn will fix this :) You guys rock. Nuff' said. ;) CVS commit by psn: Use standard color in the topic label BUG:102608 M +30 -20 common.cpp 1.43 M +1 -1 common.h 1.8 M +1 -1 topiclabel.cpp 1.20 --- kdeextragear-2/konversation/konversation/common.cpp #1.42:1.43 @@ -40,5 +40,5 @@ QString removeIrcMarkup(const QString& t } -QString tagURLs(const QString& text, const QString& fromNick) +QString tagURLs(const QString& text, const QString& fromNick, bool useCustomColor) { //QTime timer; @@ -49,15 +49,21 @@ QString tagURLs(const QString& text, con int pos = 0; int urlLen; + QString href; + QString link; - if(filteredLine.contains("#")) - { + if(filteredLine.contains("#")) { QRegExp chanExp("^(\\s+)?#[a-zA-Z0-9-+]{2,}$"); - while((pos = chanExp.search(filteredLine, pos)) >= 0) - { + while((pos = chanExp.search(filteredLine, pos)) >= 0) { urlLen = chanExp.matchedLength(); - QString href = filteredLine.mid( pos, urlLen ); - QString link = "#" + href.stripWhiteSpace(); - link = "<font color=\"#"+linkColor+"\"><a href=\""+link+"\">"+href+"</a></font>"; + href = filteredLine.mid( pos, urlLen ); + + if(useCustomColor) { + link = "<font color=\"#"+linkColor+"\">%1</font>"; + } else { + link = "%1"; + } + + link = link.arg("<a href=\"#" + href.stripWhiteSpace() + "\">" + href + "</a>"); filteredLine.replace( pos, urlLen, link ); pos += link.length()-1; @@ -72,12 +78,10 @@ QString tagURLs(const QString& text, con urlPattern.setCaseSensitive(false); - while((pos = urlPattern.search(filteredLine, pos)) >= 0) - { + while((pos = urlPattern.search(filteredLine, pos)) >= 0) { urlLen = urlPattern.matchedLength(); - QString href = filteredLine.mid( pos, urlLen ); + href = filteredLine.mid( pos, urlLen ); // Qt doesn't support (?<=pattern) so we do it here - if((pos > 0) && filteredLine[pos-1].isLetterOrNumber()) - { + if((pos > 0) && filteredLine[pos-1].isLetterOrNumber()) { pos++; continue; @@ -92,5 +96,11 @@ QString tagURLs(const QString& text, con } - QString link = "<font color=\"#"+linkColor+"\"><u><a href=\"" + protocol + href + "\">" + href + "</a></u></font>"; + if(useCustomColor) { + link = "<font color=\"#"+linkColor+"\">%1</font>"; + } else { + link = "%1"; + } + + link = link.arg("<u><a href=\"" + protocol + href + "\">" + href + "</a></u>"); filteredLine.replace( pos, urlLen, link ); pos += link.length(); --- kdeextragear-2/konversation/konversation/common.h #1.7:1.8 @@ -22,5 +22,5 @@ namespace Konversation { QString removeIrcMarkup(const QString& text); - QString tagURLs(const QString& text, const QString& fromNick); + QString tagURLs(const QString& text, const QString& fromNick, bool useCustomColor = true); QBitmap overlayMasks( const QBitmap *under, const QBitmap *over ); QPixmap overlayPixmaps(const QPixmap &under, const QPixmap &over); --- kdeextragear-2/konversation/konversation/topiclabel.cpp #1.19:1.20 @@ -150,5 +150,5 @@ void TopicLabel::updateSqueezedText() replace("<", "<"). replace(">", ">"); - text = tagURLs(text, ""); + text = tagURLs(text, "", false); QToolTip::remove(this); commit b041a2bc66f7c20f329bc7eeaea92c0513680e28 Author: Peter Simonsson <peter.simonsson@gmail.com> Date: Sun Mar 27 18:28:26 2005 +0000 Use standard color in the topic label BUG:102608 svn path=/trunk/kdeextragear-2/konversation/; revision=401053 diff --git a/konversation/common.cpp b/konversation/common.cpp index f502ebc..be84062 100644 --- a/konversation/common.cpp +++ b/konversation/common.cpp @@ -39,7 +39,7 @@ QString removeIrcMarkup(const QString& text) return escaped; } -QString tagURLs(const QString& text, const QString& fromNick) +QString tagURLs(const QString& text, const QString& fromNick, bool useCustomColor) { //QTime timer; //timer.start(); @@ -48,21 +48,27 @@ QString tagURLs(const QString& text, const QString& fromNick) QString linkColor = KonversationApplication::preferences.getColor("LinkMessage"); int pos = 0; int urlLen; + QString href; + QString link; - if(filteredLine.contains("#")) - { - QRegExp chanExp("^(\\s+)?#[a-zA-Z0-9-+]{2,}$"); - - while((pos = chanExp.search(filteredLine, pos)) >= 0) - { - urlLen = chanExp.matchedLength(); - QString href = filteredLine.mid( pos, urlLen ); - QString link = "#" + href.stripWhiteSpace(); - link = "<font color=\"#"+linkColor+"\"><a href=\""+link+"\">"+href+"</a></font>"; - filteredLine.replace( pos, urlLen, link ); - pos += link.length()-1; - } + if(filteredLine.contains("#")) { + QRegExp chanExp("^(\\s+)?#[a-zA-Z0-9-+]{2,}$"); + + while((pos = chanExp.search(filteredLine, pos)) >= 0) { + urlLen = chanExp.matchedLength(); + href = filteredLine.mid( pos, urlLen ); + + if(useCustomColor) { + link = "<font color=\"#"+linkColor+"\">%1</font>"; + } else { + link = "%1"; + } + + link = link.arg("<a href=\"#" + href.stripWhiteSpace() + "\">" + href + "</a>"); + filteredLine.replace( pos, urlLen, link ); + pos += link.length()-1; } + } pos = 0; urlLen =0; @@ -71,14 +77,12 @@ QString tagURLs(const QString& text, const QString& fromNick) "([-.\\d\\w]+@[-.\\d\\w]{2,}\\.[\\w]{2,})"); urlPattern.setCaseSensitive(false); - while((pos = urlPattern.search(filteredLine, pos)) >= 0) - { + while((pos = urlPattern.search(filteredLine, pos)) >= 0) { urlLen = urlPattern.matchedLength(); - QString href = filteredLine.mid( pos, urlLen ); + href = filteredLine.mid( pos, urlLen ); // Qt doesn't support (?<=pattern) so we do it here - if((pos > 0) && filteredLine[pos-1].isLetterOrNumber()) - { + if((pos > 0) && filteredLine[pos-1].isLetterOrNumber()) { pos++; continue; } @@ -91,7 +95,13 @@ QString tagURLs(const QString& text, const QString& fromNick) protocol = "mailto:"; } - QString link = "<font color=\"#"+linkColor+"\"><u><a href=\"" + protocol + href + "\">" + href + "</a></u></font>"; + if(useCustomColor) { + link = "<font color=\"#"+linkColor+"\">%1</font>"; + } else { + link = "%1"; + } + + link = link.arg("<u><a href=\"" + protocol + href + "\">" + href + "</a></u>"); filteredLine.replace( pos, urlLen, link ); pos += link.length(); KonversationApplication::instance()->storeUrl(fromNick, href); diff --git a/konversation/common.h b/konversation/common.h index 3940c49..162da83 100644 --- a/konversation/common.h +++ b/konversation/common.h @@ -21,7 +21,7 @@ class QPixmap; namespace Konversation { QString removeIrcMarkup(const QString& text); - QString tagURLs(const QString& text, const QString& fromNick); + QString tagURLs(const QString& text, const QString& fromNick, bool useCustomColor = true); QBitmap overlayMasks( const QBitmap *under, const QBitmap *over ); QPixmap overlayPixmaps(const QPixmap &under, const QPixmap &over); bool isUtf8(const QCString& text); diff --git a/konversation/topiclabel.cpp b/konversation/topiclabel.cpp index 787c328..b18bdaa 100644 --- a/konversation/topiclabel.cpp +++ b/konversation/topiclabel.cpp @@ -149,7 +149,7 @@ void TopicLabel::updateSqueezedText() text.replace("&", "&"). replace("<", "<"). replace(">", ">"); - text = tagURLs(text, ""); + text = tagURLs(text, "", false); QToolTip::remove(this); |