-
Notifications
You must be signed in to change notification settings - Fork 7
/
helpipdialog.cpp
44 lines (39 loc) · 1.05 KB
/
helpipdialog.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include "helpipdialog.h"
#include "ui_helpipdialog.h"
#include <QCloseEvent>
#include <QHostAddress>
#include <QNetworkInterface>
HelpIpDialog::HelpIpDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::HelpIpDialog)
{
ui->setupUi(this);
this->setWindowFlags(Qt::Dialog | Qt::WindowTitleHint);
}
HelpIpDialog::~HelpIpDialog()
{
delete ui;
}
void HelpIpDialog::accept()
{
this->hide();
}
void HelpIpDialog::closeEvent(QCloseEvent *event)
{
event->ignore();
this->hide();
}
void HelpIpDialog::show()
{
QDialog::show();
QString ips = "All iPv4 addresses:<br/><b>";
foreach (const QHostAddress &address, QNetworkInterface::allAddresses()) {
if (address.protocol() == QAbstractSocket::IPv4Protocol && address != QHostAddress(QHostAddress::LocalHost))
ips += address.toString() + "<br/>";
}
ips += "</b>";
ui->help_ip_label->setText(ips);
this->setMaximumSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX);
this->adjustSize();
this->setFixedSize(this->geometry().width(),this->geometry().height());
}