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

0001 /*
0002     SPDX-FileCopyrightText: 2008 Michael Jansen <kde@michael-jansen.biz>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #ifndef GLOBALSHORTCUTCONTEXT_H
0008 #define GLOBALSHORTCUTCONTEXT_H
0009 
0010 #include "kglobalshortcutinfo.h"
0011 
0012 #include <QString>
0013 #include <QHash>
0014 
0015 namespace KdeDGlobalAccel {
0016     class Component;
0017 }
0018 
0019 class GlobalShortcut;
0020 
0021 /**
0022  * @author Michael Jansen <kde@michael-jansen.biz>
0023  */
0024 class GlobalShortcutContext
0025     {
0026 public:
0027 
0028     /**
0029      * Default constructor
0030      */
0031     GlobalShortcutContext(
0032             const QString &uniqueName,
0033             const QString &friendlyName,
0034             KdeDGlobalAccel::Component *component );
0035 
0036     /**
0037      * Destructor
0038      */
0039     virtual ~GlobalShortcutContext();
0040 
0041     //! Adds @p shortcut to the context
0042     void addShortcut(GlobalShortcut *shortcut);
0043 
0044     //! Return KGlobalShortcutInfos for all shortcuts
0045     QList<KGlobalShortcutInfo> allShortcutInfos() const;
0046 
0047     /**
0048      * Get the name for the context
0049      */
0050     QString uniqueName() const;
0051     QString friendlyName() const;
0052 
0053     KdeDGlobalAccel::Component *component();
0054     KdeDGlobalAccel::Component const *component() const;
0055 
0056     //! Get shortcut for @p key or nullptr
0057     GlobalShortcut *getShortcutByKey(int key) const;
0058 
0059     //! Remove @p shortcut from the context. The shortcut is not deleted.
0060     GlobalShortcut *takeShortcut(GlobalShortcut *shortcut);
0061 
0062 private:
0063 
0064     friend class KdeDGlobalAccel::Component;
0065 
0066     //! The unique name for this context
0067     QString _uniqueName;
0068 
0069     //! The unique name for this context
0070     QString _friendlyName;
0071 
0072     //! The component the context belongs too
0073     KdeDGlobalAccel::Component *_component;
0074 
0075     //! The actions associated with this context
0076     QHash<QString, GlobalShortcut*> _actions;
0077 };
0078 
0079 
0080 #endif /* #ifndef GLOBALSHORTCUTCONTEXT_H */