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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user