-
Notifications
You must be signed in to change notification settings - Fork 1
/
openwindow.cpp
45 lines (37 loc) · 1.23 KB
/
openwindow.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
45
#include "openwindow.h"
#include "ui_openwindow.h"
#include <QFile>
#include <iostream>
OpenWindow::OpenWindow(QWidget *parent) :
QDialog(parent),
ui(new Ui::OpenWindow)
{
ui->setupUi(this);
system("ifconfig | grep -Eo 'inet (addr:)?([0-9]*\\.){3}[0-9]*' | grep -Eo '([0-9]*\\.){3}[0-9]*' | grep -v '127.0.0.1' > my_ip.txt");
QFile file("my_ip.txt");
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
return;
}
ui->ipList->setEditable(true);
ui->ipList->lineEdit()->setReadOnly(true);
ui->ipList->lineEdit()->setAlignment(Qt::AlignLeft);
while (!file.atEnd()) {
QByteArray line = file.readLine();
ui->ipList->addItem(line);
}
}
OpenWindow::~OpenWindow()
{
delete ui;
}
void OpenWindow::on_loginButton_clicked()
{
if(ui->usernameLineEdit->text().isEmpty() == false){
std::string ip_n = ui->ipList->currentText().toStdString();
std::string user_n = ui->usernameLineEdit->text().toStdString();
QWidget *parent = nullptr;
open_main_window = new MainWindow(parent,ip_n,user_n);
open_main_window->show();
this->close();
}
}