/* SPDX-FileCopyrightText: 2014 David Edmundson SPDX-FileCopyrightText: 2020 David Redondo SPDX-License-Identifier: LGPL-2.1-or-later */ #ifndef KEYSEQUENCEHELPER_H #define KEYSEQUENCEHELPER_H #include #include #include class KeySequenceHelperPrivate; class QQuickWindow; class KeySequenceHelper : public KKeySequenceRecorder { Q_OBJECT QML_ELEMENT Q_PROPERTY( ShortcutTypes checkAgainstShortcutTypes READ checkAgainstShortcutTypes WRITE setCheckAgainstShortcutTypes NOTIFY checkAgainstShortcutTypesChanged) public: enum ShortcutType { None = 0x00, //!< No checking for conflicts StandardShortcuts = 0x01, //!< Check against standard shortcuts. @see KStandardShortcut GlobalShortcuts = 0x02, //!< Check against global shortcuts. @see KGlobalAccel }; Q_DECLARE_FLAGS(ShortcutTypes, ShortcutType) Q_FLAG(ShortcutTypes) /** * Constructor. */ explicit KeySequenceHelper(QObject *parent = nullptr); /** * Destructs the widget. */ ~KeySequenceHelper() override; Q_INVOKABLE bool isKeySequenceAvailable(const QKeySequence &keySequence) const; ShortcutTypes checkAgainstShortcutTypes(); void setCheckAgainstShortcutTypes(ShortcutTypes types); Q_INVOKABLE static bool keySequenceIsEmpty(const QKeySequence &keySequence); Q_INVOKABLE static QString keySequenceNativeText(const QKeySequence &keySequence); Q_INVOKABLE static QWindow *renderWindow(QQuickWindow *quickWindow); Q_SIGNALS: void checkAgainstShortcutTypesChanged(); void errorOccurred(const QString &title, const QString &message); void showStealStandardShortcutDialog(const QString &title, const QString &message, const QKeySequence &key); private: friend class KeySequenceHelperPrivate; KeySequenceHelperPrivate *const d; Q_DISABLE_COPY(KeySequenceHelper) }; Q_DECLARE_OPERATORS_FOR_FLAGS(KeySequenceHelper::ShortcutTypes) #endif // KEYSEQUENCEHELPER_H