5#include "private/qshortcut_p.h"
7#include "private/qwidget_p.h"
10#if QT_CONFIG(whatsthis)
20#include <private/qapplication_p.h>
21#include <private/qshortcutmap_p.h>
23# include <private/qaction_p.h>
25#include <private/qwidgetwindow_p.h>
26#include <qpa/qplatformmenu.h>
31#if QT_CONFIG(graphicsview)
45 Q_ASSERT_X(
object,
"QShortcutMap",
"Shortcut has no owner. Illegal map state!");
57 if (qwindow && qwindow->isActive()) {
59 if (
auto widgetWindow = qobject_cast<QWidgetWindow *>(qwindow)) {
60 active_window = widgetWindow->widget();
63 qwindow = qwindow->parent();
72 if (
auto a = qobject_cast<QAction *>(
object))
73 return correctActionContext(
context,
a, active_window);
76#if QT_CONFIG(graphicsview)
77 if (
auto gw = qobject_cast<QGraphicsWidget *>(
object))
78 return correctGraphicsWidgetContext(
context, gw, active_window);
83 if (
auto s = qobject_cast<QShortcut *>(
object))
90 if (
auto widget_window = qobject_cast<QWidgetWindow *>(qwindow)) {
91 w = widget_window->widget();
94 qwindow = qwindow->parent();
106 bool visible =
w->isVisible();
107#if QT_CONFIG(menubar)
108 if (
auto menuBar = qobject_cast<QMenuBar *>(
w)) {
113 if (
auto *ww = qobject_cast<QWidgetWindow *>(pmb->parentWindow()))
122 if (!visible || !
w->isEnabled())
140#if QT_CONFIG(graphicsview)
142 if (topData->proxyWidget) {
143 bool res = correctGraphicsWidgetContext(
context, topData->proxyWidget, active_window);
149 if (active_window && active_window != tlw) {
160 if (active_window != tlw) {
161#if QT_CONFIG(menubar)
165 if (!qobject_cast<QMenuBar *>(tlw))
177 while (focus_widget && focus_widget != sw)
179 return sw == focus_widget;
182#if defined(DEBUG_QSHORTCUTMAP)
183 qDebug().nospace() <<
"..true [Pass-through]";
188#if QT_CONFIG(graphicsview)
191 bool visible =
w->isVisible();
192#if defined(Q_OS_DARWIN) && QT_CONFIG(menubar)
197 if (!visible || !
w->isEnabled() || !
w->scene())
204 const auto &views =
w->scene()->views();
205 for (
auto view : views) {
229 const auto &views =
w->scene()->views();
231 for (
auto view : views) {
232 if (
view->window() == active_window) {
250 const QObjectList associatedObjects =
a->associatedObjects();
251#if defined(DEBUG_QSHORTCUTMAP)
252 if (associatedObjects.
isEmpty())
253 qDebug() <<
a <<
"not connected to any widgets; won't trigger";
255 for (
auto object : associatedObjects) {
257 if (
auto menu = qobject_cast<QMenu *>(
object)) {
274 if (
a->isVisible() &&
a->isEnabled() && correctActionContext(
context,
a, active_window))
282#if QT_CONFIG(graphicsview)
283 else if (
auto graphicsWidget = qobject_cast<QGraphicsWidget*>(
object)) {
284 if (correctGraphicsWidgetContext(
context, graphicsWidget, active_window))
308#if QT_CONFIG(whatsthis)
The QAction class provides an abstraction for user commands that can be added to different user inter...
QShortcutPrivate * createShortcutPrivate() const override
static bool tryModalHelper(QWidget *widget, QWidget **rettop=nullptr)
static QWidget * focusWidget()
Returns the application widget that has the keyboard input focus, or \nullptr if no widget in this ap...
static QWidget * activePopupWidget()
Returns the active popup widget.
static QWidget * activeWindow()
Returns the application top-level window that has the keyboard input focus, or \nullptr if no applica...
static bool testAttribute(Qt::ApplicationAttribute attribute)
Returns true if attribute attribute is set; otherwise returns false.
static QPoint pos()
Returns the position of the cursor (hot spot) of the primary screen in global screen coordinates.
The QGraphicsItem class is the base class for all graphical items in a QGraphicsScene.
QGraphicsWidget * parentWidget() const
QGraphicsScene * scene() const
Returns the current scene for the item, or \nullptr if the item is not stored in a scene.
QGraphicsWidget * window() const
QGraphicsWidget * activeWindow() const
QGraphicsItem * focusItem() const
When the scene is active, this functions returns the scene's current focus item, or \nullptr if no it...
The QGraphicsView class provides a widget for displaying the contents of a QGraphicsScene.
static QWindow * focusWindow()
Returns the QWindow that receives events tied to focus, such as key events.
bool isEmpty() const noexcept
static QObjectPrivate * get(QObject *o)
bool(* ContextMatcher)(QObject *object, Qt::ShortcutContext context)
The QShortcut class is used to create keyboard shortcuts.
static void showText(const QPoint &pos, const QString &text, QWidget *w=nullptr)
Shows text as a "What's This?" window, at global position pos.
static bool inWhatsThisMode()
Returns true if the user interface is in "What's This?" mode; otherwise returns false.
Combined button and popup list for selecting options.
@ AA_DontUseNativeMenuBar
@ WidgetWithChildrenShortcut
GLfloat GLfloat GLfloat w
[0]
GLboolean GLboolean GLboolean GLboolean a
[7]
#define Q_ASSERT_X(cond, x, msg)
QWindow * qobject_cast< QWindow * >(QObject *o)