Add bluetooth connect
This commit is contained in:
parent
fb4ff49535
commit
d8d2358df4
|
@ -18,7 +18,7 @@ CONFIG += release
|
|||
|
||||
# CONFIG += link_pkgconfig
|
||||
# PKGCONFIG += gsettings-qt
|
||||
LIBS += -L/usr/lib/ -lgsettings-qt -lX11 -lnm
|
||||
LIBS += -L/usr/lib/ -lgsettings-qt -lX11
|
||||
|
||||
target.path = /usr/bin
|
||||
target.source += $$TARGET
|
||||
|
|
|
@ -205,7 +205,7 @@ void BackThread::execDisWifi()
|
|||
}
|
||||
|
||||
//to connect wired network
|
||||
void BackThread::execConnLan(QString connName, QString ifname)
|
||||
void BackThread::execConnLan(QString connName, QString ifname, QString connectType)
|
||||
{
|
||||
currConnLanUuid = connName;
|
||||
KylinDBus objKyDbus;
|
||||
|
@ -223,7 +223,14 @@ void BackThread::execConnLan(QString connName, QString ifname)
|
|||
//} else {
|
||||
// emit connDone(7);
|
||||
//}
|
||||
QString mycmd = "export LANG='en_US.UTF-8';export LANGUAGE='en_US';nmcli connection up '" + connName + "' ifname '" + ifname + "'";
|
||||
QString mycmd;
|
||||
qDebug() << "传送过来的类型-------------------》" << connectType;
|
||||
if (connectType == "bluetooth") {
|
||||
mycmd = "export LANG='en_US.UTF-8';export LANGUAGE='en_US';nmcli connection up '" + connName + "'";
|
||||
} else {
|
||||
mycmd = "export LANG='en_US.UTF-8';export LANGUAGE='en_US';nmcli connection up '" + connName + "' ifname '" + ifname + "'";
|
||||
}
|
||||
qDebug() << "sdasadsadsadsa------------->" << mycmd;
|
||||
QStringList options;
|
||||
options << "-c" << mycmd;
|
||||
process->start("/bin/bash",options);
|
||||
|
|
|
@ -57,7 +57,7 @@ public slots:
|
|||
void execDisNet();
|
||||
void execEnWifi();
|
||||
void execDisWifi();
|
||||
void execConnLan(QString connName, QString ifname);
|
||||
void execConnLan(QString connName, QString ifname, QString connectType);
|
||||
void execConnWifi(QString connName);
|
||||
void execConnWifiPWD(QString connName, QString password, QString connType);
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ void KSimpleNM::execGetLanList()
|
|||
isExecutingGetLanList = true;
|
||||
|
||||
shellOutputLan = "";
|
||||
QString getCmd = "export LANG='en_US.UTF-8';export LANGUAGE='en_US';nmcli -f type,uuid,name connection show";
|
||||
QString getCmd = "export LANG='zh_CN.UTF-8';export LANGUAGE='zh_CN:zh';nmcli -f type,uuid,name connection show";
|
||||
QStringList options;
|
||||
options << "-c" << getCmd;
|
||||
runProcessLan->start("/bin/bash",options);
|
||||
|
|
|
@ -872,7 +872,7 @@ QList<QString> KylinDBus::getAtiveLanSsidUuid()
|
|||
QDBusConnection::systemBus() );
|
||||
QDBusReply<QVariant> reply = interfaceType.call("Get", "org.freedesktop.NetworkManager.Connection.Active", "Type");
|
||||
|
||||
if (reply.value().toString() == "ethernet" || reply.value().toString() == "802-3-ethernet") {
|
||||
if (reply.value().toString() == "ethernet" || reply.value().toString() == "802-3-ethernet" || reply.value().toString() == "bluetooth") {
|
||||
QDBusInterface interfaceInfo( "org.freedesktop.NetworkManager",
|
||||
objPath.path(),
|
||||
"org.freedesktop.DBus.Properties",
|
||||
|
|
|
@ -1453,7 +1453,7 @@ void MainWindow::getLanListDone(QStringList slist)
|
|||
OneLancForm *ccfAct = new OneLancForm(topLanListWidget, this, confForm, ksnm);
|
||||
connect(ccfAct, SIGNAL(selectedOneLanForm(QString, QString)), this, SLOT(oneTopLanFormSelected(QString, QString)));
|
||||
connect(ccfAct, SIGNAL(disconnActiveLan()), this, SLOT(activeLanDisconn()));
|
||||
ccfAct->setName(nname, nname, nuuid, mIfName);//第二个参数本来是strLanName,但目前不需要翻译
|
||||
ccfAct->setName(nname, ltype, nuuid, mIfName);//第二个参数本来是strLanName,但目前不需要翻译
|
||||
ccfAct->setIcon(true);
|
||||
ccfAct->setLanInfo(objKyDBus->dbusLanIpv4, objKyDBus->dbusActiveLanIpv6, mwBandWidth, macInterface);
|
||||
ccfAct->isConnected = true;
|
||||
|
@ -1513,7 +1513,7 @@ void MainWindow::getLanListDone(QStringList slist)
|
|||
|
||||
OneLancForm *ocf = new OneLancForm(lanListWidget, this, confForm, ksnm);
|
||||
connect(ocf, SIGNAL(selectedOneLanForm(QString, QString)), this, SLOT(oneLanFormSelected(QString, QString)));
|
||||
ocf->setName(nname, nname, nuuid, mIfName);
|
||||
ocf->setName(nname, ltype, nuuid, mIfName);
|
||||
ocf->setIcon(true);
|
||||
ocf->setLine(true);
|
||||
ocf->setLanInfo(objKyDBus->dbusLanIpv4, objKyDBus->dbusLanIpv6, tr("Disconnected"), macInterface);
|
||||
|
@ -2762,7 +2762,7 @@ void MainWindow::connLanDone(int connFlag)
|
|||
// Lan连接结果,0点击连接成功 1因网线未插入失败 2因mac地址匹配不上失败 3开机启动网络工具时已经连接
|
||||
if (connFlag == 0) {
|
||||
syslog(LOG_DEBUG, "Wired net already connected by clicking button");
|
||||
//this->ksnm->execGetLanList();
|
||||
this->ksnm->execGetLanList();
|
||||
|
||||
QString txt(tr("Conn Ethernet Success"));
|
||||
objKyDBus->showDesktopNotify(txt);
|
||||
|
|
|
@ -222,11 +222,12 @@ void OneLancForm::setTopItem(bool isSelected)
|
|||
//设置网络名称
|
||||
void OneLancForm::setName(QString ssid, QString transSsid, QString uuid, QString interface)
|
||||
{
|
||||
ui->lbName->setText(transSsid);
|
||||
ui->lbName->setText(ssid);
|
||||
ssidName = ssid;
|
||||
transSsidName = transSsid;
|
||||
m_sConnectType = transSsid;
|
||||
uuidName = uuid;
|
||||
ifName = interface;
|
||||
qDebug() << "连接类型" << m_sConnectType;
|
||||
}
|
||||
|
||||
//根据有线网络连接与否,设置显示'已连接'文字的控件的可见与否
|
||||
|
@ -293,7 +294,7 @@ void OneLancForm::slotConnLan()
|
|||
//mw->startLoading();
|
||||
this->startWaiting(true);
|
||||
//emit sigConnLan(ui->lbName->text(), ifName);
|
||||
emit sigConnLan(uuidName, ifName);
|
||||
emit sigConnLan(uuidName, ifName, m_sConnectType);
|
||||
}
|
||||
|
||||
//点击网络断开按钮,执行该函数
|
||||
|
@ -381,7 +382,7 @@ void OneLancForm::toConnectWiredNetwork()
|
|||
bt->moveToThread(t);
|
||||
connect(t, SIGNAL(finished()), t, SLOT(deleteLater()));
|
||||
connect(t, SIGNAL(started()), this, SLOT(slotConnLan()));
|
||||
connect(this, SIGNAL(sigConnLan(QString, QString)), bt, SLOT(execConnLan(QString, QString)));
|
||||
connect(this, SIGNAL(sigConnLan(QString, QString, QString)), bt, SLOT(execConnLan(QString, QString, QString)));
|
||||
connect(bt, SIGNAL(connDone(int)), mw, SLOT(connLanDone(int)));
|
||||
connect(bt, SIGNAL(btFinish()), t, SLOT(quit()));
|
||||
t->start();
|
||||
|
|
|
@ -80,7 +80,7 @@ public:
|
|||
bool isActive;
|
||||
bool isConnected;
|
||||
QString ssidName;
|
||||
QString transSsidName;
|
||||
QString m_sConnectType;
|
||||
QString uuidName;
|
||||
QString ifName;
|
||||
|
||||
|
@ -122,7 +122,7 @@ signals:
|
|||
void connDone(int connFlag);
|
||||
void disconnActiveLan();
|
||||
|
||||
void sigConnLan(QString, QString);
|
||||
void sigConnLan(QString, QString, QString);
|
||||
};
|
||||
|
||||
#endif // ONELANCFORM_H
|
||||
|
|
Loading…
Reference in New Issue