/* This file is part of the KDE libraries SPDX-FileCopyrightText: 2001, 2002 Ellis Whitehead SPDX-FileCopyrightText: 2006 Hamish Rodda SPDX-FileCopyrightText: 2007 Andreas Hartmetz SPDX-License-Identifier: LGPL-2.0-or-later */ #ifndef KGLOBALACCEL_P_H #define KGLOBALACCEL_P_H #include #include #include #include #include "kglobalaccel.h" #include "kglobalaccel_component_interface.h" #include "kglobalaccel_interface.h" enum SetShortcutFlag { SetPresent = 2, NoAutoloading = 4, IsDefault = 8, }; class KGlobalAccelPrivate { public: enum ShortcutType { /// The shortcut will immediately become active but may be reset to "default". ActiveShortcut = 0x1, /// The shortcut is a default shortcut - it becomes active when somebody decides to /// reset shortcuts to default. DefaultShortcut = 0x2, }; Q_DECLARE_FLAGS(ShortcutTypes, ShortcutType) enum Removal { SetInactive = 0, ///< Forget the action in this class and mark it as not present in the KDED module UnRegister, ///< Remove any trace of the action in this class and in the KDED module }; KGlobalAccelPrivate(KGlobalAccel *); /// Propagate any shortcut changes to the KDED module that does the bookkeeping /// and the key grabbing. ///@todo KF6 void updateGlobalShortcut(/*const would be better*/ QAction *action, KGlobalAccelPrivate::ShortcutTypes actionFlags, KGlobalAccel::GlobalShortcutLoading globalFlags); /// Register the action in this class and in the KDED module bool doRegister(QAction *action); //"register" is a C keyword :p /// cf. the RemoveAction enum void remove(QAction *action, Removal r); //"private" helpers QString componentUniqueForAction(const QAction *action); QString componentFriendlyForAction(const QAction *action); QStringList makeActionId(const QAction *action); QList intListFromShortcut(const QList &cut); QList shortcutFromIntList(const QList &list); void cleanup(); // private slot implementations QAction *findAction(const QString &, const QString &); void invokeAction(const QString &, const QString &, qlonglong); void invokeDeactivate(const QString &, const QString &); void shortcutGotChanged(const QStringList &, const QList &); void shortcutsChanged(const QStringList &, const QList &); void serviceOwnerChanged(const QString &name, const QString &oldOwner, const QString &newOwner); void reRegisterAll(); // for all actions with (isEnabled() && globalShortcutAllowed()) QMultiHash nameToAction; QSet actions; org::kde::KGlobalAccel *iface(); //! Get the component @p componentUnique. If @p remember is true the instance is cached and we //! subscribe to signals about changes to the component. org::kde::kglobalaccel::Component *getComponent(const QString &componentUnique, bool remember); //! Our owner KGlobalAccel *q; //! The components the application is using QHash components; QMap> actionDefaultShortcuts; QMap> actionShortcuts; bool setShortcutWithDefault(QAction *action, const QList &shortcut, KGlobalAccel::GlobalShortcutLoading loadFlag); void unregister(const QStringList &actionId); void setInactive(const QStringList &actionId); private: org::kde::KGlobalAccel *m_iface = nullptr; QPointer m_lastActivatedAction; QDBusServiceWatcher *m_watcher; }; Q_DECLARE_OPERATORS_FOR_FLAGS(KGlobalAccelPrivate::ShortcutTypes) #endif