mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-04 17:33:05 +00:00
feat: ConnectDevice蓝牙接口参数改变
新增蓝牙扫描结束3分钟后,点击列表项设备连接,连接设备接口新增蓝牙设备参数 Log: ConnectDeviece蓝牙接口参数改变 Task: https://pms.uniontech.com/zentao/task-view-33527.html Change-Id: Ia4d988d31f04307a4e67f95e49f39947cb59805d Reviewed-on: http://gerrit.uniontech.com/c/dde-dock/+/2753 Reviewed-by: <mailman@uniontech.com> Reviewed-by: wangwei <wangwei@uniontech.com> Reviewed-by: fanpengcheng <fanpengcheng@uniontech.com> Tested-by: <mailman@uniontech.com>
This commit is contained in:
parent
7c6cdc6b85
commit
b8d7f24ebe
@ -299,7 +299,9 @@ void AdapterItem::createDeviceItem(Device *device)
|
|||||||
connect(device, &Device::stateChanged, deviceItem, &DeviceItem::changeState);
|
connect(device, &Device::stateChanged, deviceItem, &DeviceItem::changeState);
|
||||||
connect(device, &Device::stateChanged, this, &AdapterItem::deviceChangeState);
|
connect(device, &Device::stateChanged, this, &AdapterItem::deviceChangeState);
|
||||||
connect(device, &Device::rssiChanged, this, &AdapterItem::deviceRssiChanged);
|
connect(device, &Device::rssiChanged, this, &AdapterItem::deviceRssiChanged);
|
||||||
connect(deviceItem, &DeviceItem::clicked, m_adaptersManager, &AdaptersManager::connectDevice);
|
connect(deviceItem, &DeviceItem::clicked, m_adaptersManager, [this](Device *device){
|
||||||
|
m_adaptersManager->connectDevice(device, m_adapter);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void AdapterItem::updateView()
|
void AdapterItem::updateView()
|
||||||
|
@ -134,13 +134,13 @@ void AdaptersManager::setAdapterPowered(const Adapter *adapter, const bool &powe
|
|||||||
// }
|
// }
|
||||||
//}
|
//}
|
||||||
|
|
||||||
void AdaptersManager::connectDevice(Device *device)
|
void AdaptersManager::connectDevice(Device *device, Adapter *adapter)
|
||||||
{
|
{
|
||||||
if (device) {
|
if (device) {
|
||||||
QDBusObjectPath path(device->id());
|
QDBusObjectPath path(device->id());
|
||||||
switch (device->state()) {
|
switch (device->state()) {
|
||||||
case Device::StateUnavailable: {
|
case Device::StateUnavailable: {
|
||||||
m_bluetoothInter->ConnectDevice(path);
|
m_bluetoothInter->ConnectDevice(path, QDBusObjectPath(adapter->id()));
|
||||||
qDebug() << "connect to device: " << device->name();
|
qDebug() << "connect to device: " << device->name();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -39,7 +39,7 @@ public:
|
|||||||
|
|
||||||
void setAdapterPowered(const Adapter *adapter, const bool &powered);
|
void setAdapterPowered(const Adapter *adapter, const bool &powered);
|
||||||
// void connectAllPairedDevice(const Adapter *adapter);
|
// void connectAllPairedDevice(const Adapter *adapter);
|
||||||
void connectDevice(Device *deviceId);
|
void connectDevice(Device *device, Adapter *adapter);
|
||||||
bool defaultAdapterInitPowerState();
|
bool defaultAdapterInitPowerState();
|
||||||
int adaptersCount();
|
int adaptersCount();
|
||||||
void adapterRefresh(const Adapter *adapter);
|
void adapterRefresh(const Adapter *adapter);
|
||||||
|
@ -22,6 +22,8 @@
|
|||||||
|
|
||||||
#include "device.h"
|
#include "device.h"
|
||||||
|
|
||||||
|
#include <QDateTime>
|
||||||
|
|
||||||
QMap<QString,QString> Device::deviceType2Icon = {
|
QMap<QString,QString> Device::deviceType2Icon = {
|
||||||
{"unknow","other"},
|
{"unknow","other"},
|
||||||
{"computer","pc"},
|
{"computer","pc"},
|
||||||
@ -50,6 +52,7 @@ Device::Device(QObject *parent)
|
|||||||
, m_state(StateUnavailable)
|
, m_state(StateUnavailable)
|
||||||
, m_connectState(false)
|
, m_connectState(false)
|
||||||
{
|
{
|
||||||
|
m_time = static_cast<int>(QDateTime::currentDateTime().toTime_t());
|
||||||
}
|
}
|
||||||
|
|
||||||
Device::~Device()
|
Device::~Device()
|
||||||
@ -57,6 +60,11 @@ Device::~Device()
|
|||||||
emit stateChanged(StateUnavailable);
|
emit stateChanged(StateUnavailable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Device::updateDeviceTime()
|
||||||
|
{
|
||||||
|
m_time = static_cast<int>(QDateTime::currentDateTime().toTime_t());
|
||||||
|
}
|
||||||
|
|
||||||
void Device::setId(const QString &id)
|
void Device::setId(const QString &id)
|
||||||
{
|
{
|
||||||
m_id = id;
|
m_id = id;
|
||||||
|
@ -75,6 +75,9 @@ public:
|
|||||||
inline QString deviceType() const { return m_deviceType; }
|
inline QString deviceType() const { return m_deviceType; }
|
||||||
void setDeviceType(const QString &deviceType);
|
void setDeviceType(const QString &deviceType);
|
||||||
|
|
||||||
|
inline int deviceTime() const { return m_time; }
|
||||||
|
void updateDeviceTime();
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void nameChanged(const QString &name) const;
|
void nameChanged(const QString &name) const;
|
||||||
void pairedChanged(const bool paired) const;
|
void pairedChanged(const bool paired) const;
|
||||||
@ -95,6 +98,7 @@ private:
|
|||||||
bool m_connectState;
|
bool m_connectState;
|
||||||
QString m_adapterId;
|
QString m_adapterId;
|
||||||
QString m_deviceType;
|
QString m_deviceType;
|
||||||
|
int m_time;
|
||||||
};
|
};
|
||||||
|
|
||||||
QDebug &operator<<(QDebug &stream, const Device *device);
|
QDebug &operator<<(QDebug &stream, const Device *device);
|
||||||
|
@ -109,6 +109,7 @@ DeviceItem::DeviceItem(Device *d, QWidget *parent)
|
|||||||
|
|
||||||
bool DeviceItem::operator <(const DeviceItem &item)
|
bool DeviceItem::operator <(const DeviceItem &item)
|
||||||
{
|
{
|
||||||
|
// return this->device()->deviceTime() < item.device()->deviceTime();
|
||||||
return this->device()->rssi() < item.device()->rssi();
|
return this->device()->rssi() < item.device()->rssi();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -119,6 +120,7 @@ void DeviceItem::setTitle(const QString &name)
|
|||||||
|
|
||||||
void DeviceItem::mousePressEvent(QMouseEvent *event)
|
void DeviceItem::mousePressEvent(QMouseEvent *event)
|
||||||
{
|
{
|
||||||
|
m_device->updateDeviceTime();
|
||||||
emit clicked(m_device);
|
emit clicked(m_device);
|
||||||
QWidget::mousePressEvent(event);
|
QWidget::mousePressEvent(event);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user