Merge branch '0816-new-frontend' into 'dbus-interface'

Add list item class.

See merge request kylin-desktop/kylin-nm!164
This commit is contained in:
ren peijia 2021-08-17 07:27:13 +00:00
commit 7e1ada1dc5
7 changed files with 111 additions and 5 deletions

View File

@ -0,0 +1,6 @@
#include "lanlistitem.h"
LanListItem::LanListItem(QWidget *parent) : ListItem(parent)
{
}

View File

@ -0,0 +1,15 @@
#ifndef LANLISTITEM_H
#define LANLISTITEM_H
#include "listitem.h"
class LanListItem : public ListItem
{
Q_OBJECT
public:
LanListItem(QWidget *parent = nullptr);
~LanListItem() = default;
protected:
};
#endif // LANLISTITEM_H

View File

@ -5,12 +5,16 @@ FORMS += \
$$PWD/onelancform.ui
HEADERS += \
$$PWD/lanlistitem.h \
$$PWD/listitem.h \
$$PWD/oneconnform.h \
$$PWD/onelancform.h
$$PWD/onelancform.h \
$$PWD/wlanlistitem.h
SOURCES += \
$$PWD/lanlistitem.cpp \
$$PWD/listitem.cpp \
$$PWD/oneconnform.cpp \
$$PWD/onelancform.cpp
$$PWD/onelancform.cpp \
$$PWD/wlanlistitem.cpp

View File

@ -1,6 +1,50 @@
#include "listitem.h"
ListItem::ListItem()
{
#define MAIN_LAYOUT_MARGINS 0,0,0,0
#define MAIN_LAYOUT_SPACING 0
#define ITEM_FRAME_MARGINS 16,6,16,6
#define ITEM_FRAME_SPACING 10
ListItem::ListItem(QWidget *parent) : QFrame(parent)
{
initUI();
}
ListItem::~ListItem()
{
delete m_netButton;
m_netButton = NULL;
delete m_infoButton;
m_infoButton = NULL;
}
void ListItem::setName(const QString &name)
{
m_nameLabel->setText(name);
}
void ListItem::initUI()
{
m_mainLayout = new QVBoxLayout(this);
m_mainLayout->setContentsMargins(MAIN_LAYOUT_MARGINS);
m_mainLayout->setSpacing(MAIN_LAYOUT_SPACING);
this->setLayout(m_mainLayout);
m_itemFrame = new QFrame(this);
m_hItemLayout = new QHBoxLayout(m_itemFrame);
m_hItemLayout->setContentsMargins(ITEM_FRAME_MARGINS);
m_hItemLayout->setSpacing(ITEM_FRAME_SPACING);
m_netButton = new NetButton(m_itemFrame);
m_nameLabel = new QLabel(m_itemFrame);
m_infoButton = new InfoButton(m_itemFrame);
m_hItemLayout->addWidget(m_netButton);
m_hItemLayout->addWidget(m_nameLabel);
m_hItemLayout->addStretch();
m_hItemLayout->addWidget(m_infoButton);
m_mainLayout->addWidget(m_itemFrame);
}

View File

@ -1,12 +1,28 @@
#ifndef LISTITEM_H
#define LISTITEM_H
#include <QFrame>
#include <QHBoxLayout>
#include "netbutton.h"
#include "infobutton.h"
class ListItem : public QFrame
{
Q_OBJECT
public:
ListItem();
ListItem(QWidget *parent = nullptr);
~ListItem();
void setName(const QString &name);
protected:
QVBoxLayout * m_mainLayout = nullptr;
QFrame * m_itemFrame = nullptr;
QHBoxLayout * m_hItemLayout = nullptr;
NetButton * m_netButton = nullptr;
QLabel * m_nameLabel = nullptr;
InfoButton * m_infoButton = nullptr;
private:
void initUI();
};
#endif // LISTITEM_H

View File

@ -0,0 +1,6 @@
#include "wlanlistitem.h"
WlanListItem::WlanListItem(QWidget *parent) : ListItem(parent)
{
}

View File

@ -0,0 +1,15 @@
#ifndef WLANLISTITEM_H
#define WLANLISTITEM_H
#include "listitem.h"
class WlanListItem : public ListItem
{
Q_OBJECT
public:
WlanListItem(QWidget *parent = nullptr);
~WlanListItem() = default;
protected:
};
#endif // WLANLISTITEM_H