控制面板列表一体化

This commit is contained in:
jzxc95 2021-12-01 11:07:21 +08:00
parent 62b99acdbe
commit 41ba4bc2c8
16 changed files with 155 additions and 1 deletions

View File

@ -3,6 +3,10 @@
#include <QHBoxLayout>
#include <QLabel>
#include <QVariant>
#include <QPainter>
#include <QPainterPath>
#define RADIUS 6.0
AddNetBtn::AddNetBtn(QWidget *parent) : QPushButton(parent)
{
@ -46,3 +50,21 @@ void AddNetBtn::leaveEvent(QEvent *event){
QPushButton::leaveEvent(event);
}
void AddNetBtn::paintEvent(QPaintEvent *event)
{
QPalette pal = this->palette();
QPainter painter(this);
painter.setRenderHint(QPainter:: Antialiasing, true); //设置渲染,启动反锯齿
painter.setPen(Qt::NoPen);
painter.setBrush(pal.color(QPalette::Base));
QRect rect = this->rect();
QPainterPath path;
path.addRoundedRect (rect, RADIUS, RADIUS);
QRect temp_rect(rect.left(), rect.top(), rect.width(), rect.height()/2);
path.addRect(temp_rect);
painter.drawPath(path);
QPushButton::paintEvent(event);
}

View File

@ -17,6 +17,7 @@ public:
protected:
virtual void leaveEvent(QEvent * event);
virtual void enterEvent(QEvent * event);
void paintEvent(QPaintEvent *event);
Q_SIGNALS:
void enterWidget();

View File

@ -2,6 +2,7 @@
#define LAYOUT_MARGINS 18,0,24,0
#define FRAME_HEIGHT 58
#define RADIUS 6.0
DeviceFrame::DeviceFrame(QString devName, QWidget *parent) : QFrame(parent)
{
@ -26,3 +27,20 @@ DeviceFrame::~DeviceFrame()
}
void DeviceFrame::paintEvent(QPaintEvent *event)
{
QPalette pal = this->palette();
QPainter painter(this);
painter.setRenderHint(QPainter:: Antialiasing, true); //设置渲染,启动反锯齿
painter.setPen(Qt::NoPen);
painter.setBrush(pal.color(QPalette::Base));
QRect rect = this->rect();
QPainterPath path;
path.addRoundedRect (rect, RADIUS, RADIUS);
QRect temp_rect(rect.left(), rect.top() + rect.height()/2, rect.width(), rect.height()/2);
path.addRect(temp_rect);
painter.drawPath(path);
QFrame::paintEvent(event);
}

View File

@ -21,6 +21,9 @@ public:
SwitchButton * deviceSwitch = nullptr;
DrownLabel *dropDownLabel = nullptr;
protected:
void paintEvent(QPaintEvent *event);
private:
bool isDropDown = false;
int frameSize;

View File

@ -1,6 +1,10 @@
#include "itemframe.h"
#include <QPainter>
#include <QPalette>
#define LAYOUT_MARGINS 0,0,0,0
#define MAIN_LAYOUT_MARGINS 0,0,0,8
#define MAIN_LAYOUT_MARGINS 0,0,0,0
ItemFrame::ItemFrame(QString devName, QWidget *parent) : QFrame(parent)
{
deviceLanLayout = new QVBoxLayout(this);

View File

@ -91,3 +91,18 @@ void LanItem::waitAnimStep()
}
}
void LanItem::paintEvent(QPaintEvent *event)
{
QPalette pal = this->palette();
QPainter painter(this);
painter.setRenderHint(QPainter:: Antialiasing, true); //设置渲染,启动反锯齿
painter.setPen(Qt::NoPen);
painter.setBrush(pal.color(QPalette::Base));
QRect rect = this->rect();
painter.drawRect(rect);
QPushButton::paintEvent(event);
}

View File

@ -9,6 +9,7 @@
#include <QGSettings>
#include <QDebug>
#include <QImage>
#include <QPainter>
#include "fixlabel.h"
#include "../component/InfoButton/infobutton.h"
@ -36,6 +37,10 @@ public:
QString uuid;
QString dbusPath;
protected:
void paintEvent(QPaintEvent *);
private:
QTimer *waitTimer = nullptr;
QGSettings *themeGsettings = nullptr;

View File

@ -45,7 +45,9 @@ const QByteArray GSETTINGS_SCHEMA = "org.ukui.kylin-nm.switch";
#define DEACTIVATED 4
#define NO_MARGINS 0,0,0,0
#define TOP_MARGINS 0,0,0,0
#define MAIN_LAYOUT_MARGINS 0,0,0,8
#define SPACING 8
bool sortByVal(const QPair<QString, int> &l, const QPair<QString, int> &r) {
return (l.second < r.second);
@ -168,6 +170,8 @@ void NetConnect::initComponent() {
ui->openWIifLayout->addWidget(wiredSwitch);
ui->detailLayOut->setContentsMargins(MAIN_LAYOUT_MARGINS);
ui->verticalLayout_3->setContentsMargins(NO_MARGINS);
ui->availableLayout->setSpacing(SPACING);
ui->horizontalLayout->setContentsMargins(TOP_MARGINS);
connect(wiredSwitch, &SwitchButton::disabledClick, this, [=]() {
showDesktopNotify(tr("No ethernet device avaliable"));

View File

@ -138,6 +138,9 @@
<property name="spacing">
<number>1</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<item>
<widget class="QFrame" name="frame">
<property name="frameShape">

View File

@ -1,8 +1,10 @@
#include "deviceframe.h"
#include <QPainter>
#define LAYOUT_MARGINS 18,0,8,0
#define FRAME_HEIGHT 58
#define LAYOUT_SPACING 16
#define RADIUS 6.0
DeviceFrame::DeviceFrame(QString devName, QWidget *parent) : QFrame(parent)
{
@ -26,3 +28,21 @@ DeviceFrame::~DeviceFrame()
}
void DeviceFrame::paintEvent(QPaintEvent *event)
{
QPalette pal = this->palette();
QPainter painter(this);
painter.setRenderHint(QPainter:: Antialiasing, true); //设置渲染,启动反锯齿
painter.setPen(Qt::NoPen);
painter.setBrush(pal.color(QPalette::Base));
QRect rect = this->rect();
QPainterPath path;
path.addRoundedRect (rect, RADIUS, RADIUS);
QRect temp_rect(rect.left(), rect.top() + rect.height()/2, rect.width(), rect.height()/2);
path.addRect(temp_rect);
painter.drawPath(path);
QFrame::paintEvent(event);
}

View File

@ -19,6 +19,9 @@ public:
QLabel * deviceLabel = nullptr;
DrownLabel *dropDownLabel = nullptr;
protected:
void paintEvent(QPaintEvent *event);
private:
int frameSize;

View File

@ -1,4 +1,6 @@
#include "itemframe.h"
#include <QPainter>
#define LAYOUT_MARGINS 0,0,0,0
#define MAIN_LAYOUT_MARGINS 0,0,0,8
ItemFrame::ItemFrame(QString devName, QWidget *parent)
@ -40,3 +42,20 @@ void ItemFrame::onDrownLabelClicked()
deviceFrame->dropDownLabel->setDropDownStatus(false);
}
}
void ItemFrame::filletStyleChange()
{
if (lanItemLayout->isEmpty()) {
return;
}
for (int i = 0; i < lanItemLayout->count(); ++i) {
QLayoutItem *it = lanItemLayout->itemAt(i);
WlanItem *itemFrame = (WlanItem*)(it->widget());
if (i != lanItemLayout->count()-1) {
itemFrame->setHalfFillet(false);
} else {
itemFrame->setHalfFillet(true);
}
}
}

View File

@ -24,6 +24,8 @@ public:
//已激活uuid
QString uuid = "";
void filletStyleChange();
private slots:
void onDrownLabelClicked();
};

View File

@ -296,6 +296,7 @@ void WlanConnect::updateList()
if (deviceFrameMap.contains(iter.key())) {
QVector<QStringList> wifiList = iter.value();
resortWifiList(deviceFrameMap[iter.key()], wifiList);
deviceFrameMap[iter.key()]->filletStyleChange();
}
}
}
@ -941,6 +942,7 @@ void WlanConnect::addOneWlanFrame(ItemFrame *frame, QString deviceName, QString
}
qDebug()<<"insert " << name << " to " << deviceName << " list, postion " << index;
frame->lanItemLayout->insertWidget(index, wlanItem);
frame->filletStyleChange();
}
//减少ap
@ -955,6 +957,7 @@ void WlanConnect::removeOneWlanFrame(ItemFrame *frame, QString deviceName, QStri
frame->lanItemLayout->removeWidget(frame->itemMap[ssid]);
delete frame->itemMap[ssid];
frame->itemMap.remove(ssid);
frame->filletStyleChange();
}
}

View File

@ -1,7 +1,9 @@
#include "wlanitem.h"
#include <QPainter>
#define FRAME_SPEED 150
#define LIMIT_TIME 60*1000
#define TOTAL_PAGE 8
#define RADIUS 6.0
#define THEME_QT_SCHEMA "org.ukui.style"
#define MODE_QT_KEY "style-name"
@ -90,3 +92,24 @@ void WlanItem::waitAnimStep()
}
}
void WlanItem::paintEvent(QPaintEvent *event)
{
QPalette pal = this->palette();
QPainter painter(this);
painter.setRenderHint(QPainter:: Antialiasing, true); //设置渲染,启动反锯齿
painter.setPen(Qt::NoPen);
painter.setBrush(pal.color(QPalette::Base));
QRect rect = this->rect();
if (!useHalfFillet) {
painter.drawRect(rect);
} else {
QPainterPath path;
path.addRoundedRect (rect, RADIUS, RADIUS);
QRect temp_rect(rect.left(), rect.top(), rect.width(), rect.height()/2);
path.addRect(temp_rect);
painter.drawPath(path);
}
QPushButton::paintEvent(event);
}

View File

@ -25,6 +25,8 @@ public:
int waitPage;
int countCurrentTime;
QString uuid = "";
void setHalfFillet(bool flag) {useHalfFillet = flag; repaint();}
public:
void startLoading();
void setWaitPage(int waitPage);
@ -34,9 +36,16 @@ public:
bool isAcitve = false;
bool loading = false;
bool isLock = false;
protected:
void paintEvent(QPaintEvent *event);
private:
QTimer *waitTimer = nullptr;
QGSettings *themeGsettings = nullptr;
bool useHalfFillet = false;
};