mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-04 17:33:05 +00:00
add access point info
Change-Id: I0913475175fcb3db94a6e4926e4bc6f79213839e
This commit is contained in:
parent
fe506e6807
commit
2a5c0c872d
7
plugins/network/item/applet/accesspoint.cpp
Normal file
7
plugins/network/item/applet/accesspoint.cpp
Normal file
@ -0,0 +1,7 @@
|
||||
#include "accesspoint.h"
|
||||
|
||||
AccessPoint::AccessPoint(QObject *parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
|
||||
}
|
14
plugins/network/item/applet/accesspoint.h
Normal file
14
plugins/network/item/applet/accesspoint.h
Normal file
@ -0,0 +1,14 @@
|
||||
#ifndef ACCESSPOINT_H
|
||||
#define ACCESSPOINT_H
|
||||
|
||||
#include <QObject>
|
||||
|
||||
class AccessPoint : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit AccessPoint(QObject *parent = 0);
|
||||
};
|
||||
|
||||
#endif // ACCESSPOINT_H
|
35
plugins/network/item/applet/devicecontrolwidget.cpp
Normal file
35
plugins/network/item/applet/devicecontrolwidget.cpp
Normal file
@ -0,0 +1,35 @@
|
||||
#include "devicecontrolwidget.h"
|
||||
|
||||
#include <QHBoxLayout>
|
||||
#include <QDebug>
|
||||
|
||||
DWIDGET_USE_NAMESPACE
|
||||
|
||||
DeviceControlWidget::DeviceControlWidget(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
{
|
||||
m_deviceName = new QLabel;
|
||||
m_deviceName->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
|
||||
m_deviceName->setStyleSheet("color:white;");
|
||||
|
||||
m_switchBtn = new DSwitchButton;
|
||||
|
||||
QHBoxLayout *centeralLayout = new QHBoxLayout;
|
||||
centeralLayout->addWidget(m_deviceName);
|
||||
centeralLayout->addWidget(m_switchBtn);
|
||||
centeralLayout->setSpacing(0);
|
||||
centeralLayout->setMargin(0);
|
||||
|
||||
setLayout(centeralLayout);
|
||||
setFixedHeight(20);
|
||||
}
|
||||
|
||||
void DeviceControlWidget::setDeviceName(const QString &name)
|
||||
{
|
||||
m_deviceName->setText(name);
|
||||
}
|
||||
|
||||
void DeviceControlWidget::setDeviceEnabled(const bool enable)
|
||||
{
|
||||
m_switchBtn->setChecked(enable);
|
||||
}
|
24
plugins/network/item/applet/devicecontrolwidget.h
Normal file
24
plugins/network/item/applet/devicecontrolwidget.h
Normal file
@ -0,0 +1,24 @@
|
||||
#ifndef DEVICECONTROLWIDGET_H
|
||||
#define DEVICECONTROLWIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QLabel>
|
||||
|
||||
#include <dswitchbutton.h>
|
||||
|
||||
class DeviceControlWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit DeviceControlWidget(QWidget *parent = 0);
|
||||
|
||||
void setDeviceName(const QString &name);
|
||||
void setDeviceEnabled(const bool enable);
|
||||
|
||||
private:
|
||||
QLabel *m_deviceName;
|
||||
Dtk::Widget::DSwitchButton *m_switchBtn;
|
||||
};
|
||||
|
||||
#endif // DEVICECONTROLWIDGET_H
|
@ -1,12 +1,70 @@
|
||||
#include "wirelessapplet.h"
|
||||
|
||||
#include <QJsonDocument>
|
||||
|
||||
#define WIDTH 300
|
||||
|
||||
WirelessApplet::WirelessApplet(const QString &devicePath, QWidget *parent)
|
||||
: QScrollArea(parent),
|
||||
m_devicePath(devicePath)
|
||||
{
|
||||
setFixedHeight(300);
|
||||
m_devicePath(devicePath),
|
||||
|
||||
m_centeralLayout(new QVBoxLayout),
|
||||
m_centeralWidget(new QWidget),
|
||||
m_controlPanel(new DeviceControlWidget(this)),
|
||||
m_networkInter(new DBusNetwork(this))
|
||||
{
|
||||
setFixedHeight(WIDTH);
|
||||
|
||||
m_centeralWidget->setFixedWidth(WIDTH);
|
||||
m_centeralWidget->setLayout(m_centeralLayout);
|
||||
|
||||
m_centeralLayout->addWidget(m_controlPanel);
|
||||
|
||||
setWidget(m_centeralWidget);
|
||||
setFrameStyle(QFrame::NoFrame);
|
||||
setFixedWidth(300);
|
||||
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
setStyleSheet("background-color:transparent;");
|
||||
|
||||
setDeviceInfo();
|
||||
|
||||
connect(m_networkInter, &DBusNetwork::AccessPointPropertiesChanged, this, &WirelessApplet::APChanged);
|
||||
}
|
||||
|
||||
void WirelessApplet::setDeviceInfo()
|
||||
{
|
||||
// set device enable state
|
||||
m_controlPanel->setDeviceEnabled(m_networkInter->IsDeviceEnabled(QDBusObjectPath(m_devicePath)));
|
||||
|
||||
// set device name
|
||||
const QJsonDocument doc = QJsonDocument::fromJson(m_networkInter->devices().toUtf8());
|
||||
Q_ASSERT(doc.isObject());
|
||||
const QJsonObject obj = doc.object();
|
||||
|
||||
for (auto infoList(obj.constBegin()); infoList != obj.constEnd(); ++infoList)
|
||||
{
|
||||
Q_ASSERT(infoList.value().isArray());
|
||||
|
||||
if (infoList.key() != "wireless")
|
||||
continue;
|
||||
|
||||
for (auto wireless : infoList.value().toArray())
|
||||
{
|
||||
const QJsonObject info = wireless.toObject();
|
||||
if (info.value("Path") == m_devicePath)
|
||||
{
|
||||
m_controlPanel->setDeviceName(info.value("Vendor").toString());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void WirelessApplet::APChanged(const QString &devPath, const QString &info)
|
||||
{
|
||||
if (devPath != m_devicePath)
|
||||
return;
|
||||
|
||||
qDebug() << info;
|
||||
}
|
||||
|
@ -1,7 +1,11 @@
|
||||
#ifndef WIRELESSAPPLET_H
|
||||
#define WIRELESSAPPLET_H
|
||||
|
||||
#include "devicecontrolwidget.h"
|
||||
#include "../../dbus/dbusnetwork.h"
|
||||
|
||||
#include <QScrollArea>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
class WirelessApplet : public QScrollArea
|
||||
{
|
||||
@ -10,8 +14,19 @@ class WirelessApplet : public QScrollArea
|
||||
public:
|
||||
explicit WirelessApplet(const QString &devicePath, QWidget *parent = 0);
|
||||
|
||||
private:
|
||||
void setDeviceInfo();
|
||||
|
||||
private slots:
|
||||
void APChanged(const QString &devPath, const QString &info);
|
||||
|
||||
private:
|
||||
const QString m_devicePath;
|
||||
|
||||
QVBoxLayout *m_centeralLayout;
|
||||
QWidget *m_centeralWidget;
|
||||
DeviceControlWidget *m_controlPanel;
|
||||
DBusNetwork *m_networkInter;
|
||||
};
|
||||
|
||||
#endif // WIRELESSAPPLET_H
|
||||
|
@ -4,7 +4,7 @@ include(../../interfaces/interfaces.pri)
|
||||
QT += widgets svg dbus
|
||||
TEMPLATE = lib
|
||||
CONFIG += plugin c++11 link_pkgconfig
|
||||
PKGCONFIG +=
|
||||
PKGCONFIG += dtkbase dtkwidget
|
||||
|
||||
TARGET = $$qtLibraryTarget(network)
|
||||
DESTDIR = $$_PRO_FILE_PWD_/../
|
||||
@ -19,7 +19,9 @@ HEADERS += \
|
||||
util/imageutil.h \
|
||||
item/deviceitem.h \
|
||||
item/wirelessitem.h \
|
||||
item/applet/wirelessapplet.h
|
||||
item/applet/wirelessapplet.h \
|
||||
item/applet/devicecontrolwidget.h \
|
||||
item/applet/accesspoint.h
|
||||
|
||||
SOURCES += \
|
||||
networkplugin.cpp \
|
||||
@ -30,7 +32,9 @@ SOURCES += \
|
||||
util/imageutil.cpp \
|
||||
item/deviceitem.cpp \
|
||||
item/wirelessitem.cpp \
|
||||
item/applet/wirelessapplet.cpp
|
||||
item/applet/wirelessapplet.cpp \
|
||||
item/applet/devicecontrolwidget.cpp \
|
||||
item/applet/accesspoint.cpp
|
||||
|
||||
target.path = $${PREFIX}/lib/dde-dock/plugins/
|
||||
INSTALLS += target
|
||||
|
@ -94,7 +94,6 @@ NetworkManager::NetworkManager(QObject *parent)
|
||||
{
|
||||
connect(m_networkInter, &DBusNetwork::DevicesChanged, this, &NetworkManager::reloadDevices);
|
||||
connect(m_networkInter, &DBusNetwork::ActiveConnectionsChanged, this, &NetworkManager::reloadActiveConnections);
|
||||
connect(m_networkInter, &DBusNetwork::AccessPointPropertiesChanged, this, &NetworkManager::APPropertiesChanged);
|
||||
}
|
||||
|
||||
const QSet<NetworkDevice>::const_iterator NetworkManager::device(const QUuid &uuid) const
|
||||
|
@ -33,7 +33,6 @@ signals:
|
||||
void deviceRemoved(const NetworkDevice &device) const;
|
||||
void activeConnectionChanged(const QUuid &uuid) const;
|
||||
void networkStateChanged(const NetworkDevice::NetworkTypes &states) const;
|
||||
void APPropertiesChanged(const QString &devicePath, const QString &info) const;
|
||||
|
||||
private:
|
||||
explicit NetworkManager(QObject *parent = 0);
|
||||
|
Loading…
x
Reference in New Issue
Block a user