fix(ukui-bluetooth): 27534 【好用工程】【攻关】将蓝牙文件接受位置,修改存放至下载中进行统一管理
Description: none Log: none
This commit is contained in:
parent
1442b1af12
commit
19dd35eb49
|
@ -6,6 +6,7 @@
|
|||
<policy user="root">
|
||||
<allow own="com.ukui.bluetooth"/>
|
||||
<allow send_destination="com.ukui.bluetooth"/>
|
||||
<allow send_interface="com.ukui.bluetooth"/>
|
||||
</policy>
|
||||
|
||||
<!-- Allow anyone to invoke methods on the interfaces -->
|
||||
|
|
|
@ -19,8 +19,12 @@ Build-Depends: debhelper (>= 9),
|
|||
libxrandr-dev,
|
||||
libpeony-dev,
|
||||
libkysdk-sysinfo-dev,
|
||||
# libkysec-dev
|
||||
# libkysdk-diagnostics-dev
|
||||
qt5-qmake,
|
||||
qtbase5-dev,
|
||||
qtbase5-dev-tools,
|
||||
qtchooser,
|
||||
qtscript5-dev,
|
||||
qttools5-dev-tools,
|
||||
Standards-Version: 4.4.1
|
||||
Homepage: https://github.com/supreme886/ukui-bluetooth
|
||||
|
||||
|
|
|
@ -118,6 +118,19 @@ QStringList ApplicationMng::getRegisterClient()
|
|||
return apps;
|
||||
}
|
||||
|
||||
QString ApplicationMng::getUserDbusid(QString user, int type)
|
||||
{
|
||||
for(auto item : m_apps.toStdMap())
|
||||
{
|
||||
//控制面板
|
||||
if(item.second->type() == type && item.second->username() == user)
|
||||
{
|
||||
return item.second->dbusid();
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
void ApplicationMng::update()
|
||||
{
|
||||
KylinAdapterPtr ptr = ADAPTERMNG::getInstance()->getDefaultAdapter();
|
||||
|
|
|
@ -63,6 +63,8 @@ public:
|
|||
|
||||
QStringList getRegisterClient(void);
|
||||
//int unknownDbusid(QString, );
|
||||
|
||||
QString getUserDbusid(QString, int);
|
||||
private:
|
||||
void update(void);
|
||||
|
||||
|
|
|
@ -279,13 +279,22 @@ int KylinDevice::reset()
|
|||
return 0;
|
||||
}
|
||||
|
||||
void KylinDevice::setSendfileStatus()
|
||||
void KylinDevice::setSendfileStatus(bool status /*= true*/)
|
||||
{
|
||||
if(!m_connect)
|
||||
{
|
||||
m_connect = true;
|
||||
m_attr_send[DeviceAttr(enum_device_attr_Connected)] = m_connect;
|
||||
this->__send_attr();
|
||||
KyInfo() << "connect: " << m_connect << " devconnect: " << m_device->isConnected() << " stasus: " << status;
|
||||
if (status) {
|
||||
if (!m_connect) {
|
||||
m_connect = true;
|
||||
m_attr_send[DeviceAttr(enum_device_attr_Connected)] = m_connect;
|
||||
this->__send_attr();
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (m_connect != m_device->isConnected()) {
|
||||
m_connect = m_device->isConnected();
|
||||
m_attr_send[DeviceAttr(enum_device_attr_Connected)] = m_connect;
|
||||
this->__send_attr();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -395,10 +404,20 @@ void KylinDevice::batteryChanged(BluezQt::BatteryPtr battery)
|
|||
m_need_clean = 0;
|
||||
if(battery)
|
||||
{
|
||||
connect(battery.data(), &BluezQt::Battery::percentageChanged,
|
||||
this, &KylinDevice::percentageChanged, Qt::UniqueConnection);
|
||||
m_attr_send[DeviceAttr(enum_device_attr_Battery)] = battery->percentage();
|
||||
this->__send_attr();
|
||||
}
|
||||
}
|
||||
|
||||
void KylinDevice::percentageChanged(int percentage)
|
||||
{
|
||||
m_need_clean = 0;
|
||||
m_attr_send[DeviceAttr(enum_device_attr_Battery)] = percentage;
|
||||
this->__send_attr();
|
||||
}
|
||||
|
||||
#endif
|
||||
void KylinDevice::typeChanged(BluezQt::Device::Type Type)
|
||||
{
|
||||
|
|
|
@ -67,7 +67,7 @@ public:
|
|||
|
||||
bool ispaired(void) { return m_paired; }
|
||||
|
||||
void setSendfileStatus(void);
|
||||
void setSendfileStatus(bool status = true);
|
||||
protected slots:
|
||||
void nameChanged(const QString &name);
|
||||
void pairedChanged(bool paired);
|
||||
|
@ -77,11 +77,11 @@ protected slots:
|
|||
void connectedChanged(bool connected);
|
||||
#ifdef BATTERY
|
||||
void batteryChanged(BluezQt::BatteryPtr battery);
|
||||
void percentageChanged(int percentage);
|
||||
#endif
|
||||
void typeChanged(BluezQt::Device::Type type);
|
||||
void uuidsChanged(const QStringList &uuids);
|
||||
void mediaTransportChanged(BluezQt::MediaTransportPtr mediaTransport);
|
||||
|
||||
void mediaTransportChanged(BluezQt::MediaTransportPtr mediaTransport);
|
||||
//////////////////////////////////////////////
|
||||
void pairfinished(BluezQt::PendingCall *call);
|
||||
void connectfinished(BluezQt::PendingCall *call);
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include "sessiondbusregister.h"
|
||||
#include "device.h"
|
||||
#include "config.h"
|
||||
#include "app.h"
|
||||
|
||||
#include <file-utils.h>
|
||||
|
||||
|
@ -87,6 +88,9 @@ KylinFileSess::~KylinFileSess()
|
|||
m_attr[FileStatusAttr(enum_filestatus_status)] = 0xff;
|
||||
m_attr[FileStatusAttr(enum_filestatus_transportType)] = m_type;
|
||||
this->__send_statuschanged();
|
||||
|
||||
//设置文件传输状态
|
||||
this->setSendfileStatus(false);
|
||||
}
|
||||
|
||||
void KylinFileSess::receiveUpdate(BluezQt::ObexTransferPtr transfer, BluezQt::ObexSessionPtr session, const BluezQt::Request<QString> &request)
|
||||
|
@ -161,7 +165,6 @@ void KylinFileSess::CreateSessStart(BluezQt::PendingCall *call)
|
|||
|
||||
m_attr[FileStatusAttr(enum_filestatus_dev)] = m_dest;
|
||||
m_attr[FileStatusAttr(enum_filestatus_fileFailedDisc)] = call->errorText();
|
||||
this->__send_statuschanged();
|
||||
|
||||
FILESESSMNG::getInstance()->removeSession(m_object_path);
|
||||
return;
|
||||
|
@ -174,6 +177,7 @@ void KylinFileSess::CreateSessStart(BluezQt::PendingCall *call)
|
|||
return;
|
||||
}
|
||||
|
||||
this->__send_statuschanged();
|
||||
m_opp = new BluezQt::ObexObjectPush(m_object_path);
|
||||
this->sendfile();
|
||||
}
|
||||
|
@ -317,24 +321,41 @@ int KylinFileSess::sendfile()
|
|||
QString KylinFileSess::getProperFilePath(QString dir, QString filename)
|
||||
{
|
||||
QString dest;
|
||||
if(dest.isEmpty())
|
||||
QString dbusid = APPMNG::getInstance()->getUserDbusid(m_user, enum_app_type_bluetooth_tray);
|
||||
if(!dbusid.isEmpty())
|
||||
{
|
||||
dest = m_savePathdir + filename;
|
||||
}
|
||||
else
|
||||
{
|
||||
dest = dir + filename;
|
||||
QDBusInterface iface(dbusid, "/", "com.ukui.bluetooth", QDBusConnection::systemBus());
|
||||
QDBusPendingCall pcall = iface.asyncCall("getProperFilePath", m_user, filename);
|
||||
pcall.waitForFinished();
|
||||
QDBusMessage res = pcall.reply();
|
||||
if(res.type() == QDBusMessage::ReplyMessage)
|
||||
{
|
||||
KyInfo() << res;
|
||||
if(res.arguments().size() > 0)
|
||||
{
|
||||
dest = res.arguments().takeFirst().toString();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
KyWarning()<< res.errorName() << ": "<< res.errorMessage();
|
||||
}
|
||||
}
|
||||
|
||||
KyDebug() << dest;
|
||||
while (QFile::exists(dest))
|
||||
if(dest.isEmpty())
|
||||
{
|
||||
QStringList newUrl = dest.split("/");
|
||||
newUrl.pop_back();
|
||||
newUrl.append(Peony::FileUtils::handleDuplicateName(Peony::FileUtils::urlDecode(dest)));
|
||||
dest = newUrl.join("/");
|
||||
KyDebug() << dest << newUrl;
|
||||
dest = "/home/" + m_user + "/" + filename;
|
||||
KyDebug() << dest;
|
||||
while (QFile::exists(dest))
|
||||
{
|
||||
QStringList newUrl = dest.split("/");
|
||||
newUrl.pop_back();
|
||||
newUrl.append(Peony::FileUtils::handleDuplicateName(Peony::FileUtils::urlDecode(dest)));
|
||||
dest = newUrl.join("/");
|
||||
KyDebug() << dest << newUrl;
|
||||
}
|
||||
}
|
||||
|
||||
return dest;
|
||||
}
|
||||
|
||||
|
@ -351,10 +372,10 @@ int KylinFileSess::movefile(QString filename, QString & dest)
|
|||
if(flag)
|
||||
{
|
||||
QString cmd;
|
||||
cmd = "chgrp " + m_user + " \"" + dest + "\"";
|
||||
cmd = "chgrp " + m_user + " \'" + dest + "\'";
|
||||
KyInfo() << cmd;
|
||||
system(cmd.toStdString().c_str());
|
||||
cmd = "chown " + m_user + " \"" + dest + "\"";;
|
||||
cmd = "chown " + m_user + " \'" + dest + "\'";;
|
||||
KyInfo() << cmd;
|
||||
system(cmd.toStdString().c_str());
|
||||
}
|
||||
|
@ -378,7 +399,7 @@ void KylinFileSess::timerEvent(QTimerEvent *event)
|
|||
}
|
||||
}
|
||||
|
||||
void KylinFileSess::setSendfileStatus()
|
||||
void KylinFileSess::setSendfileStatus(bool status /*= true*/)
|
||||
{
|
||||
KylinAdapterPtr ptr = ADAPTERMNG::getInstance()->getDefaultAdapter();
|
||||
KylinDevicePtr d = nullptr;
|
||||
|
@ -389,7 +410,7 @@ void KylinFileSess::setSendfileStatus()
|
|||
|
||||
if(d)
|
||||
{
|
||||
d->setSendfileStatus();
|
||||
d->setSendfileStatus(status);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -88,7 +88,7 @@ protected:
|
|||
|
||||
virtual void timerEvent( QTimerEvent *event);
|
||||
|
||||
void setSendfileStatus(void);
|
||||
void setSendfileStatus(bool status = true);
|
||||
private:
|
||||
int send_statuschanged(void);
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ include(../environment.pri)
|
|||
|
||||
QT += core gui dbus
|
||||
|
||||
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
||||
#greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
||||
|
||||
CONFIG += c++11 \
|
||||
link_pkgconfig
|
||||
|
@ -89,4 +89,4 @@ TRANSLATIONS += ../translations/ukui-bluetooth_zh_CN.ts
|
|||
|
||||
OBJECTS_DIR = ./obj/
|
||||
MOC_DIR = ./moc/
|
||||
CONFIG+=force_debug_info
|
||||
#CONFIG+=force_debug_info
|
||||
|
|
|
@ -31,7 +31,9 @@ BluetoothBottomWindow::BluetoothBottomWindow(BlueToothDBusService * btServer,QWi
|
|||
|
||||
InitNormalWidgetBottom();
|
||||
InitConnectionData();
|
||||
AddBluetoothDevices();
|
||||
|
||||
if (btServer->m_default_bluetooth_adapter)
|
||||
AddBluetoothDevices();
|
||||
}
|
||||
|
||||
BluetoothBottomWindow::~BluetoothBottomWindow()
|
||||
|
@ -103,6 +105,9 @@ void BluetoothBottomWindow::InitConnectionData()
|
|||
|
||||
void BluetoothBottomWindow::AddBluetoothDevices()
|
||||
{
|
||||
if (!BlueToothDBusService::m_default_bluetooth_adapter)
|
||||
return;
|
||||
|
||||
QList<QString> devKeyList = BlueToothDBusService::m_default_bluetooth_adapter->m_bt_dev_list.keys(); // 存放的就是QMap的key值
|
||||
KyDebug() << devKeyList;
|
||||
for(QString dev_addr:devKeyList)
|
||||
|
|
|
@ -251,30 +251,30 @@ void BlueToothDBusService::getDefaultAdapterDevices()
|
|||
dev_add_count++;
|
||||
KyInfo() << "add an device (mac):" << dev_addr << "is count device: " << dev_add_count ;
|
||||
|
||||
if (dev_add_count > 100)
|
||||
{//首次启动时,设备数量超过100个的情况下,多余的设备以定时加入的方式
|
||||
m_remainder_loaded_bluetooth_device_address_list.append(dev_addr);
|
||||
}
|
||||
else
|
||||
{
|
||||
// if (dev_add_count > 100)
|
||||
// {//首次启动时,设备数量超过100个的情况下,多余的设备以定时加入的方式
|
||||
// m_remainder_loaded_bluetooth_device_address_list.append(dev_addr);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
bluetoothdevice * dev = createOneBleutoothDeviceForAddress(dev_addr);
|
||||
if (dev != nullptr && !dev->isPaired())
|
||||
{
|
||||
m_default_bluetooth_adapter->m_bt_dev_list.insert(dev->getDevAddress(),dev);
|
||||
}
|
||||
}
|
||||
// }
|
||||
}
|
||||
|
||||
KyInfo() << "####" << m_remainder_loaded_bluetooth_device_address_list;
|
||||
|
||||
if (m_remainder_loaded_bluetooth_device_address_list.size() > 0)
|
||||
{
|
||||
if (m_loading_dev_timer->isActive())
|
||||
m_loading_dev_timer->stop();
|
||||
// if (m_remainder_loaded_bluetooth_device_address_list.size() > 0)
|
||||
// {
|
||||
// if (m_loading_dev_timer->isActive())
|
||||
// m_loading_dev_timer->stop();
|
||||
|
||||
m_loading_dev_timer->start();
|
||||
KyInfo() << "start m_loading_dev_timer!" << m_remainder_loaded_bluetooth_device_address_list;
|
||||
}
|
||||
// m_loading_dev_timer->start();
|
||||
// KyInfo() << "start m_loading_dev_timer!" << m_remainder_loaded_bluetooth_device_address_list;
|
||||
// }
|
||||
|
||||
KyDebug() << "end";
|
||||
}
|
||||
|
|
|
@ -134,6 +134,7 @@ void bluetoothdevicefunc::showDeviceRemoveWidget(DevRemoveDialog::REMOVE_INTERFA
|
|||
|
||||
connect(mesgBox,&DevRemoveDialog::accepted,this,[=]{
|
||||
KyDebug() << "To :" << _MDev_addr << "Remove" ;
|
||||
BlueToothDBusService::m_default_bluetooth_adapter->m_bt_dev_list[_MDev_addr]->setRemoving(true);
|
||||
BlueToothDBusService::devRemove(_MDev_addr);
|
||||
Q_EMIT devFuncOpertionRemoveSignal(_MDev_addr);
|
||||
});
|
||||
|
|
|
@ -26,7 +26,9 @@ BluetoothMiddleWindow::BluetoothMiddleWindow(BlueToothDBusService * btServer,QWi
|
|||
|
||||
InitNormalWidgetMiddle();
|
||||
InitConnectionData();
|
||||
AddMyBluetoothDevices();
|
||||
|
||||
if (btServer->m_default_bluetooth_adapter)
|
||||
AddMyBluetoothDevices();
|
||||
}
|
||||
|
||||
BluetoothMiddleWindow::~BluetoothMiddleWindow()
|
||||
|
@ -58,15 +60,15 @@ void BluetoothMiddleWindow::InitNormalWidgetMiddle()
|
|||
_NormalWidgetPairedDevLayout->setContentsMargins(0,0,0,0);
|
||||
_MNormalFrameMiddle->setLayout(_NormalWidgetPairedDevLayout);
|
||||
|
||||
_MConnectedNormalFrameMiddle = new QFrame(_MNormalFrameMiddle);
|
||||
_MConnectedNormalFrameMiddle = new QWidget(_MNormalFrameMiddle);
|
||||
_MConnectedNormalFrameMiddle->setMinimumWidth(582);
|
||||
_MConnectedNormalFrameMiddle->setFrameShape(QFrame::Shape::Box);
|
||||
// _MConnectedNormalFrameMiddle->setFrameShape(QFrame::Shape::Box);
|
||||
_MConnectedNormalFrameMiddle->setContentsMargins(0,0,0,0);
|
||||
_NormalWidgetPairedDevLayout->addWidget(_MConnectedNormalFrameMiddle);
|
||||
|
||||
_MNotConnectedNormalFrameMiddle = new QFrame(_MNormalFrameMiddle);
|
||||
_MNotConnectedNormalFrameMiddle = new QWidget(_MNormalFrameMiddle);
|
||||
_MNotConnectedNormalFrameMiddle->setMinimumWidth(582);
|
||||
_MNotConnectedNormalFrameMiddle->setFrameShape(QFrame::Shape::Box);
|
||||
// _MNotConnectedNormalFrameMiddle->setFrameShape(QFrame::Shape::Box);
|
||||
_MNotConnectedNormalFrameMiddle->setContentsMargins(0,0,0,0);
|
||||
_NormalWidgetPairedDevLayout->addWidget(_MNotConnectedNormalFrameMiddle);
|
||||
|
||||
|
@ -99,6 +101,8 @@ void BluetoothMiddleWindow::InitConnectionData()
|
|||
|
||||
void BluetoothMiddleWindow::AddMyBluetoothDevices()
|
||||
{
|
||||
if (!BlueToothDBusService::m_default_bluetooth_adapter)
|
||||
return;
|
||||
QList<QString> pairedDevKeyList = BlueToothDBusService::m_default_bluetooth_adapter->m_bt_dev_list.keys(); // 存放的就是QMap的key值
|
||||
KyDebug() << pairedDevKeyList;
|
||||
for (QString dev_addr:pairedDevKeyList)
|
||||
|
|
|
@ -52,9 +52,9 @@ private:
|
|||
|
||||
QFrame *_MNormalFrameMiddle = nullptr;
|
||||
QVBoxLayout *_NormalWidgetPairedDevLayout = nullptr;
|
||||
QFrame *_MNotConnectedNormalFrameMiddle = nullptr;
|
||||
QWidget *_MNotConnectedNormalFrameMiddle = nullptr;
|
||||
QVBoxLayout *_NormalWidgetNotConnecededDevLayout = nullptr;
|
||||
QFrame *_MConnectedNormalFrameMiddle = nullptr;
|
||||
QWidget *_MConnectedNormalFrameMiddle = nullptr;
|
||||
QVBoxLayout *_NormalWidgetConnecededDevLayout = nullptr;
|
||||
|
||||
//bool ;
|
||||
|
|
|
@ -18,16 +18,23 @@
|
|||
|
||||
#include "bluetoothtopwindow.h"
|
||||
|
||||
#include "common.h"
|
||||
|
||||
bool BluetoothTopWindow::m_defaultAdapterPowerStatus = false;
|
||||
|
||||
BluetoothTopWindow::BluetoothTopWindow(BlueToothDBusService * btServer,QWidget * parent) :
|
||||
m_btServer(btServer),
|
||||
QWidget(parent)
|
||||
{
|
||||
this->setFocusPolicy(Qt::NoFocus);
|
||||
// this->setFocusPolicy(Qt::NoFocus);
|
||||
this->setFocus(Qt::NoFocusReason);
|
||||
|
||||
|
||||
InitNormalWidgetTop();
|
||||
InitDisplayState();
|
||||
|
||||
if (btServer->m_default_bluetooth_adapter)
|
||||
InitDisplayState();
|
||||
|
||||
InitConnectionData();
|
||||
}
|
||||
|
||||
|
@ -78,9 +85,11 @@ void BluetoothTopWindow::InitNormalWidgetTop()
|
|||
_BtNameLabel = new BluetoothNameLabel(BtSwitchFrame,300,38);
|
||||
BtSwitchFrameLayout->addWidget(_BtNameLabel,1,Qt::AlignLeft);
|
||||
|
||||
BtSwitchFrameLayout->addStretch(25);
|
||||
|
||||
|
||||
_BtSwitchBtn = new KSwitchButton(BtSwitchFrame);
|
||||
// _BtSwitchBtn->setChecked(true);
|
||||
BtSwitchFrameLayout->addStretch(25);
|
||||
BtSwitchFrameLayout->addWidget(_BtSwitchBtn);
|
||||
|
||||
//添加分割线
|
||||
|
@ -204,6 +213,9 @@ void BluetoothTopWindow::InitNormalWidgetTop()
|
|||
|
||||
void BluetoothTopWindow::InitDisplayState()
|
||||
{
|
||||
if (!BlueToothDBusService::m_default_bluetooth_adapter)
|
||||
return;
|
||||
|
||||
//bluetooth
|
||||
_BtNameLabel->set_dev_name(BlueToothDBusService::m_default_bluetooth_adapter->getDevName());
|
||||
KyWarning()<< "power status:" << BlueToothDBusService::m_default_bluetooth_adapter->getAdapterPower();
|
||||
|
@ -263,6 +275,9 @@ void BluetoothTopWindow::InitConnectionData()
|
|||
|
||||
//btn
|
||||
connect(_BtSwitchBtn,SIGNAL(stateChanged(bool)),this,SLOT(_BtSwitchBtnSlot(bool)));
|
||||
connect(_BtSwitchBtn, &KSwitchButton::pressed, this, &BluetoothTopWindow::_BtSwitchBtnPressedSlot);
|
||||
connect(_BtSwitchBtn, &KSwitchButton::released, this, &BluetoothTopWindow::_BtSwitchBtnReleasedSlot);
|
||||
|
||||
connect(_BtTrayIconShow,SIGNAL(stateChanged(bool)),this,SLOT(_BtTrayIconShowSlot(bool)));
|
||||
connect(_BtDiscoverable,SIGNAL(stateChanged(bool)),this,SLOT(_BtDiscoverableSlot(bool)));
|
||||
connect(_BtAutoAudioConnBtn,SIGNAL(stateChanged(bool)),this,SLOT(_BtAutoAudioConnBtnSlot(bool)));
|
||||
|
@ -396,7 +411,31 @@ void BluetoothTopWindow::sendBtPowerChangedSignal(bool status)
|
|||
|
||||
void BluetoothTopWindow::_BtSwitchBtnSlot(bool status)
|
||||
{
|
||||
KyDebug();
|
||||
KyDebug() << "status" << status << "_BtSwitchBtn status: "<< _BtSwitchBtn->isChecked();
|
||||
|
||||
if (!_BTServiceReportPowerSwitchFlag && !status && whetherNeedInfoUser())
|
||||
{
|
||||
KyInfo() << "Close bluetooth risk info!" ;
|
||||
|
||||
QMessageBox box;
|
||||
box.setIcon(QMessageBox::Warning);
|
||||
box.setText(tr("Using Bluetooth mouse or keyboard, Do you want to turn off bluetooth?"));
|
||||
QPushButton * cancelBtn= new QPushButton(tr("Cancel"));
|
||||
QPushButton * closeBluetoothBtn= new QPushButton(tr("Close bluetooth"));
|
||||
|
||||
box.addButton(cancelBtn,QMessageBox::RejectRole);
|
||||
box.addButton(closeBluetoothBtn,QMessageBox::AcceptRole);
|
||||
int res = box.exec();
|
||||
if (!res)
|
||||
{
|
||||
_BtSwitchBtn->disconnect(_BtSwitchBtn,NULL,this,NULL);
|
||||
_BtSwitchBtn->setChecked(true);
|
||||
connect(_BtSwitchBtn,SIGNAL(stateChanged(bool)),this,SLOT(_BtSwitchBtnSlot(bool)));
|
||||
connect(_BtSwitchBtn, &KSwitchButton::pressed, this, &BluetoothTopWindow::_BtSwitchBtnPressedSlot);
|
||||
connect(_BtSwitchBtn, &KSwitchButton::released, this, &BluetoothTopWindow::_BtSwitchBtnReleasedSlot);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
BtSwitchLineFrame->setVisible(status);
|
||||
if (BlueToothDBusService::m_bluetooth_adapter_name_list.size() > 1)
|
||||
|
@ -419,6 +458,7 @@ void BluetoothTopWindow::_BtSwitchBtnSlot(bool status)
|
|||
KyInfo() << "_BTServiceReportPowerSwitchFlag:" << _BTServiceReportPowerSwitchFlag ;
|
||||
if(!_BTServiceReportPowerSwitchFlag)//服务上报的状态不再次下发
|
||||
{
|
||||
m_SwitchBtnPressed = false;
|
||||
ukccbluetoothconfig::ukccBtBuriedSettings(QString("Bluetooth"),QString("BtSwitchBtn"),QString("clicked"),status?QString("true"):QString("false"));
|
||||
BlueToothDBusService::setDefaultAdapterSwitchStatus(status);
|
||||
}
|
||||
|
@ -427,6 +467,26 @@ void BluetoothTopWindow::_BtSwitchBtnSlot(bool status)
|
|||
|
||||
}
|
||||
|
||||
void BluetoothTopWindow::_BtSwitchBtnPressedSlot()
|
||||
{
|
||||
m_SwitchBtnPressed = true;
|
||||
}
|
||||
|
||||
void BluetoothTopWindow::_BtSwitchBtnReleasedSlot()
|
||||
{
|
||||
if (m_SwitchBtnPressed) {
|
||||
KyWarning() << "active click";
|
||||
_BtSwitchBtn->disconnect(_BtSwitchBtn,NULL,this,NULL);
|
||||
connect(_BtSwitchBtn,SIGNAL(stateChanged(bool)),this,SLOT(_BtSwitchBtnSlot(bool)));
|
||||
|
||||
_BtSwitchBtn->click();
|
||||
connect(_BtSwitchBtn, &KSwitchButton::pressed, this, &BluetoothTopWindow::_BtSwitchBtnPressedSlot);
|
||||
connect(_BtSwitchBtn, &KSwitchButton::released, this, &BluetoothTopWindow::_BtSwitchBtnReleasedSlot);
|
||||
}
|
||||
|
||||
m_SwitchBtnPressed = false;
|
||||
}
|
||||
|
||||
void BluetoothTopWindow::_BtTrayIconShowSlot(bool status)
|
||||
{
|
||||
KyDebug();
|
||||
|
@ -583,3 +643,58 @@ void BluetoothTopWindow::quitWindow()
|
|||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
bool BluetoothTopWindow::whetherNeedInfoUser()
|
||||
{
|
||||
KyDebug();
|
||||
unsigned int bluetoothMouseAmount = 0;
|
||||
unsigned int bluetoothKeyBoardAmount = 0 ;
|
||||
|
||||
if (BlueToothDBusService::m_default_bluetooth_adapter)
|
||||
{
|
||||
for (auto var : BlueToothDBusService::m_default_bluetooth_adapter->m_bt_dev_list)
|
||||
{
|
||||
if (!var->getRemoving() && var->isPaired() && var->isConnected())
|
||||
{
|
||||
if (bluetoothdevice::DEVICE_TYPE::mouse == var->getDevType())
|
||||
{
|
||||
bluetoothMouseAmount += 1;
|
||||
}
|
||||
else if (bluetoothdevice::DEVICE_TYPE::keyboard == var->getDevType())
|
||||
{
|
||||
bluetoothKeyBoardAmount += 1;
|
||||
}
|
||||
else
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
KyInfo() << "Connected mouse amount:" << bluetoothMouseAmount
|
||||
<< "Connected KeyBoard amount:" << bluetoothKeyBoardAmount;
|
||||
|
||||
if (bluetoothMouseAmount == 0 && bluetoothKeyBoardAmount == 0)
|
||||
{
|
||||
KyDebug() << "Not connected KeyBoard and Mouse";
|
||||
return false;
|
||||
}
|
||||
|
||||
unsigned int systemMouseAndTouchPadAmount = Common::getSystemCurrentMouseAndTouchPadDevCount();
|
||||
unsigned int systemKeyBoardAmount = Common::getSystemCurrentKeyBoardDevCount();
|
||||
KyInfo() << "Connected bluetooth Mouse amount:" << bluetoothMouseAmount
|
||||
<< "Connected bluetooth KeyBoard amount:" << bluetoothKeyBoardAmount
|
||||
<< "System Mouse and TouchPad amount:" << systemMouseAndTouchPadAmount
|
||||
<< "System KeyBoard amount:" << systemKeyBoardAmount;
|
||||
|
||||
if ((bluetoothMouseAmount != 0) && (systemMouseAndTouchPadAmount == bluetoothMouseAmount))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if ((bluetoothKeyBoardAmount != 0) && (systemKeyBoardAmount == bluetoothKeyBoardAmount))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include <QComboBox>
|
||||
#include <QVBoxLayout>
|
||||
#include <QHBoxLayout>
|
||||
#include <QMessageBox>
|
||||
|
||||
#include "kswitchbutton.h"
|
||||
#include "bluetoothnamelabel.h"
|
||||
|
@ -55,6 +56,9 @@ private Q_SLOTS:
|
|||
void setDefaultAdapterNameSlot(QString);
|
||||
|
||||
void _BtSwitchBtnSlot(bool status);
|
||||
void _BtSwitchBtnPressedSlot();
|
||||
void _BtSwitchBtnReleasedSlot();
|
||||
|
||||
void _BtTrayIconShowSlot(bool status);
|
||||
void _BtDiscoverableSlot(bool status);
|
||||
void _BtAutoAudioConnBtnSlot(bool status);
|
||||
|
@ -101,12 +105,16 @@ private:
|
|||
bool _BTServiceReportAutoAudioConnSwtichFlag = false; //服务上报的自动音频状态
|
||||
// bool _BTServiceReportDiscoveringSwtichFlag = false; //服务上报的扫描状态
|
||||
|
||||
bool m_SwitchBtnPressed = false;
|
||||
|
||||
private:
|
||||
void InitNormalWidgetTop();
|
||||
void InitDisplayState();
|
||||
void InitConnectionData();
|
||||
void sendBtPowerChangedSignal(bool status);
|
||||
void adapterChangedRefreshInterface(int indx);
|
||||
|
||||
bool whetherNeedInfoUser();
|
||||
};
|
||||
|
||||
#endif // BLUETOOTHTOPWINDOW_H
|
||||
|
|
|
@ -0,0 +1,110 @@
|
|||
#include "common.h"
|
||||
|
||||
#include <ukui-log4qt.h>
|
||||
|
||||
extern "C"{
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/extensions/XInput.h>
|
||||
}
|
||||
|
||||
|
||||
|
||||
Common::Common(QObject *parent) : QObject(parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
unsigned int Common::getSystemCurrentMouseAndTouchPadDevCount()
|
||||
{
|
||||
unsigned int count = 0 ;
|
||||
Display *display = XOpenDisplay(NULL);
|
||||
if (display == NULL) {
|
||||
// 错误处理
|
||||
KyWarning() << "display error!";
|
||||
XCloseDisplay(display);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
XDeviceInfo *devices;
|
||||
int num_devices;
|
||||
devices = XListInputDevices(display, &num_devices);
|
||||
if (devices == NULL) {
|
||||
//KyWarning() << "devices error!";
|
||||
XCloseDisplay(display);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
Atom mouse_prop = XInternAtom(display,STR_MOUSE,false);
|
||||
Atom touchPad_prop = XInternAtom(display,STR_TOUCHPAD,false);
|
||||
|
||||
//KyDebug() << "mouse_prop:" << mouse_prop ;
|
||||
//KyDebug() << "touchPad_prop:" << touchPad_prop;
|
||||
|
||||
|
||||
for (int i = 0; i < num_devices; i++) {
|
||||
if (devices[i].type == mouse_prop || devices[i].type == touchPad_prop) {
|
||||
QString dev_name = QString(devices[i].name);
|
||||
KyDebug() << "dev_name:" <<dev_name ;
|
||||
KyDebug() << "mouse/touchPad" <<" id: " << devices[i].id << "devices name:" << devices[i].name ;
|
||||
if (dev_name.contains(STR_MOUSE,Qt::CaseInsensitive)
|
||||
|| dev_name.contains(STR_TOUCHPAD,Qt::CaseInsensitive)
|
||||
|| dev_name.contains(STR_TRACKPOINT,Qt::CaseInsensitive)
|
||||
|| dev_name.contains("MS",Qt::CaseInsensitive)
|
||||
)
|
||||
count ++;
|
||||
}
|
||||
}
|
||||
KyDebug() << "mouse devices count:" << count;
|
||||
|
||||
XFreeDeviceList(devices);
|
||||
XCloseDisplay(display);
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
|
||||
unsigned int Common::getSystemCurrentKeyBoardDevCount()
|
||||
{
|
||||
unsigned int count = 0 ;
|
||||
Display *display = XOpenDisplay(NULL);
|
||||
if (display == NULL) {
|
||||
// 错误处理
|
||||
//KyWarning() << "display error!";
|
||||
XCloseDisplay(display);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
XDeviceInfo *devices;
|
||||
int num_devices;
|
||||
devices = XListInputDevices(display, &num_devices);
|
||||
if (devices == NULL) {
|
||||
//KyWarning() << "devices error!";
|
||||
XCloseDisplay(display);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
Atom keyBoard_prop = XInternAtom(display,STR_KEYBOARD,false);
|
||||
|
||||
//KyDebug() << "keyBoard_prop:" << keyBoard_prop;
|
||||
for (int i = 0; i < num_devices; i++) {
|
||||
|
||||
if(devices[i].type == keyBoard_prop)
|
||||
{
|
||||
QString dev_name = QString(devices[i].name);
|
||||
KyDebug() << "dev_name:" <<dev_name ;
|
||||
KyDebug() << "keyBoard" <<" id: " << devices[i].id << "devices name:" << devices[i].name ;
|
||||
if (dev_name.contains(STR_KEYBOARD,Qt::CaseInsensitive)
|
||||
)
|
||||
count++;
|
||||
}
|
||||
}
|
||||
KyDebug() << "keyBoard devices count:" << count;
|
||||
|
||||
XFreeDeviceList(devices);
|
||||
XCloseDisplay(display);
|
||||
|
||||
return count;
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
#ifndef COMMON_H
|
||||
#define COMMON_H
|
||||
|
||||
#include <QObject>
|
||||
|
||||
#define STR_MOUSE "MOUSE"
|
||||
#define STR_TOUCHPAD "TOUCHPAD"
|
||||
#define STR_KEYBOARD "KEYBOARD"
|
||||
#define STR_TRACKPOINT "TRACKPOINT"
|
||||
|
||||
class Common : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit Common(QObject *parent = nullptr);
|
||||
static unsigned int getSystemCurrentMouseAndTouchPadDevCount();
|
||||
static unsigned int getSystemCurrentKeyBoardDevCount();
|
||||
signals:
|
||||
|
||||
};
|
||||
|
||||
#endif // COMMON_H
|
|
@ -585,6 +585,14 @@ int bluetoothdevice::getErrorId()
|
|||
return this->m_dev_connectFailedId;
|
||||
}
|
||||
|
||||
void bluetoothdevice::setRemoving(bool state)
|
||||
{
|
||||
this->m_dev_removing = state;
|
||||
}
|
||||
bool bluetoothdevice::getRemoving()
|
||||
{
|
||||
return this->m_dev_removing;
|
||||
}
|
||||
//bluetoothdevice end
|
||||
|
||||
|
||||
|
|
|
@ -309,6 +309,9 @@ public:
|
|||
|
||||
int getErrorId();
|
||||
|
||||
void setRemoving(bool);
|
||||
bool getRemoving();
|
||||
|
||||
signals:
|
||||
|
||||
void nameChanged(QString);
|
||||
|
@ -341,6 +344,7 @@ private:
|
|||
qint16 m_dev_rssi ;
|
||||
bool m_dev_sendFileMark ;
|
||||
QString m_adapter_address ;//暂时不使用
|
||||
bool m_dev_removing = false ;//正在移除该设备
|
||||
|
||||
void bluetoothDeviceDataAnalysis(QMap<QString ,QVariant> value);
|
||||
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
#!/bin/bash
|
||||
|
||||
ts_list=(`ls translations/*.ts`)
|
||||
source /etc/os-release
|
||||
version=(`echo $ID`)
|
||||
|
||||
for ts in "${ts_list[@]}"
|
||||
do
|
||||
printf "\nprocess ${ts}\n"
|
||||
if [ "$version" == "fedora" ] || [ "$version" == "opensuse-leap" ] || [ "$version" == "opensuse-tumbleweed" ];then
|
||||
lrelease-qt5 "${ts}"
|
||||
else
|
||||
lrelease "${ts}"
|
||||
fi
|
||||
done
|
|
@ -1,4 +1,4 @@
|
|||
QT += gui dbus
|
||||
QT += gui dbus x11extras
|
||||
|
||||
include(../environment.pri)
|
||||
|
||||
|
@ -6,16 +6,23 @@ greaterThan(QT_MAJOR_VERSION, 4): QT += widgets dbus KWindowSystem
|
|||
|
||||
TEMPLATE = lib
|
||||
CONFIG += plugin \
|
||||
+= c++11 \
|
||||
c++11 \
|
||||
x11extras \
|
||||
link_pkgconfig
|
||||
|
||||
PKGCONFIG += gsettings-qt \
|
||||
PKGCONFIG += gsettings-qt \
|
||||
kysdk-qtwidgets \
|
||||
kysdk-waylandhelper \
|
||||
kysdk-sysinfo
|
||||
kysdk-sysinfo \
|
||||
x11 \
|
||||
xi
|
||||
|
||||
LIBS += -lukcc
|
||||
|
||||
CONFIG(release, debug|release) {
|
||||
!system($$PWD/translate_generation.sh): error("Failed to generate translation")
|
||||
}
|
||||
|
||||
# The following define makes your compiler emit warnings if you use
|
||||
# any Qt feature that has been marked deprecated (the exact warnings
|
||||
# depend on your compiler). Please consult the documentation of the
|
||||
|
@ -48,6 +55,7 @@ SOURCES += \
|
|||
bluetoothmiddlewindow.cpp \
|
||||
bluetoothnamelabel.cpp \
|
||||
bluetoothtopwindow.cpp \
|
||||
common.cpp \
|
||||
devicebase.cpp \
|
||||
devremovedialog.cpp \
|
||||
devrenamedialog.cpp \
|
||||
|
@ -68,6 +76,7 @@ HEADERS += \
|
|||
bluetoothmiddlewindow.h \
|
||||
bluetoothnamelabel.h \
|
||||
bluetoothtopwindow.h \
|
||||
common.h \
|
||||
config.h \
|
||||
devicebase.h \
|
||||
devremovedialog.h \
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include <QGSettings>
|
||||
#include <ukui-log4qt.h>
|
||||
|
||||
|
||||
#ifdef UKCC_BLUETOOTH_DATA_BURIAL_POINT
|
||||
#include <ukcc/interface/ukcccommon.h>
|
||||
#endif
|
||||
|
|
|
@ -0,0 +1,42 @@
|
|||
#include "sysdbusinterface.h"
|
||||
|
||||
#include <QFileInfo>
|
||||
#include <QDir>
|
||||
#include <file-utils.h>
|
||||
|
||||
#include "ukui-log4qt.h"
|
||||
|
||||
sysdbusinterface::sysdbusinterface()
|
||||
{
|
||||
|
||||
QDBusConnection systemBus = QDBusConnection::systemBus();
|
||||
if (!systemBus.registerObject("/", this, QDBusConnection::ExportAllSlots))
|
||||
{
|
||||
KyWarning() << "QDbus register object failed reason:" << systemBus.lastError();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
sysdbusinterface::~sysdbusinterface()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
QString sysdbusinterface::getProperFilePath(QString user, QString filename)
|
||||
{
|
||||
KyInfo() << user << filename;
|
||||
QString dest;
|
||||
dest = QStandardPaths::writableLocation(QStandardPaths::DownloadLocation) + "/" + filename;
|
||||
|
||||
KyDebug() << dest;
|
||||
while (QFile::exists(dest))
|
||||
{
|
||||
QStringList newUrl = dest.split("/");
|
||||
newUrl.pop_back();
|
||||
newUrl.append(Peony::FileUtils::handleDuplicateName(Peony::FileUtils::urlDecode(dest)));
|
||||
dest = newUrl.join("/");
|
||||
KyDebug() << dest << newUrl;
|
||||
}
|
||||
|
||||
return dest;
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
#ifndef SYSDBUSINTERFACE_H
|
||||
#define SYSDBUSINTERFACE_H
|
||||
|
||||
#include <QStandardPaths>
|
||||
#include <QObject>
|
||||
#include <QtDBus/QDBusContext>
|
||||
#include <QDBusConnection>
|
||||
#include <QDBusReply>
|
||||
#include <QDBusConnectionInterface>
|
||||
|
||||
class sysdbusinterface : public QObject, protected QDBusContext
|
||||
{
|
||||
Q_CLASSINFO("D-Bus Interface", "com.ukui.bluetooth")
|
||||
Q_OBJECT
|
||||
public:
|
||||
sysdbusinterface();
|
||||
~sysdbusinterface();
|
||||
|
||||
public slots:
|
||||
QString getProperFilePath(QString user, QString filename);
|
||||
|
||||
};
|
||||
|
||||
#endif // SYSDBUSINTERFACE_H
|
|
@ -30,6 +30,8 @@
|
|||
#include <ukui-log4qt.h>
|
||||
#include "kysdk/kysdk-system/libkysysinfo.h"
|
||||
|
||||
#include "dbus/sysdbusinterface.h"
|
||||
|
||||
extern bool global_rightToleft;
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
|
@ -77,6 +79,8 @@ int main(int argc, char *argv[])
|
|||
if (qt_translator->load(QLocale(), "qt", "_", qtTransPath))
|
||||
app.installTranslator(qt_translator);
|
||||
|
||||
auto ptr = new sysdbusinterface();
|
||||
|
||||
MainProgram w(envPC);
|
||||
if(w.exit_flag){
|
||||
return 0;
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
#!/bin/bash
|
||||
|
||||
ts_list=(`ls translations/*.ts`)
|
||||
source /etc/os-release
|
||||
version=(`echo $ID`)
|
||||
|
||||
for ts in "${ts_list[@]}"
|
||||
do
|
||||
printf "\nprocess ${ts}\n"
|
||||
if [ "$version" == "fedora" ] || [ "$version" == "opensuse-leap" ] || [ "$version" == "opensuse-tumbleweed" ];then
|
||||
lrelease-qt5 "${ts}"
|
||||
else
|
||||
lrelease "${ts}"
|
||||
fi
|
||||
done
|
|
@ -25,6 +25,10 @@ LIBS += -L /usr/lib/x86_64-linux-gnu -l KF5BluezQt -lgio-2.0 -lglib-2.0 -lukui-l
|
|||
|
||||
QMAKE_LFLAGS += -D_FORTIFY_SOURCE=2 -O2
|
||||
|
||||
CONFIG(release, debug|release) {
|
||||
!system($$PWD/translate_generation.sh): error("Failed to generate translation")
|
||||
}
|
||||
|
||||
inst1.files += ../data/org.bluez.Agent1.conf
|
||||
inst1.path = $$CONF_INSTALL_DIR
|
||||
inst2.files += ../data/org.ukui.bluetooth.gschema.xml
|
||||
|
@ -37,14 +41,19 @@ inst5.files += ../data/file-transfer-failed.svg
|
|||
inst5.path = $$SHARE_INSTALL_DIR
|
||||
inst6.files +=../data/connection-failed.svg
|
||||
inst6.path = $$SHARE_INSTALL_DIR
|
||||
qm_files.files += translations/*.qm
|
||||
qm_files.path += $${SHARE_TRANSLATIONS_INSTALL_DIR}
|
||||
target.source += $$TARGET
|
||||
target.path = $$BIN_INSTALL_DIR
|
||||
|
||||
|
||||
INSTALLS += inst1 \
|
||||
inst2 \
|
||||
inst3 \
|
||||
inst4 \
|
||||
inst5 \
|
||||
inst6 \
|
||||
qm_files \
|
||||
target
|
||||
|
||||
# The following define makes your compiler emit warnings if you use
|
||||
|
@ -72,6 +81,7 @@ unix {
|
|||
}
|
||||
|
||||
SOURCES += \
|
||||
dbus/sysdbusinterface.cpp \
|
||||
popwidget/activeconnectionwidget.cpp \
|
||||
component/bluetoothsettinglabel.cpp \
|
||||
component/kyfiledialog.cpp \
|
||||
|
@ -91,6 +101,7 @@ SOURCES += \
|
|||
dbus/sessiondbusinterface.cpp
|
||||
|
||||
HEADERS += \
|
||||
dbus/sysdbusinterface.h \
|
||||
popwidget/activeconnectionwidget.h \
|
||||
component/bluetoothsettinglabel.h \
|
||||
component/kyfiledialog.h \
|
||||
|
|
Loading…
Reference in New Issue