author | Michael Krelin <hacker@klever.net> | 2007-07-04 11:23:42 (UTC) |
---|---|---|
committer | Michael Krelin <hacker@klever.net> | 2007-07-04 11:23:42 (UTC) |
commit | a08aff328d4393031d5ba7d622c2b05705a89d73 (patch) (unidiff) | |
tree | 8ee90d686081c52e7c69b5ce946e9b1a7d690001 /microkde/kdeui/ktoolbarbutton.cpp | |
parent | 11edc920afe4f274c0964436633aa632c8288a40 (diff) | |
download | kdepimpi-p1.zip kdepimpi-p1.tar.gz kdepimpi-p1.tar.bz2 |
initial public commit of qt4 portp1
Diffstat (limited to 'microkde/kdeui/ktoolbarbutton.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | microkde/kdeui/ktoolbarbutton.cpp | 106 |
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 | |||
@@ -30,28 +30,32 @@ | |||
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 | ||
51 | template class QIntDict<KToolBarButton>; | 55 | template class Q3IntDict<KToolBarButton>; |
52 | 56 | ||
53 | class KToolBarButtonPrivate | 57 | class KToolBarButtonPrivate |
54 | { | 58 | { |
55 | public: | 59 | public: |
56 | KToolBarButtonPrivate() | 60 | KToolBarButtonPrivate() |
57 | { | 61 | { |
@@ -112,13 +116,13 @@ KToolBarButton::KToolBarButton( const QString& _icon, int _id, | |||
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() ), |
@@ -143,13 +147,13 @@ KToolBarButton::KToolBarButton( const QPixmap& pixmap, int _id, | |||
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() ), |
@@ -158,13 +162,13 @@ KToolBarButton::KToolBarButton( const QPixmap& pixmap, int _id, | |||
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 | ||
168 | KToolBarButton::~KToolBarButton() | 172 | KToolBarButton::~KToolBarButton() |
169 | { | 173 | { |
170 | delete d; d = 0; | 174 | delete d; d = 0; |
@@ -289,87 +293,87 @@ void KToolBarButton::setIcon( const QString &icon ) | |||
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 | ||
295 | void KToolBarButton::setIconSet( const QIconSet &iconset ) | 299 | void KToolBarButton::setIconSet( const QIcon &iconset ) |
296 | { | 300 | { |
297 | QToolButton::setIconSet( iconset ); | 301 | QToolButton::setIconSet( iconset ); |
298 | } | 302 | } |
299 | 303 | ||
300 | // remove? | 304 | // remove? |
301 | void KToolBarButton::setPixmap( const QPixmap &pixmap ) | 305 | void 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 | ||
313 | void KToolBarButton::setDefaultPixmap( const QPixmap &pixmap ) | 317 | void 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 | ||
320 | void KToolBarButton::setDisabledPixmap( const QPixmap &pixmap ) | 324 | void 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 | ||
327 | void KToolBarButton::setDefaultIcon( const QString& icon ) | 331 | void 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 | ||
341 | void KToolBarButton::setDisabledIcon( const QString& icon ) | 345 | void 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 | ||
355 | QPopupMenu *KToolBarButton::popup() | 359 | QMenu *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 | ||
362 | void KToolBarButton::setPopup(QPopupMenu *p, bool) | 366 | void 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 | ||
369 | void KToolBarButton::setDelayedPopup (QPopupMenu *p, bool) | 373 | void 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 | ||
375 | void KToolBarButton::leaveEvent(QEvent *) | 379 | void KToolBarButton::leaveEvent(QEvent *) |
@@ -448,27 +452,33 @@ bool KToolBarButton::eventFilter(QObject *o, QEvent *ev) | |||
448 | return QToolButton::eventFilter(o, ev); | 452 | return QToolButton::eventFilter(o, ev); |
449 | } | 453 | } |
450 | 454 | ||
451 | void KToolBarButton::drawButton( QPainter *_painter ) | 455 | void 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()); |
@@ -481,15 +491,15 @@ void KToolBarButton::drawButton( QPainter *_painter ) | |||
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*/ ) |
@@ -505,15 +515,15 @@ void KToolBarButton::drawButton( QPainter *_painter ) | |||
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*/ ) |
@@ -523,13 +533,13 @@ void KToolBarButton::drawButton( QPainter *_painter ) | |||
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*/ ) |
@@ -541,13 +551,13 @@ void KToolBarButton::drawButton( QPainter *_painter ) | |||
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; |
@@ -560,15 +570,15 @@ void KToolBarButton::drawButton( QPainter *_painter ) | |||
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*/ ) |
@@ -578,13 +588,13 @@ void KToolBarButton::drawButton( QPainter *_painter ) | |||
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; |
@@ -607,20 +617,24 @@ void KToolBarButton::drawButton( QPainter *_painter ) | |||
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 | } |