Commit b7bba6b0 by 刘帅

加上充值扫码界面

parent bec489a4
HK_McDonalds test json
支付
{
"ver":2,
"operator_id":"00000002",
"reqtype":72,
"station_id":1,
"store_id":"208888",
"trans_id":110,
"business_date":"20150701",
"transactions":[
{
"amount":1974,
"undis_amount":0,
"code":"289631206996295092",
"products":[
{
"consume_num":1,
"sales_type":"FREE",
"price":1000,
"pid":"0079020",
"seq":1
},
{
"consume_num":1,
"sales_type":"NORMAL",
"price":1974,
"pid":"0077842",
"seq":2
}
]
}
],
"checkValue":32.12
}
\ No newline at end of file
<RCC>
<qresource prefix="/new/recharge">
<file>res/bg_sanning.png</file>
<file>res/close.png</file>
<file>res/scanning_bar.png</file>
</qresource>
</RCC>
File added
#include "widget.h"
#include "ui_widget.h"
#include <QDebug>
#include <QPainter>
#include <QMessageBox>
#include <QJsonObject>
#include <Windows.h>
#pragma comment(lib, "user32.lib")
Widget::Widget(QWidget *parent) :
QWidget(parent),animationUp(false),
ui(new Ui::Widget)
{
ui->setupUi(this);
connect(ui->btnClose,&QPushButton::clicked,this,&Widget::close);
setWindowFlags(windowFlags() | Qt::FramelessWindowHint);
setAttribute(Qt::WA_TranslucentBackground);
scanningBar = new QPropertyAnimation(ui->labScaningBar,"geometry",this);
connect(scanningBar,&QPropertyAnimation::finished,this,&Widget::animationFinished);
scanningBar->setStartValue( QRect( 0,320,330,33));
scanningBar->setEndValue( QRect( 0,400, 330,33));
scanningBar->setDuration(1500);
scanningBar->start();
ui->code->setVisible(false);
ui->code->setFocus();
}
Widget::~Widget()
{
delete ui;
}
void Widget::show()
{
setVisible(true);
setAttribute(Qt::WA_ShowModal, true);
showNormal();
HWND hForeWnd = ::GetForegroundWindow();
DWORD dwForeID = ::GetWindowThreadProcessId(hForeWnd,NULL);
DWORD dwCurID = ::GetCurrentThreadId();
::AttachThreadInput(dwCurID,dwForeID,TRUE);
::SetForegroundWindow((HWND)effectiveWinId());
::SetWindowPos( (HWND)effectiveWinId(), HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW);
showNormal();
::SetForegroundWindow((HWND)effectiveWinId());
::AttachThreadInput(dwCurID,dwForeID,FALSE);
QWidget::show();
}
void Widget::paintEvent(QPaintEvent *)
{
QStyleOption opt;
opt.init(this);
QPainter p(this);
style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
}
void Widget::keyPressEvent(QKeyEvent *key)
{
qDebug()<<key->key() <<" keyPressEvent()";
if(key->key() == Qt::Key_Enter || key->key() == Qt::Key_Return)
{
qDebug()<<"Qt::Key_Enter or Qt::Key_Return";
emit getCode(strCode);
setVisible(false);
return;
}
strCode.append(key->text());
}
//QString Widget::getCode(QString strCode)
//{
// //strCode = ui->code->text();
// qDebug()<<strCode;
// ui->code->setText(QString());
// QString str = QString("\nrecharge amount: %1\npay code: %2\n").arg(1).arg(strCode);
// QMessageBox::information(this,"recharge confirm",str);
// //ui->amountInput->setFocus();
// QJsonObject rechargeObj;
// rechargeObj.insert("pos_ver",2);
// rechargeObj.insert("fm_cmd",10031);
// rechargeObj.insert("trans_id",QString());
// rechargeObj.insert("order_amount",0);
// rechargeObj.insert("paid_amount",0);
// rechargeObj.insert("undis_amount",0);
// rechargeObj.insert("barcode",QString());
// rechargeObj.insert("products",QJsonValue());
// qDebug()<<rechargeObj;
// return str;
//}
void Widget::close()
{
// qDebug()<<"close button cliecked!";
// qDebug()<<strCode;
// QString text = ui->code->text();
// OutputDebugString(text.toStdWString().c_str());
// qDebug()<<"ui->code->text() "<<text;
// emit getCode(strCode);
// emit QWidget::close();
}
void Widget::animationFinished()
{
scanningBar->setDuration(1500);
if(animationUp)
{
scanningBar->setStartValue( QRect( 0,320,330,33));
scanningBar->setEndValue( QRect( 0,400, 330,33));
}
else
{
scanningBar->setStartValue( QRect( 0,400, 330,33));
scanningBar->setEndValue( QRect( 0,320,330,33));
}
animationUp = !animationUp;
scanningBar->start();
}
#ifndef WIDGET_H
#define WIDGET_H
#include <QWidget>
#include <QEvent>
#include <QKeyEvent>
#include <QPropertyAnimation>
namespace Ui {
class Widget;
}
class Widget : public QWidget
{
Q_OBJECT
public:
explicit Widget(QWidget *parent = 0);
~Widget();
void show();
protected:
void paintEvent(QPaintEvent *);
void keyPressEvent(QKeyEvent *key);
public slots:
void close();
void animationFinished();
signals:
QString getCode(QString strCode);
private:
Ui::Widget *ui;
QString strCode;
QPropertyAnimation* scanningBar;
bool animationUp;
};
#endif // WIDGET_H
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Widget</class>
<widget class="QWidget" name="Widget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>330</width>
<height>450</height>
</rect>
</property>
<property name="windowTitle">
<string>MCRecharge</string>
</property>
<property name="styleSheet">
<string notr="true">#Widget{
border-radius:12px;
background-image: url(:/new/recharge/res/bg_sanning.png);
background-repeat:no-repeat;
}
#btnClose{
border: none;
background-image: url(:/new/recharge/res/close.png);
padding-left: 28px;
padding-bottom:28px;
}
#labScaningBar{
border: none;
background-image: url(:/new/recharge/res/scanning_bar.png);
}</string>
</property>
<widget class="QPushButton" name="btnClose">
<property name="geometry">
<rect>
<x>260</x>
<y>0</y>
<width>71</width>
<height>71</height>
</rect>
</property>
<property name="text">
<string/>
</property>
<property name="autoDefault">
<bool>false</bool>
</property>
</widget>
<widget class="QLineEdit" name="code">
<property name="enabled">
<bool>true</bool>
</property>
<property name="geometry">
<rect>
<x>30</x>
<y>300</y>
<width>271</width>
<height>21</height>
</rect>
</property>
<property name="frame">
<bool>true</bool>
</property>
</widget>
<widget class="QLabel" name="labScaningBar">
<property name="geometry">
<rect>
<x>0</x>
<y>320</y>
<width>330</width>
<height>30</height>
</rect>
</property>
<property name="text">
<string/>
</property>
</widget>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources/>
<connections/>
</ui>
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