File indexing completed on 2024-04-21 16:12:52

0001 /*
0002     SPDX-License-Identifier: GPL-2.0-only
0003     SPDX-FileCopyrightText: 1999-2001 Lubos Lunak <l.lunak@kde.org>
0004  */
0005 
0006 #ifndef _KHOTKEYS_KDED_H_
0007 #define _KHOTKEYS_KDED_H_
0008 
0009 #include "settings.h"
0010 #include <kdedmodule.h>
0011 
0012 #include <QKeySequence>
0013 #include <QObject>
0014 #include <QtDBus>
0015 
0016 #include <KService>
0017 
0018 namespace KHotKeys
0019 {
0020 class ActionDataGroup;
0021 class SimpleActionData;
0022 }
0023 
0024 class KHotKeysModule : public KDEDModule
0025 {
0026     Q_OBJECT
0027     Q_CLASSINFO("D-Bus Interface", "org.kde.khotkeys")
0028 
0029 public Q_SLOTS:
0030 
0031     Q_SCRIPTABLE Q_NOREPLY void reread_configuration();
0032 
0033     Q_SCRIPTABLE Q_NOREPLY void quit();
0034 
0035     /**
0036      * Register an shortcut for service @serviceStorageId with the key
0037      * sequence @seq.
0038      *
0039      * @param serviceStorageId the KService::storageId of the service
0040      * @param sequence         the key sequence to use
0041      *
0042      * @returns @c true if the key sequence was successfully set, @c if
0043      * the sequence is not available.
0044      */
0045     Q_SCRIPTABLE QString register_menuentry_shortcut(const QString &storageId, const QString &sequence);
0046 
0047     /**
0048      * Get the currently active shortcut for service @p serviceStorageId.
0049      *
0050      * @param serviceStorageId the KService::storageId of the service
0051      *
0052      * @returns the active global shortcuts for that service
0053      */
0054     Q_SCRIPTABLE QString get_menuentry_shortcut(const QString &storageId);
0055 
0056     /**
0057      * declare daemon settings outdated, do not write back until re-read has been triggered
0058      */
0059     Q_SCRIPTABLE Q_NOREPLY void declareConfigOutdated();
0060 
0061 private Q_SLOTS:
0062 
0063     //! Save
0064     void scheduleSave();
0065     void save();
0066 
0067     //! Initialize the module. Delayed initialization.
0068     void initialize();
0069 
0070 public:
0071     KHotKeysModule(QObject *parent, const QList<QVariant> &);
0072     ~KHotKeysModule() override;
0073 
0074 private:
0075     //! The action list from _settings for convenience
0076     KHotKeys::ActionDataGroup *actions_root;
0077 
0078     //! The current settings
0079     bool _settingsDirty;
0080     KHotKeys::Settings _settings;
0081 
0082     //! Is the module initialized
0083     bool _initialized;
0084 
0085     /**
0086      * @name Some method in need for a better home
0087      */
0088     //@{
0089     //! Get the group for the menuentries. Will create it if needed
0090     KHotKeys::ActionDataGroup *menuentries_group();
0091 
0092     //! Find a menuentry_action for the service with @storageId in group @group
0093     KHotKeys::SimpleActionData *menuentry_action(const QString &storageId);
0094     //@}
0095 };
0096 
0097 //***************************************************************************
0098 // Inline
0099 //***************************************************************************
0100 
0101 #endif