新二维码/条形码编辑逻辑

This commit is contained in:
2026-05-06 10:34:48 +08:00
parent a06c926162
commit a9e99f4425
76 changed files with 12679 additions and 12744 deletions
+5
View File
@@ -65,3 +65,8 @@ K(bypm0718wx)
QtUI.r666
qt4
QtUI.r668
2varRam.png
3varRam.png
800X600_New_SystemProject-_NewInterface.zip
bnsTest.png
printSceneView.png
Binary file not shown.
+36 -2
View File
@@ -236,7 +236,8 @@ QString CounterVarSet::getFamilyName(int fontsize){
void CounterVarSet::applyStyleSheet()
{
QString styleSheet = R"(
QString styleSheet =
R"(
QPushButton#closeBtn, QPushButton#checkBtn{
background-color: #E6F7FF;
border: 1px solid #87CEEB;
@@ -302,7 +303,6 @@ void CounterVarSet::applyStyleSheet()
background-color: #efefef;
}
// 下拉框
QComboBox QAbstractItemView {
border: 1px solid #000000;
border-radius: 3px;
@@ -343,6 +343,40 @@ void CounterVarSet::applyStyleSheet()
border: 1px solid #333333;
}
QTabWidget {
border: none;
background-color: #7B838E;
}
QTabBar::tab {
margin-top: -3px;
min-width: 90px;
min-height: 45px;
padding: 4px 10px;
margin-right: 4px;
border: 1px solid #dddddd;
border-bottom: none;
border-top-left-radius: 4px;
border-top-right-radius: 4px;
background-color: #5396C1;
color: #ffffff;
}
QTabWidget::tab-bar {
top: -3px;
left: 10px;
}
QTabBar::tab:focus {
outline: none;
}
QTabBar::tab:selected {
background-color: #6bb1e0;
color: #ffffff;
box-shadow: 0 -3px 8px rgba(44, 125, 232, 0.25);
}
)";
this->setStyleSheet(styleSheet);
+45 -20
View File
@@ -16,23 +16,6 @@ DateVarSet::DateVarSet(QWidget *parent) :
digitWidth = 4;
//connect(ui->radioButtonCurDate,SIGNAL(toggled(bool)),this,SLOT( slt_handleDigits()));
//connect(ui->radioButtonExpiry,SIGNAL(toggled(bool)),this,SLOT( slt_handleDigits()));
// connect(ui->radioButtonVarRandom,SIGNAL(toggled(bool)),this,SLOT(onRanDomPressed(bool)));
//connect(ui->radioButtonHour,SIGNAL(toggled(bool)),this,SLOT( slt_handleDigits()));
// connect(ui->radioButtonMinute,SIGNAL(toggled(bool)),this,SLOT( slt_handleDigits()));
// connect(ui->radioButtonWeek,SIGNAL(toggled(bool)),this,SLOT( slt_handleDigits()));
// connect(ui->radioButtonMonth,SIGNAL(toggled(bool)),this,SLOT( slt_handleDigits()));
// connect(ui->radioButtonSecond,SIGNAL(toggled(bool)),this,SLOT( slt_handleDigits()));
// connect(ui->radioButtonDay,SIGNAL(toggled(bool)),this,SLOT( slt_handleDigits()));
// // connect(ui->radioButtonXDay,SIGNAL(toggled(bool)),this,SLOT( slt_handleDigits()));
// connect(ui->radioButtonYear,SIGNAL(toggled(bool)),this,SLOT( slt_handleDigits()));
// connect(ui->radioButtonVar1,SIGNAL(toggled(bool)),this,SLOT( onDigitFourBit(bool)));
// connect(ui->radioButtonVar2,SIGNAL(toggled(bool)),this,SLOT( onDigitFourBit(bool)));
// connect(ui->radioButtonCNT3,SIGNAL(toggled(bool)),this,SLOT( onDigitFourBit(bool)));
//ui->radioButtonXDay->hide();
varTypeSet = 0;
varHtmlStr = "";
@@ -45,6 +28,8 @@ DateVarSet::DateVarSet(QWidget *parent) :
layout->addWidget(m_generalSettings);
ui->generalTab->setLayout(layout);
applyStyleSheet();
init();
initReplaceValue();
@@ -52,7 +37,6 @@ DateVarSet::DateVarSet(QWidget *parent) :
void DateVarSet::init()
{
applyStyleSheet();
// 连接信号槽
connect(ui->checkBtn, &QPushButton::clicked, this, &DateVarSet::buttonClickedSlot);
connect(ui->closeBtn,&QPushButton::clicked, this, &DateVarSet::buttonClickedSlot);
@@ -82,6 +66,17 @@ void DateVarSet::init()
connect(ui->lineEdit_Replace4, &QLineEdit::textChanged, std::bind(&DateVarSet::onLineEditReplaceChanged, this, 3, std::placeholders::_1));
}
void DateVarSet::initUI()
{
if (m_generalSettings)
m_generalSettings->initUI();
ui->lineEdit_DateFormat->setText("");
ui->expirationCBox->setCurrentIndex(0);
ui->expirationNumCBox->setValue(0);
ui->cb_replaceType->setCurrentIndex(0);
}
void DateVarSet::initReplaceValue(){
monthList.clear();
for (int i = 1; i <= 12; ++i) {
@@ -513,6 +508,8 @@ void DateVarSet::setDateModel(const DateItemModel &model)
}
loadMonthShow();
ui->tabWidget->setCurrentIndex(1);
}
void DateVarSet::useReplaceInsertVar(){
@@ -529,7 +526,6 @@ void DateVarSet::applyStyleSheet()
{
QString styleSheet =
R"(
QPushButton#closeBtn, QPushButton#checkBtn{
background-color: #E6F7FF;
border: 1px solid #87CEEB;
@@ -595,7 +591,6 @@ void DateVarSet::applyStyleSheet()
background-color: #efefef;
}
// 下拉框
QComboBox QAbstractItemView {
border: 1px solid #000000;
border-radius: 3px;
@@ -603,6 +598,36 @@ void DateVarSet::applyStyleSheet()
selection-background-color: #5396C1; /* 选中项背景色(稍深) */
selection-color: #ffffff;
}
QTabWidget {
border: none;
background-color: #7B838E;
}
QTabBar::tab {
min-width: 90px;
min-height: 45px;
padding: 4px 10px;
margin-right: 4px;
border: 1px solid #dddddd;
border-bottom: none;
border-top-left-radius: 4px;
border-top-right-radius: 4px;
background-color: #5396C1;
color: #ffffff;
}
QTabWidget::tab-bar {
top: -3px;
left: 10px;
}
QTabBar::tab:selected {
background-color: #6bb1e0;
color: #ffffff;
box-shadow: 0 -3px 8px rgba(44, 125, 232, 0.25);
}
)";
this->setStyleSheet(styleSheet);
+5 -1
View File
@@ -27,7 +27,9 @@ public:
void init();
void applyStyleSheet();
void initUI();
// void applyStyleSheet();
void bindSysPara(SysPara *sysPara);
@@ -118,6 +120,8 @@ private:
int currPage;
QXmlStreamAttributes m_backup;
void applyStyleSheet(); // 应用样式表
};
#endif // DATEVARSET_H
+1 -3
View File
@@ -160,9 +160,7 @@
background-color: #E6F7FF;
border: 1px solid #87CEEB;
border-radius: 4px;
min-width: 60px;
min-height: 40px;
font-size: 36px;
font-size: 24px;
font-family: &quot;Ubuntu&quot;;
color: #228B22;
}
+31 -22
View File
@@ -118,7 +118,6 @@ void InkJetPrinter::init()
connect(m_SystemSetting,&SystemSetting::sendButtonClickedSignal,this,&InkJetPrinter::getSystemSettingWidgetButtonClickSlot);
connect(m_OtherInfo,&OtherInfo::sendButtonClickedSignal,this,&InkJetPrinter::getOtherInfoWidgetButtonClickSlot);
connect(m_LogInfo,&LogInfo::sendButtonClickedSignal,this,&InkJetPrinter::getLogInfoWidgetButtonClickSlot);
connect(m_LogInfo,&LogInfo::sig_updateGeneralState,this,&InkJetPrinter::slt_updateGeneralState);
connect(m_DateVarSet,&DateVarSet::sendButtonClickedSignal,this,&InkJetPrinter::getDateSetWidgetButtonClickSlot);
//添加计数器,修改计数器
@@ -140,12 +139,20 @@ void InkJetPrinter::init()
connect(m_TestPrintWidget, &TestPrintWidget::sig_showEditCounter,
this, &InkJetPrinter::slt_editCounter);
// 状态界面
if (ctrl_loginfo == nullptr) ctrl_loginfo = LogInfoCtrl::instance();
connect(ctrl_loginfo, &LogInfoCtrl::sig_show, this, [=](){
getMainWidgetButtonClickedSlot(5);
m_LogInfo->checkState();
});
SysPara *para = new SysPara();
bindSysPara(para);
m_MainWidget->bindSysPara(para);
m_FontSetWidget->bindSysPara(para);
m_PrintSetting->bindSysPara(para);
m_SystemManage->bindSysPara(para);
m_SystemUpdate->bindSysPara(para);
m_SystemSetting->bindSysPara(para);
m_OtherInfo->bindSysPara(para);
m_TestPrintWidget->bindSysPara(para);
@@ -153,7 +160,8 @@ void InkJetPrinter::init()
m_CounterVarSet->bindSysPara(para);
m_MainInstruction->bindSysPara(para);
m_BarCodeDlg->bindSysPara(para);
m_QRCodeDlg->setSysPara(para);
m_QRCodeDlg->bindSysPara(para);
m_LogInfo->bindSysPara(para);
if(sysPara->para.gearPumpEnable)
pushButtonStartFlag = true;
@@ -719,8 +727,8 @@ void InkJetPrinter::timerHandler(void){
// byons: 改到往下一百行左右的位置了 byons@2026年4月11日
// 用于刷新时间类型 byons@2026年4月10日
// 现在只用于更新界面,给人看的,因此理论延迟1秒左右,实际受系统用量影响可能会更慢
if(m_StackedWidget->currentWidget() == m_MainWidget)
m_MainWidget->onPreviewScene();
// if(m_StackedWidget->currentWidget() == m_MainWidget)
// m_MainWidget->onPreviewScene();
// end by byons@2026年4月10日
}
@@ -831,20 +839,24 @@ void InkJetPrinter::timerHandler(void){
}
// byons: 时间类型图元更新 @2026年4月11日
if(sysPara->status.isPrinting) {
if (m_MainWidget->dateTimeItemsDotUpdate()) {
// // 统计追踪更新频率
// static QElapsedTimer bnsTimer;
// static int toogleCount = 0;
// ++toogleCount;
// if(toogleCount > 10) {
// auto elapsed = bnsTimer.restart();
// qDebug() << (QString("timeHandler avg elapsed: %1 s").arg(elapsed / qreal(toogleCount) / 1000.0));
// toogleCount = 0;
// }
// 统计追踪更新频率
static QElapsedTimer bnsTimer;
static int toogleCount = 0;
++toogleCount;
if(toogleCount > 10) {
auto elapsed = bnsTimer.restart();
qDebug() << (QString("timeHandler avg elapsed: %1 s").arg(elapsed / qreal(toogleCount) / 1000.0));
toogleCount = 0;
if(sysPara->status.isPrinting) {
m_MainWidget->SendPrintDataToFpga(0);
}
if (m_MainWidget->dateTimeItemsDotUpdate())
m_MainWidget->SendPrintDataToFpga(0);
if(m_StackedWidget->currentWidget() == m_MainWidget) {
m_MainWidget->updatePrintDisplayLabel();
}
}
// if (modbus->getModbusStatus() == 1) {
@@ -1130,6 +1142,7 @@ void InkJetPrinter::timerHandler(void){
static bool read_flag = false;
if((widget == m_MainWidget || widget == m_LogInfo) && pulse_100ms) {
m_MainWidget->updateSysStatusToUI();
m_MainWidget->updateGeneralState(m_MainWidget->alarmStatus);
m_LogInfo->updateSysStatusToUI(m_MainWidget->alarmStatus);
}
/*
@@ -1561,11 +1574,14 @@ void InkJetPrinter::getTestPrintWidgetButtonClickedSlot(int index)
void InkJetPrinter::openDatetimeEditor(PicDateItem* item)
{
m_DateVarSet->initUI();
m_DateVarSet->initReplaceValue();
if(item) {
m_DateVarSet->edit(item);
}
else
m_DateVarSet->setDateModel(DateItemModel::createDefaultReplaceModel());
m_StackedWidget->setCurrentWidget(m_DateVarSet);
}
@@ -1758,13 +1774,6 @@ void InkJetPrinter::getLogInfoWidgetButtonClickSlot(int index){
}
}
void InkJetPrinter::slt_updateGeneralState(DevStatusLightType type, QString stateStr)
{
if (m_MainWidget) {
m_MainWidget->updateGeneralState(type, stateStr);
}
}
void InkJetPrinter::getDateSetWidgetButtonClickSlot(int index){
switch (index)
{
+5 -4
View File
@@ -57,9 +57,10 @@ private:
MainWidget* m_MainWidget;
TestPrintWidget* m_TestPrintWidget;
QBarCode* m_BarCodeDlg = nullptr;
dlgQrCode* m_QRCodeDlg = nullptr;
// MainInterfaceWidget* m_MainInterfaceWidget;
QBarCode* m_BarCodeDlg __attribute__((deprecated("Use BarcodeEditor instead"))) = nullptr;
dlgQrCode* m_QRCodeDlg __attribute__((deprecated("Use BarcodeEditor instead"))) = nullptr;
SystemManage* m_SystemManage;
SystemUpdate* m_SystemUpdate;
SystemSetting* m_SystemSetting;
@@ -72,6 +73,7 @@ private:
MainInstruction* m_MainInstruction;
LogInfo* m_LogInfo;
LogInfoCtrl* ctrl_loginfo = nullptr;
ScheduleShiftsEditor* m_scheduleShiftsEditor = nullptr;
@@ -123,7 +125,6 @@ private slots:
void getSystemSettingWidgetButtonClickSlot(int index);
void getOtherInfoWidgetButtonClickSlot(int index);
void getLogInfoWidgetButtonClickSlot(int index);
void slt_updateGeneralState(DevStatusLightType type, QString stateStr);
void getDateSetWidgetButtonClickSlot(int index);
void getCounterVarSetWidgetButtonClickSlot(int index);
void slt_counterVarUpdate();
+2 -2
View File
@@ -86,8 +86,8 @@
<widget class="QPushButton" name="okBtn">
<property name="minimumSize">
<size>
<width>62</width>
<height>42</height>
<width>100</width>
<height>40</height>
</size>
</property>
<property name="styleSheet">
+80 -138
View File
@@ -92,6 +92,8 @@ void LogInfo::init()
QTabBar::tab:!selected {margin-top: 5px;}\
QTabBar::scroller{ width:80px;}";
// this->setStyleSheet(style_main2);
if (ctrl_loginfo == nullptr) ctrl_loginfo = LogInfoCtrl::instance();
connect(ctrl_loginfo, &LogInfoCtrl::sig_cleanOver, this, &LogInfo::slt_cleanOver);
}
void LogInfo::buttonClickedSlot()
@@ -355,6 +357,7 @@ void LogInfo::on_pushButtonClearCurrent_pressed()
runStatusTextIndex=0;
}
}
void LogInfo::onReadRecorder()
{
QString fileName = ":/buge_record.txt";
@@ -503,165 +506,48 @@ void LogInfo::updateSysStatusToUI(const AlarmStatus& alarmStatus){
ui->labOscVol->setText(alarmStatus.highVol);
ui->label_size->setText(alarmStatus.dataSize);
// 获取总状态
getGeneralState(alarmStatus);
}
void LogInfo::getGeneralState(AlarmStatus status)
void LogInfo::bindSysPara(SysPara *sysPara)
{
// 有红则红,全绿则绿,红>黄>绿
// 检查从后往前判断,因为取最后一个状态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("正常");
}
}
emit sig_updateGeneralState(m_stateColor, m_stateStr);
this->sysPara = sysPara;
}
bool LogInfo::checkRed(AlarmStatus &status)
void LogInfo::checkState()
{
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 LogInfo::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;
ui->tabWidget->setCurrentIndex(3);
}
void LogInfo::applyStyleSheet()
{
QString styleSheet = R"(
QTabWidget {
border: none;
background-color: #7B838E;
QTabWidget::pane {
border: 1px solid #dddddd;
background-color: #ffffff;
}
QTabWidget::tab-bar {
background-color: #7B838E;
alignment: left;
height: 80px;
margin: 0;
}
QTabBar {
background-color: #7B838E;
border: none;
width: 100%;
min-width: 100%;
height: 80px;
padding: 0;
top: -3px;
left: 10px;
}
QTabBar::tab {
width: 140px;
height: 80px;
font-size: 16px;
font-weight: bold;
color: #000000;
border: none;
border-top-left-radius: 10px;
border-top-right-radius: 10px;
alignment: center bottom;
padding-top: 0;
}
QTabBar::tab {
margin-left: 10px;
margin-top: 10px;
}
QTabBar::tab:!selected {
background: qlineargradient(x1:0, y1:0, x2:0, y2:1,
stop:0 #6E757F, stop:1 #96A0A9);
border: 2px solid #63535D;
min-width: 90px;
min-height: 45px;
padding: 4px 10px;
margin-right: 4px;
border: 1px solid #dddddd;
border-bottom: none;
position: relative;
bottom: 0px;
border-top-left-radius: 4px;
border-top-right-radius: 4px;
background-color: #5396C1;
color: #ffffff;
}
QTabBar::tab:selected {
background: qlineargradient(x1:0, y1:0, x2:0, y2:1,
stop:0 #95B2D4, stop:1 #F0F0F0);
border: none;
position: relative;
bottom: 0px;
}
QTabWidget::pane {
border: none;
background-color: #f0f0f0;
top: -12px;
background-color: #6bb1e0;
color: #ffffff;
box-shadow: 0 -3px 8px rgba(44, 125, 232, 0.25);
}
QWidget#buttonWidget {
@@ -734,3 +620,59 @@ void LogInfo::applyStyleSheet()
this->setStyleSheet(styleSheet);
}
void LogInfo::on_btn_clean_clicked()
{
if (ctrl_loginfo) ctrl_loginfo->emitSigClean();
}
void LogInfo::slt_cleanOver(bool flag)
{
if (flag) {
lockUI();
} else {
unlockUI();
}
}
void LogInfo::lockUI()
{
ui->closeBtn4->setEnabled(false);
ui->gl_state->setEnabled(false);
ui->gridLayout_7->setEnabled(false);
ui->tabWidget->setTabEnabled(0,false);
ui->tabWidget->setTabEnabled(1,false);
ui->tabWidget->setTabEnabled(2,false);
ui->lb_clean->setText(tr("清洗中,界面锁死"));
}
void LogInfo::unlockUI()
{
ui->closeBtn4->setEnabled(true);
ui->gl_state->setEnabled(true);
ui->gridLayout_7->setEnabled(true);
ui->tabWidget->setTabEnabled(0,true);
ui->tabWidget->setTabEnabled(1,true);
ui->tabWidget->setTabEnabled(2,true);
ui->lb_clean->setText(tr(""));
}
void LogInfo::showEvent(QShowEvent *event)
{
// 先执行父类事件
QWidget::showEvent(event);
// 更新UI和状态
if (sysPara) {
if(!sysPara->para.isCheckMagnet)
{
ui->btn_clean->setEnabled( (sysPara->status.currReclaimTankPos<70)
&& (sysPara->status.statWarn & WARN_STATUS_HDINT));
}
else
{
ui->btn_clean->setEnabled( (sysPara->status.currReclaimTankPos<70) );
}
}
}
+16 -27
View File
@@ -6,7 +6,9 @@
#include "MyFileDialog.h"
#include <QDate>
#include <QTimer>
#include "SysPara.h"
#include "myinclude.h"
#include "loginfoctrl.h"
namespace Ui {
class LogInfo;
}
@@ -34,23 +36,6 @@ typedef struct{
QString dataSize;
}AlarmStatus;
//typedef struct {
// unsigned char inkSwith;
// unsigned char NozzleCover;
// unsigned char InkTankFull;
// unsigned char InkLevel;
// unsigned char SolventLevel;
// unsigned char RecyclyFault;
// unsigned char ViscosityFault;
// unsigned char PhaseFault;
// unsigned char HighVoltageFault;
// QString pressValue;
// QString visoValue;
// QString gearPumpRunSpeed;
// QString highVol;
// QString dataSize;
//}AlarmStatus;
class LogInfo : public QWidget
{
Q_OBJECT
@@ -75,6 +60,10 @@ public:
void applyStyleSheet(); // 应用样式表
void updateSysStatusToUI(const AlarmStatus& alarmStatus);
void bindSysPara(SysPara *sysPara);
void checkState();
protected slots:
void deleteOldLog(const QString folderPath, int days);
void deleteOldLog();
@@ -90,10 +79,12 @@ private slots:
void buttonClickedSlot();
void on_btn_clean_clicked();
void slt_cleanOver(bool flag);
signals:
void sendButtonClickedSignal(int);
void faultTesumePress();
void sig_updateGeneralState(DevStatusLightType type, QString stateStr);
private:
Ui::LogInfo *ui;
@@ -107,16 +98,14 @@ private:
static QString r_CurrentDate;
QTimer *timerLogdel;
LogInfoCtrl *ctrl_loginfo = nullptr;
// 锁定全局控件,放出逆清洗
void lockUI();
void unlockUI();
protected:
SysPara *sysPara;
DevStatusLightType m_stateColor = DEV_STATUS_GREEN;
//DEV_STATUS_GREEN:正常
QString m_stateStr = "正常";
//Mainwindow获取机器总状态
void getGeneralState(AlarmStatus status);
bool checkRed(AlarmStatus &status);
bool checkYellow(AlarmStatus &status);
void showEvent(QShowEvent *event) override;
};
#endif // LOGINFO_H
+114 -1
View File
@@ -35,7 +35,7 @@ MainInstruction::MainInstruction(QWidget *parent) :
connect(MTimeSetting,SIGNAL(accepted()),this,SLOT(onMTimeSettingAccepted()));
// setStyleSheet(styleSheet);
applyStyleSheet();
}
MainInstruction::~MainInstruction()
@@ -243,3 +243,116 @@ void MainInstruction::slt_timeSetting()
sysPara->devOp->stm32Wr(0xA1,(unsigned char *)m_datatime,8);
}
void MainInstruction::applyStyleSheet()
{
QString styleSheet =
R"(
QWidget#buttonWidget {
background-color: #95989D;
}
QPushButton#closeBtn {
background-color: #E6F7FF;
border: 1px solid #87CEEB;
border-radius: 4px;
font-size: 24px;
color: #228B22;
}
QPushButton#closeBtn:hover {
background-color: #D1E9FF;
}
QPushButton#closeBtn:pressed {
background-color: #BAE7FF;
}
QLabel {
font-size: 18px;
color: #000000;
font-weight: 500;
}
QCheckBox {
font-size: 18px;
color: #000000;
font-weight:500;
}
QCheckBox::indicator {
width: 18px;
height: 18px;
border: 1px solid #96A0A9;
border-radius: 10px;
background-color: #ffffff;
}
QCheckBox::indicator:checked {
background-color: #95B2D4;
border-color: #95B2D4;
image: url(:/Demo/image/select.png);
}
QPushButton {
background-color: #5396C1;
color: #ffffff;
border: 1px solid #000000;
border-radius: 3px;
font-size: 18px;
font-weight:500;
width: 180px;
height: 90px;
}
QPushButton:hover {
background-color: #5396C1;
}
QPushButton:disabled {
background-color: #7C828E;
color: #606060;
border-color: #808080;
}
QWidget#fileTab, QWidget#extraTab, QWidget#settingsTab, QWidget#serviceTab {
background-color: #E3E7EC;
}
QTabWidget::pane {
border: 1px solid #dddddd;
background-color: #ffffff;
}
QTabWidget::tab-bar {
top: -3px;
left: 10px;
}
QTabBar::tab {
min-width: 90px;
min-height: 45px;
padding: 4px 10px;
margin-right: 4px;
border: 1px solid #dddddd;
border-bottom: none;
border-top-left-radius: 4px;
border-top-right-radius: 4px;
background-color: #5396C1;
color: #ffffff;
}
QTabBar::tab:selected {
background-color: #6bb1e0;
color: #ffffff;
box-shadow: 0 -3px 8px rgba(44, 125, 232, 0.25);
}
QTabBar::tab:focus {
outline: none;
}
)";
this->setStyleSheet(styleSheet);
}
+1
View File
@@ -63,6 +63,7 @@ private:
// 时间设置
TimeSettingDialog timeDia;
void applyStyleSheet(); // 应用样式表
};
#endif // MAININSTRUCTION_H
+36 -34
View File
@@ -93,25 +93,25 @@
<rect>
<x>9</x>
<y>9</y>
<width>641</width>
<height>501</height>
<width>601</width>
<height>431</height>
</rect>
</property>
<property name="currentIndex">
<number>1</number>
<number>0</number>
</property>
<widget class="QWidget" name="tabExtra">
<attribute name="title">
<string>基本设置</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QPushButton" name="graphicsEditorBtn">
<property name="geometry">
<rect>
<x>20</x>
<y>30</y>
<width>182</width>
<property name="maximumSize">
<size>
<width>253</width>
<height>92</height>
</rect>
</size>
</property>
<property name="text">
<string>图形编辑器</string>
@@ -123,33 +123,14 @@
</size>
</property>
</widget>
<widget class="QPushButton" name="btn_network">
<property name="geometry">
<rect>
<x>20</x>
<y>150</y>
<width>182</width>
<height>92</height>
</rect>
</property>
<property name="text">
<string>网口通信</string>
</property>
<property name="fixedSize" stdset="0">
<size>
<width>220</width>
<height>60</height>
</size>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QPushButton" name="btn_time">
<property name="geometry">
<rect>
<x>230</x>
<y>30</y>
<width>182</width>
<property name="maximumSize">
<size>
<width>253</width>
<height>92</height>
</rect>
</size>
</property>
<property name="text">
<string>时间设置</string>
@@ -161,6 +142,27 @@
</size>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QPushButton" name="btn_network">
<property name="maximumSize">
<size>
<width>253</width>
<height>92</height>
</size>
</property>
<property name="text">
<string>网口通信</string>
</property>
<property name="fixedSize" stdset="0">
<size>
<width>220</width>
<height>60</height>
</size>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tabService">
<attribute name="title">
+43 -8
View File
@@ -6,11 +6,26 @@
<rect>
<x>0</x>
<y>0</y>
<width>817</width>
<height>600</height>
<width>800</width>
<height>607</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QFrame" name="frame3">
<property name="styleSheet">
@@ -145,7 +160,7 @@
<rect>
<x>9</x>
<y>9</y>
<width>746</width>
<width>761</width>
<height>150</height>
</rect>
</property>
@@ -171,15 +186,22 @@
</widget>
</item>
<item>
<widget class="QWidget" name="widget" native="true">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>335</height>
</size>
</property>
<layout class="QHBoxLayout" name="horizontalLayout" stretch="1,0">
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QFrame" name="frame">
<widget class="QFrame" name="fra_state">
<property name="maximumSize">
<size>
<width>180</width>
<height>16777215</height>
<height>150</height>
</size>
</property>
<property name="frameShape">
@@ -580,8 +602,20 @@
<layout class="QVBoxLayout" name="verticalLayout_5" stretch="1,0">
<item>
<widget class="QLabel" name="lb_reclaimtanl">
<property name="maximumSize">
<size>
<width>200</width>
<height>150</height>
</size>
</property>
<property name="text">
<string>reclaimtanl_image</string>
<string/>
</property>
<property name="pixmap">
<pixmap resource="image.qrc">:/image/tool.png</pixmap>
</property>
<property name="scaledContents">
<bool>true</bool>
</property>
</widget>
</item>
@@ -613,7 +647,7 @@
</size>
</property>
<property name="styleSheet">
<string notr="true">border:0px;</string>
<string notr="true"/>
</property>
<property name="text">
<string>喷嘴开启</string>
@@ -647,7 +681,7 @@
</size>
</property>
<property name="styleSheet">
<string notr="true">border:0px;</string>
<string notr="true"/>
</property>
<property name="text">
<string>喷嘴关闭</string>
@@ -669,6 +703,7 @@
</layout>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
+7 -3
View File
@@ -15,9 +15,13 @@
#include "zint.h"
#define U08 unsigned char
#define U16 unsigned short
#define U32 unsigned int
// #define U08 unsigned char
// #define U16 unsigned short
// #define U32 unsigned int
typedef unsigned char U08;
typedef unsigned short U16;
typedef unsigned int U32;
#ifdef __cplusplus
extern "C"
+2
View File
@@ -23,7 +23,9 @@
#include<iostream>
#include<string>
#include<QLineEdit>
#include <QKeyEvent>
#include "InkJetPrinter.h"
extern InkJetPrinter *pInkJectPrinter;
MyInputMethod::MyInputMethod(QWidget *parent)
:QObject(parent)
+36 -481
View File
@@ -81,20 +81,6 @@ void PrintSetting::on_pushButtonApply_pressed(){
void PrintSetting::applyUIPara(){
if(sysPara){
/*
LogInfo::setRunStatusText(tr("addr: %1").arg(addr));
LogInfo::setRunStatusText(tr("data: %1").arg(data));
LogInfo::setRunStatusText(tr("len: %1").arg(len));
sysPara->para.ExtScreenType = ui->comBoxExtSrceen->currentIndex();
sysPara->para.ExtMeterType = ui->comBoxExtMeterType->currentIndex();
sysPara->para.gearPumpSpeedAlarm = ui->spinBox_gearPumpSpeedAlarm->value();
if(sysPara->para.ExtScreenType==0)
{
sysPara->status.ExtScreenEn =0;
}
*/
sysPara->para.printTriggerMode = PRINT_TRIGGER_TIME; //延时触发
sysPara->para.printDelayMs = 200; //重复间隔
sysPara->para.checkSpace = 0;//ui->checkSpace->isChecked();
@@ -103,37 +89,7 @@ void PrintSetting::applyUIPara(){
sysPara->para.upDownInverse = ui->checkBoxUpDownInverse->isChecked();
sysPara->para.currSelectVolPara = ui->comboBox_selcetVolPara->currentIndex();
sysPara->para.printColDelay = ui->spinBoxColDelay->value();
/*
sysPara->para.scanInverse = ui->checkBoxScanInverse->isChecked();
sysPara->para.currPrintMode = ui->comboBoxPrintMode->currentIndex();
sysPara->para.varLenEn = ui->checkVARLEN->isChecked();
sysPara->para.suspendAfterPhaseFault = ui->checkBoxSuspendAfterPhaseFault->isChecked();
sysPara->para.powerOffAfterPhaseFault = ui->checkBoxPowerOffAfterPhaseFault->isChecked();
sysPara->para.RecycleWarnAction = ui->checkBoxRecycleWarnAction->isChecked();
sysPara->para.stopCounterMeterAfterFault = ui->checkBoxStopCounterMeterAfterFault->isChecked();
sysPara->para.cnt1EndValue = ui->spinBoxCnt1EndValue->value();
sysPara->para.cnt1RepeateValue = ui->spinBoxCnt1RepeateCnt->value();
sysPara->para.cnt1StartValue = ui->spinBoxCnt1StartValue->value();
sysPara->para.cnt1StepValue = ui->spinBoxCnt1StepValue->value();
sysPara->para.cnt1CurrValue = ui->spinBoxCnt1CurrValue->value(); //这个值设置没关系,在关机前还会再此被设置
sysPara->para.cnt2EndValue = ui->spinBoxCnt2EndValue->value();
sysPara->para.cnt2RepeateValue = ui->spinBoxCnt2RepeateCnt->value();
sysPara->para.cnt2StartValue = ui->spinBoxCnt2StartValue->value();
sysPara->para.cnt2StepValue = ui->spinBoxCnt2StepValue->value();
sysPara->para.cnt2CurrValue = ui->spinBoxCnt2CurrValue->value();
sysPara->para.newAmplifyPlate = ui->checkBoxNewAmplifyPlate->isChecked();
sysPara->para.cnt3EndValue = ui->spinBoxCnt3EndValue->value();
sysPara->para.cnt3RepeateValue = ui->spinBoxCnt3RepeateCnt->value();
sysPara->para.cnt3StartValue = ui->spinBoxCnt3StartValue->value();
sysPara->para.cnt3StepValue = ui->spinBoxCnt3StepValue->value();
sysPara->para.cnt3CurrValue = ui->spinBoxCnt3CurrValue->value();
sysPara->para.startVoltage = ui->spinBoxStartVoltage->value();
sysPara->para.endVoltage = ui->spinBoxEndVoltage->value();
sysPara->para.charBold = ui->spinBoxColRepeatCnt->value();
*/
sysPara->para.HighVoltageAmplitude = ui->spinBoxHighVoltageValue->value();
// 回收泵的控制转至系统设置界面 byons@2026年4月22日
@@ -142,409 +98,27 @@ void PrintSetting::applyUIPara(){
sysPara->devOp->setHighVoltageAmplitudetoSTM32();
/*
sysPara->status.cnt1CurrentValueInitDoneFlag = !ui->checkBoxResetCnt1CurrValue->isChecked();
sysPara->status.cnt2CurrentValueInitDoneFlag = !ui->checkBoxResetCnt2CurrValue->isChecked();
sysPara->status.cnt3CurrentValueInitDoneFlag = !ui->checkBoxResetCnt3CurrValue->isChecked();
if(sysPara->para.cnt1ByGroupEnalbe)
ApplyCnt1GroupSetting();
sysPara->para.flagOfFastMode = ui->checkBox_FastMode->isChecked();
if(sysPara->para.flagOfFastMode){
if(ui->comboBoxPrintMode->count()>=3){
ui->comboBoxPrintMode->setItemText(0,tr("超高速"));
ui->comboBoxPrintMode->setItemText(1,tr("高速"));
ui->comboBoxPrintMode->removeItem(2);
}
}else{
if(ui->comboBoxPrintMode->count()<3){
ui->comboBoxPrintMode->setItemText(0,tr("快速"));
ui->comboBoxPrintMode->setItemText(1,tr("标准"));
ui->comboBoxPrintMode->addItem(tr("慢速"));
}
}
if(sysPara->para.EditMode==TXTFILE)
{
sysPara->status.specialVarPrint.SpecialVarEnable = ui->radioButtonSpecialCondition->isChecked();
sysPara->status.cnt4CurrValue = ui->spinBoxHiddenValue->value();
sysPara->status.specialVarPrint.MeterEnable = ui ->spinBoxMeterEnable->value();
sysPara ->status.specialVarPrint.SpecialConditionValue = ui->spinBoxConditionValue->value();
if(sysPara->status.specialVarPrint.SpecialVarEnable)
sysPara->status.specialVarPrint.SpecialVarEnable = 0xFF;
if(sysPara->status.specialVarPrint.MeterEnable)
sysPara->status.specialVarPrint.MeterEnable = 0xFF;
sysPara->para.cnt4CurrValue = sysPara->status.cnt4CurrValue;
sysPara->para.HiddenConditionValue = sysPara->status.specialVarPrint.SpecialConditionValue;
sysPara->para.HiddenFuncEnable = sysPara->status.specialVarPrint.SpecialVarEnable;
sysPara->para.HiddenMeterEnable = sysPara->status.specialVarPrint.MeterEnable;
}
*/
sysPara->devOp->writeFpgaCalandar(0);
/*
sysPara->para.reducedPixelNumRatio = ui->spinBoxReducedPixelNum->value();
sysPara->para.reducedPixelMode = ui->comboBoxReducedPixMode->currentIndex();
sysPara->para.rowSequenceMode = ui->spinBoxRowSequenceMode->value();
sysPara->para.pointVoltageAdjustPos = ui->spinBoxPointVoltageAdjustPos->value();
sysPara->para.PointVoltageAdjustValue = ui->spinBoxVoltageAdjustValue->value();
sysPara->para.lineEndAdjustPointCnt = ui->spinBoxLineEndAdjustPointCnt->value();
sysPara->para.lineEndAdjustPointDelay = ui->comboBoxLineEndAdjustPointMode->currentIndex();
sysPara->para.lastLineEndPointFixedValue = ui->spinBoxLastLineEndPointFixedValue->value();
sysPara->para.FullColFixVal = ui->radioButtonFUllColFIxVal->isChecked();//2020/3/2
sysPara->para.dacScale = ui->dacScaledSpinBox->value();
sysPara->para.industryIndex = ui->comboBoxIndustry->currentIndex();
sysPara->para.recommendedPrintSpeed = ui->comboBoxRecommendedPrintSpeed->currentIndex();
if(ui->eleCNT1IncEn->isChecked())
sysPara->para.eleEyeClearCntInSynMode = (sysPara->para.eleEyeClearCntInSynMode | 0x10); // CNT1 +1
else
sysPara->para.eleEyeClearCntInSynMode = (sysPara->para.eleEyeClearCntInSynMode & 0xef); // CNT1 = current
if(ui->eleCNT2IncEn->isChecked())
sysPara->para.eleEyeClearCntInSynMode = (sysPara->para.eleEyeClearCntInSynMode | 0x20); // CNT2 +1
else
sysPara->para.eleEyeClearCntInSynMode = (sysPara->para.eleEyeClearCntInSynMode & 0xdf); // CNT2 = current
if(ui->eleCNT3IncEn->isChecked())
sysPara->para.eleEyeClearCntInSynMode = (sysPara->para.eleEyeClearCntInSynMode | 0x40); // CNT3 +1
else
sysPara->para.eleEyeClearCntInSynMode = (sysPara->para.eleEyeClearCntInSynMode & 0xbf); // CNT3 = current
sysPara->para.alterPrint.enable =ui->comboBoxAlterPrintEnable->currentIndex();// 修改后的
if(sysPara->para.alterPrint.enable)
sysPara->para.textEditLineSpace = 0;
sysPara->para.alterPrint.lineSpace = sysPara->para.textEditLineSpace;
sysPara->para.alterPrint.startValue = ui->spinBoxXStartValue->value ();
sysPara->para.alterPrint.repeatValue = ui->spinBoxXGapValue->value ();
sysPara->para.alterPrint.repeatPrintTimes =ui->spinBoxXRepeatTimeValue->value ();
sysPara->para.alterPrint.DistanceTail =ui->spinBoxDistanceTail->value ();
if( sysPara->para.alterPrint.startValue>= sysPara->para.alterPrint.repeatValue )
{
sysPara->para.alterPrint.startValue =sysPara->para.alterPrint.repeatValue -1;
ui->spinBoxXStartValue->setValue (sysPara->para.alterPrint.startValue);
QMessageBox::information(this,tr("提示:交替参数不正确"),tr("要求:起始位置<交替间隔"));
}
if( sysPara->para.alterPrint.repeatPrintTimes+sysPara->para.alterPrint.startValue
> sysPara->para.alterPrint.repeatValue )
{
sysPara->para.alterPrint.repeatPrintTimes =sysPara->para.alterPrint.repeatValue -sysPara->para.alterPrint.startValue-1;
ui->spinBoxXRepeatTimeValue->setValue (sysPara->para.alterPrint.repeatPrintTimes);
QMessageBox::information(this,tr("提示:交替参数不正确"),tr("要求:(重复次数+起始位置)<交替间隔"));
}
sysPara->para.Cnt1NatureValue = ui->checkBoxCnt1NatureValue->isChecked (); //
sysPara->para.speedoverPaushPrint = ui->checkBoxSpeedOver->isChecked();
sysPara->para.SynCntEn = ui->checkSynCntEn->isChecked();
sysPara->para.Vol1of8En = ui->checkVol1of8En->isChecked();//打印优化
sysPara->para.mode0211 = ui->checkmode0211->isChecked();//添加0211模式
sysPara->para.cnt1ResetToInitValue = ui->resetToCnt1InitValueCheckBox->isChecked();// 电眼复位时,复位起始值或当前值
//sysPara->para.printOnce = ui->checkBoxPrintOnce->isChecked();// 每条信息只喷一次
// sysPara->para.printOnce = 0;// 每条信息只喷一次
//sysPara->para.printNumPoint = ui->checkBoxNumPoint->isChecked();// 每条信息只喷一次
sysPara->para.Reciclar = ui->checkBoxReciclar->isChecked();//sysPara->para.Reciclar = 0; //
switch(ui->spinBoxdecimalpointnum->value())
//20240625修改小数点位数可选0-3位,FPGA原参数a44d 地址第6号位为 是否打印小数使能信号,1为打印小数,0为不打印小数。
//更改为:
// a44d 地址第6号位和第7号位为 打印显示小数位数;
// 第7,6变量为 11 打印3位小数,
// 第7,6变量为 10 打印2位小数,
// 第7,6变量为 01 打印1位小数,
// 第7,6变量为 00 打印0位小数,
{
case 0:
ui->radioButtonSpecialCondition->setEnabled(true);
sysPara->para.printNumPoint = 0;
sysPara->para.rrr_nc = 0;
break;
case 1:
ui->radioButtonSpecialCondition->setEnabled(false);
ui->spinBoxMeterEnable->setValue(0);
sysPara->para.printNumPoint = 1;
sysPara->para.rrr_nc = 0;
break;
case 2:
ui->radioButtonSpecialCondition->setEnabled(false);
ui->spinBoxMeterEnable->setValue(0);
sysPara->para.printNumPoint = 0;
sysPara->para.rrr_nc = 1;
break;
case 3:
ui->radioButtonSpecialCondition->setEnabled(false);
ui->spinBoxMeterEnable->setValue(0);
sysPara->para.printNumPoint = 1;
sysPara->para.rrr_nc = 1;
break;
default:
sysPara->para.printNumPoint = 0;
sysPara->para.rrr_nc = 0;
break;
}
sysPara->para.stepPrint.startValue = ui->spinBoxJumpStartValue->value();
sysPara->para.stepPrint.endValue = ui->spinBoxJumpEndValue->value();
sysPara->para.stepPrint.enbale = ui->checkBoxStepPrintEn->isChecked();
sysPara->para.stepPrint.StepValue = ui->spinBoxJumpStepValue->value();
sysPara->para.ResetSendData = ui->checkBoxResetSendData->isChecked();
sysPara->para.eleEyeReTrigDisable = ui->checkBoxEleEyeRetrigDis->isChecked();
sysPara->para.ResetAllProductCntEn = ui->checkAllProductResetEn->isChecked();
sysPara->para.ResetProductCntEn = ui->checkProductResetEn->isChecked();
sysPara->para.HVFaultCloseEn = ui->checkHVFaultCloseEn->isChecked();
sysPara->para.phaseHighCnt = ui->phaseHighCntSpinBox->value();
sysPara->para.charWidthSetEnable = ui->checkBoxCharWidthSet->isChecked();
sysPara->para.isCheckMagnet = ui->checkBoxMagnet->isChecked();
sysPara->para.isCheckPrintLight = ui->printfLightCheckBox->isChecked();
sysPara->para.bcOption.var1Num=ui->spinBoxCnt1EndValue->text().length();
sysPara->para.bcOption.var2Num=ui->spinBoxCnt2EndValue->text().length();
// sysPara->para.bcOption.var3Num=ui->spinBoxCnt2EndValue_2->text().length();
//qDebug()<<"sysPara->para.bcOption.varNum"<<sysPara->para.bcOption.var1Num<<sysPara->para.bcOption.var2Num;
sysPara->para.ExpiryDay = ui->spinBoxExpiryDate->value();
sysPara->para.ExpirySplitMode = ui->CBDateFormat1->currentIndex();
ui->resetToCnt1InitValueCheckBox->isChecked();
//qDebug()<<sysPara->print.ExpiryDay;
*/
// if(sysPara->devOp->writeFpgaPrintPara() != -1) // save para to disk file.
// QMessageBox::information(this,tr("提示"),tr("应用成功"));
/*
//ui->labelCnt1CurrValueTxt->setEnabled(false);
// ui->labelCnt2CurrValueTxt->setEnabled(false);
ui->spinBoxCnt1CurrValue->setEnabled(false);
ui->spinBoxCnt2CurrValue->setEnabled(false);
ui->spinBoxCnt3CurrValue->setEnabled(false);
ui->checkBoxResetCnt1CurrValue->setChecked(false);
ui->checkBoxResetCnt2CurrValue->setChecked(false);
ui->checkBoxResetCnt3CurrValue->setChecked(false);
*/
}
}
void PrintSetting::updateSysParaToUI(){
if(sysPara){
/*
ui->checkVARLEN->setChecked(sysPara->para.varLenEn?1:0);
ui->checkBoxNewAmplifyPlate->setChecked(sysPara->para.newAmplifyPlate);
ui->comBoxExtSrceen->setCurrentIndex(sysPara->para.ExtScreenType);
ui->comBoxExtMeterType->setCurrentIndex(sysPara->para.ExtMeterType);
*/
ui->checkBoxLeftRightInverse->setChecked(sysPara->para.leftRightInverse);
ui->checkBoxUpDownInverse->setChecked(sysPara->para.upDownInverse);
sysPara->para.mode0211 = 1;
/*
ui->checkBoxScanInverse->setChecked(sysPara->para.scanInverse);
ui->checkBoxRecycleWarnAction->setChecked(sysPara->para.RecycleWarnAction);
ui->checkBoxPowerOffAfterPhaseFault->setChecked(sysPara->para.powerOffAfterPhaseFault);
ui->checkBoxSuspendAfterPhaseFault->setChecked(!sysPara->para.powerOffAfterPhaseFault);
ui->checkBoxSuspendAfterPhaseFault->setChecked(sysPara->para.suspendAfterPhaseFault);
ui->checkBoxStopCounterMeterAfterFault->setEnabled(sysPara->para.suspendAfterPhaseFault);
ui->checkBoxStopCounterMeterAfterFault->setChecked(sysPara->para.stopCounterMeterAfterFault);
ui->comboBoxPrintMode->setCurrentIndex(sysPara->para.currPrintMode);
ui->spinBox_gearPumpSpeedAlarm->setValue(sysPara->para.gearPumpSpeedAlarm);
*/
/*----------------------------------------*/
ui->spinBoxColDelay->setValue(sysPara->para.printColDelay);
/*
ui->spinBoxColRepeatCnt->setValue(sysPara->para.charBold);
ui->spinBoxCnt1EndValue->setValue(sysPara->para.cnt1EndValue);
ui->spinBoxCnt1RepeateCnt->setValue(sysPara->para.cnt1RepeateValue);
ui->spinBoxCnt1StartValue->setValue(sysPara->para.cnt1StartValue);
ui->spinBoxCnt1StepValue->setValue(sysPara->para.cnt1StepValue);
ui->spinBoxCnt1CurrValue->setValue(sysPara->para.cnt1CurrValue);
ui->spinBoxCnt2EndValue->setValue(sysPara->para.cnt2EndValue);
ui->spinBoxCnt2RepeateCnt->setValue(sysPara->para.cnt2RepeateValue);
ui->spinBoxCnt2StartValue->setValue(sysPara->para.cnt2StartValue);
ui->spinBoxCnt2StepValue->setValue(sysPara->para.cnt2StepValue);
ui->spinBoxCnt2CurrValue->setValue(sysPara->para.cnt2CurrValue);
ui->spinBoxCnt3EndValue->setValue(sysPara->para.cnt3EndValue);
ui->spinBoxCnt3RepeateCnt->setValue(sysPara->para.cnt3RepeateValue);
ui->spinBoxCnt3StartValue->setValue(sysPara->para.cnt3StartValue);
ui->spinBoxCnt3StepValue->setValue(sysPara->para.cnt3StepValue);
ui->spinBoxCnt3CurrValue->setValue(sysPara->para.cnt3CurrValue);
ui->spinBoxStartVoltage->setValue(sysPara->para.startVoltage);
ui->spinBoxEndVoltage->setValue(sysPara->para.endVoltage);
*/
ui->spinBoxHighVoltageValue->setValue(sysPara->para.HighVoltageAmplitude);
/*
ui->spinBoxReducedPixelNum->setValue(sysPara->para.reducedPixelNumRatio);
ui->comboBoxReducedPixMode->setCurrentIndex(sysPara->para.reducedPixelMode);
ui->spinBoxRowSequenceMode->setValue(sysPara->para.rowSequenceMode);
ui->spinBoxPointVoltageAdjustPos->setValue(sysPara->para.pointVoltageAdjustPos);
ui->spinBoxVoltageAdjustValue->setValue(sysPara->para.PointVoltageAdjustValue);
ui->spinBoxLineEndAdjustPointCnt->setValue(sysPara->para.lineEndAdjustPointCnt);
ui->comboBoxLineEndAdjustPointMode->setCurrentIndex(sysPara->para.lineEndAdjustPointDelay);
ui->spinBoxLastLineEndPointFixedValue->setValue(sysPara->para.lastLineEndPointFixedValue);
// ui->spinBoxFullColFixVal->setValue(sysPara->para.FullColFixVal);
ui->radioButtonFUllColFIxVal->setChecked(sysPara->para.FullColFixVal);
*/
ui->comboBox_selcetVolPara->setCurrentIndex(sysPara->para.currSelectVolPara);
// 齿轮泵和回收泵的控制转至系统设置 byons@2026年4月22日
// ui->checkBoxGearPumpEnable->setChecked(sysPara->para.gearPumpEnable);
// ui->checkBox_ReclaimPumpEnable->setChecked(sysPara->para.flagOfReclaimPumEnable);
//隐藏功能
/*
ui->radioButtonSpecialCondition->setChecked(sysPara->para.HiddenFuncEnable);
ui->spinBoxHiddenValue->setValue(sysPara->para.cnt4CurrValue);
ui->spinBoxConditionValue->setValue(sysPara->para.HiddenConditionValue);
ui->spinBoxMeterEnable->setValue(sysPara->para.HiddenMeterEnable);
// sysPara->status.cnt4CurrValue = sysPara->para.cnt4CurrValue;
sysPara->status.specialVarPrint.SpecialConditionValue = sysPara->para.HiddenConditionValue ;
sysPara->status.specialVarPrint.SpecialVarEnable =sysPara->para.HiddenFuncEnable ;
sysPara->status.specialVarPrint.MeterEnable = sysPara->para.HiddenMeterEnable;
if(sysPara->status.specialVarPrint.SpecialVarEnable)
sysPara->status.specialVarPrint.SpecialVarEnable = 0xFF;
if(sysPara->status.specialVarPrint.MeterEnable)
sysPara->status.specialVarPrint.MeterEnable = 0xFF;
emit HiddenFunction(ui->radioButtonSpecialCondition->isChecked());
if(sysPara->para.HiddenFuncEnable)
{
// emit HiddenFunction(ui->radioButtonSpecialCondition->isChecked());
ui->spinBoxdecimalpointnum->setValue(0);
ui->spinBoxdecimalpointnum->setEnabled(false);
ui->radioButtonSpecialCondition->setEnabled(true);
ui->spinBoxHiddenValue->setEnabled(true);
ui->spinBoxConditionValue->setEnabled(true);
ui->spinBoxMeterEnable->setEnabled(true);
}
if(!sysPara->para.rrr_nc)
{
if(!sysPara->para.printNumPoint)
ui->spinBoxdecimalpointnum->setValue(0);
else
ui->spinBoxdecimalpointnum->setValue(1);
}
else
{
if(!sysPara->para.printNumPoint)
ui->spinBoxdecimalpointnum->setValue(2);
else
ui->spinBoxdecimalpointnum->setValue(3);
}
ui->comboBoxIndustry->setCurrentIndex(sysPara->para.industryIndex);
ui->comboBoxRecommendedPrintSpeed->setCurrentIndex(sysPara->para.recommendedPrintSpeed);
ui->comboBoxAlterPrintEnable->setCurrentIndex (sysPara->para.alterPrint.enable );// 修改后的
if(sysPara->para.alterPrint.enable == 0)
{
ui->spinBoxXStartValue->setEnabled(false);
ui->spinBoxXRepeatTimeValue->setEnabled(false);
ui->spinBoxXGapValue->setEnabled(false);
}
ui->spinBoxXStartValue->setValue (sysPara->para.alterPrint.startValue );
ui->spinBoxXGapValue->setValue (sysPara->para.alterPrint.repeatValue);
ui->spinBoxXRepeatTimeValue->setValue (sysPara->para.alterPrint.repeatPrintTimes);
ui->spinBoxDistanceTail->setValue(sysPara->para.alterPrint.DistanceTail );
ui->checkBoxCnt1NatureValue->setChecked ( sysPara->para.Cnt1NatureValue); //
ui->checkBoxSpeedOver->setChecked(sysPara->para.speedoverPaushPrint);
ui->checkSynCntEn->setChecked(sysPara->para.SynCntEn);
ui->checkVol1of8En->setChecked(sysPara->para.Vol1of8En);
ui->checkBoxEleEyeRetrigDis->setChecked( sysPara->para.eleEyeReTrigDisable );
ui->checkmode0211->setChecked(sysPara->para.mode0211);
ui->resetToCnt1InitValueCheckBox->setChecked(sysPara->para.cnt1ResetToInitValue);
qDebug()<<"checkmode0211:"<<sysPara->para.mode0211;
qDebug()<<"checkVol1of8En:"<<sysPara->para.Vol1of8En;
qDebug()<<"radioButtonFUllColFIxVal:"<<sysPara->para.FullColFixVal;
qDebug()<<"checkBoxCharWidthSet:"<<sysPara->para.charWidthSetEnable;
//ui->checkBoxPrintOnce->setChecked(sysPara->para.printOnce);
//ui->checkBoxNumPoint->setChecked(sysPara->para.printNumPoint);
ui->checkBoxReciclar->setChecked(sysPara->para.Reciclar);
ui->dacScaledSpinBox->setValue(sysPara->para.dacScale);
ui->checkBoxResetSendData->setChecked(sysPara->para.ResetSendData);
ui->spinBoxJumpStartValue->setValue( sysPara->para.stepPrint.startValue );
ui->spinBoxJumpEndValue->setValue( sysPara->para.stepPrint.endValue );
//ui->checkBoxStepPrintEn->setEnabled( sysPara->para.stepPrint.enbale );
ui->checkBoxStepPrintEn->setChecked( sysPara->para.stepPrint.enbale );
ui->spinBoxJumpStepValue->setValue(sysPara->para.stepPrint.StepValue);
ui->checkProductResetEn->setChecked(sysPara->para.ResetProductCntEn);
ui->checkAllProductResetEn->setChecked(sysPara->para.ResetAllProductCntEn);
ui->checkHVFaultCloseEn->setChecked(sysPara->para.HVFaultCloseEn);
// 电眼触发计数器动作 选择
ui->eleCNT1IncEn->setChecked( (sysPara->para.eleEyeClearCntInSynMode & 0x10)?1:0);
ui->radCNT1ResetEn->setChecked( (sysPara->para.eleEyeClearCntInSynMode & 0x10)?0:1);
ui->eleCNT2IncEn->setChecked( (sysPara->para.eleEyeClearCntInSynMode & 0x20)?1:0);
ui->radCNT2ResetEn->setChecked( (sysPara->para.eleEyeClearCntInSynMode & 0x20)?0:1);
ui->eleCNT3IncEn->setChecked( (sysPara->para.eleEyeClearCntInSynMode & 0x40)?1:0);
ui->radCNT3ResetEn->setChecked( (sysPara->para.eleEyeClearCntInSynMode & 0x40)?0:1);
ui->checkBoxCharWidthSet->setChecked(sysPara->para.charWidthSetEnable);
ui->checkBoxMagnet->setChecked(sysPara->para.isCheckMagnet);
ui->printfLightCheckBox->setChecked(sysPara->para.isCheckPrintLight);
ui->phaseHighCntSpinBox->setValue( sysPara->para.phaseHighCnt);
sysPara->para.bcOption.var1Num=ui->spinBoxCnt1EndValue->text().length();
sysPara->para.bcOption.var2Num=ui->spinBoxCnt2EndValue->text().length();
ui->checkBox_FastMode->setChecked(sysPara->para.flagOfFastMode);
ui->labMac->setText(QString(" Mac:%1").arg(dlgInputAddr->jd.addr));
sysPara->status.machineMac = dlgInputAddr->jd.addr;
showMachInfo(QString::number(dlgInputAddr->jd.addr));
ui->CBDateFormat1->setCurrentIndex(sysPara->para.ExpirySplitMode);//p_var->splitMode
ui->spinBoxExpiryDate->setValue(sysPara->para.ExpiryDay);
//on_spinBoxExpiryDate_valueChanged(sysPara->print.ExpiryVar.);
ui->checkBoxSaveCNTStateValue->setCheckState(sysPara->para.isCntSaveStateValue ? Qt::Checked : Qt::Unchecked);
flagOfModuleDecimal = sysPara->para.flagOfModuleDecimal;
ModuleDecimalDisplay();
flagOfModuleHide = sysPara->para.flagOfModuleHide;
ModuleHideDisplay();
displayForAdjustVoltage(sysPara->para.flagOfAdjustVoltage);
LoadCnt1GroupSettingsToUI();
if(sysPara->para.mode0211 || sysPara->para.FullColFixVal)
{
ui->spinBoxStartVoltage->setEnabled(false);
ui->spinBoxEndVoltage->setEnabled(false);
}
if(sysPara->para.flagOfCnt1GroupDisp)
{
//edit@12-03
const int indexTab=ui->tabWidget_2->indexOf(ui->tab_9);
if(-1==indexTab)
ui->tabWidget_2->addTab(ui->tab_9,tr("其他设置"));
}
if(sysPara->para.flagOfstepPrint)
{
//edit@12-03
const int indexTab=ui->tabWidget->indexOf(ui->tab_6);
if(-1==indexTab)
ui->tabWidget->addTab(ui->tab_6,tr("跳米设置"));
}
*/
TriggerupdateSysParaToUI();
}
@@ -595,7 +169,7 @@ void PrintSetting::TriggerupdateSysParaToUI(){
//ui->spinBoxOutputPulseDelayMs->setEnabled(sysPara->para.pulseOutputEnable);
ui->spinBoxOutputPulseDelayMs->setEnabled(true /*sysPara->para.outputPulseDelayMs*/);
ui->spinBoxOutputPulseDelayMs->setEnabled(isPulseEenable);
ui->spinBoxOuputPulseCol->setValue(sysPara->para.OuputPulseCol);
ui->checkEyeTriggerSynPrintEn->setChecked (sysPara->para.eleEyeTriggerSynPrintEn);
ui->comboBoxSyncActType->setCurrentIndex (sysPara->para.synchronizorActType);
@@ -658,7 +232,13 @@ void PrintSetting::applyUITriggerPara(){
sysPara->para.pulseOutputEnable = ui->checkBoxPulseOutputEnable->isChecked();
sysPara->para.productCntPerOutputPulse = ui->spinBoxProductCntPerOutputPulse->value();
// 有脉冲延时使能的时候才可以设置延时
if (isEnabled()) {
sysPara->para.outputPulseDelayMs = ui->spinBoxOutputPulseDelayMs->value();
} else {
sysPara->para.outputPulseDelayMs = 0;
}
sysPara->para.OuputPulseCol = ui->spinBoxOuputPulseCol->value();
if(((ui->checkEyeTriggerSynPrintEn->checkState()==1 )
&&(sysPara->para.printTriggerMode == PRINT_TRIGGER_ELEC_EYE_VOLTATE_LEVEL || sysPara->para.printTriggerMode == PRINT_TRIGGER_ELEC_EYE_EDGE))
@@ -803,7 +383,7 @@ void PrintSetting::on_checkEyeTriggerSynPrintEn_clicked(bool checked)
ui->spinBoxEleEyeTriggerIntervalMs->setEnabled(0);
ui->labelEleEyeTriggerPrintDelay->setText(tr("触发延时(毫米)"));
ui->labelEleEyeTriggerIntervalMs->setText(tr("重复间隔(毫米)"));
ui->labelEleMaskTime->setText(tr("封锁间隔(毫米)"));
ui->labelEleMaskTime->setText(tr("抑止距离(毫米)"));
ui->labelOutputPulseDelayMs->setText(tr("延时(毫米):"));
if(ui->comboBoxSyncActType->currentIndex() || 0b11) //如果不是在正反转打印的模式下,就切换到正反转模式
{
@@ -830,7 +410,7 @@ void PrintSetting::on_checkEyeTriggerSynPrintEn_clicked(bool checked)
ui->spinBoxEleEyeTriggerIntervalMs->setEnabled(1);
ui->labelEleEyeTriggerPrintDelay->setText(tr("触发延时(毫秒)"));
ui->labelEleEyeTriggerIntervalMs->setText(tr("重复间隔(毫秒)"));
ui->labelEleMaskTime->setText(tr("封锁间隔(毫秒)"));
ui->labelEleMaskTime->setText(tr("抑止距离(毫秒)"));
ui->labelOutputPulseDelayMs->setText( ui->radioButtonSynTrigger->isChecked()?tr("延时(毫米):"):tr("延时(毫秒):"));
}
@@ -882,7 +462,7 @@ void PrintSetting::setTriggerUI(int triggerMode){
ui->labelEleEyeTriggerPrintDelay->setText(tr("触发延时(毫米)"));
ui->labelEleEyeTriggerIntervalMs->setText(tr("重复间隔(毫米)"));
ui->labelEleMaskTime->setText(tr("封锁间隔(毫米)"));
ui->labelEleMaskTime->setText(tr("抑止距离(毫米)"));
}
else
{
@@ -899,9 +479,7 @@ void PrintSetting::setTriggerUI(int triggerMode){
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("触发延时(毫米)"));
@@ -963,65 +541,39 @@ void PrintSetting::setSynPrintMode(int mode){
void PrintSetting::applyStyleSheet()
{
QString styleSheet = R"(
QString styleSheet =
R"(
QTabWidget {
border: none;
background-color: #7B838E;
}
QTabWidget::tab-bar {
background-color: #7B838E;
alignment: left;
height: 80px;
margin: 0;
}
QTabBar {
background-color: #7B838E;
border: none;
width: 100%;
min-width: 100%;
height: 80px;
padding: 0;
QTabBar::tab:focus {
outline: none;
}
QTabBar::tab {
width: 140px;
height: 80px;
font-size: 16px;
font-weight: bold;
color: #000000;
border: none;
border-top-left-radius: 10px;
border-top-right-radius: 10px;
alignment: center bottom;
padding-top: 0;
}
QTabBar::tab {
margin-left: 10px;
margin-top: 10px;
}
QTabBar::tab:!selected {
background: qlineargradient(x1:0, y1:0, x2:0, y2:1,
stop:0 #6E757F, stop:1 #96A0A9);
border: 2px solid #63535D;
min-width: 90px;
min-height: 45px;
padding: 4px 10px;
margin-right: 4px;
border: 1px solid #dddddd;
border-bottom: none;
position: relative;
bottom: 0px;
border-top-left-radius: 4px;
border-top-right-radius: 4px;
background-color: #5396C1;
color: #ffffff;
}
QTabBar::tab:selected {
background: qlineargradient(x1:0, y1:0, x2:0, y2:1,
stop:0 #95B2D4, stop:1 #F0F0F0);
border: none;
position: relative;
bottom: 0px;
background-color: #6bb1e0;
color: #ffffff;
box-shadow: 0 -3px 8px rgba(44, 125, 232, 0.25);
}
QTabWidget::pane {
border: none;
background-color: #f0f0f0;
top: -12px;
QTabWidget::tab-bar {
top: -3px;
left: 10px;
}
QWidget#buttonWidget {
@@ -1094,9 +646,6 @@ void PrintSetting::applyStyleSheet()
}
)";
// closeBtn->setObjectName("closeBtn");
// buttonWidget->setObjectName("buttonWidget");
this->setStyleSheet(styleSheet);
}
@@ -1186,3 +735,9 @@ void PrintSetting::on_radioButtonEleEyeLevelTrigger_clicked()
sysPara->para.printTriggerMode = PRINT_TRIGGER_ELEC_EYE_VOLTATE_LEVEL;
}
void PrintSetting::on_checkBoxPulseOutputEnable_clicked(bool checked)
{
isPulseEenable = checked;
ui->spinBoxOutputPulseDelayMs->setEnabled(checked);
}
+4
View File
@@ -73,11 +73,15 @@ private slots:
void on_radioButtonSynTriggerExternal_clicked();
void on_checkBoxPulseOutputEnable_clicked(bool checked);
private:
Ui::PrintSetting *ui;
PulseNumFix *pulseNumFix;
bool isPulseEenable = false;
void init();
void applyStyleSheet(); // 应用样式表
+81 -89
View File
@@ -26,7 +26,7 @@
<enum>Qt::StrongFocus</enum>
</property>
<property name="currentIndex">
<number>2</number>
<number>0</number>
</property>
<widget class="QWidget" name="tab">
<attribute name="title">
@@ -35,8 +35,8 @@
<widget class="QLabel" name="label_9">
<property name="geometry">
<rect>
<x>210</x>
<y>30</y>
<x>220</x>
<y>90</y>
<width>122</width>
<height>25</height>
</rect>
@@ -57,8 +57,8 @@
<widget class="QSpinBox" name="spinBoxHighVoltageValue">
<property name="geometry">
<rect>
<x>340</x>
<y>20</y>
<x>350</x>
<y>80</y>
<width>121</width>
<height>37</height>
</rect>
@@ -82,8 +82,8 @@
<widget class="QLabel" name="label_3">
<property name="geometry">
<rect>
<x>210</x>
<y>80</y>
<x>220</x>
<y>160</y>
<width>121</width>
<height>25</height>
</rect>
@@ -104,8 +104,8 @@
<widget class="QSpinBox" name="spinBoxColDelay">
<property name="geometry">
<rect>
<x>340</x>
<y>70</y>
<x>350</x>
<y>150</y>
<width>122</width>
<height>37</height>
</rect>
@@ -123,8 +123,8 @@
<widget class="QLabel" name="label_38">
<property name="geometry">
<rect>
<x>149</x>
<y>120</y>
<x>160</x>
<y>230</y>
<width>181</width>
<height>37</height>
</rect>
@@ -139,9 +139,9 @@
<widget class="QComboBox" name="comboBox_selcetVolPara">
<property name="geometry">
<rect>
<x>340</x>
<y>120</y>
<width>185</width>
<x>351</x>
<y>230</y>
<width>220</width>
<height>37</height>
</rect>
</property>
@@ -158,80 +158,15 @@
</item>
<item>
<property name="text">
<string>5行5点阵</string>
<string>32点阵对5点阵的优化</string>
</property>
</item>
<item>
<property name="text">
<string>4行7点阵</string>
<string>32点阵对4点阵的优化</string>
</property>
</item>
</widget>
<widget class="QWidget" name="layoutWidget">
<property name="geometry">
<rect>
<x>240</x>
<y>199</y>
<width>231</width>
<height>131</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QCheckBox" name="checkBoxUpDownInverse">
<property name="minimumSize">
<size>
<width>0</width>
<height>37</height>
</size>
</property>
<property name="layoutDirection">
<enum>Qt::RightToLeft</enum>
</property>
<property name="text">
<string>信息上下颠倒</string>
</property>
<property name="icon">
<iconset resource="image.qrc">
<normaloff>:/icon/updown.png</normaloff>:/icon/updown.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBoxLeftRightInverse">
<property name="minimumSize">
<size>
<width>0</width>
<height>37</height>
</size>
</property>
<property name="layoutDirection">
<enum>Qt::RightToLeft</enum>
</property>
<property name="text">
<string>信息左右颠倒</string>
</property>
<property name="icon">
<iconset resource="image.qrc">
<normaloff>:/icon/leftright.png</normaloff>:/icon/leftright.png</iconset>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
<widget class="QWidget" name="tab_3">
<attribute name="title">
@@ -737,7 +672,7 @@ border-radius: 5px;</string>
<x>40</x>
<y>50</y>
<width>431</width>
<height>171</height>
<height>211</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_5">
@@ -925,7 +860,7 @@ border-radius: 5px;</string>
<property name="geometry">
<rect>
<x>540</x>
<y>20</y>
<y>30</y>
<width>171</width>
<height>111</height>
</rect>
@@ -963,8 +898,8 @@ border-radius: 5px;</string>
<widget class="QGroupBox" name="groupBox_2">
<property name="geometry">
<rect>
<x>560</x>
<y>130</y>
<x>530</x>
<y>150</y>
<width>191</width>
<height>131</height>
</rect>
@@ -1052,8 +987,8 @@ border-radius: 5px;</string>
<widget class="QGroupBox" name="groupBox_3">
<property name="geometry">
<rect>
<x>380</x>
<y>310</y>
<x>300</x>
<y>270</y>
<width>171</width>
<height>80</height>
</rect>
@@ -1103,8 +1038,8 @@ border-radius: 5px;</string>
<widget class="QWidget" name="layoutWidget">
<property name="geometry">
<rect>
<x>50</x>
<y>330</y>
<x>60</x>
<y>300</y>
<width>231</width>
<height>41</height>
</rect>
@@ -1472,6 +1407,63 @@ QRadioButton {
</widget>
</widget>
</widget>
<widget class="QWidget" name="other">
<attribute name="title">
<string>其他设置</string>
</attribute>
<widget class="QCheckBox" name="checkBoxUpDownInverse">
<property name="geometry">
<rect>
<x>320</x>
<y>120</y>
<width>135</width>
<height>37</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>37</height>
</size>
</property>
<property name="layoutDirection">
<enum>Qt::RightToLeft</enum>
</property>
<property name="text">
<string>信息上下颠倒</string>
</property>
<property name="icon">
<iconset resource="image.qrc">
<normaloff>:/icon/updown.png</normaloff>:/icon/updown.png</iconset>
</property>
</widget>
<widget class="QCheckBox" name="checkBoxLeftRightInverse">
<property name="geometry">
<rect>
<x>320</x>
<y>220</y>
<width>135</width>
<height>37</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>37</height>
</size>
</property>
<property name="layoutDirection">
<enum>Qt::RightToLeft</enum>
</property>
<property name="text">
<string>信息左右颠倒</string>
</property>
<property name="icon">
<iconset resource="image.qrc">
<normaloff>:/icon/leftright.png</normaloff>:/icon/leftright.png</iconset>
</property>
</widget>
</widget>
</widget>
<widget class="QPushButton" name="closeBtn">
<property name="geometry">
+3 -1
View File
@@ -163,6 +163,7 @@ HEADERS += Public.h \
Log/logger.h \
Log/logmessage.h \
Log/logglobal.h \
loginfoctrl.h
FORMS += \
@@ -314,7 +315,8 @@ SOURCES +=\
scene/piccodeitem.cpp \
Log/filelogger.cpp \
Log/logger.cpp \
Log/logmessage.cpp
Log/logmessage.cpp \
loginfoctrl.cpp
-29
View File
@@ -1218,35 +1218,6 @@ void SystemManage::on_pushButtonAutoClean_pressed()
}*/
}
void SystemManage::on_pushButtonFontToUdisk_pressed()
{
//
QMessageBox::StandardButton ret;
ret = QMessageBox::information(this, tr("警告"),
tr("是否确认导出字库到U盘?"),
QMessageBox::Ok | QMessageBox::Cancel);
if (ret == QMessageBox::Ok)
{
QFile file("/udisk");
if(!file.exists()){
QMessageBox::warning(this, tr("错误"),
tr("U盘不可识别!"));
return;
}
system((char *)((QString("cp /usr/local/Trolltech/QtEmbedded-4.6.3-arm/lib/fonts/* /udisk/.")).toLatin1().data()));
system((char *)((QString("cp /usr/lib/fonts/* /udisk/.")).toLatin1().data()));//am335x
system((char *)((QString("cp /usr/lib/fonts/* /udisk/.")).toLatin1().data()));
system((char *)((QString("mkdir /udisk/zk")).toLatin1().data()));
// system((char *)((QString("cp /opt/zk/* /udisk/zk/ ")).toLatin1().data()));
QMessageBox::information(this, tr("提示"),
tr("字库导出完成!"));
//emit configChanged();
}
}
void SystemManage::on_pushButtonMotorTest_pressed()
{
QMessageBox::StandardButton ret;
-2
View File
@@ -91,8 +91,6 @@ private slots:
/***2019/10/23 */
//void on_pushButtonAutoClean_clicked();
void on_pushButtonFontToUdisk_pressed();
void on_pushButtonMotorTest_pressed();
void on_pushButtonPushAir_pressed();
+3 -26
View File
@@ -39,7 +39,7 @@
<property name="geometry">
<rect>
<x>680</x>
<y>530</y>
<y>492</y>
<width>100</width>
<height>41</height>
</rect>
@@ -77,13 +77,13 @@
</size>
</property>
</widget>
<widget class="QWidget" name="">
<widget class="QWidget" name="layoutWidget">
<property name="geometry">
<rect>
<x>9</x>
<y>9</y>
<width>750</width>
<height>502</height>
<height>471</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
@@ -620,29 +620,6 @@
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QPushButton" name="pushButtonFontToUdisk">
<property name="minimumSize">
<size>
<width>0</width>
<height>60</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>200</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>导出字库</string>
</property>
<property name="icon">
<iconset resource="image.qrc">
<normaloff>:/icon/udisk.png</normaloff>:/icon/udisk.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButtonAutoClean">
<property name="enabled">
+42 -73
View File
@@ -47,6 +47,12 @@ SystemSetting::SystemSetting(QWidget *parent) :
dialogUpateMm =new DialogAuthorization;
connect(dialogUpateMm,SIGNAL(accepted()),this,SLOT(ondialogAuthorizationAccepted()));
if (ctrl_loginfo == nullptr) {
ctrl_loginfo = LogInfoCtrl::instance();
connect(ctrl_loginfo, &LogInfoCtrl::sig_clean,
this, &SystemSetting::on_pushButtonCleanUP_pressed);
}
init();
ui->label->hide();
@@ -89,6 +95,20 @@ void SystemSetting::buttonClickedSlot()
}
}
void SystemSetting::lockUI()
{
ui->checkBtn->setEnabled(false);
ui->closeBtn->setEnabled(false);
ui->pushButtonHighVoltageData->setEnabled(false);
}
void SystemSetting::unlockUI()
{
ui->checkBtn->setEnabled(true);
ui->closeBtn->setEnabled(true);
ui->pushButtonHighVoltageData->setEnabled(true);
}
void SystemSetting::SystemupdateSysParaToUI(){
updateSysParaToUI();
@@ -237,6 +257,8 @@ void SystemSetting::updateSysStatusToUI(){
enCleanUpAppendFlag=5;
//sysPara->devOp->controlReclaimTankClose(1);
//ui->label_status->setText(tr("正在关回收槽......"));
if(ctrl_loginfo) ctrl_loginfo->emitSigCleanOver(false);
unlockUI();
}
else if(sysPara->status.currReclaimTankPos ==0 && (enCleanUpAppendFlag==5 ||enCleanUpAppendFlag==4)) //?
{
@@ -248,10 +270,6 @@ void SystemSetting::updateSysStatusToUI(){
enCleanUpAppendFlag=0;
}
}
else
{
}
}
}
@@ -294,10 +312,14 @@ void SystemSetting::on_pushButtonCleanUP_pressed()
enCleanUpAppendFlag=1;// 开始启动手动模式
sysPara->devOp->mainInkCtrl();
if (ctrl_loginfo) ctrl_loginfo->emitSigCleanOver(true);
lockUI();
timer2->start(2000); // 暂时循环一下2s
}
else if (msgBox.clickedButton() == cancleCleanButton) {
enCleanUpAppendFlag=3;
if (ctrl_loginfo) ctrl_loginfo->emitSigCleanOver(false);
unlockUI();
timerHandler2();
return ;
}
@@ -352,7 +374,6 @@ void SystemSetting::timerHandler2(){
}
else if(enCleanUpAppendFlag==3){// 清洗完成
enCleanUpAppendFlag=4;
// emit setRunStatus(tr("清洗完成"));
sysPara->devOp->controlCycleValve(false);
sysPara->devOp->controlViscosityPump(false);
sysPara->devOp->controlReclaimTankClose(1);
@@ -365,6 +386,9 @@ void SystemSetting::timerHandler2(){
}
else if(enCleanUpAppendFlag==4){
emit setRunStatus(tr("清洗完成"));
if (ctrl_loginfo) ctrl_loginfo->emitSigCleanOver(false);
unlockUI();
if(sysPara->status.currReclaimTankPos==0){
enCleanUpAppendFlag=0;
if(timer2->isActive()) timer2->stop();
@@ -697,75 +721,20 @@ void SystemSetting::on_spinBoxOscillatorVoltage_valueChanged(int arg1)
}
#include "Public.h"
void SystemSetting::on_pushButtonInterFace_pressed()
{
QString s1 = Public::ReadLanguageName();
if(s1 =="English") {
dlgLanguage.LangIndex =INPUT_METHOD_TYPE_ENGLISH;
}
else if(s1 =="Korean") {
dlgLanguage.LangIndex =INPUT_METHOD_TYPE_KOREAN;
}
else{
dlgLanguage.LangIndex =INPUT_METHOD_TYPE_CHINESE;
}
dlgLanguage.setCurrentLanguage();
dlgLanguage.show();
/*
QFile file(SYS_ROOT_DIR"UseEn");
QMessageBox::StandardButton ret;
ret = QMessageBox::information(this, tr("警告"),
tr("确定要切换显示语言吗?\r\n(重启才能生效)"),
QMessageBox::Ok | QMessageBox::Cancel);
if (ret != QMessageBox::Ok){
return;
}
QString s1 = Public::ReadLanguageName();
if(file.open(QIODevice::ReadWrite| QIODevice::Truncate)) {
QByteArray buf;
buf.clear();
if(s1 =="English") {// English--> Vietnamese
QMessageBox::information(this,tr("提示"),tr("重启后切换到越南语界面"));
buf.append("Vietnamese\r\n");
buf.append("YN_utf8.txt\r\n");
}
else if(s1 =="Vietnamese") {// Vietnamese--> Chinese
QMessageBox::information(this,tr("提示"),tr("重启后切换到中文界面"));
buf.append("Chinese\r\n");
buf.append("WINPY_utf8.txt\r\n");
}
else{// Chinese--> English
QMessageBox::information(this,tr("提示"),tr("重启后切换到英文界面"));
buf.append("English\r\n");
buf.append("WINPY_utf8.txt\r\n");
}
file.write(buf);
file.close();
setInterfaceMode();
}
*/
}
void SystemSetting::setInterfaceMode()
{
QString s1 = Public::ReadLanguageName();
if(s1 =="English") {// English--> Vietnamese
ui->pushButtonInterFace->setText( tr("Tiếng Việt(Vietnamese interface)"));
}
else if(s1 =="Vietnamese") {// Vietnamese--> Chinese
ui->pushButtonInterFace->setText( tr("Chinese interface(中文界面)"));
}
else{// Chinese--> English
ui->pushButtonInterFace->setText( tr("English interface(英文界面)"));
}
}
//void SystemSetting::setInterfaceMode()
//{
// QString s1 = Public::ReadLanguageName();
// if(s1 =="English") {// English--> Vietnamese
// ui->pushButtonInterFace->setText( tr("Tiếng Việt(Vietnamese interface)"));
// }
// else if(s1 =="Vietnamese") {// Vietnamese--> Chinese
// ui->pushButtonInterFace->setText( tr("Chinese interface(中文界面)"));
// }
// else{// Chinese--> English
// ui->pushButtonInterFace->setText( tr("English interface(英文界面)"));
// }
//}
void SystemSetting::applyStyleSheet()
{
+7 -3
View File
@@ -9,6 +9,7 @@
#include "DialogAuthorization.h"
#include "dlgmutilanguage.h"
#include <iostream>
#include "loginfoctrl.h"
namespace Ui {
class SystemSetting;
}
@@ -40,7 +41,7 @@ Q_SIGNALS:
void setRunStatus(QString);
void pressureAdjust();
private slots:
void setInterfaceMode();
// void setInterfaceMode();
void SystemupdateSysParaToUI();
void on_spinBoxReclaimPumpPower_valueChanged(int arg1);
@@ -50,7 +51,6 @@ private slots:
void timerHandler();
void on_spinBoxOscillatorVoltage_valueChanged(int arg1);
void on_pushButtonInterFace_pressed();
void ondialogAuthorizationAccepted();
void onCleanUPNow();
void timerHandler2();
@@ -63,11 +63,15 @@ signals:
private:
Ui::SystemSetting *ui;
DlgMutiLanguage dlgLanguage;
QTimer *timer,*timer2, *SetinkcloseCountTimer, *timerAuto;
unsigned char enCleanUpAppendFlag; // 0空闲,1关开回收槽,2手动,3清洗,4恢复,5停止,6
bool r_PumpValveControledByHand;
DialogAuthorization *dialogUpateMm;
LogInfoCtrl *ctrl_loginfo = nullptr;
// 清洗中,界面锁死
void lockUI();
void unlockUI();
};
#endif // SSYSTEMSETTING_H
+49
View File
@@ -1,6 +1,9 @@
#include "SystemUpdate.h"
#include "ui_SystemUpdate.h"
#include "SystemManage.h"
#include "Public.h"
#include "InputMethod.h"
#include <QMessageBox>
SystemUpdate::SystemUpdate(QWidget *parent) :
QWidget(parent),
@@ -17,6 +20,11 @@ SystemUpdate::~SystemUpdate()
delete ui;
}
void SystemUpdate::bindSysPara(SysPara *sysPara)
{
dlgLanguage.bindSysPara(sysPara);
}
/*关闭按键*/
void SystemUpdate::on_closeBtn_clicked()
{
@@ -92,3 +100,44 @@ void SystemUpdate::on_pushButtonUpdateCharLib_clicked()
emit sendUpDateChARLIBSignal();
}
void SystemUpdate::on_pushButtonFontToUdisk_clicked()
{
QMessageBox::StandardButton ret;
ret = QMessageBox::information(this, tr("警告"),
tr("是否确认导出字库到U盘?"),
QMessageBox::Ok | QMessageBox::Cancel);
if (ret == QMessageBox::Ok)
{
QFile file("/udisk");
if(!file.exists()){
QMessageBox::warning(this, tr("错误"),
tr("U盘不可识别!"));
return;
}
system((char *)((QString("cp /usr/local/Trolltech/QtEmbedded-4.6.3-arm/lib/fonts/* /udisk/.")).toLatin1().data()));
system((char *)((QString("cp /usr/lib/fonts/* /udisk/.")).toLatin1().data()));//am335x
system((char *)((QString("cp /usr/lib/fonts/* /udisk/.")).toLatin1().data()));
system((char *)((QString("mkdir /udisk/zk")).toLatin1().data()));
QMessageBox::information(this, tr("提示"),
tr("字库导出完成!"));
}
}
void SystemUpdate::on_pushButtonInterFace_clicked()
{
QString s1 = Public::ReadLanguageName();
if(s1 =="English") {
dlgLanguage.LangIndex =INPUT_METHOD_TYPE_ENGLISH;
}
else if(s1 =="Korean") {
dlgLanguage.LangIndex =INPUT_METHOD_TYPE_KOREAN;
}
else{
dlgLanguage.LangIndex =INPUT_METHOD_TYPE_CHINESE;
}
dlgLanguage.setCurrentLanguage();
dlgLanguage.show();
}
+8
View File
@@ -6,6 +6,8 @@
#define UPDATESOFT 3
#define UPDATECHARLIB 4
#include "dlgmutilanguage.h"
#include <QWidget>
namespace Ui {
@@ -20,10 +22,14 @@ public:
explicit SystemUpdate(QWidget *parent = 0);
~SystemUpdate();
void bindSysPara(SysPara *sysPara);
private:
Ui::SystemUpdate *ui;
void applyStyleSheet(); // 应用样式表
DlgMutiLanguage dlgLanguage;
signals:
void sendButtonClickedSignal(int index);
@@ -38,6 +44,8 @@ private slots:
void on_pushButtonUpdateSoftware_clicked();
void on_pushButtonUpdateCharLib_clicked();
void on_closeBtn_clicked();
void on_pushButtonFontToUdisk_clicked();
void on_pushButtonInterFace_clicked();
};
#endif // SYSTEMUPDATE_H
+57 -20
View File
@@ -38,23 +38,21 @@
</size>
</property>
</widget>
<widget class="QWidget" name="verticalLayoutWidget">
<widget class="QWidget" name="">
<property name="geometry">
<rect>
<x>100</x>
<y>130</y>
<width>601</width>
<height>268</height>
<x>80</x>
<y>190</y>
<width>614</width>
<height>128</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QPushButton" name="pushButtonProgramFPGA">
<property name="minimumSize">
<size>
<width>0</width>
<width>200</width>
<height>60</height>
</size>
</property>
@@ -69,11 +67,11 @@
</property>
</widget>
</item>
<item>
<item row="0" column="1">
<widget class="QPushButton" name="pushButtonUpdateSoftware">
<property name="minimumSize">
<size>
<width>0</width>
<width>200</width>
<height>60</height>
</size>
</property>
@@ -92,15 +90,33 @@
</property>
</widget>
</item>
</layout>
<item row="0" column="2">
<widget class="QPushButton" name="pushButtonInterFace">
<property name="enabled">
<bool>true</bool>
</property>
<property name="minimumSize">
<size>
<width>200</width>
<height>60</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>200</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>界面语言设置</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<item row="1" column="0">
<widget class="QPushButton" name="pushButtonProgramStm32">
<property name="minimumSize">
<size>
<width>0</width>
<width>200</width>
<height>60</height>
</size>
</property>
@@ -115,11 +131,11 @@
</property>
</widget>
</item>
<item>
<item row="1" column="1">
<widget class="QPushButton" name="pushButtonUpdateCharLib">
<property name="minimumSize">
<size>
<width>0</width>
<width>200</width>
<height>60</height>
</size>
</property>
@@ -138,7 +154,28 @@
</property>
</widget>
</item>
</layout>
<item row="1" column="2">
<widget class="QPushButton" name="pushButtonFontToUdisk">
<property name="minimumSize">
<size>
<width>200</width>
<height>60</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>200</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>导出字库</string>
</property>
<property name="icon">
<iconset resource="image.qrc">
<normaloff>:/icon/udisk.png</normaloff>:/icon/udisk.png</iconset>
</property>
</widget>
</item>
</layout>
</widget>
+992 -1179
View File
File diff suppressed because it is too large Load Diff
+1 -98
View File
@@ -14,104 +14,7 @@
<string>Form</string>
</property>
<property name="styleSheet">
<string notr="true">QPushButton#closeBtn, QPushButton#checkBtn{
background-color: #E6F7FF;
border: 1px solid #87CEEB;
border-radius: 4px;
font-size: 24px;
color: #228B22;
}
QPushButton#closeBtn:hover,QPushButton#checkBtn:hover{
background-color: #D1E9FF;
}
QPushButton#closeBtn:pressed,QPushButton#checkBtn:pressed{
background-color: #BAE7FF;
}
QPushButton {
background-color: #5396C1;
color: #ffffff;
border: 1px solid #000000;
border-radius: 3px;
font-size: 18px;
font-weight:500;
width: 180px;
height: 90px;
}
QPushButton:hover {
background-color: #5396C1;
}
QPushButton:disabled {
background-color: #7C828E;
color: #606060;
border-color: #808080;
}
QComboBox {
border: 1px solid #000000;
border-radius: 3px;
font-size: 14px;
width: 180px;
height: 90px;
padding-left: 10px; /* 文字左边距,避免紧贴边缘 */
}
/* 下拉箭头区域 */
QComboBox::drop-down {
border: 1px solid #333333;
border-radius: 3px;
width: 30px; /* 箭头区域宽度 */
background-color: #5396C1;
}
/* 下拉箭头图标 */
QComboBox::down-arrow {
image: url(image/down_white.png);
width: 16px; /* 图标显示宽度 */
height: 16px; /* 图标显示高度 */
}
/* 悬停状态 */
QComboBox:hover {
background-color: #efefef;
}
// 下拉框
QComboBox QAbstractItemView {
border: 1px solid #000000;
border-radius: 3px;
font-size: 14px;
selection-background-color: #5396C1; /* 选中项背景色(稍深) */
selection-color: #ffffff;
}
QSpinBox::up-button {
width: 16px; /* 图标显示宽度 */
height: 16px; /* 图标显示高度 */
border: 1px solid #333333;
border-radius: 3px;
background-color: #5396C1;
}
QSpinBox::up-arrow {
image: url(image/up_white.png);
}
QSpinBox::down-button {
width: 16px; /* 图标显示宽度 */
height: 16px; /* 图标显示高度 */
border: 1px solid #333333;
border-radius: 3px;
background-color: #5396C1;
}
QSpinBox::down-arrow {
image: url(image/down_white.png);
}
</string>
<string notr="true"/>
</property>
<widget class="QTabWidget" name="tabWidget">
<property name="geometry">
+3 -76
View File
@@ -14,80 +14,7 @@
<string>Form</string>
</property>
<property name="styleSheet">
<string notr="true">QPushButton#closeBtn, QPushButton#checkBtn{
background-color: #E6F7FF;
border: 1px solid #87CEEB;
border-radius: 4px;
font-size: 24px;
color: #228B22;
}
QPushButton#closeBtn:hover,QPushButton#checkBtn:hover{
background-color: #D1E9FF;
}
QPushButton#closeBtn:pressed,QPushButton#checkBtn:pressed{
background-color: #BAE7FF;
}
QPushButton {
background-color: #5396C1;
color: #ffffff;
border: 1px solid #000000;
border-radius: 3px;
font-size: 18px;
font-weight:500;
width: 180px;
height: 90px;
}
QPushButton:hover {
background-color: #5396C1;
}
QPushButton:disabled {
background-color: #7C828E;
color: #606060;
border-color: #808080;
}
QComboBox {
border: 1px solid #000000;
border-radius: 3px;
font-size: 14px;
width: 180px;
height: 90px;
padding-left: 10px; /* 文字左边距,避免紧贴边缘 */
}
/* 下拉箭头区域 */
QComboBox::drop-down {
border: 1px solid #333333;
border-radius: 3px;
width: 30px; /* 箭头区域宽度 */
background-color: #5396C1;
}
/* 下拉箭头图标 */
QComboBox::down-arrow {
image: url(image/down_white.png);
width: 16px; /* 图标显示宽度 */
height: 16px; /* 图标显示高度 */
}
/* 悬停状态 */
QComboBox:hover {
background-color: #efefef;
}
// 下拉框
QComboBox QAbstractItemView {
border: 1px solid #000000;
border-radius: 3px;
font-size: 14px;
selection-background-color: #5396C1; /* 选中项背景色(稍深) */
selection-color: #ffffff;
}
</string>
<string notr="true"/>
</property>
<widget class="QPushButton" name="checkBtn">
<property name="geometry">
@@ -123,8 +50,8 @@ QComboBox QAbstractItemView {
<rect>
<x>20</x>
<y>10</y>
<width>781</width>
<height>461</height>
<width>771</width>
<height>472</height>
</rect>
</property>
<property name="focusPolicy">
+1 -1
View File
@@ -633,7 +633,7 @@ void dlgQrCode::setCntCheckBoxHide(bool hideEn){
}
}
void dlgQrCode::setSysPara(SysPara * sysPara)
void dlgQrCode::bindSysPara(SysPara * sysPara)
{
this->sysPara = sysPara;
}
+1 -1
View File
@@ -39,7 +39,7 @@ public:
void setCntCheckBoxHide(bool hideEn);
QString getCounterText( int counter,int QRCntNum);
void MatrixEnCode(unsigned char *intext,int Size);
void setSysPara(SysPara * sysPara);
void bindSysPara(SysPara * sysPara);
void bindTxTEdit(QTextEdit *textEdit);
public slots:
+23
View File
@@ -2,6 +2,8 @@
#include "ui_dlgmutilanguage.h"
#include "InputMethod.h"
#include <QFile>
#include <QMessageBox>
#include <QTime>
#include <unistd.h>
DlgMutiLanguage::DlgMutiLanguage(QWidget *parent) :
@@ -117,4 +119,25 @@ void DlgMutiLanguage::SetNewLanguage(){
file.close();
}
// 提示重启
QMessageBox::StandardButton ret = QMessageBox::information(this, tr("提示"),
tr("是否重启?"),
QMessageBox::Ok);
if (ret == QMessageBox::Ok) {
sysPara->saveParaToFile(); // 关机前将相关配置保存
sysPara->saveRFIDPara();
mySleep(200);
system("sync");//缓存同步
QCoreApplication::quit();
}
}
void DlgMutiLanguage::mySleep(unsigned int msec)
{
QTime dieTime = QTime::currentTime().addMSecs(msec);
while( QTime::currentTime() < dieTime )
QCoreApplication::processEvents(QEventLoop::AllEvents, 100);
}
+5 -1
View File
@@ -1,13 +1,16 @@
#ifndef DLGMUTILANGUAGE_H
#define DLGMUTILANGUAGE_H
#include "ParaSettingUI.h"
#include "SysPara.h"
#include <QDialog>
namespace Ui {
class DlgMutiLanguage;
}
class DlgMutiLanguage : public QDialog
class DlgMutiLanguage : public QDialog,public ParaSettingUI
{
Q_OBJECT
@@ -23,6 +26,7 @@ public slots:
private:
Ui::DlgMutiLanguage *ui;
void mySleep(unsigned int msec);
};
#endif // DLGMUTILANGUAGE_H
+1
View File
@@ -0,0 +1 @@
## [InkJetPrinter](../InkJetPrinter.h)
+992 -1179
View File
File diff suppressed because it is too large Load Diff
+992 -1179
View File
File diff suppressed because it is too large Load Diff
+45
View File
@@ -14,6 +14,8 @@ FileManageWidget::FileManageWidget(QWidget *parent) :
{
ui->setupUi(this);
applyStyleSheet();
// 安装事件过滤器用于判断当前焦点位于系统文件列表还是U盘文件列表,高亮获得焦点的列表
ui->systemFileListView->installEventFilter(this);
ui->udiskFileListView->installEventFilter(this);
@@ -202,3 +204,46 @@ void FileManageWidget::copyFiles(QListWidget *from, QListWidget *to)
qInfo() << "Command: " << cmd << ", result: " << ret;
}
}
void FileManageWidget::applyStyleSheet()
{
QString styleSheet = R"(
QPushButton#closeBtn {
background-color: #E6F7FF;
border: 1px solid #87CEEB;
border-radius: 4px;
font-size: 24px;
color: #228B22;
}
QPushButton#closeBtn:hover{
background-color: #D1E9FF;
}
QPushButton#closeBtn:pressed{
background-color: #BAE7FF;
}
QPushButton {
background-color: #5396C1;
color: #ffffff;
border: 1px solid #000000;
border-radius: 3px;
font-size: 18px;
width: 100px;
height: 50px;
}
QPushButton:hover {
background-color: #5396C1;
}
QPushButton:disabled {
background-color: #7C828E;
color: #606060;
border-color: #808080;
}
)";
this->setStyleSheet(styleSheet);
}
+2
View File
@@ -48,6 +48,8 @@ private:
// 用于文件显示列表中,存放每个文件名对应的绝对路径所用的数据键
static constexpr int AbsPathRole = Qt::UserRole + 1;
void applyStyleSheet(); // 应用样式表
};
#endif // FILEMANAGEWIDGET_H
+7 -1
View File
@@ -6,9 +6,15 @@
<rect>
<x>0</x>
<y>0</y>
<width>786</width>
<height>498</height>
</rect>
</property>
<property name="maximumSize">
<size>
<width>800</width>
<height>600</height>
</rect>
</size>
</property>
<property name="windowTitle">
<string>Form</string>
+1116 -970
View File
File diff suppressed because it is too large Load Diff
+359 -211
View File
@@ -30,7 +30,10 @@
<number>0</number>
</property>
<item row="0" column="0">
<layout class="QVBoxLayout" name="verticalLayout">
<layout class="QVBoxLayout" name="verticalLayout" stretch="0">
<property name="spacing">
<number>9</number>
</property>
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="minimumSize">
@@ -47,6 +50,9 @@
<string>当前状态</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_5">
<property name="topMargin">
<number>15</number>
</property>
<item row="0" column="0">
<widget class="QTextEdit" name="textEditRunStatus">
<property name="enabled">
@@ -147,6 +153,9 @@
<string>历史状态</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_4">
<property name="topMargin">
<number>15</number>
</property>
<item row="0" column="0">
<widget class="QTextEdit" name="textEditRunStatus_2">
<property name="enabled">
@@ -204,7 +213,13 @@
<property name="minimumSize">
<size>
<width>0</width>
<height>70</height>
<height>60</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>60</height>
</size>
</property>
<property name="text">
@@ -217,7 +232,13 @@
<property name="minimumSize">
<size>
<width>0</width>
<height>70</height>
<height>60</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>60</height>
</size>
</property>
<property name="text">
@@ -230,7 +251,13 @@
<property name="minimumSize">
<size>
<width>0</width>
<height>70</height>
<height>60</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>60</height>
</size>
</property>
<property name="text">
@@ -263,7 +290,13 @@
<property name="minimumSize">
<size>
<width>100</width>
<height>70</height>
<height>60</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>60</height>
</size>
</property>
<property name="text">
@@ -280,12 +313,21 @@
<string>版本信息</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_6">
<property name="topMargin">
<number>15</number>
</property>
<item row="1" column="1">
<widget class="QPushButton" name="closeBtn3">
<property name="minimumSize">
<size>
<width>100</width>
<height>70</height>
<height>60</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>60</height>
</size>
</property>
<property name="text">
@@ -362,216 +404,31 @@
<attribute name="title">
<string>机器状态</string>
</attribute>
<widget class="QWidget" name="layoutWidget_2">
<property name="geometry">
<rect>
<x>150</x>
<y>180</y>
<width>381</width>
<height>81</height>
</rect>
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="spacing">
<number>30</number>
</property>
<layout class="QGridLayout" name="gridLayout_7" columnstretch="0,0,0,0">
<property name="topMargin">
<number>0</number>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="verticalSpacing">
<number>4</number>
</property>
<item row="1" column="0">
<widget class="QLabel" name="label_10">
<property name="maximumSize">
<property name="sizeHint" stdset="0">
<size>
<width>150</width>
<height>20</height>
<width>20</width>
<height>29</height>
</size>
</property>
<property name="text">
<string>粘度</string>
</property>
</widget>
</spacer>
</item>
<item row="1" column="2">
<widget class="QLabel" name="label_OscVolName">
<property name="maximumSize">
<size>
<width>150</width>
<height>20</height>
</size>
<item>
<layout class="QGridLayout" name="gl_state">
<property name="leftMargin">
<number>30</number>
</property>
<property name="text">
<string>高压包</string>
<property name="rightMargin">
<number>30</number>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="labViso">
<property name="minimumSize">
<size>
<width>88</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>20</height>
</size>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QLabel" name="label_11">
<property name="maximumSize">
<size>
<width>150</width>
<height>20</height>
</size>
</property>
<property name="text">
<string>隔膜位置</string>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QLabel" name="labPosition">
<property name="minimumSize">
<size>
<width>88</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>64</width>
<height>20</height>
</size>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="QLabel" name="labOscVol">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>70</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>20</height>
</size>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="2" column="0" colspan="2">
<widget class="QLabel" name="labelFpgaVersionNum">
<property name="minimumSize">
<size>
<width>110</width>
<height>20</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>500</width>
<height>16777215</height>
</size>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="labPress">
<property name="minimumSize">
<size>
<width>88</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>20</height>
</size>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_9">
<property name="maximumSize">
<size>
<width>150</width>
<height>20</height>
</size>
</property>
<property name="text">
<string>压力</string>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QLabel" name="label_size">
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QPushButton" name="closeBtn4">
<property name="geometry">
<rect>
<x>630</x>
<y>360</y>
<width>100</width>
<height>70</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>100</width>
<height>70</height>
</size>
</property>
<property name="text">
<string>✕</string>
</property>
</widget>
<widget class="QWidget" name="">
<property name="geometry">
<rect>
<x>20</x>
<y>60</y>
<width>751</width>
<height>96</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_8">
<item row="0" column="0">
<widget class="ClickLabel" name="labelStatusInkSwint">
<property name="minimumSize">
@@ -752,13 +609,13 @@
<widget class="ClickLabel" name="labelFaultResume">
<property name="minimumSize">
<size>
<width>0</width>
<height>60</height>
<width>70</width>
<height>70</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>60</width>
<width>70</width>
<height>16777215</height>
</size>
</property>
@@ -1764,7 +1621,298 @@
</widget>
</item>
</layout>
</item>
<item>
<layout class="QGridLayout" name="gridLayout_7" columnstretch="0,0,0,0,0">
<property name="leftMargin">
<number>30</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="verticalSpacing">
<number>4</number>
</property>
<item row="2" column="0" colspan="2">
<widget class="QLabel" name="labelFpgaVersionNum">
<property name="minimumSize">
<size>
<width>110</width>
<height>20</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>500</width>
<height>16777215</height>
</size>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_10">
<property name="maximumSize">
<size>
<width>150</width>
<height>20</height>
</size>
</property>
<property name="text">
<string>粘度</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QLabel" name="label_OscVolName">
<property name="maximumSize">
<size>
<width>150</width>
<height>20</height>
</size>
</property>
<property name="text">
<string>高压包</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_9">
<property name="maximumSize">
<size>
<width>150</width>
<height>20</height>
</size>
</property>
<property name="text">
<string>压力</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="labPress">
<property name="minimumSize">
<size>
<width>88</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>20</height>
</size>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QLabel" name="label_size">
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QLabel" name="labPosition">
<property name="minimumSize">
<size>
<width>88</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>64</width>
<height>20</height>
</size>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="labViso">
<property name="minimumSize">
<size>
<width>88</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>20</height>
</size>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QLabel" name="label_11">
<property name="maximumSize">
<size>
<width>150</width>
<height>20</height>
</size>
</property>
<property name="text">
<string>隔膜位置</string>
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="QLabel" name="labOscVol">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>70</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>20</height>
</size>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="1" column="4">
<spacer name="horizontalSpacer_5">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="leftMargin">
<number>30</number>
</property>
<item>
<widget class="QPushButton" name="btn_clean">
<property name="minimumSize">
<size>
<width>150</width>
<height>50</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>150</width>
<height>50</height>
</size>
</property>
<property name="text">
<string>喷嘴逆清洗</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lb_clean">
<property name="minimumSize">
<size>
<width>200</width>
<height>50</height>
</size>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_6">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>30</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="closeBtn4">
<property name="minimumSize">
<size>
<width>100</width>
<height>60</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>60</height>
</size>
</property>
<property name="text">
<string>✕</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</widget>
</item>
+21
View File
@@ -0,0 +1,21 @@
#include "loginfoctrl.h"
void LogInfoCtrl::emitSigClean()
{
emit sig_clean();
}
void LogInfoCtrl::emitSigCleanOver(bool flag)
{
emit sig_cleanOver(flag);
}
void LogInfoCtrl::emitSigShow()
{
emit sig_show();
}
LogInfoCtrl::LogInfoCtrl()
{
}
+29
View File
@@ -0,0 +1,29 @@
#ifndef LOGINFOCTRL_H
#define LOGINFOCTRL_H
#include <QObject>
class LogInfoCtrl : public QObject
{
Q_OBJECT
public:
static LogInfoCtrl* instance() {
static LogInfoCtrl ins;
return &ins;
}
void emitSigClean();
void emitSigCleanOver(bool flag);
void emitSigShow();
private:
LogInfoCtrl();
signals:
void sig_clean();
void sig_cleanOver(bool flag);
void sig_show();
};
#endif // LOGINFOCTRL_H
+194 -77
View File
@@ -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,10 +1444,10 @@ 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,只显示场景内的部分
QRectF intersectRect = itemRect.intersected(sceneRect);
@@ -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"(
ui.m_StartBtn->setStyleSheet(
R"(
QPushButton {
background-color: #27ae60;
background-color: #1e8449;
color: black;
border-radius: 5px;
}
QPushButton:disabled {
background-color: #bdc3c7;
color: #7f8c8d;
background-color: #bdc3c7; /* 灰色背景 */
color: #7f8c8d; /* 灰色文字 */
border: 1px solid #95a5a6; /* 灰色边框 */
}
)");
ui.m_StopBtn->setStyleSheet(R"(
ui.m_StopBtn->setStyleSheet(
R"(
QPushButton {
background-color: #e74c3c;
color: black;
border-radius: 5px;
}
QPushButton:disabled {
background-color: #bdc3c7;
color: #7f8c8d;
background-color: #bdc3c7; /* 灰色背景 */
color: #7f8c8d; /* 灰色文字 */
border: 1px solid #95a5a6; /* 灰色边框 */
}
)");
// 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,10 +3473,17 @@ bool MainWidget::eventFilter(QObject *watched, QEvent *event)
if (watched == ui.sub3 || watched == ui.labelProductCnt) {
if (m_setNumDlg) {
m_setNumDlg->show();
}
}
return true;
}
}
}
if (event->type() == QEvent::MouseButtonDblClick) {
if (watched == ui.fra_state || ui.lb_generalState) {
LogInfoCtrl::instance()->emitSigShow();
return true;
}
}
return false;
}
+11 -1
View File
@@ -82,6 +82,14 @@ public:
int getCurrPrintStatus();
void updateSysStatusToUI(); //重载
//Mainwindow获取机器总状态
DevStatusLightType m_stateColor = DEV_STATUS_GREEN;
//DEV_STATUS_GREEN:正常
QString m_stateStr = "正常";
bool checkRed(AlarmStatus &status);
bool checkYellow(AlarmStatus &status);
void updateGeneralState(AlarmStatus status);
void updateTotalCnt(int en);
int calculateMaxSpeed(int backup);
@@ -95,7 +103,6 @@ public:
void RefreshStatusLight();
bool updatePhaseIndicatorLight();
void updateGeneralState(DevStatusLightType type, QString stateStr);
bool flagOfClearHighVltageWarnning;
@@ -151,6 +158,9 @@ private:
void reclaimTanOpen();
void initSheet();
// 高亮切换
void changeHighLight(bool isStart);
private slots:
void airPushingProcess();
void buttonClickedSlot();
Binary file not shown.

Before

Width:  |  Height:  |  Size: 696 B

+225 -3
View File
@@ -5,6 +5,7 @@
#include "CounterEditor.h"
#include <QDebug>
#include <QKeyEvent>
#include "DlgQrcodeFormat.h"
// 使用SysPara的相关参数构造CounterEditorVM
CounterEditorVM makeCounterVM(SysPara* sysPara, COUNTER_TYPE type, int digitalNum)
@@ -53,6 +54,8 @@ BarcodeEditor::BarcodeEditor(QWidget *parent) :
m_vm.dateViewModel = DateItemModel::createDefaultReplaceModel();
m_dateReplaceEditor->setDateModel(m_vm.dateViewModel);
connect(ui->cbBoxType, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &BarcodeEditor::onTypeChanged);
connect(&m_barcodeFormatEditor, &DlgBarcodeFormat::accepted, this, &BarcodeEditor::onBarcodeFormatConfirmed);
connect(&m_qrcodeFormatEditor, &DlgQrcodeFormat::accepted, this, &BarcodeEditor::onQrcodeFormatConfirmed);
}
@@ -86,6 +89,21 @@ void BarcodeEditor::bindViewModel(const BarcodeViewModel& vm)
{
m_vm = vm;
// 通用设置视图模型
auto b = ui->widGeneralSettings->blockSignals(true);
ui->widGeneralSettings->setViewModel(vm.generalSettingsVM);
ui->widGeneralSettings->blockSignals(b);
// 内容模版
b = ui->lineEditContent->blockSignals(true);
ui->lineEditContent->setText(m_vm.contentPattern);
ui->lineEditContent->blockSignals(b);
// 类型选择框
b = ui->cbBoxType->blockSignals(true);
ui->cbBoxType->setCurrentIndex(m_vm.type);
ui->cbBoxType->blockSignals(b);
// 缺失的代替表用默认值补齐
DateItemModel& dateVm = m_vm.dateViewModel;
if (dateVm.dataMap.isEmpty() || dateVm.daysMap.isEmpty() || dateVm.monthsMap.isEmpty()
@@ -154,8 +172,15 @@ void BarcodeEditor::bindViewModel(const BarcodeViewModel& vm)
BarcodeViewModel BarcodeEditor::viewModel()
{
m_vm.contentPattern = ui->lineEditContent->text();
m_vm.type = (BarcodeType) (ui->cbBoxType->currentIndex());
// 从子编辑器拉取最新值回写到 m_vm
// 通用设置
m_vm.generalSettingsVM = ui->widGeneralSettings->viewModel();
// 日期设置,如果存在 {t} 变量
if(m_vm.contentPattern.contains("{t}")) {
DateFormatEditorVM fmt = m_dateFormatEditor->viewModel();
m_vm.dateViewModel.datetimePattern = fmt.pattern;
@@ -182,6 +207,7 @@ BarcodeViewModel BarcodeEditor::viewModel()
m_vm.dateViewModel.hoursMap = rep.hoursMap;
}
// 计数器设置,如果存在 {c} 变量
if(m_vm.contentPattern.contains("{c}")) {
CounterEditorVM cnt = m_counterEditor->viewModel();
m_vm.counterViewModel.counterType = cnt.counterType;
@@ -191,6 +217,58 @@ BarcodeViewModel BarcodeEditor::viewModel()
return m_vm;
}
void BarcodeEditor::restoreViewModel()
{
m_vm.generalSettingsVM = ItemGeneralSettingsVM();
m_vm.contentPattern = "";
m_vm.counterViewModel = CounterViewModel();
m_vm.dateViewModel = DateItemModel::createDefaultReplaceModel();
m_vm.type = BARCODE_TYPE_BARCODE;
m_vm.format.setValue(DlgBarcodeFormatVM());
bindViewModel(m_vm);
}
/**
* @brief 逻辑基本类似 CounterVarSet::applyUIPara
*
*/
void BarcodeEditor::applyCounterConfigToSysPara()
{
if(!m_vm.contentPattern.contains("{c}"))
return;
CounterEditorVM cnt = m_counterEditor->viewModel();
if(cnt.counterType == COUNTER_TYPE_1) {
m_sysPara->para.cnt1StartValue = cnt.counter1.startValue;
m_sysPara->para.cnt1EndValue = cnt.counter1.endValue;
m_sysPara->para.cnt1RepeateValue = cnt.counter1.repeatValue;
m_sysPara->para.cnt1StepValue = cnt.counter1.stepValue;
m_sysPara->para.cnt1CurrValue = cnt.counter1.currValue;
m_sysPara->status.cnt1CurrentValueInitDoneFlag = !cnt.counter1.editCurrValue;
if(cnt.counter1.eleEyeIncEn)
m_sysPara->para.eleEyeClearCntInSynMode = (m_sysPara->para.eleEyeClearCntInSynMode | 0x10); // CNT1 +1
else
m_sysPara->para.eleEyeClearCntInSynMode = (m_sysPara->para.eleEyeClearCntInSynMode & 0xef); // CNT1 = current
}
else if(cnt.counterType == COUNTER_TYPE_2) {
m_sysPara->para.cnt2StartValue = cnt.counter2.startValue;
m_sysPara->para.cnt2EndValue = cnt.counter2.endValue;
m_sysPara->para.cnt2RepeateValue = cnt.counter2.repeatValue;
m_sysPara->para.cnt2StepValue = cnt.counter2.stepValue;
m_sysPara->para.cnt2CurrValue = cnt.counter2.currValue;
m_sysPara->status.cnt2CurrentValueInitDoneFlag = !cnt.counter2.editCurrValue;
if(cnt.counter2.eleEyeIncEn)
m_sysPara->para.eleEyeClearCntInSynMode = (m_sysPara->para.eleEyeClearCntInSynMode | 0x20); // CNT2 +1
else
m_sysPara->para.eleEyeClearCntInSynMode = (m_sysPara->para.eleEyeClearCntInSynMode & 0xdf); // CNT2 = current
}
m_sysPara->devOp->writeFpgaCalandar(0);
}
void BarcodeEditor::onBtnFormatClicked()
{
if(m_vm.type == BARCODE_TYPE_BARCODE) {
@@ -228,12 +306,15 @@ void BarcodeEditor::onBtnCounterClicked()
void BarcodeEditor::onCheckBtnClicked()
{
m_vm = viewModel();
applyCounterConfigToSysPara();
emit accepted();
hide();
}
void BarcodeEditor::onCloseBtnClicked()
{
emit rejected();
hide();
}
void BarcodeEditor::onBarcodeFormatConfirmed()
@@ -256,6 +337,19 @@ void BarcodeEditor::onQrcodeFormatConfirmed()
ui->cbBoxType->blockSignals(b);
}
void BarcodeEditor::onTypeChanged(int i)
{
if(m_vm.type == i)
return;
m_vm.type = (BarcodeType)(i);
if(m_vm.type == BARCODE_TYPE_BARCODE) {
m_vm.format.setValue(DlgBarcodeFormatVM());
}
else
m_vm.format.setValue(DlgQrcodeFormatVM());
}
bool BarcodeEditor::eventFilter(QObject *obj, QEvent *event)
{
if(obj == ui->lineEditContent) {
@@ -269,9 +363,17 @@ bool BarcodeEditor::eventFilter(QObject *obj, QEvent *event)
}
// 碰到 {t} 或 {c},直接删除
QString varText = text.mid(cursor - 3, 3);
if(varText == "{t}" || varText == "{c}") {
ui->lineEditContent->setText(text.remove(cursor - 3, 3));
auto datePatternPos = text.indexOf("{t}");
auto counterPatternPos = text.indexOf("{c}");
if(datePatternPos >= 0 || counterPatternPos >= 0) {
if(datePatternPos < cursor && cursor <= datePatternPos + 3) {
ui->lineEditContent->setText(text.remove(datePatternPos, 3));
return true;
}
else if(counterPatternPos < cursor && cursor <= counterPatternPos + 3) {
ui->lineEditContent->setText(text.remove(counterPatternPos, 3));
return true;
}
}
}
}
@@ -342,3 +444,123 @@ void BarcodeEditor::onContentChanged(QString content)
m_vm.contentPattern = content;
}
void BarcodeViewModel::saveToXml(const BarcodeViewModel &vm, QXmlStreamAttributes &attrs)
{
attrs.append("barcodeContentPattern", vm.contentPattern);
attrs.append("barcodeType", QString::number(int(vm.type)));
if(vm.type == BARCODE_TYPE_BARCODE) {
DlgBarcodeFormatVM barcodeFormat = vm.format.value<DlgBarcodeFormatVM>();
attrs.append("barcodeFormat", barcodeFormat.type);
attrs.append("barcodeHeight", QString::number(barcodeFormat.height));
attrs.append("barcodeWidth", QString::number(barcodeFormat.width));
attrs.append("barcodeScale", QString::number(barcodeFormat.scale));
attrs.append("barcodeInkType", QString::number(int(barcodeFormat.inkType)));
attrs.append("barcodeTxtVisible", barcodeFormat.txtVisible ? "true" : "false");
}
else {
DlgQrcodeFormatVM qrcodeFormat = vm.format.value<DlgQrcodeFormatVM>();
attrs.append("qrcodeFormat", QString::number(qrcodeFormat.type));
attrs.append("qrcodeSize", QString::number(qrcodeFormat.size));
attrs.append("qrcodeLevel", QString::number(int(qrcodeFormat.level)));
attrs.append("qrcodeInkType", QString::number(int(qrcodeFormat.inkType)));
}
if(vm.contentPattern.contains("{t}")) {
DateItemModel::saveToXml(vm.dateViewModel, attrs);
}
if(vm.contentPattern.contains("{c}")) {
attrs.append("counterType", QString::number(vm.counterViewModel.counterType));
attrs.append("counterDigitalNum", QString::number(vm.counterViewModel.digitalNum));
}
}
BarcodeViewModel BarcodeViewModel::loadFromXml(const QXmlStreamAttributes &attrs)
{
BarcodeViewModel vm;
vm.contentPattern = attrs.value("barcodeContentPattern").toString();
vm.type = static_cast<BarcodeType>(attrs.value("barcodeType").toInt());
if(vm.type == BARCODE_TYPE_BARCODE) {
DlgBarcodeFormatVM barcodeFormat;
barcodeFormat.type = attrs.value("barcodeFormat").toString();
barcodeFormat.height = attrs.value("barcodeHeight").toInt();
barcodeFormat.width = attrs.value("barcodeWidth").toInt();
barcodeFormat.scale = attrs.value("barcodeScale").toInt();
barcodeFormat.inkType = static_cast<InkType>(attrs.value("barcodeInkType").toInt());
barcodeFormat.txtVisible = attrs.value("barcodeTxtVisible").toString() == "true";
vm.format.setValue(barcodeFormat);
}
else {
DlgQrcodeFormatVM qrcodeFormat;
qrcodeFormat.type = static_cast<QRCodeType>(attrs.value("qrcodeFormat").toInt());
qrcodeFormat.size = static_cast<QRCodeSize>(attrs.value("qrcodeSize").toInt());
qrcodeFormat.level = static_cast<QRCodeLevel>(attrs.value("qrcodeLevel").toInt());
qrcodeFormat.inkType = static_cast<InkType>(attrs.value("qrcodeInkType").toInt());
vm.format.setValue(qrcodeFormat);
}
if(vm.contentPattern.contains("{t}")) {
DateItemModel::loadFromXml(vm.dateViewModel, attrs);
}
if(vm.contentPattern.contains("{c}")) {
vm.counterViewModel.counterType = static_cast<COUNTER_TYPE>(attrs.value("counterType").toInt());
vm.counterViewModel.digitalNum = attrs.value("counterDigitalNum").toInt();
}
return vm;
}
QString BarcodeViewModel::toString(const BarcodeViewModel &vm)
{
QString str;
str += QString("type: %1\r\n").arg(int(vm.type));
str += QString("contentPattern: \"%1\"\r\n").arg(vm.contentPattern);
// counterViewModel
str += QString("counterViewModel: \r\n");
str += QString("\t counter type: %1\r\n").arg(vm.counterViewModel.counterType);
str += QString("\t digital number: %1\r\n").arg(vm.counterViewModel.digitalNum);
str += QString("\t letter space: %1\r\n").arg(vm.counterViewModel.letterSpace);
// dateViewModel
str += QString("dateViewModel: \r\n");
str += QString("\t pattern: \"%1\"\r\n").arg(vm.dateViewModel.datetimePattern);
int expirationValue = 0;
int expirationType = 0;
if(vm.dateViewModel.daysOffset > 0) {
expirationValue = vm.dateViewModel.daysOffset;
expirationType = EXPIRATION_TYPE_DAY;
}
else if(vm.dateViewModel.monthsOffset > 0) {
expirationValue = vm.dateViewModel.monthsOffset;
expirationType = EXPIRATION_TYPE_MONTH;
}
str += QString("\t expirationValue: %1\r\n").arg(expirationValue);
str += QString("\t expirationType: %1\r\n").arg(expirationType);
// format
str += QString("format: \n");
if(vm.type == BARCODE_TYPE_BARCODE) {
DlgBarcodeFormatVM barcodeFormat = vm.format.value<DlgBarcodeFormatVM>();
str += QString("\t type: \"%1\"\r\n").arg(barcodeFormat.type);
str += QString("\t height: %1\r\n").arg(barcodeFormat.height);
str += QString("\t width: %1\r\n").arg(barcodeFormat.width);
str += QString("\t scale: %1\r\n").arg(barcodeFormat.scale);
str += QString("\t inkType: %1\r\n").arg(int(barcodeFormat.inkType));
str += QString("\t txtVisible: %1\r\n").arg(barcodeFormat.txtVisible ? "true" : "false");
}
else {
DlgQrcodeFormatVM qrcodeFormat = vm.format.value<DlgQrcodeFormatVM>();
str += QString("\t type: %1\r\n").arg(int(qrcodeFormat.type));
str += QString("\t size: %1\r\n").arg(int(qrcodeFormat.size));
str += QString("\t level: %1\r\n").arg(int(qrcodeFormat.level));
str += QString("\t inkType: %1\r\n").arg(int(qrcodeFormat.inkType));
}
return str;
}
+55 -2
View File
@@ -8,6 +8,7 @@
#include "dlgQrcodeFormat.h"
#include "DlgBarcodeFormat.h"
#include <QVariant>
#include "ItemGeneralSettings.h"
class DateFormatEditor;
class DateReplaceEditor;
@@ -25,11 +26,57 @@ enum BarcodeType {
* 仅当 contentPattern 含有相应变量时,counterViewModel / dateViewModel 字段才有意义。
*/
struct BarcodeViewModel {
ItemGeneralSettingsVM generalSettingsVM; // 通用设置视图模型
QString contentPattern; // 条形码内容模版,例如 "ABC{t}{c1}"
CounterViewModel counterViewModel; // 计数器视图模型
DateItemModel dateViewModel; // 日期视图模型
BarcodeType type = BARCODE_TYPE_BARCODE;
QVariant format;
BarcodeType type = BARCODE_TYPE_BARCODE; // 条形码 或 二维码
QVariant format; // 条形码/二维码 格式设置,如果是条形码,则实际类型为 DlgBarcodeFormatVM,如果是二维码,则实际类型为 DlgQrcodeFormatVM
std::function<QImage()> imageGenerator; // 条形码/二维码 图片生成函数
/**
* @brief 将vm保存到xml属性集
*
* @param vm 条码视图模型
* @param attrs xml属性集
*/
static void saveToXml(const BarcodeViewModel& vm, QXmlStreamAttributes& attrs);
/**
* @brief 从xml属性集加载条码视图模型
*
* @param attrs xml属性集
* @return BarcodeViewModel 条码视图模型
*/
static BarcodeViewModel loadFromXml(const QXmlStreamAttributes& attrs);
/**
* @brief
*
* @param vm 条码视图模型
* @return QString 字符串表示
*
* @example
* type: 0
* contentPattern: ABC{t}{c1}
* counterViewModel:
* \t counter type: 7
* \t digital number: 2
* \t letter space: 2
* dateViewModel:
* \t pattern: "yyyy-MM-dd HH:mm:ss"
* \t expirationValue: 0
* \t expirationType: 0
* format:
* \t type: "BARCODE_128"
* \t height: 9
* \t width: 36
* \t scale: 1
* \t inkType: 0
* \t txtVisible: false
*/
static QString toString(const BarcodeViewModel& vm);
};
Q_DECLARE_METATYPE(BarcodeViewModel);
@@ -75,6 +122,10 @@ public:
*/
BarcodeViewModel viewModel();
void restoreViewModel();
void applyCounterConfigToSysPara();
private slots:
/**
@@ -126,6 +177,8 @@ private slots:
*/
void onQrcodeFormatConfirmed();
void onTypeChanged(int i);
protected:
virtual bool eventFilter(QObject* obj, QEvent* event) override;
+20 -2
View File
@@ -126,9 +126,15 @@ QSpinBox::down-arrow {
<x>520</x>
<y>540</y>
<width>101</width>
<height>50</height>
<height>40</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>100</width>
<height>40</height>
</size>
</property>
<property name="text">
<string>✓</string>
</property>
@@ -139,9 +145,21 @@ QSpinBox::down-arrow {
<x>640</x>
<y>540</y>
<width>101</width>
<height>50</height>
<height>40</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>100</width>
<height>40</height>
</size>
</property>
<property name="text">
<string>✕</string>
</property>
+1 -10
View File
@@ -257,15 +257,6 @@
</property>
</widget>
</widget>
<tabstops>
<tabstop>BarCodeType</tabstop>
<tabstop>comboBoxInkColor</tabstop>
<tabstop>BarCodeHeigh</tabstop>
<tabstop>BarCodeDot</tabstop>
<tabstop>BarCodeScale</tabstop>
<tabstop>checkBoxAddText</tabstop>
<tabstop>checkBtn</tabstop>
</tabstops>
<resources/>
<connections>
<connection>
@@ -280,7 +271,7 @@
</hint>
<hint type="destinationlabel">
<x>417</x>
<y>379</y>
<y>460</y>
</hint>
</hints>
</connection>
+1
View File
@@ -6,6 +6,7 @@ DlgQrcodeFormat::DlgQrcodeFormat(QWidget *parent) :
ui(new Ui::DlgQrcodeFormat)
{
ui->setupUi(this);
setViewModel(m_vm);
}
DlgQrcodeFormat::~DlgQrcodeFormat()
+1 -1
View File
@@ -31,7 +31,7 @@ enum QRCodeSize {
};
struct DlgQrcodeFormatVM {
QRCodeType type = QR_CODE_TYPE_DATA_MATRIX;
QRCodeType type = QR_CODE_TYPE_QRCODE;
QRCodeLevel level = QR_CODE_LEVEL_L;
QRCodeSize size = QR_CODE_SIZE_DEFAULT;
InkType inkType = INK_TYPE_BLACK;
+452 -2
View File
@@ -1,4 +1,312 @@
#include "ItemCommon.h"
#include "DlgQrcodeFormat.h"
#include "DlgBarcodeFormat.h"
#include <QtQREnCode/qrencode.h>
#include "Matrix/dm200.h"
#include "BarCode/barcode.h"
#include <QPainter>
#include <cstring>
/**
* @brief 将libqrencode的QRcode结构渲染成QImage
*
* 避免依赖文件系统或PostScript输出,直接在内存中生成可用于UI显示或打印的图像。
* 使用2D像素数组而非向量,支持任意缩放因子。
*/
static QImage renderQRCode(const QRcode *qrcode, int moduleSize = 4, QRgb foreground = 0xff000000, QRgb background = 0xffffffff)
{
if (!qrcode || qrcode->width <= 0) {
return QImage();
}
int margin = 1;
int imageSize = (qrcode->width + margin * 2) * moduleSize;
QImage image(imageSize, imageSize, QImage::Format_ARGB32);
image.fill(background);
const unsigned char *data = qrcode->data;
for (int y = 0; y < qrcode->width; ++y) {
for (int x = 0; x < qrcode->width; ++x) {
bool moduleOn = (data[y * qrcode->width + x] & 0x01) != 0;
QRgb color = moduleOn ? foreground : background;
int px = (margin + x) * moduleSize;
int py = (margin + y) * moduleSize;
for (int dy = 0; dy < moduleSize; ++dy) {
for (int dx = 0; dx < moduleSize; ++dx) {
image.setPixel(px + dx, py + dy, color);
}
}
}
}
return image;
}
/**
* @brief 将DataMatrix位图网格渲染成QImage
*
* iec16022ecc200返回原始位数组,需转换为可视化图像以供UI或打印使用。
* 与renderQRCode采用相同的像素化策略,确保两种编码方式的输出一致性。
*/
static QImage renderDataMatrix(const unsigned char *grid, int cols, int rows, int moduleSize = 1, QRgb foreground = 0xff000000, QRgb background = 0xffffffff)
{
if (!grid || cols <= 0 || rows <= 0) {
return QImage();
}
int width = cols * moduleSize;
int height = rows * moduleSize;
QImage image(width, height, QImage::Format_ARGB32);
image.fill(background);
for (int y = 0; y < rows; ++y) {
for (int x = 0; x < cols; ++x) {
bool bit = (grid[y * cols + x] & 0x01) != 0;
QRgb color = bit ? foreground : background;
int px = x * moduleSize;
int py = y * moduleSize;
for (int dy = 0; dy < moduleSize; ++dy) {
for (int dx = 0; dx < moduleSize; ++dx) {
image.setPixel(px + dx, py + dy, color);
}
}
}
}
return image;
}
static QRecLevel qrCodeLevelFromEnum(QRCodeLevel level)
{
switch (level) {
case QR_CODE_LEVEL_M: return QR_ECLEVEL_M;
case QR_CODE_LEVEL_Q: return QR_ECLEVEL_Q;
case QR_CODE_LEVEL_H: return QR_ECLEVEL_H;
default: return QR_ECLEVEL_L;
}
}
/**
* @brief 根据格式配置生成二维码或DataMatrix图像
*
* 支持两种编码方式:
* - DataMatrix:适合小容量数据和有限空间环境(如工业标签)
* - QR Code:高容量、高可靠性,广泛应用于商业和物流
*
* 直接在内存中渲染,避免对dlgQrCode或外部库的依赖。
* 颜色反转机制(INK_TYPE_WHITE)用于支持黑底白码的特殊打印场景。
*/
static QImage generateQRCodeImage(const QString &content, const DlgQrcodeFormatVM &vm)
{
if (content.isEmpty()) {
return QImage();
}
QRecLevel level = qrCodeLevelFromEnum(vm.level);
// 适配黑底白码场景(逆色):打印机某些模式下需要反转前景/背景色
QRgb foreground = vm.inkType == INK_TYPE_WHITE ? 0x00ffffff : 0xff000000;
QRgb background = vm.inkType == INK_TYPE_WHITE ? 0xff000000 : 0x00ffffff;
QByteArray bytes = content.toUtf8();
// DataMatrix:调用者指定尺寸约束(sizeType),库返回实际分配的网格
if (vm.type == QR_CODE_TYPE_DATA_MATRIX) {
short cols = 0;
short rows = 0;
short sizeType = static_cast<short>(vm.size);
// iec16022ecc200会根据sizeType调整输出尺寸,支持灵活的条码宽高比
unsigned char *grid = iec16022ecc200(&cols, &rows, reinterpret_cast<unsigned char *>(bytes.data()), &sizeType);
if (!grid || cols <= 0 || rows <= 0) {
if (grid) {
free(grid);
}
return QImage();
}
QImage image = renderDataMatrix(grid, cols, rows, 1, foreground, background);
free(grid);
return image;
}
// QR Code:版本0表示自动选择版本(1-40),确保内容总是被编码
QRcode *qrcode = QRcode_encodeString(bytes.constData(), 0, level, QR_MODE_8, 1);
if (!qrcode) {
return QImage();
}
QImage image = renderQRCode(qrcode, 1, foreground, background);
QRcode_free(qrcode);
return image;
}
/**
* @brief 将Barcode_Item的编码数据(partial)渲染成QImage
*
* partial字段存储压缩的条形码宽度数据(高4位=空白宽度,低3位=黑条宽度),
* 需展开为像素数组。barWidth参数控制每个模块的物理宽度(用于放大)。
*
* 这种直接渲染方式避免了PostScript生成和文件I/O的开销。
*/
static QImage renderBarcodeImage(const Barcode_Item *bc, int barHeight = 12, int barWidth = 1, QRgb foreground = 0xff000000, QRgb background = 0xffffffff)
{
if (!bc || !bc->partial) {
return QImage();
}
// 约束:barHeight和barWidth必须为正值。默认值支持小尺寸标签的视觉清晰度
if (barHeight <= 0) {
barHeight = 12;
}
if (barWidth <= 0) {
barWidth = 1;
}
// xoffset=8提供左边距(4像素),用于对齐打印布局和改善美观度
int xoffset = 8;
int len = static_cast<int>(strlen(bc->partial));
// 计算条形码总宽度:每字节的低4位表示条纹宽度单位数之和
int bcWidth1 = 0;
for (int i = 0; i < len; ++i) {
bcWidth1 += (bc->partial[i] & 0x0f);
}
// 最终宽度 = 左边距 + 条纹单位总数 * 每单位像素数
int imageWidth = (xoffset >> 1) + bcWidth1 * barWidth;
if (imageWidth <= 0 || barHeight <= 0) {
return QImage();
}
QImage image(imageWidth, barHeight, QImage::Format_ARGB32);
image.fill(background);
for (int y = 0; y < barHeight; ++y) {
int xpos = xoffset >> 1;
for (int n = 0; n < len; ++n) {
// partial数据编码方案:奇数索引=黑条,偶数索引=空白
// 低3位存储实际宽度,需乘以barWidth得到像素宽度
int run = (bc->partial[n] & 0x07) * barWidth;
if (n & 1) {
// 奇数索引:绘制黑条(前景色)
for (int k = 0; k < run; ++k) {
if (xpos >= 0 && xpos < imageWidth) {
image.setPixel(xpos, y, foreground);
}
++xpos;
}
} else {
// 偶数索引:跳过空白区域(已由背景色填充)
xpos += run;
}
}
}
return image;
}
static int barcodeTypeFromString(const QString &type)
{
QString t = type.trimmed().toUpper();
if (t == "BARCODE_128") return BARCODE_128;
if (t == "BARCODE_93") return BARCODE_93;
if (t == "BARCODE_ISBN") return BARCODE_ISBN;
if (t == "BARCODE_EAN") return BARCODE_EAN;
if (t == "BARCODE_UPC") return BARCODE_UPC;
if (t == "BARCODE_39") return BARCODE_39;
if (t == "BARCODE_CBR") return BARCODE_CBR;
if (t == "BARCODE_PLS") return BARCODE_PLS;
if (t == "BARCODE_MSI") return BARCODE_MSI;
return BARCODE_128;
}
static QString barcodeTypeNameFromIndex(int index)
{
switch (index) {
case 0: return QLatin1String("BARCODE_128");
case 1: return QLatin1String("BARCODE_93");
case 2: return QLatin1String("BARCODE_ISBN");
case 3: return QLatin1String("BARCODE_EAN");
case 4: return QLatin1String("BARCODE_UPC");
case 5: return QLatin1String("BARCODE_39");
case 6: return QLatin1String("BARCODE_CBR");
case 7: return QLatin1String("BARCODE_PLS");
case 8: return QLatin1String("BARCODE_MSI");
default: return QLatin1String("BARCODE_128");
}
}
static QImage generateQRCodeImage(const QString &content, int qrType)
{
DlgQrcodeFormatVM vm;
vm.type = qrType == 0 ? QR_CODE_TYPE_DATA_MATRIX : QR_CODE_TYPE_QRCODE;
return generateQRCodeImage(content, vm);
}
/**
* @brief 根据格式配置生成条形码图像
*
* 支持多种条形码标准(128、93、EAN等),直接渲染到QImage,无需文件操作。
* 避免对QBarCode类的依赖,实现自包含的编码流程。
*/
static QImage generateBarCodeImage(const QString &content, const DlgBarcodeFormatVM &vm)
{
if (content.isEmpty()) {
return QImage();
}
// UTF-8编码确保国际字符被正确处理,与打印驱动兼容
QByteArray bytes = content.toUtf8();
// Barcode_Create内部用strdup复制字符串,无需手动生命周期管理
struct Barcode_Item *bc = Barcode_Create(bytes.data());
if (!bc) {
return QImage();
}
int encodingFlag = barcodeTypeFromString(vm.type);
// BARCODE_OUT_PS: 预期PostScript格式输出(internal flag),BARCODE_OUT_NOHEADERS: 不生成PS头
int flags = encodingFlag | BARCODE_OUT_PS | BARCODE_OUT_NOHEADERS;
// 传递缩放倍数到库,影响条纹宽度和字体大小的计算(510/60为库内部单位转换)
int width = qMax(1, vm.scale) * 510;
int height = qMax(1, vm.scale) * 60;
if (Barcode_Position(bc, width, height, 0, 0, 0.0) < 0 || Barcode_Encode(bc, flags) < 0) {
Barcode_Delete(bc);
return QImage();
}
// 黑底白码支持(INK_TYPE_WHITE表示反向模式)
QRgb foreground = vm.inkType == INK_TYPE_WHITE ? 0x00ffffff : 0xff000000;
QRgb background = vm.inkType == INK_TYPE_WHITE ? 0xff000000 : 0x00ffffff;
QImage image = renderBarcodeImage(bc, vm.height, vm.width, foreground, background);
Barcode_Delete(bc);
// 可选文本叠加:某些应用场景(如物流标签)需要条码旁显示人类可读的内容
if (vm.txtVisible) {
QPainter painter(&image);
painter.setPen(foreground);
QFont font = painter.font();
// 字体大小自适应:防止文本溢出图像,同时保持可读性
font.setPixelSize(qMin(12, image.height()));
painter.setFont(font);
painter.drawText(image.rect().adjusted(1, 1, -1, -1), Qt::AlignBottom | Qt::AlignHCenter, content);
}
// 最终放大:scale>1时对整个图像进行像素放大(用于低DPI打印环保模式)
if (vm.scale > 1) {
image = image.scaled(image.width() * vm.scale, image.height() * vm.scale, Qt::KeepAspectRatio, Qt::FastTransformation);
}
return image;
}
static QImage generateBarCodeImage(const QString &content, int barCodeType)
{
DlgBarcodeFormatVM vm;
vm.type = barcodeTypeNameFromIndex(barCodeType);
return generateBarCodeImage(content, vm);
}
QString generateTxtFromDateItemModel(const DateItemModel &model, const QDateTime &time)
{
@@ -87,12 +395,154 @@ QString generateTxtFromBarcodeViewModel(const BarcodeViewModel &vm, const std::a
}
pos = vm.contentPattern.indexOf("{c}");
if(pos != 1) {
if(pos != -1) {
auto cntValue = vm.counterViewModel.counterType == COUNTER_TYPE_1 ? counterValues[0] : counterValues[1];
auto valueStr = QString("%1").arg(cntValue, 10, QChar('0'));;
valueStr.right(vm.counterViewModel.digitalNum);
valueStr = valueStr.right(vm.counterViewModel.digitalNum);
txt.replace(pos, 3, valueStr);
}
return txt;
}
/**
* @brief 统一的条码/二维码生成入口
*
* @details
* 目的:将二维码和条形码编码逻辑独立出来,避免对UI对话框类(dlgQrCode、QBarCode)的依赖,
* 实现在数据层直接进行编码,支持后端打印任务、异步处理等场景。
*
* 多态format参数设计的理由:
* - 支持便利调用(int):向后兼容现有代码路径,使用库默认配置
* - 支持细粒度控制(DlgQrcodeFormatVM/DlgBarcodeFormatVM):UI配置直通生成函数
* - 避免序列化开销:QVariant作为类型安全的通用容器
*
* @param content 已格式化的文本内容(由调用者负责模板替换如{t}、{c})
* @param type 条码类型(BARCODE_TYPE_QRCODE 或 BARCODE_TYPE_BARCODE)
* @param format 配置参数容器,支持以下类型:
* - BARCODE_TYPE_QRCODE: DlgQrcodeFormatVM(完整配置)或 int(0=DataMatrix, 1=QRCode,使用默认值)
* - BARCODE_TYPE_BARCODE: DlgBarcodeFormatVM(完整配置)或 int(条形码类型索引,使用默认值)
* @return QImage 生成的图像;失败返回空QImage
*/
QImage generateBarcodeImage(const QString &content, BarcodeType type, const QVariant &format)
{
if (content.isEmpty()) {
return QImage();
}
if (type == BARCODE_TYPE_QRCODE) {
// 优先级:完整VM配置 > 简化int配置 > 默认配置
// 原因:支持从UI直接传递结构体,同时保留向后兼容的快速路径
if (format.canConvert<DlgQrcodeFormatVM>()) {
DlgQrcodeFormatVM vm = format.value<DlgQrcodeFormatVM>();
return generateQRCodeImage(content, vm);
}
if (format.isValid() && format.canConvert<int>()) {
return generateQRCodeImage(content, format.toInt());
}
return generateQRCodeImage(content, static_cast<int>(QR_CODE_TYPE_QRCODE));
}
if (type == BARCODE_TYPE_BARCODE) {
if (format.canConvert<DlgBarcodeFormatVM>()) {
DlgBarcodeFormatVM vm = format.value<DlgBarcodeFormatVM>();
return generateBarCodeImage(content, vm);
}
if (format.isValid() && format.canConvert<int>()) {
return generateBarCodeImage(content, format.toInt());
}
return generateBarCodeImage(content, DlgBarcodeFormatVM());
}
return QImage();
}
/**
* @brief 将 QImage 中所有等于 bg 的边缘像素裁掉,仅保留有效内容的最小外接矩形
*
* 复刻自 PicTextItem 的 clipImage:用四个方向扫描确定 left/top/right/bottom 边界,
* 然后调用 QImage::copy 输出裁剪后的图像。这样字符串如 "aaa" 不会保留 "j" 才会用到的下行空白,
* 节省后续打印或合成时的画布空间。
*/
static QImage clipTxtImage(const QImage &img, QRgb bg)
{
if (img.isNull()) {
return img;
}
QRect clipRect;
for (int x = 0; x < img.width(); ++x) {
for (int y = 0; y < img.height(); ++y) {
if (img.pixel(x, y) != bg) {
clipRect.setLeft(x);
goto top;
}
}
}
// 整张图都是背景色,直接返回原图(无可裁剪内容)
return img;
top:
for (int y = 0; y < img.height(); ++y) {
for (int x = 0; x < img.width(); ++x) {
if (img.pixel(x, y) != bg) {
clipRect.setTop(y);
goto right;
}
}
}
right:
for (int x = img.width() - 1; x >= 0; --x) {
for (int y = 0; y < img.height(); ++y) {
if (img.pixel(x, y) != bg) {
clipRect.setRight(x + 1);
goto bottom;
}
}
}
bottom:
for (int y = img.height() - 1; y >= 0; --y) {
for (int x = 0; x < img.width(); ++x) {
if (img.pixel(x, y) != bg) {
clipRect.setBottom(y + 1);
goto end;
}
}
}
end:
return img.copy(clipRect);
}
QImage txtToImage(const QString &txt, const QFont &font, const QColor &fgColor, const QColor &bgColor)
{
if (txt.isEmpty()) {
return QImage();
}
// 用 QFontMetrics 计算给定字体下文本的水平推进宽度和单行高度,
// 这样初始画布刚好能容纳整段文本,避免后续裁剪时出现截断
QFontMetrics fm(font);
int width = fm.horizontalAdvance(txt);
int height = fm.height();
if (width <= 0 || height <= 0) {
return QImage();
}
QImage img(width, height, QImage::Format_ARGB32);
QRgb bgRgb = bgColor.rgba();
img.fill(bgRgb);
QPainter painter;
painter.begin(&img);
painter.setFont(font);
painter.setPen(fgColor);
painter.drawText(img.rect(), txt);
painter.end();
// 按背景色裁剪,使输出图像紧贴文字像素的最小包围盒(详见函数注释)
return clipTxtImage(img, bgRgb);
}
+45
View File
@@ -6,7 +6,26 @@
#include <QString>
#include <QVector>
#include "BarcodeEditor.h"
#include <array>
#include <QImage>
/**
* @brief 根据日期视图模型和时间生成字符串
* @param model 包含日期格式模版和相关配置的视图模型
* @param time 用于生成字符串的时间
* @return QString 生成的字符串
* @remark
* 该函数根据 model.datetimePattern 中的格式模版生成字符串,支持以下格式:
* - yyyy: 四位数年份,支持替换为自定义字符串(通过 model.yearsMap)
* - YY: 两位数年份
* - MM: 两位数月份,支持替换为自定义字符串(通过 model.monthsMap)
* - dd: 两位数日期,支持替换为自定义字符串(通过 model.daysMap)
* - HH: 两位数小时,支持替换为自定义字符串(通过 model.hoursMap)
* - mm: 两位数分钟
* - ss: 两位数秒钟
* - w: 星期几,支持替换为自定义字符串(通过 model.weeksMap)
* - c: 年中周数
*/
QString generateTxtFromDateItemModel(const DateItemModel& model, const QDateTime& time);
/**
@@ -28,4 +47,30 @@ QString generateTxtFromDateItemModel(const DateItemModel& model, const QDateTime
*/
QString generateTxtFromBarcodeViewModel(const BarcodeViewModel& vm, const std::array<int, 2> counterValues, const QDateTime& time);
/**
* @brief 根据条形码类型和内容生成条形码或二维码图像
* @param content 已格式化的文本内容
* @param type 条码类型
* @param format 配置参数
* @return QImage 生成的图像;如果失败返回空图像
* @note
* format 参数类型:
* - BARCODE_TYPE_QRCODE: DlgQrcodeFormatVM 或 int
* - BARCODE_TYPE_BARCODE: DlgBarcodeFormatVM 或 int
* 如果 format 是 int 类型, 对于 QR Code,0 表示 Data Matrix,1 表示 QR Code;对于条形码,int 值对应 DlgBarcodeFormatVM 中 type 的索引。
* 如果 format 是 int 类型,则使用默认配置并根据 int 值选择二维码或条形码的子类型;如果 format 是对应的 VM 类型,则使用其中的详细配置。
*/
QImage generateBarcodeImage(const QString& content, BarcodeType type, const QVariant& format);
/**
* @brief 将文本转换为图像
* @param txt 要转换的文本
* @param font 文本使用的字体
* @param fgColor 文本颜色,默认为黑色
* @param bgColor 背景颜色,默认为白色
* @return QImage 转换后的图像
* @note 返回的字符串图像会裁剪至最小边界以节省空间。例如字符串"aaa"的高度会比"bbbjjj"小,因为前者没有上下行部分。
*/
QImage txtToImage(const QString& txt, const QFont& font, const QColor& fgColor = Qt::black, const QColor& bgColor = Qt::white);
#endif // _ITEM_COMMON_H_
+107 -43
View File
@@ -18,6 +18,14 @@ ItemGeneralSettings::ItemGeneralSettings(QWidget *parent) :
connect(&m_directionButtonGroup, static_cast<void(QButtonGroup::*)(int)>(&QButtonGroup::buttonClicked),
this, &ItemGeneralSettings::ondirectionChanged);
connect(ui->boldSpinBox, static_cast<void(QSpinBox::*)(int)>(&QSpinBox::valueChanged),
this, &ItemGeneralSettings::onBoldSpinBoxValueChanged);
connect(ui->txtSpanSpinBox, static_cast<void(QSpinBox::*)(int)>(&QSpinBox::valueChanged),
this, &ItemGeneralSettings::onLetterSpaceSpinBoxChanged);
connect(ui->invertCheckBox, &QCheckBox::stateChanged,
this, [this](int state) { onColorReversalCheckBoxChecked(state == Qt::Checked); });
initUI();
}
ItemGeneralSettings::~ItemGeneralSettings()
@@ -28,35 +36,51 @@ ItemGeneralSettings::~ItemGeneralSettings()
void ItemGeneralSettings::edit(PicTextItem *item)
{
m_currItem = item;
if(!m_currItem) {
ui->boldSpinBox->setValue(ui->boldSpinBox->minimum());
ui->txtSpanSpinBox->setValue(ui->txtSpanSpinBox->minimum());
ui->normalRBtn->setChecked(true);
ui->invertCheckBox->setChecked(false);
ui->previewWidget->setImg(QImage());
return;
// 从item快照创建ViewModel(如果item为空,使用默认值)
setViewModel(ItemGeneralSettingsVM::fromItem(item));
}
auto b = ui->boldSpinBox->blockSignals(true);
ui->boldSpinBox->setValue(item->boldMultiple());
ui->boldSpinBox->blockSignals(b);
void ItemGeneralSettings::initUI()
{
ui->densitySpinBox->setValue(0);
ui->invertCheckBox->setChecked(false);
ui->alternateCheckBox->setChecked(false);
ui->boldSpinBox->setValue(0);
ui->txtSpanSpinBox->setValue(0);
ui->normalRBtn->setChecked(true);
ui->applyCounterCheckBox->setChecked(false);
ui->counterIDSpinBox->setValue(0);
}
b = ui->txtSpanSpinBox->blockSignals(true);
ui->txtSpanSpinBox->setValue(item->letterSpace());
ui->txtSpanSpinBox->blockSignals(b);
void ItemGeneralSettings::setViewModel(const ItemGeneralSettingsVM &vm)
{
m_vmSnapshot = vm;
m_vm = vm;
auto dirBtn = m_directionButtonGroup.button(item->direction());
b = dirBtn->blockSignals(true);
// 阻止信号以避免重复回调
auto blockBold = ui->boldSpinBox->blockSignals(true);
auto blockSpan = ui->txtSpanSpinBox->blockSignals(true);
auto blockInvert = ui->invertCheckBox->blockSignals(true);
// 根据m_vm更新UI显示
ui->boldSpinBox->setValue(m_vm.boldMultiple);
ui->txtSpanSpinBox->setValue(m_vm.letterSpace);
auto dirBtn = m_directionButtonGroup.button(m_vm.direction);
if (dirBtn) {
dirBtn->setChecked(true);
dirBtn->blockSignals(b);
}
b = ui->invertCheckBox->blockSignals(true);
ui->invertCheckBox->setChecked(item->colorReversal());
ui->invertCheckBox->blockSignals(b);
ui->invertCheckBox->setChecked(m_vm.colorReversal);
// 文字、日期、轮班可调字符间距
// 计数器类的字符间距由 @see CounterVarSet 单独调整
switch(item->sourceType()) {
// 恢复信号
ui->boldSpinBox->blockSignals(blockBold);
ui->txtSpanSpinBox->blockSignals(blockSpan);
ui->invertCheckBox->blockSignals(blockInvert);
// 字间距可见性由item的类型决定
switch(m_vm.sourceType) {
case SourceType::TEXT:
case SourceType::DATETIME:
case SourceType::SCHEDULE_SHIFT:
@@ -68,43 +92,83 @@ void ItemGeneralSettings::edit(PicTextItem *item)
break;
}
ui->previewWidget->setImg(m_currItem->preview());
updatePreview();
}
void ItemGeneralSettings::applyToItem(PicTextItem *item)
{
if (!item) {
return;
}
// VM的属性被逐一应用到item
item->setDirection(m_vm.direction);
item->setBoldMultiple(m_vm.boldMultiple);
item->setLetterSpace(m_vm.letterSpace);
item->setColorReversal(m_vm.colorReversal);
item->applyModify();
}
void ItemGeneralSettings::ondirectionChanged(int dir)
{
if(!m_currItem) {
return;
}
m_currItem->setDirection(ItemDirectionType(dir));
m_currItem->applyModify();
ui->previewWidget->setImg(m_currItem->preview());
// 只更新VM,不直接修改item
m_vm.direction = ItemDirectionType(dir);
updatePreview();
}
void ItemGeneralSettings::onBoldSpinBoxValueChanged(int multiple)
{
if(m_currItem) {
m_currItem->setBoldMultiple(multiple);
m_currItem->applyModify();
ui->previewWidget->setImg(m_currItem->preview());
}
// 只更新VM
m_vm.boldMultiple = multiple;
updatePreview();
}
void ItemGeneralSettings::onLetterSpaceSpinBoxChanged(int space)
{
if(m_currItem) {
m_currItem->setLetterSpace(space);
m_currItem->applyModify();
ui->previewWidget->setImg(m_currItem->preview());
}
// 只更新VM
m_vm.letterSpace = space;
updatePreview();
}
void ItemGeneralSettings::onColorReversalCheckBoxChecked(bool b)
{
if(m_currItem) {
m_currItem->setColorReversal(b);
// 只更新VM
m_vm.colorReversal = b;
updatePreview();
}
void ItemGeneralSettings::updatePreview()
{
// 预览需要基于item的source和m_vm的属性组合渲染
// 如果m_currItem为空,显示空图像
if (!m_currItem) {
if(m_vm.imageGenerator) {
ui->previewWidget->setImg(m_vm.imageGenerator());
}
else {
ui->previewWidget->setImg(QImage());
}
return;
}
// 临时应用VM到item以获取预览,随后还原
auto backupDir = m_currItem->direction();
auto backupBold = m_currItem->boldMultiple();
auto backupSpace = m_currItem->letterSpace();
auto backupReverse = m_currItem->colorReversal();
m_currItem->setDirection(m_vm.direction);
m_currItem->setBoldMultiple(m_vm.boldMultiple);
m_currItem->setLetterSpace(m_vm.letterSpace);
m_currItem->setColorReversal(m_vm.colorReversal);
m_currItem->applyModify();
ui->previewWidget->setImg(m_currItem->preview());
}
// 还原原始状态(preview()后item的属性不应该被留下改动)
m_currItem->setDirection(backupDir);
m_currItem->setBoldMultiple(backupBold);
m_currItem->setLetterSpace(backupSpace);
m_currItem->setColorReversal(backupReverse);
m_currItem->applyModify();
}
+89
View File
@@ -5,11 +5,52 @@
#include <QButtonGroup>
#include "pictextitem.h"
#include <QPainter>
#include <QImage>
namespace Ui {
class ItemGeneralSettings;
}
/**
* @brief 图元通用属性的ViewModel
*
* 目的:解耦UI编辑器与PicTextItem,支持灵活的数据绑定和批量操作。
* UI修改属性时先更新VM,再决定何时应用到item(实时或延迟)。
*/
struct ItemGeneralSettingsVM {
// 图元类型,用于判断是否显示字间距
SourceType sourceType = SourceType::UNKNOWN;
ItemDirectionType direction = NORMAL;
int boldMultiple = 1;
int letterSpace = 0;
bool colorReversal = false;
std::function<QImage()> imageGenerator; // 图片生成函数
// 便利方法:从PicTextItem快照创建VM
static ItemGeneralSettingsVM fromItem(PicTextItem *item) {
ItemGeneralSettingsVM vm;
if (item) {
vm.sourceType = item->sourceType();
vm.direction = item->direction();
vm.boldMultiple = item->boldMultiple();
vm.letterSpace = item->letterSpace();
vm.colorReversal = item->colorReversal();
}
return vm;
}
// 检查是否有改动
bool hasDifference(const ItemGeneralSettingsVM &other) const {
return sourceType != other.sourceType ||
direction != other.direction ||
boldMultiple != other.boldMultiple ||
letterSpace != other.letterSpace ||
colorReversal != other.colorReversal;
}
};
class ItemGeneralSettings : public QWidget
{
Q_OBJECT
@@ -18,10 +59,45 @@ public:
explicit ItemGeneralSettings(QWidget *parent = nullptr);
~ItemGeneralSettings();
/**
* @brief 加载PicTextItem的属性到ViewModel,初始化UI
*
* 原因:UI应该显示item的状态,但不应该直接持有指针长期修改。
* edit()后,用户对UI的编辑会更新m_vm,而不是直接改item。
*/
void edit(PicTextItem* item);
/**
* @brief 设置当前ViewModel
*
* @param vm
*/
void setViewModel(const ItemGeneralSettingsVM& vm);
/**
* @brief 获取当前ViewModel
*
* 调用者可以检查是否有改动,并决定是否应用
*/
ItemGeneralSettingsVM viewModel() const { return m_vm; }
/**
* @brief 将ViewModel的属性应用到指定的PicTextItem
*
* 解耦的核心:UI不再直接修改item,而是通过VM进行间接修改。
* 这支持撤销/重做、批量编辑等高级功能。
*/
void applyToItem(PicTextItem* item);
/**
* @brief 当前编辑的item源引用(可能为空)
*
* 主要用于获取preview()时作为示例源,不用于直接修改
*/
PicTextItem* currentItem() { return m_currItem; }
void initUI();
private slots:
void ondirectionChanged(int dir);
void onBoldSpinBoxValueChanged(int multiple);
@@ -29,10 +105,23 @@ private slots:
void onColorReversalCheckBoxChecked(bool b);
private:
/**
* @brief 刷新预览,基于当前VM和item的source渲染
*/
void updatePreview();
Ui::ItemGeneralSettings *ui;
QButtonGroup m_directionButtonGroup;
// 原始item的快照,用于preview()和后续应用
PicTextItem* m_currItem = nullptr;
// UI编辑的状态,独立于m_currItem
ItemGeneralSettingsVM m_vm;
// 初始加载时的VM状态,用于检测改动
ItemGeneralSettingsVM m_vmSnapshot;
QPainter m_painter;
};
+3 -38
View File
@@ -12,7 +12,7 @@ PicDateItem::PicDateItem(QGraphicsItem *parent, QGraphicsScene *scene, const Sou
updateDatetimeStr();
});
m_timer.start();
// m_timer.start();
}
QVariant PicDateItem::source()
@@ -70,48 +70,13 @@ void PicDateItem::setCustomAttrs(const QXmlStreamAttributes &attrs)
// yearsMap = "2023<subbr>2023年<br>2024<subbr>2024年<br>2025<subbr>2025年"
auto m = DateItemModel();
m.dataMap = attrs.value("dataMap").toString().split("<br>");
m.daysMap = attrs.value("daysMap").toString().split("<br>");
m.hoursMap = attrs.value("hoursMap").toString().split("<br>");
m.monthsMap = attrs.value("monthsMap").toString().split("<br>");
m.weeksMap = attrs.value("weeksMap").toString().split("<br>");
auto yearsMap = attrs.value("yearsMap").toString().split("<br>");
for(auto it = yearsMap.begin(); it != yearsMap.end(); ++it) {
auto yearPair = it->split("<subbr>");
if(yearPair.size() == 2) {
m.yearsMap[yearPair[0].toInt()] = yearPair[1];
}
}
m.monthsOffset = attrs.value("monthsOffset").toInt();
m.daysOffset = attrs.value("daysOffset").toInt();
m.datetimePattern = attrs.value("datetimePattern").toString();
DateItemModel::loadFromXml(m, attrs);
setModel(std::move(m));
}
void PicDateItem::saveCustomAttrs(QXmlStreamAttributes &attrs)
{
auto dataMap = m_model.dataMap.join("<br>");
auto daysMap = m_model.daysMap.join("<br>");
auto hoursMap = m_model.hoursMap.join("<br>");
auto monthsMap = m_model.monthsMap.join("<br>");
auto weeksMap = m_model.weeksMap.join("<br>");
QString yearsMap;
for(auto it = m_model.yearsMap.begin(); it != m_model.yearsMap.end(); ++it) {
yearsMap.append(QString("%1<subbr>%2<br>").arg(it.key()).arg(it.value()));
}
attrs.append("dataMap", dataMap);
attrs.append("daysMap", daysMap);
attrs.append("hoursMap", hoursMap);
attrs.append("monthsMap", monthsMap);
attrs.append("weeksMap", weeksMap);
attrs.append("yearsMap", yearsMap);
attrs.append("datetimePattern", m_model.datetimePattern);
attrs.append("monthsOffset", QString::number(m_model.monthsOffset));
attrs.append("daysOffset", QString::number(m_model.daysOffset));
DateItemModel::saveToXml(m_model, attrs);
}
QImage PicDateItem::itemImage()
+1 -1
View File
@@ -9,7 +9,7 @@ PicScheduleShiftItem::PicScheduleShiftItem(QGraphicsItem *parent, QGraphicsScene
connect(&m_updateTimer, &QTimer::timeout, [this](){
updateScheduleName();
});
m_updateTimer.start();
// m_updateTimer.start();
}
QVariant PicScheduleShiftItem::source()
+96 -1
View File
@@ -44,6 +44,7 @@ ScheduleShiftsEditor::ScheduleShiftsEditor(QWidget *parent) :
ui->btnAdd->setEnabled(false);
ui->btnRemove->setEnabled(false);
applyStyleSheet();
}
ScheduleShiftsEditor::~ScheduleShiftsEditor()
@@ -162,7 +163,101 @@ void ScheduleShiftsEditor::applyDataModel()
void ScheduleShiftsEditor::applyStyleSheet()
{
// TODO:: 应用样式表
QString styleSheet =
R"(
/*
QPushButton {
background-color: #5396C1;
color: #ffffff;
border: 1px solid #000000;
border-radius: 3px;
font-size: 18px;
font-weight:500;
width: 180px;
height: 90px;
}
QPushButton:hover {
background-color: #5396C1;
}
QPushButton:disabled {
background-color: #7C828E;
color: #606060;
border-color: #808080;
}
*/
QPushButton#closeBtn, QPushButton#checkBtn{
background-color: #E6F7FF;
border: 1px solid #87CEEB;
border-radius: 4px;
font-size: 24px;
color: #228B22;
}
QPushButton#closeBtn:hover,QPushButton#checkBtn:hover{
background-color: #D1E9FF;
}
QPushButton#closeBtn:pressed,QPushButton#checkBtn:pressed{
background-color: #BAE7FF;
}
QPushButton {
background-color: #5396C1;
color: #ffffff;
border: 1px solid #000000;
border-radius: 3px;
font-size: 18px;
font-weight:500;
width: 100px;
height: 50px;
}
QPushButton:hover {
background-color: #5396C1;
}
QPushButton:disabled {
background-color: #7C828E;
color: #606060;
border-color: #808080;
}
QTabWidget::pane {
border: 1px solid #dddddd;
background-color: #ffffff;
}
QTabBar::tab:focus {
outline: none;
}
QTabBar::tab {
min-width: 90px;
min-height: 45px;
padding: 4px 10px;
margin-right: 4px;
border: 1px solid #dddddd;
border-bottom: none;
border-top-left-radius: 4px;
border-top-right-radius: 4px;
background-color: #5396C1;
color: #ffffff;
}
QTabWidget::tab-bar {
top: -3px;
left: 10px;
}
QTabBar::tab:selected {
background-color: #6bb1e0;
color: #ffffff;
box-shadow: 0 -3px 8px rgba(44, 125, 232, 0.25);
}
)";
this->setStyleSheet(styleSheet);
}
SelectedStyleTimeEdit::SelectedStyleTimeEdit(QWidget *parent)
+1 -20
View File
@@ -149,26 +149,7 @@
</widget>
<widget class="QWidget" name="scheduleShiftsEditTab">
<property name="styleSheet">
<string notr="true"> QPushButton {
background-color: #5396C1;
color: #ffffff;
border: 1px solid #000000;
border-radius: 3px;
font-size: 18px;
font-weight:500;
width: 180px;
height: 90px;
}
QPushButton:hover {
background-color: #5396C1;
}
QPushButton:disabled {
background-color: #7C828E;
color: #606060;
border-color: #808080;
}</string>
<string notr="true"/>
</property>
<attribute name="title">
<string>班时编号</string>
+79
View File
@@ -1,4 +1,5 @@
#include "ViewModels.h"
#include <QDebug>
DateItemModel DateItemModel::createDefaultReplaceModel()
{
@@ -28,3 +29,81 @@ DateItemModel DateItemModel::createDefaultReplaceModel()
return model;
}
void DateItemModel::loadFromXml(DateItemModel &vm, const QXmlStreamAttributes &attrs)
{
auto& m = vm;
m.dataMap = attrs.value("dataMap").toString().split("<br>");
m.daysMap = attrs.value("daysMap").toString().split("<br>");
m.hoursMap = attrs.value("hoursMap").toString().split("<br>");
m.monthsMap = attrs.value("monthsMap").toString().split("<br>");
m.weeksMap = attrs.value("weeksMap").toString().split("<br>");
auto yearsMap = attrs.value("yearsMap").toString().split("<br>");
for(auto it = yearsMap.begin(); it != yearsMap.end(); ++it) {
auto yearPair = it->split("<subbr>");
if(yearPair.size() == 2) {
m.yearsMap[yearPair[0].toInt()] = yearPair[1];
}
}
m.monthsOffset = attrs.value("monthsOffset").toInt();
m.daysOffset = attrs.value("daysOffset").toInt();
m.datetimePattern = attrs.value("datetimePattern").toString();
}
void DateItemModel::saveToXml(const DateItemModel &vm, QXmlStreamAttributes &attrs)
{
auto& m = vm;
auto dataMap = m.dataMap.join("<br>");
auto daysMap = m.daysMap.join("<br>");
auto hoursMap = m.hoursMap.join("<br>");
auto monthsMap = m.monthsMap.join("<br>");
auto weeksMap = m.weeksMap.join("<br>");
QString yearsMap;
for(auto it = m.yearsMap.begin(); it != m.yearsMap.end(); ++it) {
yearsMap.append(QString("%1<subbr>%2<br>").arg(it.key()).arg(it.value()));
}
attrs.append("dataMap", dataMap);
attrs.append("daysMap", daysMap);
attrs.append("hoursMap", hoursMap);
attrs.append("monthsMap", monthsMap);
attrs.append("weeksMap", weeksMap);
attrs.append("yearsMap", yearsMap);
attrs.append("datetimePattern", m.datetimePattern);
attrs.append("monthsOffset", QString::number(m.monthsOffset));
attrs.append("daysOffset", QString::number(m.daysOffset));
}
void CounterViewModel::loadFromXml(CounterViewModel &vm, const QXmlStreamAttributes &attrs)
{
auto typeRef = attrs.value("counter_type");
auto digitalNumRef = attrs.value("digital_num");
bool ok = false;
int counterType = typeRef.toInt(&ok);
if(!ok || (counterType != COUNTER_TYPE_1 && COUNTER_TYPE_2 != counterType)) {
qWarning() << "Invalied counter type: " << counterType;
return;
}
ok = false;
int digitalNum = digitalNumRef.toInt(&ok);
if(!ok || digitalNum <= 0) {
qWarning() << "Invalied counter digital number: " << digitalNum;
return;
}
vm.counterType = static_cast<COUNTER_TYPE>(counterType);
vm.digitalNum = digitalNum;
qInfo() << "Loaded attrs from xml: " << " counter type: " << counterType << ", digitalNum: " << digitalNum;
}
void CounterViewModel::saveToXml(CounterViewModel &vm, QXmlStreamAttributes &attrs)
{
attrs.append("counter_type", QString::number(vm.counterType));
attrs.append("digital_num", QString::number(vm.digitalNum));
qInfo() << "Set attrs to xml: " << " counter type: " << vm.counterType << ", digitalNum: " << vm.digitalNum;
}
+6
View File
@@ -7,6 +7,7 @@
#include <QSharedPointer>
#include "SysPara.h"
#include <QMap>
#include <QXmlStreamAttributes>
enum InkType {
INK_TYPE_BLACK,
@@ -32,6 +33,9 @@ struct CounterViewModel {
int letterSpace = 2;
int charWidth = 0; // 字符宽度,仅在 enbCustomCharWidth == true 时有意义
bool enbCustomCharWidth = false;
static void loadFromXml(CounterViewModel& vm, const QXmlStreamAttributes& attrs);
static void saveToXml(CounterViewModel& vm, QXmlStreamAttributes& attrs);
};
Q_DECLARE_METATYPE(CounterViewModel);
@@ -52,6 +56,8 @@ struct DateItemModel {
QStringList hoursMap;
static DateItemModel createDefaultReplaceModel();
static void loadFromXml(DateItemModel& vm, const QXmlStreamAttributes& attrs);
static void saveToXml(const DateItemModel& vm, QXmlStreamAttributes& attrs);
};
Q_DECLARE_METATYPE(DateItemModel);
+52 -8
View File
@@ -1,38 +1,82 @@
#include "piccodeitem.h"
#include "ItemCommon.h"
#include <QDebug>
PicCodeItem::PicCodeItem(QGraphicsItem *parent, QGraphicsScene *scene, const SourceType type)
:PicTextItem(parent, scene, type)
:PicTextItem(parent, scene, type),
m_currCounterValues({0, 0})
{
setFlag(QGraphicsItem::ItemIsMovable);
setFlag(QGraphicsItem::ItemIsSelectable);
setFlag(QGraphicsItem::ItemIsFocusable);
setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
connect(&m_dateVarTimer, &QTimer::timeout, this, [this](){
updateVariants();
});
// m_dateVarTimer.start(50);
}
PicCodeItem::~PicCodeItem()
{
m_dateVarTimer.stop();
}
QVariant PicCodeItem::source()
{
return imagePath;
return m_currCodeTxt;
}
void PicCodeItem::setSource(QVariant var)
{
imagePath = var.toString();
applyModify();
}
void PicCodeItem::setBarcodeViewModel(const BarcodeViewModel &vm)
{
m_vm = vm;
m_currCodeTxt = "";
updateVariants();
qInfo() << "Barcode model: \r\n" << qPrintable(BarcodeViewModel::toString(vm));
}
BarcodeViewModel PicCodeItem::barcodeViewModel()
{
return m_vm;
}
bool PicCodeItem::updateVariants(const QVector<int> counters)
{
m_currCounterValues = counters;
return updateVariants();
}
QImage PicCodeItem::itemImage()
{
return QImage(imagePath);
return m_codeImage;
}
void PicCodeItem::setCustomAttrs(const QXmlStreamAttributes &attrs)
{
imagePath = attrs.value("CodeImage").toString();
auto vm = BarcodeViewModel::loadFromXml(attrs);
setBarcodeViewModel(vm);
}
void PicCodeItem::saveCustomAttrs(QXmlStreamAttributes &attrs)
{
attrs.append("CodeImage", imagePath);
BarcodeViewModel::saveToXml(m_vm, attrs);
}
bool PicCodeItem::updateVariants()
{
auto txt = generateTxtFromBarcodeViewModel(m_vm, {m_currCounterValues[0], m_currCounterValues[1]}, QDateTime::currentDateTime());
if(txt != m_currCodeTxt || m_currCodeTxt.isEmpty()) {
m_currCodeTxt = txt;
m_codeImage = generateBarcodeImage(txt, m_vm.type, m_vm.format);
applyModify();
return true;
}
return false;
}
+15 -5
View File
@@ -2,19 +2,24 @@
#define PICCODEITEM_H
#include "pictextitem.h"
#include "BarcodeEditor.h"
#include <QTimer>
class PicCodeItem : public PicTextItem
{
public:
PicCodeItem(QGraphicsItem *parent = 0, QGraphicsScene *scene = 0,
const SourceType type = SourceType::CODE);
virtual ~PicCodeItem() {}
virtual ~PicCodeItem();
virtual QVariant source() override;
virtual void setSource(QVariant var) override;
void setBarcodeViewModel(const BarcodeViewModel& vm);
BarcodeViewModel barcodeViewModel();
bool updateVariants(const QVector<int> counters);
protected:
/**
* @brief itemImage 子类可以重新实现该方法用于返回已经渲染好了的但未应用方向、水平拉伸的图像
@@ -29,9 +34,14 @@ protected:
virtual void saveCustomAttrs(QXmlStreamAttributes& attrs);
private:
// 保存图片的绝对路径
QString imagePath = "";
bool updateVariants();
BarcodeViewModel m_vm;
QVector<int> m_currCounterValues;
QString m_currCodeTxt;
QImage m_codeImage;
QTimer m_dateVarTimer;
};
#endif // PICCODEITEM_H
+2
View File
@@ -55,6 +55,7 @@ void PicScene::keyPressEvent(QKeyEvent *event)
{
QGraphicsScene::keyPressEvent(event);
}
//edit@12-09
void PicScene::drawBackground(QPainter *painter, const QRectF &rect)
{
@@ -112,6 +113,7 @@ void PicScene::drawBackground(QPainter *painter, const QRectF &rect)
emit showTextWidthHeight();
}
//edit@12-09
void PicScene::setIsdrawBackground(bool newIsdrawBackground)
{
+1 -1
View File
@@ -72,6 +72,6 @@ private:
bool IsdrawBackground;
QGraphicsObject* currFocusItem;
QGraphicsObject* currFocusItem = nullptr;
};
#endif // PICSCENE_H
+992 -1179
View File
File diff suppressed because it is too large Load Diff
+23 -36
View File
@@ -845,6 +845,25 @@
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="1">
<widget class="QPushButton" name="pushButtonCleanUP">
<property name="minimumSize">
<size>
<width>0</width>
<height>40</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>200</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>喷嘴逆清洗</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QPushButton" name="pushButtonHighVoltageData">
<property name="enabled">
@@ -858,7 +877,7 @@
</property>
<property name="maximumSize">
<size>
<width>260</width>
<width>200</width>
<height>16777215</height>
</size>
</property>
@@ -870,41 +889,6 @@
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QPushButton" name="pushButtonInterFace">
<property name="enabled">
<bool>true</bool>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>40</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>260</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>界面语言设置</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QPushButton" name="pushButtonCleanUP">
<property name="minimumSize">
<size>
<width>0</width>
<height>40</height>
</size>
</property>
<property name="text">
<string>喷嘴逆清洗</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QPushButton" name="checkBtn">
@@ -939,6 +923,9 @@
<class>ClickLabel</class>
<extends>QLabel</extends>
<header>ClickLabel.h</header>
<slots>
<signal>pressed()</signal>
</slots>
</customwidget>
</customwidgets>
<resources/>
+66 -43
View File
@@ -191,6 +191,11 @@ TestPrintWidget::TestPrintWidget(QWidget* parent)
emit sig_showEditCounter(vm);
});
connect(ui.btnBarcode, &QPushButton::clicked, [this](){
pPicScene->clearSelection();
showBarcodeEditor();
});
// X,Y label connection
connect(pPicScene, &PicScene::focusedItemPosChanged, this, &TestPrintWidget::onSceneFocusedItemPosChanged);
@@ -214,6 +219,8 @@ TestPrintWidget::TestPrintWidget(QWidget* parent)
itemEditor = new ItemEditor();
connect(itemEditor, &ItemEditor::accepted, this, &TestPrintWidget::onItemEditorAccepted);
connect(&m_barcodeEditor, &BarcodeEditor::accepted, this, &TestPrintWidget::slt_BarCodeItemDone);
initSelecteCodeDlg();
// 网络通信,暂时屏蔽
@@ -252,6 +259,7 @@ QPixmap TestPrintWidget::loadIcon(const QString& iconName, const QSize& size)
void TestPrintWidget::on_openfileButton_pressed()
{
pPicScene->clearSelection();
pPicScene->clearFocus();
dialogFileOperation->refreshListView(editMode);
dialogFileOperation->exec();
}
@@ -1219,39 +1227,41 @@ void TestPrintWidget::onCreateSceneImage(QString filePath)
void TestPrintWidget::on_KeyUp_clicked()
{
pViewer->setFocus();
#ifndef Q_OS_WIN32
//QWSServer::sendKeyEvent(0,Qt::Key_Up,Qt::NoModifier,true,false); //向系统发送键盘事件
MyInputMethod::sendEvent(Qt::Key_Up,Qt::NoModifier);
#endif
moveSelectedItem(Qt::Key_Up);
}
void TestPrintWidget::on_KeyLeft_clicked()
{
pViewer->setFocus();
#ifndef Q_OS_WIN32
//QWSServer::sendKeyEvent(0,Qt::Key_Left,Qt::NoModifier,true,false); //向系统发送键盘事件
MyInputMethod::sendEvent(Qt::Key_Left,Qt::NoModifier);
#endif
moveSelectedItem(Qt::Key_Left);
}
void TestPrintWidget::on_KeyRight_clicked()
{
pViewer->setFocus();
#ifndef Q_OS_WIN32
//QWSServer::sendKeyEvent(0,Qt::Key_Right,Qt::NoModifier,true,false); //向系统发送键盘事件
MyInputMethod::sendEvent(Qt::Key_Right,Qt::NoModifier);
#endif
moveSelectedItem(Qt::Key_Right);
}
void TestPrintWidget::on_KeyDown_clicked()
{
pViewer->setFocus();
#ifndef Q_OS_WIN32
//QWSServer::sendKeyEvent(0,Qt::Key_Down,Qt::NoModifier,true,false); //向系统发送键盘事件
MyInputMethod::sendEvent(Qt::Key_Down,Qt::NoModifier);
#endif
moveSelectedItem(Qt::Key_Down);
}
void TestPrintWidget::moveSelectedItem(Qt::Key key)
{
pViewer->setFocus();
auto selectedItems = pPicScene->selectedItems();
QGraphicsItem* lastItem = nullptr;
if(selectedItems.size() >= 1) {
lastItem = selectedItems.last();
}
if(lastItem) {
lastItem->setFocus();
}
#ifndef Q_OS_WIN32
//QWSServer::sendKeyEvent(0,Qt::Key_Up,Qt::NoModifier,true,false); //向系统发送键盘事件
MyInputMethod::sendEvent(key, Qt::NoModifier);
#endif
}
void TestPrintWidget::on_delButton_pressed()
@@ -1371,13 +1381,12 @@ void TestPrintWidget::onBtnItemConfigClicked()
}
if (item->sourceType() == SourceType::CODE) {
QString s = item->source().toString();
editCodeFlag = true;
if (s.contains(QString("QR")) || s.contains(QString("DMT"))) {
emit sendButtonClickedSignal(202);
} else if (s.contains(QString("BAR"))) {
emit sendButtonClickedSignal(201);
}
auto codeItem = dynamic_cast<PicCodeItem*>(item);
if(!codeItem)
return;
m_barcodeEditor.bindViewModel(codeItem->barcodeViewModel());
showBarcodeEditor(false);
return;
}
@@ -1414,26 +1423,37 @@ void TestPrintWidget::on_newfileButton_pressed(){
sendButtonClickedSignal(21); //新建文件完成
}
void TestPrintWidget::slt_BarCodeItemDone(QString str)
void TestPrintWidget::slt_BarCodeItemDone()
{
if (editCodeFlag) {
on_delButton_pressed();
editCodeFlag = false;
auto vm = m_barcodeEditor.viewModel();
// 如果当前选中了一个条形码或二维码,则更新其内容,然后直接返回
bool flag = false;
auto selectedItem = pPicScene->selectedItems();
for(auto item : selectedItem) {
auto codeItem = dynamic_cast<PicCodeItem*>(item);
if(codeItem) {
codeItem->setBarcodeViewModel(vm);
flag = true;
}
}
addCodeItem(str);
m_TextEdit->clear();
if(flag)
return;
int index = checkSelectScene();
if (index == -1) return;
QString html = m_TextEdit->toHtml();
foreach (QGraphicsItem *item, pPicScene->selectedItems())
{
PicCodeItem *pItem = (PicCodeItem*)item;
pItem->setHtml(html);
pItem->setSource(str);
if(vm.contentPattern.isEmpty()) {
qInfo() << "Empty content pattern, the barcode will not be generated.";
return;
}
// 添加条形码或验证码
pPicScene->clearSelection();
PicCodeItem* item = new PicCodeItem(0, 0, SourceType::CODE);
item->setBarcodeViewModel(vm);
auto boundingRect = pPicScene->itemsBoundingRect();
pPicScene->addItem(item);
item->setPos(boundingRect.right(), 0.0);
item->setSelected(true);
}
void TestPrintWidget::slt_QRCodeItemDone(QString str)
@@ -1619,11 +1639,14 @@ void TestPrintWidget::addCounterItem(CounterViewModel vm, QSharedPointer<QFont>
}
}
void TestPrintWidget::on_btnBarcode_clicked()
void TestPrintWidget::showBarcodeEditor(bool restoreViewModel)
{
#if defined(ARCH_AARCH64)
m_barcodeEditor.setWindowState(Qt::WindowFullScreen);
#endif
if(restoreViewModel)
m_barcodeEditor.restoreViewModel();
m_barcodeEditor.show();
}
+9 -2
View File
@@ -67,6 +67,7 @@ public:
void on_KeyLeft_clicked();
void on_KeyRight_clicked();
void on_KeyDown_clicked();
void on_delButton_pressed();
void setFontNameIndex(float);
@@ -98,7 +99,7 @@ public slots:
void on_newfileButton_pressed();
void slt_BarCodeItemDone(QString str);
void slt_BarCodeItemDone();
void slt_QRCodeItemDone(QString str);
protected:
@@ -116,7 +117,7 @@ private slots:
void addDateItem();
void on_btnBarcode_clicked();
void showBarcodeEditor(bool restoreVM = true);
void onBtnArrowClicked();
@@ -137,6 +138,12 @@ private:
void parseVbfile(QXmlStreamReader &reader);
/**
* @brief 对 on_KeyUp_clicked 等按键事件的简便包装
*
* @param key
*/
void moveSelectedItem(Qt::Key key);
// 加载图标(保留原功能)
QPixmap loadIcon(const QString& iconName, const QSize& size = QSize(40, 40));
+992 -1179
View File
File diff suppressed because it is too large Load Diff
+992 -1179
View File
File diff suppressed because it is too large Load Diff
+992 -1179
View File
File diff suppressed because it is too large Load Diff