玉兔远程控制 0.1.0-bate5
载入中...
搜索中...
未找到
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
13class CDesktopShortcutManager : public QObject
14{
15 Q_OBJECT
16
17public:
18 explicit CDesktopShortcutManager(QObject *parent = nullptr);
20
21 // 主要功能
22 bool disableAllShortcuts();
23 bool restoreAllShortcuts();
24
25 // 状态查询
26 bool isDisabled() const { return m_shortcutsDisabled; }
27 QString desktopEnvironment() const { return m_desktopEnv; }
28
29 // 检测方法
30 static QString detectDesktopEnvironment();
31 static bool runCommand(const QString &program, const QStringList &args = QStringList(), int timeout = 5000);
32 static QString getCommandOutput(const QString &program, const QStringList &args);
33
34private:
35 QString m_desktopEnv;
36 bool m_shortcutsDisabled = false;
37
38 // 存储原始设置
39 QMap<QString, QVariant> m_gnomeSettings;
40 QMap<QString, QString> m_kdeSettings;
41 QString m_gnomeBackupPath;
42 QString m_kdeBackupPath;
43
44#if defined(Q_OS_LINUX)
45 // GNOME 方法
46 bool disableGNOMEShortcuts();
47 bool restoreGNOMEShortcuts();
48 bool resetGNOMEShortcuts();
49 void backupGNOMESettings();
50
51 // KDE 方法
52 bool disableKDEShortcuts();
53 bool restoreKDEShortcuts();
54 void backupKDESettings();
55#endif
56
57 // 通用方法
58 bool backupFile(const QString &sourcePath, const QString &backupPath);
59 bool restoreFile(const QString &backupPath, const QString &targetPath);
60};