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();
69 if (
auto a = qobject_cast<QAction *>(
object))
70 return correctActionContext(
context,
a, active_window);
73#if QT_CONFIG(graphicsview)
74 if (
auto gw = qobject_cast<QGraphicsWidget *>(
object))
75 return correctGraphicsWidgetContext(
context, gw, active_window);
80 if (
auto s = qobject_cast<QShortcut *>(
object))
87 if (
auto widget_window = qobject_cast<QWidgetWindow *>(qwindow)) {
88 w = widget_window->widget();
91 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())
134 tw = tw->parentWidget();
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)
194 bool visible =
w->isVisible();
195#if defined(Q_OS_DARWIN) && QT_CONFIG(menubar)
200 if (!visible || !
w->isEnabled() || !
w->scene())
207 const auto &views =
w->scene()->views();
208 for (
auto view : views) {
220 if (ti && ti->isWidget()) {
234 for (
auto view : views) {
235 if (
view->window() == active_window) {
256 const QObjectList associatedObjects =
a->associatedObjects();
257#if defined(DEBUG_QSHORTCUTMAP)
258 if (associatedObjects.
isEmpty())
259 qDebug() <<
a <<
"not connected to any widgets; won't trigger";
261 for (
auto object : associatedObjects) {
263 if (
auto menu = qobject_cast<QMenu *>(
object)) {
280 if (
a->isVisible() &&
a->isEnabled() && correctActionContext(
context,
a, active_window))
284 if (
auto widget = qobject_cast<QWidget*>(
object)) {
288#if QT_CONFIG(graphicsview)
289 else if (
auto graphicsWidget = qobject_cast<QGraphicsWidget*>(
object)) {
290 if (correctGraphicsWidgetContext(
context, graphicsWidget, active_window))
314#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
QList< QGraphicsView * > views() const
Returns a list of all the views that display this scene.
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)
static bool simpleContextMatcher(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)