Author: lmontel
Date: Fri Feb  9 11:39:05 2007
New Revision: 118358

Added:
   
packages/cooker/kdebase/current/SOURCES/kdebase-3.5.6-kicker-button-custom.patch
Modified:
   packages/cooker/kdebase/current/SPECS/kdebase.spec

Log:
Add custom button icon


Added: 
packages/cooker/kdebase/current/SOURCES/kdebase-3.5.6-kicker-button-custom.patch
==============================================================================
--- (empty file)
+++ 
packages/cooker/kdebase/current/SOURCES/kdebase-3.5.6-kicker-button-custom.patch
    Fri Feb  9 11:39:05 2007
@@ -0,0 +1,218 @@
+--- kdebase-3.5.6/kicker/libkicker/panelbutton.h.kicker_custom_button  
2006-01-19 18:01:40.000000000 +0100
++++ kdebase-3.5.6/kicker/libkicker/panelbutton.h       2007-02-09 
11:28:24.000000000 +0100
+@@ -133,6 +133,13 @@
+     void setIcon(const QString& icon);
+ 
+     /**
++     * Used to set the icon for this panel button without reescale.
++     * @param icon the path to the button's icon
++     * @param scale tell to scale or not button ( default is scale )
++     */
++    void setIcon(const QString& icon, bool scale);
++
++    /**
+      * @return the button's icon
+      */
+     QString icon() const;
+@@ -378,6 +385,7 @@
+     bool m_highlight;
+     bool m_changeCursorOverItem;
+     bool m_hasAcceptedDrag;
++    bool m_scaleButton;
+     QColor m_textColor;
+     QColor m_tileColor;
+     QString m_buttonText;
+--- kdebase-3.5.6/kicker/libkicker/global.cpp.kicker_custom_button     
2006-03-17 11:17:31.000000000 +0100
++++ kdebase-3.5.6/kicker/libkicker/global.cpp  2007-02-09 11:28:24.000000000 
+0100
+@@ -156,7 +156,7 @@
+ 
+ int maxButtonDim()
+ {
+-    return (2 * KickerSettings::iconMargin()) + KIcon::SizeLarge;
++    return (2 * KickerSettings::iconMargin()) + KIcon::SizeHuge;
+ }
+ 
+ QString newDesktopFile(const KURL& url)
+--- kdebase-3.5.6/kicker/libkicker/panelbutton.cpp.kicker_custom_button        
2006-07-22 10:15:18.000000000 +0200
++++ kdebase-3.5.6/kicker/libkicker/panelbutton.cpp     2007-02-09 
11:28:24.000000000 +0100
+@@ -41,6 +41,7 @@
+ #include <kicontheme.h>
+ #include <kipc.h>
+ #include <kstandarddirs.h>
++#include <kiconeffect.h>
+ #include <klocale.h>
+ 
+ #include "global.h"
+@@ -63,6 +64,7 @@
+       m_highlight(false),
+       m_changeCursorOverItem(true),
+       m_hasAcceptedDrag(false),
++      m_scaleButton(true),
+       m_arrowDirection(KPanelExtension::Bottom),
+       m_popupDirection(KPanelApplet::Up),
+       m_orientation(Horizontal),
+@@ -264,20 +266,20 @@
+ // return the dimension that the button wants to be for a given panel 
dimension (panelDim)
+ int PanelButton::preferredDimension(int panelDim) const
+ {
+-    // determine the upper limit on the size.  Normally, this is panelDim,
+-    // but if conserveSpace() is true, we restrict size to comfortably fit 
the icon
+-    if (KickerSettings::conserveSpace())
+-    {
+-        int newSize = preferredIconSize(panelDim);
+-        if (newSize > 0)
+-        {
+-            return QMIN(panelDim, newSize + (KDialog::spacingHint() * 2));
+-        }
+-    }
+-
+-    return panelDim;
++   int newSize = panelDim;
++   
++   if ( KickerSettings::conserveSpace() )
++   {
++      int preferred = preferredIconSize( panelDim );
++      if ( preferred > 0 )
++      {
++         newSize = QMIN( panelDim, preferred + ( KDialog::spacingHint() * 2 ) 
);
++      }
++   }
++   return QMAX( newSize,orientation() == Horizontal ? m_icon.width() : 
m_icon.height() ) ;
+ }
+ 
++
+ int PanelButton::widthForHeight(int height) const
+ {
+     int rc = preferredDimension(height);
+@@ -321,6 +323,12 @@
+     m_title = t;
+ }
+ 
++void PanelButton::setIcon(const QString& icon, bool scale )
++{
++   m_scaleButton = scale;
++   setIcon( icon );
++}
++
+ void PanelButton::setIcon(const QString& icon)
+ {
+     if (icon == m_iconName)
+@@ -687,6 +695,7 @@
+     // Get sizes from icontheme. We assume they are sorted.
+     KIconTheme *ith = KGlobal::iconLoader()->theme();
+ 
++
+     if (!ith)
+     {
+         return -1; // unknown icon size
+@@ -700,6 +709,7 @@
+     {
+         proposed_size = (orientation() == Horizontal) ? height() : width();
+     }
++    
+ 
+     // determine the upper limit on the size.  Normally, this is panelSize,
+     // but if conserve space is requested, the max button size is used 
instead.
+@@ -721,8 +731,7 @@
+         sz = *i;   // get the largest size under the limit
+         ++i;
+     }
+-
+-    //kdDebug()<<"Using icon sizes: "<<sz<<"  "<<zoom_sz<<endl<<flush;
++    
+     return sz;
+ }
+ 
+@@ -783,10 +792,29 @@
+ void PanelButton::loadIcons()
+ {
+     KIconLoader * ldr = KGlobal::iconLoader();
++    KIconEffect * kfx = new KIconEffect();
+     QString nm = m_iconName;
++
+     KIcon::States defaultState = isEnabled() ? KIcon::DefaultState :
+                                                KIcon::DisabledState;
+-    m_icon = ldr->loadIcon(nm, KIcon::Panel, m_size, defaultState, 0L, true);
++
++    QSize ref = ldr->loadIcon( defaultIcon(), KIcon::Panel, m_size, 
defaultState).size();
++
++    QImage img = QImage( ldr->iconPath(  nm, KIcon::Panel ) );
++
++    if ( m_scaleButton )
++    {
++       if ( img.height() == img.width() )
++          m_icon = img.smoothScale( ref );
++       else
++          orientation() == Horizontal ? 
++             m_icon = img.smoothScale( ( img.width() * ref.height() ) / 
img.height(), ref.height() ) :
++             m_icon = img.smoothScale( ref.width(), ( img.height() * 
ref.width() ) / img.width() );
++    }
++    else
++    {
++       m_icon = img;
++    }
+ 
+     if (m_icon.isNull())
+     {
+@@ -800,12 +828,16 @@
+     }
+     else
+     {
+-        m_iconh = ldr->loadIcon(nm, KIcon::Panel, m_size,
+-                                KIcon::ActiveState, 0L, true);
+-    }
+-
+-    m_iconz = ldr->loadIcon(nm, KIcon::Panel, KIcon::SizeHuge,
+-                            defaultState, 0L, true );
++       m_iconh = kfx->apply( 
++             m_icon,
++             KIcon::Panel,
++             KIcon::ActiveState );
++    }
++    
++    m_iconz = kfx->apply( 
++          QPixmap( ldr->iconPath( nm, KIcon::SizeHuge ) ),
++          KIcon::Panel,
++          defaultState );
+ }
+ 
+ // (re)calculates the icon sizes and report true if they have changed.
+--- kdebase-3.5.6/kicker/kicker/buttons/kbutton.cpp.kicker_custom_button       
2007-02-09 11:28:24.000000000 +0100
++++ kdebase-3.5.6/kicker/kicker/buttons/kbutton.cpp    2007-02-09 
11:34:51.000000000 +0100
+@@ -26,6 +26,14 @@
+ #include <klocale.h>
+ #include <kapplication.h>
+ #include <kdebug.h>
++#include <kiconloader.h>
++#include <qimage.h>
++#include <qpixmap.h>
++#include <krootpixmap.h>
++#include <qcolor.h>
++#include <qpainter.h>
++#include <qdragobject.h>
++#include <kglobalsettings.h>
+ 
+ #include "kickerSettings.h"
+ 
+@@ -47,7 +55,9 @@
+     MenuManager::the()->registerKButton(this);
+     KConfig* config = KGlobal::config();
+     config->setGroup("KMenu");
+-    setIcon( config->readBoolEntry("KmenuUseMdvIcon", true) ? "menuk-mdk" : 
"kmenu" );
++    QString icon = config->readEntry( "KMenuIcon", "kmenu" );
++    QString iconName = config->readBoolEntry("KmenuUseMdvIcon", true) ? 
"menuk-mdk" : icon ;
++    config->readBoolEntry( "KMenuButtonScale", true ) ? setIcon( iconName ) : 
setIcon( iconName, false );
+ 
+     if (KickerSettings::showKMenuText())
+     {
+--- kdebase-3.5.6/kicker/applets/menu/menuapplet.cpp.kicker_custom_button      
2005-09-10 10:25:31.000000000 +0200
++++ kdebase-3.5.6/kicker/applets/menu/menuapplet.cpp   2007-02-09 
11:28:24.000000000 +0100
+@@ -354,7 +354,7 @@
+     {
+     if (active_menu)
+         return active_menu->width();
+-    return 0; // we're stretch applet
++    return 50; // we're stretch applet
+     }
+ 
+ int Applet::heightForWidth( int ) const

Modified: packages/cooker/kdebase/current/SPECS/kdebase.spec
==============================================================================
--- packages/cooker/kdebase/current/SPECS/kdebase.spec  (original)
+++ packages/cooker/kdebase/current/SPECS/kdebase.spec  Fri Feb  9 11:39:05 2007
@@ -41,7 +41,7 @@
 Name: kdebase
 Summary:       K Desktop Environment - Core files
 Version: 3.5.6
-Release: %mkrel 6
+Release: %mkrel 7
 Epoch: 1
 Group: Graphical desktop/KDE
 License:       GPL
@@ -251,6 +251,8 @@
 
 Patch161:      kdebase-3.5.6-fix-background-default.patch
 
+Patch166:      kdebase-3.5.6-kicker-button-custom.patch
+
 BuildConflicts: lm_utils
 BuildConflicts: lm_utils-devel
 BuildConflicts: liblm_sensors1
@@ -1649,6 +1651,8 @@
 %patch160 -p1 -b .fix_startkde_mdk
 %patch161 -p1 -b .fix_background_default_value
 
+%patch166 -p1 -b .kicker_custom_button
+
 %build
 # This is here just because patch 93. Too
 # bad that we can get rid of this lib problem without

Reply via email to