Make the closeAllPopup helper virtual in QGuiApplication
QPA plugins might have to close popups for events that are not delivered to QWindow or QWidget instances. For instance, the Cocoa plugin has to explicilty close popups when the user clicks into the window frame. Expose this functionality through a virtual in QGuiApplicationPrivate, and move the QApplication implementation from a static helper into the override. Task-number: QTBUG-96450 Change-Id: I52be5710c8d7515b9ae2e4bbadb069df4b3ed546 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>bb10
parent
62b658ee8e
commit
276943c8b7
|
|
@ -223,6 +223,7 @@ public:
|
|||
static void updateBlockedStatus(QWindow *window);
|
||||
virtual bool isWindowBlocked(QWindow *window, QWindow **blockingWindow = nullptr) const;
|
||||
virtual bool popupActive() { return false; }
|
||||
virtual bool closeAllPopups() { return false; }
|
||||
|
||||
static Qt::MouseButton mousePressButton;
|
||||
static QPointF lastCursorPosition;
|
||||
|
|
|
|||
|
|
@ -2628,16 +2628,6 @@ bool QApplicationPrivate::shouldQuit()
|
|||
return QGuiApplicationPrivate::shouldQuitInternal(processedWindows);
|
||||
}
|
||||
|
||||
static inline void closeAllPopups()
|
||||
{
|
||||
// Close all popups: In case some popup refuses to close,
|
||||
// we give up after 1024 attempts (to avoid an infinite loop).
|
||||
int maxiter = 1024;
|
||||
QWidget *popup;
|
||||
while ((popup = QApplication::activePopupWidget()) && maxiter--)
|
||||
popup->close();
|
||||
}
|
||||
|
||||
/*! \reimp
|
||||
*/
|
||||
bool QApplication::notify(QObject *receiver, QEvent *e)
|
||||
|
|
@ -2711,7 +2701,7 @@ bool QApplication::notify(QObject *receiver, QEvent *e)
|
|||
// Close all popups (triggers when switching applications
|
||||
// by pressing ALT-TAB on Windows, which is not receive as key event.
|
||||
// triggers when the screen rotates.)
|
||||
closeAllPopups();
|
||||
d->closeAllPopups();
|
||||
break;
|
||||
case QEvent::Wheel: // User input and window activation makes tooltips sleep
|
||||
case QEvent::ActivationChange:
|
||||
|
|
@ -3444,6 +3434,17 @@ extern QWidget *qt_popup_down;
|
|||
extern bool qt_replay_popup_mouse_event;
|
||||
extern bool qt_popup_down_closed;
|
||||
|
||||
bool QApplicationPrivate::closeAllPopups()
|
||||
{
|
||||
// Close all popups: In case some popup refuses to close,
|
||||
// we give up after 1024 attempts (to avoid an infinite loop).
|
||||
int maxiter = 1024;
|
||||
QWidget *popup;
|
||||
while ((popup = QApplication::activePopupWidget()) && maxiter--)
|
||||
popup->close(); // this will call QApplicationPrivate::closePopup
|
||||
return true;
|
||||
}
|
||||
|
||||
void QApplicationPrivate::closePopup(QWidget *popup)
|
||||
{
|
||||
if (!popupWidgets)
|
||||
|
|
|
|||
|
|
@ -145,6 +145,7 @@ public:
|
|||
|
||||
static bool inPopupMode();
|
||||
bool popupActive() override { return inPopupMode(); }
|
||||
bool closeAllPopups() override;
|
||||
void closePopup(QWidget *popup);
|
||||
void openPopup(QWidget *popup);
|
||||
static void setFocusWidget(QWidget *focus, Qt::FocusReason reason);
|
||||
|
|
|
|||
Loading…
Reference in New Issue