You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1553 lines
54 KiB
C++

1 year ago
#include "wangluo.h"
#include "canshupeizhi.h"
#include "xitongshezhi.h"
#include "ui_wangluo.h"
#include "ui_keyboard.h"
#include <mainwindow.h>
#include "ui_mainwindow.h"
#include "keyboard.h"
#include <QDebug>
#include <QFileDialog>
#include <QTime>
bool wlpz_flag=false;
void Delay_MSec(unsigned int msec)
{
QEventLoop eventloop;
QTimer::singleShot((int)msec, &eventloop, SLOT(quit()));
eventloop.exec();
}
wangluo::wangluo(QWidget *parent) :
QWidget(parent),
ui(new Ui::wangluo)
{
ui->setupUi(this);
this->setFixedSize(this->geometry().size());
KeyBoard_Code=false;
KeyBoard_ABC_Code=false;
keyBoard_flag=false;
keyBoard_ABC_flag=false;
wlxx_set_back_color();
ui->label_1->close();
ui->label_2->show();//选择网络配置界面提示
ui->label_3->close();
ui->label_4->close();
label_wlxx_0_1=new QLabel(this);
label_wlxx_0_2=new QLabel(this);
label_wlxx_0_3=new QLabel(this);
label_wlxx_0_4=new QLabel(this);
label_wlxx_0_5=new QLabel(this);
label_wlxx_0_1->installEventFilter(this);//安装鼠标事件
label_wlxx_0_2->installEventFilter(this);//安装鼠标事件
label_wlxx_0_3->installEventFilter(this);//安装鼠标事件
label_wlxx_0_4->installEventFilter(this);//安装鼠标事件
label_wlxx_0_5->installEventFilter(this);//安装鼠标事件
label_wlxx_3_2=new QLabel(this);//正在连接WIFI......
label_wlxx_3_2->close();
label_wlxx_5_11=new QLabel(this);//4G状态
label_wlxx_5_11->close();
label_wlxx_5_12=new QLabel(this);//WIFIHOST状态
label_wlxx_5_12->close();
label_wlxx_5_13=new QLabel(this);//WIFI状态
label_wlxx_5_13->close();
label_wlxx_5_14=new QLabel(this);//LAN状态
label_wlxx_5_14->close();
lineEdit_wlxx_5_2=new QLineEdit(this);//网络状态——WIFI账号
lineEdit_wlxx_5_2->close();
label_wlxx_4G_back=new QLabel(this);
label_wlxx_4G_back->setGeometry(10,185,780,256);
label_wlxx_4G_back->setStyleSheet("background: rgb(145, 145, 145)");
label_wlxx_WIFIHOST_back=new QLabel(this);
label_wlxx_WIFIHOST_back->setGeometry(10,185,780,256);
label_wlxx_WIFIHOST_back->setStyleSheet("background: rgb(145, 145, 145)");
label_wlxx_WIFI_back=new QLabel(this);
label_wlxx_WIFI_back->setGeometry(10,185,780,256);
label_wlxx_WIFI_back->setStyleSheet("background: rgb(145, 145, 145)");
label_wlxx_LAN_back=new QLabel(this);
label_wlxx_LAN_back->setGeometry(10,185,780,256);
label_wlxx_LAN_back->setStyleSheet("background: rgb(145, 145, 145)");
label_wlxx_WLZT_back=new QLabel(this);
label_wlxx_WLZT_back->setGeometry(10,185,780,256);
label_wlxx_WLZT_back->setStyleSheet("background: rgb(145, 145, 145)");
label_mimajiemian = new QLabel(this);
label_mimajiemian->setGeometry(10, 136, 780, 300);
label_mimajiemian->setStyleSheet("background: rgb(145, 145, 145)");
mimaline=new QLineEdit(this);
mimaline->setGeometry(360, 210, 120, 30);
mimaline->setStyleSheet("font: 12pt 黑体;color: rgb(0, 0, 0)");
mimaButton = new QPushButton(this);
mimaButton->setGeometry(360, 250, 100, 40);
mimaButton->setStyleSheet("background: rgb(0, 35, 53);font: 12pt 黑体;color: rgb(0, 171, 171)");
mimaButton->setText("获取权限");
label_mima1 = new QLabel(this);
label_mima1->setGeometry(360, 180, 200, 30);
label_mima1->setStyleSheet("font: 12pt 黑体;color: rgb(255, 255, 255);color: rgb(0, 0, 0)");
label_mima1->setText("请输入密码:");
label_mima2 = new QLabel(this);
label_mima2->setGeometry(330, 300, 200, 30);
label_mima2->setStyleSheet("font: 14pt 黑体;color: rgb(255, 255, 255);color: rgb(255, 255, 255)");
mimaline->installEventFilter(this);
connect(mimaButton,SIGNAL(clicked()), this,SLOT(mimaButtonClicked()));
label_wlxx_0_1->setGeometry(15,143,150,39);
label_wlxx_0_1->setStyleSheet("background: rgb(0, 35, 53);font: 12pt 黑体;color: rgb(0, 171, 171)");
label_wlxx_0_1->setAlignment(Qt::AlignCenter);
label_wlxx_0_1->setText("4G配置");
label_wlxx_0_2->setGeometry(170,143,150,39);
label_wlxx_0_2->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体;color: rgb(255, 255, 255)");
label_wlxx_0_2->setAlignment(Qt::AlignCenter);
label_wlxx_0_2->setText("WIFI热点配置");
label_wlxx_0_3->setGeometry(325,143,150,39);
label_wlxx_0_3->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体;color: rgb(255, 255, 255)");
label_wlxx_0_3->setAlignment(Qt::AlignCenter);
label_wlxx_0_3->setText("WIFI连接");
label_wlxx_0_4->setGeometry(480,143,150,39);
label_wlxx_0_4->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体;color: rgb(255, 255, 255)");
label_wlxx_0_4->setAlignment(Qt::AlignCenter);
label_wlxx_0_4->setText("LAN配置");
label_wlxx_0_5->setGeometry(635,143,150,39);
label_wlxx_0_5->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体;color: rgb(255, 255, 255)");
label_wlxx_0_5->setAlignment(Qt::AlignCenter);
label_wlxx_0_5->setText("网络状态");
wlxx_4Gset_page();
wlxx_WIFIHOSTset_page();//输入密码后加载,防止卡顿
wlxx_WIFIset_page();
wlxx_LANset_page();
wlxx_WLZTset_page();
}
wangluo::~wangluo()
{
delete ui;
}
void wangluo::label_wlxx_1_show(int a)
{
if(a==1)
{
label_wlxx_4G_back->raise();
label_wlxx_1_2->show();
label_wlxx_1_3->show();
label_wlxx_1_4->show();
label_wlxx_1_5->show();
label_wlxx_1_6->show();
label_wlxx_1_7->show();
comboBox_wlxx_1_2->show();
lineEdit_wlxx_1_1->show();
lineEdit_wlxx_1_2->show();
lineEdit_wlxx_1_3->show();
button_wlxx_1_1->show();
label_wlxx_1_2->raise();
label_wlxx_1_3->raise();
label_wlxx_1_4->raise();
label_wlxx_1_5->raise();
label_wlxx_1_6->raise();
label_wlxx_1_7->raise();
comboBox_wlxx_1_2->raise();
lineEdit_wlxx_1_1->raise();
lineEdit_wlxx_1_2->raise();
lineEdit_wlxx_1_3->raise();
button_wlxx_1_1->raise();
}
}
void wangluo::label_wlxx_2_show(int a)
{
if(a==1)
{
label_wlxx_WIFIHOST_back->raise();
label_wlxx_2_1->show();
label_wlxx_2_1->raise();
label_wlxx_2_2->show();
label_wlxx_2_2->raise();
label_wlxx_2_3->show();
label_wlxx_2_3->raise();
lineEdit_wlxx_2_1->show();
lineEdit_wlxx_2_1->raise();
lineEdit_wlxx_2_2->show();
lineEdit_wlxx_2_2->raise();
button_wlxx_2_1->show();
button_wlxx_2_1->raise();
button_wlxx_2_2->show();
button_wlxx_2_2->raise();
}
}
void wangluo::label_wlxx_3_show(int a)
{
if(a==1)
{
label_wlxx_WIFI_back->raise();
label_wlxx_3_1->show();
label_wlxx_3_1->show();
label_wlxx_3_2->show();
comboBox_wlxx_3_1->show();
lineEdit_wlxx_3_1->show();
button_wlxx_3_1->show();
button_wlxx_3_2->show();
button_wlxx_3_3->show();
label_wlxx_3_1->raise();
label_wlxx_3_1->raise();
label_wlxx_3_2->raise();
comboBox_wlxx_3_1->raise();
lineEdit_wlxx_3_1->raise();
button_wlxx_3_1->raise();
button_wlxx_3_2->raise();
button_wlxx_3_3->raise();
}
}
void wangluo::label_wlxx_4_show(int a)
{
QFile file_read5("/home/LAN_IP");
if(file_read5.open(QIODevice::ReadOnly | QIODevice::Text))
{
QTextStream in(&file_read5);//创建一个对象让它去读文件
line_lan_ip=in.readLine();
if(line_lan_ip=="")
{
label_wlxx_LAN_back->raise();
label_wlxx_4_2->hide();
label_wlxx_4_4->hide();
label_wlxx_4_3->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体 bold;color: red");
label_wlxx_4_3->setText("LAN未连接");
label_wlxx_4_3->show();
label_wlxx_4_3->raise();
}
else
{
if(a==1)
{
label_wlxx_4_4->setText(line_lan_ip);
label_wlxx_LAN_back->raise();
label_wlxx_4_2->show();
label_wlxx_4_3->show();
label_wlxx_4_4->show();
label_wlxx_4_2->raise();
label_wlxx_4_3->raise();
label_wlxx_4_4->raise();
label_wlxx_4_3->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体 bold;color: rgb(0, 0, 0)");
label_wlxx_4_3->setText("LAN已连接");
}
}
}
file_read5.close();
}
void wangluo::label_wlxx_5_show(int a)
{
if(a==1)
{
label_wlxx_WLZT_back->raise();
label_wlxx_5_1->show();
label_wlxx_5_2->show();
label_wlxx_5_3->show();
label_wlxx_5_4->show();
label_wlxx_5_5->show();
label_wlxx_5_6->show();
label_wlxx_5_7->show();
label_wlxx_5_8->show();
label_wlxx_5_10->show();
label_wlxx_5_11->show();
label_wlxx_5_12->show();
label_wlxx_5_13->show();
label_wlxx_5_14->show();
lineEdit_wlxx_5_6->show();
lineEdit_wlxx_5_1->show();
lineEdit_wlxx_5_2->show();
lineEdit_wlxx_5_3->show();
lineEdit_wlxx_5_5->show();
line_wlxx_5_1->show();
line_wlxx_5_2->show();
line_wlxx_5_3->show();
label_wlxx_5_1->raise();
label_wlxx_5_2->raise();
label_wlxx_5_3->raise();
label_wlxx_5_4->raise();
label_wlxx_5_5->raise();
label_wlxx_5_6->raise();
label_wlxx_5_7->raise();
label_wlxx_5_8->raise();
label_wlxx_5_10->raise();
label_wlxx_5_11->raise();
label_wlxx_5_12->raise();
label_wlxx_5_13->raise();
label_wlxx_5_14->raise();
lineEdit_wlxx_5_6->raise();
lineEdit_wlxx_5_1->raise();
lineEdit_wlxx_5_2->raise();
lineEdit_wlxx_5_3->raise();
lineEdit_wlxx_5_5->raise();
line_wlxx_5_1->raise();
line_wlxx_5_2->raise();
line_wlxx_5_3->raise();
}
}
void wangluo::wlxx_page(int a)
{
switch (a)
{
case 1:
{
label_wlxx_0_1->setStyleSheet("background: rgb(0, 35, 53);font: 12pt 黑体;color: rgb(0, 171, 171)");
label_wlxx_0_2->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体;color: rgb(255, 255, 255)");
label_wlxx_0_3->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体;color: rgb(255, 255, 255)");
label_wlxx_0_4->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体;color: rgb(255, 255, 255)");
label_wlxx_0_5->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体;color: rgb(255, 255, 255)");
};
break;
case 2:
{
label_wlxx_0_1->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体;color: rgb(255, 255, 255)");
label_wlxx_0_2->setStyleSheet("background: rgb(0, 35, 53);font: 12pt 黑体;color: rgb(0, 171, 171)");
label_wlxx_0_3->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体;color: rgb(255, 255, 255)");
label_wlxx_0_4->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体;color: rgb(255, 255, 255)");
label_wlxx_0_5->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体;color: rgb(255, 255, 255)");
};
break;
case 3:
{
label_wlxx_0_1->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体;color: rgb(255, 255, 255)");
label_wlxx_0_2->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体;color: rgb(255, 255, 255)");
label_wlxx_0_3->setStyleSheet("background: rgb(0, 35, 53);font: 12pt 黑体;color: rgb(0, 171, 171)");
label_wlxx_0_4->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体;color: rgb(255, 255, 255)");
label_wlxx_0_5->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体;color: rgb(255, 255, 255)");
};
break;
case 4:
{
label_wlxx_0_1->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体;color: rgb(255, 255, 255)");
label_wlxx_0_2->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体;color: rgb(255, 255, 255)");
label_wlxx_0_3->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体;color: rgb(255, 255, 255)");
label_wlxx_0_4->setStyleSheet("background: rgb(0, 35, 53);font: 12pt 黑体;color: rgb(0, 171, 171)");
label_wlxx_0_5->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体;color: rgb(255, 255, 255)");
};
break;
case 5:
{
label_wlxx_0_1->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体;color: rgb(255, 255, 255)");
label_wlxx_0_2->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体;color: rgb(255, 255, 255)");
label_wlxx_0_3->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体;color: rgb(255, 255, 255)");
label_wlxx_0_4->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体;color: rgb(255, 255, 255)");
label_wlxx_0_5->setStyleSheet("background: rgb(0, 35, 53);font: 12pt 黑体;color: rgb(0, 171, 171)");
};
break;
default:
{
};
break;
}
}
void wangluo::wlxx_4Gset_page()
{
label_wlxx_1_2=new QLabel(this);
label_wlxx_1_3=new QLabel(this);
label_wlxx_1_4=new QLabel(this);
label_wlxx_1_5=new QLabel(this);
label_wlxx_1_6=new QLabel(this);
label_wlxx_1_7=new QLabel(this);
comboBox_wlxx_1_2 = new QComboBox(this);
lineEdit_wlxx_1_1=new QLineEdit(this);
lineEdit_wlxx_1_2=new QLineEdit(this);
lineEdit_wlxx_1_3=new QLineEdit(this);
button_wlxx_1_1=new QPushButton(this);
lineEdit_wlxx_1_1->installEventFilter(this);
lineEdit_wlxx_1_2->installEventFilter(this);
lineEdit_wlxx_1_3->installEventFilter(this);
label_wlxx_1_2->setGeometry(240,230,120,30);
label_wlxx_1_2->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体 bold;color: rgb(255, 255, 255)");
label_wlxx_1_2->setText("APN接入点");
label_wlxx_1_3->setGeometry(240,270,120,30);
label_wlxx_1_3->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体 bold;color: rgb(255, 255, 255)");
label_wlxx_1_3->setText("服务器IP地址");
label_wlxx_1_4->setGeometry(240,310,120,30);
label_wlxx_1_4->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体 bold;color: rgb(255, 255, 255)");
label_wlxx_1_4->setText("端口号:");
label_wlxx_1_7->setGeometry(240,350,120,30);
label_wlxx_1_7->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体 bold;color: rgb(255, 255, 255)");
label_wlxx_1_7->setText("设备识别码:");
comboBox_wlxx_1_2->setGeometry(350,230,120,30);
comboBox_wlxx_1_2->setStyleSheet("background: rgb(255, 255, 255);font: 12pt 黑体 bold;color: rgb(0, 0, 0)");
comboBox_wlxx_1_2->addItem("移动/电信");
comboBox_wlxx_1_2->addItem("联通");
lineEdit_wlxx_1_1->setGeometry(350,270,120,30);
lineEdit_wlxx_1_1->setStyleSheet("background: rgb(255, 255, 255);font: 12pt 黑体 bold;color: rgb(0, 0, 0)");
lineEdit_wlxx_1_2->setGeometry(350,310,120,30);
lineEdit_wlxx_1_2->setStyleSheet("background: rgb(255, 255, 255);font: 12pt 黑体 bold;color: rgb(0, 0, 0)");
lineEdit_wlxx_1_3->setGeometry(350,350,120,30);
lineEdit_wlxx_1_3->setStyleSheet("background: rgb(255, 255, 255);font: 12pt 黑体 bold;color: rgb(0, 0, 0)");
/*文件读取*/
QFile file_read("/home/data/rexiangyi_domain");
if(file_read.open(QIODevice::ReadOnly | QIODevice::Text))
{
QTextStream in(&file_read);//创建一个对象让它去读文件
QString line1=in.readLine();
QString line2=in.readLine();
QString line3=in.readLine();
lineEdit_wlxx_1_3->setText(line1);
lineEdit_wlxx_1_1->setText(line2);
lineEdit_wlxx_1_2->setText(line3);
}
file_read.close();
button_wlxx_1_1->setGeometry(240,390,100,30);
button_wlxx_1_1->setStyleSheet("background: rgb(0, 171, 171);font: 12pt 黑体 bold;color: rgb(0, 0, 0)");
button_wlxx_1_1->setText("保存参数");
label_wlxx_1_5->setGeometry(350,390,150,30);
label_wlxx_1_5->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体 bold;color: rgb(0, 0, 0)");
label_wlxx_1_6->setGeometry(580,390,100,30);
label_wlxx_1_6->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体 bold;color: rgb(0, 0, 0)");
connect(button_wlxx_1_1,SIGNAL(clicked()),this,SLOT(button_wlxx_1_1_Clicked()));
}
void wangluo::wlxx_WIFIHOSTset_page()
{
label_wlxx_2_1=new QLabel(this);
label_wlxx_2_2=new QLabel(this);
label_wlxx_2_3=new QLabel(this);
lineEdit_wlxx_2_1=new QLineEdit(this);
lineEdit_wlxx_2_2=new QLineEdit(this);
button_wlxx_2_1=new QPushButton(this);
button_wlxx_2_2=new QPushButton(this);
lineEdit_wlxx_2_1->installEventFilter(this);
lineEdit_wlxx_2_2->installEventFilter(this);
label_wlxx_2_1->setGeometry(300,210,100,30);
label_wlxx_2_1->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体 bold;color: rgb(255, 255, 255)");
label_wlxx_2_1->setText("WIFI热点账号");
label_wlxx_2_2->setGeometry(300,250,100,30);
label_wlxx_2_2->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体 bold;color: rgb(255, 255, 255)");
label_wlxx_2_2->setText("WIFI热点密码");
label_wlxx_2_3->setGeometry(410,290,200,30);
label_wlxx_2_3->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体 bold;color: rgb(255, 255, 255)");
label_wlxx_2_3->close();
QFile file_readc("/home/data/wlxx_WIFIHOSTset");
if(file_readc.open(QIODevice::ReadOnly | QIODevice::Text))
{
QTextStream in(&file_readc);//创建一个对象让它去读文件
lineEdit_wlxx_2_1->setText(in.readLine());
lineEdit_wlxx_2_2->setText(in.readLine());
}
file_readc.close();
lineEdit_wlxx_2_1->setGeometry(410,210,120,30);
lineEdit_wlxx_2_1->setStyleSheet("background: rgb(255, 255, 255);font: 12pt 黑体 bold;color: rgb(0, 0, 0)");
lineEdit_wlxx_2_2->setGeometry(410,250,120,30);
lineEdit_wlxx_2_2->setStyleSheet("background: rgb(255, 255, 255);font: 12pt 黑体 bold;color: rgb(0, 0, 0)");
button_wlxx_2_1->setGeometry(300,290,100,30);
button_wlxx_2_1->setStyleSheet("background: rgb(0, 171, 171);font: 12pt 黑体 bold;color: rgb(0, 0, 0)");
button_wlxx_2_1->setText("开启WIFI热点");
button_wlxx_2_2->setGeometry(300,330,100,30);
button_wlxx_2_2->setStyleSheet("background: rgb(0, 171, 171);font: 12pt 黑体 bold;color: rgb(0, 0, 0)");
button_wlxx_2_2->setText("关闭WIFI热点");
connect(button_wlxx_2_1,SIGNAL(clicked()),this,SLOT(button_wlxx_2_1_Clicked()));
connect(button_wlxx_2_2,SIGNAL(clicked()),this,SLOT(button_wlxx_2_2_Clicked()));
}
void wangluo::wlxx_WIFIset_page()
{
label_wlxx_3_1=new QLabel(this);
comboBox_wlxx_3_1 = new QComboBox(this);
lineEdit_wlxx_3_1=new QLineEdit(this);
button_wlxx_3_1=new QPushButton(this);
button_wlxx_3_2=new QPushButton(this);
button_wlxx_3_3=new QPushButton(this);
lineEdit_wlxx_3_1->installEventFilter(this);
label_wlxx_3_1->setGeometry(300,250,120,30);
label_wlxx_3_1->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体 bold;color: rgb(255, 255, 255)");
label_wlxx_3_1->setText("WIFI密码");
comboBox_wlxx_3_1->setGeometry(410,210,180,30);
comboBox_wlxx_3_1->setStyleSheet("background: rgb(255, 255, 255);font: 12pt 黑体 bold;color: rgb(0, 0, 0)");
comboBox_wlxx_3_1->view()->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);//添加下拉框滑动条
comboBox_wlxx_3_1->setStyle(QStyleFactory::create("Windows"));//改成windows风格不然linux下不显示滑动条
comboBox_wlxx_3_1->setMaxVisibleItems(7);
lineEdit_wlxx_3_1->setGeometry(410,250,120,30);
lineEdit_wlxx_3_1->setStyleSheet("background: rgb(255, 255, 255);font: 12pt 黑体 bold;color: rgb(0, 0, 0)");
button_wlxx_3_1->setGeometry(300,210,100,30);
button_wlxx_3_1->setStyleSheet("background: rgb(0, 171, 171);font: 12pt 黑体 bold;color: rgb(0, 0, 0)");
button_wlxx_3_1->setText("搜索WIFI");
button_wlxx_3_2->setGeometry(300,290,100,30);
button_wlxx_3_2->setStyleSheet("background: rgb(0, 171, 171);font: 12pt 黑体 bold;color: rgb(0, 0, 0)");
button_wlxx_3_2->setText("WIFI连接");
button_wlxx_3_3->setGeometry(300,330,100,30);
button_wlxx_3_3->setStyleSheet("background: rgb(0, 171, 171);font: 12pt 黑体 bold;color: rgb(0, 0, 0)");
button_wlxx_3_3->setText("WIFI断开");
label_wlxx_3_2->setGeometry(410,290,300,30);
label_wlxx_3_2->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体 bold;color: rgb(0, 0, 0)");
connect(button_wlxx_3_1,SIGNAL(clicked()),this,SLOT(button_wlxx_3_1_Clicked()));
connect(button_wlxx_3_2,SIGNAL(clicked()),this,SLOT(button_wlxx_3_2_Clicked()));
connect(button_wlxx_3_3,SIGNAL(clicked()),this,SLOT(button_wlxx_3_3_Clicked()));
}
void wangluo::wlxx_LANset_page()
{
label_wlxx_4_2=new QLabel(this);
label_wlxx_4_3=new QLabel(this);
label_wlxx_4_4=new QLabel(this);
label_wlxx_4_2->setGeometry(320,250,80,30);
label_wlxx_4_2->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体 bold;color: rgb(255, 255, 255)");
label_wlxx_4_2->setText("IP地址");
label_wlxx_4_3->setGeometry(390,290,120,30);
label_wlxx_4_3->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体 bold;color: rgb(0, 0, 0)");
label_wlxx_4_3->setText("已连接");
label_wlxx_4_4->setGeometry(390,250,120,30);
label_wlxx_4_4->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体 bold;color: rgb(255, 255, 255)");
label_wlxx_4_4->setText(line_lan_ip);
}
void wangluo::wlxx_WLZTset_page()
{
label_wlxx_5_1=new QLabel(this);
label_wlxx_5_2=new QLabel(this);
label_wlxx_5_3=new QLabel(this);
label_wlxx_5_4=new QLabel(this);
label_wlxx_5_5=new QLabel(this);
label_wlxx_5_6=new QLabel(this);
label_wlxx_5_7=new QLabel(this);
label_wlxx_5_8=new QLabel(this);
label_wlxx_5_10=new QLabel(this);
lineEdit_wlxx_5_1=new QLineEdit(this);
lineEdit_wlxx_5_3=new QLineEdit(this);
lineEdit_wlxx_5_5=new QLineEdit(this);
lineEdit_wlxx_5_6=new QLineEdit(this);//WIFI热点账号
line_wlxx_5_1=new QFrame(this);
line_wlxx_5_2=new QFrame(this);
line_wlxx_5_3=new QFrame(this);
label_wlxx_5_1->setGeometry(40,210,120,30);
label_wlxx_5_1->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体 bold;color: rgb(255, 255, 255)");
label_wlxx_5_1->setAlignment(Qt::AlignCenter);
label_wlxx_5_1->setText("4G通信状态");
label_wlxx_5_2->setGeometry(240,210,120,30);
label_wlxx_5_2->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体 bold;color: rgb(255, 255, 255)");
label_wlxx_5_2->setAlignment(Qt::AlignCenter);
label_wlxx_5_2->setText("WIFI热点状态");
label_wlxx_5_3->setGeometry(440,210,120,30);
label_wlxx_5_3->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体 bold;color: rgb(255, 255, 255)");
label_wlxx_5_3->setAlignment(Qt::AlignCenter);
label_wlxx_5_3->setText("WIFI通信状态");
label_wlxx_5_4->setGeometry(640,210,120,30);
label_wlxx_5_4->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体 bold;color: rgb(255, 255, 255)");
label_wlxx_5_4->setAlignment(Qt::AlignCenter);
label_wlxx_5_4->setText("LAN通信状态");
label_wlxx_5_5->setGeometry(40,250,120,30);
label_wlxx_5_5->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体 bold;color: rgb(0, 0, 0)");
label_wlxx_5_5->setAlignment(Qt::AlignCenter);
label_wlxx_5_5->setText("本机IP地址");
label_wlxx_5_6->setGeometry(220,250,170,30);
label_wlxx_5_6->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体 bold;color: rgb(0, 0, 0)");
label_wlxx_5_6->setAlignment(Qt::AlignCenter);
label_wlxx_5_6->setText("WIFI热点");
label_wlxx_5_7->setGeometry(440,250,140,30);
label_wlxx_5_7->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体 bold;color: rgb(0, 0, 0)");
label_wlxx_5_7->setAlignment(Qt::AlignCenter);
label_wlxx_5_7->setText("连接的WIFI账号");
label_wlxx_5_8->setGeometry(640,250,120,30);
label_wlxx_5_8->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体 bold;color: rgb(0, 0, 0)");
label_wlxx_5_8->setAlignment(Qt::AlignCenter);
label_wlxx_5_8->setText("LAN设备IP地址");
label_wlxx_5_10->setGeometry(220, 320, 160, 30);
label_wlxx_5_10->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体 bold;color: rgb(0, 0, 0)");
label_wlxx_5_10->setAlignment(Qt::AlignCenter);
label_wlxx_5_10->setText("WIFI热点密码");
label_wlxx_5_11->setGeometry(40,400,120,30);
label_wlxx_5_11->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体 bold;color: red");
label_wlxx_5_11->setAlignment(Qt::AlignCenter);
label_wlxx_5_11->setText("4G通信异常");
label_wlxx_5_12->setGeometry(240,400,120,30);
label_wlxx_5_12->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体 bold;color: red");
label_wlxx_5_12->setAlignment(Qt::AlignCenter);
label_wlxx_5_12->setText("WIFI热点异常");
label_wlxx_5_13->setGeometry(440,400,120,30);
label_wlxx_5_13->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体 bold;color: red");
label_wlxx_5_13->setAlignment(Qt::AlignCenter);
label_wlxx_5_13->setText("WIFI通信异常");
label_wlxx_5_14->setGeometry(640,400,120,30);
label_wlxx_5_14->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体 bold;color: red");
label_wlxx_5_14->setAlignment(Qt::AlignCenter);
label_wlxx_5_14->setText("LAN通信异常");
lineEdit_wlxx_5_6->setGeometry(240,280,120,30);
lineEdit_wlxx_5_6->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体 bold;color: rgb(0, 0, 0)");
lineEdit_wlxx_5_1->setGeometry(40,280,120,30);
lineEdit_wlxx_5_1->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体 bold;color: rgb(0, 0, 0)");
lineEdit_wlxx_5_2->setGeometry(440,280,120,30);//网络状态wifi通信状态账号显示
lineEdit_wlxx_5_2->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体 bold;color: rgb(0, 0, 0)");
lineEdit_wlxx_5_3->setGeometry(640,280,120,30);
lineEdit_wlxx_5_3->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体 bold;color: rgb(0, 0, 0)");
lineEdit_wlxx_5_5->setGeometry(240,350,120,30);
lineEdit_wlxx_5_5->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体 bold;color: rgb(0, 0, 0)");
line_wlxx_5_1->setGeometry(200,210,1,200);
line_wlxx_5_1->setStyleSheet("color: rgb(255, 255, 255)");
line_wlxx_5_1->setFrameShape(QFrame::VLine);
line_wlxx_5_2->setGeometry(400,210,1,200);
line_wlxx_5_2->setStyleSheet("color: rgb(255, 255, 255)");
line_wlxx_5_2->setFrameShape(QFrame::VLine);
line_wlxx_5_3->setGeometry(600,210,1,200);
line_wlxx_5_3->setStyleSheet("color: rgb(255, 255, 255)");
line_wlxx_5_3->setFrameShape(QFrame::VLine);
}
bool wangluo::eventFilter(QObject *watch, QEvent *evn)//鼠标事件,判断触摸是左滑还是右滑
{
if(watch == label_wlxx_0_1 && evn->type() == QEvent::MouseButtonPress)//点击lable切换页面
{
label_wlxx_0_1_clicked();
}
if(watch == label_wlxx_0_2 && evn->type() == QEvent::MouseButtonPress)
{
label_wlxx_0_2_clicked();
}
if(watch == label_wlxx_0_3 && evn->type() == QEvent::MouseButtonPress)
{
label_wlxx_0_3_clicked();
}
if(watch == label_wlxx_0_4 && evn->type() == QEvent::MouseButtonPress)
{
label_wlxx_0_4_clicked();
}
if(watch == label_wlxx_0_5 && evn->type() == QEvent::MouseButtonPress)
{
label_wlxx_0_5_clicked();
}
if ((watch == mimaline) && evn->type() == QEvent::MouseButtonPress)
{
callKeyBoard(mimaline);
}
if ((watch == lineEdit_wlxx_1_1) && evn->type() == QEvent::MouseButtonPress)
{
callKeyBoard_ABC(lineEdit_wlxx_1_1);
}
if ((watch == lineEdit_wlxx_1_2) && evn->type() == QEvent::MouseButtonPress)
{
callKeyBoard(lineEdit_wlxx_1_2);
}
if ((watch == lineEdit_wlxx_1_3) && evn->type() == QEvent::MouseButtonPress)
{
callKeyBoard(lineEdit_wlxx_1_3);
}
if ((watch == lineEdit_wlxx_2_1) && evn->type() == QEvent::MouseButtonPress)
{
callKeyBoard_ABC(lineEdit_wlxx_2_1);
}
if ((watch == lineEdit_wlxx_2_2) && evn->type() == QEvent::MouseButtonPress)
{
callKeyBoard_ABC(lineEdit_wlxx_2_2);
}
if ((watch == lineEdit_wlxx_3_1) && evn->type() == QEvent::MouseButtonPress)
{
callKeyBoard_ABC(lineEdit_wlxx_3_1);
}
return QWidget::eventFilter(watch,evn);
}
void wangluo::on_pushButton_zhujiemian_clicked()
{
where_page = 0;
lowpower_mode_flag1=true;
wlpz_flag=false;
if(keyBoard_flag==true)
{
keyBoard->close();
}
if(keyBoard_ABC_flag==true)
{
keyBoard_ABC->close();
}
this->hide();
}
void wangluo::on_pushButton_wangluoxinxi_clicked()
{
where_page = 1;
}
void wangluo::on_pushButton_canshushezhi_clicked()
{
where_page = 2;
wlpz_flag=false;
if(!cspz_flag && !wlpz_flag)
{
cspz_flag=true;
if(keyBoard_flag==true)
{
keyBoard->close();
}
if(keyBoard_ABC_flag==true)
{
keyBoard_ABC->close();
}
this->hide();
KeyBoard_Code=false;
KeyBoard_ABC_Code=false;
keyBoard_flag=false;
keyBoard_ABC_flag=false;
canshupeizhi_thread->show();
canshupeizhi_thread->cspz_set_back_color();
canshupeizhi_thread->mimaButton->show();
canshupeizhi_thread->mimaline->show();
canshupeizhi_thread->label_mima1->show();
canshupeizhi_thread->label_mima2->show();
canshupeizhi_thread->label_mimajiemian->show();
canshupeizhi_thread->label_mimajiemian->raise();
canshupeizhi_thread->mimaButton->raise();
canshupeizhi_thread->mimaline->clear();
canshupeizhi_thread->mimaline->raise();
canshupeizhi_thread->label_mima1->raise();
canshupeizhi_thread->label_mima2->clear();
canshupeizhi_thread->label_mima2->raise();
}
}
void wangluo::on_pushButton_xitongshezhi_clicked()
{
where_page = 3;
wlpz_flag=false;
if(!cspz_flag && !wlpz_flag)
{
xtpz_flag=true;
if(keyBoard_flag==true)
{
keyBoard->close();
}
if(keyBoard_ABC_flag==true)
{
keyBoard_ABC->close();
}
this->hide();
xitongshezhi_thread->show();
xitongshezhi_thread->xtsz_page(1);
xitongshezhi_thread->label_xtsz_1_show(1);
xitongshezhi_thread->label_xtsz_2_show(0);
xitongshezhi_thread->label_xtsz_3_show(0);
}
}
void wangluo::mimaButtonClicked()
{
QString str= mimaline->text();
if(str=="1111")
{
label_mima2->raise();
label_mima2->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体 bold;color: rgb(0, 100, 60)");
label_mima2->setText("密码正确,正在加载...");
Delay_MSec(50);
wlxx_page(1);//显示第1页4G配置
mimaline->clear();
mimaline->close();
mimaButton->close();
label_mima1->close();
label_mimajiemian->close();
label_mima2->close();
label_wlxx_1_show(1);
if(keyBoard_flag==true)
{
keyBoard->close();
}
if(keyBoard_ABC_flag==true)
{
keyBoard_ABC->close();
}
}
else
{
label_mima2->setStyleSheet("font: 12pt 黑体;color: rgb(255, 255, 255);color: red");
label_mima2->setGeometry(360, 300, 200, 30);
label_mima2->setText("密码错误!");
mimaline->clear();
}
}
void wangluo::callKeyBoard(QLineEdit *a)
{
if(keyBoard_flag==true)
{
keyBoard->close();
}
if(KeyBoard_Code==false)
{
keyBoard = new KeyBoard(0, a);
keyBoard->setGeometry(490, 200, 321, 182);
keyBoard->show();
KeyBoard_Code=true;
}
else
{
if(keyBoard_flag==true)
{
keyBoard->close();
}
keyBoard = new KeyBoard(0, a);
keyBoard->setGeometry(490, 200, 321, 182);
keyBoard->show();
}
keyBoard->setAttribute(Qt::WA_DeleteOnClose);
}
void wangluo::callKeyBoard_ABC(QLineEdit *a)
{
if(keyBoard_ABC_flag==true)
{
keyBoard_ABC->close();
}
if(KeyBoard_ABC_Code==false)
{
keyBoard_ABC = new KeyBoard_ABC(0, a);
keyBoard_ABC->setGeometry(5, 326, 790, 143);
keyBoard_ABC->show();
KeyBoard_ABC_Code=true;
}
else
{
if(keyBoard_ABC_flag==true)
{
keyBoard_ABC->close();
}
keyBoard_ABC = new KeyBoard_ABC(0, a);
keyBoard_ABC->setGeometry(5, 326, 790, 143);
keyBoard_ABC->show();
}
keyBoard_ABC->setAttribute(Qt::WA_DeleteOnClose);
}
void wangluo::button_wlxx_1_1_Clicked()//4G配置页面保存参数槽函数
{
button_wlxx_1_1->hide();
label_wlxx_1_5->setText("正在重新配网...");
ui->pushButton_zhujiemian->setDisabled(true);
ui->pushButton_canshushezhi->setDisabled(true);
ui->pushButton_xitongshezhi->setDisabled(true);
if(keyBoard_flag==true)
{
keyBoard->close();
}
if(keyBoard_ABC_flag==true)
{
keyBoard_ABC->close();
}
QFile file_write("/home/data/rexiangyi_domain");//热像仪域名端口号
if(file_write.open(QFile::WriteOnly))
{
QTextStream set4G_data(&file_write);
set4G_data<<lineEdit_wlxx_1_3->text()<<endl<<lineEdit_wlxx_1_1->text()<<endl<<lineEdit_wlxx_1_2->text()<<endl;
}
file_write.close();
if("联通"==comboBox_wlxx_1_2->currentText())
{
QFile file_write1("/etc/ppp/peers/Neoway-chat-connect");//联通卡选择
if(file_write1.open(QFile::WriteOnly))
{
QTextStream set4G_data(&file_write1);
set4G_data<<"TIMEOUT 5"<<endl<<
"ABORT \"BUSY\""<<endl<<
"ABORT \"DELAYED\""<<endl<<
"ABORT \"ERROR\""<<endl<<
"ABORT \"NODIALTONE\""<<endl<<
"ABORT \"NOCARRIER\""<<endl<<
"TIMEOUT 5"<<endl<<
"''AT"<<endl<<
"OK AT+CSQ"<<endl<<
"OK AT+CGDCONT=1,\"IP\",\"3gnet\""<<endl<<
"AT+XGAUTH=1,1,\"CARD\",\"CARD\""<<endl<<
"OK ATD*99#"<<endl<<
"CONNECT ''"<<endl;
}
file_write1.close();
}
else
{
QFile file_write1("/etc/ppp/peers/Neoway-chat-connect");//移动卡选择
if(file_write1.open(QFile::WriteOnly))
{
QTextStream set4G_data(&file_write1);
set4G_data<<"TIMEOUT 5"<<endl<<
"ABORT \"BUSY\""<<endl<<
"ABORT \"DELAYED\""<<endl<<
"ABORT \"ERROR\""<<endl<<
"ABORT \"NODIALTONE\""<<endl<<
"ABORT \"NOCARRIER\""<<endl<<
"TIMEOUT 5"<<endl<<
"''AT"<<endl<<
"OK AT+CSQ"<<endl<<
"OK AT+CGDCONT=1,\"IP\",\"cmiot\""<<endl<<
"OK ATD*99#"<<endl<<
"CONNECT ''"<<endl;
}
file_write1.close();
}
#ifdef LINUX
std::system("killall pppd");
Delay_MSec(3000);
std::system("pppd call Neoway-pppdial &");
#endif
label_wlxx_1_5->setText("4G配置更改成功");
Delay_MSec(1000);
label_wlxx_1_5->clear();
ui->pushButton_zhujiemian->setEnabled(true);
ui->pushButton_canshushezhi->setEnabled(true);
ui->pushButton_xitongshezhi->setEnabled(true);
button_wlxx_1_1->show();
}
void wangluo::button_wlxx_1_2_Clicked()//4G配置页面重新连接槽函数
{
label_wlxx_1_6->setText("连接成功!");
Delay_MSec(1000);
label_wlxx_1_6->clear();
}
void wangluo::button_wlxx_2_1_Clicked()//WIFI热点配置页面保存参数槽函数
{
ui->pushButton_zhujiemian->setDisabled(true);
ui->pushButton_canshushezhi->setDisabled(true);
ui->pushButton_xitongshezhi->setDisabled(true);
#ifdef LINUX
std::system("killall hostapd");
#endif
Delay_MSec(2000);
if(keyBoard_flag==true)
{
keyBoard->close();
}
if(keyBoard_ABC_flag==true)
{
keyBoard_ABC->close();
}
if(lineEdit_wlxx_2_1->text() == "" || lineEdit_wlxx_2_2->text() == "" )
{
label_wlxx_2_3->show();
label_wlxx_2_3->setText("WIFI账号密码不能为空");
label_wlxx_2_3->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体 bold;color: red");
}
else if(lineEdit_wlxx_2_2->text().length()<8)
{
label_wlxx_2_3->show();
label_wlxx_2_3->setText("WIFI密码长度必须大于8位");
label_wlxx_2_3->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体 bold;color: red");
}
else
{
QFile file_write("/home/data/wlxx_WIFIHOSTset");//WIFIHOST账号密码文件
if(file_write.open(QFile::WriteOnly))
{
QTextStream setWIFI_data(&file_write);
setWIFI_data<<lineEdit_wlxx_2_1->text()<<endl<<lineEdit_wlxx_2_2->text()<<endl;//获取用户输入的账号密码
}
file_write.close();
/*设置WIFIHOST账号密码*/
QString str1="interface=uap0\nctrl_interface=/var/hostapd\ndriver=nl80211\nssid="+lineEdit_wlxx_2_1->text()+"\n";
QString str2="channel=11\nhw_mode=g\nieee80211n=1\nwpa=2\nwpa_pairwise=TKIP CCMP\nwpa_passphrase="+lineEdit_wlxx_2_2->text()+"\n";
QString str=str1+str2;
QFile::remove("/etc/ap.conf");
QFile file("/etc/ap.conf");
if(!file.open(QIODevice::WriteOnly))
{
return ;
}
file.write(str.toUtf8());
file.close();
#ifdef LINUX
std::system("ifconfig uap0 192.168.2.1 netmask 255.255.255.0 up");//开启uap0
std::system("touch /etc/udhcpd.leases");//创建空文件保存参数
std::system("udhcpd -fS /etc/udhcpd.conf &");
std::system("iptables -A FORWARD -s 192.168.2.0/24 -o ppp0 -j ACCEPT");
std::system("iptables -A FORWARD -d 192.168.4.0/24 -j ACCEPT");
std::system("iptables -t nat -A POSTROUTING -s 192.168.2.0/255.255.255.0 -o ppp0 -j MASQUERADE");
std::system("echo 1 >/proc/sys/net/ipv4/ip_forward");
std::system("/home/hostapd /etc/ap.conf -B ");
#endif
label_wlxx_2_3->setText("WIFI热点开启成功");
label_wlxx_2_3->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体 bold;color: rgb(0, 100, 60)");
Delay_MSec(1000);
lineEdit_wlxx_5_6->setText(lineEdit_wlxx_2_1->text());
lineEdit_wlxx_5_5->setText(lineEdit_wlxx_2_2->text());
label_wlxx_5_12->setText("WIFI热点正常");
label_wlxx_5_12->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体 bold;color: rgb(0, 100, 60)");
label_wlxx_2_3->clear();
WIFI_HOST_state=true;
}
ui->pushButton_zhujiemian->setEnabled(true);
ui->pushButton_canshushezhi->setEnabled(true);
ui->pushButton_xitongshezhi->setEnabled(true);
}
void wangluo::button_wlxx_2_2_Clicked()//WIFI热点关闭槽函数
{
if(keyBoard_flag==true)
{
keyBoard->close();
}
if(keyBoard_ABC_flag==true)
{
keyBoard_ABC->close();
}
#ifdef LINUX
std::system("killall hostapd");
#endif
label_wlxx_2_3->setText("WIFI热点已关闭");
QTimer::singleShot(1000,label_wlxx_2_3,SLOT(clear));
WIFI_HOST_state=false;
}
void wangluo::button_wlxx_3_1_Clicked()//搜索WIFI槽函数
{
ui->pushButton_zhujiemian->setDisabled(true);
ui->pushButton_canshushezhi->setDisabled(true);
ui->pushButton_xitongshezhi->setDisabled(true);
label_wlxx_3_2->setText("正在搜索WIFI...");
button_wlxx_3_1->hide();
QString line;
#ifdef LINUX
std::system("killall wpa_supplicant");
Delay_MSec(1000);
std::system("ifconfig mlan0 down");//初始化wlan0
std::system("ifconfig mlan0 up");//初始化wlan0
std::system("iwlist mlan0 scan | grep ESSID >/home/data/wlxx_wifi_name");//获取WIFI账号列表保存至wlxx_wifi_name文件
#endif
/*文件读取*/
comboBox_wlxx_3_1->clear();//先清除显示
QFile file_read("/home/data/wlxx_wifi_name");
if(file_read.open(QIODevice::ReadOnly | QIODevice::Text))
{
QTextStream in(&file_read);//创建一个对象让它去读文件
while (!in.atEnd()) {//获取文件行数
line= in.readLine();
line.replace(" ESSID:\"","");//删除前面几个字符 ESSID:"
line.chop(1);//删除最后一个"
comboBox_wlxx_3_1->addItem(line);//WIFI账号显示
}
}
file_read.close();
label_wlxx_3_2->clear();
button_wlxx_3_1->show();
ui->pushButton_zhujiemian->setEnabled(true);
ui->pushButton_canshushezhi->setEnabled(true);
ui->pushButton_xitongshezhi->setEnabled(true);
}
void wangluo::button_wlxx_3_2_Clicked()//WIFI连接槽函数
{
ui->pushButton_zhujiemian->setDisabled(true);
ui->pushButton_wangluoxinxi->setDisabled(true);
ui->pushButton_xitongshezhi->setDisabled(true);
if(keyBoard_ABC_flag==true)
{
keyBoard_ABC->close();
}
QString wifi_name;
QString wifi_password;
QString wifi_quality;
QFile file_write("/home/data/wlxx_wificonnect");//用户输入的账号密码文件
if(file_write.open(QFile::WriteOnly))
{
QTextStream setWIFI_data(&file_write);
setWIFI_data<<comboBox_wlxx_3_1->currentText()<<endl<<lineEdit_wlxx_3_1->text()<<endl;//获取用户输入的账号密码
}
file_write.close();
QFile file_write6("/home/data/wlxx_wificonnect_name");//用户输入的账号密码文件
if(file_write6.open(QFile::WriteOnly))
{
QTextStream setWIFI_data(&file_write6);
setWIFI_data<<comboBox_wlxx_3_1->currentText()<<endl;//获取用户输入的账号密码
}
file_write6.close();
/*文件读取*/
QFile file_read("/home/data/wlxx_wificonnect");
if(file_read.open(QIODevice::ReadOnly | QIODevice::Text))
{
QTextStream in(&file_read);//创建一个对象让它去读文件
wifi_name="\""+in.readLine()+"\"";
wifi_password="\""+in.readLine()+"\"";
}
file_read.close();
QFile fileTemp("/etc/sta.conf");//删除旧的wifi信息文件
fileTemp.remove();
/*修改wifi信息文件-wifi_name*/
QString wifi_file;
wifi_file="ctrl_interface=/var/run/wpa_supplicant\nnetwork={\nssid="+wifi_name+"\npsk="+wifi_password+"\n}\n";
QFile file_write_wifi_connect("/etc/sta.conf");//文件路径
if(file_write_wifi_connect.open(QFile::WriteOnly))
{
QTextStream set_wifi_connect(&file_write_wifi_connect);
set_wifi_connect<<wifi_file<<endl;
}
file_write_wifi_connect.close();
label_wlxx_3_2->setGeometry(410, 290, 300, 30);
label_wlxx_3_2->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体 bold;color: rgb(0, 100, 60)");
if(wifi->isConnected() && wifi_name == wifi->getName() && wifi_password == wifi_password)
{
label_wlxx_3_2->setText("WIFI已连接!");
label_wlxx_3_2->show();
Delay_MSec(1000);
label_wlxx_3_2->clear();
}
//TODO: 账号,密码一致,且已经连接,无需重连
else{
wifiConectFlag = true;
label_wlxx_3_2->setText("正在连接WIFI......");
#ifdef LINUX
std::system("killall wpa_supplicant");
#endif
label_wlxx_3_2->show();
emit sigWifiConnect(wifi_name, wifi_password);
}
ui->pushButton_zhujiemian->setEnabled(true);
ui->pushButton_canshushezhi->setEnabled(true);
ui->pushButton_xitongshezhi->setEnabled(true);
}
void wangluo::button_wlxx_3_3_Clicked()//WIFI关闭槽函数
{
wifiConectFlag = false;
emit sigWifiDisconect();
label_wlxx_3_2->setText("WIFI已断开");
Delay_MSec(1000);
label_wlxx_3_2->clear();
// QFile file_read_wifi_ip("/home/WIFI_IP");
// QString wifi_ip;
// if(file_read_wifi_ip.open(QIODevice::ReadOnly | QIODevice::Text))
// {
// QTextStream in(&file_read_wifi_ip);//创建一个对象让它去读文件
// wifi_ip=in.readLine();
// }
// file_read_wifi_ip.close();
// int local = wifi_ip.indexOf('.',9,Qt::CaseInsensitive);//意思是从第9位往后找找到的第一个.’所在的位置
// wifi_ip=wifi_ip.left(local+1);//从左向右截取n个字符串
// wifi_ip=wifi_ip+"1";
// wifi_ip="route del default gw "+wifi_ip;
// qDebug() << "LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLwifi_ipdel:"<<wifi_ip<<endl;
// std::system(wifi_ip.toLatin1());
}
int wlxx_back_color;
void wangluo::wlxx_set_back_color()
{
QString data;
/*文件读取*/
QFile file_read("/home/data/back_color");
if(file_read.open(QFile::ReadOnly))
{
QTextStream in(&file_read);//创建一个对象让它去读文件
data=in.readAll();
}
wlxx_back_color=data.toInt();
file_read.close();
switch(wlxx_back_color)
{
case 1:
{
ui->label->setStyleSheet("background: rgb(244, 244, 244)");
};
break;
case 2:
{
ui->label->setStyleSheet("background: rgb(148, 238, 213)");
};
break;
case 3:
{
ui->label->setStyleSheet("background: rgb(255, 255, 96)");
};
break;
case 4:
{
ui->label->setStyleSheet("background: rgb(209, 99, 191)");
};
break;
case 5:
{
ui->label->setStyleSheet("background: rgb(87, 255, 78)");
};
break;
default:
{
};
break;
}
}
void wangluo::wifiSoltClickGwUpdate()
{
Delay_MSec(10000);
#ifdef LINUX
/*wifi连接*/
//std::system("ifconfig mlan0 | grep \"inet addr\" | awk '{ print $2}' | awk -F: '{print $2}' > /home/WIFI_IP");
std::system("route -n | grep -i \"mlan0\" | awk -F\" \" '{print $2}' > /home/WIFI_IP");
#endif
QFile file_read_wifi_ip("/home/WIFI_IP");
QString wifi_ip;
if(file_read_wifi_ip.open(QIODevice::ReadOnly | QIODevice::Text))
{
QTextStream in(&file_read_wifi_ip);//创建一个对象让它去读文件
wifi_ip=in.readLine();
}
file_read_wifi_ip.close();
// int local = wifi_ip.indexOf('.',9,Qt::CaseInsensitive);//意思是从第9位往后找找到的第一个.’所在的位置
// wifi_ip=wifi_ip.left(local+1);//从左向右截取n个字符串
// wifi_ip=wifi_ip+"1";
QString wifi_ip_reset="route del default gw "+wifi_ip;
QFile file_read5("/home/LAN_IP");
if(file_read5.open(QIODevice::ReadOnly | QIODevice::Text))
{
QTextStream in(&file_read5);//创建一个对象让它去读文件
line_lan_ip=in.readLine();
}
file_read5.close();
QFile file_read3("/home/4G_IP");
if(file_read3.open(QIODevice::ReadOnly | QIODevice::Text))
{
QTextStream in(&file_read3);//创建一个对象让它去读文件
line_4G_ip=in.readLine();
}
file_read3.close();
QString wifi_ip_set;
if(line_lan_ip == "" && line_4G_ip == "")
{
wifi_ip_set="route add default gw "+wifi_ip;
}else{
wifi_ip_set="route add default dev mlan0 metric 20 gw "+wifi_ip;
}
#ifdef LINUX
std::system(wifi_ip_reset.toLatin1());
std::system(wifi_ip_set.toLatin1());
#endif
QFile file_writewifi("/home/data/file_writewifi.txt");//文件路径
if(file_writewifi.open(QFile::WriteOnly))
{
QTextStream setWIFI_data(&file_writewifi);
setWIFI_data<<wifi_ip<<endl;
}
file_writewifi.close();
}
void wangluo::onWifiStateUpdate(bool state)
{
emit onWifiTuBiaoState(state);
if(!state)
{
if(wifiConectFlag)
{
label_wlxx_3_2->setText("连接失败,请重试!");
label_wlxx_3_2->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体 bold;color: red");
Delay_MSec(1000);
label_wlxx_3_2->clear();
}
}
else
{
wifiSoltClickGwUpdate();
label_wlxx_3_2->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体 bold;color: rgb(0, 100, 60)");
#ifdef LINUX
std::system("killall Modules");
Delay_MSec(3000);
std::system("/home/Modules &");
#endif
label_wlxx_3_2->setText("连接成功!");
Delay_MSec(1000);
label_wlxx_3_2->clear();
}
}
void wangluo::label_wlxx_0_1_clicked()//页面1label点击槽函数
{
if(keyBoard_flag==true)
{
keyBoard->close();
}
if(keyBoard_ABC_flag==true)
{
keyBoard_ABC->close();
}
wlxx_page(1);//显示第1页有功电量
label_wlxx_1_show(1);//页面1有功电量显示开启
}
void wangluo::label_wlxx_0_2_clicked()//页面2label点击槽函数
{
if(keyBoard_flag==true)
{
keyBoard->close();
}
if(keyBoard_ABC_flag==true)
{
keyBoard_ABC->close();
}
wlxx_page(2);//显示第1页有功电量
label_wlxx_2_show(1);//页面2无功电量显示关闭
}
void wangluo::label_wlxx_0_3_clicked()//页面3label点击槽函数
{
if(keyBoard_flag==true)
{
keyBoard->close();
}
if(keyBoard_ABC_flag==true)
{
keyBoard_ABC->close();
}
wlxx_page(3);//显示第1页有功电量
label_wlxx_3_show(1);
}
void wangluo::label_wlxx_0_4_clicked()//页面4label点击槽函数
{
if(keyBoard_flag==true)
{
keyBoard->close();
}
if(keyBoard_ABC_flag==true)
{
keyBoard_ABC->close();
}
wlxx_page(4);//显示第1页有功电量
label_wlxx_4_show(1);
}
void wangluo::label_wlxx_0_5_clicked()//页面5label点击槽函数
{
if(keyBoard_flag==true)
{
keyBoard->close();
}
if(keyBoard_ABC_flag==true)
{
keyBoard_ABC->close();
}
wlxx_page(5);//显示第1页有功电量
QFile file_read4("/home/data/4G_quility");
if(file_read4.open(QIODevice::ReadOnly | QIODevice::Text))
{
QTextStream in(&file_read4);//创建一个对象让它去读文件
in.readLine();
in.readLine();
in.readLine();
QString SIM_ok=in.readLine();
if(SIM_ok=="ERROR")//无SIM卡
{
label_wlxx_5_11->setText("4G通信异常");
label_wlxx_5_11->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体 bold;color: red");
}
else
{
label_wlxx_5_11->setText("4G通信正常");
label_wlxx_5_11->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体 bold;color: rgb(0, 100, 60)");
QFile file_read3("/home/4G_IP");
if(file_read3.open(QIODevice::ReadOnly | QIODevice::Text))
{
QTextStream in(&file_read3);//创建一个对象让它去读文件
line_4G_ip=in.readLine();
lineEdit_wlxx_5_1->setText(line_4G_ip);
}
file_read3.close();
}
}
file_read4.close();
QFile file_read("/home/data/wlxx_wificonnect_name");
if(file_read.open(QFile::ReadOnly))
{
QTextStream in(&file_read);//创建一个对象让它去读文件
lineEdit_wlxx_5_2->setText(in.readAll());
}
file_read.close();
if(WIFI_HOST_state)
{
label_wlxx_5_12->setText("WIFI热点正常");
label_wlxx_5_12->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体 bold;color: rgb(0, 100, 60)");
}
else
{
label_wlxx_5_12->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体 bold;color: red");
label_wlxx_5_12->setText("WIFI热点异常");
}
QFile file_readc("/home/data/wlxx_WIFIHOSTset");
if(file_readc.open(QIODevice::ReadOnly | QIODevice::Text))
{
QTextStream in(&file_readc);//创建一个对象让它去读文件
lineEdit_wlxx_5_6->setText(in.readLine());
lineEdit_wlxx_5_5->setText(in.readLine());
}
file_readc.close();
if(wifi->isConnected())
{
label_wlxx_5_13->setText("WIFI通信正常");
label_wlxx_5_13->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体 bold;color: rgb(0, 100, 60)");
}
else
{
label_wlxx_5_13->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体 bold;color: red");
label_wlxx_5_13->setText("WIFI通信异常");
}
QFile file_read5("/home/LAN_IP");
if(file_read5.open(QIODevice::ReadOnly | QIODevice::Text))
{
QTextStream in(&file_read5);//创建一个对象让它去读文件
line_lan_ip=in.readLine();
if(line_lan_ip=="")
{
label_wlxx_5_14->setText("LAN通信异常");
label_wlxx_5_14->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体 bold;color: red");
lineEdit_wlxx_5_3->setText("");
}
else
{
label_wlxx_5_14->setText("LAN通信正常");
label_wlxx_5_14->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体 bold;color: rgb(0, 100, 60)");
lineEdit_wlxx_5_3->setText(line_lan_ip);
}
}
label_wlxx_5_show(1);
}