Changeset 561 for trunk/src/gui/widgets/qpushbutton.cpp
- Timestamp:
- Feb 11, 2010, 11:19:06 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
-
Property svn:mergeinfo
set to (toggle deleted branches)
/branches/vendor/nokia/qt/4.6.1 merged eligible /branches/vendor/nokia/qt/current merged eligible /branches/vendor/trolltech/qt/current 3-149
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
trunk/src/gui/widgets/qpushbutton.cpp
r306 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information ([email protected]) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation ([email protected]) 5 6 ** 6 7 ** This file is part of the QtGui module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you 37 ** @nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 64 64 #endif 65 65 66 66 67 #include "private/qpushbutton_p.h" 67 68 … … 74 75 75 76 \ingroup basicwidgets 76 \mainclass 77 77 78 78 79 The push button, or command button, is perhaps the most commonly … … 388 389 { 389 390 Q_D(const QPushButton); 390 if (d->sizeHint.isValid() )391 if (d->sizeHint.isValid()) 391 392 return d->sizeHint; 393 392 394 ensurePolished(); 393 395 … … 528 530 529 531 if (menu && !d->menu) { 530 disconnect(this, SIGNAL(pressed()), this, SLOT(_q_popupPressed())); 531 connect(this, SIGNAL(pressed()), this, SLOT(_q_popupPressed())); 532 connect(this, SIGNAL(pressed()), this, SLOT(_q_popupPressed()), Qt::UniqueConnection); 532 533 } 533 534 if (d->menu) … … 576 577 577 578 menu->setNoReplayFor(q); 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 578 599 bool horizontal = true; 579 600 #if !defined(QT_NO_TOOLBAR) 580 QToolBar *tb = qobject_cast<QToolBar*>( q->parentWidget());601 QToolBar *tb = qobject_cast<QToolBar*>(); 581 602 if (tb && tb->orientation() == Qt::Vertical) 582 603 horizontal = false; 583 604 #endif 605 584 606 QWidgetItem item(q); 585 607 QRect rect = item.geometry(); … … 591 613 int y = globalPos.y(); 592 614 if (horizontal) { 593 if (globalPos.y() + rect.height() + menuSize.height() <= qApp->desktop()->height()) {615 if (globalPos.y() + rect.height() + menuSize.height() <= height()) { 594 616 y += rect.height(); 595 617 } else { … … 599 621 x += rect.width() - menuSize.width(); 600 622 } else { 601 if (globalPos.x() + rect.width() + menu->sizeHint().width() <= qApp->desktop()->width())623 if (globalPos.x() + rect.width() + menu->sizeHint().width() <= width()) 602 624 x += rect.width(); 603 625 else 604 626 x -= menuSize.width(); 605 627 } 606 QPointer<QPushButton> guard(q); 607 608 //Because of a delay in menu effects, we must keep track of the 609 //menu visibility to avoid flicker on button release 610 menuOpen = true; 611 menu->exec(QPoint(x, y)); 612 if (guard) { 613 menuOpen = false; 614 // on some platforms (e.g. OS/2) QPushButton::focusOutEvent() may be called 615 // before we return from exec() above (for example, as a result of window 616 // deactivation). It will set down to false but since menuOpen won't be 617 // false yet, the button will be redrawn as sunken still. Simple setDown(false) 618 // won't do anything in this case so we need to call update() instead to make 619 // sure the button is redrawn as unsunken. 620 if (down) 621 q->setDown(false); 622 else 623 q->update(); 624 } 625 } 628 629 return QPoint(x,y); 630 } 631 626 632 #endif // QT_NO_MENU 627 633 … … 668 674 d->resetLayoutItemMargins(); 669 675 updateGeometry(); 676 677 670 678 } 671 679 return QAbstractButton::event(e);
Note:
See TracChangeset
for help on using the changeset viewer.