aboutsummaryrefslogtreecommitdiffstats
path: root/src/imports/templates
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@qt.io>2016-10-21 21:36:53 +0200
committerJ-P Nurmi <jpnurmi@qt.io>2016-10-31 11:58:50 +0000
commit4ce80b299ccc805b08c1c0227adda92049a2187e (patch)
tree03d5ab1c41f5f0ff5b8ff90364c9936dbfd551ac /src/imports/templates
parent548b0bdd0f57c2209c8cbd7ac4ecda204cf69a2e (diff)
Fix Shortcut to respect modal popups
In the Gallery example, the back navigation shortcut no longer activates when the settings dialog or the about dialog is open. Notice that the back navigation shortcut still activates while the options menu is open. [ChangeLog][Controls][Popup] The QML Shortcut type from QtQuick has been fixed to respect modal popups from QtQuick Controls 2. Task-number: QTBUG-56562 Change-Id: I4c3c762e9db0935ef250ff9f8c553e7d211220c7 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Diffstat (limited to 'src/imports/templates')
-rw-r--r--src/imports/templates/qtquicktemplates2plugin.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/imports/templates/qtquicktemplates2plugin.cpp b/src/imports/templates/qtquicktemplates2plugin.cpp
index b0ec18d3..2c87fd45 100644
--- a/src/imports/templates/qtquicktemplates2plugin.cpp
+++ b/src/imports/templates/qtquicktemplates2plugin.cpp
@@ -65,6 +65,7 @@
#include <QtQuickTemplates2/private/qquickrangeslider_p.h>
#include <QtQuickTemplates2/private/qquickscrollbar_p.h>
#include <QtQuickTemplates2/private/qquickscrollindicator_p.h>
+#include <QtQuickTemplates2/private/qquickshortcutcontext_p_p.h>
#include <QtQuickTemplates2/private/qquickslider_p.h>
#include <QtQuickTemplates2/private/qquickspinbox_p.h>
#include <QtQuickTemplates2/private/qquickstackview_p.h>
@@ -88,6 +89,11 @@ static inline void initResources()
#endif
}
+// qtdeclarative/src/quick/util/qquickshortcut.cpp
+typedef bool (*ShortcutContextMatcher)(QObject *, Qt::ShortcutContext);
+extern ShortcutContextMatcher qt_quick_shortcut_context_matcher();
+extern void qt_quick_set_shortcut_context_matcher(ShortcutContextMatcher matcher);
+
QT_BEGIN_NAMESPACE
class QtQuickTemplates2Plugin: public QQmlExtensionPlugin
@@ -97,12 +103,25 @@ class QtQuickTemplates2Plugin: public QQmlExtensionPlugin
public:
QtQuickTemplates2Plugin(QObject *parent = nullptr);
+ ~QtQuickTemplates2Plugin();
+
void registerTypes(const char *uri);
+
+private:
+ ShortcutContextMatcher originalContextMatcher;
};
QtQuickTemplates2Plugin::QtQuickTemplates2Plugin(QObject *parent) : QQmlExtensionPlugin(parent)
{
initResources();
+
+ originalContextMatcher = qt_quick_shortcut_context_matcher();
+ qt_quick_set_shortcut_context_matcher(QQuickShortcutContext::matcher);
+}
+
+QtQuickTemplates2Plugin::~QtQuickTemplates2Plugin()
+{
+ qt_quick_set_shortcut_context_matcher(originalContextMatcher);
}
void QtQuickTemplates2Plugin::registerTypes(const char *uri)