Fix bug 140401

This commit is contained in:
zhangyuanyuan1 2022-09-15 14:00:55 +08:00
parent cda4a0f6b1
commit c3b7aad39d
2 changed files with 15 additions and 0 deletions

View File

@ -27,6 +27,7 @@ FirewallDialog::FirewallDialog(KDialog *parent)
this->setWindowIcon(QIcon::fromTheme("kylin-network"));
this->setFixedSize(480, 204);
setAttribute(Qt::WA_DeleteOnClose);
centerToScreen();
}
FirewallDialog::~FirewallDialog()
@ -87,3 +88,14 @@ void FirewallDialog::initUI()
connect(m_YesBtn, &QPushButton::clicked, this, &FirewallDialog::setPublicNetMode);
connect(m_NoBtn, &QPushButton::clicked, this, &FirewallDialog::setPrivateNetMode);
}
void FirewallDialog::centerToScreen()
{
QDesktopWidget* m = QApplication::desktop();
QRect desk_rect = m->screenGeometry(m->screenNumber(QCursor::pos()));
int desk_x = desk_rect.width();
int desk_y = desk_rect.height();
int x = this->width();
int y = this->height();
this->move(desk_x / 2 - x / 2 + desk_rect.left(), desk_y / 2 - y / 2 + desk_rect.top());
}

View File

@ -24,6 +24,8 @@
#include <QHBoxLayout>
#include <QFormLayout>
#include <QLabel>
#include <QDesktopWidget>
#include <QApplication>
#include "kwidget.h"
#include "kdialog.h"
@ -41,6 +43,7 @@ public:
private:
void initUI();
void centerToScreen();
QString m_uuid;
QLabel * m_iconLabel = nullptr;
QLabel * m_contentLabel = nullptr;