Merge branch 'up-dbus' into 'dbus-interface'

add  DesktopNotify

See merge request kylin-desktop/kylin-nm!280
This commit is contained in:
Zhang Jiaping 2021-09-24 09:32:39 +00:00
commit 0f45ed8ad6
4 changed files with 28 additions and 10 deletions

2
debian/kylin-nm.postinst vendored Normal file → Executable file
View File

@ -10,5 +10,5 @@ fi
echo "kylin nm set cap success"
exit(0)
exit 0

View File

@ -20,6 +20,24 @@
//extern void qt_blurImage(QImage &blurImage, qreal radius, bool quality, int transposed);
void NetDetail::showDesktopNotify(const QString &message)
{
QDBusInterface iface("org.freedesktop.Notifications",
"/org/freedesktop/Notifications",
"org.freedesktop.Notifications",
QDBusConnection::sessionBus());
QList<QVariant> args;
args<<(tr("Kylin NM"))
<<((unsigned int) 0)
<<QString("/usr/share/icons/ukui-icon-theme-default/24x24/devices/gnome-dev-ethernet.png")
<<tr("kylin network desktop message") //显示的是什么类型的信息
<<message //显示的具体信息
<<QStringList()
<<QVariantMap()
<<(int)-1;
iface.callWithArgumentList(QDBus::AutoDetect,"Notify",args);
}
NetDetail::NetDetail(QString interface, QString name, QString uuid, bool isActive, bool isWlan, bool isCreateNet, QWidget *parent)
:m_deviceName(interface),
m_name(name),
@ -571,6 +589,7 @@ void NetDetail::setConfirmEnable()
bool NetDetail::checkIpv4Conflict(QString ipv4Address)
{
showDesktopNotify(tr("start check ipv4 address conflict"));
bool isConflict = false;
KyIpv4Arping* ipv4Arping = new KyIpv4Arping(m_deviceName, ipv4Address);
@ -587,6 +606,7 @@ bool NetDetail::checkIpv4Conflict(QString ipv4Address)
bool NetDetail::checkIpv6Conflict(QString ipv6address)
{
showDesktopNotify(tr("start check ipv6 address conflict"));
bool isConflict = false;
KyIpv6Arping* ipv46rping = new KyIpv6Arping(m_deviceName, ipv6address);
@ -632,7 +652,7 @@ bool NetDetail::createWiredConnect()
if (connetSetting.m_ipv4ConfigIpType != CONFIG_IP_DHCP) {
if (checkIpv4Conflict(connetSetting.m_ipv4Address.at(0).ip().toString())) {
qDebug() << "ipv4 conflict";
//todo desktop notify
showDesktopNotify(tr("ipv4 address conflict!"));
return false;
}
}
@ -669,7 +689,7 @@ bool NetDetail::createWirelessConnect()
if (ipv4Change && connetSetting.m_ipv4ConfigIpType == CONFIG_IP_MANUAL) {
if (checkIpv4Conflict(connetSetting.m_ipv4Address.at(0).ip().toString())) {
qDebug() << "ipv4 conflict";
//todo desktop notify
showDesktopNotify(tr("ipv4 address conflict!"));
return false;
}
}
@ -677,7 +697,7 @@ bool NetDetail::createWirelessConnect()
if (ipv6Change && connetSetting.m_ipv6ConfigIpType == CONFIG_IP_MANUAL) {
if (checkIpv6Conflict(connetSetting.m_ipv6Address.at(0).ip().toString())) {
qDebug() << "ipv6 conflict";
//todo desktop notify
showDesktopNotify(tr("ipv6 address conflict!"));
return false;
}
}
@ -747,7 +767,7 @@ bool NetDetail::updateConnect()
if (ipv4Change && connetSetting.m_ipv4ConfigIpType == CONFIG_IP_MANUAL) {
if (checkIpv4Conflict(connetSetting.m_ipv4Address.at(0).ip().toString())) {
qDebug() << "ipv4 conflict";
//todo desktop notify
showDesktopNotify(tr("ipv4 address conflict!"));
return false;
}
}
@ -755,7 +775,7 @@ bool NetDetail::updateConnect()
if (ipv6Change && connetSetting.m_ipv6ConfigIpType == CONFIG_IP_MANUAL) {
if (checkIpv6Conflict(connetSetting.m_ipv6Address.at(0).ip().toString())) {
qDebug() << "ipv6 conflict";
//todo desktop notify
showDesktopNotify(tr("ipv6 address conflict!"));
return false;
}
}

View File

@ -69,6 +69,8 @@ private:
bool createWiredConnect();
bool createWirelessConnect();
bool updateConnect();
void showDesktopNotify(const QString &message);
private:
KyNetworkDeviceResourse *m_netDeviceResource = nullptr;
KyConnectOperation* m_connectOperation = nullptr;

View File

@ -189,10 +189,6 @@ void LanPage::initDeviceCombox()
//TODO 获取设备列表,单设备时隐藏下拉框,多设备时添加到下拉框;m_devList记录插入的所有设备deviceMap记录设备状态
QMap<QString, bool> deviceMap;
m_deviceComboBox->clear();
m_devList.clear();
enableDevice.clear();
if (!m_switchGsettings) {
qDebug() << "[LanPage]:m_switchGsettings is null" << Q_FUNC_INFO << __LINE__;
return;