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

List:       kde-usability
Subject:    Re: gtk+ file selector mockups
From:       "Aaron J. Seigo" <aseigo () kde ! org>
Date:       2004-01-09 23:07:44
Message-ID: 200401091607.45043.aseigo () kde ! org
[Download RAW message or body]

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Thursday 08 January 2004 01:44, Mikolaj Machowski wrote:
> Your forgot about #include <kstringhandler.h> and:
> lb undeclared, first use in this function.

so i discovered when i was finally able to compile it =) i also discovered 
that the string compression needs to be done in the paint() method ...

updated patch attached ... 

outstanding issues / questions:

 o should the url bar grow wider when vertical to accommodate wider titles? 
(it doesn't in the attached patch, but i think it should)
	o if so, what should be the max? 

 o should the widest icon be used to line up the titles, in case there are 
icons of different widths? (e.g. do the same as i did to line up the icons in 
kcontrol's treeview) ... or is it safe to assume the icons will all be the 
same size?

 o with this patch, should the default become "Small Icons"? it looks nicer 
than with big icons now =)

- -- 
Aaron J. Seigo
GPG Fingerprint: 8B8B 2209 0C6F 7C47 B1EA  EE75 D6B7 2EB1 A7F1 DB43
while (!horse()); cart();
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2-rc1-SuSE (GNU/Linux)

iD8DBQE//zRA1rcusafx20MRAnF0AJ9L90nhiIXyCEg53Rh+2Mz6Q5Th9ACfX/qp
591rD7mBff7UHKkjjn6Kiyo=
=O0s1
-----END PGP SIGNATURE-----

["kurlbar.diff" (text/x-diff)]

Index: kurlbar.cpp
===================================================================
RCS file: /home/kde/kdelibs/kio/kfile/kurlbar.cpp,v
retrieving revision 1.50
diff -u -3 -d -p -r1.50 kurlbar.cpp
--- kurlbar.cpp	3 Dec 2003 14:10:33 -0000	1.50
+++ kurlbar.cpp	9 Jan 2004 23:28:58 -0000
@@ -39,6 +39,7 @@
 #include <klocale.h>
 #include <kmimetype.h>
 #include <kprotocolinfo.h>
+#include <kstringhandler.h>
 #include <kurldrag.h>
 #include <kurlrequester.h>
 
@@ -177,6 +178,7 @@ void KURLBarItem::paint( QPainter *p )
 {
     QListBox *box = listBox();
     int w = width( box );
+    static const int margin = KDialog::spacingHint();
 
     if ( m_parent->iconSize() < KIcon::SizeMedium ) {
         // small icon -> draw icon next to text
@@ -186,21 +188,24 @@ void KURLBarItem::paint( QPainter *p )
         const QPixmap *pm = pixmap();
         int yPos = QMAX( 0, (height(box) - pm->height())/2 );
 
-        p->drawPixmap( 3, yPos, *pm );
+        p->drawPixmap( margin, yPos, *pm );
         if ( !text().isEmpty() ) {
             QFontMetrics fm = p->fontMetrics();
             if ( pm->height() < fm.height() )
                 yPos = fm.ascent() + fm.leading()/2;
             else
                 yPos = pm->height()/2 - fm.height()/2 + fm.ascent();
-            p->drawText( pm->width() + 5, yPos, text() );
+
+            yPos += margin;
+            int stringWidth = box->width() - pm->width() - 2 - (margin * 2);
+            QString visibleText = KStringHandler::rPixelSqueeze( text(), fm, stringWidth );
+            p->drawText( pm->width() + margin + 2, yPos, visibleText );
         }
         // end cut & paste (modulo pixmap centering)
     }
 
     else {
         // big icons -> draw text below icon
-        static const int margin = 3;
         int y = margin;
         const QPixmap *pm = pixmap();
 
@@ -213,9 +218,13 @@ void KURLBarItem::paint( QPainter *p )
         if ( !text().isEmpty() ) {
             QFontMetrics fm = p->fontMetrics();
             y += pm->height() + fm.height() - fm.descent();
-            int x = (w - fm.width( text() )) / 2;
+
+            int stringWidth = box->width() - (margin * 2);
+            QString visibleText = KStringHandler::rPixelSqueeze( text(), fm, stringWidth );
+            int x = (w - fm.width( visibleText )) / 2;
             x = QMAX( x, margin );
-            p->drawText( x, y, text() );
+
+            p->drawText( x, y, visibleText );
         }
     }
 
@@ -233,18 +242,18 @@ QSize KURLBarItem::sizeHint() const
     const KURLBarListBox *lb =static_cast<const KURLBarListBox*>(listBox());
 
     if ( m_parent->iconSize() < KIcon::SizeMedium ) {
-        wmin = QListBoxPixmap::width( lb );
-        hmin = QListBoxPixmap::height( lb );
+        wmin = QListBoxPixmap::width( lb ) + KDialog::spacingHint() * 2;
+        hmin = QListBoxPixmap::height( lb ) + KDialog::spacingHint() * 2;
     }
     else {
-        wmin = QMAX(lb->fontMetrics().width(text()), pixmap()->width()) + 6;
-        hmin = lb->fontMetrics().lineSpacing() + pixmap()->height() + 6;
+        wmin = QMAX(lb->fontMetrics().width(text()), pixmap()->width()) + KDialog::spacingHint() * 2;
+        hmin = lb->fontMetrics().lineSpacing() + pixmap()->height() + KDialog::spacingHint() * 2;
     }
 
     if ( lb->isVertical() )
-        wmin = QMAX( wmin, lb->viewport()->sizeHint().width() );
+        wmin = QMIN( wmin, lb->viewport()->sizeHint().width() );
     else
-        hmin = QMAX( hmin, lb->viewport()->sizeHint().height() );
+        hmin = QMIN( hmin, lb->viewport()->sizeHint().height() );
 
     return QSize( wmin, hmin );
 }
@@ -252,7 +261,7 @@ QSize KURLBarItem::sizeHint() const
 int KURLBarItem::width( const QListBox *lb ) const
 {
     if ( static_cast<const KURLBarListBox *>( lb )->isVertical() )
-        return QMAX( sizeHint().width(), lb->viewport()->width() );
+        return QMIN( sizeHint().width(), lb->viewport()->width() );
     else
         return sizeHint().width();
 }
@@ -262,7 +271,7 @@ int KURLBarItem::height( const QListBox 
     if ( static_cast<const KURLBarListBox *>( lb )->isVertical() )
         return sizeHint().height();
     else
-        return QMAX( sizeHint().height(), lb->viewport()->height() );
+        return QMIN( sizeHint().height(), lb->viewport()->height() );
 }
 
 bool KURLBarItem::isPersistent() const


_______________________________________________
kde-usability mailing list
kde-usability@kde.org
https://mail.kde.org/mailman/listinfo/kde-usability


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

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