Feat: Add some interfaces for list item.
This commit is contained in:
parent
bf15d59efd
commit
c473e3b9ed
|
@ -1,6 +1,28 @@
|
|||
#include "lanlistitem.h"
|
||||
|
||||
LanListItem::LanListItem(QWidget *parent) : ListItem(parent)
|
||||
LanListItem::LanListItem(KyConnectItem *data, QWidget *parent) : ListItem(parent)
|
||||
{
|
||||
|
||||
m_data = data;
|
||||
}
|
||||
|
||||
void LanListItem::initLanUI()
|
||||
{
|
||||
this->setName(m_data->m_connectName);
|
||||
}
|
||||
|
||||
void LanListItem::refreshIcon()
|
||||
{
|
||||
// if (m_data->m_connectState) //ZJP_TODO
|
||||
}
|
||||
|
||||
void LanListItem::onInfoButtonClicked()
|
||||
{
|
||||
//ZJP_TODO 呼出有线详情页
|
||||
qDebug() << "On lan info button clicked! name = " << m_data->m_connectName << "; uuid = " << m_data->m_connectUuid << "." <<Q_FUNC_INFO << __LINE__;
|
||||
}
|
||||
|
||||
void LanListItem::onNetButtonClicked()
|
||||
{
|
||||
//ZJP_TODO 点击连接/断开
|
||||
qDebug() << "On lan clicked! name = " << m_data->m_connectName << "; uuid = " << m_data->m_connectUuid << "." <<Q_FUNC_INFO << __LINE__;
|
||||
}
|
||||
|
|
|
@ -1,15 +1,26 @@
|
|||
#ifndef LANLISTITEM_H
|
||||
#define LANLISTITEM_H
|
||||
#include "listitem.h"
|
||||
#include "kylinconnectitem.h"
|
||||
|
||||
class LanListItem : public ListItem
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
LanListItem(QWidget *parent = nullptr);
|
||||
LanListItem(KyConnectItem *data, QWidget *parent = nullptr);
|
||||
~LanListItem() = default;
|
||||
protected:
|
||||
|
||||
private:
|
||||
KyConnectItem * m_data = nullptr;
|
||||
|
||||
private:
|
||||
void initLanUI();
|
||||
void refreshIcon();
|
||||
|
||||
private slots:
|
||||
void onInfoButtonClicked();
|
||||
void onNetButtonClicked();
|
||||
};
|
||||
|
||||
#endif // LANLISTITEM_H
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#include "listitem.h"
|
||||
#include <QEvent>
|
||||
|
||||
#define MAIN_LAYOUT_MARGINS 0,0,0,0
|
||||
#define MAIN_LAYOUT_SPACING 0
|
||||
|
@ -8,6 +9,7 @@
|
|||
ListItem::ListItem(QWidget *parent) : QFrame(parent)
|
||||
{
|
||||
initUI();
|
||||
initConnection();
|
||||
}
|
||||
|
||||
ListItem::~ListItem()
|
||||
|
@ -19,6 +21,15 @@ ListItem::~ListItem()
|
|||
m_infoButton = NULL;
|
||||
}
|
||||
|
||||
bool ListItem::eventFilter(QObject *watched, QEvent *event)
|
||||
{
|
||||
if (watched == this) {
|
||||
if (event->type() == QEvent::MouseButtonPress) {
|
||||
this->onNetButtonClicked();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ListItem::setName(const QString &name)
|
||||
{
|
||||
m_nameLabel->setText(name);
|
||||
|
@ -48,3 +59,19 @@ void ListItem::initUI()
|
|||
|
||||
m_mainLayout->addWidget(m_itemFrame);
|
||||
}
|
||||
|
||||
void ListItem::initConnection()
|
||||
{
|
||||
connect(this->m_netButton, &NetButton::clicked, this, &ListItem::onNetButtonClicked);
|
||||
connect(this->m_infoButton, &InfoButton::clicked, this, &ListItem::onInfoButtonClicked);
|
||||
}
|
||||
|
||||
void ListItem::onInfoButtonClicked()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void ListItem::onNetButtonClicked()
|
||||
{
|
||||
|
||||
}
|
||||
|
|
|
@ -13,6 +13,9 @@ public:
|
|||
~ListItem();
|
||||
void setName(const QString &name);
|
||||
|
||||
protected:
|
||||
bool eventFilter(QObject *watched, QEvent *event);
|
||||
|
||||
protected:
|
||||
QVBoxLayout * m_mainLayout = nullptr;
|
||||
QFrame * m_itemFrame = nullptr;
|
||||
|
@ -23,6 +26,11 @@ protected:
|
|||
|
||||
private:
|
||||
void initUI();
|
||||
void initConnection();
|
||||
|
||||
protected slots:
|
||||
virtual void onInfoButtonClicked();
|
||||
virtual void onNetButtonClicked();
|
||||
};
|
||||
|
||||
#endif // LISTITEM_H
|
||||
|
|
|
@ -1,6 +1,62 @@
|
|||
#include "wlanlistitem.h"
|
||||
|
||||
WlanListItem::WlanListItem(QWidget *parent) : ListItem(parent)
|
||||
WlanListItem::WlanListItem(KyWirelessNetItem *data, QWidget *parent) : ListItem(parent)
|
||||
{
|
||||
|
||||
m_data = data;
|
||||
initWlanUI();
|
||||
}
|
||||
|
||||
void WlanListItem::setWlanSignal(const int &signal)
|
||||
{
|
||||
m_data->m_signalStrength = signal;
|
||||
refreshIcon();
|
||||
}
|
||||
|
||||
void WlanListItem::setWlanState(const int &state)
|
||||
{
|
||||
// m_data->m_state = state; //ZJP_TODO 后端接口待补全
|
||||
refreshIcon();
|
||||
}
|
||||
|
||||
void WlanListItem::initWlanUI()
|
||||
{
|
||||
//设置显示的Wlan名称
|
||||
this->setName(m_data->m_connName);
|
||||
//刷新左侧按钮图标
|
||||
refreshIcon();
|
||||
}
|
||||
|
||||
void WlanListItem::refreshIcon()
|
||||
{
|
||||
// if (m_data->m_state) //ZJP_TODO 连接中、已连接、未连接的处理,要单独写逻辑,后端接口待补全
|
||||
if (m_data->m_secuType.isEmpty() ||m_data->m_secuType == "") {
|
||||
//ZJP_TODO 无加密 注意信号格数计算方式,可能需要修改
|
||||
switch (m_data->m_signalStrength / 25 + 1) {
|
||||
case 5:
|
||||
case 4:
|
||||
break;
|
||||
case 3:
|
||||
break;
|
||||
case 2:
|
||||
break;
|
||||
case 1:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
//ZJP_TODO 有加密
|
||||
}
|
||||
}
|
||||
|
||||
void WlanListItem::onInfoButtonClicked()
|
||||
{
|
||||
//ZJP_TODO 呼出无线详情页
|
||||
qDebug() << "On wlan info button clicked! ssid = " << m_data->m_NetSsid << "; name = " << m_data->m_connName << "." <<Q_FUNC_INFO << __LINE__;
|
||||
}
|
||||
|
||||
void WlanListItem::onNetButtonClicked()
|
||||
{
|
||||
//ZJP_TODO 点击连接/断开
|
||||
qDebug() << "On wlan clicked! ssid = " << m_data->m_NetSsid << "; name = " << m_data->m_connName << "." <<Q_FUNC_INFO << __LINE__;
|
||||
}
|
||||
|
|
|
@ -1,15 +1,30 @@
|
|||
#ifndef WLANLISTITEM_H
|
||||
#define WLANLISTITEM_H
|
||||
#include "listitem.h"
|
||||
#include "kywirelessnetitem.h"
|
||||
|
||||
class WlanListItem : public ListItem
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
WlanListItem(QWidget *parent = nullptr);
|
||||
WlanListItem(KyWirelessNetItem *data, QWidget *parent = nullptr);
|
||||
~WlanListItem() = default;
|
||||
protected:
|
||||
|
||||
public:
|
||||
void setWlanSignal(const int &signal);
|
||||
void setWlanState(const int &state);
|
||||
|
||||
private:
|
||||
void initWlanUI();
|
||||
void initWlanConnection();
|
||||
void refreshIcon();
|
||||
|
||||
private:
|
||||
KyWirelessNetItem * m_data = nullptr;
|
||||
|
||||
private slots:
|
||||
void onInfoButtonClicked();
|
||||
void onNetButtonClicked();
|
||||
};
|
||||
|
||||
#endif // WLANLISTITEM_H
|
||||
|
|
|
@ -39,6 +39,7 @@ void NetButton::setReleased()
|
|||
void NetButton::setButtonIcon(QIcon *icon)
|
||||
{
|
||||
if (!icon) { return; }
|
||||
//ZJP_TODO 绘制圆形按钮
|
||||
m_iconLabel->setPixmap(icon->pixmap(this->size()));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue