hlp:桂林国际齿轮泵代码

This commit is contained in:
kite_lucs
2026-10-09 10:25:24 +08:00
commit fd606b3c81
2447 changed files with 999531 additions and 0 deletions
@@ -0,0 +1,741 @@
#include "TriggerCtrl.h"
#include "ui_triggerctrl.h"
#include <QCheckBox>
#include <QMessageBox>
#include <QValidator>
#include <QDoubleValidator>
#include "qdebug.h"
#include <stdio.h>
#include "myinclude.h"
#include "Public.h"
#include "VerBVersion.h"
#include "DevOp.h"
#include "InkJetPrinter.h"
extern InkJetPrinter *pInkJectPrinter;
/* readme: 20140809
1. 同步字宽mm: 0.1+ w*(4-0.1) = 0.1+3.9w (mm)
2. 按长度喷印:
*/
// 20140923-12:05版本存在图形方式下变量不变绿问题,新版本已经更正
// 20141013-16:36修正密码有效期设置错误。
//2015-10-17 二维码变量问题
// 2015-11-01 无聊: 要从V6S版本恢复原来的 para.set_HVData_Flag = 0; 参数
// 估计过段时间又要要求增加 UART功能。 V6S 原来已经有这个功能了。但他们不用!!
// 20151109 新增计数1和计数器2单独立即清零 版本号 No42
// 更新了Vietname字库,使用中文使用wenquanyiBitmap,编译uncode编码使用wenquanyimicrohei,英文自己编,越南语自己编,基于DejaVu Sans
// 新版软件更新或升级,会因参数错位,出现隔膜位置设定值(等参数)错误,引起主墨泵不工作,开机不循环等现象。(解决办法,重新检查并设置所有参数)
// 20160203:修改了变量定位方式,更新的Image图片。 将左下角更换为RGB = 250,250,0 -=== 0xFFF7FC00
// 修正了停止打印关闭高压的问题,重新打印出现高压故障
// 修改了密码一周一变,增加了密码校验,需要使用新版20以上的手机密码软件,密码为7位;
// 20160218 修改了提示框显示方式,避免提示阻塞处理进程
// 20160304 优化了变量显示; 增加了中心旋转交替功能;增加了 13位随机码打印功能; 修正界面显示字库部分汉字问题
// 本次修改需要同时更并按ARM和FPGA
// FPGA实现自动点距调整,实现连续点位置修正 20160714 FPGA版本 V44, 0714B
// 20160715 : 去掉了“点距电压微调”、“内存数据显示”、部分相检控制参数设置
// 20160729: 发现打开历史记录会死机问题,原因待查。但执行删除历史记录后,可避免再次死机。
// 20160723: 增加电眼复位功能。 与电眼清零不同,复位时,计数不清零,而是等于预设的当前值。
// 20160718: 参考日立方案,优化打印效果
/*
20160728:发现历史记录打开时,会死机
20160729: 查找原因:fi
// 20160806:重要修改 : 毫米脉冲的系数由X8改为X256,原因是:使用X8时传递误差较大,导致1000mm会有6mm误差, 使用X256(即8位二进制表示小数时,可以精确到0.004,从而提高精度)
X8 时,小数精度为0.125而已
20160812:增加左横,右横变量
if((varType<9) // 普通变量
||(varType>=20 && varType<29) // 横左变量
||(varType>=40 && varType<49) // 右横变量
if(fontname.contains("SerifL") ||fontname.contains("serifl") ) varType1= 20+varType;
else if(fontname.contains("SerifR") ||fontname.contains("serifr") ) varType1= 40+varType;
20160831: 增加临时密码,每小时一变
20160904: 解决重新开机后,有时不能自动打印文件问题。
20160905: 第二行单独变量时显示不全问题
// 20160912: 去掉高压故障自动关闭回收的默认值 1
// 20160912: 设置了隐藏按键,用于对墨线时间和开机次数进行复位 No49
20160927: FIFO实现RAND 码上传,暂时与RST0806 No49区别开来 No50
20161212: 修改总产品计数器清零功能。由ARM清零改为FPGA清零 No51 // [3]总产品计数器清零FPGA
20161217: 增加了 SPV210编译选项,以处理V6核心版驱动问题
修改随机码处理函数,以解决 不能输出奇数位 随机码问题。
20170217: 有厂家只想打一条横线,改最小列点阵数。
20170224: 输入密码不回显
20170313: 修改开机重启或重载参数时,设定计数当前值为起始值
20170318: 制作0318版本的刷机文件
20170803: 增加外接屏功能,20170808完成
*/
#ifdef MIMA
#ifdef ALT16
#define BVER "(ALT53)" TST // 20160801 之前使用 RST46
#else
#define BVER "(SUN53)" TST // 20160801 之前使用 RST46
#endif
#endif
//#define NON_CABLE//喷印间隔固定
// 20160507 1138
// 20161209 编辑 小数点喷印间隔
// 20170603: 太阳能条码专用版本
// Nam Ninh phồng tuyệt vời Mã Technology Co., Ltd.
TriggerCtrl::TriggerCtrl(QWidget *parent) :
QWidget(parent),
ui(new Ui::TriggerCtrl)
{
ui->setupUi(this);
//#ifdef SYNLENFLOAT
QRegExp double_rx100("10000000|([0-9]{1,8}[\.][0-9]{0,1})");
ui->spinBoxSynTriggerPrintLen->setValidator(new QRegExpValidator(double_rx100,ui->spinBoxSynTriggerPrintLen));
#ifdef NON_CABLE
ui->spinBoxSynTriggerPrintLen->setEnabled(0);
#endif
//#endif
pulseNumFix = new PulseNumFix(parent);
pulseNumFix->hide();
ui->lineEditTriggerPulsePerMm->setValidator(new QDoubleValidator(0));
connect(pulseNumFix,SIGNAL(pulseNuxFixDone(float)),this,SLOT(onPulseNumFixDone(float)));
//ui->test_version->setText (tr(BUILD_DATE));
updateSysStatusToUI();
QString s;
#if 0 /* roger use new Version manage,so delete it */
s.sprintf(" %s ",__TIME__);
#ifdef MYTEST
s = (QString) Public::DateToString(__DATE__)+s + "A2451测试";
#else
s = (QString) Public::DateToString(__DATE__)+s + BVER;
#endif
#else
s.sprintf("%d.%d.%02d_GuiL_V2_", UP_PRINTER_MAJOR_VER, UP_PRINTER_MINOR_VER,UP_PRINTER_RIVISION_VER);
s = s + (QString) Public::DateToString(__DATE__)+"_"+ QString(__TIME__)+"_"+ UP_PRINTER_STAGE_VER;
//s = s + BVER;
#endif
ui->test_version->setText(s);
ui->checkBoxEleEyeMakeClean->setVisible(false);
tr("独立参数");
//ui->labelDelayTriggerValue->setText(tr("重复间隔(毫秒)"));
//--if( QString(BUILD_DATE).left(21)!="2015-10-26 20:56(M40)"){
//--ui->labelEleMaskTime->hide();
//--ui->spinBoxEleMaskTime->hide();
//--}
if(Public::ReadLanguageName()=="Chinese"){
ui->label_miv12->setPixmap(QPixmap(QString::fromUtf8(":/image/MIV12.png")));
}else
{
ui->label_miv12->setPixmap(QPixmap(QString::fromUtf8(":/image/MIV13.png")));
}
//qDebug()<<"Run TriggerCtrl ok.";
#ifdef ENGLISH
ui->label_miv12->setPixmap(QPixmap(QString::fromUtf8(":/image/MIV13.png")));
#endif
ui->spinBoxOuputPulseCol->setHidden(1);
// ui->labelOuputPulseCol->setHidden(1);
}
TriggerCtrl::~TriggerCtrl()
{
delete ui;
delete pulseNumFix;
}
void TriggerCtrl::setTriggerUI(int triggerMode){
ui->radioButtonDelayTrigger->setChecked(triggerMode == PRINT_TRIGGER_TIME);
ui->spinBoxDelayTriggerValue->setEnabled(triggerMode == PRINT_TRIGGER_TIME);
ui->labelDelayTriggerValue->setEnabled(triggerMode == PRINT_TRIGGER_TIME);
ui->comboBoxTimeTriggerMode->setEnabled(triggerMode == PRINT_TRIGGER_TIME);
ui->labelTimeTriggerMode->setEnabled(triggerMode == PRINT_TRIGGER_TIME);
ui->radioButtonEleEyeEdgetTrigger->setChecked( triggerMode == PRINT_TRIGGER_ELEC_EYE_EDGE);
ui->radioButtonEleEyeLevelTrigger->setChecked(triggerMode == PRINT_TRIGGER_ELEC_EYE_VOLTATE_LEVEL);
ui->spinBoxEleEyeTriggerIntervalMs->setEnabled(triggerMode == PRINT_TRIGGER_ELEC_EYE_VOLTATE_LEVEL || triggerMode == PRINT_TRIGGER_ELEC_EYE_EDGE);
ui->labelEleEyeTriggerIntervalMs->setEnabled(triggerMode == PRINT_TRIGGER_ELEC_EYE_VOLTATE_LEVEL || triggerMode == PRINT_TRIGGER_ELEC_EYE_EDGE);
ui->spinBoxEleEyeTriggerRepeatCnt->setEnabled(triggerMode == PRINT_TRIGGER_ELEC_EYE_VOLTATE_LEVEL || triggerMode == PRINT_TRIGGER_ELEC_EYE_EDGE);
ui->labelEleEyeTriggerRepeatCnt->setEnabled(triggerMode == PRINT_TRIGGER_ELEC_EYE_VOLTATE_LEVEL || triggerMode == PRINT_TRIGGER_ELEC_EYE_EDGE);
ui->spinBoxEleEyeTriggerPrintDelay->setEnabled(triggerMode == PRINT_TRIGGER_ELEC_EYE_VOLTATE_LEVEL || triggerMode == PRINT_TRIGGER_ELEC_EYE_EDGE || PRINT_TRIGGER_SYNCHRONIZER);
ui->labelEleEyeTriggerPrintDelay->setEnabled(triggerMode == PRINT_TRIGGER_ELEC_EYE_VOLTATE_LEVEL || triggerMode == PRINT_TRIGGER_ELEC_EYE_EDGE || PRINT_TRIGGER_SYNCHRONIZER);
ui->checkBoxSynMakeClean->setEnabled(triggerMode == PRINT_TRIGGER_ELEC_EYE_VOLTATE_LEVEL || triggerMode == PRINT_TRIGGER_ELEC_EYE_EDGE);
ui->checkEyeTriggerSynPrintEn->setEnabled (triggerMode == PRINT_TRIGGER_ELEC_EYE_VOLTATE_LEVEL || triggerMode == PRINT_TRIGGER_ELEC_EYE_EDGE);
ui->labelEleMaskTime->setEnabled (triggerMode == PRINT_TRIGGER_ELEC_EYE_VOLTATE_LEVEL || triggerMode == PRINT_TRIGGER_ELEC_EYE_EDGE);
ui->spinBoxEleMaskTime->setEnabled (triggerMode == PRINT_TRIGGER_ELEC_EYE_VOLTATE_LEVEL || triggerMode == PRINT_TRIGGER_ELEC_EYE_EDGE);
if(sysPara->para.eleEyeTriggerSynPrintEn &&
(triggerMode == PRINT_TRIGGER_ELEC_EYE_VOLTATE_LEVEL || triggerMode == PRINT_TRIGGER_ELEC_EYE_EDGE)
)
{
//ui->radioButtonSynTrigger->setChecked(1);
ui->spinBoxSynTriggerPrintLen->setEnabled(0);
ui->labelSynTriggerPrintLen->setEnabled(1);
ui->lineEditTriggerPulsePerMm->setEnabled(1);
ui->labelTriggerPulsePerMm->setEnabled(1);
ui->spinBoxSynTriggerPrintLenRatio->setEnabled(1);
ui->labelSynTriggerPrintLenRatio->setEnabled(1);
ui->checkBoxEleEyeMakeClean->setEnabled(1);
ui->pushButtonApplyPulseFix->setEnabled(1);
ui->comboBoxSynPrintMode->setEnabled(1);
ui->labelSynPrintMode->setEnabled(1);
//ui->checkBoxAutoSpeedEN->setEnabled (1);
ui->labelEleMaskTime->setEnabled(1);
ui->spinBoxEleMaskTime->setEnabled(1);
//ui->spinBoxEleMaskTime->setEnabled(1);
ui->labelEleEyeTriggerPrintDelay->setText(tr("触发延时(毫米)"));
ui->labelEleEyeTriggerIntervalMs->setText(tr("重复间隔(毫米)"));
ui->labelEleMaskTime->setText(tr("封锁间隔(毫米)"));
}
else
{
ui->radioButtonSynTrigger->setChecked(triggerMode == PRINT_TRIGGER_SYNCHRONIZER);
#ifndef NON_CABLE
ui->spinBoxSynTriggerPrintLen->setEnabled(triggerMode == PRINT_TRIGGER_SYNCHRONIZER);
#endif
ui->labelSynTriggerPrintLen->setEnabled(triggerMode == PRINT_TRIGGER_SYNCHRONIZER);
ui->lineEditTriggerPulsePerMm->setEnabled(triggerMode == PRINT_TRIGGER_SYNCHRONIZER);
ui->labelTriggerPulsePerMm->setEnabled(triggerMode == PRINT_TRIGGER_SYNCHRONIZER);
ui->spinBoxSynTriggerPrintLenRatio->setEnabled(triggerMode == PRINT_TRIGGER_SYNCHRONIZER);
ui->labelSynTriggerPrintLenRatio->setEnabled(triggerMode == PRINT_TRIGGER_SYNCHRONIZER);
ui->checkBoxEleEyeMakeClean->setEnabled(triggerMode == PRINT_TRIGGER_SYNCHRONIZER);
ui->pushButtonApplyPulseFix->setEnabled(triggerMode == PRINT_TRIGGER_SYNCHRONIZER);
ui->comboBoxSynPrintMode->setEnabled(triggerMode == PRINT_TRIGGER_SYNCHRONIZER);
ui->labelSynPrintMode->setEnabled(triggerMode == PRINT_TRIGGER_SYNCHRONIZER);
//ui->checkBoxAutoSpeedEN->setEnabled (triggerMode == PRINT_TRIGGER_SYNCHRONIZER);
//ui->labelEleMaskTime->setEnabled(triggerMode == PRINT_TRIGGER_SYNCHRONIZER);
//ui->spinBoxEleMaskTime->setEnabled(triggerMode == PRINT_TRIGGER_SYNCHRONIZER);
if(triggerMode == PRINT_TRIGGER_SYNCHRONIZER)
{
ui->labelEleEyeTriggerPrintDelay->setText(tr("触发延时(毫米)"));
}
else
{
ui->labelEleEyeTriggerPrintDelay->setText(tr("触发延时(毫秒)"));
}
ui->labelEleEyeTriggerIntervalMs->setText(tr("重复间隔(毫秒)"));
ui->labelEleMaskTime->setText(tr("封锁时间(毫秒)"));
}
if(( ( //sysPara->para.eleEyeTriggerSynPrintEn ||
ui->checkEyeTriggerSynPrintEn->isChecked())
&&(triggerMode == PRINT_TRIGGER_ELEC_EYE_VOLTATE_LEVEL || triggerMode == PRINT_TRIGGER_ELEC_EYE_EDGE))
|| triggerMode == PRINT_TRIGGER_SYNCHRONIZER )
{
ui->labelOutputPulseDelayMs->setText(tr("延时(毫米):"));
}
else ui->labelOutputPulseDelayMs->setText(tr("延时(毫秒):"));
setSynPrintMode(sysPara->para.sysTriggerPrintMode);
//72版本禁用该输入框
//67打开
// if(triggerMode== PRINT_TRIGGER_SYNCHRONIZER){
// const unsigned short &FpgaVer=sysPara->status.build_dat.builTime;
// if(72==FpgaVer)
// {
// ui->spinBoxSynTriggerPrintLenRatio->setValue(0);
// ui->spinBoxSynTriggerPrintLenRatio->setEnabled(false);
// }
// else if(67==FpgaVer)
// {
// ui->spinBoxSynTriggerPrintLenRatio->setEnabled(true);
// }
// }
// else{
// ui->spinBoxSynTriggerPrintLenRatio->setValue(0);
// ui->spinBoxSynTriggerPrintLenRatio->setEnabled(false);
// }
}
void TriggerCtrl::setSynPrintMode(int mode){
ui->labelSynTriggerPrintLenRatio->setText((mode == SYN_PRINT_MODE_ACCORDING_CHAR_WIDTH)?tr("字符宽度"):tr("喷印比例(%)"));
ui->comboBoxSynPrintMode->setCurrentIndex(mode);
//ui->spinBoxSynTriggerPrintLenRatio->setValue((mode == SYN_PRINT_MODE_ACCORDING_CHAR_WIDTH)?sysPara->para.synCharWidthRatio:sysPara->para.synTriggerPrintLenRatio);
//edit@11-18
if(SYN_PRINT_MODE_ACCORDING_CHAR_WIDTH!=mode)
{
ui->spinBoxSynTriggerPrintLenRatio->setValue(sysPara->para.synTriggerPrintLenRatio);
}
const bool bShow=SYN_PRINT_MODE_ACCORDING_CHAR_WIDTH!=mode;
//隐藏文本框
ui->labelSynTriggerPrintLenRatio->setVisible(bShow);
//隐藏输入框
ui->spinBoxSynTriggerPrintLenRatio->setVisible(bShow);
}
void TriggerCtrl::GetTriggerUIPara(){
if(sysPara){
sysPara->para.printDelayMs = ui->spinBoxDelayTriggerValue->value();
sysPara->para.timeTriggerPrintMode = ui->comboBoxTimeTriggerMode->currentIndex();
sysPara->para.elecEyeTriggerInterval = ui->spinBoxEleEyeTriggerIntervalMs->value();
sysPara->para.photoElectricityRepeateNum = ui->spinBoxEleEyeTriggerRepeatCnt->value();
//
sysPara->para.synTriggerPrintLenMm = ui->spinBoxSynTriggerPrintLen->text().toFloat();
//sysPara->para.synTriggerPrintLenMm = ui->spinBoxSynTriggerPrintLen->value();
#ifdef NON_CABLE
sysPara->para.synTriggerPrintLenMm = 255.0;
ui->spinBoxSynTriggerPrintLen->setText("255");
#endif
sysPara->para.synPulseNumPerMm = ui->lineEditTriggerPulsePerMm->text().toFloat();
sysPara->para.sysTriggerPrintMode = ui->comboBoxSynPrintMode->currentIndex();
if(sysPara->para.sysTriggerPrintMode == SYN_PRINT_MODE_ACCORDING_CHAR_WIDTH)
//edit@11-19
;//sysPara->para.synCharWidthRatio = ui->spinBoxSynTriggerPrintLenRatio->value();
else
sysPara->para.synTriggerPrintLenRatio = ui->spinBoxSynTriggerPrintLenRatio->value();
// 原代码:
//sysPara->para.AltMirrorGap =(unsigned int) ( ((unsigned int)ui->spinBoxAltMirrorGap->value()) & 0x7fff) | ( ui->comboBoxAltMirrType->currentIndex()==1?0x8000:0x0000);
// 20160303:
sysPara->para.AltMirrorGap =(unsigned int) ( ((unsigned int)ui->spinBoxAltMirrorGap->value()) & 0x0fff) |( ( ui->comboBoxAltMirrType->currentIndex())<<12 );
//qDebug()<< (sysPara->para.AltMirrorGap & 0x0fff) << (sysPara->para.AltMirrorGap & 0xf000);
if(ui->radioButtonDelayTrigger->isChecked())
sysPara->para.printTriggerMode = PRINT_TRIGGER_TIME;
else if(ui->radioButtonEleEyeLevelTrigger->isChecked())
sysPara->para.printTriggerMode = PRINT_TRIGGER_ELEC_EYE_VOLTATE_LEVEL;
else if(ui->radioButtonEleEyeEdgetTrigger->isChecked())
sysPara->para.printTriggerMode = PRINT_TRIGGER_ELEC_EYE_EDGE;
else if(ui->radioButtonSynTrigger->isChecked())
sysPara->para.printTriggerMode = PRINT_TRIGGER_SYNCHRONIZER;
else
sysPara->para.printTriggerMode = PRINT_TRIGGER_NONE;
sysPara->para.eleEyeTriggerSynPrintEn = ui->checkEyeTriggerSynPrintEn->isChecked ();
sysPara->para.eleEyeTriggerPrintDelay = ui->spinBoxEleEyeTriggerPrintDelay->value();
sysPara->para.synClearCntInEleEyeMode = ui->checkBoxSynMakeClean->isChecked();
sysPara->para.eleEyeClearCntInSynMode = (sysPara->para.eleEyeClearCntInSynMode & 0xf0) + ui->comboBoxEleEyeMakeClean->currentIndex(); //ui->checkBoxEleEyeMakeClean->isChecked();
//sysPara->para.autoSynSpeedEn = ui->checkBoxAutoSpeedEN->isChecked ();
sysPara->para.autoSynSpeedEn = 0;
//sysPara->para.synPulsePerMmX8 = (unsigned short)(sysPara->para.synPulseNumPerMm *256);
sysPara->para.synPulsePerMmX8 = (unsigned short)((unsigned int)sysPara->para.synPulseNumPerMm <<8);
sysPara->para.eleMaskTime = ui->spinBoxEleMaskTime->value();
//qDebug()<<"eleEyeClearCntInSynMode"<< sysPara->para.eleEyeClearCntInSynMode ;
sysPara->para.synchronizorActType = ui->comboBoxSyncActType->currentIndex();
//qDebug()<<"synchronizorActType"<< sysPara->para.synchronizorActType;
sysPara->para.pulse_sinal_value = ui->spinBoxpluseSinal->value();
}
}
void TriggerCtrl::TriggerupdateSysParaToUI(){
updateSysParaToUI();
}
void TriggerCtrl::updateSysParaToUI(){
if(sysPara)
{
/*----------------------------------------*/
setTriggerUI(sysPara->para.printTriggerMode);
ui->spinBoxDelayTriggerValue->setValue(sysPara->para.printDelayMs);
#ifndef NON_CABLE
ui->comboBoxTimeTriggerMode->setCurrentIndex(sysPara->para.timeTriggerPrintMode);
#endif
ui->spinBoxEleEyeTriggerIntervalMs->setValue(sysPara->para.elecEyeTriggerInterval);
ui->spinBoxOutputPulseDelayMs->setValue(sysPara->para.outputPulseDelayMs);
ui->spinBoxEleEyeTriggerRepeatCnt->setValue(sysPara->para.photoElectricityRepeateNum);
//ui->spinBoxSynTriggerPrintLen->setValue(sysPara->para.synTriggerPrintLenMm);
ui->spinBoxSynTriggerPrintLen->setText(QString::number(sysPara->para.synTriggerPrintLenMm));
ui->lineEditTriggerPulsePerMm->setText(QString::number(sysPara->para.synPulseNumPerMm));
if(sysPara->para.sysTriggerPrintMode == SYN_PRINT_MODE_ACCORDING_CHAR_WIDTH)
//edit@11-19
;//ui->spinBoxSynTriggerPrintLenRatio->setValue(sysPara->para.synCharWidthRatio);
else
ui->spinBoxSynTriggerPrintLenRatio->setValue(sysPara->para.synTriggerPrintLenRatio);
/*----------------------------------------*/
ui->spinBoxEleEyeTriggerPrintDelay->setValue(sysPara->para.eleEyeTriggerPrintDelay);
ui->checkBoxSynMakeClean->setChecked(sysPara->para.synClearCntInEleEyeMode);
//ui->checkBoxEleEyeMakeClean->setChecked(sysPara->para.eleEyeClearCntInSynMode);
ui->comboBoxEleEyeMakeClean->setCurrentIndex( sysPara->para.eleEyeClearCntInSynMode & 0x0f);
ui->checkBoxPulseOutputEnable->setChecked(sysPara->para.pulseOutputEnable);
ui->labelProductCntPerOutputPulse->setEnabled(sysPara->para.pulseOutputEnable);
ui->spinBoxProductCntPerOutputPulse->setEnabled(sysPara->para.pulseOutputEnable);
ui->spinBoxProductCntPerOutputPulse->setValue(sysPara->para.productCntPerOutputPulse);
ui->labelOutputPulseDelayMs->setEnabled(sysPara->para.pulseOutputEnable);
//ui->spinBoxOutputPulseDelayMs->setEnabled(sysPara->para.pulseOutputEnable);
ui->spinBoxOutputPulseDelayMs->setEnabled(true /*sysPara->para.outputPulseDelayMs*/);
ui->spinBoxOuputPulseCol->setValue(sysPara->para.OuputPulseCol);
ui->checkEyeTriggerSynPrintEn->setChecked (sysPara->para.eleEyeTriggerSynPrintEn);
ui->comboBoxSyncActType->setCurrentIndex (sysPara->para.synchronizorActType);
//ui->checkBoxAutoSpeedEN->setChecked (sysPara->para.autoSynSpeedEn );
ui->spinBoxEleMaskTime->setValue(sysPara->para.eleMaskTime);
ui->spinBoxAltMirrorGap->setValue( sysPara->para.AltMirrorGap & 0x0fff );
ui->comboBoxAltMirrType->setCurrentIndex( (sysPara->para.AltMirrorGap>>12) & 0x000F);
ui->spinBoxpluseSinal->setValue(sysPara->para.pulse_sinal_value);
//72版本禁用该输入框
//67打开
}
}
void TriggerCtrl::applyUIPara(){
if(sysPara){
GetTriggerUIPara();
if(sysPara->para.printTriggerMode == PRINT_TRIGGER_SYNCHRONIZER)
{
if( sysPara->para.synTriggerPrintLenMm < sysPara->para.eleEyeTriggerPrintDelay )
{
QMessageBox::information(this,tr("提示:参数不正确"),tr("要求:触发长度小于喷印间隔"));
}
}
sysPara->para.pulseOutputEnable = ui->checkBoxPulseOutputEnable->isChecked();
sysPara->para.productCntPerOutputPulse = ui->spinBoxProductCntPerOutputPulse->value();
sysPara->para.outputPulseDelayMs = ui->spinBoxOutputPulseDelayMs->value();
sysPara->para.OuputPulseCol = ui->spinBoxOuputPulseCol->value();
if(( ( //sysPara->para.eleEyeTriggerSynPrintEn ||
ui->checkEyeTriggerSynPrintEn->checkState()==1 )
&&(sysPara->para.printTriggerMode == PRINT_TRIGGER_ELEC_EYE_VOLTATE_LEVEL || sysPara->para.printTriggerMode == PRINT_TRIGGER_ELEC_EYE_EDGE))
|| sysPara->para.printTriggerMode == PRINT_TRIGGER_SYNCHRONIZER )
{
ui->labelOutputPulseDelayMs->setText(tr("延时(毫米):"));
}
else ui->labelOutputPulseDelayMs->setText(tr("延时(毫秒):"));
#ifdef DEBUG1
qDebug()<<"TriggerCtrl::applyUIPara"<<"1";
#endif
if(sysPara->devOp->writeFpgaPrintPara() != -1)
QMessageBox::information(this,tr("提示"),tr("应用成功"));
#ifdef DEBUG1
qDebug()<<"TriggerCtrl::applyUIPara"<<"3";
#endif
}
}
void TriggerCtrl::updateSysStatusToUI(){
static char t_init = 0;
if(sysPara){
if(t_init == 0){
sysPara->loadParaFromFile();
//qDebug()<<"sysPara->para.pulse_sinal_value="<<sysPara->para.pulse_sinal_value;
ui->spinBoxpluseSinal->setValue(sysPara->para.pulse_sinal_value);
t_init = 1;
}
// if((sysPara->para.printTriggerMode == PRINT_TRIGGER_SYNCHRONIZER))
// {
// ui->lineEditPulseCount ->setText(QString::number((int )((sysPara->para.synTriggerPrintLenMm)*sysPara->para.synPulseNumPerMm)));
// }
// else if(((sysPara->para.printTriggerMode == PRINT_TRIGGER_ELEC_EYE_VOLTATE_LEVEL
// ||sysPara->para.printTriggerMode == PRINT_TRIGGER_ELEC_EYE_EDGE)
// && sysPara->para.eleEyeTriggerSynPrintEn))
// {
// ui->lineEditPulseCount ->setText(QString::number( (int )((sysPara->para.elecEyeTriggerInterval)*sysPara->para.synPulseNumPerMm)));
// }
}
}
void TriggerCtrl::on_checkEyeTriggerSynPrintEn_pressed()
{
#if 0
int triggerMode = sysPara->para.printTriggerMode;
if(sysPara)
{
//if( !sysPara->para.eleEyeTriggerSynPrintEn )
if( !ui->checkEyeTriggerSynPrintEn->isChecked() )
{
//ui->radioButtonSynTrigger->setChecked(1);
ui->spinBoxSynTriggerPrintLen->setEnabled(1);
ui->labelSynTriggerPrintLen->setEnabled(1);
ui->lineEditTriggerPulsePerMm->setEnabled(1);
ui->labelTriggerPulsePerMm->setEnabled(1);
ui->spinBoxSynTriggerPrintLenRatio->setEnabled(1);
ui->labelSynTriggerPrintLenRatio->setEnabled(1);
ui->checkBoxEleEyeMakeClean->setEnabled(1);
ui->pushButtonApplyPulseFix->setEnabled(1);
ui->comboBoxSynPrintMode->setEnabled(1);
ui->labelSynPrintMode->setEnabled(1);
ui->checkBoxAutoSpeedEN->setEnabled (1);
ui->spinBoxEleEyeTriggerIntervalMs->setEnabled(0);
ui->labelEleEyeTriggerPrintDelay->setText(tr("触发延时(毫米)"));
ui->labelEleEyeTriggerIntervalMs->setText(tr("重复间隔(毫米)"));
ui->labelOutputPulseDelayMs->setText("延时(毫米):");
if(ui->checkBoxpausePrintSyncInv->isChecked())
{
ui->checkBoxpausePrintSyncInv->setChecked(false);
}
}
else
{
ui->radioButtonSynTrigger->setChecked(triggerMode == PRINT_TRIGGER_SYNCHRONIZER);
ui->spinBoxSynTriggerPrintLen->setEnabled(triggerMode == PRINT_TRIGGER_SYNCHRONIZER);
ui->labelSynTriggerPrintLen->setEnabled(triggerMode == PRINT_TRIGGER_SYNCHRONIZER);
ui->lineEditTriggerPulsePerMm->setEnabled(triggerMode == PRINT_TRIGGER_SYNCHRONIZER);
ui->labelTriggerPulsePerMm->setEnabled(triggerMode == PRINT_TRIGGER_SYNCHRONIZER);
ui->spinBoxSynTriggerPrintLenRatio->setEnabled(triggerMode == PRINT_TRIGGER_SYNCHRONIZER);
ui->labelSynTriggerPrintLenRatio->setEnabled(triggerMode == PRINT_TRIGGER_SYNCHRONIZER);
ui->checkBoxEleEyeMakeClean->setEnabled(triggerMode == PRINT_TRIGGER_SYNCHRONIZER);
ui->pushButtonApplyPulseFix->setEnabled(triggerMode == PRINT_TRIGGER_SYNCHRONIZER);
ui->comboBoxSynPrintMode->setEnabled(triggerMode == PRINT_TRIGGER_SYNCHRONIZER);
ui->labelSynPrintMode->setEnabled(triggerMode == PRINT_TRIGGER_SYNCHRONIZER);
ui->checkBoxAutoSpeedEN->setEnabled (triggerMode == PRINT_TRIGGER_SYNCHRONIZER);
//ui->spinBoxEleEyeTriggerIntervalMs->setEnabled(triggerMode == PRINT_TRIGGER_SYNCHRONIZER);
ui->spinBoxEleEyeTriggerIntervalMs->setEnabled(1);
ui->labelEleEyeTriggerPrintDelay->setText(tr("触发延时(毫秒)"));
ui->labelEleEyeTriggerIntervalMs->setText(tr("重复间隔(毫秒)"));
ui->labelOutputPulseDelayMs->setText( ui->radioButtonSynTrigger->isChecked()?"延时(毫米):":"延时(毫秒):");
}
// sysPara->para.eleEyeTriggerSynPrintEn=!sysPara->para.eleEyeTriggerSynPrintEn;
}
#endif
}
void TriggerCtrl::on_radioButtonDelayTrigger_pressed()
{
setTriggerUI(PRINT_TRIGGER_TIME);
// emit synDisableFontWidth(false);
}
void TriggerCtrl::on_radioButtonEleEyeEdgetTrigger_pressed()
{
setTriggerUI(PRINT_TRIGGER_ELEC_EYE_EDGE);
// emit synDisableFontWidth(false);
}
void TriggerCtrl::on_radioButtonEleEyeLevelTrigger_pressed()
{
setTriggerUI(PRINT_TRIGGER_ELEC_EYE_VOLTATE_LEVEL);
// emit synDisableFontWidth(false);
}
void TriggerCtrl::on_radioButtonSynTrigger_pressed()
{
//edit@11-19
sysPara->para.printTriggerMode = PRINT_TRIGGER_SYNCHRONIZER;
setTriggerUI(PRINT_TRIGGER_SYNCHRONIZER);
// const unsigned short &FpgaVer=sysPara->status.build_dat.builTime;
// //72版本禁用字符宽度
// if(72 == FpgaVer){
// ui->spinBoxSynTriggerPrintLenRatio->setValue(0);
// ui->spinBoxSynTriggerPrintLenRatio->setEnabled(0);
// }else if (67 == FpgaVer)
// ui->spinBoxSynTriggerPrintLenRatio->setEnabled(1);
// emit synDisableFontWidth(true);
}
void TriggerCtrl::on_pushButtonApplyPulseFix_clicked()
{
pulseNumFix->bindSysPara(sysPara);
pulseNumFix->hide();
pulseNumFix->show();
}
void TriggerCtrl::onPulseNumFixDone(float value){
ui->lineEditTriggerPulsePerMm->setText(QString::number(value));
}
void TriggerCtrl::on_comboBoxSynPrintMode_currentIndexChanged(int index)
{
setSynPrintMode(index);
}
void TriggerCtrl::on_pushButtonApply_pressed()
{
applyUIPara();
if(sysPara)sysPara->saveParaToFile ();
emit autoUpdateFontWidthByTriggerCtrl(sysPara->status.textEditTotalCol);
TriggerCtrlLog();
}
void TriggerCtrl::TriggerCtrlLog(){
qDebug()<<QString("TriggerCtrl 触发模式: %1").arg(sysPara->para.printTriggerMode);
qDebug()<<QString("TriggerCtrl 脉冲数/毫米: %1").arg(ui->lineEditTriggerPulsePerMm->text().toFloat());
qDebug()<<QString("TriggerCtrl 喷印间隔(毫米): %1").arg(ui->spinBoxSynTriggerPrintLen->text().toFloat());
qDebug()<<QString("TriggerCtrl 同步喷印模式: %1").arg(ui->comboBoxSynPrintMode->currentIndex());
qDebug()<<QString("TriggerCtrl 字符宽度: %1").arg(ui->spinBoxSynTriggerPrintLenRatio->value());
qDebug()<<QString("TriggerCtrl 电眼控制: %1").arg(ui->comboBoxEleEyeMakeClean->currentIndex());
qDebug()<<QString("TriggerCtrl 镜象交替类型: %1").arg(ui->comboBoxAltMirrType->currentIndex());
qDebug()<<QString("TriggerCtrl 镜像交替间隔: %1").arg(ui->spinBoxAltMirrorGap->value());
qDebug()<<QString("TriggerCtrl 脉冲信号值: %1").arg(ui->spinBoxpluseSinal->value());
qDebug()<<QString("TriggerCtrl 重复次数: %1").arg(ui->spinBoxEleEyeTriggerRepeatCnt->value());
qDebug()<<QString("TriggerCtrl 重复间隔(毫秒): %1").arg(ui->spinBoxEleEyeTriggerIntervalMs->value());
qDebug()<<QString("TriggerCtrl 同步打印: %1").arg(ui->checkEyeTriggerSynPrintEn->isChecked ());
qDebug()<<QString("TriggerCtrl 触发延时(毫秒): %1").arg(ui->spinBoxEleEyeTriggerPrintDelay->value());
qDebug()<<QString("TriggerCtrl 封锁时间(毫秒): %1").arg(ui->spinBoxEleMaskTime->value());
qDebug()<<QString("TriggerCtrl 同步器清零: %1").arg(ui->checkBoxSynMakeClean->isChecked());
qDebug()<<QString("TriggerCtrl 重复间隔(毫秒): %1").arg(ui->spinBoxDelayTriggerValue->value());
qDebug()<<QString("TriggerCtrl 间隔模式: %1").arg(ui->comboBoxTimeTriggerMode->currentIndex());
qDebug()<<QString("TriggerCtrl 同步器正反转打印: %1").arg(ui->comboBoxSyncActType->currentIndex());
qDebug()<<QString("TriggerCtrl 产生脉冲所需计数: %1").arg(ui->spinBoxProductCntPerOutputPulse->value());
qDebug()<<QString("TriggerCtrl 延时(毫秒): %1").arg(ui->spinBoxOutputPulseDelayMs->value());
qDebug()<<QString("TriggerCtrl 脉冲输出使能: %1").arg(ui->checkBoxPulseOutputEnable->isChecked());
}
void TriggerCtrl::on_checkBoxPulseOutputEnable_clicked()
{
bool checked = ui->checkBoxPulseOutputEnable->isChecked();
ui->labelProductCntPerOutputPulse->setEnabled(checked);
ui->spinBoxProductCntPerOutputPulse->setEnabled(checked);
//ui->labelOutputPulseDelayMs->setEnabled(checked);
//ui->spinBoxOutputPulseDelayMs->setEnabled(checked);
}
void TriggerCtrl::setBuildTime(QString s1)
{
QString s;
#if 0 /* roger use new Version manage,so delete it */
s.sprintf(" %s ",__TIME__);
s = (QString) Public::DateToString(__DATE__)+s + BVER;
#else
s.sprintf("%d.%d.%02d_GuiL_V2_", UP_PRINTER_MAJOR_VER, UP_PRINTER_MINOR_VER,UP_PRINTER_RIVISION_VER);
s = s + (QString) Public::DateToString(__DATE__)+ "_"+ QString(__TIME__)+"_"+UP_PRINTER_STAGE_VER;
// s = s + BVER;
#endif
ui->test_version->setText(s+s1);
//ui->test_version->setText (BUILD_DATE+s);
}
void TriggerCtrl::on_checkEyeTriggerSynPrintEn_clicked(bool checked)
{
int triggerMode = sysPara->para.printTriggerMode;
if(sysPara)
{
//if( !sysPara->para.eleEyeTriggerSynPrintEn )
if( checked)
{
//ui->radioButtonSynTrigger->setChecked(1);
#ifndef NON_CABLE
ui->spinBoxSynTriggerPrintLen->setEnabled(1);
#endif
ui->labelSynTriggerPrintLen->setEnabled(1);
ui->lineEditTriggerPulsePerMm->setEnabled(1);
ui->labelTriggerPulsePerMm->setEnabled(1);
ui->spinBoxSynTriggerPrintLenRatio->setEnabled(1);
ui->labelSynTriggerPrintLenRatio->setEnabled(1);
ui->checkBoxEleEyeMakeClean->setEnabled(1);
ui->pushButtonApplyPulseFix->setEnabled(1);
ui->comboBoxSynPrintMode->setEnabled(1);
ui->labelSynPrintMode->setEnabled(1);
//ui->checkBoxAutoSpeedEN->setEnabled (1);
ui->spinBoxEleEyeTriggerIntervalMs->setEnabled(0);
ui->labelEleEyeTriggerPrintDelay->setText(tr("触发延时(毫米)"));
ui->labelEleEyeTriggerIntervalMs->setText(tr("重复间隔(毫米)"));
ui->labelEleMaskTime->setText(tr("封锁间隔(毫米)"));
ui->labelOutputPulseDelayMs->setText(tr("延时(毫米):"));
if(ui->comboBoxSyncActType->currentIndex() || 0b11) //如果不是在正反转打印的模式下,就切换到正反转模式
{
ui->comboBoxSyncActType->setCurrentIndex(0);
}
}
else
{
ui->radioButtonSynTrigger->setChecked(triggerMode == PRINT_TRIGGER_SYNCHRONIZER);
#ifndef NON_CABLE
ui->spinBoxSynTriggerPrintLen->setEnabled(triggerMode == PRINT_TRIGGER_SYNCHRONIZER);
#endif
ui->labelSynTriggerPrintLen->setEnabled(triggerMode == PRINT_TRIGGER_SYNCHRONIZER);
ui->lineEditTriggerPulsePerMm->setEnabled(triggerMode == PRINT_TRIGGER_SYNCHRONIZER);
ui->labelTriggerPulsePerMm->setEnabled(triggerMode == PRINT_TRIGGER_SYNCHRONIZER);
ui->spinBoxSynTriggerPrintLenRatio->setEnabled(triggerMode == PRINT_TRIGGER_SYNCHRONIZER);
ui->labelSynTriggerPrintLenRatio->setEnabled(triggerMode == PRINT_TRIGGER_SYNCHRONIZER);
ui->checkBoxEleEyeMakeClean->setEnabled(triggerMode == PRINT_TRIGGER_SYNCHRONIZER);
ui->pushButtonApplyPulseFix->setEnabled(triggerMode == PRINT_TRIGGER_SYNCHRONIZER);
ui->comboBoxSynPrintMode->setEnabled(triggerMode == PRINT_TRIGGER_SYNCHRONIZER);
ui->labelSynPrintMode->setEnabled(triggerMode == PRINT_TRIGGER_SYNCHRONIZER);
//ui->checkBoxAutoSpeedEN->setEnabled (triggerMode == PRINT_TRIGGER_SYNCHRONIZER);
//ui->spinBoxEleEyeTriggerIntervalMs->setEnabled(triggerMode == PRINT_TRIGGER_SYNCHRONIZER);
ui->spinBoxEleEyeTriggerIntervalMs->setEnabled(1);
ui->labelEleEyeTriggerPrintDelay->setText(tr("触发延时(毫秒)"));
ui->labelEleEyeTriggerIntervalMs->setText(tr("重复间隔(毫秒)"));
ui->labelEleMaskTime->setText(tr("封锁间隔(毫秒)"));
ui->labelOutputPulseDelayMs->setText( ui->radioButtonSynTrigger->isChecked()?tr("延时(毫米):"):tr("延时(毫秒):"));
}
}
}
void TriggerCtrl::on_comboBoxSyncActType_activated(int index)
{
if(index>0)
{
on_checkEyeTriggerSynPrintEn_clicked(false);
}
}
void TriggerCtrl::on_lineEditTriggerPulsePerMm_textChanged(const QString &arg1)
{
Q_UNUSED(arg1);
sysPara->para.synPulseNumPerMm = ui->lineEditTriggerPulsePerMm->text().toFloat();
}
void TriggerCtrl::on_spinBoxSynTriggerPrintLen_textChanged(const QString &arg1)
{
Q_UNUSED(arg1);
//sysPara->para.synTriggerPrintLenMm = ui->spinBoxSynTriggerPrintLen->text().toFloat();
}
//void TriggerCtrl::on_spinBoxEleEyeTriggerIntervalMs_valueChanged(int arg1)
//{
// sysPara->para.elecEyeTriggerInterval = arg1;
//}
// //2020/3/2
// void TriggerCtrl::on_radioButtonSynTrigger_clicked()
// {
// sysPara->para.printTriggerMode = PRINT_TRIGGER_SYNCHRONIZER;
// sysPara->para.printColDelay = 0;
// }
void TriggerCtrl::on_radioButtonEleEyeLevelTrigger_clicked()
{
sysPara->para.printTriggerMode = PRINT_TRIGGER_ELEC_EYE_VOLTATE_LEVEL;
}
void TriggerCtrl::on_radioButtonEleEyeEdgetTrigger_clicked()
{
sysPara->para.printTriggerMode = PRINT_TRIGGER_ELEC_EYE_EDGE;
}
void TriggerCtrl::on_radioButtonDelayTrigger_clicked()
{
sysPara->para.printTriggerMode = PRINT_TRIGGER_TIME;
}
#define PRINT_CTRL_ADDR_BASE 0xa400
typedef struct pulse_struct {
unsigned int pulse_value:16;
}Pulse_struct;
void TriggerCtrl::on_spinBoxpluseSinal_valueChanged(int arg1)
{
Pulse_struct t_pulse_struct;
sysPara->para.pulse_sinal_value = arg1;
t_pulse_struct.pulse_value = arg1*10*ui->lineEditTriggerPulsePerMm->text().toFloat();
sysPara->devOp->fpgaWr(PRINT_CTRL_ADDR_BASE + 0x88, (unsigned char *)&t_pulse_struct, 2);
}
void TriggerCtrl::OutputPulse()
{
ui->checkBoxPulseOutputEnable->setChecked(true);
ui->spinBoxProductCntPerOutputPulse->setEnabled(true);
ui->spinBoxProductCntPerOutputPulse->setValue(sysPara->para.productCntPerOutputPulse);
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,91 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Dialoginputpasswd</class>
<widget class="QDialog" name="Dialoginputpasswd">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>384</width>
<height>112</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="geometry">
<rect>
<x>30</x>
<y>70</y>
<width>341</width>
<height>32</height>
</rect>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>20</x>
<y>20</y>
<width>62</width>
<height>49</height>
</rect>
</property>
<property name="text">
<string>修改密码:</string>
</property>
</widget>
<widget class="QLineEdit" name="t_lineEdit">
<property name="geometry">
<rect>
<x>90</x>
<y>30</y>
<width>241</width>
<height>27</height>
</rect>
</property>
</widget>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>Dialoginputpasswd</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>Dialoginputpasswd</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>
@@ -0,0 +1,858 @@
/*
* wpa_gui - NetworkConfig class
* Copyright (c) 2005-2006, Jouni Malinen <j@w1.fi>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* Alternatively, this software may be distributed under the terms of BSD
* license.
*
* See README and COPYING for more details.
*/
#include <cstdio>
#include <QMessageBox>
#include "networkconfig.h"
#include "wpagui.h"
enum {
AUTH_NONE_OPEN,
AUTH_NONE_WEP,
AUTH_NONE_WEP_SHARED,
AUTH_IEEE8021X,
AUTH_WPA_PSK,
AUTH_WPA_EAP,
AUTH_WPA2_PSK,
AUTH_WPA2_EAP
};
#define WPA_GUI_KEY_DATA "[key is configured]"
NetworkConfig::NetworkConfig(QWidget *parent, const char *, bool, Qt::WFlags)
: QDialog(parent)
{
setupUi(this);
encrSelect->setEnabled(false);
connect(authSelect, SIGNAL(activated(int)), this,
SLOT(authChanged(int)));
connect(cancelButton, SIGNAL(clicked()), this, SLOT(close()));
connect(addButton, SIGNAL(clicked()), this, SLOT(addNetwork()));
connect(encrSelect, SIGNAL(activated(const QString &)), this,
SLOT(encrChanged(const QString &)));
connect(removeButton, SIGNAL(clicked()), this, SLOT(removeNetwork()));
connect(eapSelect, SIGNAL(activated(int)), this,
SLOT(eapChanged(int)));
connect(useWpsButton, SIGNAL(clicked()), this, SLOT(useWps()));
wpagui = NULL;
new_network = false;
}
NetworkConfig::~NetworkConfig()
{
}
void NetworkConfig::languageChange()
{
retranslateUi(this);
}
void NetworkConfig::paramsFromScanResults(QTreeWidgetItem *sel)
{
new_network = true;
/* SSID BSSID frequency signal flags */
setWindowTitle(sel->text(0));
ssidEdit->setText(sel->text(0));
QString flags = sel->text(4);
int auth, encr = 0;
if (flags.indexOf("[WPA2-EAP") >= 0)
auth = AUTH_WPA2_EAP;
else if (flags.indexOf("[WPA-EAP") >= 0)
auth = AUTH_WPA_EAP;
else if (flags.indexOf("[WPA2-PSK") >= 0)
auth = AUTH_WPA2_PSK;
else if (flags.indexOf("[WPA-PSK") >= 0)
auth = AUTH_WPA_PSK;
else
auth = AUTH_NONE_OPEN;
if (flags.indexOf("-CCMP") >= 0)
encr = 1;
else if (flags.indexOf("-TKIP") >= 0)
encr = 0;
else if (flags.indexOf("WEP") >= 0) {
encr = 1;
if (auth == AUTH_NONE_OPEN)
auth = AUTH_NONE_WEP;
} else
encr = 0;
authSelect->setCurrentIndex(auth);
authChanged(auth);
encrSelect->setCurrentIndex(encr);
wepEnabled(auth == AUTH_NONE_WEP);
getEapCapa();
if (flags.indexOf("[WPS") >= 0)
useWpsButton->setEnabled(true);
bssid = sel->text(1);
}
void NetworkConfig::authChanged(int sel)
{
encrSelect->setEnabled(sel != AUTH_NONE_OPEN && sel != AUTH_NONE_WEP &&
sel != AUTH_NONE_WEP_SHARED);
pskEdit->setEnabled(sel == AUTH_WPA_PSK || sel == AUTH_WPA2_PSK);
bool eap = sel == AUTH_IEEE8021X || sel == AUTH_WPA_EAP ||
sel == AUTH_WPA2_EAP;
eapSelect->setEnabled(eap);
identityEdit->setEnabled(eap);
passwordEdit->setEnabled(eap);
cacertEdit->setEnabled(eap);
phase2Select->setEnabled(eap);
if (eap)
eapChanged(eapSelect->currentIndex());
while (encrSelect->count())
encrSelect->removeItem(0);
if (sel == AUTH_NONE_OPEN || sel == AUTH_NONE_WEP ||
sel == AUTH_NONE_WEP_SHARED || sel == AUTH_IEEE8021X) {
encrSelect->addItem("None");
encrSelect->addItem("WEP");
encrSelect->setCurrentIndex(sel == AUTH_NONE_OPEN ? 0 : 1);
} else {
encrSelect->addItem("TKIP");
encrSelect->addItem("CCMP");
encrSelect->setCurrentIndex((sel == AUTH_WPA2_PSK ||
sel == AUTH_WPA2_EAP) ? 1 : 0);
}
wepEnabled(sel == AUTH_NONE_WEP || sel == AUTH_NONE_WEP_SHARED);
}
void NetworkConfig::eapChanged(int sel)
{
QString prev_val = phase2Select->currentText();
while (phase2Select->count())
phase2Select->removeItem(0);
QStringList inner;
inner << "PEAP" << "TTLS" << "FAST";
if (!inner.contains(eapSelect->itemText(sel)))
return;
phase2Select->addItem("[ any ]");
/* Add special cases based on outer method */
if (eapSelect->currentText().compare("TTLS") == 0) {
phase2Select->addItem("PAP");
phase2Select->addItem("CHAP");
phase2Select->addItem("MSCHAP");
phase2Select->addItem("MSCHAPv2");
} else if (eapSelect->currentText().compare("FAST") == 0)
phase2Select->addItem("GTC(auth) + MSCHAPv2(prov)");
/* Add all enabled EAP methods that can be used in the tunnel */
int i;
QStringList allowed;
allowed << "MSCHAPV2" << "MD5" << "GTC" << "TLS" << "OTP" << "SIM"
<< "AKA";
for (i = 0; i < eapSelect->count(); i++) {
if (allowed.contains(eapSelect->itemText(i))) {
phase2Select->addItem("EAP-" + eapSelect->itemText(i));
}
}
for (i = 0; i < phase2Select->count(); i++) {
if (phase2Select->itemText(i).compare(prev_val) == 0) {
phase2Select->setCurrentIndex(i);
break;
}
}
}
void NetworkConfig::addNetwork()
{
char reply[10], cmd[256];
size_t reply_len;
int id;
int psklen = pskEdit->text().length();
int auth = authSelect->currentIndex();
if (auth == AUTH_WPA_PSK || auth == AUTH_WPA2_PSK) {
if (psklen < 8 || psklen > 64) {
QMessageBox::warning(
this,
tr("WPA Pre-Shared Key Error"),
tr("WPA-PSK requires a passphrase of 8 to 63 "
"characters\n"
"or 64 hex digit PSK"));
pskEdit->setFocus();
return;
}
}
if (idstrEdit->isEnabled() && !idstrEdit->text().isEmpty()) {
QRegExp rx("^(\\w|-)+$");
if (rx.indexIn(idstrEdit->text()) < 0) {
QMessageBox::warning(
this, tr("Network ID Error"),
tr("Network ID String contains non-word "
"characters.\n"
"It must be a simple string, "
"without spaces, containing\n"
"only characters in this range: "
"[A-Za-z0-9_-]\n"));
idstrEdit->setFocus();
return;
}
}
if (wpagui == NULL)
return;
memset(reply, 0, sizeof(reply));
reply_len = sizeof(reply) - 1;
if (new_network) {
wpagui->ctrlRequest("ADD_NETWORK", reply, &reply_len);
if (reply[0] == 'F') {
QMessageBox::warning(this, "wpa_gui",
tr("Failed to add "
"network to wpa_supplicant\n"
"configuration."));
return;
}
id = atoi(reply);
} else
id = edit_network_id;
setNetworkParam(id, "ssid", ssidEdit->text().toAscii().constData(),
true);
const char *key_mgmt = NULL, *proto = NULL, *pairwise = NULL;
switch (auth) {
case AUTH_NONE_OPEN:
case AUTH_NONE_WEP:
case AUTH_NONE_WEP_SHARED:
key_mgmt = "NONE";
break;
case AUTH_IEEE8021X:
key_mgmt = "IEEE8021X";
break;
case AUTH_WPA_PSK:
key_mgmt = "WPA-PSK";
proto = "WPA";
break;
case AUTH_WPA_EAP:
key_mgmt = "WPA-EAP";
proto = "WPA";
break;
case AUTH_WPA2_PSK:
key_mgmt = "WPA-PSK";
proto = "WPA2";
break;
case AUTH_WPA2_EAP:
key_mgmt = "WPA-EAP";
proto = "WPA2";
break;
}
if (auth == AUTH_NONE_WEP_SHARED)
setNetworkParam(id, "auth_alg", "SHARED", false);
else
setNetworkParam(id, "auth_alg", "OPEN", false);
if (auth == AUTH_WPA_PSK || auth == AUTH_WPA_EAP ||
auth == AUTH_WPA2_PSK || auth == AUTH_WPA2_EAP) {
int encr = encrSelect->currentIndex();
if (encr == 0)
pairwise = "TKIP";
else
pairwise = "CCMP";
}
if (proto)
setNetworkParam(id, "proto", proto, false);
if (key_mgmt)
setNetworkParam(id, "key_mgmt", key_mgmt, false);
if (pairwise) {
setNetworkParam(id, "pairwise", pairwise, false);
setNetworkParam(id, "group", "TKIP CCMP WEP104 WEP40", false);
}
if (pskEdit->isEnabled() &&
strcmp(pskEdit->text().toAscii().constData(),
WPA_GUI_KEY_DATA) != 0)
setNetworkParam(id, "psk",
pskEdit->text().toAscii().constData(),
psklen != 64);
if (eapSelect->isEnabled()) {
const char *eap =
eapSelect->currentText().toAscii().constData();
setNetworkParam(id, "eap", eap, false);
if (strcmp(eap, "SIM") == 0 || strcmp(eap, "AKA") == 0)
setNetworkParam(id, "pcsc", "", true);
else
setNetworkParam(id, "pcsc", "NULL", false);
}
if (phase2Select->isEnabled()) {
QString eap = eapSelect->currentText();
QString inner = phase2Select->currentText();
char phase2[32];
phase2[0] = '\0';
if (eap.compare("PEAP") == 0) {
if (inner.startsWith("EAP-"))
snprintf(phase2, sizeof(phase2), "auth=%s",
inner.right(inner.size() - 4).
toAscii().constData());
} else if (eap.compare("TTLS") == 0) {
if (inner.startsWith("EAP-"))
snprintf(phase2, sizeof(phase2), "autheap=%s",
inner.right(inner.size() - 4).
toAscii().constData());
else
snprintf(phase2, sizeof(phase2), "auth=%s",
inner.toAscii().constData());
} else if (eap.compare("FAST") == 0) {
const char *provisioning = NULL;
if (inner.startsWith("EAP-")) {
snprintf(phase2, sizeof(phase2), "auth=%s",
inner.right(inner.size() - 4).
toAscii().constData());
provisioning = "fast_provisioning=2";
} else if (inner.compare("GTC(auth) + MSCHAPv2(prov)")
== 0) {
snprintf(phase2, sizeof(phase2),
"auth=GTC auth=MSCHAPV2");
provisioning = "fast_provisioning=1";
} else
provisioning = "fast_provisioning=3";
if (provisioning) {
char blob[32];
setNetworkParam(id, "phase1", provisioning,
true);
snprintf(blob, sizeof(blob),
"blob://fast-pac-%d", id);
setNetworkParam(id, "pac_file", blob, true);
}
}
if (phase2[0])
setNetworkParam(id, "phase2", phase2, true);
else
setNetworkParam(id, "phase2", "NULL", false);
} else
setNetworkParam(id, "phase2", "NULL", false);
if (identityEdit->isEnabled() && identityEdit->text().length() > 0)
setNetworkParam(id, "identity",
identityEdit->text().toAscii().constData(),
true);
else
setNetworkParam(id, "identity", "NULL", false);
if (passwordEdit->isEnabled() && passwordEdit->text().length() > 0 &&
strcmp(passwordEdit->text().toAscii().constData(),
WPA_GUI_KEY_DATA) != 0)
setNetworkParam(id, "password",
passwordEdit->text().toAscii().constData(),
true);
else if (passwordEdit->text().length() == 0)
setNetworkParam(id, "password", "NULL", false);
if (cacertEdit->isEnabled() && cacertEdit->text().length() > 0)
setNetworkParam(id, "ca_cert",
cacertEdit->text().toAscii().constData(),
true);
else
setNetworkParam(id, "ca_cert", "NULL", false);
writeWepKey(id, wep0Edit, 0);
writeWepKey(id, wep1Edit, 1);
writeWepKey(id, wep2Edit, 2);
writeWepKey(id, wep3Edit, 3);
if (wep0Radio->isEnabled() && wep0Radio->isChecked())
setNetworkParam(id, "wep_tx_keyidx", "0", false);
else if (wep1Radio->isEnabled() && wep1Radio->isChecked())
setNetworkParam(id, "wep_tx_keyidx", "1", false);
else if (wep2Radio->isEnabled() && wep2Radio->isChecked())
setNetworkParam(id, "wep_tx_keyidx", "2", false);
else if (wep3Radio->isEnabled() && wep3Radio->isChecked())
setNetworkParam(id, "wep_tx_keyidx", "3", false);
if (idstrEdit->isEnabled() && idstrEdit->text().length() > 0)
setNetworkParam(id, "id_str",
idstrEdit->text().toAscii().constData(),
true);
else
setNetworkParam(id, "id_str", "NULL", false);
if (prioritySpinBox->isEnabled()) {
QString prio;
prio = prio.setNum(prioritySpinBox->value());
setNetworkParam(id, "priority", prio.toAscii().constData(),
false);
}
snprintf(cmd, sizeof(cmd), "ENABLE_NETWORK %d", id);
reply_len = sizeof(reply);
wpagui->ctrlRequest(cmd, reply, &reply_len);
if (strncmp(reply, "OK", 2) != 0) {
QMessageBox::warning(this, "wpa_gui",
tr("Failed to enable "
"network in wpa_supplicant\n"
"configuration."));
/* Network was added, so continue anyway */
}
wpagui->triggerUpdate();
wpagui->ctrlRequest("SAVE_CONFIG", reply, &reply_len);
close();
}
void NetworkConfig::setWpaGui(WpaGui *_wpagui)
{
wpagui = _wpagui;
}
int NetworkConfig::setNetworkParam(int id, const char *field,
const char *value, bool quote)
{
char reply[10], cmd[256];
size_t reply_len;
snprintf(cmd, sizeof(cmd), "SET_NETWORK %d %s %s%s%s",
id, field, quote ? "\"" : "", value, quote ? "\"" : "");
reply_len = sizeof(reply);
wpagui->ctrlRequest(cmd, reply, &reply_len);
return strncmp(reply, "OK", 2) == 0 ? 0 : -1;
}
void NetworkConfig::encrChanged(const QString &)
{
}
void NetworkConfig::wepEnabled(bool enabled)
{
wep0Edit->setEnabled(enabled);
wep1Edit->setEnabled(enabled);
wep2Edit->setEnabled(enabled);
wep3Edit->setEnabled(enabled);
wep0Radio->setEnabled(enabled);
wep1Radio->setEnabled(enabled);
wep2Radio->setEnabled(enabled);
wep3Radio->setEnabled(enabled);
}
void NetworkConfig::writeWepKey(int network_id, QLineEdit *edit, int id)
{
char buf[10];
bool hex;
const char *txt, *pos;
size_t len;
if (!edit->isEnabled() || edit->text().isEmpty())
return;
/*
* Assume hex key if only hex characters are present and length matches
* with 40, 104, or 128-bit key
*/
txt = edit->text().toAscii().constData();
if (strcmp(txt, WPA_GUI_KEY_DATA) == 0)
return;
len = strlen(txt);
if (len == 0)
return;
pos = txt;
hex = true;
while (*pos) {
if (!((*pos >= '0' && *pos <= '9') ||
(*pos >= 'a' && *pos <= 'f') ||
(*pos >= 'A' && *pos <= 'F'))) {
hex = false;
break;
}
pos++;
}
if (hex && len != 10 && len != 26 && len != 32)
hex = false;
snprintf(buf, sizeof(buf), "wep_key%d", id);
setNetworkParam(network_id, buf, txt, !hex);
}
static int key_value_isset(const char *reply, size_t reply_len)
{
return reply_len > 0 && (reply_len < 4 || memcmp(reply, "FAIL", 4) != 0);
}
void NetworkConfig::paramsFromConfig(int network_id)
{
int i, res;
edit_network_id = network_id;
getEapCapa();
char reply[1024], cmd[256], *pos;
size_t reply_len;
snprintf(cmd, sizeof(cmd), "GET_NETWORK %d ssid", network_id);
reply_len = sizeof(reply) - 1;
if (wpagui->ctrlRequest(cmd, reply, &reply_len) >= 0 &&
reply_len >= 2 && reply[0] == '"') {
reply[reply_len] = '\0';
pos = strchr(reply + 1, '"');
if (pos)
*pos = '\0';
ssidEdit->setText(reply + 1);
}
snprintf(cmd, sizeof(cmd), "GET_NETWORK %d proto", network_id);
reply_len = sizeof(reply) - 1;
int wpa = 0;
if (wpagui->ctrlRequest(cmd, reply, &reply_len) >= 0) {
reply[reply_len] = '\0';
if (strstr(reply, "RSN") || strstr(reply, "WPA2"))
wpa = 2;
else if (strstr(reply, "WPA"))
wpa = 1;
}
int auth = AUTH_NONE_OPEN, encr = 0;
snprintf(cmd, sizeof(cmd), "GET_NETWORK %d key_mgmt", network_id);
reply_len = sizeof(reply) - 1;
if (wpagui->ctrlRequest(cmd, reply, &reply_len) >= 0) {
reply[reply_len] = '\0';
if (strstr(reply, "WPA-EAP"))
auth = wpa & 2 ? AUTH_WPA2_EAP : AUTH_WPA_EAP;
else if (strstr(reply, "WPA-PSK"))
auth = wpa & 2 ? AUTH_WPA2_PSK : AUTH_WPA_PSK;
else if (strstr(reply, "IEEE8021X")) {
auth = AUTH_IEEE8021X;
encr = 1;
}
}
snprintf(cmd, sizeof(cmd), "GET_NETWORK %d pairwise", network_id);
reply_len = sizeof(reply) - 1;
if (wpagui->ctrlRequest(cmd, reply, &reply_len) >= 0) {
reply[reply_len] = '\0';
if (strstr(reply, "CCMP") && auth != AUTH_NONE_OPEN &&
auth != AUTH_NONE_WEP && auth != AUTH_NONE_WEP_SHARED)
encr = 1;
else if (strstr(reply, "TKIP"))
encr = 0;
else if (strstr(reply, "WEP"))
encr = 1;
else
encr = 0;
}
snprintf(cmd, sizeof(cmd), "GET_NETWORK %d psk", network_id);
reply_len = sizeof(reply) - 1;
res = wpagui->ctrlRequest(cmd, reply, &reply_len);
if (res >= 0 && reply_len >= 2 && reply[0] == '"') {
reply[reply_len] = '\0';
pos = strchr(reply + 1, '"');
if (pos)
*pos = '\0';
pskEdit->setText(reply + 1);
} else if (res >= 0 && key_value_isset(reply, reply_len)) {
pskEdit->setText(WPA_GUI_KEY_DATA);
}
snprintf(cmd, sizeof(cmd), "GET_NETWORK %d identity", network_id);
reply_len = sizeof(reply) - 1;
if (wpagui->ctrlRequest(cmd, reply, &reply_len) >= 0 &&
reply_len >= 2 && reply[0] == '"') {
reply[reply_len] = '\0';
pos = strchr(reply + 1, '"');
if (pos)
*pos = '\0';
identityEdit->setText(reply + 1);
}
snprintf(cmd, sizeof(cmd), "GET_NETWORK %d password", network_id);
reply_len = sizeof(reply) - 1;
res = wpagui->ctrlRequest(cmd, reply, &reply_len);
if (res >= 0 && reply_len >= 2 && reply[0] == '"') {
reply[reply_len] = '\0';
pos = strchr(reply + 1, '"');
if (pos)
*pos = '\0';
passwordEdit->setText(reply + 1);
} else if (res >= 0 && key_value_isset(reply, reply_len)) {
passwordEdit->setText(WPA_GUI_KEY_DATA);
}
snprintf(cmd, sizeof(cmd), "GET_NETWORK %d ca_cert", network_id);
reply_len = sizeof(reply) - 1;
if (wpagui->ctrlRequest(cmd, reply, &reply_len) >= 0 &&
reply_len >= 2 && reply[0] == '"') {
reply[reply_len] = '\0';
pos = strchr(reply + 1, '"');
if (pos)
*pos = '\0';
cacertEdit->setText(reply + 1);
}
enum { NO_INNER, PEAP_INNER, TTLS_INNER, FAST_INNER } eap = NO_INNER;
snprintf(cmd, sizeof(cmd), "GET_NETWORK %d eap", network_id);
reply_len = sizeof(reply) - 1;
if (wpagui->ctrlRequest(cmd, reply, &reply_len) >= 0 &&
reply_len >= 1) {
reply[reply_len] = '\0';
for (i = 0; i < eapSelect->count(); i++) {
if (eapSelect->itemText(i).compare(reply) == 0) {
eapSelect->setCurrentIndex(i);
if (strcmp(reply, "PEAP") == 0)
eap = PEAP_INNER;
else if (strcmp(reply, "TTLS") == 0)
eap = TTLS_INNER;
else if (strcmp(reply, "FAST") == 0)
eap = FAST_INNER;
break;
}
}
}
if (eap != NO_INNER) {
snprintf(cmd, sizeof(cmd), "GET_NETWORK %d phase2",
network_id);
reply_len = sizeof(reply) - 1;
if (wpagui->ctrlRequest(cmd, reply, &reply_len) >= 0 &&
reply_len >= 1) {
reply[reply_len] = '\0';
eapChanged(eapSelect->currentIndex());
} else
eap = NO_INNER;
}
char *val;
val = reply + 1;
while (*(val + 1))
val++;
if (*val == '"')
*val = '\0';
switch (eap) {
case PEAP_INNER:
if (strncmp(reply, "\"auth=", 6))
break;
val = reply + 2;
memcpy(val, "EAP-", 4);
break;
case TTLS_INNER:
if (strncmp(reply, "\"autheap=", 9) == 0) {
val = reply + 5;
memcpy(val, "EAP-", 4);
} else if (strncmp(reply, "\"auth=", 6) == 0)
val = reply + 6;
break;
case FAST_INNER:
if (strncmp(reply, "\"auth=", 6))
break;
if (strcmp(reply + 6, "GTC auth=MSCHAPV2") == 0) {
val = (char *) "GTC(auth) + MSCHAPv2(prov)";
break;
}
val = reply + 2;
memcpy(val, "EAP-", 4);
break;
case NO_INNER:
break;
}
for (i = 0; i < phase2Select->count(); i++) {
if (phase2Select->itemText(i).compare(val) == 0) {
phase2Select->setCurrentIndex(i);
break;
}
}
for (i = 0; i < 4; i++) {
QLineEdit *wepEdit;
switch (i) {
default:
case 0:
wepEdit = wep0Edit;
break;
case 1:
wepEdit = wep1Edit;
break;
case 2:
wepEdit = wep2Edit;
break;
case 3:
wepEdit = wep3Edit;
break;
}
snprintf(cmd, sizeof(cmd), "GET_NETWORK %d wep_key%d",
network_id, i);
reply_len = sizeof(reply) - 1;
res = wpagui->ctrlRequest(cmd, reply, &reply_len);
if (res >= 0 && reply_len >= 2 && reply[0] == '"') {
reply[reply_len] = '\0';
pos = strchr(reply + 1, '"');
if (pos)
*pos = '\0';
if (auth == AUTH_NONE_OPEN || auth == AUTH_IEEE8021X) {
if (auth == AUTH_NONE_OPEN)
auth = AUTH_NONE_WEP;
encr = 1;
}
wepEdit->setText(reply + 1);
} else if (res >= 0 && key_value_isset(reply, reply_len)) {
if (auth == AUTH_NONE_OPEN || auth == AUTH_IEEE8021X) {
if (auth == AUTH_NONE_OPEN)
auth = AUTH_NONE_WEP;
encr = 1;
}
wepEdit->setText(WPA_GUI_KEY_DATA);
}
}
if (auth == AUTH_NONE_WEP) {
snprintf(cmd, sizeof(cmd), "GET_NETWORK %d auth_alg",
network_id);
reply_len = sizeof(reply) - 1;
if (wpagui->ctrlRequest(cmd, reply, &reply_len) >= 0) {
reply[reply_len] = '\0';
if (strcmp(reply, "SHARED") == 0)
auth = AUTH_NONE_WEP_SHARED;
}
}
snprintf(cmd, sizeof(cmd), "GET_NETWORK %d wep_tx_keyidx", network_id);
reply_len = sizeof(reply) - 1;
if (wpagui->ctrlRequest(cmd, reply, &reply_len) >= 0 && reply_len >= 1)
{
reply[reply_len] = '\0';
switch (atoi(reply)) {
case 0:
wep0Radio->setChecked(true);
break;
case 1:
wep1Radio->setChecked(true);
break;
case 2:
wep2Radio->setChecked(true);
break;
case 3:
wep3Radio->setChecked(true);
break;
}
}
snprintf(cmd, sizeof(cmd), "GET_NETWORK %d id_str", network_id);
reply_len = sizeof(reply) - 1;
if (wpagui->ctrlRequest(cmd, reply, &reply_len) >= 0 &&
reply_len >= 2 && reply[0] == '"') {
reply[reply_len] = '\0';
pos = strchr(reply + 1, '"');
if (pos)
*pos = '\0';
idstrEdit->setText(reply + 1);
}
snprintf(cmd, sizeof(cmd), "GET_NETWORK %d priority", network_id);
reply_len = sizeof(reply) - 1;
if (wpagui->ctrlRequest(cmd, reply, &reply_len) >= 0 && reply_len >= 1)
{
reply[reply_len] = '\0';
prioritySpinBox->setValue(atoi(reply));
}
authSelect->setCurrentIndex(auth);
authChanged(auth);
encrSelect->setCurrentIndex(encr);
wepEnabled(auth == AUTH_NONE_WEP || auth == AUTH_NONE_WEP_SHARED);
removeButton->setEnabled(true);
addButton->setText("Save");
}
void NetworkConfig::removeNetwork()
{
char reply[10], cmd[256];
size_t reply_len;
if (QMessageBox::information(
this, "wpa_gui",
tr("This will permanently remove the network\n"
"from the configuration. Do you really want\n"
"to remove this network?"),
tr("Yes"), tr("No")) != 0)
return;
snprintf(cmd, sizeof(cmd), "REMOVE_NETWORK %d", edit_network_id);
reply_len = sizeof(reply);
wpagui->ctrlRequest(cmd, reply, &reply_len);
if (strncmp(reply, "OK", 2) != 0) {
QMessageBox::warning(this, "wpa_gui",
tr("Failed to remove network from "
"wpa_supplicant\n"
"configuration."));
} else {
wpagui->triggerUpdate();
wpagui->ctrlRequest("SAVE_CONFIG", reply, &reply_len);
}
close();
}
void NetworkConfig::newNetwork()
{
new_network = true;
getEapCapa();
}
void NetworkConfig::getEapCapa()
{
char reply[256];
size_t reply_len;
if (wpagui == NULL)
return;
reply_len = sizeof(reply) - 1;
if (wpagui->ctrlRequest("GET_CAPABILITY eap", reply, &reply_len) < 0)
return;
reply[reply_len] = '\0';
QString res(reply);
QStringList types = res.split(QChar(' '));
eapSelect->insertItems(-1, types);
}
void NetworkConfig::useWps()
{
if (wpagui == NULL)
return;
wpagui->setBssFromScan(bssid);
wpagui->wpsDialog();
close();
}
@@ -0,0 +1,76 @@
#ifndef PICSCENE_H
#define PICSCENE_H
#if 1
#include <QGraphicsScene>
#include "pictextitem.h"
#include <QGraphicsSceneMouseEvent>
QT_BEGIN_NAMESPACE
class QGraphicsSceneMouseEvent;
class QMenu;
class QPointF;
class QGraphicsLineItem;
class QFont;
class QGraphicsTextItem;
class QColor;
QT_END_NAMESPACE
class PicScene : public QGraphicsScene
{
Q_OBJECT
public:
enum Mode { InsertItem, InsertLine, InsertText, InsertPic, MoveItem };
explicit PicScene(QObject *parent = 0);
QFont font() const
{ return myFont; }
QColor textColor() const
{ return myTextColor; }
QColor itemColor() const
{ return myItemColor; }
QColor lineColor() const
{ return myLineColor; }
void setLineColor(const QColor &color);
void setTextColor(const QColor &color);
void setItemColor(const QColor &color);
void setFont(const QFont &font);
void keyPressEvent(QKeyEvent *event);
public slots:
void setMode(Mode mode);
//void setItemType(DiagramItem::DiagramType type);
//void editorLostFocus(DiagramTextItem *item);
void setIsdrawBackground(bool newIsdrawBackground);
signals:
//void itemInserted(DiagramItem *item);
void textInserted(QGraphicsTextItem *item);
void itemSelected(QGraphicsItem *item);
void xmlContentChanged();
//void sceneRectChanged(const QRectF &rect);//edit@12-12
void showTextWidthHeight();
void adjustItemsPos();
protected:
void mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent);
void mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent);
void mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent);
void drawBackground(QPainter *painter, const QRectF &rect);
private:
bool isItemChange(int type);
//DiagramItem::DiagramType myItemType;
QMenu *myItemMenu;
Mode myMode;
bool leftButtonDown;
QPointF startPoint;
QGraphicsLineItem *line;
QFont myFont;
PicTextItem *textItem;
QColor myTextColor;
QColor myItemColor;
QColor myLineColor;
private:
bool IsdrawBackground;
};
#endif
#endif // PICSCENE_H