hlp:最多添加两个计数器,编辑计数器图元,只显示当前计数器的修改tab
This commit is contained in:
+36
-4
@@ -91,7 +91,7 @@ void CounterVarSet::onDigitsChanged(int digits)
|
||||
endValueBox->setValue(maxValue);
|
||||
}
|
||||
|
||||
void CounterVarSet::setCounterConfig(CounterViewModel viewModel)
|
||||
void CounterVarSet::setCounterConfig(CounterViewModel viewModel, bool isChange)
|
||||
{
|
||||
m_vm = viewModel;
|
||||
|
||||
@@ -101,7 +101,7 @@ void CounterVarSet::setCounterConfig(CounterViewModel viewModel)
|
||||
ui->tabWidget->setCurrentIndex(viewModel.counterType == COUNTER_TYPE_1 ? 1 : 2);
|
||||
ui->letterSpaceSpinBox->setValue(viewModel.letterSpace);
|
||||
|
||||
updateSysParaToUI();
|
||||
updateSysParaToUI(isChange);
|
||||
}
|
||||
|
||||
void CounterVarSet::getValue(int *varType,int *digitalWidth,unsigned char *splitMode){
|
||||
@@ -139,8 +139,10 @@ void CounterVarSet::applyUIPara()
|
||||
m_vm.cnt2Settings.currValue = ui->spinBoxCnt2CurrValue->value();
|
||||
}
|
||||
|
||||
void CounterVarSet::updateSysParaToUI()
|
||||
void CounterVarSet::updateSysParaToUI(bool isChange)
|
||||
{
|
||||
handleChange(isChange);
|
||||
|
||||
ui->spinBoxCnt1EndValue->setValue(m_vm.cnt1Settings.endValue);
|
||||
ui->spinBoxCnt1RepeateCnt->setValue(m_vm.cnt1Settings.repeatValue);
|
||||
ui->spinBoxCnt1StartValue->setValue(m_vm.cnt1Settings.startValue);
|
||||
@@ -154,6 +156,36 @@ void CounterVarSet::updateSysParaToUI()
|
||||
ui->spinBoxCnt2CurrValue->setValue(m_vm.cnt2Settings.currValue);
|
||||
}
|
||||
|
||||
void CounterVarSet::handleChange(bool isChange)
|
||||
{
|
||||
if (isChange) {
|
||||
const bool useCnt1 = ui->radioButtonVar1->isChecked();
|
||||
if (useCnt1) {
|
||||
// 只显示 cnt1Tab
|
||||
if (ui->tabWidget->indexOf(ui->cnt2Tab) >= 0)
|
||||
ui->tabWidget->removeTab(ui->tabWidget->indexOf(ui->cnt2Tab));
|
||||
if (ui->tabWidget->indexOf(ui->cnt1Tab) < 0)
|
||||
ui->tabWidget->insertTab(1, ui->cnt1Tab, tr("计数器1"));
|
||||
|
||||
ui->tabWidget->setCurrentWidget(ui->cnt1Tab);
|
||||
} else {
|
||||
// 只显示 cnt2Tab
|
||||
if (ui->tabWidget->indexOf(ui->cnt1Tab) >= 0)
|
||||
ui->tabWidget->removeTab(ui->tabWidget->indexOf(ui->cnt1Tab));
|
||||
if (ui->tabWidget->indexOf(ui->cnt2Tab) < 0)
|
||||
ui->tabWidget->insertTab(1, ui->cnt2Tab, tr("计数器2"));
|
||||
|
||||
ui->tabWidget->setCurrentWidget(ui->cnt2Tab);
|
||||
}
|
||||
} else {
|
||||
// 两个都显示
|
||||
if (ui->tabWidget->indexOf(ui->cnt1Tab) < 0)
|
||||
ui->tabWidget->insertTab(1, ui->cnt1Tab, tr("计数器1"));
|
||||
if (ui->tabWidget->indexOf(ui->cnt2Tab) < 0)
|
||||
ui->tabWidget->insertTab(2, ui->cnt2Tab, tr("计数器2"));
|
||||
}
|
||||
}
|
||||
|
||||
void CounterVarSet::applyStyleSheet()
|
||||
{
|
||||
QString styleSheet =
|
||||
@@ -353,4 +385,4 @@ void CounterVarSet::applyStyleSheet()
|
||||
)";
|
||||
|
||||
this->setStyleSheet(styleSheet);
|
||||
}
|
||||
}
|
||||
|
||||
+3
-2
@@ -25,14 +25,15 @@ public:
|
||||
void applyStyleSheet();
|
||||
void getValue(int *varType,int *digitalWidth,unsigned char *splitMode);
|
||||
|
||||
void updateSysParaToUI(); //重载
|
||||
void updateSysParaToUI(bool isChange); //重载
|
||||
void handleChange(bool isChange);
|
||||
void applyUIPara(); //重载
|
||||
|
||||
// 获取当前计数器配置:varType(7或8) 和 digitalNum(位数)
|
||||
CounterViewModel getCounterConfig();
|
||||
|
||||
// 设置ui,用户编辑计数器item时,会调用此函数显示计数器的配置
|
||||
void setCounterConfig(CounterViewModel viewModel);
|
||||
void setCounterConfig(CounterViewModel viewModel, bool isChange);
|
||||
signals:
|
||||
void sendButtonClickedSignal(int);
|
||||
|
||||
|
||||
+4
-4
@@ -187,7 +187,7 @@ void InkJetPrinter::init()
|
||||
m_PrintSetting->updateModelToUI();
|
||||
m_SystemSetting->updateSysParaToUI();
|
||||
m_OtherInfo->updateSysParaToUI();
|
||||
m_CounterVarSet->updateSysParaToUI();
|
||||
m_CounterVarSet->updateSysParaToUI(false);
|
||||
|
||||
m_SystemManage->loadKeyBoardType();
|
||||
|
||||
@@ -256,11 +256,11 @@ void InkJetPrinter::init()
|
||||
}
|
||||
|
||||
// type 1,2: 分别显示计数器1或2的界面
|
||||
void InkJetPrinter::slt_editCounter(CounterViewModel vm)
|
||||
void InkJetPrinter::slt_editCounter(CounterViewModel vm, bool isChange)
|
||||
{
|
||||
if (m_CounterVarSet) {
|
||||
m_CounterVarSet->updateSysParaToUI();
|
||||
m_CounterVarSet->setCounterConfig(vm);
|
||||
// m_CounterVarSet->updateSysParaToUI(isChange);
|
||||
m_CounterVarSet->setCounterConfig(vm,isChange);
|
||||
m_StackedWidget->setCurrentWidget(m_CounterVarSet);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -234,7 +234,7 @@ private slots:
|
||||
|
||||
void OnFinished(int event);
|
||||
|
||||
void slt_editCounter(CounterViewModel vm);
|
||||
void slt_editCounter(CounterViewModel vm, bool isChange);
|
||||
|
||||
// 保养警告
|
||||
void slt_warningMaintenance();
|
||||
|
||||
@@ -296,7 +296,8 @@ void PrintTextDisplay::paintEvent(QPaintEvent *event){
|
||||
if(val>base-1)jmin=Num-j-1;
|
||||
base *= 10;
|
||||
}
|
||||
str= QString("%1").arg(val%base,Num,10,QLatin1Char('0'))+str;
|
||||
int r = (base != 0) ? (val % base) : 0;
|
||||
str= QString("%1").arg(r,Num,10,QLatin1Char('0'))+str;
|
||||
}
|
||||
|
||||
|
||||
|
||||
+14
@@ -193,12 +193,16 @@
|
||||
<message>
|
||||
<location filename="countervarset.ui" line="84"/>
|
||||
<location filename="countervarset.ui" line="273"/>
|
||||
<location filename="CounterVarSet.cpp" line="168"/>
|
||||
<location filename="CounterVarSet.cpp" line="183"/>
|
||||
<source>计数器1</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="countervarset.ui" line="112"/>
|
||||
<location filename="countervarset.ui" line="655"/>
|
||||
<location filename="CounterVarSet.cpp" line="176"/>
|
||||
<location filename="CounterVarSet.cpp" line="185"/>
|
||||
<source>计数器2</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
@@ -5958,6 +5962,16 @@ p, li { white-space: pre-wrap; }
|
||||
<source>是否保存文件?</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="testprintwidget.cpp" line="1055"/>
|
||||
<source>警告</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="testprintwidget.cpp" line="1055"/>
|
||||
<source>无法创建更多计数器</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>TimeSettingDialog</name>
|
||||
|
||||
+14
@@ -193,12 +193,16 @@
|
||||
<message>
|
||||
<location filename="countervarset.ui" line="84"/>
|
||||
<location filename="countervarset.ui" line="273"/>
|
||||
<location filename="CounterVarSet.cpp" line="168"/>
|
||||
<location filename="CounterVarSet.cpp" line="183"/>
|
||||
<source>计数器1</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="countervarset.ui" line="112"/>
|
||||
<location filename="countervarset.ui" line="655"/>
|
||||
<location filename="CounterVarSet.cpp" line="176"/>
|
||||
<location filename="CounterVarSet.cpp" line="185"/>
|
||||
<source>计数器2</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
@@ -5958,6 +5962,16 @@ p, li { white-space: pre-wrap; }
|
||||
<source>是否保存文件?</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="testprintwidget.cpp" line="1055"/>
|
||||
<source>警告</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="testprintwidget.cpp" line="1055"/>
|
||||
<source>无法创建更多计数器</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>TimeSettingDialog</name>
|
||||
|
||||
@@ -193,12 +193,16 @@
|
||||
<message>
|
||||
<location filename="countervarset.ui" line="84"/>
|
||||
<location filename="countervarset.ui" line="273"/>
|
||||
<location filename="CounterVarSet.cpp" line="168"/>
|
||||
<location filename="CounterVarSet.cpp" line="183"/>
|
||||
<source>计数器1</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="countervarset.ui" line="112"/>
|
||||
<location filename="countervarset.ui" line="655"/>
|
||||
<location filename="CounterVarSet.cpp" line="176"/>
|
||||
<location filename="CounterVarSet.cpp" line="185"/>
|
||||
<source>计数器2</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
@@ -5958,6 +5962,16 @@ p, li { white-space: pre-wrap; }
|
||||
<source>是否保存文件?</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="testprintwidget.cpp" line="1055"/>
|
||||
<source>警告</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="testprintwidget.cpp" line="1055"/>
|
||||
<source>无法创建更多计数器</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>TimeSettingDialog</name>
|
||||
|
||||
@@ -201,12 +201,16 @@
|
||||
<message>
|
||||
<location filename="countervarset.ui" line="84"/>
|
||||
<location filename="countervarset.ui" line="273"/>
|
||||
<location filename="CounterVarSet.cpp" line="168"/>
|
||||
<location filename="CounterVarSet.cpp" line="183"/>
|
||||
<source>计数器1</source>
|
||||
<translation>카운터1</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="countervarset.ui" line="112"/>
|
||||
<location filename="countervarset.ui" line="655"/>
|
||||
<location filename="CounterVarSet.cpp" line="176"/>
|
||||
<location filename="CounterVarSet.cpp" line="185"/>
|
||||
<source>计数器2</source>
|
||||
<translation>카운터2</translation>
|
||||
</message>
|
||||
@@ -11351,6 +11355,16 @@ configuration.</source>
|
||||
<source>是否保存文件?</source>
|
||||
<translation>파일을 저장하시겠습니까?</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="testprintwidget.cpp" line="1055"/>
|
||||
<source>警告</source>
|
||||
<translation>경고</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="testprintwidget.cpp" line="1055"/>
|
||||
<source>无法创建更多计数器</source>
|
||||
<translation>더 이상 카운터를 생성할 수 없습니다</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>TextEditOption</name>
|
||||
|
||||
@@ -125,7 +125,7 @@ void PicCounterItem::setCustomAttrs(const QXmlStreamAttributes &attrs)
|
||||
|
||||
ok = false;
|
||||
int displayNum = displayNumRef.toInt(&ok);
|
||||
if(!ok || displayNum <= 0) {
|
||||
if(!ok /*|| displayNum <= 0*/) {
|
||||
qWarning() << "Invalied counter display number: " << displayNum;
|
||||
return;
|
||||
}
|
||||
|
||||
+14
@@ -193,12 +193,16 @@
|
||||
<message>
|
||||
<location filename="countervarset.ui" line="84"/>
|
||||
<location filename="countervarset.ui" line="273"/>
|
||||
<location filename="CounterVarSet.cpp" line="168"/>
|
||||
<location filename="CounterVarSet.cpp" line="183"/>
|
||||
<source>计数器1</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="countervarset.ui" line="112"/>
|
||||
<location filename="countervarset.ui" line="655"/>
|
||||
<location filename="CounterVarSet.cpp" line="176"/>
|
||||
<location filename="CounterVarSet.cpp" line="185"/>
|
||||
<source>计数器2</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
@@ -5958,6 +5962,16 @@ p, li { white-space: pre-wrap; }
|
||||
<source>是否保存文件?</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="testprintwidget.cpp" line="1055"/>
|
||||
<source>警告</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="testprintwidget.cpp" line="1055"/>
|
||||
<source>无法创建更多计数器</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>TimeSettingDialog</name>
|
||||
|
||||
+21
-2
@@ -146,7 +146,7 @@ TestPrintWidget::TestPrintWidget(QWidget* parent)
|
||||
vm.letterSpace = 1;
|
||||
vm.cnt1Settings = m_printSettingModel.cnt1Settings;
|
||||
vm.cnt2Settings = m_printSettingModel.cnt2Settings;
|
||||
emit sig_showEditCounter(vm);
|
||||
emit sig_showEditCounter(vm, false);
|
||||
});
|
||||
|
||||
connect(ui.btnBarcode, &QPushButton::clicked, [this](){
|
||||
@@ -715,7 +715,7 @@ void TestPrintWidget::onBtnItemConfigClicked()
|
||||
vm.charWidth = counterItem->charWidth();
|
||||
vm.cnt1Settings = m_printSettingModel.cnt1Settings;
|
||||
vm.cnt2Settings = m_printSettingModel.cnt2Settings;
|
||||
emit sig_showEditCounter(vm);
|
||||
emit sig_showEditCounter(vm, true);
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -1050,6 +1050,12 @@ void TestPrintWidget::addCounterItem(CounterViewModel vm, QSharedPointer<QFont>
|
||||
}
|
||||
}
|
||||
|
||||
// 最多两个计数器
|
||||
if (getCounterNum() >= 2 && !flag) {
|
||||
QMessageBox::warning(this, tr("警告"),tr("无法创建更多计数器"));
|
||||
return;
|
||||
}
|
||||
|
||||
QVector<int> currVals{vm.cnt1Settings.currValue, vm.cnt2Settings.currValue};
|
||||
|
||||
QFont font;
|
||||
@@ -1100,6 +1106,19 @@ void TestPrintWidget::addCounterItem(CounterViewModel vm, QSharedPointer<QFont>
|
||||
updateCountersCurrVal(currVals);
|
||||
}
|
||||
|
||||
int TestPrintWidget::getCounterNum()
|
||||
{
|
||||
int count = 0;
|
||||
const QList<QGraphicsItem *> items = pPicScene->items();
|
||||
for (QGraphicsItem *it : items) {
|
||||
if (auto *counter = dynamic_cast<PicCounterItem *>(it)) {
|
||||
Q_UNUSED(counter);
|
||||
++count;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
QString TestPrintWidget::currentFile()
|
||||
{
|
||||
return xmlfileName;
|
||||
|
||||
+3
-1
@@ -58,6 +58,8 @@ public:
|
||||
|
||||
void addCounterItem(CounterViewModel vm, QSharedPointer<QFont> font = nullptr);
|
||||
|
||||
int getCounterNum();
|
||||
|
||||
QString currentFile();
|
||||
|
||||
// 更新编辑界面内所有计数器的当前值
|
||||
@@ -176,7 +178,7 @@ signals:
|
||||
|
||||
void sendButtonClickedSignal(int index);
|
||||
|
||||
void sig_showEditCounter(CounterViewModel viewModel);
|
||||
void sig_showEditCounter(CounterViewModel viewModel, bool isChange);
|
||||
|
||||
// 用户请求打开日期类型图元编辑窗口时发送此信号
|
||||
void sig_showEditDateTime(DateItemModel dateModel, TextItemModel textModel);
|
||||
|
||||
@@ -193,12 +193,16 @@
|
||||
<message>
|
||||
<location filename="countervarset.ui" line="84"/>
|
||||
<location filename="countervarset.ui" line="273"/>
|
||||
<location filename="CounterVarSet.cpp" line="168"/>
|
||||
<location filename="CounterVarSet.cpp" line="183"/>
|
||||
<source>计数器1</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="countervarset.ui" line="112"/>
|
||||
<location filename="countervarset.ui" line="655"/>
|
||||
<location filename="CounterVarSet.cpp" line="176"/>
|
||||
<location filename="CounterVarSet.cpp" line="185"/>
|
||||
<source>计数器2</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
@@ -5958,6 +5962,16 @@ p, li { white-space: pre-wrap; }
|
||||
<source>是否保存文件?</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="testprintwidget.cpp" line="1055"/>
|
||||
<source>警告</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="testprintwidget.cpp" line="1055"/>
|
||||
<source>无法创建更多计数器</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>TimeSettingDialog</name>
|
||||
|
||||
@@ -193,12 +193,16 @@
|
||||
<message>
|
||||
<location filename="countervarset.ui" line="84"/>
|
||||
<location filename="countervarset.ui" line="273"/>
|
||||
<location filename="CounterVarSet.cpp" line="168"/>
|
||||
<location filename="CounterVarSet.cpp" line="183"/>
|
||||
<source>计数器1</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="countervarset.ui" line="112"/>
|
||||
<location filename="countervarset.ui" line="655"/>
|
||||
<location filename="CounterVarSet.cpp" line="176"/>
|
||||
<location filename="CounterVarSet.cpp" line="185"/>
|
||||
<source>计数器2</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
@@ -5958,6 +5962,16 @@ p, li { white-space: pre-wrap; }
|
||||
<source>是否保存文件?</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="testprintwidget.cpp" line="1055"/>
|
||||
<source>警告</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="testprintwidget.cpp" line="1055"/>
|
||||
<source>无法创建更多计数器</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>TimeSettingDialog</name>
|
||||
|
||||
@@ -193,12 +193,16 @@
|
||||
<message>
|
||||
<location filename="countervarset.ui" line="84"/>
|
||||
<location filename="countervarset.ui" line="273"/>
|
||||
<location filename="CounterVarSet.cpp" line="168"/>
|
||||
<location filename="CounterVarSet.cpp" line="183"/>
|
||||
<source>计数器1</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="countervarset.ui" line="112"/>
|
||||
<location filename="countervarset.ui" line="655"/>
|
||||
<location filename="CounterVarSet.cpp" line="176"/>
|
||||
<location filename="CounterVarSet.cpp" line="185"/>
|
||||
<source>计数器2</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
@@ -5958,6 +5962,16 @@ p, li { white-space: pre-wrap; }
|
||||
<source>是否保存文件?</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="testprintwidget.cpp" line="1055"/>
|
||||
<source>警告</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="testprintwidget.cpp" line="1055"/>
|
||||
<source>无法创建更多计数器</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>TimeSettingDialog</name>
|
||||
|
||||
Reference in New Issue
Block a user