File indexing completed on 2024-04-21 14:56:33
0001 /* 0002 This file is part of the KDE libraries 0003 SPDX-FileCopyrightText: 2001, 2002 Ellis Whitehead <ellis@kde.org> 0004 SPDX-FileCopyrightText: 2015 Martin Gräßlin <mgraesslin@kde.org> 0005 0006 SPDX-License-Identifier: LGPL-2.0-or-later 0007 */ 0008 0009 #ifndef KGLOBALACCEL_INTERFACE_H 0010 #define KGLOBALACCEL_INTERFACE_H 0011 0012 #include <QObject> 0013 0014 #include "kf5globalaccelprivate_export.h" 0015 0016 class GlobalShortcutsRegistry; 0017 0018 #define KGlobalAccelInterface_iid "org.kde.kglobalaccel5.KGlobalAccelInterface" 0019 0020 /** 0021 * Abstract interface for plugins to implement 0022 */ 0023 class KGLOBALACCELPRIVATE_EXPORT KGlobalAccelInterface : public QObject 0024 { 0025 Q_OBJECT 0026 0027 public: 0028 explicit KGlobalAccelInterface(QObject *parent); 0029 ~KGlobalAccelInterface() override; 0030 0031 public: 0032 /** 0033 * This function registers or unregisters a certain key for global capture, 0034 * depending on \b grab. 0035 * 0036 * Before destruction, every grabbed key will be released, so this 0037 * object does not need to do any tracking. 0038 * 0039 * \param key the Qt keycode to grab or release. 0040 * \param grab true to grab they key, false to release the key. 0041 * 0042 * \return true if successful, otherwise false. 0043 */ 0044 virtual bool grabKey(int key, bool grab) = 0; 0045 0046 /* 0047 * Enable/disable all shortcuts. There will not be any grabbed shortcuts at this point. 0048 */ 0049 virtual void setEnabled(bool) = 0; 0050 0051 /** 0052 * Allows implementing plugins to synchronize with the windowing system. 0053 * Default implementation does nothing. 0054 **/ 0055 virtual void syncWindowingSystem(); 0056 0057 void setRegistry(GlobalShortcutsRegistry *registry); 0058 0059 protected: 0060 /** 0061 * called by the implementation to inform us about key presses 0062 * @returns @c true if the key was handled 0063 **/ 0064 bool keyPressed(int keyQt); 0065 void grabKeys(); 0066 void ungrabKeys(); 0067 0068 class Private; 0069 QScopedPointer<Private> d; 0070 }; 0071 0072 class KGLOBALACCELPRIVATE_EXPORT KGlobalAccelInterfaceV2 : public KGlobalAccelInterface 0073 { 0074 Q_OBJECT 0075 public: 0076 KGlobalAccelInterfaceV2(QObject *parent); 0077 0078 protected: 0079 /** 0080 * Called by the implementation to inform us about key releases 0081 * 0082 * @param keyQt the key that was just released 0083 * 0084 * @returns @c true if the key was handled 0085 **/ 0086 bool keyReleased(int keyQt); 0087 }; 0088 0089 Q_DECLARE_INTERFACE(KGlobalAccelInterface, KGlobalAccelInterface_iid) 0090 0091 #endif