Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-109948

Trigger transient parent shortcuts when tool window has focus

    XMLWordPrintable

Details

    • Suggestion
    • Resolution: Unresolved
    • Not Evaluated
    • None
    • 5.15.13
    • Quick: Controls 1
    • None
    • Windows

    Description

      On macOS any shortcuts in the global menu of a main application window are working even when a tool window (e.g. undocked panel) has focus (this is due to the main menu being backed by native OS global menu). On Windows this won't work.

       

      For my project I have modified the qShortcutContextMatcher to accept transient parent shortcuts for all tool windows, but probably it would be better to add a new Qt::WindowFlag that would control this behaviour. Below is my change to have the coherent behaviour (expected by my users) on all of the platforms:

      --- a/src/controls/qquickaction.cpp
      +++ b/src/controls/qquickaction.cpp
      @@ -236,8 +236,18 @@ bool qShortcutContextMatcher(QObject *o, Qt::ShortcutContext context)
                   if (QQuickItem * item = qobject_cast<QQuickItem*>(w))
                       w = item->window();
               }
      -        if (w && w == QGuiApplication::focusWindow())
      +
      +        auto focusWindow = QGuiApplication::focusWindow();
      +
      +        if (w && w == focusWindow)
                   return true;
      +
      +        // Tool windows that have focus should trigger shortcuts of their transient parents
      +        if (w && focusWindow &&
      +            (focusWindow->flags() & Qt::Tool) == Qt::Tool &&
      +            focusWindow->transientParent() == w) {
      +          return true;
      +        }
           } 

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            dariusz.maciejewski Dariusz Maciejewski
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes