equal
deleted
inserted
replaced
61 |
61 |
62 #ifndef QT_NO_ACCESSIBILITY |
62 #ifndef QT_NO_ACCESSIBILITY |
63 #include "qaccessible.h" |
63 #include "qaccessible.h" |
64 #endif |
64 #endif |
65 |
65 |
|
66 #include "private/qmenu_p.h" |
66 #include "private/qpushbutton_p.h" |
67 #include "private/qpushbutton_p.h" |
67 |
68 |
68 QT_BEGIN_NAMESPACE |
69 QT_BEGIN_NAMESPACE |
69 |
70 |
70 |
71 |
573 Q_Q(QPushButton); |
574 Q_Q(QPushButton); |
574 if (!down || !menu) |
575 if (!down || !menu) |
575 return; |
576 return; |
576 |
577 |
577 menu->setNoReplayFor(q); |
578 menu->setNoReplayFor(q); |
|
579 |
|
580 QPoint menuPos = adjustedMenuPosition(); |
|
581 |
|
582 QPointer<QPushButton> guard(q); |
|
583 QMenuPrivate::get(menu)->causedPopup.widget = guard; |
|
584 |
|
585 //Because of a delay in menu effects, we must keep track of the |
|
586 //menu visibility to avoid flicker on button release |
|
587 menuOpen = true; |
|
588 menu->exec(menuPos); |
|
589 if (guard) { |
|
590 menuOpen = false; |
|
591 q->setDown(false); |
|
592 } |
|
593 } |
|
594 |
|
595 QPoint QPushButtonPrivate::adjustedMenuPosition() |
|
596 { |
|
597 Q_Q(QPushButton); |
|
598 |
578 bool horizontal = true; |
599 bool horizontal = true; |
579 #if !defined(QT_NO_TOOLBAR) |
600 #if !defined(QT_NO_TOOLBAR) |
580 QToolBar *tb = qobject_cast<QToolBar*>(parent); |
601 QToolBar *tb = qobject_cast<QToolBar*>(parent); |
581 if (tb && tb->orientation() == Qt::Vertical) |
602 if (tb && tb->orientation() == Qt::Vertical) |
582 horizontal = false; |
603 horizontal = false; |
583 #endif |
604 #endif |
|
605 |
584 QWidgetItem item(q); |
606 QWidgetItem item(q); |
585 QRect rect = item.geometry(); |
607 QRect rect = item.geometry(); |
586 rect.setRect(rect.x() - q->x(), rect.y() - q->y(), rect.width(), rect.height()); |
608 rect.setRect(rect.x() - q->x(), rect.y() - q->y(), rect.width(), rect.height()); |
587 |
609 |
588 QSize menuSize = menu->sizeHint(); |
610 QSize menuSize = menu->sizeHint(); |
601 if (globalPos.x() + rect.width() + menu->sizeHint().width() <= QApplication::desktop()->availableGeometry(q).width()) |
623 if (globalPos.x() + rect.width() + menu->sizeHint().width() <= QApplication::desktop()->availableGeometry(q).width()) |
602 x += rect.width(); |
624 x += rect.width(); |
603 else |
625 else |
604 x -= menuSize.width(); |
626 x -= menuSize.width(); |
605 } |
627 } |
606 QPointer<QPushButton> guard(q); |
628 |
607 |
629 return QPoint(x,y); |
608 //Because of a delay in menu effects, we must keep track of the |
630 } |
609 //menu visibility to avoid flicker on button release |
631 |
610 menuOpen = true; |
|
611 menu->exec(QPoint(x, y)); |
|
612 if (guard) { |
|
613 menuOpen = false; |
|
614 q->setDown(false); |
|
615 } |
|
616 } |
|
617 #endif // QT_NO_MENU |
632 #endif // QT_NO_MENU |
618 |
633 |
619 void QPushButtonPrivate::resetLayoutItemMargins() |
634 void QPushButtonPrivate::resetLayoutItemMargins() |
620 { |
635 { |
621 Q_Q(QPushButton); |
636 Q_Q(QPushButton); |