File indexing completed on 2019-01-15 11:47:11

0001 #ifndef GLOBALSHORTCUTCONTEXT_H
0002 #define GLOBALSHORTCUTCONTEXT_H
0003 /* Copyright (C) 2008 Michael Jansen <kde@michael-jansen.biz>
0004 
0005    This library is free software; you can redistribute it and/or
0006    modify it under the terms of the GNU Library General Public
0007    License as published by the Free Software Foundation; either
0008    version 2 of the License, or (at your option) any later version.
0009 
0010    This library is distributed in the hope that it will be useful,
0011    but WITHOUT ANY WARRANTY; without even the implied warranty of
0012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0013    Library General Public License for more details.
0014 
0015    You should have received a copy of the GNU Library General Public License
0016    along with this library; see the file COPYING.LIB.  If not, write to
0017    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0018    Boston, MA 02110-1301, USA.
0019 */
0020 
0021 #include "kglobalshortcutinfo.h"
0022 
0023 #include <QString>
0024 #include <QHash>
0025 
0026 namespace KdeDGlobalAccel {
0027     class Component;
0028 }
0029 
0030 class GlobalShortcut;
0031 
0032 /**
0033  * @author Michael Jansen <kde@michael-jansen.biz>
0034  */
0035 class GlobalShortcutContext
0036     {
0037 public:
0038 
0039     /**
0040      * Default constructor
0041      */
0042     GlobalShortcutContext(
0043             const QString &uniqueName,
0044             const QString &friendlyName,
0045             KdeDGlobalAccel::Component *component );
0046 
0047     /**
0048      * Destructor
0049      */
0050     virtual ~GlobalShortcutContext();
0051 
0052     //! Adds @p shortcut to the context
0053     void addShortcut(GlobalShortcut *shortcut);
0054 
0055     //! Return KGlobalShortcutInfos for all shortcuts
0056     QList<KGlobalShortcutInfo> allShortcutInfos() const;
0057 
0058     /**
0059      * Get the name for the context
0060      */
0061     QString uniqueName() const;
0062     QString friendlyName() const;
0063 
0064     KdeDGlobalAccel::Component *component();
0065     KdeDGlobalAccel::Component const *component() const;
0066 
0067     //! Get shortcut for @p key or nullptr
0068     GlobalShortcut *getShortcutByKey(int key) const;
0069 
0070     //! Remove @p shortcut from the context. The shortcut is not deleted.
0071     GlobalShortcut *takeShortcut(GlobalShortcut *shortcut);
0072 
0073 private:
0074 
0075     friend class KdeDGlobalAccel::Component;
0076 
0077     //! The unique name for this context
0078     QString _uniqueName;
0079 
0080     //! The unique name for this context
0081     QString _friendlyName;
0082 
0083     //! The component the context belongs too
0084     KdeDGlobalAccel::Component *_component;
0085 
0086     //! The actions associated with this context
0087     QHash<QString, GlobalShortcut*> _actions;
0088 };
0089 
0090 
0091 #endif /* #ifndef GLOBALSHORTCUTCONTEXT_H */