File indexing completed on 2020-08-09 10:58:02

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 /**
0019  * Abstract interface for plugins to implement
0020  */
0021 class KGLOBALACCELPRIVATE_EXPORT KGlobalAccelInterface : public QObject
0022 {
0023     Q_OBJECT
0024 
0025 public:
0026     explicit KGlobalAccelInterface(QObject *parent);
0027     virtual ~KGlobalAccelInterface();
0028 
0029 public:
0030     /**
0031      * This function registers or unregisters a certain key for global capture,
0032      * depending on \b grab.
0033      *
0034      * Before destruction, every grabbed key will be released, so this
0035      * object does not need to do any tracking.
0036      *
0037      * \param key the Qt keycode to grab or release.
0038      * \param grab true to grab they key, false to release the key.
0039      *
0040      * \return true if successful, otherwise false.
0041      */
0042     virtual bool grabKey(int key, bool grab) = 0;
0043 
0044     /*
0045      * Enable/disable all shortcuts. There will not be any grabbed shortcuts at this point.
0046      */
0047     virtual void setEnabled(bool) = 0;
0048 
0049     /**
0050      * Allows implementing plugins to synchronize with the windowing system.
0051      * Default implementation does nothing.
0052      **/
0053     virtual void syncWindowingSystem();
0054 
0055     void setRegistry(GlobalShortcutsRegistry *registry);
0056 
0057 protected:
0058     /**
0059      * called by the implementation to inform us about key presses
0060      * @returns @c true if the key was handled
0061      **/
0062     bool keyPressed(int keyQt);
0063     void grabKeys();
0064     void ungrabKeys();
0065 
0066 private:
0067     class Private;
0068     QScopedPointer<Private> d;
0069 };
0070 
0071 Q_DECLARE_INTERFACE(KGlobalAccelInterface, "org.kde.kglobalaccel5.KGlobalAccelInterface")
0072 
0073 #endif