Commit 3e83e27d by gujin.wang

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

parent 454a4b3b
...@@ -25,7 +25,8 @@ void ConsumOkDialog::showConsumOk(const QString& act_name, const QString& code_n ...@@ -25,7 +25,8 @@ void ConsumOkDialog::showConsumOk(const QString& act_name, const QString& code_n
// v.setGeometry( 0,0,350,470); // v.setGeometry( 0,0,350,470);
v.ui->labCode->setText( coupon); 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->labTime->setText( time_name);
v.ui->labCodeName->setText( code_name); v.ui->labCodeName->setText( code_name);
v.exec(); v.exec();
...@@ -52,3 +53,24 @@ void ConsumOkDialog::mouseReleaseEvent(QMouseEvent *e) ...@@ -52,3 +53,24 @@ void ConsumOkDialog::mouseReleaseEvent(QMouseEvent *e)
{ {
mouse_pressed = true; 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: ...@@ -23,6 +23,9 @@ protected:
void mouseReleaseEvent(QMouseEvent* e); void mouseReleaseEvent(QMouseEvent* e);
private: private:
QString GetLineFeed(const QString& str);
private:
Ui::ConsumOkDialog *ui; Ui::ConsumOkDialog *ui;
bool mouse_pressed; bool mouse_pressed;
QPoint movePosition; QPoint movePosition;
......
...@@ -153,9 +153,9 @@ ...@@ -153,9 +153,9 @@
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
<y>105</y> <y>30</y>
<width>330</width> <width>330</width>
<height>80</height> <height>150</height>
</rect> </rect>
</property> </property>
<property name="minimumSize"> <property name="minimumSize">
...@@ -167,14 +167,14 @@ ...@@ -167,14 +167,14 @@
<property name="maximumSize"> <property name="maximumSize">
<size> <size>
<width>330</width> <width>330</width>
<height>80</height> <height>150</height>
</size> </size>
</property> </property>
<property name="text"> <property name="text">
<string>5元脆骨鸡</string> <string>5元脆骨鸡</string>
</property> </property>
<property name="alignment"> <property name="alignment">
<set>Qt::AlignCenter</set> <set>Qt::AlignHCenter|Qt::AlignTop</set>
</property> </property>
</widget> </widget>
<widget class="QLabel" name="labCodeName"> <widget class="QLabel" name="labCodeName">
......
...@@ -106,7 +106,7 @@ void ConsumptionDialog::setData(const QString& act_name, const QString& code_nam ...@@ -106,7 +106,7 @@ void ConsumptionDialog::setData(const QString& act_name, const QString& code_nam
{ {
ui->labCode->setText( coupon); ui->labCode->setText( coupon);
ui->labCodeName->setText( code_name); ui->labCodeName->setText( code_name);
ui->labActName->setText( act_name); ui->labActName->setText(GetLineFeed(act_name));
ui->labTime->setText( time_name); ui->labTime->setText( time_name);
} }
...@@ -132,4 +132,25 @@ void ConsumptionDialog::mouseReleaseEvent(QMouseEvent *e) ...@@ -132,4 +132,25 @@ void ConsumptionDialog::mouseReleaseEvent(QMouseEvent *e)
{ {
mouse_pressed = false; mouse_pressed = false;
return QDialog::mouseReleaseEvent(e); 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: ...@@ -25,6 +25,7 @@ public:
private slots: private slots:
void OnTimeout(); void OnTimeout();
QString GetLineFeed(const QString& str);
protected: protected:
void mousePressEvent(QMouseEvent* e); void mousePressEvent(QMouseEvent* e);
......
...@@ -18,6 +18,8 @@ CouponKeypad::CouponKeypad(QWidget *parent, Qt::WindowFlags f) : ...@@ -18,6 +18,8 @@ CouponKeypad::CouponKeypad(QWidget *parent, Qt::WindowFlags f) :
connect(ui->d7, SIGNAL(clicked(bool)), SLOT(onDigitClicked())); connect(ui->d7, SIGNAL(clicked(bool)), SLOT(onDigitClicked()));
connect(ui->d8, SIGNAL(clicked(bool)), SLOT(onDigitClicked())); connect(ui->d8, SIGNAL(clicked(bool)), SLOT(onDigitClicked()));
connect(ui->d9, 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() CouponKeypad::~CouponKeypad()
...@@ -56,9 +58,9 @@ void CouponKeypad::onDigitClicked() ...@@ -56,9 +58,9 @@ void CouponKeypad::onDigitClicked()
void CouponKeypad::mousePressEvent(QMouseEvent *e) void CouponKeypad::mousePressEvent(QMouseEvent *e)
{ {
mouse_pressed = true; mouse_pressed = true;
movePosition = e->globalPos() - pos(); movePosition = e->globalPos() - pos();
return QDialog::mousePressEvent(e); return QDialog::mousePressEvent(e);
} }
void CouponKeypad::mouseMoveEvent(QMouseEvent *e) void CouponKeypad::mouseMoveEvent(QMouseEvent *e)
......
...@@ -49,7 +49,7 @@ void ErrCodeDialog::showForExpird(const QString& act_name, const QString& code_n ...@@ -49,7 +49,7 @@ void ErrCodeDialog::showForExpird(const QString& act_name, const QString& code_n
v.ui->labCode->setText(coupon ); v.ui->labCode->setText(coupon );
v.ui->labTime->setText( time_name); 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.ui->labCodeName->setText( code_name);
v.exec(); v.exec();
...@@ -69,26 +69,7 @@ void ErrCodeDialog::showForErr(const QString& coupon, const QString& mess, QWidg ...@@ -69,26 +69,7 @@ void ErrCodeDialog::showForErr(const QString& coupon, const QString& mess, QWidg
v.ui->labActName->setVisible( true); v.ui->labActName->setVisible( true);
v.ui->labCode->setText(coupon ); v.ui->labCode->setText(coupon );
v.ui->labActName->setText( mess); v.ui->labActName->setText(v.GetLineFeed(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.exec(); v.exec();
} }
...@@ -114,4 +95,25 @@ void ErrCodeDialog::mouseMoveEvent(QMouseEvent *e) ...@@ -114,4 +95,25 @@ void ErrCodeDialog::mouseMoveEvent(QMouseEvent *e)
void ErrCodeDialog::mouseReleaseEvent(QMouseEvent *e) void ErrCodeDialog::mouseReleaseEvent(QMouseEvent *e)
{ {
mouse_pressed = false; 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: ...@@ -19,7 +19,6 @@ public:
static void showForInvalid(const QString& coupon, QWidget *parent = 0); 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 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 showForErr(const QString& coupon, const QString& mess, QWidget *parent = 0);
static void showForMismatch(const QString& coupon, const QString& mess, QWidget *parent = 0);
protected: protected:
void mousePressEvent(QMouseEvent *e); void mousePressEvent(QMouseEvent *e);
...@@ -27,6 +26,9 @@ protected: ...@@ -27,6 +26,9 @@ protected:
void mouseReleaseEvent(QMouseEvent *e); void mouseReleaseEvent(QMouseEvent *e);
private: private:
QString GetLineFeed(const QString& str);
private:
Ui::ErrCodeDialog *ui; Ui::ErrCodeDialog *ui;
bool mouse_pressed; bool mouse_pressed;
QPoint movePosition; QPoint movePosition;
......
...@@ -348,6 +348,11 @@ QJsonObject FMPRedeem::ShowForUnConsum(QJsonObject json) ...@@ -348,6 +348,11 @@ QJsonObject FMPRedeem::ShowForUnConsum(QJsonObject json)
redeemResult["discount"] = SearchJsonObject(json, "amount").toInt(); redeemResult["discount"] = SearchJsonObject(json, "amount").toInt();
redeemResult["couponType"] = "20003"; redeemResult["couponType"] = "20003";
} }
else if(couponType == 3)
{
redeemResult["discount"] = SearchJsonObject(json, "amount").toInt();
redeemResult["couponType"] = "20005";
}
redeemResult["couponDesc"] = act_name; redeemResult["couponDesc"] = act_name;
redeemResult["code"] = coupon; redeemResult["code"] = coupon;
redeemResult["redeem_json"] = _redeem_json; 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