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.
whellvalue/tpvs17/tpMain/QAlgParamDlg.cpp

132 lines
4.1 KiB
C++

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#include "QAlgParamDlg.h"
#include "qshowimg.h"
#include <QFileDialog>
#include <QMessageBox>
#include "lpGlobalConfig.h"
#pragma execution_character_set("utf-8")
QAlgParamDlg::QAlgParamDlg(QWidget *parent)
: QWidget(parent)
{
ui.setupUi(this);
connect(ui.m_pbShowBackImage, SIGNAL(clicked()), this, SLOT(onButtonClicked()));
connect(ui.m_pbApply, SIGNAL(clicked()), this, SLOT(onButtonClicked()));
connect(ui.m_pbExit, SIGNAL(clicked()), this, SLOT(onButtonClicked()));
ui.label->setVisible(false);
}
QAlgParamDlg::~QAlgParamDlg()
{
}
Q_SLOT void QAlgParamDlg::onButtonClicked()
{
QString strObj = sender()->objectName();
if (strObj == "m_pbShowBackImage")
{
QShowImg m_showImgDlg(this);
m_showImgDlg.setWindowFlags(Qt::Dialog | Qt::WindowCloseButtonHint);
m_showImgDlg.setWindowModality(Qt::ApplicationModal);
m_showImgDlg.setAttribute(Qt::WA_ShowModal, true);
m_showImgDlg.setWindowIcon(QIcon(":/image/leaper"));
QString DstPath = ".\\user\\background.png";
connect(&m_showImgDlg, SIGNAL(sgChangeImg()), this, SLOT(onChangeBG()));
connect(this, SIGNAL(sgChangeBG(QString)), &m_showImgDlg, SLOT(setPicPath(QString)));
m_showImgDlg.setPicPath(DstPath);
m_showImgDlg.exec();
}
else if (strObj == "m_pbApply")
{
getParam();
ui.label->setVisible(true);
m_timeID = startTimer(1000);
emit sgParamChange();
}
else if (strObj == "m_pbExit")
{
close();
}
}
void QAlgParamDlg::showEvent(QShowEvent *event)
{
setParam();
}
void QAlgParamDlg::timerEvent(QTimerEvent *event)
{
if (m_timeID == event->timerId())
{
killTimer(m_timeID);
m_timeID = 0;
ui.label->setVisible(false);
}
}
void QAlgParamDlg::setParam()
{
ui.checkBox->setChecked(lpGlobalConfig::instance()->algParam.m_UseBackground == 0 ? false : true);
ui.checkBox_equal->setChecked(lpGlobalConfig::instance()->algParam.m_bUseEqual);
ui.spinBox_filterSize->setValue(lpGlobalConfig::instance()->algParam.m_filterSize);
ui.spinBox_circle_ACThres->setValue(lpGlobalConfig::instance()->algParam.m_Circle_ACThres);
ui.spinBox_circle_EdgeWidth->setValue(lpGlobalConfig::instance()->algParam.m_Circle_EdgeWidth);
ui.comboBox_transform->setCurrentIndex(lpGlobalConfig::instance()->algParam.m_Circle_Polarity);
//ui.checkBox_ratio->setChecked(lpGlobalConfig::instance()->algParam.m_RatioDetectType==0?false:true);
}
void QAlgParamDlg::getParam()
{
lpGlobalConfig::instance()->algParam.m_UseBackground = ui.checkBox->isChecked();
lpGlobalConfig::instance()->algParam.m_bUseEqual = ui.checkBox_equal->isChecked();
lpGlobalConfig::instance()->algParam.m_filterSize = ui.spinBox_filterSize->value();
lpGlobalConfig::instance()->algParam.m_Circle_ACThres = ui.spinBox_circle_ACThres->value();
lpGlobalConfig::instance()->algParam.m_Circle_EdgeWidth = ui.spinBox_circle_EdgeWidth->value();
lpGlobalConfig::instance()->algParam.m_Circle_Polarity = ui.comboBox_transform->currentIndex();
//lpGlobalConfig::instance()->algParam.m_RatioDetectType = ui.checkBox_ratio->isChecked();
lpGlobalConfig::instance()->save();
}
Q_SLOT void QAlgParamDlg::onChangeBG()
{
QFileDialog fileDialog;
fileDialog.setWindowTitle(tr("<EFBFBD><EFBFBD>ѡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD><EFBFBD><EFBFBD>ͼ"));
fileDialog.setNameFilter("Picture(*.bmp *.jpg *.png)");
fileDialog.setFileMode(QFileDialog::ExistingFiles);
if (fileDialog.exec() == QDialog::Accepted)
{
QStringList backgroundFile = fileDialog.selectedFiles();
if (backgroundFile.size() > 0)
{
QString DstPath = QApplication::applicationDirPath() + "\\user\\background.png";
QString sourcePath = backgroundFile.at(0);
DstPath.replace("\\", "/");
if (sourcePath == DstPath) {
// //return;
// //return true;
}
if (!QFile::exists(sourcePath)) {
//return false;
}
QDir *createfile = new QDir;
bool exist = createfile->exists(DstPath);
if (exist) {
//if (converFileIfExist){
createfile->remove(DstPath);
//}
}
if (!QFile::copy(sourcePath, DstPath)) {
//return false;
}
//emit sgChangeBG(DstPath);
QMessageBox infobox(QMessageBox::Information, tr("<EFBFBD><EFBFBD>ʾ"), tr("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>."), QMessageBox::Yes, NULL);
infobox.setWindowIcon(QIcon(":/image/leaper"));
infobox.setButtonText(QMessageBox::Yes, tr("ȷ<EFBFBD><EFBFBD>"));
infobox.exec();
}
}
}