summaryrefslogtreecommitdiffabout
path: root/microkde/kdeui/ktoolbarbutton.cpp
Unidiff
Diffstat (limited to 'microkde/kdeui/ktoolbarbutton.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--microkde/kdeui/ktoolbarbutton.cpp106
1 files changed, 60 insertions, 46 deletions
diff --git a/microkde/kdeui/ktoolbarbutton.cpp b/microkde/kdeui/ktoolbarbutton.cpp
index 1d5d0e5..7b98b32 100644
--- a/microkde/kdeui/ktoolbarbutton.cpp
+++ b/microkde/kdeui/ktoolbarbutton.cpp
@@ -24,40 +24,44 @@
24//US #include <config.h> 24//US #include <config.h>
25#include <string.h> 25#include <string.h>
26 26
27#include "ktoolbarbutton.h" 27#include "ktoolbarbutton.h"
28#include "ktoolbar.h" 28#include "ktoolbar.h"
29 29
30#include <qstyle.h> 30#include <qstyle.h>
31#include <qimage.h> 31#include <qimage.h>
32#include <qtimer.h> 32#include <qtimer.h>
33#include <qdrawutil.h> 33#include <qdrawutil.h>
34#include <qtooltip.h> 34#include <qtooltip.h>
35#include <qbitmap.h> 35#include <qbitmap.h>
36#include <qpopupmenu.h> 36#include <q3popupmenu.h>
37#include <qcursor.h> 37#include <qcursor.h>
38#include <qpainter.h> 38#include <qpainter.h>
39#include <qlayout.h> 39#include <qlayout.h>
40//Added by qt3to4:
41#include <QPixmap>
42#include <QMouseEvent>
43#include <QEvent>
40 44
41#include <kapplication.h> 45#include <kapplication.h>
42#include <kdebug.h> 46#include <kdebug.h>
43#include <kglobal.h> 47#include <kglobal.h>
44#include <kglobalsettings.h> 48#include <kglobalsettings.h>
45//US #include <kiconeffect.h> 49//US #include <kiconeffect.h>
46#include <kiconloader.h> 50#include <kiconloader.h>
47 51
48// needed to get our instance 52// needed to get our instance
49#include <kmainwindow.h> 53#include <kmainwindow.h>
50 54
51template class QIntDict<KToolBarButton>; 55template class Q3IntDict<KToolBarButton>;
52 56
53class KToolBarButtonPrivate 57class KToolBarButtonPrivate
54{ 58{
55public: 59public:
56 KToolBarButtonPrivate() 60 KToolBarButtonPrivate()
57 { 61 {
58 m_noStyle = false; 62 m_noStyle = false;
59 m_isSeparator = false; 63 m_isSeparator = false;
60 m_isRadio = false; 64 m_isRadio = false;
61 m_highlight = false; 65 m_highlight = false;
62 m_isRaised = false; 66 m_isRaised = false;
63 m_isActive = false; 67 m_isActive = false;
@@ -106,25 +110,25 @@ KToolBarButton::KToolBarButton( QWidget *_parent, const char *_name )
106KToolBarButton::KToolBarButton( const QString& _icon, int _id, 110KToolBarButton::KToolBarButton( const QString& _icon, int _id,
107 QWidget *_parent, const char *_name, 111 QWidget *_parent, const char *_name,
108 const QString &_txt/*US, KInstance *_instance*/ ) 112 const QString &_txt/*US, KInstance *_instance*/ )
109 : QToolButton( _parent, _name ), d( 0 ) 113 : QToolButton( _parent, _name ), d( 0 )
110{ 114{
111 d = new KToolBarButtonPrivate; 115 d = new KToolBarButtonPrivate;
112 116
113 d->m_id = _id; 117 d->m_id = _id;
114 d->m_parent = (KToolBar*)_parent; 118 d->m_parent = (KToolBar*)_parent;
115 QToolButton::setTextLabel(_txt); 119 QToolButton::setTextLabel(_txt);
116//US d->m_instance = _instance; 120//US d->m_instance = _instance;
117 121
118 setFocusPolicy( NoFocus ); 122 setFocusPolicy( Qt::NoFocus );
119 123
120 // connect all of our slots and start trapping events 124 // connect all of our slots and start trapping events
121 connect(d->m_parent, SIGNAL( modechange() ), 125 connect(d->m_parent, SIGNAL( modechange() ),
122 this, SLOT( modeChange() )); 126 this, SLOT( modeChange() ));
123 127
124 connect(this, SIGNAL( clicked() ), 128 connect(this, SIGNAL( clicked() ),
125 this, SLOT( slotClicked() ) ); 129 this, SLOT( slotClicked() ) );
126 connect(this, SIGNAL( pressed() ), 130 connect(this, SIGNAL( pressed() ),
127 this, SLOT( slotPressed() ) ); 131 this, SLOT( slotPressed() ) );
128 connect(this, SIGNAL( released() ), 132 connect(this, SIGNAL( released() ),
129 this, SLOT( slotReleased() ) ); 133 this, SLOT( slotReleased() ) );
130 installEventFilter(this); 134 installEventFilter(this);
@@ -137,40 +141,40 @@ KToolBarButton::KToolBarButton( const QString& _icon, int _id,
137 141
138KToolBarButton::KToolBarButton( const QPixmap& pixmap, int _id, 142KToolBarButton::KToolBarButton( const QPixmap& pixmap, int _id,
139 QWidget *_parent, const char *name, 143 QWidget *_parent, const char *name,
140 const QString& txt) 144 const QString& txt)
141 : QToolButton( _parent, name ), d( 0 ) 145 : QToolButton( _parent, name ), d( 0 )
142{ 146{
143 d = new KToolBarButtonPrivate; 147 d = new KToolBarButtonPrivate;
144 148
145 d->m_id = _id; 149 d->m_id = _id;
146 d->m_parent = (KToolBar *) _parent; 150 d->m_parent = (KToolBar *) _parent;
147 QToolButton::setTextLabel(txt); 151 QToolButton::setTextLabel(txt);
148 152
149 setFocusPolicy( NoFocus ); 153 setFocusPolicy( Qt::NoFocus );
150 154
151 // connect all of our slots and start trapping events 155 // connect all of our slots and start trapping events
152 connect(d->m_parent, SIGNAL( modechange()), 156 connect(d->m_parent, SIGNAL( modechange()),
153 this, SLOT(modeChange())); 157 this, SLOT(modeChange()));
154 158
155 connect(this, SIGNAL( clicked() ), 159 connect(this, SIGNAL( clicked() ),
156 this, SLOT( slotClicked() )); 160 this, SLOT( slotClicked() ));
157 connect(this, SIGNAL( pressed() ), 161 connect(this, SIGNAL( pressed() ),
158 this, SLOT( slotPressed() )); 162 this, SLOT( slotPressed() ));
159 connect(this, SIGNAL( released() ), 163 connect(this, SIGNAL( released() ),
160 this, SLOT( slotReleased() )); 164 this, SLOT( slotReleased() ));
161 installEventFilter(this); 165 installEventFilter(this);
162 166
163 // set our pixmap and do our initial setup 167 // set our pixmap and do our initial setup
164 setIconSet( QIconSet( pixmap )); 168 setIconSet( QIcon( pixmap ));
165 modeChange(); 169 modeChange();
166} 170}
167 171
168KToolBarButton::~KToolBarButton() 172KToolBarButton::~KToolBarButton()
169{ 173{
170 delete d; d = 0; 174 delete d; d = 0;
171} 175}
172 176
173void KToolBarButton::modeChange() 177void KToolBarButton::modeChange()
174{ 178{
175 QSize mysize; 179 QSize mysize;
176 180
@@ -283,99 +287,99 @@ void KToolBarButton::setIcon( const QString &icon )
283 if (!strcmp(d->m_parent->name(), "mainToolBar")) 287 if (!strcmp(d->m_parent->name(), "mainToolBar"))
284/*US QToolButton::setIconSet( d->m_instance->iconLoader()->loadIconSet( 288/*US QToolButton::setIconSet( d->m_instance->iconLoader()->loadIconSet(
285 d->m_iconName, KIcon::MainToolbar, d->m_iconSize )); 289 d->m_iconName, KIcon::MainToolbar, d->m_iconSize ));
286*/ 290*/
287 QToolButton::setIconSet( KGlobal::iconLoader()->loadIconSet(d->m_iconName )); 291 QToolButton::setIconSet( KGlobal::iconLoader()->loadIconSet(d->m_iconName ));
288 else 292 else
289/*US QToolButton::setIconSet(d->m_instance->iconLoader()->loadIconSet( 293/*US QToolButton::setIconSet(d->m_instance->iconLoader()->loadIconSet(
290 d->m_iconName, KIcon::Toolbar, d->m_iconSize )); 294 d->m_iconName, KIcon::Toolbar, d->m_iconSize ));
291*/ 295*/
292 QToolButton::setIconSet(KGlobal::iconLoader()->loadIconSet(d->m_iconName)); 296 QToolButton::setIconSet(KGlobal::iconLoader()->loadIconSet(d->m_iconName));
293} 297}
294 298
295void KToolBarButton::setIconSet( const QIconSet &iconset ) 299void KToolBarButton::setIconSet( const QIcon &iconset )
296{ 300{
297 QToolButton::setIconSet( iconset ); 301 QToolButton::setIconSet( iconset );
298} 302}
299 303
300// remove? 304// remove?
301void KToolBarButton::setPixmap( const QPixmap &pixmap ) 305void KToolBarButton::setPixmap( const QPixmap &pixmap )
302{ 306{
303 if( pixmap.isNull()) // called by QToolButton 307 if( pixmap.isNull()) // called by QToolButton
304 { 308 {
305 QToolButton::setPixmap( pixmap ); 309 QToolButton::setPixmap( pixmap );
306 return; 310 return;
307 } 311 }
308 QIconSet set = iconSet(); 312 QIcon set = iconSet();
309 set.setPixmap( pixmap, QIconSet::Automatic, QIconSet::Active ); 313 set.setPixmap( pixmap, QIcon::Automatic, QIcon::Active );
310 QToolButton::setIconSet( set ); 314 QToolButton::setIconSet( set );
311} 315}
312 316
313void KToolBarButton::setDefaultPixmap( const QPixmap &pixmap ) 317void KToolBarButton::setDefaultPixmap( const QPixmap &pixmap )
314{ 318{
315 QIconSet set = iconSet(); 319 QIcon set = iconSet();
316 set.setPixmap( pixmap, QIconSet::Automatic, QIconSet::Normal ); 320 set.setPixmap( pixmap, QIcon::Automatic, QIcon::Normal );
317 QToolButton::setIconSet( set ); 321 QToolButton::setIconSet( set );
318} 322}
319 323
320void KToolBarButton::setDisabledPixmap( const QPixmap &pixmap ) 324void KToolBarButton::setDisabledPixmap( const QPixmap &pixmap )
321{ 325{
322 QIconSet set = iconSet(); 326 QIcon set = iconSet();
323 set.setPixmap( pixmap, QIconSet::Automatic, QIconSet::Disabled ); 327 set.setPixmap( pixmap, QIcon::Automatic, QIcon::Disabled );
324 QToolButton::setIconSet( set ); 328 QToolButton::setIconSet( set );
325} 329}
326 330
327void KToolBarButton::setDefaultIcon( const QString& icon ) 331void KToolBarButton::setDefaultIcon( const QString& icon )
328{ 332{
329 QIconSet set = iconSet(); 333 QIcon set = iconSet();
330 QPixmap pm; 334 QPixmap pm;
331 if (!strcmp(d->m_parent->name(), "mainToolBar")) 335 if (!strcmp(d->m_parent->name(), "mainToolBar"))
332 pm = /*US d->m_instance->iconLoader()*/KGlobal::iconLoader()->loadIcon( icon, KIcon::MainToolbar, 336 pm = /*US d->m_instance->iconLoader()*/KGlobal::iconLoader()->loadIcon( icon, KIcon::MainToolbar,
333 d->m_iconSize ); 337 d->m_iconSize );
334 else 338 else
335 pm = /*US d->m_instance->iconLoader()*/KGlobal::iconLoader()->loadIcon( icon, KIcon::Toolbar, 339 pm = /*US d->m_instance->iconLoader()*/KGlobal::iconLoader()->loadIcon( icon, KIcon::Toolbar,
336 d->m_iconSize ); 340 d->m_iconSize );
337 set.setPixmap( pm, QIconSet::Automatic, QIconSet::Normal ); 341 set.setPixmap( pm, QIcon::Automatic, QIcon::Normal );
338 QToolButton::setIconSet( set ); 342 QToolButton::setIconSet( set );
339} 343}
340 344
341void KToolBarButton::setDisabledIcon( const QString& icon ) 345void KToolBarButton::setDisabledIcon( const QString& icon )
342{ 346{
343 QIconSet set = iconSet(); 347 QIcon set = iconSet();
344 QPixmap pm; 348 QPixmap pm;
345 if (!strcmp(d->m_parent->name(), "mainToolBar")) 349 if (!strcmp(d->m_parent->name(), "mainToolBar"))
346 pm = /*US d->m_instance->iconLoader()*/ KGlobal::iconLoader()->loadIcon( icon, KIcon::MainToolbar, 350 pm = /*US d->m_instance->iconLoader()*/ KGlobal::iconLoader()->loadIcon( icon, KIcon::MainToolbar,
347 d->m_iconSize ); 351 d->m_iconSize );
348 else 352 else
349 pm = /*US d->m_instance->iconLoader()*/ KGlobal::iconLoader()->loadIcon( icon, KIcon::Toolbar, 353 pm = /*US d->m_instance->iconLoader()*/ KGlobal::iconLoader()->loadIcon( icon, KIcon::Toolbar,
350 d->m_iconSize ); 354 d->m_iconSize );
351 set.setPixmap( pm, QIconSet::Automatic, QIconSet::Disabled ); 355 set.setPixmap( pm, QIcon::Automatic, QIcon::Disabled );
352 QToolButton::setIconSet( set ); 356 QToolButton::setIconSet( set );
353} 357}
354 358
355QPopupMenu *KToolBarButton::popup() 359QMenu *KToolBarButton::popup()
356{ 360{
357 // obsolete 361 // obsolete
358 // KDE4: remove me 362 // KDE4: remove me
359 return QToolButton::popup(); 363 return QToolButton::popup();
360} 364}
361 365
362void KToolBarButton::setPopup(QPopupMenu *p, bool) 366void KToolBarButton::setPopup(Q3PopupMenu *p, bool)
363{ 367{
364 QToolButton::setPopup(p); 368 QToolButton::setPopup(p);
365 QToolButton::setPopupDelay(1); 369 QToolButton::setPopupDelay(1);
366} 370}
367 371
368 372
369void KToolBarButton::setDelayedPopup (QPopupMenu *p, bool) 373void KToolBarButton::setDelayedPopup (Q3PopupMenu *p, bool)
370{ 374{
371 QToolButton::setPopup(p); 375 QToolButton::setPopup(p);
372//US QToolButton::setPopupDelay(QApplication::startDragTime()); 376//US QToolButton::setPopupDelay(QApplication::startDragTime());
373} 377}
374 378
375void KToolBarButton::leaveEvent(QEvent *) 379void KToolBarButton::leaveEvent(QEvent *)
376{ 380{
377 if( d->m_isRaised || d->m_isActive ) 381 if( d->m_isRaised || d->m_isActive )
378 { 382 {
379 d->m_isRaised = false; 383 d->m_isRaised = false;
380 d->m_isActive = false; 384 d->m_isActive = false;
381 repaint(false); 385 repaint(false);
@@ -442,155 +446,161 @@ bool KToolBarButton::eventFilter(QObject *o, QEvent *ev)
442 { 446 {
443 emit doubleClicked(d->m_id); 447 emit doubleClicked(d->m_id);
444 return true; 448 return true;
445 } 449 }
446 } 450 }
447 451
448 return QToolButton::eventFilter(o, ev); 452 return QToolButton::eventFilter(o, ev);
449} 453}
450 454
451void KToolBarButton::drawButton( QPainter *_painter ) 455void KToolBarButton::drawButton( QPainter *_painter )
452{ 456{
453#ifdef DESKTOP_VERSION 457#ifdef DESKTOP_VERSION
454 QStyle::SFlags flags = QStyle::Style_Default; 458 QStyle::State flags = QStyle::State_None;
455 QStyle::SCFlags active = QStyle::SC_None; 459 QStyle::SubControls active = QStyle::SC_None;
456 460
457 if (isDown()) { 461 if (isDown()) {
458 flags |= QStyle::Style_Down; 462 flags |= QStyle::State_DownArrow;
459 active |= QStyle::SC_ToolButton; 463 active |= QStyle::SC_ToolButton;
460 } 464 }
461 if (isEnabled()) flags |= QStyle::Style_Enabled; 465 if (isEnabled()) flags |= QStyle::State_Enabled;
462 if (isOn()) flags |= QStyle::Style_On; 466 if (isOn()) flags |= QStyle::State_On;
463 if (isEnabled() && d->m_isRaised)flags |= QStyle::Style_Raised; 467 if (isEnabled() && d->m_isRaised)flags |= QStyle::State_Raised;
464 if (hasFocus())flags |= QStyle::Style_HasFocus; 468 if (hasFocus())flags |= QStyle::State_HasFocus;
469
470 QStyleOptionToolButton qsotb;
471 qsotb.initFrom(this);
472 qsotb.state = flags;
473 qsotb.activeSubControls = active;
474 qsotb.rect = rect();
475 qsotb.palette = palette();
465 476
466 // Draw a styled toolbutton 477 // Draw a styled toolbutton
467 style().drawComplexControl(QStyle::CC_ToolButton, _painter, this, rect(), 478 style()->drawComplexControl(QStyle::CC_ToolButton, &qsotb, _painter, this);
468 colorGroup(), flags, QStyle::SC_ToolButton, active, QStyleOption());
469 479
470#else 480#else
471 style().drawToolButton(_painter, rect().x(), rect().y(), rect().width(), rect().height(), colorGroup()); 481 style().drawToolButton(_painter, rect().x(), rect().y(), rect().width(), rect().height(), colorGroup());
472#endif 482#endif
473 int dx, dy; 483 int dx, dy;
474 QFont tmp_font(KGlobalSettings::toolBarFont()); 484 QFont tmp_font(KGlobalSettings::toolBarFont());
475 QFontMetrics fm(tmp_font); 485 QFontMetrics fm(tmp_font);
476 QRect textRect; 486 QRect textRect;
477 int textFlags = 0; 487 int textFlags = 0;
478 488
479 if (d->m_iconText == KToolBar::IconOnly) // icon only 489 if (d->m_iconText == KToolBar::IconOnly) // icon only
480 { 490 {
481/*US 491/*US
482 QPixmap pixmap = iconSet().pixmap( QIconSet::Automatic, 492 QPixmap pixmap = iconSet().pixmap( QIconSet::Automatic,
483 isEnabled() ? (d->m_isActive ? QIconSet::Active : QIconSet::Normal) : 493 isEnabled() ? (d->m_isActive ? QIconSet::Active : QIconSet::Normal) :
484 QIconSet::Disabled, 494 QIconSet::Disabled,
485 isOn() ? QIconSet::On : QIconSet::Off ); 495 isOn() ? QIconSet::On : QIconSet::Off );
486*/ 496*/
487 QPixmap pixmap = iconSet().pixmap( QIconSet::Automatic, 497 QPixmap pixmap = iconSet().pixmap( QIcon::Automatic,
488 isEnabled() ? (d->m_isActive ? QIconSet::Active : QIconSet::Normal) : 498 isEnabled() ? (d->m_isActive ? QIcon::Active : QIcon::Normal) :
489 QIconSet::Disabled); 499 QIcon::Disabled);
490 500
491 if( !pixmap.isNull()) 501 if( !pixmap.isNull())
492 { 502 {
493 dx = ( width() - pixmap.width() ) / 2; 503 dx = ( width() - pixmap.width() ) / 2;
494 dy = ( height() - pixmap.height() ) / 2; 504 dy = ( height() - pixmap.height() ) / 2;
495 if ( isDown() /*US && style().styleHint(QStyle::SH_GUIStyle) == WindowsStyle*/ ) 505 if ( isDown() /*US && style().styleHint(QStyle::SH_GUIStyle) == WindowsStyle*/ )
496 { 506 {
497 ++dx; 507 ++dx;
498 ++dy; 508 ++dy;
499 } 509 }
500 _painter->drawPixmap( dx, dy, pixmap ); 510 _painter->drawPixmap( dx, dy, pixmap );
501 } 511 }
502 } 512 }
503 else if (d->m_iconText == KToolBar::IconTextRight) // icon and text (if any) 513 else if (d->m_iconText == KToolBar::IconTextRight) // icon and text (if any)
504 { 514 {
505/*US 515/*US
506 QPixmap pixmap = iconSet().pixmap( QIconSet::Automatic, 516 QPixmap pixmap = iconSet().pixmap( QIconSet::Automatic,
507 isEnabled() ? (d->m_isActive ? QIconSet::Active : QIconSet::Normal) : 517 isEnabled() ? (d->m_isActive ? QIconSet::Active : QIconSet::Normal) :
508 QIconSet::Disabled, 518 QIconSet::Disabled,
509 isOn() ? QIconSet::On : QIconSet::Off ); 519 isOn() ? QIconSet::On : QIconSet::Off );
510*/ 520*/
511 QPixmap pixmap = iconSet().pixmap( QIconSet::Automatic, 521 QPixmap pixmap = iconSet().pixmap( QIcon::Automatic,
512 isEnabled() ? (d->m_isActive ? QIconSet::Active : QIconSet::Normal) : 522 isEnabled() ? (d->m_isActive ? QIcon::Active : QIcon::Normal) :
513 QIconSet::Disabled); 523 QIcon::Disabled);
514 524
515 if( !pixmap.isNull()) 525 if( !pixmap.isNull())
516 { 526 {
517 dx = 4; 527 dx = 4;
518 dy = ( height() - pixmap.height() ) / 2; 528 dy = ( height() - pixmap.height() ) / 2;
519 if ( isDown() /*US && style().styleHint(QStyle::SH_GUIStyle) == WindowsStyle*/ ) 529 if ( isDown() /*US && style().styleHint(QStyle::SH_GUIStyle) == WindowsStyle*/ )
520 { 530 {
521 ++dx; 531 ++dx;
522 ++dy; 532 ++dy;
523 } 533 }
524 _painter->drawPixmap( dx, dy, pixmap ); 534 _painter->drawPixmap( dx, dy, pixmap );
525 } 535 }
526 536
527 if (!textLabel().isNull()) 537 if (!textLabel().isNull())
528 { 538 {
529 textFlags = AlignVCenter|AlignLeft; 539 textFlags = Qt::AlignVCenter|Qt::AlignLeft;
530 if (!pixmap.isNull()) 540 if (!pixmap.isNull())
531 dx = 4 + pixmap.width() + 2; 541 dx = 4 + pixmap.width() + 2;
532 else 542 else
533 dx = 4; 543 dx = 4;
534 dy = 0; 544 dy = 0;
535 if ( isDown() /*US && style().styleHint(QStyle::SH_GUIStyle) == WindowsStyle*/ ) 545 if ( isDown() /*US && style().styleHint(QStyle::SH_GUIStyle) == WindowsStyle*/ )
536 { 546 {
537 ++dx; 547 ++dx;
538 ++dy; 548 ++dy;
539 } 549 }
540 textRect = QRect(dx, dy, width()-dx, height()); 550 textRect = QRect(dx, dy, width()-dx, height());
541 } 551 }
542 } 552 }
543 else if (d->m_iconText == KToolBar::TextOnly) 553 else if (d->m_iconText == KToolBar::TextOnly)
544 { 554 {
545 if (!textLabel().isNull()) 555 if (!textLabel().isNull())
546 { 556 {
547 textFlags = AlignVCenter|AlignLeft; 557 textFlags = Qt::AlignVCenter|Qt::AlignLeft;
548 dx = (width() - fm.width(textLabel())) / 2; 558 dx = (width() - fm.width(textLabel())) / 2;
549 dy = (height() - fm.lineSpacing()) / 2; 559 dy = (height() - fm.lineSpacing()) / 2;
550 if ( isDown() /*US && style().styleHint(QStyle::SH_GUIStyle) == WindowsStyle*/ ) 560 if ( isDown() /*US && style().styleHint(QStyle::SH_GUIStyle) == WindowsStyle*/ )
551 { 561 {
552 ++dx; 562 ++dx;
553 ++dy; 563 ++dy;
554 } 564 }
555 textRect = QRect( dx, dy, fm.width(textLabel()), fm.lineSpacing() ); 565 textRect = QRect( dx, dy, fm.width(textLabel()), fm.lineSpacing() );
556 } 566 }
557 } 567 }
558 else if (d->m_iconText == KToolBar::IconTextBottom) 568 else if (d->m_iconText == KToolBar::IconTextBottom)
559 { 569 {
560/*US 570/*US
561 QPixmap pixmap = iconSet().pixmap( QIconSet::Automatic, 571 QPixmap pixmap = iconSet().pixmap( QIconSet::Automatic,
562 isEnabled() ? (d->m_isActive ? QIconSet::Active : QIconSet::Normal) : 572 isEnabled() ? (d->m_isActive ? QIconSet::Active : QIconSet::Normal) :
563 QIconSet::Disabled, 573 QIconSet::Disabled,
564 isOn() ? QIconSet::On : QIconSet::Off ); 574 isOn() ? QIconSet::On : QIconSet::Off );
565*/ 575*/
566 QPixmap pixmap = iconSet().pixmap( QIconSet::Automatic, 576 QPixmap pixmap = iconSet().pixmap( QIcon::Automatic,
567 isEnabled() ? (d->m_isActive ? QIconSet::Active : QIconSet::Normal) : 577 isEnabled() ? (d->m_isActive ? QIcon::Active : QIcon::Normal) :
568 QIconSet::Disabled); 578 QIcon::Disabled);
569 579
570 if( !pixmap.isNull()) 580 if( !pixmap.isNull())
571 { 581 {
572 dx = (width() - pixmap.width()) / 2; 582 dx = (width() - pixmap.width()) / 2;
573 dy = (height() - fm.lineSpacing() - pixmap.height()) / 2; 583 dy = (height() - fm.lineSpacing() - pixmap.height()) / 2;
574 if ( isDown() /*US && style().styleHint(QStyle::SH_GUIStyle) == WindowsStyle*/ ) 584 if ( isDown() /*US && style().styleHint(QStyle::SH_GUIStyle) == WindowsStyle*/ )
575 { 585 {
576 ++dx; 586 ++dx;
577 ++dy; 587 ++dy;
578 } 588 }
579 _painter->drawPixmap( dx, dy, pixmap ); 589 _painter->drawPixmap( dx, dy, pixmap );
580 } 590 }
581 591
582 if (!textLabel().isNull()) 592 if (!textLabel().isNull())
583 { 593 {
584 textFlags = AlignBottom|AlignHCenter; 594 textFlags = Qt::AlignBottom|Qt::AlignHCenter;
585 dx = (width() - fm.width(textLabel())) / 2; 595 dx = (width() - fm.width(textLabel())) / 2;
586 dy = height() - fm.lineSpacing() - 4; 596 dy = height() - fm.lineSpacing() - 4;
587 597
588 if ( isDown() /*US && style().styleHint(QStyle::SH_GUIStyle) == WindowsStyle*/ ) 598 if ( isDown() /*US && style().styleHint(QStyle::SH_GUIStyle) == WindowsStyle*/ )
589 { 599 {
590 ++dx; 600 ++dx;
591 ++dy; 601 ++dy;
592 } 602 }
593 textRect = QRect( dx, dy, fm.width(textLabel()), fm.lineSpacing() ); 603 textRect = QRect( dx, dy, fm.width(textLabel()), fm.lineSpacing() );
594 } 604 }
595 } 605 }
596 606
@@ -601,32 +611,36 @@ void KToolBarButton::drawButton( QPainter *_painter )
601 if (!isEnabled()) 611 if (!isEnabled())
602 _painter->setPen(palette().disabled().dark()); 612 _painter->setPen(palette().disabled().dark());
603 else if(d->m_isRaised) 613 else if(d->m_isRaised)
604 _painter->setPen(KGlobalSettings::toolBarHighlightColor()); 614 _painter->setPen(KGlobalSettings::toolBarHighlightColor());
605 else 615 else
606 _painter->setPen( colorGroup().buttonText() ); 616 _painter->setPen( colorGroup().buttonText() );
607 _painter->drawText(textRect, textFlags, textLabel()); 617 _painter->drawText(textRect, textFlags, textLabel());
608 } 618 }
609 619
610 if (QToolButton::popup()) 620 if (QToolButton::popup())
611 { 621 {
612#ifdef DESKTOP_VERSION 622#ifdef DESKTOP_VERSION
613 QStyle::SFlags arrowFlags = QStyle::Style_Default; 623 QStyle::State arrowFlags = QStyle::State_None;
624
625 if (isDown())arrowFlags |= QStyle::State_DownArrow;
626 if (isEnabled()) arrowFlags |= QStyle::State_Enabled;
614 627
615 if (isDown())arrowFlags |= QStyle::Style_Down; 628 QStyleOption qso;
616 if (isEnabled()) arrowFlags |= QStyle::Style_Enabled; 629 qso.initFrom(this);
630 qso.state = arrowFlags;
631 qso.rect = QRect(width()-7, height()-7, 7, 7);
632 qso.palette = palette();
617 633
618 style().drawPrimitive(QStyle::PE_ArrowDown, _painter, 634 style()->drawPrimitive(QStyle::PE_IndicatorArrowDown, &qso, _painter);
619 QRect(width()-7, height()-7, 7, 7), colorGroup(),
620 arrowFlags, QStyleOption() );
621#else 635#else
622 style().drawArrow(_painter, Qt::DownArrow, isDown(), 636 style().drawArrow(_painter, Qt::DownArrow, isDown(),
623 width()-7, height()-7, 7, 7, colorGroup(), isEnabled() ); 637 width()-7, height()-7, 7, 7, colorGroup(), isEnabled() );
624#endif 638#endif
625 639
626 } 640 }
627} 641}
628 642
629void KToolBarButton::paletteChange(const QPalette &) 643void KToolBarButton::paletteChange(const QPalette &)
630{ 644{
631 if(!d->m_isSeparator) 645 if(!d->m_isSeparator)
632 { 646 {