Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/QtGui/qshortcut.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 // Copyright (C) 2019 The Qt Company Ltd.
0002 // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
0003 
0004 #ifndef QSHORTCUT_H
0005 #define QSHORTCUT_H
0006 
0007 #include <QtGui/qtguiglobal.h>
0008 #include <QtGui/qkeysequence.h>
0009 #include <QtCore/qobject.h>
0010 
0011 QT_REQUIRE_CONFIG(shortcut);
0012 
0013 QT_BEGIN_NAMESPACE
0014 
0015 class QShortcutPrivate;
0016 class QWindow;
0017 
0018 class Q_GUI_EXPORT QShortcut : public QObject
0019 {
0020     Q_OBJECT
0021     Q_DECLARE_PRIVATE(QShortcut)
0022     Q_PROPERTY(QKeySequence key READ key WRITE setKey)
0023     Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled)
0024     Q_PROPERTY(bool autoRepeat READ autoRepeat WRITE setAutoRepeat)
0025     Q_PROPERTY(Qt::ShortcutContext context READ context WRITE setContext)
0026 public:
0027     explicit QShortcut(QObject *parent);
0028     explicit QShortcut(const QKeySequence& key, QObject *parent,
0029                        const char *member = nullptr, const char *ambiguousMember = nullptr,
0030                        Qt::ShortcutContext context = Qt::WindowShortcut);
0031     explicit QShortcut(QKeySequence::StandardKey key, QObject *parent,
0032                        const char *member = nullptr, const char *ambiguousMember = nullptr,
0033                        Qt::ShortcutContext context = Qt::WindowShortcut);
0034 
0035 #ifdef Q_QDOC
0036     template<typename Functor>
0037     QShortcut(const QKeySequence &key, QObject *parent,
0038               Functor functor,
0039               Qt::ShortcutContext shortcutContext = Qt::WindowShortcut);
0040     template<typename Functor>
0041     QShortcut(const QKeySequence &key, QObject *parent,
0042               const QObject *context, Functor functor,
0043               Qt::ShortcutContext shortcutContext = Qt::WindowShortcut);
0044     template<typename Functor, typename FunctorAmbiguous>
0045     QShortcut(const QKeySequence &key, QObject *parent,
0046               const QObject *context1, Functor functor,
0047               FunctorAmbiguous functorAmbiguous,
0048               Qt::ShortcutContext shortcutContext = Qt::WindowShortcut);
0049     template<typename Functor, typename FunctorAmbiguous>
0050     QShortcut(const QKeySequence &key, QObject *parent,
0051               const QObject *context1, Functor functor,
0052               const QObject *context2, FunctorAmbiguous functorAmbiguous,
0053               Qt::ShortcutContext shortcutContext = Qt::WindowShortcut);
0054 
0055     template<typename Functor>
0056     QShortcut(QKeySequence::StandardKey key, QObject *parent,
0057               Functor functor,
0058               Qt::ShortcutContext shortcutContext = Qt::WindowShortcut);
0059     template<typename Functor>
0060     QShortcut(QKeySequence::StandardKey key, QObject *parent,
0061               const QObject *context, Functor functor,
0062               Qt::ShortcutContext shortcutContext = Qt::WindowShortcut);
0063     template<typename Functor, typename FunctorAmbiguous>
0064     QShortcut(QKeySequence::StandardKey key, QObject *parent,
0065               const QObject *context1, Functor functor,
0066               FunctorAmbiguous functorAmbiguous,
0067               Qt::ShortcutContext shortcutContext = Qt::WindowShortcut);
0068     template<typename Functor, typename FunctorAmbiguous>
0069     QShortcut(QKeySequence::StandardKey key, QObject *parent,
0070               const QObject *context1, Functor functor,
0071               const QObject *context2, FunctorAmbiguous functorAmbiguous,
0072               Qt::ShortcutContext shortcutContext = Qt::WindowShortcut);
0073 #else
0074     template<typename Func1>
0075     QShortcut(const QKeySequence &key, QObject *parent,
0076               Func1 slot1,
0077               Qt::ShortcutContext context = Qt::WindowShortcut)
0078         : QShortcut(key, parent, static_cast<const char*>(nullptr), static_cast<const char*>(nullptr), context)
0079     {
0080         connect(this, &QShortcut::activated, std::move(slot1));
0081     }
0082     template<class Obj1, typename Func1>
0083     QShortcut(const QKeySequence &key, QObject *parent,
0084               const Obj1 *object1, Func1 slot1,
0085               Qt::ShortcutContext context = Qt::WindowShortcut,
0086               typename std::enable_if<QtPrivate::IsPointerToTypeDerivedFromQObject<Obj1*>::Value>::type* = 0)
0087         : QShortcut(key, parent, static_cast<const char*>(nullptr), static_cast<const char*>(nullptr), context)
0088     {
0089         connect(this, &QShortcut::activated, object1, std::move(slot1));
0090     }
0091     template<class Obj1, typename Func1, typename Func2>
0092     QShortcut(const QKeySequence &key, QObject *parent,
0093               const Obj1 *object1, Func1 slot1, Func2 slot2,
0094               Qt::ShortcutContext context = Qt::WindowShortcut,
0095               typename std::enable_if<QtPrivate::IsPointerToTypeDerivedFromQObject<Obj1*>::Value>::type* = 0)
0096         : QShortcut(key, parent, static_cast<const char*>(nullptr), static_cast<const char*>(nullptr), context)
0097     {
0098         connect(this, &QShortcut::activated, object1, std::move(slot1));
0099         connect(this, &QShortcut::activatedAmbiguously, object1, std::move(slot2));
0100     }
0101     template<class Obj1, typename Func1, class Obj2, typename Func2>
0102     QShortcut(const QKeySequence &key, QObject *parent,
0103               const Obj1 *object1, Func1 slot1,
0104               const Obj2 *object2, Func2 slot2,
0105               Qt::ShortcutContext context = Qt::WindowShortcut,
0106               typename std::enable_if<QtPrivate::IsPointerToTypeDerivedFromQObject<Obj1*>::Value>::type* = 0,
0107               typename std::enable_if<QtPrivate::IsPointerToTypeDerivedFromQObject<Obj2*>::Value>::type* = 0)
0108         : QShortcut(key, parent, static_cast<const char*>(nullptr), static_cast<const char*>(nullptr), context)
0109     {
0110         connect(this, &QShortcut::activated, object1, std::move(slot1));
0111         connect(this, &QShortcut::activatedAmbiguously, object2, std::move(slot2));
0112     }
0113 
0114     template<typename Func1>
0115     QShortcut(QKeySequence::StandardKey key, QObject *parent,
0116               Func1 slot1,
0117               Qt::ShortcutContext context = Qt::WindowShortcut)
0118         : QShortcut(key, parent, static_cast<const char*>(nullptr), static_cast<const char*>(nullptr), context)
0119     {
0120         connect(this, &QShortcut::activated, std::move(slot1));
0121     }
0122     template<class Obj1, typename Func1>
0123     QShortcut(QKeySequence::StandardKey key, QObject *parent,
0124               const Obj1 *object1, Func1 slot1,
0125               Qt::ShortcutContext context = Qt::WindowShortcut,
0126               typename std::enable_if<QtPrivate::IsPointerToTypeDerivedFromQObject<Obj1*>::Value>::type* = 0)
0127         : QShortcut(key, parent, static_cast<const char*>(nullptr), static_cast<const char*>(nullptr), context)
0128     {
0129         connect(this, &QShortcut::activated, object1, std::move(slot1));
0130     }
0131     template<class Obj1, typename Func1, typename Func2>
0132     QShortcut(QKeySequence::StandardKey key, QObject *parent,
0133               const Obj1 *object1, Func1 slot1, Func2 slot2,
0134               Qt::ShortcutContext context = Qt::WindowShortcut,
0135               typename std::enable_if<QtPrivate::IsPointerToTypeDerivedFromQObject<Obj1*>::Value>::type* = 0)
0136         : QShortcut(key, parent, static_cast<const char*>(nullptr), static_cast<const char*>(nullptr), context)
0137     {
0138         connect(this, &QShortcut::activated, object1, std::move(slot1));
0139         connect(this, &QShortcut::activatedAmbiguously, object1, std::move(slot2));
0140     }
0141     template<class Obj1, typename Func1, class Obj2, typename Func2>
0142     QShortcut(QKeySequence::StandardKey key, QObject *parent,
0143               const Obj1 *object1, Func1 slot1,
0144               const Obj2 *object2, Func2 slot2,
0145               Qt::ShortcutContext context = Qt::WindowShortcut,
0146               typename std::enable_if<QtPrivate::IsPointerToTypeDerivedFromQObject<Obj1*>::Value>::type* = 0,
0147               typename std::enable_if<QtPrivate::IsPointerToTypeDerivedFromQObject<Obj2*>::Value>::type* = 0)
0148         : QShortcut(key, parent, static_cast<const char*>(nullptr), static_cast<const char*>(nullptr), context)
0149     {
0150         connect(this, &QShortcut::activated, object1, std::move(slot1));
0151         connect(this, &QShortcut::activatedAmbiguously, object2, std::move(slot2));
0152     }
0153 #endif
0154 
0155     ~QShortcut();
0156 
0157     void setKey(const QKeySequence& key);
0158     QKeySequence key() const;
0159     void setKeys(QKeySequence::StandardKey key);
0160     void setKeys(const QList<QKeySequence> &keys);
0161     QList<QKeySequence> keys() const;
0162 
0163     void setEnabled(bool enable);
0164     bool isEnabled() const;
0165 
0166     void setContext(Qt::ShortcutContext context);
0167     Qt::ShortcutContext context() const;
0168 
0169     void setAutoRepeat(bool on);
0170     bool autoRepeat() const;
0171 
0172 #if QT_DEPRECATED_SINCE(6,0)
0173     QT_DEPRECATED_VERSION_6_0 int id() const;
0174 #endif
0175 
0176     void setWhatsThis(const QString &text);
0177     QString whatsThis() const;
0178 
0179 #if QT_DEPRECATED_SINCE(6,0)
0180 #ifdef Q_QDOC
0181     QWidget *parentWidget() const;
0182 #else
0183     template<typename T = QWidget*>
0184     QT_DEPRECATED_VERSION_X_6_0("Use parent() and qobject_cast instead")
0185     inline T parentWidget() const
0186     { return static_cast<T>(QObject::parent()); }
0187 #endif
0188 #endif
0189 
0190 Q_SIGNALS:
0191     void activated();
0192     void activatedAmbiguously();
0193 
0194 protected:
0195     bool event(QEvent *e) override;
0196 };
0197 
0198 QT_END_NAMESPACE
0199 
0200 #endif // QSHORTCUT_H