Fwd: [PATCH] khtmlview.cpp

Pascal Létourneau pletourn at globetrotter.net
Tue Oct 22 17:31:31 BST 2002


On October 22, 2002 11:58, Dirk Mueller wrote:
> On Die, 22 Okt 2002, Pascal Létourneau wrote:
> > I agree, but from a user perspective, it's a bug in konqueror.
> > Anyway, this hack can be easily removed when the qt bug is fixed.
>
> Ah, rereading your patch it seems it makes something different than I
> thought.
>
> can you try if QStyleSheet::fromPlainText() (or something similiar to that,
> I'm too far away from Qt docu right now :) works, that would even be the
> right fix.
The new patch is:
Index: khtmlview.cpp
===================================================================
RCS file: /home/kde/kdelibs/khtml/khtmlview.cpp,v
retrieving revision 1.491
diff -u -3 -p -r1.491 khtmlview.cpp
--- khtmlview.cpp       2002/10/20 23:09:14     1.491
+++ khtmlview.cpp       2002/10/22 16:19:46
@@ -51,6 +51,7 @@
 #include <qpainter.h>
 #include <qpaintdevicemetrics.h>
 #include <qobjectlist.h>
+#include <qstylesheet.h>
 #include <kapplication.h>

 #include <kimageio.h>
@@ -239,8 +240,13 @@ void KHTMLToolTip::maybeTip(const QPoint
         if ( node->isElementNode() ) {
             QString s = static_cast<DOM::ElementImpl*>( node )->getAttribute( 
ATTR_TITLE ).string();
             region |= QRect( m_view->contentsToViewport( 
node->getRect().topLeft() ), node->getRect().size() );
-            if ( !s.isEmpty() ) {
-                tip( region,  s );
+           if ( !s.isEmpty() ) {
+               if ( s.length() > 50 )
+                   s = QStyleSheet::convertFromPlainText( s, 
QStyleSheetItem::WhiteSpaceNormal );
+               else
+                   s = QStyleSheet::convertFromPlainText( s, 
QStyleSheetItem::WhiteSpacePre );
+               tip( region, s );
                 break;
             }
         }

The magic number still need to be there, because without it, the tooltip "two 
words" will be shown on two lines (which is ugly).

> I thought its about those tooltips that have no '\n' at all, just one long
> text. those never wrap currently, producing a tooltip that goes beyond the
> right screen edge and enters the screen from the left side again :)
They have '\n' for paragraphs.

Pascal Létourneau




More information about the kfm-devel mailing list