Author: lmontel
Date: Fri Feb 16 10:35:50 2007
New Revision: 121621

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

Log:
add second part of custom kicker button (patch from corporate)


Added: 
packages/cooker/kdebase/current/SOURCES/kdebase-3.5.6-kicker-button-custom2.patch
==============================================================================
--- (empty file)
+++ 
packages/cooker/kdebase/current/SOURCES/kdebase-3.5.6-kicker-button-custom2.patch
   Fri Feb 16 10:35:50 2007
@@ -0,0 +1,535 @@
+--- kdebase-3.5.6/kicker/libkicker/kickerSettings.kcfg--       2007-02-16 
10:26:24.000000000 +0100
++++ kdebase-3.5.6/kicker/libkicker/kickerSettings.kcfg 2007-02-16 
10:26:30.000000000 +0100
+@@ -272,8 +272,28 @@
+ 
+ <entry name="KMenuText" key="Text" type="String" >
+       <label>Text to be shown on K Menu Button</label>
+-      <default code="true">i18n("Applications")</default>
+-   </entry>
++      <default>Applications</default>
++</entry>
++
++<entry name="KMenuTextRelativeXPos" key="TextRelativeXPos" type="UInt" >
++      <label>Relative horizontal position of text</label>
++      <default>0</default>
++</entry>
++
++<entry name="KMenuTextRelativeYPos" key="TextRelativeYPos" type="UInt" >
++      <label>Relative Vertical position of text</label>
++      <default>0</default>
++</entry>
++
++<entry name="KMenuTextFont" key="TextFont" type="Font" >
++      <label>Font for the buttons with text.</label>
++      <default code="true">KGlobalSettings::generalFont()</default>
++</entry>
++
++<entry name="KMenuTextColor" key="TextColor" type="Color" >
++      <label>Text color for the buttons.</label>
++      <default code="true">KGlobalSettings::textColor()</default>
++</entry>
+ 
+ </group>
+ 
+@@ -325,10 +345,10 @@
+       <default>true</default>
+    </entry>
+ 
+-<entry name="ButtonFont" key="Font" type="Font" >
++<entry name="ButtonTextFont" key="TextFont" type="Font" >
+       <label>Font for the buttons with text.</label>
+       <default code="true">KGlobalSettings::generalFont()</default>
+-   </entry>
++</entry>
+ 
+ <entry name="ButtonTextColor" key="TextColor" type="Color" >
+       <label>Text color for the buttons.</label>
+--- kdebase-3.5.6/kicker/libkicker/panelbutton.cpp--   2007-02-16 
10:26:41.000000000 +0100
++++ kdebase-3.5.6/kicker/libkicker/panelbutton.cpp     2007-02-16 
10:26:48.000000000 +0100
+@@ -64,19 +64,19 @@
+       m_highlight(false),
+       m_changeCursorOverItem(true),
+       m_hasAcceptedDrag(false),
+-      m_scaleButton(true),
++      m_scaleButton(false),
++      m_rotateButton(false),
+       m_arrowDirection(KPanelExtension::Bottom),
+       m_popupDirection(KPanelApplet::Up),
+       m_orientation(Horizontal),
+-      m_size((KIcon::StdSizes)-1),
+-      m_fontPercent(0.40)
++      m_size((KIcon::StdSizes)-1)
+ {
+     KGlobal::locale()->insertCatalogue("libkicker");
+     calculateIconSize();
+     setAcceptDrops(true);
+ 
+     m_textColor = KGlobalSettings::textColor();
+-
++    m_textFont = KickerSettings::kMenuTextFont();
+     updateSettings(KApplication::SETTINGS_MOUSE);
+ 
+     kapp->addKipcEventMask(KIPC::SettingsChanged | KIPC::IconChanged);
+@@ -276,26 +276,32 @@
+          newSize = QMIN( panelDim, preferred + ( KDialog::spacingHint() * 2 ) 
);
+       }
+    }
+-   return QMAX( newSize,orientation() == Horizontal ? m_icon.width() : 
m_icon.height() ) ;
++
++   if ( m_rotateButton )
++   {
++       return QMAX( newSize, QMAX( m_icon.width(), m_icon.height() ) );
++   }
++   else
++   {
++       return QMAX( newSize, orientation() == Horizontal ? m_icon.width() : 
m_icon.height() ) ;
++   }
+ }
+ 
+ 
+ int PanelButton::widthForHeight(int height) const
+ {
+-    int rc = preferredDimension(height);
+-
+-    // we only paint the text when horizontal, so make sure we're horizontal
+-    // before adding the text in here
+-    if (orientation() == Horizontal && !m_buttonText.isEmpty())
+-    {
+-        QFont f(font());
+-        f.setPixelSize(KMIN(height, KMAX(int(float(height) * m_fontPercent), 
16)));
+-        QFontMetrics fm(f);
++return preferredDimension(height);
++}
+ 
+-        rc += fm.width(m_buttonText) + KMIN(25, KMAX(5, fm.width('m') / 2));
+-    }
++void PanelButton::setButtonRotation( bool r )
++{
++   m_rotateButton = r;
++}
+ 
+-    return rc;
++void PanelButton::setIcon(const QString& icon, bool scale )
++{
++    m_scaleButton = scale;
++    setIcon( icon );
+ }
+ 
+ int PanelButton::heightForWidth(int width) const
+@@ -323,12 +329,6 @@
+     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)
+@@ -354,7 +354,7 @@
+ 
+ void PanelButton::setButtonText(const QString& text)
+ {
+-    m_buttonText = text;
++    m_buttonText = i18n( text.latin1() );
+     update();
+ }
+ 
+@@ -373,14 +373,14 @@
+     return m_textColor;
+ }
+ 
+-void PanelButton::setFontPercent(double p)
++void PanelButton::setTextFont(const QFont& f)
+ {
+-    m_fontPercent = p;
++m_textFont = f;
+ }
+ 
+-double PanelButton::fontPercent() const
++QFont PanelButton::textFont() const
+ {
+-    return m_fontPercent;
++    return m_textFont;
+ }
+ 
+ KPanelExtension::Orientation PanelButton::orientation() const
+@@ -503,10 +503,8 @@
+ {
+     loadTiles();
+ 
+-    if (calculateIconSize())
+-    {
+-        loadIcons();
+-    }
++    calculateIconSize();
++    loadIcons();
+ }
+ 
+ void PanelButton::drawButton(QPainter *p)
+@@ -551,57 +549,135 @@
+ {
+     QPixmap icon = labelIcon();
+     bool active = isDown() || isOn();
+-
++    if ( QApplication::reverseLayout() && orientation() == Horizontal )
++    {
++        icon = icon.convertToImage().mirror( true, false );
++    }
+     if (active)
+     {
+         icon = icon.convertToImage().smoothScale(icon.width() - 2,
+                                                  icon.height() - 2);
+     }
+-
+-    if (!m_buttonText.isEmpty() && orientation() == Horizontal)
++    int w = width();
++    int h = height();
++    int y = 0;
++    int x = (w - icon.width()) / 2;
++    
++    if ( ! m_scaleButton )
+     {
+-        int h = height();
+-        int w = width();
+-        int y = (h - icon.height())/2;
+-        p->save();
+-        QFont f = font();
+-
+-        double fontPercent = m_fontPercent;
+-        if (active)
++        y = ( h - icon.height() ) / 2;
++    }
++    int relx = KickerSettings::kMenuTextRelativeXPos();
++    int rely = KickerSettings::kMenuTextRelativeYPos();
++    if ( !m_buttonText.isEmpty() )
++    {
++        // We always rotate button when apply text
++        m_rotateButton = true;
++        if ( orientation() == Vertical)
+         {
+-            fontPercent *= .8;
++            x = 0;
++            y = m_scaleButton ? 
++                0 - icon.height() :
++                0 - w + ( ( w - icon.height() ) / 2 ) + 2; 
++            p->rotate( 90 );
+         }
+-        f.setPixelSize(KMIN(h, KMAX(int(float(h) * m_fontPercent), 16)));
++        p->save();
++        QFont f = m_textFont;
+         QFontMetrics fm(f);
++      if ( orientation() == Horizontal )      
++        {
++            while ( fm.width( m_buttonText, m_buttonText.length() ) > ( w - 
relx - 8 ) )
++            {
++                if ( ( f.pointSize() -1 ) <= 0  )
++                {
++                    break;
++                }
++                f.setPointSize( f.pointSize() - 1 );
++                fm = QFontMetrics( f );
++            }
++        }
++        else
++        {
++            while ( fm.width( m_buttonText, m_buttonText.length() ) > ( h - 
relx - 8 ) )
++            {
++                if ( ( f.pointSize() -1 ) <= 0  )
++                {
++                    break;
++                }
++                f.setPointSize( f.pointSize() -1 );
++                fm = QFontMetrics( f );
++            }
++        }
+         p->setFont(f);
+ 
+         /* Draw shadowed text */
+         bool reverse = QApplication::reverseLayout();
+         QPainter::TextDirection rtl = reverse ? QPainter::RTL : QPainter::LTR;
+ 
+-        if (!reverse && !icon.isNull())
++        if (!icon.isNull())
+         {
+-            /* Draw icon */
+-            p->drawPixmap(3, y, icon);
++            if ( !reverse || orientation() == Vertical )
++            {
++                p->drawPixmap(x, y, icon);
++            }
++            else
++            {
++                p->drawPixmap(w - icon.width(), y, icon);
++            }
+         }
+ 
+-        int tX = reverse ? 3 : icon.width() + KMIN(25, KMAX(5, fm.width('m') 
/ 2));
+-        int tY = fm.ascent() + ((h - fm.height()) / 2);
+-
++        int tX = icon.width() + KMIN( 25, KMAX( 5, fm.width( 'm' ) / 2 ) );
++        if ( relx > 0 )
++        {
++            tX = orientation() == Vertical ?
++                ( ( h * relx ) / 100 ) + 2 :
++                ( ( w * relx ) / 100 ) + 2;
++        }
++ 
++        int tY = fm.ascent() + ( ( h - fm.height() ) / 2 );
++        if ( orientation() == Vertical)
++        {
++            tY = m_scaleButton ?
++                0 - ( w / 2 ) + ( fm.height() /4 ) : 
++                0 - ( w - icon.height() ) /2 - ( icon.height() - fm.height() 
) / 2 - fm.height()/4;
++        }
++       
++        if ( rely > 0 )
++        {
++            tY = orientation() == Vertical ?
++                0 - w + ( w * rely ) /100 + fm.height() / 2:
++                ( ( h * rely ) /100 ) + fm.height() / 2;
++        }
+         QColor shadCol = KickerLib::shadowColor(m_textColor);
+ 
+         // get a transparent pixmap
+         QPainter pixPainter;
+-        QPixmap textPixmap(w, h);
++        QPixmap textPixmap;
+ 
++        if ( ! m_scaleButton && orientation() == Horizontal )
++        {
++            textPixmap = QPixmap( icon.width(), icon.height() );
++        }
++        else if ( ! m_scaleButton )
++        {
++            textPixmap = QPixmap( icon.height(), icon.width() );
++        }
++        else if ( orientation() == Horizontal )
++        {
++            textPixmap = QPixmap(w, h);
++        }
++        else 
++        {
++            textPixmap = QPixmap(h, w);
++        }
+         textPixmap.fill(QColor(0,0,0));
+         textPixmap.setMask(textPixmap.createHeuristicMask(true));
+ 
+         // draw text
+         pixPainter.begin(&textPixmap);
+-        pixPainter.setPen(m_textColor);
+-        pixPainter.setFont(p->font()); // get the font from the root painter
+-        pixPainter.drawText(tX, tY, m_buttonText, -1, rtl);
++        pixPainter.setPen( m_textColor );
++        pixPainter.setFont( f ); // get the font from the root painter
++        pixPainter.drawText( tX, orientation() == Horizontal ? tY : width() + 
tY + 1, m_buttonText, -1, rtl);
+         pixPainter.end();
+ 
+         if (!s_textShadowEngine)
+@@ -610,29 +686,37 @@
+             shadset->setOffsetX(0);
+             shadset->setOffsetY(0);
+             shadset->setThickness(1);
+-            shadset->setMaxOpacity(96);
++            shadset->setMaxOpacity(64);
+             s_textShadowEngine = new KShadowEngine(shadset);
+         }
+ 
+         // draw shadow
+         QImage img = s_textShadowEngine->makeShadow(textPixmap, shadCol);
+-        p->drawImage(0, 0, img);
++        p->drawImage( 0, orientation() == Horizontal ? 0 : 0 - w, img);
+         p->save();
+-        p->setPen(m_textColor);
+-        p->drawText(tX, tY, m_buttonText, -1, rtl);
+-        p->restore();
++        p->setPen( m_textColor );
++        p->setFont( f );
++        p->drawText( tX, tY, m_buttonText, -1, rtl);        
++      p->restore();
+ 
+-        if (reverse && !icon.isNull())
+-        {
+-            p->drawPixmap(w - icon.width() - 3, y, icon);
+-        }
+ 
+         p->restore();
+     }
+     else if (!icon.isNull())
+     {
+-        int y = (height() - icon.height()) / 2;
+-        int x = (width()  - icon.width()) / 2;
++        if ( orientation() == Vertical && m_rotateButton )
++        {
++            if (  m_scaleButton )
++            {
++                x = 0;
++                y = 0 - icon.height();
++            }
++            else
++            {
++                y = 0 - (  w / 2 ) - (  icon.height() /2 ) + 1;
++            }
++            p->rotate( 90 );
++        }
+         p->drawPixmap(x, y, icon);
+     }
+ 
+@@ -791,35 +875,52 @@
+ 
+ void PanelButton::loadIcons()
+ {
+-    KIconLoader * ldr = KGlobal::iconLoader();
+-    KIconEffect * kfx = new KIconEffect();
+     QString nm = m_iconName;
+ 
+     KIcon::States defaultState = isEnabled() ? KIcon::DefaultState :
+                                                KIcon::DisabledState;
+ 
+-    QSize ref = ldr->loadIcon( defaultIcon(), KIcon::Panel, m_size, 
defaultState).size();
++    QSize ref = KGlobal::iconLoader()->loadIcon( defaultIcon(), KIcon::Panel, 
m_size, defaultState).size();
+ 
+-    QImage img = QImage( ldr->iconPath(  nm, KIcon::Panel ) );
++    QImage img = QImage( KGlobal::iconLoader()->iconPath(  nm, KIcon::Panel ) 
);
+ 
++    // Try load default image if bitmap is invalid
++    if ( img.isNull() )
++        img = KGlobal::iconLoader()->loadIcon( defaultIcon(), KIcon::Panel, 
m_size, defaultState );
++
++    // again null ? return empty;
++    if ( img.isNull() )
++        return;
++    
++    KIconEffect * kfx = new KIconEffect();
++    
+     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() );
++        int h = KMAX( height(), ref.height() );
++        int w = KMAX( width(), ref.width() );
++        
++        if ( img.height() == img.width() )
++        {
++            m_icon = img.smoothScale( h, h );
++        }
++        else
++        {
++            orientation() == Horizontal ? 
++                m_icon = img.smoothScale( ( img.width() * h ) / img.height(), 
h ) :
++                m_icon = img.smoothScale( ( img.width() * w ) / img.height(), 
w ) ;
++        }
+     }
+     else
+     {
+-       m_icon = img;
++        orientation() == Horizontal ? 
++            m_icon = img.smoothScale( ( img.width() * ref.height() ) / 
img.height(), ref.height() ) :
++            m_icon = img.smoothScale( ( img.width() * ref.width() ) / 
img.height(), ref.width() ) ;
+     }
+ 
+     if (m_icon.isNull())
+     {
+         nm = defaultIcon();
+-        m_icon = ldr->loadIcon(nm, KIcon::Panel, m_size, defaultState);
++        m_icon = KGlobal::iconLoader()->loadIcon(nm, KIcon::Panel, m_size, 
defaultState);
+     }
+ 
+     if (!isEnabled())
+@@ -828,16 +929,18 @@
+     }
+     else
+     {
+-       m_iconh = kfx->apply( 
+-             m_icon,
+-             KIcon::Panel,
+-             KIcon::ActiveState );
++        m_iconh = kfx->apply( 
++                m_icon,
++                KIcon::Panel,
++                KIcon::ActiveState );
+     }
+-    
+     m_iconz = kfx->apply( 
+-          QPixmap( ldr->iconPath( nm, KIcon::SizeHuge ) ),
+-          KIcon::Panel,
+-          defaultState );
++            QPixmap( KGlobal::iconLoader()->iconPath( nm, KIcon::SizeHuge ) ),
++            KIcon::Panel,
++            defaultState );
++    
++    delete kfx;
++    
+ }
+ 
+ // (re)calculates the icon sizes and report true if they have changed.
+--- kdebase-3.5.6/kicker/libkicker/panelbutton.h--     2007-02-16 
10:26:56.000000000 +0100
++++ kdebase-3.5.6/kicker/libkicker/panelbutton.h       2007-02-16 
10:27:05.000000000 +0100
+@@ -171,6 +171,24 @@
+      */
+     QColor textColor() const;
+ 
++     /**
++     * Change the button's text label font
++     * @param f the new text label font
++     */
++    void setTextFont(const QFont& f);
++
++    /**
++     * @return the button's text label font
++     */
++    QFont textFont() const;
++
++
++    /** 
++     * Set button to be rotated on vertical oriented panel
++     */
++    void setButtonRotation( bool r );
++
++
+     /**
+      * Change the button's text scale
+      * @param p font scale (in percent)
+@@ -386,9 +404,11 @@
+     bool m_changeCursorOverItem;
+     bool m_hasAcceptedDrag;
+     bool m_scaleButton;
++    bool m_rotateButton;
+     QColor m_textColor;
+     QColor m_tileColor;
+     QString m_buttonText;
++    QFont m_textFont;
+     QString m_tile;
+     QString m_title;
+     QString m_iconName;
+--- kdebase-3.5.6/kicker/kicker/buttons/kbutton.cpp--  2007-02-16 
10:20:14.000000000 +0100
++++ kdebase-3.5.6/kicker/kicker/buttons/kbutton.cpp    2007-02-16 
10:26:13.000000000 +0100
+@@ -55,15 +55,14 @@
+     MenuManager::the()->registerKButton(this);
+     KConfig* config = KGlobal::config();
+     config->setGroup("KMenu");
+-    QString icon = config->readEntry( "KMenuIcon", "kmenu" );
+-    QString iconName = config->readBoolEntry("KmenuUseMdvIcon", true) ? 
"mdv_kmenu" : icon ;
+-    config->readBoolEntry( "KMenuButtonScale", true ) ? setIcon( iconName ) : 
setIcon( iconName, false );
+-
++    setIcon( config->readEntry( "KMenuIcon", "kmenu" ),
++          config->readBoolEntry( "KMenuButtonScale", true ) );
++    setButtonRotation( config->readBoolEntry( "KMenuButtonRotate", false ) );
+     if (KickerSettings::showKMenuText())
+     {
+-        setButtonText(KickerSettings::kMenuText());
+-        setFont(KickerSettings::buttonFont());
+-        setTextColor(KickerSettings::buttonTextColor());
++        setButtonText( KickerSettings::kMenuText() );
++        setTextColor( KickerSettings::kMenuTextColor() );
++        setTextFont( KickerSettings::kMenuTextFont() );
+     }
+ }
+ 

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 16 10:35:50 2007
@@ -41,7 +41,7 @@
 Name: kdebase
 Summary:       K Desktop Environment - Core files
 Version: 3.5.6
-Release: %mkrel 11
+Release: %mkrel 12
 Epoch: 1
 Group: Graphical desktop/KDE
 License:       GPL
@@ -252,7 +252,9 @@
 Patch161:      kdebase-3.5.6-fix-background-default.patch
 
 Patch166:      kdebase-3.5.6-kicker-button-custom.patch
-Patch167:      kdebase-3.5.6-sidetop.patch
+Patch167:      kdebase-3.5.6-kicker-button-custom2.patch
+Patch168:      kdebase-3.5.6-sidetop.patch
+
 
 BuildConflicts: lm_utils
 BuildConflicts: lm_utils-devel
@@ -1654,7 +1656,8 @@
 %patch161 -p1 -b .fix_background_default_value
 
 %patch166 -p1 -b .kicker_custom_button
-%patch167 -p1 -b .kicker_side_top
+%patch167 -p1 -b .kicker_custom_button2
+#%patch168 -p1 -b .kicker_side_top
 
 %build
 # This is here just because patch 93. Too

Reply via email to