Merge branch '1012' into 'dbus-interface'

bug#83296

See merge request kylin-desktop/kylin-nm!325
This commit is contained in:
ren peijia 2021-10-15 07:51:08 +00:00
commit fda671327f
9 changed files with 170 additions and 79 deletions

View File

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

View File

@ -1,16 +0,0 @@
#ifndef DETAILITEM_H
#define DETAILITEM_H
#include <QWidget>
class DetailItem : public QWidget
{
Q_OBJECT
public:
explicit DetailItem(QWidget *parent = nullptr);
signals:
};
#endif // DETAILITEM_H

View File

@ -1,5 +1,6 @@
#include "detailpage.h" #include "detailpage.h"
#include <QPainter> #include <QPainter>
#include <QListWidget>
extern void qt_blurImage(QImage &blurImage, qreal radius, bool quality, int transposed); extern void qt_blurImage(QImage &blurImage, qreal radius, bool quality, int transposed);
@ -73,68 +74,78 @@ bool DetailPage::checkIsChanged(const ConInfo info)
} }
} }
void DetailPage::addDetailItem(QListWidget *listWidget, DetailWidget *detailWidget)
{
QListWidgetItem *listWidgetItem = new QListWidgetItem(listWidget);
listWidgetItem->setSizeHint(QSize(listWidget->width(),36));
listWidgetItem->setFlags(Qt::NoItemFlags);
listWidget->addItem(listWidgetItem);
listWidget->setItemWidget(listWidgetItem, detailWidget);
}
void DetailPage::initUI() { void DetailPage::initUI() {
forgetNetBox = new QCheckBox(this); forgetNetBox = new QCheckBox(this);
layout = new QVBoxLayout(this); layout = new QVBoxLayout(this);
layout->setContentsMargins(0,0,0,0);
mDetailLayout = new QFormLayout(this); QWidget *mDetailFrame = new QFrame(this);
mDetailLayout = new QVBoxLayout(mDetailFrame);
mDetailLayout->setContentsMargins(0,0,0,0);
m_listWidget = new QListWidget(mDetailFrame);
m_listWidget->setFrameShape(QFrame::Shape::NoFrame);
m_listWidget->setBackgroundRole(QPalette::Base);
m_listWidget->setFocusPolicy(Qt::FocusPolicy::NoFocus);
mDetailLayout->addWidget(m_listWidget);
mSSID = new QLineEdit(this); mSSID = new QLineEdit(this);
mSSID->setAlignment(Qt::AlignRight); mSSID->setAlignment(Qt::AlignRight);
if (!isCreate) { if (!isCreate) {
mSSID->setStyleSheet("background:transparent;border-width:0;border-style:outset"); mSSID->setStyleSheet("background:transparent;border-width:0px;border-style:none");
mSSID->setFocusPolicy(Qt::NoFocus); mSSID->setFocusPolicy(Qt::NoFocus);
} else { } else {
mSSID->setStyleSheet("border-width:0;border-style:outset"); // mSSID->setStyleSheet("border-width:1px;;border-style:solid;border-color:black;border-radius:2px");
mSSID->setStyleSheet("border-top:0px solid;border-bottom:1px solid;border-left:0px solid;border-right: 0px solid;");
mSSID->setPlaceholderText(tr("Please input SSID:"));
} }
QHBoxLayout *mSsidLayout = new QHBoxLayout(this); m_ssidWidget = new DetailWidget(qobject_cast<QWidget *>(mSSID), m_listWidget);
mSsidLayout->addStretch(); m_ssidWidget->setKey(tr("SSID:"));
mSsidLayout->addWidget(mSSID);
mProtocol = new QLabel(this); mProtocol = new QLabel(this);
QHBoxLayout *mProtocolLayout = new QHBoxLayout(this); m_protocolWidget = new DetailWidget(qobject_cast<QWidget *>(mProtocol), m_listWidget);
mProtocolLayout->addStretch(); m_protocolWidget->setKey(tr("Protocol:"));
mProtocolLayout->addWidget(mProtocol);
mSecType = new QLabel(this); mSecType = new QLabel(this);
QHBoxLayout *mSecTypeLayout = new QHBoxLayout(this); m_secTypeWidget = new DetailWidget(qobject_cast<QWidget *>(mSecType));
mSecTypeLayout->addStretch(); m_secTypeWidget->setKey(tr("Security Type:"));
mSecTypeLayout->addWidget(mSecType);
mHz = new QLabel(this); mHz = new QLabel(this);
QHBoxLayout *mHzLayout = new QHBoxLayout(this); m_hzWidget = new DetailWidget(qobject_cast<QWidget *>(mHz));
mHzLayout->addStretch(); m_hzWidget->setKey(tr("Hz:"));
mHzLayout->addWidget(mHz);
mChan = new QLabel(this); mChan = new QLabel(this);
QHBoxLayout *mChanLayout = new QHBoxLayout(this); m_chanelWidget = new DetailWidget(qobject_cast<QWidget *>(mChan));
mChanLayout->addStretch(); m_chanelWidget->setKey(tr("Chan:"));
mChanLayout->addWidget(mChan);
mBandWidth = new QLabel(this); mBandWidth = new QLabel(this);
QHBoxLayout *mBandWidthLayout = new QHBoxLayout(this); m_bandwidthWidget = new DetailWidget(qobject_cast<QWidget *>(mBandWidth), m_listWidget);
mBandWidthLayout->addStretch(); m_bandwidthWidget->setKey(tr("BandWidth:"));
mBandWidthLayout->addWidget(mBandWidth);
mIPV4 = new QLabel(this); mIPV4 = new QLabel(this);
QHBoxLayout *mIPV4Layout = new QHBoxLayout(this); m_ipv4Widget = new DetailWidget(qobject_cast<QWidget *>(mIPV4), m_listWidget);
mIPV4Layout->addStretch(); m_ipv4Widget->setKey(tr("IPV4:"));
mIPV4Layout->addWidget(mIPV4);
mIPV4Dns = new QLabel(this); mIPV4Dns = new QLabel(this);
QHBoxLayout *mIPV4DnsLayout = new QHBoxLayout(this); m_ipv4DnsWidget = new DetailWidget(qobject_cast<QWidget *>(mIPV4Dns), m_listWidget);
mIPV4DnsLayout->addStretch(); m_ipv4DnsWidget->setKey(tr("IPV4 Dns:"));
mIPV4DnsLayout->addWidget(mIPV4Dns);
mIPV6 = new QLabel(this); mIPV6 = new QLabel(this);
QHBoxLayout *mIPV6Layout = new QHBoxLayout(this); m_ipv6Widget = new DetailWidget(qobject_cast<QWidget *>(mIPV6), m_listWidget);
mIPV6Layout->addStretch(); m_ipv6Widget->setKey(tr("IPV6:"));
mIPV6Layout->addWidget(mIPV6);
mMac = new QLabel(this); mMac = new QLabel(this);
QHBoxLayout *mMacLayout = new QHBoxLayout(this); m_macWidget = new DetailWidget(qobject_cast<QWidget *>(mMac), m_listWidget);
mMacLayout->addStretch(); m_macWidget->setKey(tr("Mac:"));
mMacLayout->addWidget(mMac);
autoConnect = new QLabel(this); autoConnect = new QLabel(this);
@ -147,23 +158,28 @@ void DetailPage::initUI() {
mAutoLayout->addWidget(autoConnect); mAutoLayout->addWidget(autoConnect);
mAutoLayout->addSpacerItem(horizontalSpacer); mAutoLayout->addSpacerItem(horizontalSpacer);
mDetailLayout->addRow(tr("SSID:"), mSsidLayout); this->addDetailItem(m_listWidget, m_ssidWidget);
mDetailLayout->addRow(tr("Protocol:"), mProtocolLayout); this->addDetailItem(m_listWidget, m_protocolWidget);
if (mIsWlan) { if (mIsWlan) {
mDetailLayout->addRow(tr("Security Type:"), mSecTypeLayout); this->addDetailItem(m_listWidget, m_secTypeWidget);
mDetailLayout->addRow(tr("Hz:"), mHzLayout); this->addDetailItem(m_listWidget, m_hzWidget);
mDetailLayout->addRow(tr("Chan:"), mChanLayout); this->addDetailItem(m_listWidget, m_chanelWidget);
} }
mDetailLayout->addRow(tr("BandWidth:"), mBandWidthLayout); this->addDetailItem(m_listWidget, m_bandwidthWidget);
mDetailLayout->addRow(tr("IPV6:"), mIPV6Layout); this->addDetailItem(m_listWidget, m_ipv6Widget);
mDetailLayout->addRow(tr("IPV4:"), mIPV4Layout); this->addDetailItem(m_listWidget, m_ipv4Widget);
mDetailLayout->addRow(tr("IPV4 Dns:"), mIPV4DnsLayout); this->addDetailItem(m_listWidget, m_ipv4DnsWidget);
mDetailLayout->addRow(tr("Mac:"), mMacLayout); this->addDetailItem(m_listWidget, m_macWidget);
layout->addLayout(mDetailLayout); QPalette mpal(m_listWidget->palette());
layout->addStretch(); mpal.setColor(QPalette::Base, qApp->palette().base().color());
mpal.setColor(QPalette::AlternateBase, qApp->palette().alternateBase().color());
m_listWidget->setAlternatingRowColors(true);
// m_listWidget->setAutoFillBackground(true);
m_listWidget->setPalette(mpal);
layout->addWidget(mDetailFrame);
layout->addLayout(mAutoLayout); layout->addLayout(mAutoLayout);
} }
void DetailPage::setEnableOfSaveBtn() { void DetailPage::setEnableOfSaveBtn() {

View File

@ -7,7 +7,10 @@
#include <QCheckBox> #include <QCheckBox>
#include <QSpacerItem> #include <QSpacerItem>
#include <QDebug> #include <QDebug>
#include <QListWidget>
#include <QApplication>
#include "detailwidget.h"
#include "coninfo.h" #include "coninfo.h"
class DetailPage : public QFrame class DetailPage : public QFrame
@ -34,8 +37,21 @@ public:
private: private:
void initUI(); void initUI();
void addDetailItem(QListWidget *listWidget, DetailWidget *detailWidget);
public: public:
QListWidget * m_listWidget = nullptr;
DetailWidget * m_ssidWidget = nullptr;
DetailWidget * m_protocolWidget = nullptr;
DetailWidget * m_secTypeWidget = nullptr;
DetailWidget * m_hzWidget = nullptr;
DetailWidget * m_chanelWidget = nullptr;
DetailWidget * m_bandwidthWidget = nullptr;
DetailWidget * m_ipv4Widget = nullptr;
DetailWidget * m_ipv4DnsWidget = nullptr;
DetailWidget * m_ipv6Widget = nullptr;
DetailWidget * m_macWidget = nullptr;
QLineEdit *mSSID; QLineEdit *mSSID;
QLabel *mProtocol; QLabel *mProtocol;
QLabel *mSecType; QLabel *mSecType;
@ -51,7 +67,7 @@ public:
// QWidget *autoFrame; // QWidget *autoFrame;
private: private:
QVBoxLayout *layout; QVBoxLayout *layout;
QFormLayout *mDetailLayout; QVBoxLayout *mDetailLayout;
QHBoxLayout *mAutoLayout; QHBoxLayout *mAutoLayout;
QCheckBox *forgetNetBox; QCheckBox *forgetNetBox;
bool mIsWlan; bool mIsWlan;

View File

@ -0,0 +1,32 @@
#include "detailwidget.h"
#define ITEM_HEIGHT 36
#define ITEM_MARGINS 18,0,16,0
DetailWidget::DetailWidget(QWidget *valueWidget, QWidget *parent)
: m_valueWidget(valueWidget) , QWidget(parent)
{
// m_valueWidget = valueWidget;
initUI();
}
DetailWidget::~DetailWidget()
{
}
void DetailWidget::initUI()
{
this->setFixedHeight(ITEM_HEIGHT);
m_mainLayout = new QHBoxLayout(this);
m_mainLayout->setContentsMargins(ITEM_MARGINS);
m_keyLabel = new QLabel(this);
m_mainLayout->addWidget(m_keyLabel);
m_mainLayout->addStretch();
m_mainLayout->addWidget(m_valueWidget);
}
void DetailWidget::setKey(const QString &keyLabel)
{
m_keyLabel->setText(keyLabel);
}

View File

@ -0,0 +1,27 @@
#ifndef DetailWidget_H
#define DetailWidget_H
#include <QWidget>
#include <QLabel>
#include <QHBoxLayout>
class DetailWidget : public QWidget
{
Q_OBJECT
public:
explicit DetailWidget(QWidget *valueWidget = nullptr, QWidget *parent = nullptr);
~DetailWidget();
void setKey(const QString &keyLabel);
private:
QHBoxLayout * m_mainLayout = nullptr;
QLabel * m_keyLabel = nullptr;
QWidget * m_valueWidget = nullptr;
void initUI();
signals:
};
#endif // DetailWidget_H

View File

@ -3,8 +3,8 @@
#include "backend/kylinipv6arping.h" #include "backend/kylinipv6arping.h"
#include "xatom/xatom-helper.h" #include "xatom/xatom-helper.h"
#define WINDOW_WIDTH 540 #define WINDOW_WIDTH 520
#define WINDOW_HEIGHT 574 #define WINDOW_HEIGHT 590
#define BUTTON_SIZE 30 #define BUTTON_SIZE 30
#define ICON_SIZE 22,22 #define ICON_SIZE 22,22
#define TITLE_LAYOUT_MARGINS 9,9,0,0 #define TITLE_LAYOUT_MARGINS 9,9,0,0
@ -80,6 +80,7 @@ NetDetail::NetDetail(QString interface, QString name, QString uuid, bool isActiv
getConInfo(m_info); getConInfo(m_info);
pagePadding(name,isWlan); pagePadding(name,isWlan);
connect(qApp, &QApplication::paletteChanged, this, &NetDetail::onPaletteChanged);
isCreateOk = !(m_isCreateNet && !isWlan); isCreateOk = !(m_isCreateNet && !isWlan);
isDetailOk = !(m_name.isEmpty()); isDetailOk = !(m_name.isEmpty());
@ -97,6 +98,20 @@ NetDetail::~NetDetail()
} }
void NetDetail::onPaletteChanged()
{
QPalette pal = qApp->palette();
pal.setColor(QPalette::Window, qApp->palette().base().color());
this->setPalette(pal);
QPalette listwidget_pal(detailPage->m_listWidget->palette());
listwidget_pal.setColor(QPalette::Base, qApp->palette().base().color());
listwidget_pal.setColor(QPalette::AlternateBase, qApp->palette().alternateBase().color());
detailPage->m_listWidget->setAlternatingRowColors(true);
detailPage->m_listWidget->setPalette(listwidget_pal);
}
void NetDetail::paintEvent(QPaintEvent *event) void NetDetail::paintEvent(QPaintEvent *event)
{ {
return QDialog::paintEvent(event); return QDialog::paintEvent(event);
@ -227,6 +242,10 @@ void NetDetail::initUI()
bottomLayout->addWidget(cancelBtn); bottomLayout->addWidget(cancelBtn);
bottomLayout->addWidget(confimBtn); bottomLayout->addWidget(confimBtn);
QPalette pal(this->palette());
pal.setColor(QPalette::Background, qApp->palette().base().color());
this->setAutoFillBackground(true);
this->setPalette(pal);
} }
void NetDetail::loadPage() void NetDetail::loadPage()

View File

@ -127,5 +127,6 @@ private:
private slots: private slots:
void on_btnConfirm_clicked(); void on_btnConfirm_clicked();
void on_btnForget_clicked(); void on_btnForget_clicked();
void onPaletteChanged();
}; };
#endif // NETDETAIL_H #endif // NETDETAIL_H

View File

@ -5,6 +5,7 @@ HEADERS += \
$$PWD/creatnetpage.h \ $$PWD/creatnetpage.h \
$$PWD/customtabstyle.h \ $$PWD/customtabstyle.h \
$$PWD/detailpage.h \ $$PWD/detailpage.h \
$$PWD/detailwidget.h \
$$PWD/ipv4page.h \ $$PWD/ipv4page.h \
$$PWD/ipv6page.h \ $$PWD/ipv6page.h \
$$PWD/netdetail.h \ $$PWD/netdetail.h \
@ -14,6 +15,7 @@ SOURCES += \
$$PWD/creatnetpage.cpp \ $$PWD/creatnetpage.cpp \
$$PWD/customtabstyle.cpp \ $$PWD/customtabstyle.cpp \
$$PWD/detailpage.cpp \ $$PWD/detailpage.cpp \
$$PWD/detailwidget.cpp \
$$PWD/ipv4page.cpp \ $$PWD/ipv4page.cpp \
$$PWD/ipv6page.cpp \ $$PWD/ipv6page.cpp \
$$PWD/netdetail.cpp \ $$PWD/netdetail.cpp \