新二维码/条形码编辑逻辑
This commit is contained in:
+207
-90
@@ -29,6 +29,7 @@
|
||||
#include <string>
|
||||
#include "scene/PicDateItem.h"
|
||||
#include "scene/PicScheduleShiftItem.h"
|
||||
#include "scene/piccodeitem.h"
|
||||
#include <QElapsedTimer>
|
||||
|
||||
extern MyInputMethod *myInputMethod;
|
||||
@@ -40,7 +41,6 @@ MainWidget::MainWidget(QWidget* parent)
|
||||
{
|
||||
// 加载UI文件
|
||||
ui.setupUi(this);
|
||||
initSheet();
|
||||
|
||||
// 关联成员变量到UI控件
|
||||
m_EditBtn = ui.m_EditBtn;
|
||||
@@ -69,10 +69,12 @@ MainWidget::MainWidget(QWidget* parent)
|
||||
// ui.labelRunStatus->setWordWrap(true);
|
||||
|
||||
ui.sub3->installEventFilter(this);
|
||||
ui.fra_state->installEventFilter(this);
|
||||
ui.labelTotalProductCnt->hide();
|
||||
ui.lb_counter->hide();
|
||||
|
||||
enablePrintButton(true);
|
||||
changeHighLight(false);
|
||||
enablePrintButton(false);
|
||||
}
|
||||
|
||||
MainWidget::~MainWidget()
|
||||
@@ -1398,7 +1400,7 @@ bool MainWidget::dateTimeItemsDotUpdate()
|
||||
if(!item)
|
||||
continue;
|
||||
|
||||
if(item->sourceType() != SourceType::DATETIME && item->sourceType() != SourceType::SCHEDULE_SHIFT)
|
||||
if(item->sourceType() != SourceType::DATETIME && item->sourceType() != SourceType::SCHEDULE_SHIFT && item->sourceType() != SourceType::CODE)
|
||||
continue;
|
||||
|
||||
if(item->sourceType() == SourceType::DATETIME) {
|
||||
@@ -1423,6 +1425,18 @@ bool MainWidget::dateTimeItemsDotUpdate()
|
||||
continue;
|
||||
}
|
||||
|
||||
if(item->sourceType() == SourceType::CODE) {
|
||||
auto codeItem = dynamic_cast<PicCodeItem*>(item);
|
||||
if(!codeItem)
|
||||
continue;
|
||||
|
||||
QVector<int> counterValus{sysPara->para.cnt1CurrValue, sysPara->para.cnt2CurrValue};
|
||||
auto b = codeItem->updateVariants(counterValus);
|
||||
isUpdate |= b;
|
||||
if(!b)
|
||||
continue;
|
||||
}
|
||||
|
||||
QImage img = item->preview();
|
||||
if(img.isNull()) {
|
||||
++nbInvaliedDatetimePreview;
|
||||
@@ -1430,9 +1444,9 @@ bool MainWidget::dateTimeItemsDotUpdate()
|
||||
}
|
||||
|
||||
auto sceneRect = pPicScene->sceneRect();
|
||||
QRectF itemRect(item->pos(), img.size());
|
||||
auto boundingRect = pPicScene->itemsBoundingRect();
|
||||
QRectF itemRect(item->pos() - boundingRect.topLeft(), img.size());
|
||||
totalOfDatetimeNumber++;
|
||||
|
||||
|
||||
// 裁剪item位置, 确保item位于场景内
|
||||
// 如果item超出了场景范围,则裁剪img并更新itemRect,只显示场景内的部分
|
||||
@@ -1457,9 +1471,6 @@ bool MainWidget::dateTimeItemsDotUpdate()
|
||||
totalOfProcessedDots += imageToPrintData(img, (int)itemRect.left(), (int)itemRect.top());
|
||||
}
|
||||
|
||||
// if(totalOfProcessedDots)
|
||||
// LogInfo::setRunStatusText(QString("totalOfProcessedDots: %1").arg(totalOfProcessedDots));
|
||||
|
||||
return isUpdate;
|
||||
}
|
||||
|
||||
@@ -1636,26 +1647,13 @@ void MainWidget::on_m_StartBtn_clicked()
|
||||
}
|
||||
sysPara->status.isPrinting=false;
|
||||
|
||||
// setRunStatus(tr("开始打印1")); hlp
|
||||
// qDebug()<<QString("mainwindow 打印内容:%1").arg(ui->textEdit->toPlainText());
|
||||
|
||||
SendPrintDataToFpga(0); // 0--正常打印,1--打印交替部分信息1; 2--打印交替部分信息2,
|
||||
// if(sysPara->para.isCheckInsertTime)
|
||||
// {
|
||||
// if(!startPrintingFlag)
|
||||
// {
|
||||
// LogInfo::setRunStatusText(tr("开始打印"));
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// LogInfo::setRunStatusText(tr("开始打印"));
|
||||
// }
|
||||
|
||||
/*-------------------------------------------------------------------*/
|
||||
// ui->labelSynColDelay->setText("");
|
||||
sysPara->status.lastSynColDelay = -1; //目的是为了清空原来的数据
|
||||
/*--------------------------------暂停按钮------------------------------*/
|
||||
// ui->pushButtonPausePrint->setEnabled(true);
|
||||
// ui->pushButtonPausePrint->setText(tr("暂停打印"));
|
||||
|
||||
/*---------------------------------开关回收槽------------------------------*/
|
||||
enableReclaimCtrlButton(false);
|
||||
// updatePrintDisplayLabel(); hlp
|
||||
@@ -1665,13 +1663,11 @@ void MainWidget::on_m_StartBtn_clicked()
|
||||
sysPara->devOp->printCtrl(PRINT_CTRL_START);
|
||||
printintFlag = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
//如果已经在打印,则不要在发送start命令,只要更新相应的数据即可
|
||||
// if(!printintFlag) //如果在暂停,重复取消暂停
|
||||
// on_pushButtonPausePrint_pressed();
|
||||
}
|
||||
|
||||
startPrintingFlag = true;sysPara->status.isPrinting=true;
|
||||
|
||||
// 高亮切换
|
||||
changeHighLight(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1713,6 +1709,8 @@ void MainWidget::on_m_StopBtn_clicked()
|
||||
|
||||
}
|
||||
}
|
||||
// 高亮切换
|
||||
changeHighLight(false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1887,32 +1885,76 @@ void MainWidget::reclaimTanOpen()
|
||||
void MainWidget::initSheet()
|
||||
{
|
||||
// 仅当前按钮生效
|
||||
ui.m_StartBtn->setStyleSheet(R"(
|
||||
QPushButton {
|
||||
background-color: #27ae60;
|
||||
color: black;
|
||||
border-radius: 5px;
|
||||
}
|
||||
QPushButton:disabled {
|
||||
background-color: #bdc3c7;
|
||||
color: #7f8c8d;
|
||||
}
|
||||
)");
|
||||
ui.m_StartBtn->setStyleSheet(
|
||||
R"(
|
||||
QPushButton {
|
||||
background-color: #1e8449;
|
||||
color: black;
|
||||
border-radius: 5px;
|
||||
}
|
||||
QPushButton:disabled {
|
||||
background-color: #bdc3c7; /* 灰色背景 */
|
||||
color: #7f8c8d; /* 灰色文字 */
|
||||
border: 1px solid #95a5a6; /* 灰色边框 */
|
||||
}
|
||||
)");
|
||||
|
||||
ui.m_StopBtn->setStyleSheet(R"(
|
||||
QPushButton {
|
||||
background-color: #e74c3c;
|
||||
color: black;
|
||||
border-radius: 5px;
|
||||
}
|
||||
ui.m_StopBtn->setStyleSheet(
|
||||
R"(
|
||||
QPushButton {
|
||||
background-color: #e74c3c;
|
||||
color: black;
|
||||
border-radius: 5px;
|
||||
}
|
||||
QPushButton:disabled {
|
||||
background-color: #bdc3c7; /* 灰色背景 */
|
||||
color: #7f8c8d; /* 灰色文字 */
|
||||
border: 1px solid #95a5a6; /* 灰色边框 */
|
||||
}
|
||||
)");
|
||||
|
||||
QPushButton:disabled {
|
||||
background-color: #bdc3c7;
|
||||
color: #7f8c8d;
|
||||
}
|
||||
)");
|
||||
}
|
||||
|
||||
// this->setStyleSheet(styleSheet);
|
||||
void MainWidget::changeHighLight(bool isStart)
|
||||
{
|
||||
initSheet();
|
||||
if (isStart) {
|
||||
QString highlightStyle =
|
||||
R"(
|
||||
QPushButton {
|
||||
background-color: #27ae60;
|
||||
color: black;
|
||||
border-radius: 5px;
|
||||
border: 3px solid #f39c12;
|
||||
box-shadow: 0 0 8px rgba(231, 76, 60, 0.6);
|
||||
}
|
||||
QPushButton:disabled {
|
||||
background-color: #bdc3c7; /* 灰色背景 */
|
||||
color: #7f8c8d; /* 灰色文字 */
|
||||
border: 1px solid #95a5a6; /* 灰色边框 */
|
||||
}
|
||||
)";
|
||||
m_StartBtn->setStyleSheet(highlightStyle);
|
||||
|
||||
|
||||
} else {
|
||||
QString highlightStyle =
|
||||
R"(
|
||||
QPushButton {
|
||||
background-color: #f07167;
|
||||
color: black;
|
||||
border-radius: 5px;
|
||||
border: 3px solid #f39c12;
|
||||
box-shadow: 0 0 8px rgba(231, 76, 60, 0.6);
|
||||
}
|
||||
QPushButton:disabled {
|
||||
background-color: #bdc3c7; /* 灰色背景 */
|
||||
color: #7f8c8d; /* 灰色文字 */
|
||||
border: 1px solid #95a5a6; /* 灰色边框 */
|
||||
}
|
||||
)";
|
||||
m_StopBtn->setStyleSheet(highlightStyle);
|
||||
}
|
||||
}
|
||||
|
||||
void MainWidget::on_m_RightBtn_clicked()
|
||||
@@ -2028,17 +2070,8 @@ static int oldsizeSTM32 = -1;
|
||||
static int reclaimTankDelay = 0;
|
||||
void MainWidget::updateSysStatusToUI(){ //100ms
|
||||
if(sysPara){
|
||||
if(sysPara->para.gearPumpEnable)
|
||||
{
|
||||
// ui->label_11->setText(tr("齿轮泵转速"));
|
||||
}
|
||||
else
|
||||
{
|
||||
// ui->label_11->setText(tr("隔膜位置"));
|
||||
}
|
||||
RefreshStatusLight();
|
||||
if(sysPara->status.lastProductCnt != sysPara->status.productCnt){ //产品计数
|
||||
//ui.labelProductCnt->setText(QString::number(sysPara->status.productCnt));
|
||||
updateTotalCnt(0);
|
||||
}
|
||||
|
||||
@@ -2047,9 +2080,6 @@ void MainWidget::updateSysStatusToUI(){ //100ms
|
||||
sysPara->status.ExpiryDispUpdate--;
|
||||
m_PrintDisplay->update();// 2018.5.25
|
||||
}
|
||||
// if(sysPara->para.alterPrint.enable==1) ui->labelXFileName->setText (tr("交替打印"));
|
||||
// else if(sysPara->para.alterPrint.enable==2) ui->labelXFileName->setText (tr("电眼交替"));
|
||||
// else ui->labelXFileName->setText ("");
|
||||
/*--------------------------------------------------------------------------*/
|
||||
//if(sysPara->para.printTriggerMode == PRINT_TRIGGER_SYNCHRONIZER && printintFlag){ //同步器速度
|
||||
if((
|
||||
@@ -2265,6 +2295,107 @@ void MainWidget::updateSysStatusToUI(){ //100ms
|
||||
|
||||
}
|
||||
|
||||
bool MainWidget::checkRed(AlarmStatus &status)
|
||||
{
|
||||
if (status.highVoltageFault == DEV_STATUS_RED) {
|
||||
m_stateStr = tr("高压故障");
|
||||
return true;
|
||||
}
|
||||
if (status.chargeFault == DEV_STATUS_RED) {
|
||||
m_stateStr = tr("相位故障");
|
||||
return true;
|
||||
}
|
||||
if (status.viscosityWarn == DEV_STATUS_RED) {
|
||||
m_stateStr = tr("粘度故障");
|
||||
return true;
|
||||
}
|
||||
if (status.recycleWarn == DEV_STATUS_RED) {
|
||||
m_stateStr = tr("回收故障");
|
||||
return true;
|
||||
}
|
||||
if (status.solveLevelWarn == DEV_STATUS_RED) {
|
||||
m_stateStr = tr("溶液液位");
|
||||
return true;
|
||||
}
|
||||
if (status.inkWaterLevel == DEV_STATUS_RED) {
|
||||
m_stateStr = tr("墨水液位");
|
||||
return true;
|
||||
}
|
||||
if (status.inkLeak == DEV_STATUS_RED) {
|
||||
m_stateStr = tr("墨水缸满");
|
||||
return true;
|
||||
}
|
||||
if (status.inkSwint == DEV_STATUS_RED) {
|
||||
m_stateStr = tr("墨线开关");
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool MainWidget::checkYellow(AlarmStatus &status)
|
||||
{
|
||||
if (status.highVoltageFault == DEV_STATUS_YELLOW) {
|
||||
m_stateStr = tr("高压故障");
|
||||
return true;
|
||||
}
|
||||
if (status.chargeFault == DEV_STATUS_YELLOW) {
|
||||
m_stateStr = tr("相位故障");
|
||||
return true;
|
||||
}
|
||||
if (status.viscosityWarn == DEV_STATUS_YELLOW) {
|
||||
m_stateStr = tr("粘度故障");
|
||||
return true;
|
||||
}
|
||||
if (status.recycleWarn == DEV_STATUS_YELLOW) {
|
||||
m_stateStr = tr("回收故障");
|
||||
return true;
|
||||
}
|
||||
if (status.solveLevelWarn == DEV_STATUS_YELLOW) {
|
||||
m_stateStr = tr("溶液液位");
|
||||
return true;
|
||||
}
|
||||
if (status.inkWaterLevel == DEV_STATUS_YELLOW) {
|
||||
m_stateStr = tr("墨水液位");
|
||||
return true;
|
||||
}
|
||||
if (status.inkLeak == DEV_STATUS_YELLOW) {
|
||||
m_stateStr = tr("墨水缸满");
|
||||
return true;
|
||||
}
|
||||
if (status.inkSwint == DEV_STATUS_YELLOW) {
|
||||
m_stateStr = tr("墨线开关");
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void MainWidget::updateGeneralState(AlarmStatus status)
|
||||
{
|
||||
// 有红则红,全绿则绿,红>黄>绿
|
||||
// 检查从后往前判断,因为取最后一个状态QString
|
||||
bool isRed = checkRed(status);
|
||||
if (isRed) {
|
||||
m_stateColor = DEV_STATUS_RED;
|
||||
} else {
|
||||
bool isYellow = checkYellow(status);
|
||||
if (isYellow) {
|
||||
m_stateColor = DEV_STATUS_YELLOW;
|
||||
} else {
|
||||
m_stateColor = DEV_STATUS_GREEN;
|
||||
m_stateStr= tr("正常");
|
||||
}
|
||||
}
|
||||
|
||||
if (m_stateColor == DEV_STATUS_GREEN) {
|
||||
ui.fra_state->setStyleSheet("background-color: #ccffcc;");
|
||||
} else if (m_stateColor == DEV_STATUS_RED) {
|
||||
ui.fra_state->setStyleSheet("background-color: #ff6b6b;");
|
||||
} else {
|
||||
ui.fra_state->setStyleSheet("background-color: #ffd93c;");
|
||||
}
|
||||
ui.lb_generalState->setText(m_stateStr);
|
||||
}
|
||||
|
||||
|
||||
int MainWidget::calculateMaxSpeed(int backup)
|
||||
{
|
||||
@@ -3039,18 +3170,9 @@ void MainWidget::handleEmptySize()
|
||||
return;
|
||||
}
|
||||
|
||||
void MainWidget::updatePrintDisplayLabel(){
|
||||
// if(sysPara && !sysPara->status.reclainTankReachEnd){
|
||||
// setRunStatus(tr("回收槽未到底!!!!!!"));
|
||||
// }
|
||||
// else if(startPrintingFlag ){
|
||||
// if(printintFlag)
|
||||
// setRunStatus(tr("正在喷印..............."));
|
||||
// else
|
||||
// setRunStatus(tr("暂停喷印..............."));
|
||||
// }
|
||||
// else
|
||||
// setRunStatus("");
|
||||
void MainWidget::updatePrintDisplayLabel()
|
||||
{
|
||||
m_PrintDisplay->update();
|
||||
}
|
||||
|
||||
void MainWidget::RefreshStatusLight(){//100ms
|
||||
@@ -3344,18 +3466,6 @@ bool MainWidget::updatePhaseIndicatorLight(){
|
||||
return sysPara->status.lastPhaseFault;
|
||||
}
|
||||
|
||||
void MainWidget::updateGeneralState(DevStatusLightType type, QString stateStr)
|
||||
{
|
||||
if (type == DEV_STATUS_GREEN) {
|
||||
ui.frame->setStyleSheet("background-color: #ccffcc;");
|
||||
} else if (type == DEV_STATUS_RED) {
|
||||
ui.frame->setStyleSheet("background-color: #ff6b6b;");
|
||||
} else {
|
||||
ui.frame->setStyleSheet("background-color: #ffd93c;");
|
||||
}
|
||||
ui.lb_generalState->setText(stateStr);
|
||||
}
|
||||
|
||||
bool MainWidget::eventFilter(QObject *watched, QEvent *event)
|
||||
{
|
||||
if (event->type() == QEvent::MouseButtonDblClick) {
|
||||
@@ -3363,9 +3473,16 @@ bool MainWidget::eventFilter(QObject *watched, QEvent *event)
|
||||
if (watched == ui.sub3 || watched == ui.labelProductCnt) {
|
||||
if (m_setNumDlg) {
|
||||
m_setNumDlg->show();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
if (event->type() == QEvent::MouseButtonDblClick) {
|
||||
if (watched == ui.fra_state || ui.lb_generalState) {
|
||||
LogInfoCtrl::instance()->emitSigShow();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user