add device switch button

Change-Id: I3a591b74d1a642a37f6ad1ac4e7f32367f1a0c27
This commit is contained in:
石博文 2016-07-26 17:36:31 +08:00 committed by Hualet Wang
parent bd38772b43
commit 0a78fc01ea
5 changed files with 15 additions and 2 deletions

View File

@ -147,10 +147,10 @@ public Q_SLOTS: // METHODS
return asyncCallWithArgumentList(QStringLiteral("EditConnection"), argumentList);
}
inline QDBusPendingReply<> EnableDevice(const QDBusObjectPath &in0, bool in1)
inline QDBusPendingReply<> EnableDevice(const QDBusObjectPath &devPath, bool enable)
{
QList<QVariant> argumentList;
argumentList << QVariant::fromValue(in0) << QVariant::fromValue(in1);
argumentList << QVariant::fromValue(devPath) << QVariant::fromValue(enable);
return asyncCallWithArgumentList(QStringLiteral("EnableDevice"), argumentList);
}

View File

@ -22,6 +22,8 @@ DeviceControlWidget::DeviceControlWidget(QWidget *parent)
setLayout(centeralLayout);
setFixedHeight(20);
connect(m_switchBtn, &DSwitchButton::checkedChanged, this, &DeviceControlWidget::deviceEnableChanged);
}
void DeviceControlWidget::setDeviceName(const QString &name)

View File

@ -16,6 +16,9 @@ public:
void setDeviceName(const QString &name);
void setDeviceEnabled(const bool enable);
signals:
void deviceEnableChanged(const bool enable) const;
private:
QLabel *m_deviceName;
Dtk::Widget::DSwitchButton *m_switchBtn;

View File

@ -39,6 +39,8 @@ WirelessApplet::WirelessApplet(const QString &devicePath, QWidget *parent)
connect(m_networkInter, &DBusNetwork::AccessPointPropertiesChanged, this, &WirelessApplet::APPropertiesChanged);
connect(m_controlPanel, &DeviceControlWidget::deviceEnableChanged, this, &WirelessApplet::deviceEnableChanged);
connect(m_updateAPTimer, &QTimer::timeout, this, &WirelessApplet::updateAPList);
}
@ -137,3 +139,8 @@ void WirelessApplet::updateAPList()
m_centeralWidget->setFixedHeight(contentHeight);
setFixedHeight(std::min(contentHeight, MAX_HEIGHT));
}
void WirelessApplet::deviceEnableChanged(const bool enable)
{
m_networkInter->EnableDevice(QDBusObjectPath(m_devicePath), enable);
}

View File

@ -25,6 +25,7 @@ private slots:
void init();
void APPropertiesChanged(const QString &devPath, const QString &info);
void updateAPList();
void deviceEnableChanged(const bool enable);
private:
const QString m_devicePath;