[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-04 11:50:48
Message-ID: 200504041450.51687.baris () uludag ! org ! tr
[Download RAW message or body]

[Attachment #2 (multipart/signed)]

[Attachment #4 (multipart/mixed)]


Cumartesi 02 Nisan 2005 12:27 tarihinde, Aaron J. Seigo şunları yazmıştı: 
> > I'll try to implement your ideas. I don't have a KDE 3.4 desktop for
> > weekend but will try my best monday night.
>
> great... i'll be ready to triage into CVS when the patches are ready...

I've modified the patch for reverse layout, shadowed text and tiled buttons. 
The result can be seen from http://cekirdek.uludag.org.tr/~baris/tmp/kicker/

I've implemented a (somewhat lame) method for shadow color. If there is a 
generic way to get shadowed text, I can use that one. I know Kdesktop's 
KShadowEngine implementation, but thought it's specific to kdesktop.

The patch is attached.

best regards.
-- 
Barış Metin

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

? libkonq/konq_popupmenu.loT
Index: kicker/buttons/kbutton.cpp
===================================================================
RCS file: /home/kde/kdebase/kicker/buttons/kbutton.cpp,v
retrieving revision 1.23
diff -u -3 -p -r1.23 kbutton.cpp
--- kicker/buttons/kbutton.cpp	29 Mar 2005 18:33:52 -0000	1.23
+++ kicker/buttons/kbutton.cpp	4 Apr 2005 09:26:02 -0000
@@ -22,6 +22,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE 
 ******************************************************************/
 
 #include <qtooltip.h>
+#include <qpainter.h>
 
 #include <klocale.h>
 #include <kapplication.h>
@@ -44,6 +45,24 @@ KButton::KButton( QWidget* parent )
     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 );
+
+    _textColor = KGlobalSettings::textColor();
+    // 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);
+
+    _shadowColor = shadowColor( _textColor );
+
 }
 
 KButton::~KButton()
@@ -67,3 +86,80 @@ void KButton::initPopup()
     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);
+
+           p->drawPixmap(3, y, icon);
+
+           int tX = icon.width()+5;
+           int tY = int( float( height() )*_fontHeight );
+           QString buttonText = i18n( "KMenu" );
+           if ( QApplication::reverseLayout() ) {
+               p->setPen( _shadowColor );
+               p->drawText( tX+2, tY+2, buttonText, -1, QPainter::RTL );
+
+               p->setPen( _textColor );
+               p->drawText( tX, tY, buttonText, -1, QPainter::RTL );
+           } else {
+               p->setPen( _shadowColor );
+               p->drawText( tX+2, tY+2, buttonText );
+
+               p->setPen( _textColor );
+               p->drawText( tX, tY, buttonText );
+           }
+           p->restore();
+       } else {
+           int x = (width()  - icon.width() )/2;
+           p->drawPixmap(x, y, icon);
+       }
+    }
+
+    if (isDown() || isOn())
+       p->translate(-2,-2);
+}
+
+QColor KButton::shadowColor(QColor& c)
+{
+    int r = c.red();
+    int g = c.green();
+    int b = c.blue();
+
+    if ( r < 128 )
+        r = 255;
+    else
+        r = 0;
+
+    if ( g < 128 )
+        g = 255;
+    else
+        g = 0;
+
+    if ( b < 128 )
+        b = 255;
+    else
+        b = 0;
+
+    return QColor( r, g, b );
+
+}
+
+
Index: kicker/buttons/kbutton.h
===================================================================
RCS file: /home/kde/kdebase/kicker/buttons/kbutton.h,v
retrieving revision 1.6
diff -u -3 -p -r1.6 kbutton.h
--- kicker/buttons/kbutton.h	17 Nov 2004 22:10:57 -0000	1.6
+++ kicker/buttons/kbutton.h	4 Apr 2005 09:26:02 -0000
@@ -45,6 +45,15 @@ protected:
     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,
+	_shadowColor;
+    QColor shadowColor(QColor&);
 };
 
 #endif
Index: kicker/core/container_button.cpp
===================================================================
RCS file: /home/kde/kdebase/kicker/core/container_button.cpp,v
retrieving revision 1.71
diff -u -3 -p -r1.71 container_button.cpp
--- kicker/core/container_button.cpp	2 Apr 2005 10:44:43 -0000	1.71
+++ kicker/core/container_button.cpp	4 Apr 2005 09:26:03 -0000
@@ -320,14 +320,30 @@ KMenuButtonContainer::KMenuButtonContain
 {
     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
Index: kicker/core/container_button.h
===================================================================
RCS file: /home/kde/kdebase/kicker/core/container_button.h,v
retrieving revision 1.42
diff -u -3 -p -r1.42 container_button.h
--- kicker/core/container_button.h	31 Jan 2005 00:04:09 -0000	1.42
+++ kicker/core/container_button.h	4 Apr 2005 09:26:03 -0000
@@ -90,6 +90,10 @@ public:
     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