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

List:       kde-devel
Subject:    Re: Old kicker bug that can be closed
From:       Barış_Metin <baris () uludag ! org ! tr>
Date:       2005-04-01 13:49:14
Message-ID: 200504011649.16924.baris () uludag ! org ! tr
[Download RAW message or body]

[Attachment #2 (multipart/signed)]

[Attachment #4 (multipart/mixed)]


Cuma 11 Mart 2005 15:06 tarihinde, Barış Metin şunları yazmıştı: 
> Cuma 11 Mart 2005 14:43 tarihinde, Barış Metin şunları yazmıştı:
> > > something i've considered doing is popping up the mouse over effect for
> > > the K Menu on the first time kicker is started, triggered by the same
> > > thing that causes the default buttons to be added to the panel the
> > > first time.
> >
> > It can be very good to attract the user's attention at first. But IMHO,
> > KMenu is the second most used part of kicker (after taskbar). Especially
> > non-expert users use it very often.
>
> Sorry, I forgot to add. As KMenu is used so often we must make it more
> accessible. At least more than other buttons on kicker.

I've prepared a 3.4.0 patch which adds text to the K menu button, based on 
Linspire's patches. As Aaron once mentioned about adding (only?) text to the 
K menu button, I've removed the tiles part from patch.

Linspire's solution is cute, but broken with some fonts and some panel sizes. 
So I've added some (hacky) bits too. Anyhow it doesn't work seamlessly even 
now, but better.

What it looks like is here[1]. Screenshots are for our distro but its pretty 
same with untouched kdebase too :).

1. http://cekirdek.uludag.org.tr/~baris/tmp/kicker/
-- 
Barış Metin

["kdebase-3.4.0-kbutton-text.patch" (text/x-diff)]

diff -ur kdebase-3.4.0.orig/kicker/buttons/kbutton.cpp \
                kdebase-3.4.0/kicker/buttons/kbutton.cpp
--- kdebase-3.4.0.orig/kicker/buttons/kbutton.cpp	2005-04-01 16:15:33.000000000 +0300
+++ kdebase-3.4.0/kicker/buttons/kbutton.cpp	2005-04-01 16:20:34.008786000 +0300
@@ -22,6 +22,7 @@
 ******************************************************************/
 
 #include <qtooltip.h>
+#include <qpainter.h>
 
 #include <klocale.h>
 #include <kapplication.h>
@@ -44,6 +45,21 @@
     setPopup(MenuManager::the()->kmenu());
     MenuManager::the()->registerKButton(this);
     setIcon("kmenu");
+
+    KConfigGroup cfgGroup( KGlobal::config(), "KMenu" );
+
+    //QFont f("Nimbus Sans L");
+    QFont f(KApplication::kApplication()->font());
+    f = cfgGroup.readFontEntry( "Font", &f );
+    _fontPercent = cfgGroup.readDoubleNumEntry( "FontSize", 0.40 );
+    setFont(f);
+
+    _fontHeight = cfgGroup.readDoubleNumEntry( "FontHeight", 0.60 );
+
+    // we *want* the color to be invalid if not specifically set
+    // this makes it easy to let the text color use the system default
+    _textColor = cfgGroup.readColorEntry("TextColor",&_textColor);
+
 }
 
 KButton::~KButton()
@@ -67,3 +83,40 @@
     MenuManager::the()->kmenu()->initialize();
 }
 
+void KButton::resizeEvent(QResizeEvent*e)
+{
+    PanelPopupButton::resizeEvent(e);
+}
+
+void KButton::drawButtonLabel(QPainter *p)
+{
+    if (isDown() || isOn())
+       p->translate(2,2);
+
+    const QPixmap& icon = labelIcon();
+    if ( !icon.isNull() ) {
+       int y = (height() - icon.height())/2;
+
+       // the config defaults and the i18n'd text *must* be the same both here and \
in container_button.cpp +       if ( orientation() == Horizontal ) {
+           p->save();
+           QFont f = font();
+           f.setPixelSize( int( float(height()) * _fontPercent ) );
+           f.setBold(true);
+           p->setFont(f);
+           if( _textColor.isValid() )
+             p->setPen(_textColor);
+           p->drawPixmap(3, y, icon);
+           p->drawText( icon.width()+5, int( float(height())*_fontHeight ), \
i18n("KMenu")); +           p->restore();
+       } else {
+           int x = (width()  - icon.width() )/2;
+           p->drawPixmap(x, y, icon);
+       }
+    }
+
+    if (isDown() || isOn())
+       p->translate(-2,-2);
+}
+
+
diff -ur kdebase-3.4.0.orig/kicker/buttons/kbutton.h \
                kdebase-3.4.0/kicker/buttons/kbutton.h
--- kdebase-3.4.0.orig/kicker/buttons/kbutton.h	2005-04-01 16:15:33.000000000 +0300
+++ kdebase-3.4.0/kicker/buttons/kbutton.h	2005-04-01 16:19:34.388849608 +0300
@@ -45,6 +45,13 @@
     virtual QString tileName() { return "KMenu"; }
     virtual void initPopup();
     virtual QString defaultIcon() const { return "go"; }
+
+    virtual void drawButtonLabel(QPainter *);
+    virtual void resizeEvent(QResizeEvent*);
+
+private:
+    float _fontPercent, _fontHeight;
+    QColor _textColor;
 };
 
 #endif
diff -ur kdebase-3.4.0.orig/kicker/core/container_button.cpp \
                kdebase-3.4.0/kicker/core/container_button.cpp
--- kdebase-3.4.0.orig/kicker/core/container_button.cpp	2005-04-01 16:15:33.000000000 \
                +0300
+++ kdebase-3.4.0/kicker/core/container_button.cpp	2005-04-01 16:26:06.815191736 \
+0300 @@ -316,14 +316,30 @@
 {
     embedButton( new KButton(this) );
     _actions = PanelAppletOpMenu::KMenuEditor;
+
+    KConfigGroup cfgGroup( KGlobal::config(), "KMenu" );
+    //QFont f("Nimbus Sans L");
+    QFont f(KApplication::kApplication()->font());
+    f = cfgGroup.readFontEntry( "Font", &f );
+    fontPercent = cfgGroup.readDoubleNumEntry( "FontSize", 0.30 );
+    extraSpace = cfgGroup.readDoubleNumEntry( "ExtraSpace", 0.50 );
 }
 
 int KMenuButtonContainer::widthForHeight( int height ) const
 {
-    if ( height < 32 )
-        return height + 10;
-    else
-        return ButtonContainer::widthForHeight(height);
+    int padding = int( float(height) * extraSpace );
+
+    // the config defaults and the i18n'd text *must* be the same both here and in \
kbutton.cpp +    QFont f(font());
+    f.setPixelSize( int( float(height) * fontPercent ) );
+    f.setBold(true);
+    QFontMetrics fm( f );
+    if (height > 50) // large panel
+        padding += height/2;
+
+    // the added X is to provide some pad on the right
+    int w = height + fm.width(i18n("KMenu"), -1) + padding;
+    return w;
 }
 
 int KMenuButtonContainer::heightForWidth( int width ) const
diff -ur kdebase-3.4.0.orig/kicker/core/container_button.h \
                kdebase-3.4.0/kicker/core/container_button.h
--- kdebase-3.4.0.orig/kicker/core/container_button.h	2005-04-01 16:15:33.000000000 \
                +0300
+++ kdebase-3.4.0/kicker/core/container_button.h	2005-04-01 16:16:13.000000000 +0300
@@ -90,6 +90,10 @@
     virtual int widthForHeight( int height ) const;
     virtual int heightForWidth( int width )  const;
     bool isAMenu() const { return true; }
+    
+private:
+    float fontPercent;
+    float extraSpace;
 };
 
 class DesktopButtonContainer : public ButtonContainer


[Attachment #8 (application/pgp-signature)]

>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<


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

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