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.
459 lines
15 KiB
C++
459 lines
15 KiB
C++
#include "dialogsetup.hpp"
|
|
#include <qprocess.h>
|
|
#include <thread>
|
|
#include <qmessagebox.h>
|
|
#include <QCryptographicHash>
|
|
#include <QIntValidator>
|
|
#include "common.h"
|
|
#include <iostream>
|
|
#include <fstream>
|
|
#include "basecamera.h"
|
|
#include <windows.h> //用于显示桌面
|
|
#include <shldisp.h> //用于显示桌面
|
|
|
|
extern SysConf g_sys_conf; //系统配置参数
|
|
extern QString g_admin_pswd; //管理员密码
|
|
|
|
extern QString g_op_pswd; //操作员密码
|
|
|
|
void task_osk()
|
|
{
|
|
system("start /b C:\\Windows\\system32\\osk.exe");
|
|
}
|
|
|
|
DialogSetup::DialogSetup(QWidget * parent) : QDialog(parent) {
|
|
ui.setupUi(this);
|
|
InitPtrMat();
|
|
this->setWindowFlags(Qt::FramelessWindowHint);
|
|
|
|
for(int i=0;i<NumberOfSupportedCameras;i++)
|
|
{
|
|
lineEdit_expo_mat[i]->setValidator(new QIntValidator(0, 1000000, this));
|
|
lineEdit_expo_mat[i]->setText(QString::number(g_sys_conf.expo[i]));
|
|
lineEdit_gain_mat[i]->setValidator(new QIntValidator(0, 64, this));
|
|
lineEdit_gain_mat[i]->setText(QString::number(g_sys_conf.gain[i]));
|
|
lineEdit_filter_mat[i]->setValidator(new QIntValidator(0, 1000000, this));
|
|
lineEdit_filter_mat[i]->setText(QString::number(g_sys_conf.filter[i]));
|
|
}
|
|
|
|
if (g_sys_conf.auto_open == 1)
|
|
{
|
|
ui.checkBox_auto_open->setChecked(true);
|
|
}
|
|
else {
|
|
ui.checkBox_auto_open->setChecked(false);
|
|
}
|
|
if (g_sys_conf.auto_work == 1)
|
|
{
|
|
ui.checkBox_auto_work->setChecked(true);
|
|
}
|
|
else {
|
|
ui.checkBox_auto_work->setChecked(false);
|
|
}
|
|
|
|
//
|
|
switch (g_sys_conf.save)
|
|
{
|
|
case 0:
|
|
ui.radioButton_none->setChecked(true);
|
|
break;
|
|
case 1:
|
|
ui.radioButton_ng->setChecked(true);
|
|
break;
|
|
case 2:
|
|
ui.radioButton_all->setChecked(true);
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
//
|
|
}
|
|
|
|
DialogSetup::~DialogSetup() {
|
|
|
|
}
|
|
|
|
void DialogSetup::on_toolButton_keyboard_released()
|
|
{
|
|
std::thread osk_thread = std::thread(task_osk);
|
|
osk_thread.detach();
|
|
}
|
|
void DialogSetup::on_pushButton_exit_released()
|
|
{
|
|
if (QMessageBox::Yes == QMessageBox::critical(NULL, QStringLiteral("退出系统"), QStringLiteral("确定退出系统?"), QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes))
|
|
{
|
|
emit system_exit();
|
|
this->close();
|
|
}
|
|
}
|
|
|
|
void DialogSetup::on_pushButton_desktop_released()
|
|
{
|
|
CoInitialize(0);
|
|
IShellDispatch4 * pdisp = NULL;
|
|
CoCreateInstance(CLSID_Shell, NULL, CLSCTX_ALL, __uuidof(IShellDispatch4), (void **)&pdisp);
|
|
pdisp->ToggleDesktop(); // 这句是用来切换桌面的
|
|
pdisp->Release();
|
|
CoUninitialize();
|
|
}
|
|
|
|
void DialogSetup::on_pushButton_expo_released()
|
|
{
|
|
for(int i=0;i<NumberOfSupportedCameras;i++)
|
|
{
|
|
g_sys_conf.expo[i] = (lineEdit_expo_mat[i]->text()).toInt();
|
|
g_sys_conf.gain[i] = (lineEdit_gain_mat[i]->text()).toInt();
|
|
}
|
|
QMessageBox::information(NULL, QStringLiteral("提示"), QStringLiteral("设置成功"), QMessageBox::Ok);
|
|
}
|
|
|
|
void DialogSetup::on_checkBox_auto_open_clicked(bool checked)
|
|
{
|
|
if (checked)
|
|
{
|
|
g_sys_conf.auto_open = 1;
|
|
}
|
|
else
|
|
{
|
|
g_sys_conf.auto_open = 0;
|
|
}
|
|
}
|
|
|
|
void DialogSetup::on_checkBox_auto_work_clicked(bool checked)
|
|
{
|
|
if (checked)
|
|
{
|
|
g_sys_conf.auto_work = 1;
|
|
}
|
|
else
|
|
{
|
|
g_sys_conf.auto_work = 0;
|
|
}
|
|
}
|
|
|
|
void DialogSetup::on_pushButton_filter_released()
|
|
{
|
|
for(int i=0;i<NumberOfSupportedCameras;i++)
|
|
{
|
|
g_sys_conf.filter[i] = (lineEdit_filter_mat[i]->text()).toInt();
|
|
}
|
|
QMessageBox::information(NULL, QStringLiteral("提示"), QStringLiteral("设置成功"), QMessageBox::Ok);
|
|
}
|
|
|
|
void DialogSetup::on_pushButton_image_released()
|
|
{
|
|
if (ui.radioButton_none->isChecked())
|
|
{
|
|
g_sys_conf.save = 0;
|
|
}
|
|
if (ui.radioButton_ng->isChecked())
|
|
{
|
|
g_sys_conf.save = 1;
|
|
}
|
|
if (ui.radioButton_all->isChecked())
|
|
{
|
|
g_sys_conf.save = 2;
|
|
}
|
|
QMessageBox::information(NULL, QStringLiteral("提示"), QStringLiteral("设置成功"), QMessageBox::Ok);
|
|
}
|
|
|
|
void DialogSetup::on_pushButton_pswd_released()
|
|
{
|
|
QString md5Str = QCryptographicHash::hash((ui.lineEdit_old->text()).toLatin1(), QCryptographicHash::Md5).toHex();
|
|
if (md5Str.compare(g_admin_pswd, Qt::CaseInsensitive) == 0)
|
|
{
|
|
QString pswd_new = ui.lineEdit_new->text();
|
|
QString pswd_confirm = ui.lineEdit_confirm->text();
|
|
if (pswd_new.compare(pswd_confirm, Qt::CaseInsensitive) == 0)
|
|
{
|
|
g_admin_pswd = QCryptographicHash::hash(pswd_new.toLatin1(), QCryptographicHash::Md5).toHex();
|
|
write_pswd();
|
|
QMessageBox::information(NULL, QStringLiteral("提示"), QStringLiteral("管理员密码修改成功"), QMessageBox::Ok);
|
|
}
|
|
else {
|
|
QMessageBox::information(NULL, QStringLiteral("提示消息"), QStringLiteral("新密码两次输入不一致,请重新输入"), QMessageBox::Ok);
|
|
}
|
|
}
|
|
else {
|
|
QMessageBox::information(NULL, QStringLiteral("提示消息"), QStringLiteral("原密码错误,请重新输入"), QMessageBox::Ok);
|
|
}
|
|
}
|
|
void DialogSetup::on_pushButton_pswd_op_released()
|
|
{
|
|
QString md5Str = QCryptographicHash::hash((ui.lineEdit_old_op->text()).toLatin1(), QCryptographicHash::Md5).toHex();
|
|
if (md5Str.compare(g_op_pswd, Qt::CaseInsensitive) == 0)
|
|
{
|
|
QString pswd_new = ui.lineEdit_new_op->text();
|
|
QString pswd_confirm = ui.lineEdit_confirm_op->text();
|
|
if (pswd_new.compare(pswd_confirm, Qt::CaseInsensitive) == 0)
|
|
{
|
|
g_op_pswd = QCryptographicHash::hash(pswd_new.toLatin1(), QCryptographicHash::Md5).toHex();
|
|
write_pswd_op();
|
|
QMessageBox::information(NULL, QStringLiteral("提示"), QStringLiteral("操作员密码修改成功"), QMessageBox::Ok);
|
|
}
|
|
else {
|
|
QMessageBox::information(NULL, QStringLiteral("提示消息"), QStringLiteral("新密码两次输入不一致,请重新输入"), QMessageBox::Ok);
|
|
}
|
|
}
|
|
else {
|
|
QMessageBox::information(NULL, QStringLiteral("提示消息"), QStringLiteral("原密码错误,请重新输入"), QMessageBox::Ok);
|
|
}
|
|
}
|
|
void DialogSetup::on_pushButton_save_released()
|
|
{
|
|
//存图设置
|
|
if (ui.radioButton_none->isChecked())
|
|
{
|
|
g_sys_conf.save = 0;
|
|
}
|
|
if (ui.radioButton_ng->isChecked())
|
|
{
|
|
g_sys_conf.save = 1;
|
|
}
|
|
if (ui.radioButton_all->isChecked())
|
|
{
|
|
g_sys_conf.save = 2;
|
|
}
|
|
for(int i=0;i<NumberOfSupportedCameras;i++)
|
|
{
|
|
g_sys_conf.expo[i] = (lineEdit_expo_mat[i]->text()).toInt();
|
|
g_sys_conf.gain[i] = (lineEdit_gain_mat[i]->text()).toInt();
|
|
g_sys_conf.filter[i] = (lineEdit_filter_mat[i]->text()).toInt();
|
|
}
|
|
write_config();
|
|
QMessageBox::information(NULL, QStringLiteral("提示"), QStringLiteral("保存参数成功,部分配置需要重启程序后生效"), QMessageBox::Ok);
|
|
}
|
|
void DialogSetup::on_pushButton_close_released()
|
|
{
|
|
this->close();
|
|
}
|
|
void DialogSetup::write_pswd()
|
|
{
|
|
std::fstream cfg_file;
|
|
cfg_file.open("pswd.txt", std::ios::out | std::ios::trunc);
|
|
if (cfg_file.good())
|
|
{
|
|
char buf[256];
|
|
memset(buf, 0, 256);
|
|
sprintf(buf, "%s", g_admin_pswd.toStdString().c_str());
|
|
cfg_file.write(buf, strlen(buf));
|
|
}
|
|
cfg_file.close();
|
|
}
|
|
void DialogSetup::write_pswd_op()
|
|
{
|
|
std::fstream cfg_file;
|
|
cfg_file.open("pswd_op.txt", std::ios::out | std::ios::trunc);
|
|
if (cfg_file.good())
|
|
{
|
|
char buf[256];
|
|
memset(buf, 0, 256);
|
|
sprintf(buf, "%s", g_op_pswd.toStdString().c_str());
|
|
cfg_file.write(buf, strlen(buf));
|
|
}
|
|
cfg_file.close();
|
|
}
|
|
void DialogSetup::write_config()
|
|
{
|
|
std::fstream cfg_file;
|
|
cfg_file.open("../conf/conf.txt", std::ios::out | std::ios::trunc);
|
|
if (cfg_file.good())
|
|
{
|
|
char buf[256];
|
|
memset(buf, 0, 256);
|
|
sprintf(buf, "SAVE=%d\n", g_sys_conf.save);
|
|
cfg_file.write(buf, strlen(buf));
|
|
memset(buf, 0, 256);
|
|
sprintf(buf, "MISMATCHACT=%d\n", g_sys_conf.MisMatchAct);
|
|
cfg_file.write(buf, strlen(buf));
|
|
memset(buf, 0, 256);///
|
|
sprintf(buf, "SAVE_DAYS=%d\n", g_sys_conf.save_days);
|
|
cfg_file.write(buf, strlen(buf));
|
|
memset(buf, 0, 256);
|
|
sprintf(buf, "AUTO_OPEN=%d\n", g_sys_conf.auto_open);
|
|
cfg_file.write(buf, strlen(buf));
|
|
memset(buf, 0, 256);
|
|
sprintf(buf, "AUTO_WORK=%d\n", g_sys_conf.auto_work);
|
|
cfg_file.write(buf, strlen(buf));
|
|
memset(buf, 0, 256);
|
|
sprintf(buf, "AUTO_SHIFT=%d\n", g_sys_conf.auto_shift);
|
|
cfg_file.write(buf, strlen(buf));
|
|
memset(buf, 0, 256);
|
|
sprintf(buf, "TIMING_SHIFT=%d\n", g_sys_conf.timing_shift);
|
|
cfg_file.write(buf, strlen(buf));
|
|
memset(buf, 0, 256);
|
|
sprintf(buf, "SHIFT_A=%d|%d\n", g_sys_conf.shiftA.hour(), g_sys_conf.shiftA.minute());
|
|
cfg_file.write(buf, strlen(buf));
|
|
memset(buf, 0, 256);
|
|
sprintf(buf, "SHIFT_B=%d|%d\n", g_sys_conf.shiftB.hour(), g_sys_conf.shiftB.minute());
|
|
cfg_file.write(buf, strlen(buf));
|
|
memset(buf, 0, 256);
|
|
sprintf(buf, "SHIFT_C=%d|%d\n", g_sys_conf.shiftC.hour(), g_sys_conf.shiftC.minute());
|
|
cfg_file.write(buf, strlen(buf));
|
|
memset(buf, 0, 256);
|
|
sprintf(buf, "*****************************************\n");
|
|
cfg_file.write(buf, strlen(buf));
|
|
#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>0)
|
|
memset(buf, 0, 256);
|
|
sprintf(buf, "EXPO1=%d\n", g_sys_conf.expo[0]);
|
|
cfg_file.write(buf, strlen(buf));
|
|
memset(buf, 0, 256);
|
|
sprintf(buf, "GAIN1=%d\n", g_sys_conf.gain[0]);
|
|
cfg_file.write(buf, strlen(buf));
|
|
sprintf(buf, "FILTER1=%d\n", g_sys_conf.filter[0]);
|
|
cfg_file.write(buf, strlen(buf));
|
|
memset(buf, 0, 256);
|
|
sprintf(buf, "USERID1=%d\n", g_sys_conf.UserID[0]);
|
|
cfg_file.write(buf, strlen(buf));
|
|
memset(buf, 0, 256);
|
|
sprintf(buf, "NO1=%d|%d|%d\n", g_sys_conf.no[0][0],g_sys_conf.no[0][1],g_sys_conf.no[0][2]);
|
|
cfg_file.write(buf, strlen(buf));
|
|
memset(buf, 0, 256);
|
|
sprintf(buf, "SHOOT1=%d\n", g_sys_conf.shoot[0]);
|
|
cfg_file.write(buf, strlen(buf));
|
|
memset(buf, 0, 256);
|
|
sprintf(buf, "*****************************************\n");
|
|
cfg_file.write(buf, strlen(buf));
|
|
#endif
|
|
#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>1)
|
|
memset(buf, 0, 256);
|
|
sprintf(buf, "EXPO2=%d\n", g_sys_conf.expo[1]);
|
|
cfg_file.write(buf, strlen(buf));
|
|
memset(buf, 0, 256);
|
|
sprintf(buf, "GAIN2=%d\n", g_sys_conf.gain[1]);
|
|
cfg_file.write(buf, strlen(buf));
|
|
memset(buf, 0, 256);
|
|
sprintf(buf, "FILTER2=%d\n", g_sys_conf.filter[1]);
|
|
cfg_file.write(buf, strlen(buf));
|
|
sprintf(buf, "USERID2=%d\n", g_sys_conf.UserID[1]);
|
|
cfg_file.write(buf, strlen(buf));
|
|
memset(buf, 0, 256);
|
|
sprintf(buf, "NO2=%d|%d|%d\n", g_sys_conf.no[1][0],g_sys_conf.no[1][1],g_sys_conf.no[1][2]);
|
|
cfg_file.write(buf, strlen(buf));
|
|
memset(buf, 0, 256);
|
|
sprintf(buf, "SHOOT2=%d\n", g_sys_conf.shoot[1]);
|
|
cfg_file.write(buf, strlen(buf));
|
|
memset(buf, 0, 256);
|
|
sprintf(buf, "*****************************************\n");
|
|
cfg_file.write(buf, strlen(buf));
|
|
#endif
|
|
#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>2)
|
|
memset(buf, 0, 256);
|
|
sprintf(buf, "EXPO3=%d\n", g_sys_conf.expo[2]);
|
|
cfg_file.write(buf, strlen(buf));
|
|
memset(buf, 0, 256);
|
|
sprintf(buf, "GAIN3=%d\n", g_sys_conf.gain[2]);
|
|
cfg_file.write(buf, strlen(buf));
|
|
memset(buf, 0, 256);
|
|
sprintf(buf, "FILTER3=%d\n", g_sys_conf.filter[2]);
|
|
cfg_file.write(buf, strlen(buf));
|
|
sprintf(buf, "USERID3=%d\n", g_sys_conf.UserID[2]);
|
|
cfg_file.write(buf, strlen(buf));
|
|
memset(buf, 0, 256);
|
|
sprintf(buf, "NO3=%d|%d|%d\n", g_sys_conf.no[2][0],g_sys_conf.no[2][1],g_sys_conf.no[2][2]);
|
|
cfg_file.write(buf, strlen(buf));
|
|
memset(buf, 0, 256);
|
|
sprintf(buf, "SHOOT3=%d\n", g_sys_conf.shoot[2]);
|
|
cfg_file.write(buf, strlen(buf));
|
|
memset(buf, 0, 256);
|
|
sprintf(buf, "*****************************************\n");
|
|
cfg_file.write(buf, strlen(buf));
|
|
#endif
|
|
#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>3)
|
|
memset(buf, 0, 256);
|
|
sprintf(buf, "EXPO4=%d\n", g_sys_conf.expo[3]);
|
|
cfg_file.write(buf, strlen(buf));
|
|
memset(buf, 0, 256);
|
|
sprintf(buf, "GAIN4=%d\n", g_sys_conf.gain[3]);
|
|
cfg_file.write(buf, strlen(buf));
|
|
memset(buf, 0, 256);
|
|
sprintf(buf, "FILTER4=%d\n", g_sys_conf.filter[3]);
|
|
cfg_file.write(buf, strlen(buf));
|
|
sprintf(buf, "USERID4=%d\n", g_sys_conf.UserID[3]);
|
|
cfg_file.write(buf, strlen(buf));
|
|
memset(buf, 0, 256);
|
|
sprintf(buf, "NO4=%d|%d|%d\n", g_sys_conf.no[3][0],g_sys_conf.no[3][1],g_sys_conf.no[3][2]);
|
|
cfg_file.write(buf, strlen(buf));
|
|
memset(buf, 0, 256);
|
|
sprintf(buf, "SHOOT4=%d\n", g_sys_conf.shoot[3]);
|
|
cfg_file.write(buf, strlen(buf));
|
|
memset(buf, 0, 256);
|
|
sprintf(buf, "*****************************************\n");
|
|
cfg_file.write(buf, strlen(buf));
|
|
#endif
|
|
memset(buf, 0, 256);
|
|
sprintf(buf, "MonitorIP=%s\n", g_sys_conf.MonitorIP.c_str());
|
|
cfg_file.write(buf, strlen(buf));
|
|
|
|
memset(buf, 0, 256);
|
|
cfg_file.write(buf, strlen(buf));
|
|
sprintf(buf, "MonitorPort=%d\n", g_sys_conf.MonitorPort);
|
|
cfg_file.write(buf, strlen(buf));
|
|
}
|
|
cfg_file.close();
|
|
}
|
|
void DialogSetup::InitPtrMat()
|
|
{
|
|
#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>0)
|
|
lineEdit_expo_mat[0]=ui.lineEdit_expo_1;
|
|
lineEdit_gain_mat[0]=ui.lineEdit_gain_1;
|
|
lineEdit_filter_mat[0]=ui.lineEdit_filter_1;
|
|
#endif
|
|
#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>1)
|
|
lineEdit_expo_mat[1]=ui.lineEdit_expo_2;
|
|
lineEdit_gain_mat[1]=ui.lineEdit_gain_2;
|
|
lineEdit_filter_mat[1]=ui.lineEdit_filter_2;
|
|
#endif
|
|
#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>2)
|
|
lineEdit_expo_mat[2]=ui.lineEdit_expo_3;
|
|
lineEdit_gain_mat[2]=ui.lineEdit_gain_3;
|
|
lineEdit_filter_mat[2]=ui.lineEdit_filter_3;
|
|
#endif
|
|
#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>3)
|
|
lineEdit_expo_mat[3]=ui.lineEdit_expo_4;
|
|
lineEdit_gain_mat[3]=ui.lineEdit_gain_4;
|
|
lineEdit_filter_mat[3]=ui.lineEdit_filter_4;
|
|
#endif
|
|
}
|
|
|
|
void DialogSetup::on_pushButton_config_released()
|
|
{
|
|
if (m_camera_glue)delete m_camera_glue;
|
|
m_camera_glue = new camera_glue(this);
|
|
connect(m_camera_glue, &camera_glue::sendMsgToDialogSetup,this, &DialogSetup::recMsgFromDialogConfig);
|
|
connect(this, &DialogSetup::sendMsgToConfig,m_camera_glue, &camera_glue::recMsgFromDialogSetup);
|
|
m_camera_glue->show();
|
|
m_camera_glue->move(this->geometry().center() - m_camera_glue->rect().center());//移动父窗口中心位置
|
|
emit sendMsgToConfig(g_sys_conf.no);
|
|
}
|
|
void DialogSetup::recMsgFromDialogConfig(int ptr[][3])
|
|
{
|
|
for(int i=0;i<NumberOfSupportedCameras;i++)
|
|
for(int j=0;j<3;j++)
|
|
g_sys_conf.no[i][j]=ptr[i][j];
|
|
}
|
|
void DialogSetup::on_pushButton_change_released()
|
|
{
|
|
if (m_change_shift)delete m_change_shift;
|
|
m_change_shift = new change_shift(this);
|
|
connect(m_change_shift, &change_shift::sendMsgToDialogSetup, this, &DialogSetup::recMsgFromChangeShift);
|
|
connect(this, &DialogSetup::sendMsgToShift, m_change_shift, &change_shift::recMsgFromDialogSetup);
|
|
m_change_shift->show();
|
|
m_change_shift->move(this->geometry().center() - m_change_shift->rect().center());
|
|
emit sendMsgToShift(g_sys_conf.shiftA, g_sys_conf.shiftB, g_sys_conf.shiftC);
|
|
}
|
|
void DialogSetup::on_pushButton_statistic_released()
|
|
{
|
|
if (m_output_statistic)delete m_output_statistic;
|
|
m_output_statistic = new output_statistic(this);
|
|
connect(this, &DialogSetup::sendMsgToOutput, m_output_statistic, &output_statistic::recMsgFromDialogSetup);
|
|
m_output_statistic->show();
|
|
m_output_statistic->move(this->geometry().center() - m_output_statistic->rect().center());
|
|
emit sendMsgToOutput();
|
|
}
|
|
void DialogSetup::recMsgFromChangeShift(QTime timeA, QTime timeB, QTime timeC)
|
|
{
|
|
g_sys_conf.shiftA.setHMS(timeA.hour(), timeA.minute(), 0);
|
|
g_sys_conf.shiftB.setHMS(timeB.hour(), timeB.minute(), 0);
|
|
g_sys_conf.shiftC.setHMS(timeC.hour(), timeC.minute(), 0);
|
|
} |