[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    kdenonbeta/kopete/kopete
From:       Will Stephenson <lists () stevello ! free-online ! co ! uk>
Date:       2003-08-18 22:53:29
[Download RAW message or body]

CVS commit by wstephens: 

Provide clickable links that dismiss the balloon.  It's great for sending hot URLs \
around the office (yes, really)!  

The long text squeezing code could be made more clever (squeeze long links but keep \
the href="" attribute in the html), but I haven't got time to do it right now. \
CCMAIL:kopete-devel@mail.kde.org


  M +7 -1      kopeteballoon.cpp   1.14
  M +22 -4     systemtray.cpp   1.21


--- kdenonbeta/kopete/kopete/kopeteballoon.cpp  #1.13:1.14
@@ -33,4 +33,5 @@
 #include <klocale.h>
 #include <kstandarddirs.h>
+#include <kactivelabel.h>
 
 #include "kopeteballoon.h"
@@ -47,5 +48,6 @@ KopeteBalloon::KopeteBalloon(const QStri
         // BEGIN Layout1
         QHBoxLayout *Layout1 = new QHBoxLayout(BalloonLayout, \
                KDialog::spacingHint(), "Layout1");
-        QLabel *mCaption = new QLabel(text, this, "mCaption");
+        KActiveLabel *mCaption = new KActiveLabel(text, this, "mCaption");
+        mCaption->setPalette( QToolTip::palette() );
 
         if (!pix.isEmpty())
@@ -80,4 +82,8 @@ KopeteBalloon::KopeteBalloon(const QStri
         connect(mIgnoreButton, SIGNAL(clicked()), \
SIGNAL(signalIgnoreButtonClicked()));  connect(mIgnoreButton, SIGNAL(clicked()), \
SLOT(deleteLater())); +
+        connect( mCaption, SIGNAL( linkClicked( const QString & ) ),
+                        SIGNAL( signalIgnoreButtonClicked() ) );
+        connect( mCaption, SIGNAL( linkClicked( const QString & ) ), SLOT( \
deleteLater() ) );  }
 

--- kdenonbeta/kopete/kopete/systemtray.cpp  #1.20:1.21
@@ -23,4 +23,5 @@
 #include <qtimer.h>
 #include <qtooltip.h>
+#include <qregexp.h>
 
 #include <kaboutdata.h>
@@ -229,10 +230,27 @@ void KopeteSystemTray::addBalloon()
                 KopeteMessage msg = mEventList.first()->message();
 
-                if( msg.from() )  
+                if ( msg.from() )
                 {
-                        QString msgText = msg.plainBody();
+                        QString msgText = msg.parsedBody();
                         kdDebug(14010) << k_funcinfo << "msgText=" << msgText << \
endl; +                        QRegExp rx( "(<a[^>]+[^<]+</a>)" );
+                        if ( rx.search( msgText ) == -1 )
+                        {
+                                // no URLs in text, just pick the first 30 chars of 
+                                // the plain text if necessary
+                                msgText = msg.plainBody();
                         if( msgText.length() > 30 )
-                                msgText = msgText.left(30) + \
QString::fromLatin1("..."); +                                        msgText = \
msgText.left( 30 ) + QString::fromLatin1( "..." ); +                        }
+                        else
+                        {
+                                if( msgText.length() > 30 )
+                                {
+                                        // pull the first URL out and use that in \
the balloon +                                        msgText = QString::fromLatin1( \
"..." ) + rx.cap( 1 ) +                                                + \
QString::fromLatin1( "..." ); +                                }
+                        }
+                        kdDebug(14010) << k_funcinfo << "msgText=" << msgText << \
endl;  
                         QString msgFrom;


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic