Rabbit Remote Control 0.1.0-bate10
Loading...
Searching...
No Matches
DesktopShortcuts.h
1// Author: Kang Lin <kl222@126.com>
2
3#pragma once
4
5#include <QObject>
6#include <QString>
7#include <QProcess>
8#include <QMap>
9#include <QSettings>
10#include <QFile>
11#include <QDir>
12
16class CDesktopShortcutManager : public QObject
17{
18 Q_OBJECT
19
20public:
21 explicit CDesktopShortcutManager(QObject *parent = nullptr);
23
24 // 主要功能
25 bool disableAllShortcuts();
26 bool restoreAllShortcuts();
27
28 // 状态查询
29 bool isDisabled() const { return m_shortcutsDisabled; }
30 QString desktopEnvironment() const { return m_desktopEnv; }
31
32 // 检测方法
33 static QString detectDesktopEnvironment();
34 static bool runCommand(const QString &program, const QStringList &args = QStringList(), int timeout = 5000);
35 static QString getCommandOutput(const QString &program, const QStringList &args);
36
37private:
38 QString m_desktopEnv;
39 bool m_shortcutsDisabled = false;
40
41 // 存储原始设置
42 QMap<QString, QMap<QString, QString> > m_gnomeSettings;
43 QMap<QString, QString> m_kdeSettings;
44 QMap<QString, QString> m_xfceSettings; // XFCE 快捷键配置备份
45 QString m_gnomeBackupPath;
46 QString m_kdeBackupPath;
47
48#if defined(Q_OS_LINUX)
49 // GNOME 方法
50 bool disableGNOMEShortcuts();
51 bool restoreGNOMEShortcuts();
52 bool resetGNOMEShortcuts();
53 int backupGNOMESettings();
54
55 // KDE 方法
56 bool disableKDEShortcuts();
57 bool restoreKDEShortcuts();
58 int backupKDESettings();
59
60 // XFCE 方法
61 bool disableXFCEShortcuts();
62 bool restoreXFCEShortcuts();
63 int backupXFCEShortcuts();
64
65#endif
66
67 // 通用方法
68 bool backupFile(const QString &sourcePath, const QString &backupPath);
69 bool restoreFile(const QString &backupPath, const QString &targetPath);
70};
Manage desktop shortcut keys.