VPN新建界面ui调整

This commit is contained in:
zhangyuanyuan1 2023-04-11 20:52:01 +08:00
parent f5b6d2ba7a
commit 37792e91e3
3 changed files with 40 additions and 56 deletions

View File

@ -2,6 +2,17 @@
#include <QDebug>
#include "vpnconfigpage.h"
#define VPNADDPAGE_SIZE 520,272
#define MAINLAYOUT_MARGINS 24, 16, 24, 24
#define MAINLAYOUT_SPACE 24
#define NULL_MARGINS 0,0,0,0
#define NULL_SPACE 0
#define VPNADDPAGE_NAME_MAX_LENGTH 32
#define VPNADDPAGE_LABLE_FIXEDWIDTH 112
#define VPNADDPAGE_COMBOBOX_FIXEDWIDTH 360
#define VPNADDPAGE_INPUTBOX_FIXEDWIDTH 360
vpnAddPage::vpnAddPage(QWidget *parent) : QWidget(parent)
{
m_vpnConnOperation = new KyVpnConnectOperation(this);
@ -33,8 +44,8 @@ void vpnAddPage::initWindow()
void vpnAddPage::initUI()
{
QVBoxLayout *mainLayout = new QVBoxLayout(this);
mainLayout->setContentsMargins(VPNADDPAGE_MAINLAYOUT_MARGINS);
mainLayout->setSpacing(VPNADDPAGE_NULLSPACE);
mainLayout->setContentsMargins(MAINLAYOUT_MARGINS);
mainLayout->setSpacing(MAINLAYOUT_SPACE);
initVpnTypeFrame();
initVpnNameFrame();
@ -54,11 +65,10 @@ void vpnAddPage::initVpnTypeFrame()
{
m_vpnTypeFrame = new QFrame(this);
m_vpnTypeFrame->setFrameShape(QFrame::Shape::NoFrame);
m_vpnTypeFrame->setFixedSize(VPNADDPAGE_FRAME_FIXEDSIZE);
QHBoxLayout *typeLayout = new QHBoxLayout(m_vpnTypeFrame);
typeLayout->setContentsMargins(VPNADDPAGE_ITEM_MARGINS);
typeLayout->setSpacing(VPNADDPAGE_NULLSPACE);
typeLayout->setContentsMargins(NULL_MARGINS);
typeLayout->setSpacing(NULL_SPACE);
QLabel *vpnTypeLabel = new QLabel(tr("VPN Type"), this);
vpnTypeLabel->setFixedWidth(VPNADDPAGE_LABLE_FIXEDWIDTH);
@ -83,11 +93,10 @@ void vpnAddPage::initVpnNameFrame()
{
m_vpnNameFrame = new QFrame(this);
m_vpnNameFrame->setFrameShape(QFrame::Shape::NoFrame);
m_vpnNameFrame->setFixedSize(VPNADDPAGE_FRAME_FIXEDSIZE);
QHBoxLayout *nameLayout = new QHBoxLayout(m_vpnNameFrame);
nameLayout->setContentsMargins(VPNADDPAGE_ITEM_MARGINS);
nameLayout->setSpacing(VPNADDPAGE_NULLSPACE);
nameLayout->setContentsMargins(NULL_MARGINS);
nameLayout->setSpacing(NULL_SPACE);
QLabel *vpnNameLabel = new QLabel(tr("VPN Name"), this);
vpnNameLabel->setFixedWidth(VPNADDPAGE_LABLE_FIXEDWIDTH);
@ -106,11 +115,10 @@ void vpnAddPage::initVpnServerFrame()
{
m_vpnServerFrame = new QFrame(this);
m_vpnServerFrame->setFrameShape(QFrame::Shape::NoFrame);
m_vpnServerFrame->setFixedSize(VPNADDPAGE_FRAME_FIXEDSIZE);
QHBoxLayout *serverLayout = new QHBoxLayout(m_vpnServerFrame);
serverLayout->setContentsMargins(VPNADDPAGE_ITEM_MARGINS);
serverLayout->setSpacing(VPNADDPAGE_NULLSPACE);
serverLayout->setContentsMargins(NULL_MARGINS);
serverLayout->setSpacing(NULL_SPACE);
QLabel *vpnServerLabel = new QLabel(tr("VPN Server"), this);
vpnServerLabel->setFixedWidth(VPNADDPAGE_LABLE_FIXEDWIDTH);
@ -132,35 +140,22 @@ void vpnAddPage::initVpnServerFrame()
void vpnAddPage::initButtonFrame()
{
m_buttonFrame = new QFrame(this);
m_buttonFrame->setFixedSize(VPNDETAILPAGE_FRAME_FIXEDSIZE);
QHBoxLayout *buttonLayout = new QHBoxLayout(m_buttonFrame);
buttonLayout->setContentsMargins(VPNDETAILPAGE_ITEM_MARGINS);
buttonLayout->setSpacing(VPNDETAILPAGE_NULLSPACE);
buttonLayout->setContentsMargins(NULL_MARGINS);
buttonLayout->setSpacing(NULL_SPACE);
QLabel *autoConnectLabel = new QLabel(this);
m_autoConnectBox = new QCheckBox(this);
autoConnectLabel->setText(tr("Auto Connection"));
QWidget *autoConWidget = new QWidget(this);
QHBoxLayout *autoLayout = new QHBoxLayout(autoConWidget);
autoLayout->setContentsMargins(VPNDETAILPAGE_NULLMAGINS);
autoLayout->setSpacing(VPNDETAILPAGE_NULLSPACE);
autoLayout->addWidget(m_autoConnectBox);
autoLayout->addWidget(autoConnectLabel);
autoConWidget->setLayout(autoLayout);
m_autoConnectBox->setText(tr("Auto Connection"));
m_confimBtn = new QPushButton(this);
m_confimBtn->setFixedSize(VPNDETAILPAGE_BUTTON_FIXEDSIZE);
m_confimBtn->setText(tr("Confirm"));
m_cancelBtn = new QPushButton(this);
m_cancelBtn->setFixedSize(VPNDETAILPAGE_BUTTON_FIXEDSIZE);
m_cancelBtn->setText(tr("Cancel"));
buttonLayout->addWidget(autoConWidget);
buttonLayout->addWidget(m_autoConnectBox);
buttonLayout->addStretch();
buttonLayout->addWidget(m_cancelBtn);
buttonLayout->addSpacing(VPNDETAILPAGE_BUTTON_SPACE);
buttonLayout->addSpacing(16);
buttonLayout->addWidget(m_confimBtn);
m_buttonFrame->setLayout(buttonLayout);
}
@ -232,3 +227,14 @@ vpnAddPage::~vpnAddPage()
{
Q_EMIT this->closed();
}
void vpnAddPage::paintEvent(QPaintEvent *event)
{
QPalette pal = qApp->palette();
QPainter painter(this);
painter.setBrush(pal.color(QPalette::Base));
painter.drawRect(this->rect());
painter.fillRect(rect(), QBrush(pal.color(QPalette::Base)));
return QWidget::paintEvent(event);
}

View File

@ -13,35 +13,10 @@
#include <QFormLayout>
#include <QDesktopWidget>
#include <QApplication>
#include <QPainter>
#include "kyvpnconnectoperation.h"
#define VPNADDPAGE_MAINLAYOUT_MARGINS 0, 12, 0, 12
#define VPNADDPAGE_ITEM_MARGINS 24, 0, 24, 0
#define VPNADDPAGE_NULLMAGINS 0, 0, 0, 0
#define VPNADDPAGE_SIZE 520,312
#define VPNADDPAGE_FRAME_FIXEDSIZE 520, 60
#define VPNADDPAGE_BUTTON_FIXEDSIZE 96, 36
#define VPNADDPAGE_NULLSPACE 0
#define VPNADDPAGE_BUTTON_SPACE 16
#define VPNADDPAGE_NAME_MAX_LENGTH 32
#define VPNADDPAGE_LABLE_FIXEDWIDTH 112
#define VPNADDPAGE_COMBOBOX_FIXEDWIDTH 360
#define VPNADDPAGE_INPUTBOX_FIXEDWIDTH 360
#define VPNDETAILPAGE_ITEM_MARGINS 24, 0, 24, 0
#define VPNDETAILPAGE_NULLMAGINS 0, 0, 0, 0
#define VPNDETAILPAGE_FRAME_FIXEDSIZE 520, 60
#define VPNDETAILPAGE_BUTTON_FIXEDSIZE 96, 36
#define VPNDETAILPAGE_NULLSPACE 0
#define VPNDETAILPAGE_BUTTON_SPACE 16
class vpnAddPage : public QWidget
{
Q_OBJECT
@ -50,6 +25,9 @@ public:
void centerToScreen();
~vpnAddPage();
protected:
void paintEvent(QPaintEvent *event);
private:
void initWindow();
void initUI();
@ -63,7 +41,6 @@ private:
bool checkConfimBtnIsEnabled();
bool createVpnConnect();
private:
QFrame *m_vpnTypeFrame = nullptr;
QFrame *m_vpnNameFrame = nullptr;
QFrame *m_vpnServerFrame = nullptr;

View File

@ -133,6 +133,7 @@ void vpnObject::showVpnAddWidget()
m_vpnAddPage = new vpnAddPage();
connect(m_vpnAddPage, &vpnAddPage::closed, [&] () {m_vpnAddPage = nullptr;});
m_vpnAddPage->show();
m_vpnAddPage->centerToScreen();
}
m_vpnAddPage->raise();
}