Bug 102608 - Trouble with channel topic display using hyperlink colour
Summary: Trouble with channel topic display using hyperlink colour
Status: RESOLVED FIXED
Alias: None
Product: konversation
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Gentoo Packages Linux
: NOR normal
Target Milestone: ---
Assignee: Peter Simonsson
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-03-27 17:49 UTC by Eike Hein
Modified: 2010-07-01 16:01 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments
Screenshot illustrating the problem (9.46 KB, image/png)
2005-03-27 18:05 UTC, Eike Hein
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Eike Hein 2005-03-27 17:49:22 UTC
Version:           0.16 (using KDE KDE 3.4.0)
Installed from:    Gentoo Packages
Compiler:          GCC 3.3 
OS:                Linux

I'm using a black background colour for my chat window; my hyperlink colour is set to white. Thus hyperlinks in the channel topic display area above the chat window are shown white as well. This poses a problem for me, since white text is nearly unreadable in conjunction with my KDE GUI colour scheme.

I suggest to use the KDE default GUI text colour, unless there are (m)IRC colour codes in the topic string.
Comment 1 Ismail Donmez 2005-03-27 17:58:48 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?
Comment 2 Eike Hein 2005-03-27 18:05:45 UTC
Created attachment 10368 [details]
Screenshot illustrating the problem
Comment 3 Eike Hein 2005-03-27 18:06:35 UTC
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.)
Comment 4 Ismail Donmez 2005-03-27 18:10:42 UTC
Psn will fix this :)
Comment 5 Eike Hein 2005-03-27 18:42:37 UTC
You guys rock. Nuff' said. ;)
Comment 6 Peter Simonsson 2005-03-27 20:28:34 UTC
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("<", "&lt;").
       replace(">", "&gt;");
-  text = tagURLs(text, "");
+  text = tagURLs(text, "", false);
 
   QToolTip::remove(this);
Comment 7 Peter Simonsson 2010-07-01 16:01:18 UTC
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("&", "&amp;").
       replace("<", "&lt;").
       replace(">", "&gt;");
-  text = tagURLs(text, "");
+  text = tagURLs(text, "", false);
 
   QToolTip::remove(this);