DtkSystemSettings  1.0.3
dtk library for systemsettings.
drfmanager.h
浏览该文件的文档.
1// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
2//
3// SPDX-License-Identifier: LGPL-3.0-or-later
4#ifndef DRFMANAGER_H
5#define DRFMANAGER_H
6
7#include "dtkrfmanager_global.h"
8#include <QObject>
9#include <dexpected.h>
10#include "dtksystemsettings_global.h"
11
12DRFMGR_BEGIN_NAMESPACE
13using DCORE_NAMESPACE::DExpected;
14class DRfmanagerPrivate;
15class LIBDTKSYSTEMSETTINGSSHARED_EXPORT DRfmanager : public QObject
16{
17 Q_OBJECT
18 Q_PROPERTY(bool bluetoothBlocked READ isBluetoothBlocked WRITE blockBluetooth NOTIFY bluetoothBlockedChanged)
19 Q_PROPERTY(bool wifiBlocked READ isWifiBlocked WRITE blockWifi NOTIFY wifiBlockedChanged)
20 Q_PROPERTY(int count READ count NOTIFY countChanged)
21 Q_PROPERTY(bool allBlocked READ isAllBlocked WRITE blockAll NOTIFY allBlockedChanged)
22
23public:
26 ADD = 0,
27 DEL,
28 CHANGE,
29 CHANGE_ALL,
32 };
33 Q_ENUM(RfOperation)
34
35
36 enum RfType {
37 ALL = 0,
38 WLAN,
39 WIFI = WLAN,
40 BLUETOOTH,
41 UWB,
42 WIMAX,
43 WWAN,
44 GPS,
45 FM,
46 NFC,
48 NUM_TYPES,
49 };
50 Q_ENUM(RfType)
51
52
53 struct RfDevice
54 {
55 quint32 idx;
56 RfType type;
57 QString name;
58 bool softBlocked;
59 bool hardBlocked;
60 };
61
62 explicit DRfmanager(QObject *parent = nullptr);
63 virtual ~DRfmanager() override;
64
65 bool block(RfType type, bool blocked = true);
66 bool block(quint32 id, bool blocked = true);
67
68 bool isBluetoothBlocked() const;
69 bool isWifiBlocked() const;
70 bool isAllBlocked() const;
71 int count() const;
72 QList<RfDevice> deviceList() const;
73
74public slots:
75 DExpected<bool> blockBluetooth(bool bluetoothBlocked = true);
76 DExpected<bool> blockWifi(bool wifiBlocked = true);
77 DExpected<bool> blockAll(bool blockAll = true);
78
79signals:
80 void bluetoothBlockedChanged(bool bluetoothBlocked);
81 void wifiBlockedChanged(bool wifiBlocked);
82 void countChanged(int count);
83 void allBlockedChanged(bool blockAll);
84 void blockedChanged(quint32 idx);
85
86private:
87 QScopedPointer<DRfmanagerPrivate> d_dptr;
88 Q_DECLARE_PRIVATE_D(d_dptr, DRfmanager)
89};
90
91#if !defined(QT_NO_DEBUG_STREAM)
92Q_CORE_EXPORT QDebug operator<<(QDebug, const DRfmanager::RfDevice &);
93#endif
94
95DRFMGR_END_NAMESPACE
96#endif // DRFMANAGER_H
无线设备管理类
Definition: drfmanager.h:16
bool isWifiBlocked() const
无线网络设备是否禁用
bool isAllBlocked() const
支持的设备是否都被禁用
bool isBluetoothBlocked() const
蓝牙设备是否禁用
DExpected< bool > blockBluetooth(bool bluetoothBlocked=true)
禁用或者启用蓝牙设备
bool block(RfType type, bool blocked=true)
禁用或者启用类型为 type 的无线设备
void bluetoothBlockedChanged(bool bluetoothBlocked)
蓝牙设备禁用或者启用状态发生变化信号
DExpected< bool > blockAll(bool blockAll=true)
禁用或者启用所有无线设备
QList< RfDevice > deviceList() const
获取支持的设备列表
void blockedChanged(quint32 idx)
设备禁用或者启用状态发生变化信号
RfOperation
<
Definition: drfmanager.h:25
void countChanged(int count)
无线设备拔插时即设备数量变化的信号
bool block(quint32 id, bool blocked=true)
禁用或者启用设备编号为 id 的无线设备
void allBlockedChanged(bool blockAll)
支持的所有社别设备全部禁用或者非全部状态发生变化信号
DExpected< bool > blockWifi(bool wifiBlocked=true)
禁用或者启用无线网络设备
void wifiBlockedChanged(bool wifiBlocked)
无线网络设备禁用或者启用状态发生变化信号
virtual ~DRfmanager() override
析构函数
int count() const
获取支持的设备数量
DRfmanager(QObject *parent=nullptr)
构造函数
Definition: drfmanager.h:54