Commit 616f5b65 by 刘帅

首次提交

parents
# This file is used to ignore files which are generated
# ----------------------------------------------------------------------------
*~
*.autosave
*.a
*.core
*.moc
*.o
*.obj
*.orig
*.rej
*.so
*.so.*
*_pch.h.cpp
*_resource.rc
*.qm
.#*
*.*#
core
!core/
tags
.DS_Store
*.debug
Makefile*
*.prl
*.app
moc_*.cpp
ui_*.h
qrc_*.cpp
Thumbs.db
*.res
*.rc
/.qmake.cache
/.qmake.stash
*.manifest
# qtcreator generated files
*.pro.user*
# xemacs temporary files
*.flc
# Vim temporary files
.*.swp
# Visual Studio generated files
*.ib_pdb_index
*.idb
*.ilk
*.pdb
*.sln
*.suo
*.vcproj
*vcproj.*.*.user
*.ncb
*.sdf
*.opensdf
*.vcxproj
*vcxproj.*
# MinGW generated files
*.Debug
*.Release
# Python byte code
*.pyc
# Binaries
# --------
*.exe
/bin/*
!/bin/*.txt
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>InputDialog</class>
<widget class="QDialog" name="InputDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>362</width>
<height>480</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgb(255, 255, 255);
border: none;
</string>
</property>
<widget class="QLineEdit" name="txtInput">
<property name="geometry">
<rect>
<x>30</x>
<y>40</y>
<width>300</width>
<height>41</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">border: 1 solid;
border-color: rgb(223, 0, 0);
font: bold 14px;
color: rgb(103, 103, 103);</string>
</property>
</widget>
<widget class="QWidget" name="">
<property name="geometry">
<rect>
<x>32</x>
<y>146</y>
<width>300</width>
<height>164</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QPushButton" name="btn1">
<property name="minimumSize">
<size>
<width>70</width>
<height>50</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">border: 1 solid rgb(140,140,140);
border-radius: 10px;
font: bold 14px;
color: rgb(103, 103, 103);
pressed-color:rgb(103,103,103);</string>
</property>
<property name="text">
<string>1</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QPushButton" name="btn2">
<property name="minimumSize">
<size>
<width>70</width>
<height>50</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">border: 1 solid rgb(140,140,140);
border-radius: 10px;
font: bold 14px;
color: rgb(103, 103, 103);</string>
</property>
<property name="text">
<string>2</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QPushButton" name="btn3">
<property name="minimumSize">
<size>
<width>70</width>
<height>50</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">border: 1 solid rgb(140,140,140);
border-radius: 10px;
font: bold 14px;
color: rgb(103, 103, 103);</string>
</property>
<property name="text">
<string>3</string>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QPushButton" name="btnback">
<property name="minimumSize">
<size>
<width>70</width>
<height>50</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">
border: 1 solid rgb(140,140,140);
background-image: url(:/c/daima/删.png);
background-repeat: repeat;
background-position:center;
border-radius: 10px;
font: bold 14px;
color: rgb(103, 103, 103);</string>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QPushButton" name="btn4">
<property name="minimumSize">
<size>
<width>70</width>
<height>50</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">border: 1 solid rgb(140,140,140);
border-radius: 10px;
font: bold 14px;
color: rgb(103, 103, 103);</string>
</property>
<property name="text">
<string>4</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QPushButton" name="btn5">
<property name="minimumSize">
<size>
<width>70</width>
<height>50</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">border: 1 solid rgb(140,140,140);
border-radius: 10px;
font: bold 14px;
color: rgb(103, 103, 103);</string>
</property>
<property name="text">
<string>5</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QPushButton" name="btn6">
<property name="minimumSize">
<size>
<width>70</width>
<height>50</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">border: 1 solid rgb(140,140,140);
border-radius: 10px;
font: bold 14px;
color: rgb(103, 103, 103);</string>
</property>
<property name="text">
<string>6</string>
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="QPushButton" name="btn0">
<property name="minimumSize">
<size>
<width>70</width>
<height>50</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">border: 1 solid rgb(140,140,140);
border-radius: 10px;
font: bold 14px;
color: rgb(103, 103, 103);</string>
</property>
<property name="text">
<string>0</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QPushButton" name="btn7">
<property name="minimumSize">
<size>
<width>70</width>
<height>50</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">border: 1 solid rgb(140,140,140);
border-radius: 10px;
font: bold 14px;
color: rgb(103, 103, 103);</string>
</property>
<property name="text">
<string>7</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QPushButton" name="btn8">
<property name="minimumSize">
<size>
<width>70</width>
<height>50</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">border: 1 solid rgb(140,140,140);
border-radius: 10px;
font: bold 14px;
color: rgb(103, 103, 103);</string>
</property>
<property name="text">
<string>8</string>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QPushButton" name="btn9">
<property name="minimumSize">
<size>
<width>70</width>
<height>50</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">border: 1 solid rgb(140,140,140);
border-radius: 10px;
font: bold 14px;
color: rgb(103, 103, 103);</string>
</property>
<property name="text">
<string>9</string>
</property>
</widget>
</item>
<item row="2" column="3">
<widget class="QPushButton" name="btnclear">
<property name="minimumSize">
<size>
<width>70</width>
<height>50</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">border: 1 solid rgb(140,140,140);
border-radius: 10px;
font: bold 14px;
color: rgb(103, 103, 103);</string>
</property>
<property name="text">
<string>清除</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="">
<property name="geometry">
<rect>
<x>31</x>
<y>350</y>
<width>302</width>
<height>52</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QPushButton" name="pushButton">
<property name="minimumSize">
<size>
<width>120</width>
<height>50</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">border: 1 solid rgb(255, 170, 0);
color: rgb(255, 170, 0);</string>
</property>
<property name="text">
<string>返回</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>48</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="pushButton_2">
<property name="minimumSize">
<size>
<width>120</width>
<height>50</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">border: 1 solid rgb(255, 170, 0);
background-color: rgb(255, 170, 0);
color: rgb(0, 0, 0);</string>
</property>
<property name="text">
<string>查询</string>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
<resources>
<include location="picture.qrc"/>
</resources>
<connections/>
</ui>
<RCC>
<qresource prefix="c/daima">
<file>删.png</file>
<file>图层-23.png</file>
</qresource>
</RCC>
#include "consumokdialog.h"
#include "ui_consumokdialog.h"
ConsumOkDialog::ConsumOkDialog(QWidget *parent) :
LcMyDialog(parent),
ui(new Ui::ConsumOkDialog)
{
ui->setupUi(this);
connect( ui->btnConsumOk, &QPushButton::clicked, this, &ConsumOkDialog::accept);
}
ConsumOkDialog::~ConsumOkDialog()
{
delete ui;
}
void ConsumOkDialog::showConsumOk(const QString act_name,
const QString code_name,
const QString time_name,
const QString coupon,
QWidget *parent)
{
ConsumOkDialog v(parent);
v.setGeometry( 0,0,350,470);
v.ui->labCode->setText( coupon);
v.ui->labActName->setText( act_name);
v.ui->labTime->setText( time_name);
v.ui->labCodeName->setText( code_name);
v.exec();
}
//-------------------------------------------------
//
// Project created by 孙长鹏 2016-01-11T12:58:22
// Copyright (C) 2016 上海非码网络科技有限公司
// All rights reserved
//-------------------------------------------------
#ifndef CONSUMOKDIALOG_H
#define CONSUMOKDIALOG_H
#include <QDialog>
#include "lc_my_dialog.h"
namespace Ui {
class ConsumOkDialog;
}
class ConsumOkDialog : public LcMyDialog
{
Q_OBJECT
public:
explicit ConsumOkDialog(QWidget *parent = 0);
~ConsumOkDialog();
static void showConsumOk(const QString act_name,
const QString code_name,
const QString time_name,
const QString coupon,
QWidget *parent = 0);
private:
Ui::ConsumOkDialog *ui;
};
#endif // CONSUMOKDIALOG_H
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ConsumOkDialog</class>
<widget class="QDialog" name="ConsumOkDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>350</width>
<height>470</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>350</width>
<height>470</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>350</width>
<height>470</height>
</size>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<property name="styleSheet">
<string notr="true">#ConsumptionDialog{
border: none;
background-color: transparent;
}
#BgWidget{
border: none; background-color: transparent;
border-top-left-radius:12px;
border-top-right-radius:12px;
}
/**/
#topNoConsumeWidget{
background-image: url(:/res/bg_no_exchange.png);
border:none;
border-top-left-radius:12px;
border-top-right-radius:12px;
}
#topHasConsumeWidget{
background-image: url(:/res/bg_exchange.png);
border:none;
border-top-left-radius:12px;
border-top-right-radius:12px;
}
/**/
#labActName{
font: 75 45pt &quot;微软雅黑&quot;;
color: rgb(255, 255, 0);
}
#labCodeName{
font: 72 23pt &quot;微软雅黑&quot;;
color: rgb(146, 53, 50);
}
#labTime{
background-color: rgb(146, 53, 50);
font: 16pt &quot;微软雅黑&quot;;
color: rgb(255, 255, 255);
}
#labCode{
background-image: url(:/res/ma_bg.png);
font: 17pt &quot;微软雅黑&quot;;
color: rgb(33, 33, 33);
}
#btnCannel{
border:none;
background-image: url(:/res/btn_canel.png);
}
/**/
#btnConsumOk{
border:none;
background-image: url(:/res/consumption_ok.png);
}
/**/
</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>10</number>
</property>
<property name="topMargin">
<number>10</number>
</property>
<property name="rightMargin">
<number>10</number>
</property>
<property name="bottomMargin">
<number>10</number>
</property>
<item>
<widget class="QWidget" name="BgWidget" native="true">
<property name="minimumSize">
<size>
<width>330</width>
<height>450</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>330</width>
<height>450</height>
</size>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QWidget" name="topHasConsumeWidget" native="true">
<property name="minimumSize">
<size>
<width>330</width>
<height>300</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>330</width>
<height>300</height>
</size>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<widget class="LcMyBigLabel" name="labActName">
<property name="geometry">
<rect>
<x>0</x>
<y>105</y>
<width>330</width>
<height>80</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>330</width>
<height>80</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>330</width>
<height>80</height>
</size>
</property>
<property name="text">
<string>5元脆骨鸡</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
<widget class="LcMySmallLabel" name="labCodeName">
<property name="geometry">
<rect>
<x>0</x>
<y>200</y>
<width>330</width>
<height>37</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>330</width>
<height>37</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>330</width>
<height>37</height>
</size>
</property>
<property name="text">
<string>键位促销</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
<widget class="QLabel" name="labTime">
<property name="geometry">
<rect>
<x>0</x>
<y>270</y>
<width>330</width>
<height>30</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>330</width>
<height>30</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>330</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>上海金桥店 2016.2.2</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</widget>
</item>
<item>
<widget class="QLabel" name="labCode">
<property name="minimumSize">
<size>
<width>330</width>
<height>51</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>330</width>
<height>51</height>
</size>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="text">
<string>123456789</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
<number>0</number>
</property>
<item>
<widget class="QPushButton" name="btnConsumOk">
<property name="minimumSize">
<size>
<width>330</width>
<height>99</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>330</width>
<height>99</height>
</size>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>LcMyBigLabel</class>
<extends>QLabel</extends>
<header location="global">lcmybiglabel.h</header>
</customwidget>
<customwidget>
<class>LcMySmallLabel</class>
<extends>QLabel</extends>
<header location="global">lcmysmalllabel.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>
#include "consumptiondialog.h"
#include "ui_consumptiondialog.h"
ConsumptionDialog::ConsumptionDialog(QWidget *parent) :
LcMyDialog(parent),
ui(new Ui::ConsumptionDialog)
{
ui->setupUi(this);
connect( ui->btnConsumption, &QPushButton::clicked, this, &ConsumptionDialog::accept);
connect( ui->btnCannel, &QPushButton::clicked, this, &ConsumptionDialog::reject);
}
ConsumptionDialog::~ConsumptionDialog()
{
delete ui;
}
bool ConsumptionDialog::ShowForUnConsum(const QString &act_name,
const QString code_name,
const QString time_name,
const QString coupon,
QWidget *parent)
{
ConsumptionDialog v(parent);
v.setGeometry( 0,0,350,470);
v.ui->topNoConsumeWidget->setObjectName( "topNoConsumeWidget");
v.ui->topNoConsumeWidget->setStyleSheet( v.ui->topNoConsumeWidget->styleSheet());
v.ui->btnConsumption->setObjectName( "btnConsumption");
v.ui->btnConsumption->setStyleSheet( v.ui->btnConsumption->styleSheet());
v.ui->btnConsumption->setEnabled( true);
v.setDate( act_name,code_name ,time_name,coupon );
if( v.exec() == QDialog::Accepted){
return true;
}
return false;
}
bool ConsumptionDialog::ShowForHasConsum(const QString &act_name,
const QString code_name,
const QString time_name,
const QString coupon,
QWidget *parent)
{
ConsumptionDialog v(parent);
v.setGeometry( 0,0,350,470);
v.ui->topNoConsumeWidget->setObjectName( "topHasConsumeWidget");
v.ui->topNoConsumeWidget->setStyleSheet( v.ui->topNoConsumeWidget->styleSheet());
v.ui->btnConsumption->setObjectName( "btnConsumNull");
v.ui->btnConsumption->setStyleSheet( v.ui->btnConsumption->styleSheet());
v.ui->btnConsumption->setEnabled( false);
v.setDate( act_name,code_name ,time_name,coupon );
if( v.exec() == QDialog::Accepted){
return true;
}
return false;
}
void ConsumptionDialog::setDate(const QString &act_name,
const QString code_name,
const QString time_name,
const QString coupon)
{
ui->labCode->setText( coupon);
ui->labCodeName->setText( code_name);
ui->labActName->setText( act_name);
ui->labTime->setText( time_name);
}
//-------------------------------------------------
//
// Project created by 孙长鹏 2016-01-11T12:58:22
// Copyright (C) 2016 上海非码网络科技有限公司
// All rights reserved
//-------------------------------------------------
#ifndef CONSUMPTIONDIALOG_H
#define CONSUMPTIONDIALOG_H
#include <QDialog>
#include "lc_my_dialog.h"
class WorkObject;
namespace Ui {
class ConsumptionDialog;
}
class ConsumptionDialog : public LcMyDialog
{
Q_OBJECT
public:
explicit ConsumptionDialog( QWidget *parent = 0);
~ConsumptionDialog();
void setDate(const QString& act_name,
const QString code_name,
const QString time_name,
const QString coupon);
static bool ShowForUnConsum(const QString &act_name,
const QString code_name,
const QString time_name,
const QString coupon,
QWidget *parent = 0);
static bool ShowForHasConsum(const QString& act_name,
const QString code_name,
const QString time_name,
const QString coupon,
QWidget *parent = 0);
signals:
void sgBtnOk();
void sgBtnCannel();
private:
Ui::ConsumptionDialog *ui;
};
#endif // CONSUMPTIONDIALOG_H
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ConsumptionDialog</class>
<widget class="QDialog" name="ConsumptionDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>350</width>
<height>470</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>350</width>
<height>470</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>350</width>
<height>470</height>
</size>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<property name="styleSheet">
<string notr="true">#ConsumptionDialog{
border: none;
background-color: transparent;
}
#BgWidget{
border: none; background-color: transparent;
border-top-left-radius:12px;
border-top-right-radius:12px;
}
/**/
#topNoConsumeWidget{
background-image: url(:/res/bg_no_exchange.png);
border:none;
border-top-left-radius:12px;
border-top-right-radius:12px;
}
#topHasConsumeWidget{
background-image: url(:/res/bg_exchange.png);
border:none;
border-top-left-radius:12px;
border-top-right-radius:12px;
}
/**/
#labActName{
font: 75 45pt &quot;微软雅黑&quot;;
color: rgb(255, 255, 0);
border:none;
}
#labCodeName{
font: 72 25pt &quot;微软雅黑&quot;;
color: rgb(146, 53, 50);
border:none;
}
#labTime{
background-color: rgb(146, 53, 50);
font: 11pt &quot;FZLanTingHei-H-GBK&quot;;
color: rgb(255, 255, 255);
border:none;
}
#labCode{
background-image: url(:/res/ma_bg.png);
font: 17pt &quot;FZLanTingHei-H-GBK&quot;;
color: rgb(33, 33, 33);
border:none;
}
#btnCannel{
border:none;
background-image: url(:/res/btn_canel.png);
}
/**/
#btnConsumption{
border:none;
background-image: url(:/res/btn_consumption.png);
}
#btnConsumNull{
border:none;
background-image: url(:/res/btn_consumption_invalid.png);
}
/**/</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>10</number>
</property>
<property name="topMargin">
<number>10</number>
</property>
<property name="rightMargin">
<number>10</number>
</property>
<property name="bottomMargin">
<number>10</number>
</property>
<item>
<widget class="QWidget" name="BgWidget" native="true">
<property name="minimumSize">
<size>
<width>330</width>
<height>450</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>330</width>
<height>450</height>
</size>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QWidget" name="topNoConsumeWidget" native="true">
<property name="minimumSize">
<size>
<width>330</width>
<height>300</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>330</width>
<height>300</height>
</size>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<widget class="LcMyBigLabel" name="labActName">
<property name="geometry">
<rect>
<x>0</x>
<y>105</y>
<width>330</width>
<height>80</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>330</width>
<height>80</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>330</width>
<height>80</height>
</size>
</property>
<property name="text">
<string>查询中</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
<widget class="QLabel" name="labTime">
<property name="geometry">
<rect>
<x>0</x>
<y>270</y>
<width>330</width>
<height>30</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>330</width>
<height>30</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>330</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>9992(4) 2016.2.28/23.59</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
<widget class="LcMySmallLabel" name="labCodeName">
<property name="geometry">
<rect>
<x>0</x>
<y>205</y>
<width>330</width>
<height>37</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>330</width>
<height>37</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>330</width>
<height>37</height>
</size>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="text">
<string>键位促销</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</widget>
</item>
<item>
<widget class="QLabel" name="labCode">
<property name="minimumSize">
<size>
<width>330</width>
<height>51</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>330</width>
<height>51</height>
</size>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="text">
<string>132456789</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
<number>0</number>
</property>
<item>
<widget class="QPushButton" name="btnCannel">
<property name="minimumSize">
<size>
<width>111</width>
<height>99</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>111</width>
<height>99</height>
</size>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnConsumption">
<property name="minimumSize">
<size>
<width>219</width>
<height>99</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>219</width>
<height>99</height>
</size>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>LcMyBigLabel</class>
<extends>QLabel</extends>
<header location="global">lcmybiglabel.h</header>
</customwidget>
<customwidget>
<class>LcMySmallLabel</class>
<extends>QLabel</extends>
<header location="global">lcmysmalllabel.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>
#include "errcodedialog.h"
#include "ui_errcodedialog.h"
ErrCodeDialog::ErrCodeDialog(QWidget *parent) :
LcMyDialog(parent),
ui(new Ui::ErrCodeDialog)
{
ui->setupUi(this);
connect( ui->btnCannel, &QPushButton::clicked, this, &ErrCodeDialog::accept);
}
ErrCodeDialog::~ErrCodeDialog()
{
delete ui;
}
void ErrCodeDialog::showForInvalid(const QString &coupon, QWidget *parent)
{
ErrCodeDialog v(parent);
v.setGeometry( 0,0,350,470);
v.ui->topInvalidWidget->setObjectName("topInvalidWidget");
v.ui->topInvalidWidget->setStyleSheet( v.ui->topInvalidWidget->styleSheet());
v.ui->labTime->setVisible( false);
v.ui->labActName->setVisible( false);
v.ui->labCodeName->setVisible( false);
v.ui->labFolat->setVisible( false);
v.ui->labCode->setText(coupon );
v.exec();
}
void ErrCodeDialog::showForExpird(const QString &act_name,
const QString code_name,
const QString time_name,
const QString coupon,
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( true);
v.ui->labActName->setVisible( true);
v.ui->labCodeName->setVisible( true);
v.ui->labCode->setText(coupon );
v.ui->labTime->setText( time_name);
v.ui->labActName->setText( act_name);
v.ui->labCodeName->setText( code_name);
v.exec();
}
void ErrCodeDialog::showForErr(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();
}
//-------------------------------------------------
//
// Project created by 孙长鹏 2016-01-11T12:58:22
// Copyright (C) 2016 上海非码网络科技有限公司
// All rights reserved
//-------------------------------------------------
#ifndef ERRCODEDIALOG_H
#define ERRCODEDIALOG_H
#include <QDialog>
#include "lc_my_dialog.h"
namespace Ui {
class ErrCodeDialog;
}
class ErrCodeDialog : public LcMyDialog
{
Q_OBJECT
public:
explicit ErrCodeDialog(QWidget *parent = 0);
~ErrCodeDialog();
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);
private:
Ui::ErrCodeDialog *ui;
};
#endif // ERRCODEDIALOG_H
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ErrCodeDialog</class>
<widget class="QDialog" name="ErrCodeDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>350</width>
<height>470</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>350</width>
<height>470</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>350</width>
<height>470</height>
</size>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<property name="styleSheet">
<string notr="true">#ConsumptionDialog{
border: none;
background-color: transparent;
}
#BgWidget{
border: none; background-color: transparent;
border-top-left-radius:12px;
border-top-right-radius:12px;
}
/**/
#topInvalidWidget{
background-image: url(:/res/bg_invalid_code.png);
border:none;
border-top-left-radius:12px;
border-top-right-radius:12px;
}
#topExpirdWidget{
background-image: url(:/res/bg_be_invalid.png);
border:none;
border-top-left-radius:12px;
border-top-right-radius:12px;
}
#labFolat{
border:none;
background-image: url(:/res/folat_be_invalid.png);
}
/**/
#labCode{
background-image: url(:/res/ma_bg.png);
}
#labTime{
background-color: rgb(81, 81, 81);
}
/*label*/
#labActName{
font: 75 45pt &quot;微软雅黑&quot;;
color: rgb(81, 81, 81);
}
#labCodeName{
font: 72 25pt &quot;微软雅黑&quot;;
color: rgb(81, 81, 81);
}
#labTime{
font: 16pt &quot;微软雅黑&quot;;
color: rgb(255, 255, 255);
}
#labCode{
background-image: url(:/res/ma_bg.png);
font: 17pt &quot;微软雅黑&quot;;
color: rgb(33, 33, 33);
}
/*label*/
#btnCannel{
border:none;
background-image: url(:/res/btn_canel.png);
}
/**/
#btnConsumption{
border:none;
background-image: url(:/res/btn_consumption.png);
}
#btnConsumNull{
border:none;
background-image: url(:/res/btn_consumption_invalid.png);
}
/**/</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>10</number>
</property>
<property name="topMargin">
<number>10</number>
</property>
<property name="rightMargin">
<number>10</number>
</property>
<property name="bottomMargin">
<number>10</number>
</property>
<item>
<widget class="QWidget" name="BgWidget" native="true">
<property name="minimumSize">
<size>
<width>330</width>
<height>450</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>330</width>
<height>450</height>
</size>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QWidget" name="topInvalidWidget" native="true">
<property name="minimumSize">
<size>
<width>330</width>
<height>300</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>330</width>
<height>300</height>
</size>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<widget class="QLabel" name="labTime">
<property name="geometry">
<rect>
<x>0</x>
<y>270</y>
<width>330</width>
<height>30</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>330</width>
<height>30</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>330</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>有效期至:2016.2.28/23.59</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
<widget class="LcMyGrayBigLabel" name="labActName">
<property name="geometry">
<rect>
<x>0</x>
<y>90</y>
<width>330</width>
<height>80</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>330</width>
<height>80</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>330</width>
<height>80</height>
</size>
</property>
<property name="text">
<string>5元脆骨鸡</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
<widget class="LcMyGraySmallLabel" name="labCodeName">
<property name="geometry">
<rect>
<x>0</x>
<y>190</y>
<width>330</width>
<height>37</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>330</width>
<height>37</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>330</width>
<height>37</height>
</size>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="text">
<string>键位促销</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
<widget class="QLabel" name="labFolat">
<property name="geometry">
<rect>
<x>68</x>
<y>0</y>
<width>262</width>
<height>167</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>262</width>
<height>167</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>262</width>
<height>167</height>
</size>
</property>
<property name="text">
<string/>
</property>
</widget>
</widget>
</item>
<item>
<widget class="QLabel" name="labCode">
<property name="minimumSize">
<size>
<width>330</width>
<height>51</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>330</width>
<height>51</height>
</size>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="text">
<string>123456789</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
<number>0</number>
</property>
<item>
<widget class="QPushButton" name="btnCannel">
<property name="minimumSize">
<size>
<width>111</width>
<height>99</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>111</width>
<height>99</height>
</size>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnConsumNull">
<property name="minimumSize">
<size>
<width>219</width>
<height>99</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>219</width>
<height>99</height>
</size>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>LcMyGraySmallLabel</class>
<extends>QLabel</extends>
<header location="global">lcmygraysmalllabel.h</header>
</customwidget>
<customwidget>
<class>LcMyGrayBigLabel</class>
<extends>QLabel</extends>
<header location="global">lcmygraybiglabel.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>
#include "golbal.h"
#include <QFile>
#include <QMessageBox>
#include <QXmlStreamReader>
#include <QDebug>
QString bigFontName;
QString smallFontName;
QString exePath;
bool readStorid(QString &storid)
{
QString StoreId, StoreLegacyId;
QString strorXml = "E:\\NewPos61\\PosData\\store-db.xml";
QFile file(strorXml);
if(!file.open(QFile::ReadOnly | QFile::Text))
{
QMessageBox::information(NULL, QString("err"), "E:\\NewPos61\\PosData\\store-db.xml打开失败,请联系it人员!");
return false;
}
QXmlStreamReader xml(&file);
int flag = 0;
while(!xml.atEnd() && !xml.hasError()){
//读取下一个element.
QXmlStreamReader::TokenType token = xml.readNext();
//如果获取的仅为StartDocument,则进行下一个
if(token == QXmlStreamReader::StartDocument)
{
continue;
}
//如果获取了StartElement,则尝试读取
if(token == QXmlStreamReader::StartElement)
{
if( xml.name() == "StoreId"){
xml.readNext();
StoreId = xml.text().toString();
flag = flag + 1;
}
if( xml.name() == "StoreLegacyId"){
xml.readNext();
StoreLegacyId = xml.text().toString();
flag = flag + 1;
}
}
if( flag >= 2)
break;
}
if(xml.hasError())
{
QMessageBox::information(NULL, QString("err"), "门店信息store-db.xml读取失败,请联系it人员!");
xml.clear();
file.close();
return false;
}
xml.clear();
file.close();
if( StoreLegacyId != StoreId){
QMessageBox::information(NULL, QString("err"), "StoreLegacyId和StoreId不配,请联系it人员!");
}
storid = StoreId;
return true;
}
bool readPosNo(QString &posNo)
{
QString posNoCfg = "E:\\NewPos61\\Bat\\start.np6";
QFile file(posNoCfg);
if(!file.open(QFile::ReadOnly | QFile::Text))
{
QMessageBox::information(NULL, QString("err"), "E:\\NewPos61\\Bat\\start.np6打开失败,请联系it人员!");
return false;
}
QByteArray array = file.readAll();
file.close();
QString str = QString::fromLatin1( array);
QString indexStr = "..\\posdata\\_POS";
int index = str.indexOf(indexStr);
if( index < 0){
QMessageBox::information(NULL, QString("err"), "读取posno失败,请联系it人员!");
return false;
}
index = index + indexStr.length();
posNo = QString();
posNo.append(str.at(index) ).append( str.at(index + 1));
return true;
}
//-------------------------------------------------
//
// Project created by 孙长鹏 2016-01-11T12:58:22
// Copyright (C) 2016 上海非码网络科技有限公司
// All rights reserved
//-------------------------------------------------
#ifndef GOLBAL_H
#define GOLBAL_H
#include <QString>
#include <QRect>
extern QString bigFontName;
extern QString smallFontName;
extern QString exePath;
bool readStorid( QString& storid);
bool readPosNo( QString& posNo);
#endif // GOLBAL_H
#include "inputdialog.h"
#include "ui_inputdialog.h"
#include <windows.h>
InputDialog::InputDialog(QWidget *parent) :
LcMyDialog(parent),
ui(new Ui::InputDialog)
{
ui->setupUi(this);
connect( ui->btn0, &QPushButton::clicked, this, &InputDialog::btnClick);
connect( ui->btn1, &QPushButton::clicked, this, &InputDialog::btnClick);
connect( ui->btn2, &QPushButton::clicked, this, &InputDialog::btnClick);
connect( ui->btn3, &QPushButton::clicked, this, &InputDialog::btnClick);
connect( ui->btn4, &QPushButton::clicked, this, &InputDialog::btnClick);
connect( ui->btn5, &QPushButton::clicked, this, &InputDialog::btnClick);
connect( ui->btn6, &QPushButton::clicked, this, &InputDialog::btnClick);
connect( ui->btn7, &QPushButton::clicked, this, &InputDialog::btnClick);
connect( ui->btn8, &QPushButton::clicked, this, &InputDialog::btnClick);
connect( ui->btn9, &QPushButton::clicked, this, &InputDialog::btnClick);
connect( ui->btnDel, &QPushButton::clicked, this, &InputDialog::btnDelClick);
connect( ui->btnClear, &QPushButton::clicked, this, &InputDialog::btnClearClick);
connect( ui->btnCanle, &QPushButton::clicked, this, &InputDialog::btnCanelClick);
connect( ui->btnOk, &QPushButton::clicked, this, &InputDialog::btnOkClick);
//setAttribute(Qt::WA_TranslucentBackground);
//this->installEventFilter( this);
checkTopTimer.setInterval( 1000);
connect( &checkTopTimer, &QTimer::timeout, this, &InputDialog::timeOut);
checkTopTimer.start();
// timeOut();
}
void InputDialog::timeOut()
{
HWND hForeWnd = ::GetForegroundWindow();
DWORD dwForeID = ::GetWindowThreadProcessId(hForeWnd,NULL);
DWORD dwCurID = ::GetCurrentThreadId();
::AttachThreadInput(dwCurID,dwForeID,TRUE);
::SetWindowPos( (HWND)effectiveWinId(), HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW);
showNormal();
::SetForegroundWindow( (HWND)this->effectiveWinId());
::AttachThreadInput(dwCurID,dwForeID,FALSE);
this->setFocus();
ui->txtInput->setFocus();
}
InputDialog::~InputDialog()
{
delete ui;
}
bool InputDialog::showInputDialog(QString &code_in_out, QWidget *parent)
{
InputDialog v(parent);
v.setGeometry( 0,0,v.width(),v.height());
if( v.exec() == QDialog::Accepted){
code_in_out = v.code;
return true;
}
return false;
}
void InputDialog::btnOkClick()
{
code = ui->txtInput->text();
accept();
}
void InputDialog::btnCanelClick()
{
reject();
}
void InputDialog::btnClearClick()
{
ui->txtInput->setText("");
}
void InputDialog::btnDelClick()
{
QString str = ui->txtInput->text();
str.chop(1);
ui->txtInput->setText( str);
}
void InputDialog::btnClick()
{
QPushButton *btn = (QPushButton *)sender();
QString c;
if( ui->btn0 == btn)
c = "0";
else if( ui->btn1 == btn)
c = "1";
else if( ui->btn2 == btn)
c = "2";
else if( ui->btn3 == btn)
c = "3";
else if( ui->btn4 == btn)
c = "4";
else if( ui->btn5 == btn)
c = "5";
else if( ui->btn6 == btn)
c = "6";
else if( ui->btn7 == btn)
c = "7";
else if( ui->btn8 == btn)
c = "8";
else if( ui->btn9 == btn)
c = "9";
QString str = ui->txtInput->text();
str.append(c);
ui->txtInput->setText( str);
}
#ifndef INPUTDIALOG_H
#define INPUTDIALOG_H
#include <QDialog>
#include "lc_my_dialog.h"
#include <QTimer>
namespace Ui {
class InputDialog;
}
class InputDialog : public LcMyDialog
{
Q_OBJECT
public:
explicit InputDialog(QWidget *parent = 0);
~InputDialog();
static bool showInputDialog(QString& code_in_out, QWidget *parent = 0);
private:
void btnClick();
void btnOkClick();
void btnCanelClick();
void btnClearClick();
void btnDelClick();
Ui::InputDialog *ui;
QString code;
QTimer checkTopTimer;
void timeOut();
};
#endif // INPUTDIALOG_H
#include <QApplication>
#include <scaningdialog.h>
#include <QFontDatabase>
#include "golbal.h"
#include "consumptiondialog.h"
#include "errcodedialog.h"
#include "QDir"
#include <QFile>
#include "workwidget.h"
#if defined Q_OS_WIN32 //for win
#include <windows.h>
bool checkOnly()
{
HANDLE m_hMutex = CreateMutex(NULL, FALSE, L"fm_lppos" );
if (GetLastError() == ERROR_ALREADY_EXISTS) {
CloseHandle(m_hMutex);
m_hMutex = NULL;
return false;
}
else
return true;
}
#endif //
#if defined Q_OS_LINUX //for linux
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
bool checkOnly()
{
const char filename[] = "/tmp/lockfile";
int fd = open (filename, O_WRONLY | O_CREAT , 0644);
int flock = lockf(fd, F_TLOCK, 0 );
if (fd == -1) {
perror("open lockfile/n");
return false;
}
//给文件加锁
if (flock == -1) {
perror("lock file error/n");
return false;
}
//程序退出后,文件自动解锁
return true;
}
#endif
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
if(checkOnly()==false) {
//HWND hFormer = FindWindow(L"QWidget", "Form");
return 0;
}
exePath = qApp->applicationDirPath();
QString fontPath = exePath + "/";
int bigfontIndex = QFontDatabase::addApplicationFont( fontPath + "big_GBK.TTF");
QStringList bigList = QFontDatabase::applicationFontFamilies(bigfontIndex);
if( !bigList.isEmpty())
bigFontName = bigList.at(0);
int smallfontIndex = QFontDatabase::addApplicationFont( fontPath + "small_GBK.TTF");
QStringList smallList = QFontDatabase::applicationFontFamilies(smallfontIndex);
if( !smallList.isEmpty())
smallFontName = smallList.at(0);
qDebug() << bigFontName << smallFontName;
WorkWidget w;
// if( argc == 2){
// w.refund();
// }else{
w.beginWork();
// }
return a.exec();
}
// find /opt/soft/log/ -mtime +30 -name "*.log" -exec rm -rf {} \;
#include "mainobject.h"
MainObject::MainObject(QObject *parent) : QObject(parent)
{
}
//-------------------------------------------------
//
// Project created by 孙长鹏 2016-01-11T12:58:22
// Copyright (C) 2016 上海非码网络科技有限公司
// All rights reserved
//-------------------------------------------------
#ifndef MAINOBJECT_H
#define MAINOBJECT_H
#include <QObject>
#include <QTcpSocket>
class MainObject : public QObject
{
Q_OBJECT
public:
explicit MainObject(QObject *parent = 0);
signals:
public slots:
};
#endif // MAINOBJECT_H
#include "prorefunddialog.h"
#include "ui_prorefunddialog.h"
ProRefundDialog::ProRefundDialog(QWidget *parent) :
LcMyDialog(parent),
ui(new Ui::ProRefundDialog)
{
ui->setupUi(this);
connect( ui->btnOK, &QPushButton::clicked, this, &ProRefundDialog::accept);
}
ProRefundDialog::~ProRefundDialog()
{
delete ui;
}
bool ProRefundDialog::proRefund(const QString mess, QWidget *parent )
{
ProRefundDialog v(parent);
v.setGeometry(0,0,350,470);
v.ui->labMess->setText( mess);
v.exec();
return true;
}
//-------------------------------------------------
//
// Project created by 孙长鹏 2016-01-11T12:58:22
// Copyright (C) 2016 上海非码网络科技有限公司
// All rights reserved
//-------------------------------------------------
#ifndef PROREFUNDDIALOG_H
#define PROREFUNDDIALOG_H
#include "lc_my_dialog.h"
namespace Ui {
class ProRefundDialog;
}
class ProRefundDialog : public LcMyDialog
{
Q_OBJECT
public:
explicit ProRefundDialog(QWidget *parent = 0);
~ProRefundDialog();
static bool proRefund( const QString mess, QWidget *parent = 0);
private:
Ui::ProRefundDialog *ui;
};
#endif // PROREFUNDDIALOG_H
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ProRefundDialog</class>
<widget class="QDialog" name="ProRefundDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>350</width>
<height>470</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>350</width>
<height>470</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>350</width>
<height>470</height>
</size>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<property name="styleSheet">
<string notr="true">#labMess{
font: 20pt;
background-color: rgb(255, 255, 255);
}
#btnOK{
font: 20pt;
}
#ProRefundDialog{
background-color: rgb(255, 255, 255);
}
</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="labMess">
<property name="minimumSize">
<size>
<width>0</width>
<height>80</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>80</height>
</size>
</property>
<property name="text">
<string>TextLabel</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnOK">
<property name="minimumSize">
<size>
<width>0</width>
<height>80</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>80</height>
</size>
</property>
<property name="text">
<string>确认</string>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
#-------------------------------------------------
#
# Project created by 孙长2016-01-11T12:58:22
# Copyright (C) 2016 上海非码网络科技有限公司
# All rights reserved
#-------------------------------------------------
QT += core gui winextras network xml
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = qMcdCode
TEMPLATE = app
INCLUDEPATH += $$PWD/../qMcdCode/widget
SOURCES += main.cpp\
widget/lc_my_dialog.cpp \
errcodedialog.cpp \
consumptiondialog.cpp \
consumokdialog.cpp \
#workobject.cpp \
scaningdialog.cpp \
widget/mysock.cpp \
golbal.cpp \
widget/lcmybiglabel.cpp \
widget/lcmylabel.cpp \
widget/lcmysmalllabel.cpp \
widget/lcmygraybiglabel.cpp \
widget/lcmygraysmalllabel.cpp \
workwidget.cpp \
refunddialog.cpp \
prorefunddialog.cpp \
mainobject.cpp \
widget/lcmynormal.cpp \
inputdialog.cpp
HEADERS += \
widget/lc_my_dialog.h \
errcodedialog.h \
consumptiondialog.h \
consumokdialog.h \
# workobject.h \
scaningdialog.h \
widget/mysock.h \
golbal.h \
widget/lcmybiglabel.h \
widget/lcmylabel.h \
widget/lcmysmalllabel.h \
widget/lcmygraybiglabel.h \
widget/lcmygraysmalllabel.h \
workwidget.h \
refunddialog.h \
prorefunddialog.h \
mainobject.h \
widget/lcmynormal.h \
inputdialog.h
FORMS += \
errcodedialog.ui \
consumptiondialog.ui \
consumokdialog.ui \
scaningdialog.ui \
workwidget.ui \
refunddialog.ui \
prorefunddialog.ui \
inputdialog.ui
RESOURCES += \
res.qrc
#include "refunddialog.h"
#include "ui_refunddialog.h"
#include "windows.h"
RefundDialog::RefundDialog(QWidget *parent) :
LcMyDialog(parent),
ui(new Ui::RefundDialog)
{
ui->setupUi(this);
connect( ui->btnOK, &QPushButton::clicked, this, &RefundDialog::accept);
connect( ui->btnCanel, &QPushButton::clicked, this, &RefundDialog::reject);
this->installEventFilter( this);
checkTopTimer.setInterval( 3000);
connect( &checkTopTimer, &QTimer::timeout, this, &RefundDialog::timeOut);
checkTopTimer.start(3000);
}
void RefundDialog::timeOut()
{
// qDebug() << "activateWindow";
// ::SetWindowPos( (HWND)effectiveWinId(), HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW);
// ::SetWindowPos( (HWND)effectiveWinId(), HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW);
// raise();
// showNormal();
// activateWindow();
// raise();
// ui->txtCode->setFocus();
HWND hForeWnd = ::GetForegroundWindow();
DWORD dwForeID = ::GetWindowThreadProcessId(hForeWnd,NULL);
DWORD dwCurID = ::GetCurrentThreadId();
::AttachThreadInput(dwCurID,dwForeID,TRUE);
::SetWindowPos( (HWND)effectiveWinId(), HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW);
// ::SetWindowPos( (HWND)effectiveWinId(), HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW);
showNormal();
::SetForegroundWindow( (HWND)this->effectiveWinId());
::AttachThreadInput(dwCurID,dwForeID,FALSE);
ui->txtCode->setFocus();
}
RefundDialog::~RefundDialog()
{
delete ui;
}
bool RefundDialog::refund(QString &_out_cupon, QWidget *parent)
{
RefundDialog v(parent);
if( v.exec() == QDialog::Accepted){
_out_cupon = v.ui->txtCode->text();
return true;
}
return false;
}
//-------------------------------------------------
//
// Project created by 孙长鹏 2016-01-11T12:58:22
// Copyright (C) 2016 上海非码网络科技有限公司
// All rights reserved
//-------------------------------------------------
#ifndef REFUNDDIALOG_H
#define REFUNDDIALOG_H
#include "lc_my_dialog.h"
#include "QTimer"
namespace Ui {
class RefundDialog;
}
class RefundDialog : public LcMyDialog
{
Q_OBJECT
public:
explicit RefundDialog(QWidget *parent = 0);
~RefundDialog();
static bool refund(QString& _out_cupon, QWidget *parent = 0);
private:
Ui::RefundDialog *ui;
QTimer checkTopTimer;
void timeOut();
};
#endif // REFUNDDIALOG_H
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>RefundDialog</class>
<widget class="QDialog" name="RefundDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>350</width>
<height>470</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>350</width>
<height>470</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>350</width>
<height>470</height>
</size>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<property name="styleSheet">
<string notr="true">font: 20pt;</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLineEdit" name="txtCode">
<property name="minimumSize">
<size>
<width>0</width>
<height>50</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>50</height>
</size>
</property>
<property name="placeholderText">
<string>输入券号用来退货</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnOK">
<property name="minimumSize">
<size>
<width>0</width>
<height>50</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>50</height>
</size>
</property>
<property name="text">
<string>确认退货</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnCanel">
<property name="minimumSize">
<size>
<width>0</width>
<height>50</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>50</height>
</size>
</property>
<property name="text">
<string>取消</string>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
<RCC>
<qresource prefix="/">
<file>res/bg.png</file>
<file>res/bg_be_invalid.png</file>
<file>res/bg_exchange.png</file>
<file>res/bg_invalid_code.png</file>
<file>res/bg_no_exchange.png</file>
<file>res/bg_sanning.png</file>
<file>res/btn_canel.png</file>
<file>res/btn_consumption.png</file>
<file>res/btn_consumption_invalid.png</file>
<file>res/consumption_ok.png</file>
<file>res/ma_bg.png</file>
<file>res/scanning_bar.png</file>
<file>res/folat_be_invalid.png</file>
<file>res/bg_working.png</file>
<file>res/close.png</file>
<file>res/btnDel.png</file>
<file>res/inputClose.png</file>
<file>res/top.png</file>
<file>res/btnInput.png</file>
</qresource>
</RCC>
#include "scaningdialog.h"
#include "ui_scaningdialog.h"
#include <QFontDatabase>
#include <QFont>
#include <windows.h>
#pragma comment(lib, "user32.lib")
ScaningDialog::ScaningDialog(QWidget *parent) :
LcMyDialog(parent),
ui(new Ui::ScaningDialog)
{
ui->setupUi(this);
setAttribute(Qt::WA_TranslucentBackground);
this->installEventFilter( this);
ui->labScaningBar->setFocus();
connect( ui->btnClose, &QPushButton::clicked, this, &ScaningDialog::scaningClose);
scaningBar = new QPropertyAnimation( ui->labScaningBar, "geometry",this);
animationUp = true;
animationEnd();
connect( scaningBar, &QPropertyAnimation::finished, this, &ScaningDialog::animationEnd);
connect( ui->btnShowInput, &QPushButton::clicked, this, &ScaningDialog::btnShowInputClick);
checkTopTimer.setInterval( 1000);
connect( &checkTopTimer, &QTimer::timeout, this, &ScaningDialog::timeOut);
checkTopTimer.start();
is_manual = 0;
}
void ScaningDialog::timeOut()
{
qDebug() << "activateWindow111";
HWND hForeWnd = ::GetForegroundWindow();
DWORD dwForeID = ::GetWindowThreadProcessId(hForeWnd,NULL);
DWORD dwCurID = ::GetCurrentThreadId();
::AttachThreadInput(dwCurID,dwForeID,TRUE);
::SetWindowPos( (HWND)effectiveWinId(), HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW);
// ::SetWindowPos( (HWND)effectiveWinId(), HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW);
showNormal();
::SetForegroundWindow( (HWND)this->effectiveWinId());
::AttachThreadInput(dwCurID,dwForeID,FALSE);
this->setFocus();
ui->labScaningBar->setFocus();
}
//192.168.100.98
void ScaningDialog::animationEnd()
{
scaningBar->setDuration( 1500);
if(animationUp){
scaningBar->setStartValue( QRect( 0,310, 330,33));
scaningBar->setEndValue( QRect( 0,407,330,33));
}else
{
scaningBar->setStartValue( QRect( 0,407,330,33));
scaningBar->setEndValue( QRect( 0,310, 330,33));
}
animationUp = !animationUp;
scaningBar->start();
}
ScaningDialog::~ScaningDialog()
{
delete ui;
delete scaningBar;
}
void ScaningDialog::scaningClose()
{
exit(0);
}
void ScaningDialog::keyPressEvent(QKeyEvent *e)
{
qDebug() << e->key() << e->text();
if( e->key() == Qt::Key_Enter
|| e->key() == Qt::Key_End || e->key() == 16777220 )
{
qDebug() << "ok";
this->accept();
return;
}
qDebug() << code;
code.append( e->text());
}
bool ScaningDialog::scanningCode(QString &code_in_out, int &is_manual_out, QWidget *parent) //循环focus
{
ScaningDialog v(parent);
v.setGeometry( 0,0,350,470);
if( v.exec() == QDialog::Accepted){
code_in_out = v.code;
is_manual_out = v.is_manual;
return true;
}
return false;
}
void ScaningDialog::btnShowInputClick()
{
is_manual = 1;
this->accept();
}
//-------------------------------------------------
//
// Project created by 孙长鹏 2016-01-11T12:58:22
// Copyright (C) 2016 上海非码网络科技有限公司
// All rights reserved
//-------------------------------------------------
#ifndef SCANINGDIALOG_H
#define SCANINGDIALOG_H
#include <QDialog>
#include <QKeyEvent>
#include "lc_my_dialog.h"
#include <QPropertyAnimation>
#include <QTimer>
namespace Ui {
class ScaningDialog;
}
class ScaningDialog : public LcMyDialog
{
Q_OBJECT
public:
explicit ScaningDialog(QWidget *parent = 0);
~ScaningDialog();
static bool scanningCode(QString &code_in_out, int &is_manual_out, QWidget *parent = 0);
void scanningCode();
signals:
void ScaningOk( const QString code);
protected:
void keyPressEvent(QKeyEvent *e);
private:
void animationEnd();
void scaningClose();
void btnShowInputClick();
Ui::ScaningDialog *ui;
QString code;
int is_manual;
bool animationUp;
QPropertyAnimation *scaningBar;
QTimer checkTopTimer;
void timeOut();
};
#endif // SCANINGDIALOG_H
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ScaningDialog</class>
<widget class="QDialog" name="ScaningDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>350</width>
<height>470</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>350</width>
<height>470</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>350</width>
<height>470</height>
</size>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<property name="styleSheet">
<string notr="true">#ScaningDialog{
border: none;
background-color: transparent;
}
#bgWidget{
border: none; background-color: transparent;
border-radius:12px;
background-image: url(:/res/bg_sanning.png);
}
#btnClose{
border: none;
image: url(:/res/close.png);
padding-left: 28px;
padding-bottom:28px;
}
#labScaningBar{
border: none;
background-image: url(:/res/scanning_bar.png);
}
</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="leftMargin">
<number>10</number>
</property>
<property name="topMargin">
<number>10</number>
</property>
<property name="rightMargin">
<number>10</number>
</property>
<property name="bottomMargin">
<number>10</number>
</property>
<item>
<widget class="QWidget" name="bgWidget" native="true">
<property name="minimumSize">
<size>
<width>330</width>
<height>450</height>
</size>
</property>
<widget class="QPushButton" name="btnClose">
<property name="geometry">
<rect>
<x>270</x>
<y>0</y>
<width>60</width>
<height>60</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>60</width>
<height>60</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>60</width>
<height>60</height>
</size>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QLabel" name="labScaningBar">
<property name="geometry">
<rect>
<x>0</x>
<y>310</y>
<width>330</width>
<height>33</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>330</width>
<height>33</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>330</width>
<height>33</height>
</size>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QPushButton" name="btnShowInput">
<property name="geometry">
<rect>
<x>65</x>
<y>190</y>
<width>200</width>
<height>50</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>200</width>
<height>48</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>200</width>
<height>50</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">background-image: url(:/res/btnInput.png);
border:none;</string>
</property>
<property name="text">
<string/>
</property>
</widget>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
#include "lc_my_dialog.h"
#include <QPainter>
#include <QtMath>
LcMyDialog::LcMyDialog( QWidget* parent) :
QDialog(parent)
{
mouse_press = false;
setWindowFlags(Qt::FramelessWindowHint);
//setAttribute(Qt::WA_TranslucentBackground);
setAttribute( Qt::WA_QuitOnClose,false);
}
//void LcMyDialog::paintEvent(QPaintEvent *event)
//{
// QPainterPath path;
// path.setFillRule(Qt::WindingFill);
// path.addRect(10, 10, this->width()-20, this->height()-20);
// QPainter painter(this);
// painter.setRenderHint(QPainter::Antialiasing, true);
// painter.fillPath(path, QBrush(Qt::white));
// QColor color(0, 0, 0, 50);
// for(int i=0; i<10; i++)
// {
// QPainterPath path;
// path.setFillRule(Qt::WindingFill);
// path.addRect(10-i, 10-i, this->width()-(10-i)*2, this->height()-(10-i)*2);
// color.setAlpha(150 - qSqrt(i)*50);
// painter.setPen(color);
// painter.drawPath(path);
// color.setAlpha(150 - qSqrt(i)*50);
// QLine line(10+i,10-i, this->width()-(10-i),10-i);
// painter.setPen(color);
// painter.drawLine( line);
// }
//}
//void LcMyDialog::mousePressEvent(QMouseEvent *event)
//{
// if (event->button() == Qt::LeftButton) {
// mouse_press = true;
// move_point = event->globalPos() - pos();
// }
// //窗口移动距离
//}
//void LcMyDialog::mouseMoveEvent(QMouseEvent *event)
//{
// //若鼠标左键被按下
// if(mouse_press)
// {
// //鼠标相对于屏幕的位置
// QPoint move_pos = event->globalPos();
// //移动主窗体位置
// this->move(move_pos - move_point);
// }
//}
//void LcMyDialog::mouseReleaseEvent(QMouseEvent *event)
//{
// //设置鼠标为未被按下
// mouse_press = false;
//}
bool LcMyDialog::eventFilter(QObject *watched, QEvent *event)
{
if( watched != this)
return false;
if( event->type() == QEvent::WindowDeactivate){
this->reject();
return true;
}
return false;
}
//-------------------------------------------------
//
// Project created by 孙长鹏 2016-01-11T12:58:22
// Copyright (C) 2016 上海非码网络科技有限公司
// All rights reserved
//-------------------------------------------------
#ifndef LCMYDIALOG_H
#define LCMYDIALOG_H
#include <QObject>
#include <QWidget>
#include <QDialog>
#include <QMouseEvent>
#include <QDebug>
typedef struct{
QString codeName;
QString actName;
}Parmters;
class LcMyDialog : public QDialog
{
Q_OBJECT
public:
explicit LcMyDialog(QWidget *parent = 0);
protected:
// virtual void mousePressEvent(QMouseEvent * event);
// virtual void mouseReleaseEvent(QMouseEvent * event);
// virtual void mouseMoveEvent(QMouseEvent * event);
//void paintEvent( QPaintEvent *event);
private:
bool eventFilter(QObject *watched, QEvent *event);
QPoint move_point; //移动的距离
bool mouse_press; //按下鼠标左键
};
#endif // LCMYDIALOG_H
#include "lcmybiglabel.h"
#include <QPainter>
#include <QPainterPathStroker>
#include <QFont>
#include "golbal.h"
#include <QDebug>
#include <QFontDatabase>
#include <QFontMetrics>
LcMyBigLabel::LcMyBigLabel(QWidget *parent) : LcMyLabel(parent)
{
labSize = Big;
getFontColor(colorPath, colorFont);
}
//-------------------------------------------------
//
// Project created by 孙长鹏 2016-01-11T12:58:22
// Copyright (C) 2016 上海非码网络科技有限公司
// All rights reserved
//-------------------------------------------------
#ifndef LcMyBigLabel_H
#define LcMyBigLabel_H
#include <QObject>
#include <QWidget>
#include <QLabel>
#include "lcmylabel.h"
class LcMyBigLabel : public LcMyLabel
{
Q_OBJECT
public:
explicit LcMyBigLabel(QWidget *parent = 0);
};
#endif // LcMyBigLabel_H
#include "lcmygraybiglabel.h"
#include <QPainter>
#include <QPainterPathStroker>
#include <QFont>
#include "golbal.h"
#include <QDebug>
#include <QFontDatabase>
#include <QFontMetrics>
LcMyGrayBigLabel::LcMyGrayBigLabel(QWidget *parent) : LcMyLabel(parent)
{
labSize = grayBig;
getFontColor(colorPath, colorFont);
}
//-------------------------------------------------
//
// Project created by 孙长鹏 2016-01-11T12:58:22
// Copyright (C) 2016 上海非码网络科技有限公司
// All rights reserved
//-------------------------------------------------
#ifndef LCMYGRAYBIGLABEL_H
#define LCMYGRAYBIGLABEL_H
#include <QObject>
#include <QWidget>
#include "lcmylabel.h"
class LcMyGrayBigLabel : public LcMyLabel
{
Q_OBJECT
public:
explicit LcMyGrayBigLabel(QWidget *parent = 0);
};
#endif // LCMYGRAYBIGLABEL_H
#include "lcmygraysmalllabel.h"
#include <QPainter>
#include <QPainterPathStroker>
#include <QFont>
#include "golbal.h"
#include <QDebug>
#include <QFontDatabase>
#include <QFontMetrics>
LcMyGraySmallLabel::LcMyGraySmallLabel(QWidget *parent) : LcMyLabel(parent)
{
labSize = graySmall;
getFontColor(colorPath, colorFont);
}
//-------------------------------------------------
//
// Project created by 孙长鹏 2016-01-11T12:58:22
// Copyright (C) 2016 上海非码网络科技有限公司
// All rights reserved
//-------------------------------------------------
#ifndef LCMYGRAYSMALLLABEL_H
#define LCMYGRAYSMALLLABEL_H
#include <QObject>
#include <QWidget>
#include "lcmylabel.h"
class LcMyGraySmallLabel : public LcMyLabel
{
Q_OBJECT
public:
explicit LcMyGraySmallLabel(QWidget *parent = 0);
};
#endif // LCMYGRAYSMALLLABEL_H
#include "lcmylabel.h"
#include <QPainter>
#include <QPainterPathStroker>
#include <QFont>
#include "golbal.h"
#include <QDebug>
#include <QFontDatabase>
#include <QFontMetrics>
LcMyLabel::LcMyLabel(QWidget *parent) : QLabel(parent)
{
}
int LcMyLabel::getMaxSize(const QString &str, const int maxWidth)
{
int i = 11;
int textWidth;
do{
i ++ ;
if( i > str.length()){
i --;
return str.length();
}
QString _str = str.left( i);
QFont font(bigFontName);
font.setPointSize(22);
font.setBold( true);
QFontMetrics fm(font);
QRect fRect = fm.boundingRect( _str);
textWidth = fRect.width();
}while( textWidth < maxWidth);
return i;
}
void LcMyLabel::getFontColor(QColor &colorPath, QColor &colorFont)
{
if( labSize == Big ||
labSize == normal){
colorPath = QColor(146, 53, 50);
colorFont = QColor(255, 255, 0);
}
if( labSize == Small){
colorPath = QColor(255, 255, 255);
colorFont = QColor(146, 53, 50);
}
if( labSize == grayBig || labSize == graySmall){
colorPath = QColor(171, 171, 171);
colorFont = QColor(118, 118, 118);
}
}
void LcMyLabel::paintEvent(QPaintEvent *event)
{
QString allStr = this->text();
QPainter p(this);
QPainterPath pp(QPointF(0,0));
p.setViewport( this->rect());
//qDebug() << allStr.size() << allStr.length();
if( labSize == normal){
QFont font;
int textWidth;
int textY;
int fontSize = 38;
QFont _font(bigFontName);
font = _font;
font.setPointSize(fontSize);
font.setBold( true);
QFontMetrics fm(font);
QRect fRect = fm.boundingRect( allStr);
textWidth = fRect.width();
textY = fRect.y();
pp.addText(rect().center().x() - textWidth / 2.0, 0- textY , font, allStr);
QPainterPathStroker pps;
pps.setCapStyle(Qt::SquareCap);
pps.setJoinStyle(Qt::RoundJoin);
int lineWith = fontSize/3;
pps.setWidth(lineWith);
QPainterPath path = pps.createStroke(pp);
p.setRenderHint(QPainter::Antialiasing);
p.fillPath(path, colorPath);
p.fillPath(pp, colorFont);
return;
}
if( labSize == Big || labSize == grayBig){
QFont font;
int textWidth;
int textY;
int fontSize = 22;
int maxSize = getMaxSize( allStr, this->width());
if( allStr.length() <=maxSize){
QFont _font(bigFontName);
font = _font;
//font.setPixelSize(60);
font.setPointSize(fontSize);
font.setBold( true);
QFontMetrics fm(font);
QRect fRect = fm.boundingRect( allStr);
textWidth = fRect.width();
textY = fRect.y();
pp.addText(rect().center().x() - textWidth / 2.0, 0- textY , font, allStr);
}else{
QFont _font(bigFontName);
font = _font;
font.setPointSize(fontSize);
font.setBold( true);
QString str1 = allStr.left(11);
QFontMetrics fm1(font);
QRect fRect1 = fm1.boundingRect( str1);
textWidth = fRect1.width();
textY = fRect1.y() - 2;
pp.addText(rect().center().x() - textWidth / 2.0, 0 - textY , font, str1);
QString str2 = allStr.right( allStr.length() - 11);
QFontMetrics fm2(font);
QRect fRect2 = fm2.boundingRect( str2);
textWidth = fRect2.width();
textY = fRect2.y() - 4;
pp.addText(rect().center().x() - textWidth / 2.0, 0 - textY * 2 , font, str2);
qDebug() << textY;
}
QPainterPathStroker pps;
pps.setCapStyle(Qt::SquareCap);
pps.setJoinStyle(Qt::RoundJoin);
int lineWith = fontSize/3;
//qDebug() << "lineWith" << lineWith;
pps.setWidth(lineWith );
QPainterPath path = pps.createStroke(pp);
p.setRenderHint(QPainter::Antialiasing);
p.fillPath(path, colorPath);
p.fillPath(pp, colorFont);
return;
}
if( labSize == Small || labSize == graySmall){
QFont font;
int textWidth;
int textY;
int fontSize = 22;
do{
fontSize = fontSize -2;
QFont _font(bigFontName);
font = _font;
font.setPointSize(fontSize);
font.setBold( true);
QFontMetrics fm(font);
QRect fRect = fm.boundingRect( allStr);
textWidth = fRect.width();
textY = fRect.y();
}while( textWidth > this->width());
pp.addText(rect().center().x() - textWidth / 2.0, 0- textY , font, allStr);
QPainterPathStroker pps;
pps.setCapStyle(Qt::SquareCap);
pps.setJoinStyle(Qt::RoundJoin);
int lineWith = fontSize/3;
pps.setWidth(lineWith);
QPainterPath path = pps.createStroke(pp);
p.setRenderHint(QPainter::Antialiasing);
p.fillPath(path, colorPath);
p.fillPath(pp, colorFont);
return;
}
QLabel::paintEvent( event);
}
//-------------------------------------------------
//
// Project created by 孙长鹏 2016-01-11T12:58:22
// Copyright (C) 2016 上海非码网络科技有限公司
// All rights reserved
//-------------------------------------------------
#ifndef LcMyLabel_H
#define LcMyLabel_H
#include <QObject>
#include <QWidget>
#include <QLabel>
class LcMyLabel : public QLabel
{
Q_OBJECT
public:
explicit LcMyLabel(QWidget *parent = 0);
typedef enum{
Big,
Small,
normal,
grayBig,
graySmall,
}LabSize;
LabSize labSize;
void getFontColor( QColor& colorPath, QColor& colorFont);
QColor colorPath,colorFont;
signals:
protected:
void paintEvent( QPaintEvent *event);
public slots:
private:
int getMaxSize(const QString& str, const int maxWidth);
};
#endif // LcMyLabel_H
#include "lcmynormal.h"
LcMyNormal::LcMyNormal(QWidget *parent) : LcMyLabel(parent)
{
labSize = normal;
getFontColor(colorPath, colorFont);
}
//-------------------------------------------------
//
// Project created by 孙长鹏 2016-01-11T12:58:22
// Copyright (C) 2016 上海非码网络科技有限公司
// All rights reserved
//-------------------------------------------------
#ifndef LCMYNORMAL_H
#define LCMYNORMAL_H
#include "lcmylabel.h"
class LcMyNormal : public LcMyLabel
{
Q_OBJECT
public:
explicit LcMyNormal(QWidget *parent = 0);
};
#endif // LCMYNORMAL_H
#include "lcmysmalllabel.h"
LcMySmallLabel::LcMySmallLabel(QWidget *parent) : LcMyLabel(parent)
{
labSize = Small;
getFontColor(colorPath, colorFont);
}
//-------------------------------------------------
//
// Project created by 孙长鹏 2016-01-11T12:58:22
// Copyright (C) 2016 上海非码网络科技有限公司
// All rights reserved
//-------------------------------------------------
#ifndef LcMySmallLabel_H
#define LcMySmallLabel_H
#include <QObject>
#include <QWidget>
#include <QLabel>
#include "lcmylabel.h"
class LcMySmallLabel : public LcMyLabel
{
Q_OBJECT
public:
explicit LcMySmallLabel(QWidget *parent = 0);
};
#endif // LcMyBigLabel_H
#include "mysock.h"
mySock::mySock(QObject *parent) : QThread(parent),quit(false)
{
hostName = "127.0.0.1";
port = 34952;
qRegisterMetaType<mySock::RequstType>("mySock::RequstType");
connect( this, &mySock::error, this, &mySock::threadQuitErr);
}
int ZH_caclChkValue(char * pJsonData, int startPos, int endPos)
{/* startPos <= && < endPos */
int value = 0, loop = startPos, count = 0;
for (; loop < endPos; loop++)
{
if( pJsonData[loop] == '"' || pJsonData[loop] == '\'')
continue;
if (2 > count){
value += (int)pJsonData[loop];
}
else if (2 == count){
value *= (int)pJsonData[loop];
}else{
value -= (int)pJsonData[loop];
}
count = (count + 1) & 3;
}
return value;
}
//585918355
QByteArray checkSendArray( QByteArray & jsonArray)
{
int size = jsonArray.size() + 50;
char* tmpBuf = new char[size];
memset(tmpBuf, 0, size);
//char tmpBuf[ jsonArray.size() + 50] = {0};
strcpy(tmpBuf, jsonArray.data());
int strLength = strlen(tmpBuf);
while('}' != tmpBuf[strLength - 1])
{
strLength--;
}
strLength--;
sprintf(tmpBuf + strLength, ", \"checkValue\":");
int aLength = strlen(tmpBuf + strLength);
int nValue = ZH_caclChkValue( tmpBuf, 0, strLength + 2);
strLength += aLength;
sprintf(tmpBuf + strLength, " %d", nValue);
aLength = strlen(tmpBuf + strLength);
strLength += aLength;
tmpBuf[strLength] = '}';
tmpBuf[strLength + 1] = '\0';
strLength ++;
QByteArray array(tmpBuf);
delete tmpBuf;
return array;
}
void mySock::threadQuitErr(int socketError, const QString &message)
{
}
void mySock::begin(const RequstType type, const QJsonObject &json)
{
QMutexLocker locker(&mutex); //锁
QJsonDocument doc(json);
QByteArray array = doc.toJson( QJsonDocument::Compact);
qDebug() << array;
sendArray = checkSendArray( array);
reType = type;
if( !isRunning()){
qDebug() << "stra";
start();
}else{
cond.wakeOne();
qDebug() << "wakeOne";
}
}
bool mySock::isFullJson(const QByteArray &array)
{
QJsonParseError json_error;
QJsonDocument::fromJson( array, &json_error);
return (json_error.error == QJsonParseError::NoError);
}
QJsonObject mySock::getReturnJsonObject(const QByteArray &array)
{
QJsonDocument doc = QJsonDocument::fromJson( array);
return doc.object();
}
void mySock::run()
{
mutex.lock();
QString serverName = hostName;
quint16 serverPort = port;
mutex.unlock();
while( !quit){
const int Timeout = 7 * 1000;
qDebug() << "get";
QTcpSocket socket;
//连接
socket.connectToHost(serverName, serverPort);
if (!socket.waitForConnected(Timeout)) {
emit error(socket.error(), socket.errorString());
return;
}
//发送
/*int wLen = */socket.write( sendArray);
if ( !socket.waitForBytesWritten( Timeout)){
emit error( socket.error(), socket.errorString());
return;
}
//接受
QByteArray receArray;
do{
if (!socket.waitForReadyRead(Timeout)) {
emit error(socket.error(), socket.errorString());
return;
}
receArray.append( socket.readAll());
}while( !isFullJson( receArray));
socket.close();
const QJsonObject returnJson = getReturnJsonObject( receArray);
qDebug() << "1";
mutex.lock();
emit sgReturnJson( reType, returnJson); //将数据返回给界面
qDebug()<<returnJson;
cond.wait(&mutex);
mutex.unlock();
}
}
mySock * g_sock = NULL;
mySock *getMySock()
{
if( g_sock == NULL)
g_sock = new mySock(qApp);
return g_sock;
}
//-------------------------------------------------
//
// Project created by 孙长鹏 2016-01-11T12:58:22
// Copyright (C) 2016 上海非码网络科技有限公司
// All rights reserved
//-------------------------------------------------
#ifndef MYSOCK_H
#define MYSOCK_H
#include <QObject>
#include <QTcpSocket>
#include <QThread>
#include <QWaitCondition>
#include <QMutexLocker>
#include <QJsonDocument>
#include <QJsonArray>
#include <QJsonObject>
#include <QApplication>
class mySock : public QThread
{
Q_OBJECT
public:
explicit mySock(QObject *parent = 0);
typedef enum{
Query,
Consume,
refund
}RequstType;
void begin(const mySock::RequstType type, const QJsonObject& json);
void run() Q_DECL_OVERRIDE;
signals:
void error(int socketError, const QString message);
void sgReturnJson(const mySock::RequstType type, const QJsonObject& json);
public slots:
private:
void threadQuitErr( int socketError, const QString &message);
bool isFullJson( const QByteArray& array);
QJsonObject getReturnJsonObject( const QByteArray& array);
//
QString hostName;
quint16 port;
//中间数据
QByteArray sendArray;
RequstType reType;
//锁和信号
QMutex mutex;
QWaitCondition cond;
bool quit;
};
mySock * getMySock();
#endif // MYSOCK_H
#include "workingdialog.h"
#include "ui_workingdialog.h"
WorkingDialog::WorkingDialog(QWidget *parent) :
QWidget(parent),
ui(new Ui::WorkingDialog)
{
ui->setupUi(this);
}
WorkingDialog::~WorkingDialog()
{
delete ui;
}
#ifndef WORKINGDIALOG_H
#define WORKINGDIALOG_H
#include <QWidget>
namespace Ui {
class WorkingDialog;
}
class WorkingDialog : public QWidget
{
Q_OBJECT
public:
explicit WorkingDialog(QWidget *parent = 0);
~WorkingDialog();
private:
Ui::WorkingDialog *ui;
};
#endif // WORKINGDIALOG_H
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>WorkingDialog</class>
<widget class="QWidget" name="WorkingDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>350</width>
<height>470</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>350</width>
<height>470</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>350</width>
<height>470</height>
</size>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="leftMargin">
<number>10</number>
</property>
<property name="topMargin">
<number>10</number>
</property>
<property name="rightMargin">
<number>10</number>
</property>
<property name="bottomMargin">
<number>10</number>
</property>
<item>
<widget class="QWidget" name="widget" native="true">
<widget class="LcMyNormal" name="labActName">
<property name="geometry">
<rect>
<x>0</x>
<y>100</y>
<width>330</width>
<height>65</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>330</width>
<height>65</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>330</width>
<height>65</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>LcMyNormal</class>
<extends>QLabel</extends>
<header location="global">lcmynormal.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>
//-------------------------------------------------
//
// Project created by 孙长鹏 2016-01-11T12:58:22
// Copyright (C) 2016 上海非码网络科技有限公司
// All rights reserved
//-------------------------------------------------
#ifndef WORKWIDGET_H
#define WORKWIDGET_H
#include <QTimer>
#include <QWidget>
#include <QObject>
#include <QJsonObject>
#include <QDate>
#include <QDateTime>
//#include "fmsock.h"
#include "consumptiondialog.h"
#include "consumokdialog.h"
#include "mysock.h"
#include "errcodedialog.h"
#include "refunddialog.h"
#include "prorefunddialog.h"
#include "scaningdialog.h"
namespace Ui {
class WorkWidget;
}
class WorkWidget : public QWidget
{
Q_OBJECT
public:
explicit WorkWidget(QWidget *parent = 0);
~WorkWidget();
void beginWork();
void refund();
signals:
void sgJosnCome( const QJsonObject& json);
public slots:
protected:
private:
void readCfgFile();
void readXmlFile();
void getQueryCodeJson(const QString code, const int is_manual);
void proQueryCodeJson(const QJsonObject& json);
void getConsumCodeJson();
void proGetConsumCodeJson( const QJsonObject& json);
void getRefundCodeJson( const QString code);
void proGetRefundCodeJson( const QJsonObject& json);
void slReturnJson(const mySock::RequstType type,
const QJsonObject &json);
void error(int socketError, const QString message);
void queryCode100( const QJsonObject& json);
void queryCode11( const QJsonObject& json);
void queryCode12( const QJsonObject& json);
void queryCode14( const QJsonObject& json);
void queryCodeErr( const QJsonObject& json);
void consumCode100( const QJsonObject& json);
void consumCodeErr( const QJsonObject& json);
QString act_name;
QString code_name;
QString time_name;
QString coupon;
QString storeId;
QString posNo;
int g_is_manual; //手输 1 其他为0
QJsonObject codeInfo;
int couponType;
QTimer timer;
int pointTime;
void timeout();
private:
Ui::WorkWidget *ui;
};
#endif // WORKWIDGET_H
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>WorkWidget</class>
<widget class="QWidget" name="WorkWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>350</width>
<height>470</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>350</width>
<height>470</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>3500</width>
<height>4700</height>
</size>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<property name="styleSheet">
<string notr="true">#WorkWidget{
border: none;
background-color: transparent;
}
#bgWidget{
border: none; background-color: transparent;
border-radius:12px;
background-image: url(:/res/bg_working.png);
}
#labActName{
font: 75 45pt &quot;微软雅黑&quot;;
color: rgb(255, 255, 0);
}</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QStackedWidget" name="stackedWidget">
<widget class="QWidget" name="page">
<widget class="QWidget" name="bgWidget" native="true">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>330</width>
<height>450</height>
</rect>
</property>
<widget class="LcMyNormal" name="labActName">
<property name="geometry">
<rect>
<x>0</x>
<y>110</y>
<width>330</width>
<height>65</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>330</width>
<height>65</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>330</width>
<height>65</height>
</size>
</property>
<property name="text">
<string>验证中......</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</widget>
</widget>
<widget class="QWidget" name="page_2">
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QWidget" name="widget" native="true">
<property name="styleSheet">
<string notr="true">font: 20pt;
background-color: rgb(255, 255, 255);</string>
</property>
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>0</x>
<y>140</y>
<width>332</width>
<height>50</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>50</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>50</height>
</size>
</property>
<property name="text">
<string>退货中.....</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>LcMyNormal</class>
<extends>QLabel</extends>
<header location="global">lcmynormal.h</header>
</customwidget>
</customwidgets>
<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