File indexing completed on 2024-05-19 05:29:56
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 "kglobalacceld_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 KGLOBALACCELD_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 void setRegistry(GlobalShortcutsRegistry *registry); 0052 0053 protected: 0054 /** 0055 * called by the implementation to inform us about key presses 0056 * @returns @c true if the key was handled 0057 **/ 0058 bool keyPressed(int keyQt); 0059 void grabKeys(); 0060 void ungrabKeys(); 0061 /** 0062 * Called by the implementation to inform us about key releases 0063 * 0064 * @param keyQt the key that was just released 0065 * 0066 * @returns @c true if the key was handled 0067 **/ 0068 bool keyReleased(int keyQt); 0069 0070 class Private; 0071 QScopedPointer<Private> d; 0072 }; 0073 0074 Q_DECLARE_INTERFACE(KGlobalAccelInterface, KGlobalAccelInterface_iid) 0075 0076 #endif