Merge branch '0823-new-fe' into 'dbus-interface'

Feature: Abstract class - TabPage.

See merge request kylin-desktop/kylin-nm!183
This commit is contained in:
ren peijia 2021-08-23 02:45:21 +00:00
commit 18090fc803
7 changed files with 168 additions and 243 deletions

View File

@ -1,94 +1,13 @@
#include "lanpage.h"
#define MAIN_LAYOUT_MARGINS 0,0,0,0
#define MAIN_LAYOUT_SPACING 0
#define TITLE_FRAME_HEIGHT 52
#define TITLE_LAYOUT_MARGINS 24,0,0,0
#define LAN_LAYOUT_MARGINS 8,8,8,8
#define LAN_LAYOUT_SPACING 8
#define LAN_LIST_SPACING 2
#define TEXT_MARGINS 16,0,0,0
//#define SCROLL_AREA_HEIGHT 200
#define SETTINGS_LAYOUT_MARGINS 24,16,24,16
LanPage::LanPage(QWidget *parent) : QWidget(parent)
LanPage::LanPage(QWidget *parent) : TabPage(parent)
{
initUI();
initLanUI();
}
LanPage::~LanPage()
void LanPage::initLanUI()
{
delete m_titleDivider;
delete m_activatedLanDivider;
delete m_inactivatedLanDivider;
}
void LanPage::initUI()
{
m_mainLayout = new QVBoxLayout(this);
m_mainLayout->setContentsMargins(MAIN_LAYOUT_MARGINS);
m_mainLayout->setSpacing(MAIN_LAYOUT_SPACING);
this->setLayout(m_mainLayout);
m_titleFrame = new QFrame(this);
m_titleFrame->setFixedHeight(TITLE_FRAME_HEIGHT);
m_titleLayout = new QHBoxLayout(m_titleFrame);
m_titleLayout->setContentsMargins(TITLE_LAYOUT_MARGINS);
m_titleLabel = new QLabel(m_titleFrame);
m_titleLabel->setText(tr("LAN"));
m_lanSwitch = new SwitchButton(m_titleFrame);
m_titleLayout->addWidget(m_titleLabel);
m_titleLayout->addStretch();
m_titleLayout->addWidget(m_lanSwitch);
m_titleDivider = new Divider(this);
m_activatedLanFrame = new QFrame(this);
m_activatedLanLayout = new QVBoxLayout(m_activatedLanFrame);
m_activatedLanLayout->setContentsMargins(LAN_LAYOUT_MARGINS);
m_activatedLanLayout->setSpacing(LAN_LAYOUT_SPACING);
m_activatedLanLabel = new QLabel(m_activatedLanFrame);
m_activatedLanLabel->setContentsMargins(TEXT_MARGINS);
m_activatedLanLabel->setText(tr("Activated LAN"));
m_activatedLanListWidget = new QListWidget(m_activatedLanFrame);
m_activatedLanListWidget->setContentsMargins(MAIN_LAYOUT_MARGINS);
m_activatedLanListWidget->setSpacing(LAN_LIST_SPACING);
m_activatedLanLayout->addWidget(m_activatedLanLabel);
m_activatedLanLayout->addWidget(m_activatedLanListWidget);
m_activatedLanDivider = new Divider(this);
m_inactivatedLanFrame = new QFrame(this);
m_inactivatedLanLayout = new QVBoxLayout(m_inactivatedLanFrame);
m_inactivatedLanLayout->setContentsMargins(LAN_LAYOUT_MARGINS);
m_inactivatedLanLayout->setSpacing(LAN_LAYOUT_SPACING);
m_inactivatedLanFrame->setLayout(m_inactivatedLanLayout);
m_inactivatedLanLabel = new QLabel(m_inactivatedLanFrame);
m_inactivatedLanLabel->setContentsMargins(TEXT_MARGINS);
m_inactivatedLanLabel->setText(tr("Inactivated LAN"));
m_inactivatedLanListArea = new QScrollArea(m_inactivatedLanFrame);
m_inactivatedLanListWidget = new QListWidget(m_inactivatedLanListArea);
m_inactivatedLanListArea->setWidget(m_inactivatedLanListWidget);
m_inactivatedLanListArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
m_inactivatedLanListArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
m_inactivatedLanListWidget->setContentsMargins(MAIN_LAYOUT_MARGINS);
m_inactivatedLanListWidget->setSpacing(LAN_LIST_SPACING);
// m_inactivated_lan_list_area->setFixedHeight(SCROLL_AREA_HEIGHT);
m_inactivatedLanLayout->addWidget(m_inactivatedLanLabel);
m_inactivatedLanLayout->addWidget(m_inactivatedLanListArea);
m_inactivatedLanDivider = new Divider(this);
m_settingsFrame = new QFrame(this);
m_settingsLayout = new QHBoxLayout(m_settingsFrame);
m_settingsLayout->setContentsMargins(SETTINGS_LAYOUT_MARGINS);
m_settingsLabel = new QLabel(m_settingsFrame);
m_settingsLabel->setText(tr("Settings"));
m_settingsLayout->addWidget(m_settingsLabel);
m_settingsFrame->setLayout(m_settingsLayout);
m_mainLayout->addWidget(m_titleFrame);
m_mainLayout->addWidget(m_titleDivider);
m_mainLayout->addWidget(m_activatedLanFrame);
m_mainLayout->addWidget(m_activatedLanDivider);
m_mainLayout->addWidget(m_inactivatedLanFrame);
m_mainLayout->addWidget(m_inactivatedLanDivider);
m_mainLayout->addWidget(m_settingsFrame);
m_activatedNetLabel->setText(tr("Activated LAN"));
m_inactivatedNetLabel->setText(tr("Inactivated LAN"));
}

View File

@ -1,48 +1,19 @@
#ifndef LANPAGE_H
#define LANPAGE_H
#include "divider.h"
#include "switchbutton.h"
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QLabel>
#include <QScrollArea>
#include <QListWidget>
#include "tabpage.h"
class LanPage : public QWidget
class LanPage : public TabPage
{
Q_OBJECT
public:
explicit LanPage(QWidget *parent = nullptr);
~LanPage();
~LanPage()=default;
signals:
private:
void initUI();
QVBoxLayout * m_mainLayout = nullptr;
QFrame * m_titleFrame = nullptr;
QHBoxLayout * m_titleLayout = nullptr;
QLabel * m_titleLabel = nullptr;
SwitchButton * m_lanSwitch = nullptr;
Divider * m_titleDivider = nullptr;
QFrame * m_activatedLanFrame = nullptr;
QVBoxLayout * m_activatedLanLayout = nullptr;
QLabel * m_activatedLanLabel = nullptr;
QListWidget * m_activatedLanListWidget = nullptr;
Divider * m_activatedLanDivider = nullptr;
QFrame * m_inactivatedLanFrame = nullptr;
QVBoxLayout * m_inactivatedLanLayout = nullptr;
QLabel * m_inactivatedLanLabel = nullptr;
QScrollArea * m_inactivatedLanListArea = nullptr;
QListWidget * m_inactivatedLanListWidget = nullptr;
Divider * m_inactivatedLanDivider = nullptr;
QFrame * m_settingsFrame = nullptr;
QHBoxLayout * m_settingsLayout = nullptr;
QLabel * m_settingsLabel = nullptr;
void initLanUI();
};
#endif // LANPAGE_H

View File

@ -2,9 +2,11 @@ INCLUDEPATH += $$PWD
HEADERS += \
$$PWD/lanpage.h \
$$PWD/wlanpage.h
$$PWD/wlanpage.h \
$$PWD/tabpage.h
SOURCES += \
$$PWD/lanpage.cpp \
$$PWD/wlanpage.cpp
$$PWD/wlanpage.cpp \
$$PWD/tabpage.cpp

View File

@ -0,0 +1,80 @@
#include "tabpage.h"
TabPage::TabPage(QWidget *parent) : QWidget(parent)
{
initUI();
}
TabPage::~TabPage()
{
delete m_titleDivider;
delete m_activatedNetDivider;
delete m_inactivatedNetDivider;
}
void TabPage::initUI()
{
m_mainLayout = new QVBoxLayout(this);
m_mainLayout->setContentsMargins(MAIN_LAYOUT_MARGINS);
m_mainLayout->setSpacing(MAIN_LAYOUT_SPACING);
this->setLayout(m_mainLayout);
m_titleFrame = new QFrame(this);
m_titleFrame->setFixedHeight(TITLE_FRAME_HEIGHT);
m_titleLayout = new QHBoxLayout(m_titleFrame);
m_titleLayout->setContentsMargins(TITLE_LAYOUT_MARGINS);
m_titleLabel = new QLabel(m_titleFrame);
m_netSwitch = new SwitchButton(m_titleFrame);
m_titleLayout->addWidget(m_titleLabel);
m_titleLayout->addStretch();
m_titleLayout->addWidget(m_netSwitch);
m_titleDivider = new Divider(this);
m_activatedNetFrame = new QFrame(this);
m_activatedNetLayout = new QVBoxLayout(m_activatedNetFrame);
m_activatedNetLayout->setContentsMargins(NET_LAYOUT_MARGINS);
m_activatedNetLayout->setSpacing(NET_LAYOUT_SPACING);
m_activatedNetLabel = new QLabel(m_activatedNetFrame);
m_activatedNetLabel->setContentsMargins(TEXT_MARGINS);
m_activatedNetListWidget = new QListWidget(m_activatedNetFrame);
m_activatedNetListWidget->setContentsMargins(MAIN_LAYOUT_MARGINS);
m_activatedNetListWidget->setSpacing(NET_LIST_SPACING);
m_activatedNetLayout->addWidget(m_activatedNetLabel);
m_activatedNetLayout->addWidget(m_activatedNetListWidget);
m_activatedNetDivider = new Divider(this);
m_inactivatedNetFrame = new QFrame(this);
m_inactivatedNetLayout = new QVBoxLayout(m_inactivatedNetFrame);
m_inactivatedNetLayout->setContentsMargins(NET_LAYOUT_MARGINS);
m_inactivatedNetLayout->setSpacing(NET_LAYOUT_SPACING);
m_inactivatedNetFrame->setLayout(m_inactivatedNetLayout);
m_inactivatedNetLabel = new QLabel(m_inactivatedNetFrame);
m_inactivatedNetLabel->setContentsMargins(TEXT_MARGINS);
m_inactivatedNetListArea = new QScrollArea(m_inactivatedNetFrame);
m_inactivatedNetListWidget = new QListWidget(m_inactivatedNetListArea);
m_inactivatedNetListArea->setWidget(m_inactivatedNetListWidget);
m_inactivatedNetListArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
m_inactivatedNetListArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
m_inactivatedNetListWidget->setContentsMargins(MAIN_LAYOUT_MARGINS);
m_inactivatedNetListWidget->setSpacing(NET_LIST_SPACING);
// m_inactivated_Net_list_area->setFixedHeight(SCROLL_AREA_HEIGHT);
m_inactivatedNetLayout->addWidget(m_inactivatedNetLabel);
m_inactivatedNetLayout->addWidget(m_inactivatedNetListArea);
m_inactivatedNetDivider = new Divider(this);
m_settingsFrame = new QFrame(this);
m_settingsLayout = new QHBoxLayout(m_settingsFrame);
m_settingsLayout->setContentsMargins(SETTINGS_LAYOUT_MARGINS);
m_settingsLabel = new QLabel(m_settingsFrame);
m_settingsLabel->setText(tr("Settings"));
m_settingsLayout->addWidget(m_settingsLabel);
m_settingsFrame->setLayout(m_settingsLayout);
m_mainLayout->addWidget(m_titleFrame);
m_mainLayout->addWidget(m_titleDivider);
m_mainLayout->addWidget(m_activatedNetFrame);
m_mainLayout->addWidget(m_activatedNetDivider);
m_mainLayout->addWidget(m_inactivatedNetFrame);
m_mainLayout->addWidget(m_inactivatedNetDivider);
m_mainLayout->addWidget(m_settingsFrame);
}

View File

@ -0,0 +1,60 @@
#ifndef TABPAGE_H
#define TABPAGE_H
#include "divider.h"
#include "switchbutton.h"
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QLabel>
#include <QScrollArea>
#include <QListWidget>
#define MAIN_LAYOUT_MARGINS 0,0,0,0
#define MAIN_LAYOUT_SPACING 0
#define TITLE_FRAME_HEIGHT 52
#define TITLE_LAYOUT_MARGINS 24,0,0,0
#define NET_LAYOUT_MARGINS 8,8,8,8
#define NET_LAYOUT_SPACING 8
#define NET_LIST_SPACING 2
#define TEXT_MARGINS 16,0,0,0
//#define SCROLL_AREA_HEIGHT 200
#define SETTINGS_LAYOUT_MARGINS 24,16,24,16
class TabPage : public QWidget
{
Q_OBJECT
public:
explicit TabPage(QWidget *parent = nullptr);
~TabPage();
signals:
protected:
void initUI();
QVBoxLayout * m_mainLayout = nullptr;
QFrame * m_titleFrame = nullptr;
QHBoxLayout * m_titleLayout = nullptr;
QLabel * m_titleLabel = nullptr;
SwitchButton * m_netSwitch = nullptr;
Divider * m_titleDivider = nullptr;
QFrame * m_activatedNetFrame = nullptr;
QVBoxLayout * m_activatedNetLayout = nullptr;
QLabel * m_activatedNetLabel = nullptr;
QListWidget * m_activatedNetListWidget = nullptr;
Divider * m_activatedNetDivider = nullptr;
QFrame * m_inactivatedNetFrame = nullptr;
QVBoxLayout * m_inactivatedNetLayout = nullptr;
QLabel * m_inactivatedNetLabel = nullptr;
QScrollArea * m_inactivatedNetListArea = nullptr;
QListWidget * m_inactivatedNetListWidget = nullptr;
Divider * m_inactivatedNetDivider = nullptr;
QFrame * m_settingsFrame = nullptr;
QHBoxLayout * m_settingsLayout = nullptr;
QLabel * m_settingsLabel = nullptr;
};
#endif // TABPAGE_H

View File

@ -1,27 +1,9 @@
#include "wlanpage.h"
#include <QEvent>
#define MAIN_LAYOUT_MARGINS 0,0,0,0
#define MAIN_LAYOUT_SPACING 0
#define TITLE_FRAME_HEIGHT 52
#define TITLE_LAYOUT_MARGINS 24,0,0,0
#define LAN_LAYOUT_MARGINS 8,8,8,8
#define LAN_LAYOUT_SPACING 8
#define LAN_LIST_SPACING 2
#define TEXT_MARGINS 16,0,0,0
//#define SCROLL_AREA_HEIGHT 200
#define SETTINGS_LAYOUT_MARGINS 24,16,24,16
WlanPage::WlanPage(QWidget *parent) : QWidget(parent)
WlanPage::WlanPage(QWidget *parent) : TabPage(parent)
{
initUI();
}
WlanPage::~WlanPage()
{
delete m_titleDivider;
delete m_activatedWlanDivider;
delete m_inactivatedWlanDivider;
initWlanUI();
}
bool WlanPage::eventFilter(QObject *w, QEvent *e)
@ -36,58 +18,21 @@ bool WlanPage::eventFilter(QObject *w, QEvent *e)
return QWidget::eventFilter(w,e);
}
void WlanPage::initUI()
void WlanPage::initWlanUI()
{
m_mainLayout = new QVBoxLayout(this);
m_mainLayout->setContentsMargins(MAIN_LAYOUT_MARGINS);
m_mainLayout->setSpacing(MAIN_LAYOUT_SPACING);
this->setLayout(m_mainLayout);
m_titleFrame = new QFrame(this);
m_titleFrame->setFixedHeight(TITLE_FRAME_HEIGHT);
m_titleLayout = new QHBoxLayout(m_titleFrame);
m_titleLayout->setContentsMargins(TITLE_LAYOUT_MARGINS);
m_titleLabel = new QLabel(m_titleFrame);
m_titleLabel->setText(tr("WLAN"));
m_lanSwitch = new SwitchButton(m_titleFrame);
m_titleLayout->addWidget(m_titleLabel);
m_titleLayout->addStretch();
m_titleLayout->addWidget(m_lanSwitch);
m_titleDivider = new Divider(this);
m_activatedNetLabel->setText(tr("Activated WLAN"));
m_inactivatedNetLabel->setText(tr("Inactivated WLAN"));
m_activatedWlanFrame = new QFrame(this);
m_activatedWlanLayout = new QVBoxLayout(m_activatedWlanFrame);
m_activatedWlanLayout->setContentsMargins(LAN_LAYOUT_MARGINS);
m_activatedWlanLayout->setSpacing(LAN_LAYOUT_SPACING);
m_activatedWlanLabel = new QLabel(m_activatedWlanFrame);
m_activatedWlanLabel->setContentsMargins(TEXT_MARGINS);
m_activatedWlanLabel->setText(tr("Activated WLAN"));
m_activatedWlanListWidget = new QListWidget(m_activatedWlanFrame);
m_activatedWlanListWidget->setContentsMargins(MAIN_LAYOUT_MARGINS);
m_activatedWlanListWidget->setSpacing(LAN_LIST_SPACING);
m_activatedWlanLayout->addWidget(m_activatedWlanLabel);
m_activatedWlanLayout->addWidget(m_activatedWlanListWidget);
m_activatedWlanDivider = new Divider(this);
m_inactivatedWlanFrame = new QFrame(this);
m_inactivatedWlanLayout = new QVBoxLayout(m_inactivatedWlanFrame);
m_inactivatedWlanLayout->setContentsMargins(LAN_LAYOUT_MARGINS);
m_inactivatedWlanLayout->setSpacing(LAN_LAYOUT_SPACING);
m_inactivatedWlanFrame->setLayout(m_inactivatedWlanLayout);
m_inactivatedWlanLabel = new QLabel(m_inactivatedWlanFrame);
m_inactivatedWlanLabel->setContentsMargins(TEXT_MARGINS);
m_inactivatedWlanLabel->setText(tr("Inactivated WLAN"));
m_inactivatedWlanListArea = new QScrollArea(m_inactivatedWlanFrame);
m_inactivatedWlanListArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
m_inactivatedWlanListArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
m_inactivatedWlanListAreaCentralWidget = new QFrame(m_inactivatedWlanListArea);
m_inactivatedWlanListArea->setWidget(m_inactivatedWlanListAreaCentralWidget);
//一些独有控件
m_inactivatedWlanListAreaCentralWidget = new QFrame(m_inactivatedNetListArea);
m_inactivatedNetListArea->setWidget(m_inactivatedWlanListAreaCentralWidget);
m_inactivatedWlanListAreaLayout = new QVBoxLayout(m_inactivatedWlanListAreaCentralWidget);
m_inactivatedWlanListAreaCentralWidget->setLayout(m_inactivatedWlanListAreaLayout);
m_inactivatedWlanListAreaLayout->setContentsMargins(MAIN_LAYOUT_MARGINS);
m_inactivatedWlanListWidget = new QListWidget(m_inactivatedWlanListAreaCentralWidget);
m_inactivatedWlanListWidget->setContentsMargins(MAIN_LAYOUT_MARGINS);
m_inactivatedWlanListWidget->setSpacing(LAN_LIST_SPACING);
m_inactivatedNetListWidget = new QListWidget(m_inactivatedWlanListAreaCentralWidget);
m_inactivatedNetListWidget->setContentsMargins(MAIN_LAYOUT_MARGINS);
m_inactivatedNetListWidget->setSpacing(NET_LIST_SPACING);
m_hiddenWlanWidget = new QFrame(m_inactivatedWlanListAreaCentralWidget);
m_hiddenWlanLayout = new QHBoxLayout(m_hiddenWlanWidget);
m_hiddenWlanLayout->setContentsMargins(MAIN_LAYOUT_MARGINS);
@ -95,27 +40,4 @@ void WlanPage::initUI()
m_hiddenWlanLabel->setText(tr("More..."));
m_hiddenWlanLayout->addWidget(m_hiddenWlanLabel);
m_hiddenWlanLayout->addStretch();
m_inactivatedWlanListAreaLayout->addWidget(m_inactivatedWlanListWidget);
m_inactivatedWlanListAreaLayout->addWidget(m_hiddenWlanWidget);
// m_inactivated_lan_list_area->setFixedHeight(SCROLL_AREA_HEIGHT);
m_inactivatedWlanLayout->addWidget(m_inactivatedWlanLabel);
m_inactivatedWlanLayout->addWidget(m_inactivatedWlanListArea);
m_inactivatedWlanDivider = new Divider(this);
m_settingsFrame = new QFrame(this);
m_settingsLayout = new QHBoxLayout(m_settingsFrame);
m_settingsLayout->setContentsMargins(SETTINGS_LAYOUT_MARGINS);
m_settingsLabel = new QLabel(m_settingsFrame);
m_settingsLabel->setText(tr("Settings"));
m_settingsLayout->addWidget(m_settingsLabel);
m_settingsFrame->setLayout(m_settingsLayout);
m_mainLayout->addWidget(m_titleFrame);
m_mainLayout->addWidget(m_titleDivider);
m_mainLayout->addWidget(m_activatedWlanFrame);
m_mainLayout->addWidget(m_activatedWlanDivider);
m_mainLayout->addWidget(m_inactivatedWlanFrame);
m_mainLayout->addWidget(m_inactivatedWlanDivider);
m_mainLayout->addWidget(m_settingsFrame);
}

View File

@ -1,20 +1,14 @@
#ifndef WLANPAGE_H
#define WLANPAGE_H
#include "divider.h"
#include "switchbutton.h"
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QLabel>
#include <QScrollArea>
#include <QListWidget>
#include "tabpage.h"
class WlanPage : public QWidget
class WlanPage : public TabPage
{
Q_OBJECT
public:
explicit WlanPage(QWidget *parent = nullptr);
~WlanPage();
~WlanPage() = default;
signals:
@ -22,35 +16,12 @@ protected:
bool eventFilter(QObject *watched, QEvent *event);
private:
void initUI();
QVBoxLayout * m_mainLayout = nullptr;
QFrame * m_titleFrame = nullptr;
QHBoxLayout * m_titleLayout = nullptr;
QLabel * m_titleLabel = nullptr;
SwitchButton * m_lanSwitch = nullptr;
Divider * m_titleDivider = nullptr;
QFrame * m_activatedWlanFrame = nullptr;
QVBoxLayout * m_activatedWlanLayout = nullptr;
QLabel *m_activatedWlanLabel = nullptr;
QListWidget * m_activatedWlanListWidget = nullptr;
Divider * m_activatedWlanDivider = nullptr;
QFrame * m_inactivatedWlanFrame = nullptr;
QVBoxLayout * m_inactivatedWlanLayout = nullptr;
QLabel * m_inactivatedWlanLabel = nullptr;
QScrollArea * m_inactivatedWlanListArea = nullptr;
void initWlanUI();
QFrame * m_inactivatedWlanListAreaCentralWidget = nullptr;
QVBoxLayout * m_inactivatedWlanListAreaLayout = nullptr;
QListWidget * m_inactivatedWlanListWidget = nullptr;
QFrame * m_hiddenWlanWidget = nullptr;
QHBoxLayout * m_hiddenWlanLayout = nullptr;
QLabel * m_hiddenWlanLabel = nullptr;
Divider * m_inactivatedWlanDivider = nullptr;
QFrame * m_settingsFrame = nullptr;
QHBoxLayout * m_settingsLayout = nullptr;
QLabel * m_settingsLabel = nullptr;
};
#endif // WLANPAGE_H