6#ifndef QSK_SHORTCUT_MAP_H
7#define QSK_SHORTCUT_MAP_H
9#include "QskMetaFunction.h"
10#include <qquickwindow.h>
18 static void setAutoRepeat(
int,
bool on );
19 static void setEnabled(
int,
bool on );
20 static void setEnabled(
const QKeySequence&,
bool on );
22 static void removeShortcut(
int );
25 static int addShortcut(
const QKeySequence&,
26 bool autoRepeat,
const QObject* receiver,
const char* method );
28 static int addShortcut( QQuickWindow*,
const QKeySequence&,
29 bool autoRepeat,
const QObject* receiver,
const char* method );
31 static int addShortcut( QQuickItem*,
const QKeySequence&,
32 bool autoRepeat,
const QObject* receiver,
const char* method );
35 template<
typename T, QskMetaFunctionTraits::IsFunctorOrStaticFunction< T >* =
nullptr >
36 static int addShortcut(
const QKeySequence&,
bool autoRepeat, T function );
38 template<
typename T, QskMetaFunctionTraits::IsFunctorOrStaticFunction< T >* =
nullptr >
39 static int addShortcut( QQuickItem*,
const QKeySequence&,
bool autoRepeat, T function );
41 template<
typename T, QskMetaFunctionTraits::IsFunctorOrStaticFunction< T >* =
nullptr >
42 static int addShortcut( QQuickWindow*,
const QKeySequence&,
bool autoRepeat, T function );
44 template<
typename T, QskMetaFunctionTraits::IsFunctorOrStaticFunction< T >* =
nullptr >
45 static int addShortcut(
const QKeySequence&,
bool autoRepeat,
46 const QObject* context, T function );
48 template<
typename T, QskMetaFunctionTraits::IsFunctorOrStaticFunction< T >* =
nullptr >
49 static int addShortcut( QQuickItem*,
const QKeySequence&,
50 bool autoRepeat,
const QObject* context, T function );
52 template<
typename T, QskMetaFunctionTraits::IsFunctorOrStaticFunction< T >* =
nullptr >
53 static int addShortcut( QQuickWindow*,
const QKeySequence&,
54 bool autoRepeat,
const QObject* context, T function );
56 template<
typename T, QskMetaFunctionTraits::IsMemberFunction< T >* =
nullptr >
57 static int addShortcut(
const QKeySequence&,
bool autoRepeat,
58 const typename QtPrivate::FunctionPointer< T >::Object* receiver, T function );
60 template<
typename T, QskMetaFunctionTraits::IsMemberFunction< T >* =
nullptr >
61 static int addShortcut( QQuickItem*,
const QKeySequence&,
bool autoRepeat,
62 const typename QtPrivate::FunctionPointer< T >::Object* receiver, T function );
64 template<
typename T, QskMetaFunctionTraits::IsMemberFunction< T >* =
nullptr >
65 static int addShortcut( QQuickWindow*,
const QKeySequence&,
bool autoRepeat,
66 const typename QtPrivate::FunctionPointer< T >::Object* receiver, T function );
69 static bool invokeCallback(
const QKeySequence& );
70 static bool invokeCallback( QQuickWindow*,
const QKeySequence& );
71 static bool invokeCallback( QQuickItem*,
const QKeySequence& );
73 static bool contextMatcher(
const QQuickItem*, Qt::ShortcutContext );
79 template<
typename T >
80 static int addFunctionT(
81 QQuickItem*,
const QKeySequence&,
bool autoRepeat,
82 const QObject* receiver, T );
84 static int addFunction(
85 QQuickItem*,
const QKeySequence&,
bool autoRepeat,
89 QQuickItem*,
const QKeySequence&,
bool autoRepeat,
90 const QObject* receiver,
const char* );
93inline int QskShortcutMap::addShortcut(
94 const QKeySequence& sequence,
bool autoRepeat,
95 const QObject* receiver,
const char* method )
97 return addMethod(
nullptr, sequence, autoRepeat, receiver, method );
100inline int QskShortcutMap::addShortcut(
101 QQuickWindow* window,
const QKeySequence& sequence,
102 bool autoRepeat,
const QObject* receiver,
const char* method )
104 auto item = window ? window->contentItem() :
nullptr;
105 return addMethod( item, sequence, autoRepeat, receiver, method );
108template<
typename T, QskMetaFunctionTraits::IsFunctorOrStaticFunction< T >* >
109inline int QskShortcutMap::addShortcut(
110 const QKeySequence& sequence,
bool autoRepeat, T function )
112 return addFunctionT(
nullptr, sequence, autoRepeat,
nullptr, function );
115template<
typename T, QskMetaFunctionTraits::IsFunctorOrStaticFunction< T >* >
116inline int QskShortcutMap::addShortcut(
117 QQuickItem* item,
const QKeySequence& sequence,
118 bool autoRepeat, T function )
120 return addFunctionT( item, sequence, autoRepeat,
nullptr, function );
123template<
typename T, QskMetaFunctionTraits::IsFunctorOrStaticFunction< T >* >
124inline int QskShortcutMap::addShortcut(
125 QQuickWindow* window,
const QKeySequence& sequence,
126 bool autoRepeat, T function )
128 auto item = window ? window->contentItem() :
nullptr;
129 return addFunctionT( item, sequence, autoRepeat,
nullptr, function );
132template<
typename T, QskMetaFunctionTraits::IsFunctorOrStaticFunction< T >* >
133inline int QskShortcutMap::addShortcut(
134 const QKeySequence& sequence,
bool autoRepeat,
135 const QObject* context, T function )
137 return addFunctionT(
nullptr, sequence, autoRepeat, context, function );
140template<
typename T, QskMetaFunctionTraits::IsFunctorOrStaticFunction< T >* >
141inline int QskShortcutMap::addShortcut(
142 QQuickItem* item,
const QKeySequence& sequence,
bool autoRepeat,
143 const QObject* context, T function )
145 return addFunctionT( item, sequence, autoRepeat, context, function );
148template<
typename T, QskMetaFunctionTraits::IsFunctorOrStaticFunction< T >* >
149inline int QskShortcutMap::addShortcut(
150 QQuickWindow* window,
const QKeySequence& sequence,
151 bool autoRepeat,
const QObject* context, T function )
153 auto item = window ? window->contentItem() :
nullptr;
154 return addFunctionT( item, sequence, autoRepeat, context, function );
157template<
typename T, QskMetaFunctionTraits::IsMemberFunction< T >* >
158inline int QskShortcutMap::addShortcut(
159 const QKeySequence& sequence,
bool autoRepeat,
160 const typename QtPrivate::FunctionPointer< T >::Object* receiver, T function )
162 return addFunctionT(
nullptr, sequence, autoRepeat, receiver, function );
165template<
typename T, QskMetaFunctionTraits::IsMemberFunction< T >* >
166inline int QskShortcutMap::addShortcut(
167 QQuickItem* item,
const QKeySequence& sequence,
bool autoRepeat,
168 const typename QtPrivate::FunctionPointer< T >::Object* receiver, T function )
170 return addFunctionT( item, sequence, autoRepeat, receiver, function );
173template<
typename T, QskMetaFunctionTraits::IsMemberFunction< T >* >
174inline int QskShortcutMap::addShortcut(
175 QQuickWindow* window,
const QKeySequence& sequence,
bool autoRepeat,
176 const typename QtPrivate::FunctionPointer< T >::Object* receiver, T function )
178 auto item = window ? window->contentItem() :
nullptr;
179 return addFunctionT( item, sequence, autoRepeat, receiver, function );
182template<
typename T >
183inline int QskShortcutMap::addFunctionT(
184 QQuickItem* item,
const QKeySequence& sequence,
bool autoRepeat,
185 const QObject* context, T function )
187 static_assert( QskMetaFunctionTraits::argumentCount< T >() == 0,
188 "QskShortcutMap::addShortcut: #number of arguments need to be 0." );
190 return addFunction( item, sequence, autoRepeat, context, function );