Commit 3e83e27d by gujin.wang

添加核销界面文本换行显示

parent 454a4b3b
......@@ -25,7 +25,8 @@ void ConsumOkDialog::showConsumOk(const QString& act_name, const QString& code_n
// v.setGeometry( 0,0,350,470);
v.ui->labCode->setText( coupon);
v.ui->labActName->setText( act_name);
v.ui->labActName->setText(v.GetLineFeed(act_name));
v.ui->labTime->setText( time_name);
v.ui->labCodeName->setText( code_name);
v.exec();
......@@ -52,3 +53,24 @@ void ConsumOkDialog::mouseReleaseEvent(QMouseEvent *e)
{
mouse_pressed = true;
}
QString ConsumOkDialog::GetLineFeed(const QString &str)
{
int w = ui->labActName->width();
QFontMetrics fm = ui->labActName->fontMetrics();
QString tmp, newStr;
for(int i = 0; i < str.length(); i++)
{
tmp.append(str.at(i));
int nw = fm.width(tmp);
if(nw >= w - 20)
{
tmp.append(QChar::LineFeed);
newStr.append(tmp);
tmp.clear();
}
}
if(!tmp.isEmpty())
newStr.append(tmp);
return newStr;
}
......@@ -23,6 +23,9 @@ protected:
void mouseReleaseEvent(QMouseEvent* e);
private:
QString GetLineFeed(const QString& str);
private:
Ui::ConsumOkDialog *ui;
bool mouse_pressed;
QPoint movePosition;
......
......@@ -153,9 +153,9 @@
<property name="geometry">
<rect>
<x>0</x>
<y>105</y>
<y>30</y>
<width>330</width>
<height>80</height>
<height>150</height>
</rect>
</property>
<property name="minimumSize">
......@@ -167,14 +167,14 @@
<property name="maximumSize">
<size>
<width>330</width>
<height>80</height>
<height>150</height>
</size>
</property>
<property name="text">
<string>5元脆骨鸡</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
<set>Qt::AlignHCenter|Qt::AlignTop</set>
</property>
</widget>
<widget class="QLabel" name="labCodeName">
......
......@@ -106,7 +106,7 @@ void ConsumptionDialog::setData(const QString& act_name, const QString& code_nam
{
ui->labCode->setText( coupon);
ui->labCodeName->setText( code_name);
ui->labActName->setText( act_name);
ui->labActName->setText(GetLineFeed(act_name));
ui->labTime->setText( time_name);
}
......@@ -133,3 +133,24 @@ void ConsumptionDialog::mouseReleaseEvent(QMouseEvent *e)
mouse_pressed = false;
return QDialog::mouseReleaseEvent(e);
}
QString ConsumptionDialog::GetLineFeed(const QString &str)
{
int w = ui->labActName->width();
QFontMetrics fm = ui->labActName->fontMetrics();
QString tmp, newStr;
for(int i = 0; i < str.length(); i++)
{
tmp.append(str.at(i));
int nw = fm.width(tmp);
if(nw >= w - 20)
{
tmp.append(QChar::LineFeed);
newStr.append(tmp);
tmp.clear();
}
}
if(!tmp.isEmpty())
newStr.append(tmp);
return newStr;
}
\ No newline at end of file
......@@ -25,6 +25,7 @@ public:
private slots:
void OnTimeout();
QString GetLineFeed(const QString& str);
protected:
void mousePressEvent(QMouseEvent* e);
......
......@@ -18,6 +18,8 @@ CouponKeypad::CouponKeypad(QWidget *parent, Qt::WindowFlags f) :
connect(ui->d7, SIGNAL(clicked(bool)), SLOT(onDigitClicked()));
connect(ui->d8, SIGNAL(clicked(bool)), SLOT(onDigitClicked()));
connect(ui->d9, SIGNAL(clicked(bool)), SLOT(onDigitClicked()));
connect(ui->text, SIGNAL(returnPressed()), this, SLOT(on_btnOK_clicked()));
}
CouponKeypad::~CouponKeypad()
......
......@@ -49,7 +49,7 @@ void ErrCodeDialog::showForExpird(const QString& act_name, const QString& code_n
v.ui->labCode->setText(coupon );
v.ui->labTime->setText( time_name);
v.ui->labActName->setText( act_name);
v.ui->labActName->setText(v.GetLineFeed(act_name));
v.ui->labCodeName->setText( code_name);
v.exec();
......@@ -69,26 +69,7 @@ void ErrCodeDialog::showForErr(const QString& coupon, const QString& mess, QWidg
v.ui->labActName->setVisible( true);
v.ui->labCode->setText(coupon );
v.ui->labActName->setText( mess);
v.exec();
}
void ErrCodeDialog::showForMismatch(const QString &coupon, const QString &mess, QWidget *parent)
{
ErrCodeDialog v(parent);
// v.setGeometry( 0,0,350,470);
v.ui->topInvalidWidget->setObjectName("topExpirdWidget");
v.ui->topInvalidWidget->setStyleSheet( v.ui->topInvalidWidget->styleSheet());
v.ui->labTime->setVisible( false);
v.ui->labCodeName->setVisible( false);
v.ui->labFolat->setVisible( false);
v.ui->labActName->setVisible( true);
v.ui->labCode->setText(coupon );
v.ui->labActName->setText( mess);
v.ui->labActName->setText(v.GetLineFeed(mess));
v.exec();
}
......@@ -115,3 +96,24 @@ void ErrCodeDialog::mouseReleaseEvent(QMouseEvent *e)
{
mouse_pressed = false;
}
QString ErrCodeDialog::GetLineFeed(const QString &str)
{
int w = ui->labActName->width();
QFontMetrics fm = ui->labActName->fontMetrics();
QString tmp, newStr;
for(int i = 0; i < str.length(); i++)
{
tmp.append(str.at(i));
int nw = fm.width(tmp);
if(nw >= w - 20)
{
tmp.append(QChar::LineFeed);
newStr.append(tmp);
tmp.clear();
}
}
if(!tmp.isEmpty())
newStr.append(tmp);
return newStr;
}
\ No newline at end of file
......@@ -19,7 +19,6 @@ public:
static void showForInvalid(const QString& coupon, QWidget *parent = 0);
static void showForExpird(const QString& act_name, const QString& code_name, const QString& time_name, const QString& coupon, QWidget *parent = 0);
static void showForErr(const QString& coupon, const QString& mess, QWidget *parent = 0);
static void showForMismatch(const QString& coupon, const QString& mess, QWidget *parent = 0);
protected:
void mousePressEvent(QMouseEvent *e);
......@@ -27,6 +26,9 @@ protected:
void mouseReleaseEvent(QMouseEvent *e);
private:
QString GetLineFeed(const QString& str);
private:
Ui::ErrCodeDialog *ui;
bool mouse_pressed;
QPoint movePosition;
......
......@@ -348,6 +348,11 @@ QJsonObject FMPRedeem::ShowForUnConsum(QJsonObject json)
redeemResult["discount"] = SearchJsonObject(json, "amount").toInt();
redeemResult["couponType"] = "20003";
}
else if(couponType == 3)
{
redeemResult["discount"] = SearchJsonObject(json, "amount").toInt();
redeemResult["couponType"] = "20005";
}
redeemResult["couponDesc"] = act_name;
redeemResult["code"] = coupon;
redeemResult["redeem_json"] = _redeem_json;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment