diff --git a/src/frontend/netdetails/detailitem.cpp b/src/frontend/netdetails/detailitem.cpp deleted file mode 100644 index be9001a4..00000000 --- a/src/frontend/netdetails/detailitem.cpp +++ /dev/null @@ -1,6 +0,0 @@ -#include "detailitem.h" - -DetailItem::DetailItem(QWidget *parent) : QWidget(parent) -{ - -} diff --git a/src/frontend/netdetails/detailitem.h b/src/frontend/netdetails/detailitem.h deleted file mode 100644 index 6e775c6f..00000000 --- a/src/frontend/netdetails/detailitem.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef DETAILITEM_H -#define DETAILITEM_H - -#include - -class DetailItem : public QWidget -{ - Q_OBJECT -public: - explicit DetailItem(QWidget *parent = nullptr); - -signals: - -}; - -#endif // DETAILITEM_H diff --git a/src/frontend/netdetails/detailpage.cpp b/src/frontend/netdetails/detailpage.cpp index 572ea7e3..7b8e45a8 100644 --- a/src/frontend/netdetails/detailpage.cpp +++ b/src/frontend/netdetails/detailpage.cpp @@ -1,5 +1,6 @@ #include "detailpage.h" #include +#include 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() { forgetNetBox = new QCheckBox(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->setAlignment(Qt::AlignRight); 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); } 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); - mSsidLayout->addStretch(); - mSsidLayout->addWidget(mSSID); + m_ssidWidget = new DetailWidget(qobject_cast(mSSID), m_listWidget); + m_ssidWidget->setKey(tr("SSID:")); - mProtocol = new QLabel(this); - QHBoxLayout *mProtocolLayout = new QHBoxLayout(this); - mProtocolLayout->addStretch(); - mProtocolLayout->addWidget(mProtocol); + mProtocol = new QLabel(this); + m_protocolWidget = new DetailWidget(qobject_cast(mProtocol), m_listWidget); + m_protocolWidget->setKey(tr("Protocol:")); - mSecType = new QLabel(this); - QHBoxLayout *mSecTypeLayout = new QHBoxLayout(this); - mSecTypeLayout->addStretch(); - mSecTypeLayout->addWidget(mSecType); + mSecType = new QLabel(this); + m_secTypeWidget = new DetailWidget(qobject_cast(mSecType)); + m_secTypeWidget->setKey(tr("Security Type:")); - mHz = new QLabel(this); - QHBoxLayout *mHzLayout = new QHBoxLayout(this); - mHzLayout->addStretch(); - mHzLayout->addWidget(mHz); + mHz = new QLabel(this); + m_hzWidget = new DetailWidget(qobject_cast(mHz)); + m_hzWidget->setKey(tr("Hz:")); - mChan = new QLabel(this); - QHBoxLayout *mChanLayout = new QHBoxLayout(this); - mChanLayout->addStretch(); - mChanLayout->addWidget(mChan); + mChan = new QLabel(this); + m_chanelWidget = new DetailWidget(qobject_cast(mChan)); + m_chanelWidget->setKey(tr("Chan:")); mBandWidth = new QLabel(this); - QHBoxLayout *mBandWidthLayout = new QHBoxLayout(this); - mBandWidthLayout->addStretch(); - mBandWidthLayout->addWidget(mBandWidth); + m_bandwidthWidget = new DetailWidget(qobject_cast(mBandWidth), m_listWidget); + m_bandwidthWidget->setKey(tr("BandWidth:")); - mIPV4 = new QLabel(this); - QHBoxLayout *mIPV4Layout = new QHBoxLayout(this); - mIPV4Layout->addStretch(); - mIPV4Layout->addWidget(mIPV4); + mIPV4 = new QLabel(this); + m_ipv4Widget = new DetailWidget(qobject_cast(mIPV4), m_listWidget); + m_ipv4Widget->setKey(tr("IPV4:")); - mIPV4Dns = new QLabel(this); - QHBoxLayout *mIPV4DnsLayout = new QHBoxLayout(this); - mIPV4DnsLayout->addStretch(); - mIPV4DnsLayout->addWidget(mIPV4Dns); + mIPV4Dns = new QLabel(this); + m_ipv4DnsWidget = new DetailWidget(qobject_cast(mIPV4Dns), m_listWidget); + m_ipv4DnsWidget->setKey(tr("IPV4 Dns:")); - mIPV6 = new QLabel(this); - QHBoxLayout *mIPV6Layout = new QHBoxLayout(this); - mIPV6Layout->addStretch(); - mIPV6Layout->addWidget(mIPV6); + mIPV6 = new QLabel(this); + m_ipv6Widget = new DetailWidget(qobject_cast(mIPV6), m_listWidget); + m_ipv6Widget->setKey(tr("IPV6:")); - mMac = new QLabel(this); - QHBoxLayout *mMacLayout = new QHBoxLayout(this); - mMacLayout->addStretch(); - mMacLayout->addWidget(mMac); + mMac = new QLabel(this); + m_macWidget = new DetailWidget(qobject_cast(mMac), m_listWidget); + m_macWidget->setKey(tr("Mac:")); autoConnect = new QLabel(this); @@ -147,23 +158,28 @@ void DetailPage::initUI() { mAutoLayout->addWidget(autoConnect); mAutoLayout->addSpacerItem(horizontalSpacer); - mDetailLayout->addRow(tr("SSID:"), mSsidLayout); - mDetailLayout->addRow(tr("Protocol:"), mProtocolLayout); + this->addDetailItem(m_listWidget, m_ssidWidget); + this->addDetailItem(m_listWidget, m_protocolWidget); if (mIsWlan) { - mDetailLayout->addRow(tr("Security Type:"), mSecTypeLayout); - mDetailLayout->addRow(tr("Hz:"), mHzLayout); - mDetailLayout->addRow(tr("Chan:"), mChanLayout); + this->addDetailItem(m_listWidget, m_secTypeWidget); + this->addDetailItem(m_listWidget, m_hzWidget); + this->addDetailItem(m_listWidget, m_chanelWidget); } - mDetailLayout->addRow(tr("BandWidth:"), mBandWidthLayout); - mDetailLayout->addRow(tr("IPV6:"), mIPV6Layout); - mDetailLayout->addRow(tr("IPV4:"), mIPV4Layout); - mDetailLayout->addRow(tr("IPV4 Dns:"), mIPV4DnsLayout); - mDetailLayout->addRow(tr("Mac:"), mMacLayout); + this->addDetailItem(m_listWidget, m_bandwidthWidget); + this->addDetailItem(m_listWidget, m_ipv6Widget); + this->addDetailItem(m_listWidget, m_ipv4Widget); + this->addDetailItem(m_listWidget, m_ipv4DnsWidget); + this->addDetailItem(m_listWidget, m_macWidget); - layout->addLayout(mDetailLayout); - layout->addStretch(); + QPalette mpal(m_listWidget->palette()); + 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); - } void DetailPage::setEnableOfSaveBtn() { diff --git a/src/frontend/netdetails/detailpage.h b/src/frontend/netdetails/detailpage.h index 719e33ce..fa40c35a 100644 --- a/src/frontend/netdetails/detailpage.h +++ b/src/frontend/netdetails/detailpage.h @@ -7,7 +7,10 @@ #include #include #include +#include +#include +#include "detailwidget.h" #include "coninfo.h" class DetailPage : public QFrame @@ -34,8 +37,21 @@ public: private: void initUI(); + void addDetailItem(QListWidget *listWidget, DetailWidget *detailWidget); 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; QLabel *mProtocol; QLabel *mSecType; @@ -51,7 +67,7 @@ public: // QWidget *autoFrame; private: QVBoxLayout *layout; - QFormLayout *mDetailLayout; + QVBoxLayout *mDetailLayout; QHBoxLayout *mAutoLayout; QCheckBox *forgetNetBox; bool mIsWlan; diff --git a/src/frontend/netdetails/detailwidget.cpp b/src/frontend/netdetails/detailwidget.cpp new file mode 100644 index 00000000..a045e0ce --- /dev/null +++ b/src/frontend/netdetails/detailwidget.cpp @@ -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); +} diff --git a/src/frontend/netdetails/detailwidget.h b/src/frontend/netdetails/detailwidget.h new file mode 100644 index 00000000..00333bb2 --- /dev/null +++ b/src/frontend/netdetails/detailwidget.h @@ -0,0 +1,27 @@ +#ifndef DetailWidget_H +#define DetailWidget_H + +#include +#include +#include + +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 diff --git a/src/frontend/netdetails/netdetail.cpp b/src/frontend/netdetails/netdetail.cpp index 0b1de9d3..11f124d7 100644 --- a/src/frontend/netdetails/netdetail.cpp +++ b/src/frontend/netdetails/netdetail.cpp @@ -3,8 +3,8 @@ #include "backend/kylinipv6arping.h" #include "xatom/xatom-helper.h" -#define WINDOW_WIDTH 540 -#define WINDOW_HEIGHT 574 +#define WINDOW_WIDTH 520 +#define WINDOW_HEIGHT 590 #define BUTTON_SIZE 30 #define ICON_SIZE 22,22 #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); pagePadding(name,isWlan); + connect(qApp, &QApplication::paletteChanged, this, &NetDetail::onPaletteChanged); isCreateOk = !(m_isCreateNet && !isWlan); 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) { return QDialog::paintEvent(event); @@ -227,6 +242,10 @@ void NetDetail::initUI() bottomLayout->addWidget(cancelBtn); bottomLayout->addWidget(confimBtn); + QPalette pal(this->palette()); + pal.setColor(QPalette::Background, qApp->palette().base().color()); + this->setAutoFillBackground(true); + this->setPalette(pal); } void NetDetail::loadPage() diff --git a/src/frontend/netdetails/netdetail.h b/src/frontend/netdetails/netdetail.h index d6c721a0..e40db6c0 100644 --- a/src/frontend/netdetails/netdetail.h +++ b/src/frontend/netdetails/netdetail.h @@ -127,5 +127,6 @@ private: private slots: void on_btnConfirm_clicked(); void on_btnForget_clicked(); + void onPaletteChanged(); }; #endif // NETDETAIL_H diff --git a/src/frontend/netdetails/netdetails.pri b/src/frontend/netdetails/netdetails.pri index 206899b9..720a66b8 100644 --- a/src/frontend/netdetails/netdetails.pri +++ b/src/frontend/netdetails/netdetails.pri @@ -5,6 +5,7 @@ HEADERS += \ $$PWD/creatnetpage.h \ $$PWD/customtabstyle.h \ $$PWD/detailpage.h \ + $$PWD/detailwidget.h \ $$PWD/ipv4page.h \ $$PWD/ipv6page.h \ $$PWD/netdetail.h \ @@ -14,6 +15,7 @@ SOURCES += \ $$PWD/creatnetpage.cpp \ $$PWD/customtabstyle.cpp \ $$PWD/detailpage.cpp \ + $$PWD/detailwidget.cpp \ $$PWD/ipv4page.cpp \ $$PWD/ipv6page.cpp \ $$PWD/netdetail.cpp \