Files

157 lines
6.0 KiB
C++
Raw Permalink Normal View History

#include "Amount.h"
#include <QIcon>
#include "Global.h"
Amount::Amount(QWidget *parent)
: QWidget(parent)
{
ui.setupUi(this);
// 设置窗口图标
this->setWindowIcon(QIcon(":/images/Images/client.ico"));
// 设置窗口标题
this->setWindowTitle("注单金额判断处理");
// 设置为对话框窗口
setWindowFlags(Qt::Dialog);
// 设置窗口仅有关闭按钮
setWindowFlags(Qt::WindowCloseButtonHint);
// 设置窗口固定大小
this->setFixedSize(460,700);
ui.originalAmountLowerCheckBox->setChecked(g_config->originalAmountLowerGiveUpEnable());
ui.originalAmountLowerEdit->setText(QString::number(g_config->originalAmountLower()));
ui.originalAmountHigherCheckBox->setChecked(g_config->originalAmountHigherGiveUpEnable());
ui.originalAmountHigherEdit->setText(QString::number(g_config->originalAmountHigher()));
ui.amountLowerCheckBox->setChecked(g_config->amountLowerEnable());
ui.amountLowerEdit->setText(QString::number(g_config->amountLower()));
ui.amountLowerAddToRadio->setChecked(g_config->amountLowerAddToEnable());
ui.amountLowerAddToEdit->setText(QString::number(g_config->amountLowerAddTo()));
ui.amountLowerGiveUpRadio->setChecked(g_config->amountLowerGiveUpEnable());
ui.amountHigherCheckBox->setChecked(g_config->amountHigherEnable());
ui.amountHigherEdit->setText(QString::number(g_config->amountHigher()));
ui.amountHigherSubToRadio->setChecked(g_config->amountHigherSubToEnable());
ui.amountHigherSubToEdit->setText(QString::number(g_config->amountHigherSubTo()));
ui.amountHigherGiveUpRadio->setChecked(g_config->amountHigherGiveUpEnable());
if (g_config->amount_less_than_platform() == 0)
{
ui.amount_less_add->setChecked(true);
}
else
{
ui.amount_less_give_up->setChecked(true);
}
if (g_config->amount_more_than_platform() == 0)
{
ui.amount_more_sub->setChecked(true);
}
else
{
ui.amount_more_give_up->setChecked(true);
}
//ui.halfAdjustEdit->setText(QString::number(g_config->carry()));
//ui.halfAdjustComboBox->setCurrentIndex(g_config->carryIndex());
//ui.halfAdjustRadio->setChecked(g_config->carryHalfAdjustEnable());
//ui.roundingRadio->setChecked(g_config->carryRoundingEnable());
//ui.minEdit->setText(QString::number(g_config->amountMin()));
//ui.maxEdit->setText(QString::number(g_config->amountMax()));
//connect(ui.halfAdjustEdit,&QLineEdit::textChanged,this,&Amount::slotCalc);
//connect(ui.halfAdjustComboBox, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &Amount::slotCalc);
//connect(ui.halfAdjustRadio, &QRadioButton::clicked, this, &Amount::slotCalc);
//connect(ui.roundingRadio, &QRadioButton::clicked, this, &Amount::slotCalc);
}
Amount::~Amount()
{}
void Amount::slotCalc()
{
// 保存
g_config->setOriginalAmountLowerGiveUpEnable(ui.originalAmountLowerCheckBox->isChecked());
g_config->setOriginalAmountLower(ui.originalAmountLowerEdit->text().toInt());
g_config->setOriginalAmountHigherGiveUpEnable(ui.originalAmountHigherCheckBox->isChecked());
g_config->setOriginalAmountHigher(ui.originalAmountHigherEdit->text().toInt());
g_config->setAmountLowerEnable(ui.amountLowerCheckBox->isChecked());
g_config->setAmountLower(ui.amountLowerEdit->text().toInt());
g_config->setAmountLowerAddToEnable(ui.amountLowerAddToRadio->isChecked());
g_config->setAmountLowerAddTo(ui.amountLowerAddToEdit->text().toInt());
g_config->setAmountLowerGiveUpEnable(ui.amountLowerGiveUpRadio->isChecked());
g_config->setAmountHigherEnable(ui.amountHigherCheckBox->isChecked());
g_config->setAmountHigher(ui.amountHigherEdit->text().toInt());
g_config->setAmountHigherSubToEnable(ui.amountHigherSubToRadio->isChecked());
g_config->setAmountHigherSubTo(ui.amountHigherSubToEdit->text().toInt());
g_config->setAmountHigherGiveUpEnable(ui.amountHigherGiveUpRadio->isChecked());
if (ui.amount_less_add->isChecked())
{
g_config->set_amount_less_than_platform(0);
}
else
{
g_config->set_amount_less_than_platform(1);
}
if (ui.amount_more_sub->isChecked())
{
g_config->set_amount_more_than_platform(0);
}
else
{
g_config->set_amount_more_than_platform(1);
}
//g_config->setCarry(ui.halfAdjustEdit->text().toInt());
//g_config->setCarryIndex(ui.halfAdjustComboBox->currentIndex());
//g_config->setCarryHalfAdjustEnable(ui.halfAdjustRadio->isChecked());
//g_config->setCarryRoundingEnable(ui.roundingRadio->isChecked());
//g_config->setAmountMin(ui.minEdit->text().toInt());
//g_config->setAmountMax(ui.maxEdit->text().toInt());
//ui.result->setText("结果:" + g_config->carry(ui.halfAdjustEdit->text()));
}
void Amount::closeEvent(QCloseEvent * event)
{
g_config->setOriginalAmountLowerGiveUpEnable(ui.originalAmountLowerCheckBox->isChecked());
g_config->setOriginalAmountLower(ui.originalAmountLowerEdit->text().toInt());
g_config->setOriginalAmountHigherGiveUpEnable(ui.originalAmountHigherCheckBox->isChecked());
g_config->setOriginalAmountHigher(ui.originalAmountHigherEdit->text().toInt());
g_config->setAmountLowerEnable(ui.amountLowerCheckBox->isChecked());
g_config->setAmountLower(ui.amountLowerEdit->text().toInt());
g_config->setAmountLowerAddToEnable(ui.amountLowerAddToRadio->isChecked());
g_config->setAmountLowerAddTo(ui.amountLowerAddToEdit->text().toInt());
g_config->setAmountLowerGiveUpEnable(ui.amountLowerGiveUpRadio->isChecked());
g_config->setAmountHigherEnable(ui.amountHigherCheckBox->isChecked());
g_config->setAmountHigher(ui.amountHigherEdit->text().toInt());
g_config->setAmountHigherSubToEnable(ui.amountHigherSubToRadio->isChecked());
g_config->setAmountHigherSubTo(ui.amountHigherSubToEdit->text().toInt());
g_config->setAmountHigherGiveUpEnable(ui.amountHigherGiveUpRadio->isChecked());
//g_config->setCarry(ui.halfAdjustEdit->text().toInt());
//g_config->setCarryIndex(ui.halfAdjustComboBox->currentIndex());
//g_config->setCarryHalfAdjustEnable(ui.halfAdjustRadio->isChecked());
//g_config->setCarryRoundingEnable(ui.roundingRadio->isChecked());
//g_config->setAmountMin(ui.minEdit->text().toInt());
//g_config->setAmountMax(ui.maxEdit->text().toInt());
}