diff -r -u -x .deps -x '*.o' -x '*.la' -x .libs -x 'Makefile*' -x '*.moc' kdebase-3.5.9/kicker.orig/kicker/buttons/kbutton.cpp kdebase-3.5.9/kicker/kicker/buttons/kbutton.cpp --- kdebase-3.5.9/kicker.orig/kicker/buttons/kbutton.cpp 2008-03-05 11:19:04.000000000 -0300 +++ kdebase-3.5.9/kicker/kicker/buttons/kbutton.cpp 2008-03-05 17:51:54.000000000 -0300 @@ -58,10 +58,7 @@ KConfig* config = KGlobal::config(); config->setGroup("KMenu"); QString iconname = config->readEntry( "KMenuIcon", "kmenu" ); - //if( QApplication::reverseLayout() && orientation() == Horizontal ) - // iconname += iconname.append( "-rtl" ); - setIcon( iconname, - config->readBoolEntry( "KMenuButtonScale", true ) ); + setIcon( iconname, false ); setButtonRotation( config->readBoolEntry( "KMenuButtonRotate", false ) ); if (KickerSettings::showKMenuText()) @@ -85,8 +82,6 @@ void KButton::initPopup() { -// kdDebug(1210) << "KButton::initPopup()" << endl; - // this hack is required to ensure the correct popup position // when the size of the recent application part of the menu changes // please don't remove this _again_ diff -r -u -x .deps -x '*.o' -x '*.la' -x .libs -x 'Makefile*' -x '*.moc' kdebase-3.5.9/kicker.orig/kicker/buttons/knewbutton.cpp kdebase-3.5.9/kicker/kicker/buttons/knewbutton.cpp --- kdebase-3.5.9/kicker.orig/kicker/buttons/knewbutton.cpp 2008-03-05 11:19:04.000000000 -0300 +++ kdebase-3.5.9/kicker/kicker/buttons/knewbutton.cpp 2008-03-05 11:20:11.000000000 -0300 @@ -63,16 +63,8 @@ m_mouseInside = false; m_drag = false; - setIconAlignment((Qt::AlignmentFlags)(AlignTop|AlignRight)); - setAcceptDrops(true); - setIcon("kmenu-suse"); setDrawArrow(false); - m_movie = new QMovie(locate("data", "kicker/pics/kmenu_basic.mng")); - m_movie->connectUpdate(this, SLOT(updateMovie())); - m_movie->connectStatus(this, SLOT(slotStatus(int))); - m_movie->connectResize(this, SLOT(slotSetSize(const QSize&))); - QApplication::desktop()->screen()->installEventFilter(this); setMouseTracking(true); } @@ -82,130 +74,25 @@ if ( m_self == this ) m_self = 0; setMouseTracking(false); - delete m_movie; -} - -void KNewButton::slotStatus(int status) -{ - if(status == QMovie::EndOfLoop) - slotStopAnimation(); -} - -QColor KNewButton::borderColor() const -{ - QImage img = m_active_pixmap.convertToImage(); - - for (int i = 0; i < img.width(); ++i) { - QRgb rgb = img.pixel(orientation() == Qt::Horizontal ? img.width() - i - 1 : - i, 2); - - if (qGreen(rgb) > 0x50) - return rgb; - } - - return img.pixel( orientation() == Qt::Horizontal ? img.width() - 2 : 2, 2); -} - -void KNewButton::show() -{ - KButton::show(); - - if (KickerSettings::firstRun()) { - QTimer::singleShot(500,this,SLOT(slotExecMenu())); - KickerSettings::setFirstRun(false); - KickerSettings::writeConfig(); - } -} - -void KNewButton::updateMovie() -{ - m_oldPos = QPoint( -1, -1 ); - drawEye(); - - if (!m_active && m_movie->running()) - m_movie->pause(); } void KNewButton::setPopupDirection(KPanelApplet::Direction d) { KButton::setPopupDirection(d); - delete m_movie; - switch (d) { case KPanelApplet::Left: setIconAlignment((Qt::AlignmentFlags)(AlignTop|AlignLeft)); - m_movie = new QMovie(locate("data", "kicker/pics/kmenu_vertical.mng")); break; case KPanelApplet::Right: setIconAlignment((Qt::AlignmentFlags)(AlignTop|AlignRight)); - m_movie = new QMovie(locate("data", "kicker/pics/kmenu_vertical.mng")); break; case KPanelApplet::Up: setIconAlignment((Qt::AlignmentFlags)(AlignTop|AlignHCenter)); - m_movie = new QMovie(locate("data", "kicker/pics/kmenu_basic.mng")); break; case KPanelApplet::Down: setIconAlignment((Qt::AlignmentFlags)(AlignBottom|AlignHCenter)); - m_movie = new QMovie(locate("data", "kicker/pics/kmenu_flipped.mng")); } - - m_movie->connectUpdate(this, SLOT(updateMovie())); - m_movie->connectStatus(this, SLOT(slotStatus(int))); - m_movie->connectResize(this, SLOT(slotSetSize(const QSize&))); -} - -void KNewButton::slotSetSize(const QSize& s) -{ - m_iconSize = s; -} - -double KNewButton::buttonScaleFactor(const QSize& s) const -{ - double sf = 1.0; - - switch (popupDirection()) { - case KPanelApplet::Left: - case KPanelApplet::Right: -// sf = kMin(double(s.width()) / m_iconSize.height(), double(s.height()) / m_iconSize.width()); -// break; - case KPanelApplet::Up: - case KPanelApplet::Down: - sf = kMin(double(s.width()) / m_iconSize.width(), double(s.height()) / m_iconSize.height()); - break; - } - - if (sf > 0.8) sf = 1.0; - return sf; -} - -int KNewButton::widthForHeight(int height) const -{ - int r = m_iconSize.width() * buttonScaleFactor(QSize(m_iconSize.width(), height)); - - if (!m_movie->running() && height != m_active_pixmap.height()) - { - KNewButton* that = const_cast<KNewButton*>(this); - QTimer::singleShot(0, that, SLOT(slotStopAnimation())); - } - - return r; -} - -int KNewButton::preferredDimension(int panelDim) const -{ - return kMax(m_icon.width(), m_icon.height()); -} - -int KNewButton::heightForWidth(int width) const -{ - int r = m_iconSize.width() * buttonScaleFactor(QSize(width, m_iconSize.height())); - if (!m_movie->running() && width != m_active_pixmap.width()) - { - KNewButton* that = const_cast<KNewButton*>(this); - QTimer::singleShot(0, that, SLOT(slotStopAnimation())); - } - return r; } bool KNewButton::eventFilter(QObject *o, QEvent *e) @@ -223,75 +110,9 @@ } } - if (KickerSettings::kickoffDrawGeekoEye() && e->type() == QEvent::MouseMove) - { - QMouseEvent *me = static_cast<QMouseEvent *>(e); - if ((me->state() & MouseButtonMask) == NoButton) - drawEye(); - } - return KButton::eventFilter(o, e); } -void KNewButton::drawEye() -{ -#define eye_x 62 -#define eye_y 13 - QPoint mouse = QCursor::pos(); - QPoint me = mapToGlobal(QPoint(eye_x, eye_y)); - double a = atan2(mouse.y() - me.y(), mouse.x() - me.x()); - int dx = int(2.1 * cos(a)); - int dy = int(2.1 * sin(a)); - - QPoint newpos(eye_x+dx,eye_y+dy); - if (newpos!=m_oldPos) { - m_oldPos = newpos; - QPixmap pixmap = m_active_pixmap; - - double sf = 1.0; - - if(!m_movie->framePixmap().isNull()) - { - pixmap = m_movie->framePixmap(); - pixmap.detach(); - m_iconSize = pixmap.size(); - sf = buttonScaleFactor(size()); - - if (KickerSettings::kickoffDrawGeekoEye()) { - QPainter p(&pixmap); - p.setPen(white); - p.setBrush(white); - // p.setPen(QColor(110,185,55)); - p.drawRect(eye_x+dx, eye_y+dy, 2, 2); - p. end(); - } - } - - QWMatrix matrix; - switch (popupDirection()) { - case KPanelApplet::Left: - matrix.scale(sf, -sf); - matrix.rotate(90); - break; - case KPanelApplet::Up: - matrix.scale(sf, sf); - break; - case KPanelApplet::Right: - matrix.scale(sf, -sf); - matrix.rotate(90); - break; - case KPanelApplet::Down: - matrix.scale(sf, sf); - break; - } - m_active_pixmap = pixmap.xForm(matrix); - - repaint(false); - } -#undef eye_x -#undef eye_y -} - void KNewButton::enterEvent(QEvent* e) { KButton::enterEvent(e); @@ -315,14 +136,6 @@ } m_active = true; - m_movie->unpause(); - m_movie->restart(); -} - -void KNewButton::rewindMovie() -{ - m_oldPos = QPoint( -1, -1 ); - m_movie->unpause(); } void KNewButton::dragEnterEvent(QDragEnterEvent* /*e*/) @@ -369,19 +182,6 @@ } } -void KNewButton::slotStopAnimation() -{ - m_active = false; - m_movie->pause(); - m_movie->restart(); - QTimer::singleShot(200, this, SLOT(rewindMovie())); -} - -const QPixmap& KNewButton::labelIcon() const -{ - return m_active_pixmap; -} - void KNewButton::slotExecMenu() { if (m_openTimer != -1) @@ -389,52 +189,17 @@ m_openTimer = startTimer(QApplication::doubleClickInterval() * 3); - if (m_active) - { - m_active = false; - m_movie->pause(); - m_movie->restart(); - } - KButton::slotExecMenu(); assert(!KickerTip::tippingEnabled()); assert(dynamic_cast<KMenu*>(m_popup)); - disconnect(dynamic_cast<KMenu*>(m_popup), SIGNAL(aboutToHide()), this, - SLOT(slotStopAnimation())); - connect(dynamic_cast<KMenu*>(m_popup), SIGNAL(aboutToHide()), - SLOT(slotStopAnimation())); - m_popup->move(KickerLib::popupPosition(popupDirection(), m_popup, this)); // I wish KMenu would properly done itself when it closes. But it doesn't. - bool useEffect = true; // could be QApplication::isEffectEnabled() - useEffect = false; // too many Qt bugs to be useful - if (m_drag) - useEffect = false; - m_drag = false; // once is enough - if (useEffect) - { - switch (popupDirection()) { - case KPanelApplet::Left: - qScrollEffect(m_popup, QEffects::LeftScroll); - break; - case KPanelApplet::Up: - qScrollEffect(m_popup, QEffects::UpScroll); - break; - case KPanelApplet::Right: - qScrollEffect(m_popup, QEffects::RightScroll); - break; - case KPanelApplet::Down: - qScrollEffect(m_popup, QEffects::DownScroll); - break; - } - } - else - static_cast<KMenu*>(m_popup)->show(); + static_cast<KMenu*>(m_popup)->show(); } void KNewButton::timerEvent(QTimerEvent* e) diff -r -u -x .deps -x '*.o' -x '*.la' -x .libs -x 'Makefile*' -x '*.moc' kdebase-3.5.9/kicker.orig/kicker/buttons/knewbutton.h kdebase-3.5.9/kicker/kicker/buttons/knewbutton.h --- kdebase-3.5.9/kicker.orig/kicker/buttons/knewbutton.h 2008-03-05 11:19:04.000000000 -0300 +++ kdebase-3.5.9/kicker/kicker/buttons/knewbutton.h 2008-03-05 11:20:11.000000000 -0300 @@ -28,7 +28,6 @@ #include "kbutton.h" -#include <qmovie.h> #include <qpoint.h> /** @@ -46,28 +45,11 @@ void loadConfig( const KConfigGroup& config ); - virtual const QPixmap& labelIcon() const; - - virtual int widthForHeight(int height) const; - virtual int preferredDimension(int panelDim) const; - virtual int heightForWidth(int width) const; - - QColor borderColor() const; - virtual void setPopupDirection(KPanelApplet::Direction d); -private slots: - void slotStatus(int); - void slotSetSize(const QSize&); - void slotStopAnimation(); - void rewindMovie(); - void updateMovie(); - protected: - virtual void show(); virtual void slotExecMenu(); virtual QString tileName() { return "KMenu"; } - virtual QString defaultIcon() const { return "go"; } virtual void enterEvent(QEvent* e); virtual void leaveEvent(QEvent* e); @@ -78,10 +60,6 @@ void timerEvent(QTimerEvent*); private: - void drawEye(); - double buttonScaleFactor(const QSize& s) const; - - QMovie* m_movie; QPixmap m_active_pixmap; QPoint m_oldPos; QSize m_iconSize; diff -r -u -x .deps -x '*.o' -x '*.la' -x .libs -x 'Makefile*' -x '*.moc' kdebase-3.5.9/kicker.orig/kicker/ui/appletop_mnu.cpp kdebase-3.5.9/kicker/kicker/ui/appletop_mnu.cpp --- kdebase-3.5.9/kicker.orig/kicker/ui/appletop_mnu.cpp 2008-03-05 11:19:04.000000000 -0300 +++ kdebase-3.5.9/kicker/kicker/ui/appletop_mnu.cpp 2008-03-05 18:00:59.000000000 -0300 @@ -235,17 +235,22 @@ void PanelAppletOpMenu::toggleIcon() { bool legacy = !KickerSettings::defaultKButton(); - - - KickerSettings::setDefaultKButton(legacy); - KickerSettings::setShowKMenuText(!legacy); - KickerSettings::setKMenuButtonScale(true); - KickerSettings::setKMenuButtonRotate(!legacy); - if (legacy) + + KickerSettings::setDefaultKButton( legacy ); + KickerSettings::setShowKMenuText( !legacy ); + + if ( legacy ) KickerSettings::setKMenuIcon("kmenu"); else - KickerSettings::setKMenuIcon("mdv_kmenu"); - KickerSettings::writeConfig(); + { + QString menuName = KickerSettings::kMenuIcon(); + if ( menuName.isEmpty() || menuName == "kmenu" ) + KickerSettings::setKMenuIcon("mdv_kmenu"); + else + KickerSettings::setKMenuIcon( menuName ) ; + } + + KickerSettings::writeConfig(); Kicker::the()->restart(); } diff -r -u -x .deps -x '*.o' -x '*.la' -x .libs -x 'Makefile*' -x '*.moc' kdebase-3.5.9/kicker.orig/kicker/ui/k_new_mnu.cpp kdebase-3.5.9/kicker/kicker/ui/k_new_mnu.cpp --- kdebase-3.5.9/kicker.orig/kicker/ui/k_new_mnu.cpp 2008-03-05 11:19:04.000000000 -0300 +++ kdebase-3.5.9/kicker/kicker/ui/k_new_mnu.cpp 2008-03-05 11:20:11.000000000 -0300 @@ -1700,8 +1700,8 @@ QPixmap pix( 64, footer->height() ); QPainter p( &pix ); p.fillRect( 0, 0, 64, footer->height(), m_branding->colorGroup().brush( QColorGroup::Base ) ); - p.fillRect( 0, m_orientation == BottomUp ? footer->height() - 2 : 0, - 64, 3, KNewButton::self()->borderColor() ); + //p.fillRect( 0, m_orientation == BottomUp ? footer->height() - 2 : 0, + // 64, 3, KNewButton::self()->borderColor() ); p.end(); footer->setPaletteBackgroundPixmap( pix ); } diff -r -u -x .deps -x '*.o' -x '*.la' -x .libs -x 'Makefile*' -x '*.moc' kdebase-3.5.9/kicker.orig/libkicker/kickerSettings.kcfg kdebase-3.5.9/kicker/libkicker/kickerSettings.kcfg --- kdebase-3.5.9/kicker.orig/libkicker/kickerSettings.kcfg 2008-03-05 11:19:04.000000000 -0300 +++ kdebase-3.5.9/kicker/libkicker/kickerSettings.kcfg 2008-03-05 11:20:11.000000000 -0300 @@ -387,19 +387,9 @@ <default>true</default> </entry> -<entry name="KMenuButtonScale" key="KMenuButtonScale" type="Bool" > - <label>Enable scaling in the K Menu Button</label> - <default>true</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 name="KMenuButtonMaxVSize" key="KMenuButtonMaxVSize" type="UInt" > + <label>Limit the maximum vertical size of button</label> + <default>22</default> </entry> <entry name="KMenuTextFont" key="TextFont" type="Font" > diff -r -u -x .deps -x '*.o' -x '*.la' -x .libs -x 'Makefile*' -x '*.moc' kdebase-3.5.9/kicker.orig/libkicker/panelbutton.cpp kdebase-3.5.9/kicker/libkicker/panelbutton.cpp --- kdebase-3.5.9/kicker.orig/libkicker/panelbutton.cpp 2008-03-05 11:19:04.000000000 -0300 +++ kdebase-3.5.9/kicker/libkicker/panelbutton.cpp 2008-03-05 18:22:31.000000000 -0300 @@ -278,22 +278,19 @@ { QString nm = m_iconName; - if (nm != "menuk-mdk") - { - int newSize = panelDim; - - if ( KickerSettings::conserveSpace() ) - { - int preferred = preferredIconSize( panelDim ); - if ( preferred > 0 ) - newSize = QMIN( panelDim, preferred + ( KDialog::spacingHint() * 2 ) ); - } - - 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 newSize = panelDim; + + if ( KickerSettings::conserveSpace() ) + { + int preferred = preferredIconSize( panelDim ); + if ( preferred > 0 ) + newSize = QMIN( panelDim, preferred + ( KDialog::spacingHint() * 2 ) ); + } + + 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() ) ; // determine the upper limit on the size. Normally, this is panelDim, // but if conserveSpace() is true, we restrict size to comfortably fit the icon @@ -311,25 +308,7 @@ int PanelButton::widthForHeight(int height) const { - QString nm = m_iconName; - - if (nm != "menuk-mdk") - return preferredDimension(height); - - 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); - - rc += fm.width(m_buttonText) + KMIN(25, KMAX(5, fm.width('m') / 2)); - } - - return rc; + return preferredDimension(height); } int PanelButton::heightForWidth(int width) const @@ -599,24 +578,10 @@ icon = icon.convertToImage().smoothScale(icon.width() - 2, icon.height() - 2); - int y = 0; int w = width(); int h = height(); - int x = (w - icon.width()) / 2; - - if ( nm=="menuk-mdk" ) - { - if ( m_iconAlignment & AlignVCenter ) - y = ( height() - icon.height() ) / 2; - else if ( m_iconAlignment & AlignBottom ) - y = ( height() - icon.height() ); - } - - if ( ! m_scaleButton ) - y = ( h - icon.height() ) / 2; - - int relx = KickerSettings::kMenuTextRelativeXPos(); - int rely = KickerSettings::kMenuTextRelativeYPos(); + int y = ( height() - icon.height() ) / 2; + int x = ( width() - icon.width()) / 2; if ( !m_buttonText.isEmpty() ) { @@ -625,9 +590,7 @@ if ( orientation() == Vertical) { x = 0; - y = m_scaleButton ? - 0 - icon.height() : - 0 - w + ( ( w - icon.height() ) / 2 ) + 2; + y = 0 - icon.height() - ( width()/4 ) + 2; p->rotate( 90 ); } p->save(); @@ -639,7 +602,7 @@ // possible relx diference. If not reduce font size if ( orientation() == Horizontal ) { - while ( fm.width( m_buttonText, m_buttonText.length() ) > ( w - relx - 8 ) ) + while ( fm.width( m_buttonText, m_buttonText.length() ) > ( w - 8 ) ) { if ( ( f.pointSize() -1 ) <= 0 ) { @@ -651,7 +614,7 @@ } else { - while ( fm.width( m_buttonText, m_buttonText.length() ) > ( h - relx - 8 ) ) + while ( fm.width( m_buttonText, m_buttonText.length() ) > ( h - 8 ) ) { if ( ( f.pointSize() -1 ) <= 0 ) { @@ -676,60 +639,36 @@ p->drawPixmap(w - icon.width(), y, icon); } - 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); + QColor shadCol = KickerLib::shadowColor(m_textColor); // get a transparent pixmap QPainter pixPainter; QPixmap textPixmap; - if ( ! m_scaleButton && orientation() == Horizontal ) - { + if ( 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 = QPixmap( icon.height(), icon.width() ); textPixmap.fill(QColor(0,0,0)); textPixmap.setMask(textPixmap.createHeuristicMask(true)); + + + int textX = orientation() == Horizontal ? + width()/2 - fm.width( m_buttonText, m_buttonText.length() )/2 + 8 : + height()/2 - fm.width( m_buttonText, m_buttonText.length() )/2 + 8; + int textY = orientation() == Horizontal ? + height()/2 + icon.height()/4 : + 0 - width()/2 + icon.height()/4; - // draw text + kdDebug() << "WIDTH: " << width() << " : TEXTX: " << textX << endl; + kdDebug() << "HEIGHT: " << height() << " : TEXTY: " << textY << endl; + + // draw shadow pixPainter.begin(&textPixmap); 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.drawText( textX + 2, textY + 2, m_buttonText, -1, rtl); pixPainter.end(); if (!s_textShadowEngine) @@ -742,41 +681,23 @@ s_textShadowEngine = new KShadowEngine(shadset); } - // draw shadow + // draw text QImage img = s_textShadowEngine->makeShadow(textPixmap, shadCol); p->drawImage( 0, orientation() == Horizontal ? 0 : 0 - w, img); p->save(); p->setPen( m_textColor ); p->setFont( f ); - p->drawText( tX, tY, m_buttonText, -1, rtl); - p->restore(); - + p->drawText( textX , textY , m_buttonText, -1, rtl); p->restore(); } else if (!icon.isNull()) { if ( orientation() == Vertical && m_rotateButton ) { - if ( m_scaleButton ) - { - x = 0; - y = 0 - icon.height(); - } - else - { - y = 0 - ( w / 2 ) - ( icon.height() /2 ) + 1; - } + y = 0 - ( w / 2 ) - ( icon.height() /2 ) + 1; p->rotate( 90 ); } - if ( nm=="menuk-mdk" ) - { - if ( m_iconAlignment & AlignVCenter ) - y = ( height() - icon.height() ) / 2; - else if ( m_iconAlignment & AlignBottom ) - y = ( height() - icon.height() ); - } - p->drawPixmap(x, y, icon); } @@ -942,55 +863,32 @@ QImage img; KIconEffect * kfx = new KIconEffect(); - if (nm=="menuk-mdk") + ref = KGlobal::iconLoader()->loadIcon( defaultIcon(), KIcon::Panel, m_size, defaultState).size(); + 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; + + KConfig* config = KGlobal::config(); + config->setGroup( "KMenu" ); + uint maxVSize = config->readUnsignedNumEntry( "KMenuButtonMaxVSize", 22 ); + uint buttonHeight = ref.height() > maxVSize ? maxVSize : ref.height(); + + if ( !m_buttonText.isEmpty() ) { - QString pth = locate( "data", "kicker/pics/kmenu_basic.mng" ); - if (!pth.isEmpty()) - { - m_icon = QImage(pth); - m_iconh = QPixmap(m_icon); - m_iconz = QPixmap(m_icon); - return; - } + m_icon = img.smoothScale( ( img.width() * buttonHeight ) / img.height(), buttonHeight ); } else - { - ref = KGlobal::iconLoader()->loadIcon( defaultIcon(), KIcon::Panel, m_size, defaultState).size(); - 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; - - if ( m_scaleButton ) - { - 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 - { - 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() ) ; - } + { + 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();