donghualin 06bab9d640 fix: 修复蓝牙列表中设备顺序与控制中心不一致的问题
增加记录蓝牙设备顺序的列表,根据新增删除设备的顺序对设备进行排序

Log:
Influence: 打开快捷面板中的蓝牙列表,在多个设备同时存在的情况下,观察设备顺序是否和控制中心一致
Bug: https://pms.uniontech.com/bug-view-171513.html
Change-Id: I5c1017a30e0658022c61a053b9cd724312b37c40
2022-11-22 03:46:37 +00:00

68 lines
2.1 KiB
C++

/*
* Copyright (C) 2016 ~ 2018 Deepin Technology Co., Ltd.
*
* Author: zhaolong <zhaolong@uniontech.com>
*
* Maintainer: zhaolong <zhaolong@uniontech.com>
*
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ADAPTERSMANAGER_H
#define ADAPTERSMANAGER_H
#include "org_deepin_daemon_bluetooth.h"
using DBusBluetooth = org::deepin::daemon::Bluetooth1;
class Adapter;
class Device;
class AdaptersManager : public QObject
{
Q_OBJECT
public:
explicit AdaptersManager(QObject *parent = nullptr);
void setAdapterPowered(const Adapter *adapter, const bool &powered);
void connectDevice(const Device *device, Adapter *adapter);
int adaptersCount();
void adapterRefresh(const Adapter *adapter);
QList<const Adapter *> adapters();
signals:
void adapterIncreased(Adapter *adapter);
void adapterDecreased(Adapter *adapter);
private slots:
void onAdapterPropertiesChanged(const QString &json);
void onDevicePropertiesChanged(const QString &json);
void onAddAdapter(const QString &json);
void onRemoveAdapter(const QString &json);
void onAddDevice(const QString &json);
void onRemoveDevice(const QString &json);
private:
void adapterAdd(Adapter *adapter, const QJsonObject &adpterObj);
void inflateAdapter(Adapter *adapter, const QJsonObject &adapterObj);
private:
DBusBluetooth *m_bluetoothInter;
QMap<QString, const Adapter *> m_adapters;
QStringList m_adapterIds; // 用于记录蓝牙适配器的排序
};
#endif // ADAPTERSMANAGER_H