改进计数器编辑、预览状态和行为;修复移除source属性的影响、修改自检期间粘度计每次工作时间、更新翻译

This commit is contained in:
2026-09-10 19:17:34 +08:00
parent e9d601a3e8
commit 5a187c359b
27 changed files with 2184 additions and 2226 deletions
+41 -18
View File
@@ -138,15 +138,12 @@ TestPrintWidget::TestPrintWidget(QWidget* parent)
connect(ui.btnNum,&QPushButton::clicked,[this](){
pPicScene->clearSelection();
QFont font("WenQuanYi7");
int ls = (int)(font.letterSpacing());
CounterViewModel vm;
vm.charWidth = 0;
vm.enbCustomCharWidth = false;
vm.counterType = COUNTER_TYPE_1;
vm.digitalNum = 2;
vm.letterSpace = ls;
vm.letterSpace = 1;
vm.cnt1Settings = m_printSettingModel.cnt1Settings;
vm.cnt2Settings = m_printSettingModel.cnt2Settings;
emit sig_showEditCounter(vm);
@@ -689,10 +686,9 @@ void TestPrintWidget::onImageLoaderAccepted()
item->setImagePath(imgPath);
auto boundingRect = pPicScene->itemsBoundingRect();
int y = sysPara->para.canvasHeight - item->boundingRect().height();
item->setPos(x_item, y);
x_item = x_item + boundingRect.right() + 5;
item->setPos(boundingRect.right() + 1, y);
x_item = x_item + boundingRect.right() + 1;
item->setSelected(true);
}
void TestPrintWidget::onBtnItemConfigClicked()
@@ -831,8 +827,8 @@ void TestPrintWidget::slt_BarCodeItemDone()
auto boundingRect = pPicScene->itemsBoundingRect();
pPicScene->addItem(codeItem);
int y = sysPara->para.canvasHeight - codeItem->boundingRect().height();
codeItem->setPos(x_item, y);
x_item = x_item + boundingRect.right() + 5;
codeItem->setPos(boundingRect.right() + 1, y);
x_item = x_item + boundingRect.right() + 1;
} else {
codeItem->setBarcodeViewModel(vm);
}
@@ -993,16 +989,22 @@ void TestPrintWidget::addDateTimeItem(const DateItemModel &model, const TextItem
PicDateItem* item = new PicDateItem();
item->setHtml(htmlStr);
pPicScene->addItem(item);
item->setTextItemModel(textModel);
item->setModel(model);
auto boundingRect = pPicScene->itemsBoundingRect();
int y = sysPara->para.canvasHeight - item->boundingRect().height();
item->setPos(x_item, y);
x_item = x_item + boundingRect.right() + 5;
item->setPos(boundingRect.right() + 1, y);
x_item = x_item + boundingRect.right() + 1;
item->setSelected(true);
item->setModel(model);
}
void TestPrintWidget::addScheduleShiftsItem(QVector<ScheduleModel> schedules, TextItemModel txtModel)
{
if(schedules.size() == 0) {
qWarning() << "The schedules is empty, will be nothing";
return;
}
// 如果当前选中了一个日期时间item,则直接设置模型
auto selectItems = pPicScene->selectedItems();
if(selectItems.size() == 1) {
@@ -1022,13 +1024,12 @@ void TestPrintWidget::addScheduleShiftsItem(QVector<ScheduleModel> schedules, Te
item->setHtml(htmlStr);
pPicScene->addItem(item);
item->setTextItemModel(txtModel);
item->setSchedules(std::move(schedules));
auto boundingRect = pPicScene->itemsBoundingRect();
int y = sysPara->para.canvasHeight - item->boundingRect().height();
item->setPos(x_item, y+3);
x_item = x_item + boundingRect.right() + 5;
item->setPos(boundingRect.right() + 1, y+3);
x_item = x_item + boundingRect.right() + 1;
item->setSelected(true);
item->setSchedules(std::move(schedules));
}
void TestPrintWidget::addCounterItem(CounterViewModel vm, QSharedPointer<QFont> f)
@@ -1047,6 +1048,8 @@ void TestPrintWidget::addCounterItem(CounterViewModel vm, QSharedPointer<QFont>
}
}
QVector<int> currVals{vm.cnt1Settings.currValue, vm.cnt2Settings.currValue};
QFont font;
if(flag) {
@@ -1066,6 +1069,7 @@ void TestPrintWidget::addCounterItem(CounterViewModel vm, QSharedPointer<QFont>
m_printSettingModel.cnt1Settings = vm.cnt1Settings;
m_printSettingModel.cnt2Settings = vm.cnt2Settings;
updateCountersCurrVal(currVals);
}
return;
}
@@ -1085,12 +1089,13 @@ void TestPrintWidget::addCounterItem(CounterViewModel vm, QSharedPointer<QFont>
auto boundingRect = pPicScene->itemsBoundingRect();
int y = sysPara->para.canvasHeight - item->boundingRect().height();
item->setPos(x_item, y);
x_item = x_item + boundingRect.right() + 5;
item->setPos(boundingRect.right() + 1, y);
x_item = x_item + boundingRect.right() + 1;
item->setSelected(true);
m_printSettingModel.cnt1Settings = vm.cnt1Settings;
m_printSettingModel.cnt2Settings = vm.cnt2Settings;
updateCountersCurrVal(currVals);
}
QString TestPrintWidget::currentFile()
@@ -1098,6 +1103,24 @@ QString TestPrintWidget::currentFile()
return xmlfileName;
}
void TestPrintWidget::updateCountersCurrVal(const QVector<int> values)
{
if(values.size() < 2) {
qDebug() << "Invalied values";
return;
}
auto items = pPicScene->items();
for(auto item : items) {
auto counterItem = dynamic_cast<PicCounterItem*>(item);
if(!counterItem)
continue;
int displayNum = counterItem->counterType() == COUNTER_TYPE_1 ? values[0] : values[1];
counterItem->setCounter(counterItem->counterType(), counterItem->digitalNum(), displayNum);
}
}
void TestPrintWidget::showBarcodeEditor(const BarcodeViewModel& vm)
{
#if defined(ARCH_AARCH64)