File indexing completed on 2024-12-01 08:07:34
0001 /* 0002 SPDX-FileCopyrightText: 2019 Michail Vourlakos <mvourlakos@gmail.com> 0003 SPDX-License-Identifier: GPL-2.0-or-later 0004 */ 0005 0006 #ifndef SHORTCUTSTRACKER_H 0007 #define SHORTCUTSTRACKER_H 0008 0009 // Qt 0010 #include <QObject> 0011 0012 // KDE 0013 #include <KSharedConfig> 0014 0015 namespace Latte { 0016 namespace ShortcutsPart { 0017 0018 class ShortcutsTracker: public QObject { 0019 Q_OBJECT 0020 Q_PROPERTY(bool basedOnPositionEnabled READ basedOnPositionEnabled NOTIFY badgesForActivateChanged) 0021 Q_PROPERTY(QStringList badgesForActivate READ badgesForActivate NOTIFY badgesForActivateChanged) 0022 0023 public: 0024 ShortcutsTracker(QObject *parent); 0025 ~ShortcutsTracker() override; 0026 0027 void clearAllAppletShortcuts(); 0028 0029 bool basedOnPositionEnabled() const; 0030 0031 QStringList badgesForActivate() const; 0032 0033 QList<uint> appletsWithPlasmaShortcuts(); 0034 0035 public slots: 0036 Q_INVOKABLE QString appletShortcutBadge(int appletId); 0037 0038 signals: 0039 void badgesForActivateChanged(); 0040 0041 private slots: 0042 void shortcutsFileChanged(const QString &file); 0043 0044 private: 0045 void initGlobalShortcutsWatcher(); 0046 //! access user set global shortcuts for activate entries 0047 void parseGlobalShortcuts(); 0048 0049 QString shortcutToBadge(QStringList shortcutRecords); 0050 0051 private: 0052 bool m_basedOnPositionEnabled{false}; 0053 0054 QStringList m_badgesForActivate; 0055 0056 //! shortcuts assigned to applets through plasma infrastructure 0057 //! <applet id, shortcut> 0058 QHash<uint, QString> m_appletShortcuts; 0059 0060 KSharedConfig::Ptr m_shortcutsConfigPtr; 0061 }; 0062 0063 } 0064 } 0065 0066 #endif