hlp:桂林国际齿轮泵代码

This commit is contained in:
kite_lucs
2026-10-09 10:25:24 +08:00
commit fd606b3c81
2447 changed files with 999531 additions and 0 deletions
Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

@@ -0,0 +1,801 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
** This file is part of the QtCore module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this
** file. Please review the following information to ensure the GNU Lesser
** General Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU General
** Public License version 3.0 as published by the Free Software Foundation
** and appearing in the file LICENSE.GPL included in the packaging of this
** file. Please review the following information to ensure the GNU General
** Public License version 3.0 requirements will be met:
** http://www.gnu.org/copyleft/gpl.html.
**
** Other Usage
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include <qdebug.h>
#include "qjsonparser_p.h"
#include "qjson_p.h"
//#define PARSER_DEBUG
#ifdef PARSER_DEBUG
static int indent = 0;
#define BEGIN qDebug() << QByteArray(4*indent++, ' ').constData() << "pos=" << current
#define END --indent
#define DEBUG qDebug() << QByteArray(4*indent, ' ').constData()
#else
#define BEGIN if (1) ; else qDebug()
#define END do {} while (0)
#define DEBUG if (1) ; else qDebug()
#endif
QT_BEGIN_NAMESPACE
using namespace QJsonPrivate;
Parser::Parser(const char *json, int length)
: head(json), json(json), data(0), dataLength(0), current(0), lastError(QJsonParseError::NoError)
{
end = json + length;
}
/*
begin-array = ws %x5B ws ; [ left square bracket
begin-object = ws %x7B ws ; { left curly bracket
end-array = ws %x5D ws ; ] right square bracket
end-object = ws %x7D ws ; } right curly bracket
name-separator = ws %x3A ws ; : colon
value-separator = ws %x2C ws ; , comma
Insignificant whitespace is allowed before or after any of the six
structural characters.
ws = *(
%x20 / ; Space
%x09 / ; Horizontal tab
%x0A / ; Line feed or New line
%x0D ; Carriage return
)
*/
enum {
Space = 0x20,
Tab = 0x09,
LineFeed = 0x0a,
Return = 0x0d,
BeginArray = 0x5b,
BeginObject = 0x7b,
EndArray = 0x5d,
EndObject = 0x7d,
NameSeparator = 0x3a,
ValueSeparator = 0x2c,
Quote = 0x22
};
bool Parser::eatSpace()
{
while (json < end) {
if (*json > Space)
break;
if (*json != Space &&
*json != Tab &&
*json != LineFeed &&
*json != Return)
break;
++json;
}
return (json < end);
}
char Parser::nextToken()
{
if (!eatSpace())
return 0;
char token = *json++;
switch (token) {
case BeginArray:
case BeginObject:
case NameSeparator:
case ValueSeparator:
case EndArray:
case EndObject:
eatSpace();
case Quote:
break;
default:
token = 0;
break;
}
return token;
}
/*
JSON-text = object / array
*/
QJsonDocument Parser::parse(QJsonParseError *error)
{
#ifdef PARSER_DEBUG
indent = 0;
qDebug() << ">>>>> parser begin";
#endif
// allocate some space
dataLength = qMax(end - json, (ptrdiff_t) 256);
data = (char *)malloc(dataLength);
// fill in Header data
QJsonPrivate::Header *h = (QJsonPrivate::Header *)data;
h->tag = QJsonDocument::BinaryFormatTag;
h->version = 1u;
current = sizeof(QJsonPrivate::Header);
char token = nextToken();
DEBUG << token;
if (token == BeginArray) {
if (!parseArray())
goto error;
} else if (token == BeginObject) {
if (!parseObject())
goto error;
} else {
goto error;
}
END;
{
if (error) {
error->offset = 0;
error->error = QJsonParseError::NoError;
}
QJsonPrivate::Data *d = new QJsonPrivate::Data(data, current);
return QJsonDocument(d);
}
error:
#ifdef PARSER_DEBUG
qDebug() << ">>>>> parser error";
#endif
if (error) {
error->offset = json - head;
error->error = lastError;
}
free(data);
return QJsonDocument();
}
void Parser::ParsedObject::insert(uint offset) {
const QJsonPrivate::Entry *newEntry = reinterpret_cast<const QJsonPrivate::Entry *>(parser->data + objectPosition + offset);
int min = 0;
int n = offsets.size();
while (n > 0) {
int half = n >> 1;
int middle = min + half;
if (*entryAt(middle) >= *newEntry) {
n = half;
} else {
min = middle + 1;
n -= half + 1;
}
}
if (min < offsets.size() && *entryAt(min) == *newEntry) {
offsets[min] = offset;
} else {
offsets.insert(min, offset);
}
}
/*
object = begin-object [ member *( value-separator member ) ]
end-object
*/
bool Parser::parseObject()
{
int objectOffset = reserveSpace(sizeof(QJsonPrivate::Object));
BEGIN << "parseObject pos=" << objectOffset << current << json;
ParsedObject parsedObject(this, objectOffset);
char token = nextToken();
while (token == Quote) {
int off = current - objectOffset;
if (!parseMember(objectOffset))
return false;
parsedObject.insert(off);
token = nextToken();
if (token != ValueSeparator)
break;
token = nextToken();
if (token == EndObject) {
lastError = QJsonParseError::MissingObject;
return false;
}
}
DEBUG << "end token=" << token;
if (token != EndObject) {
lastError = QJsonParseError::UnterminatedObject;
return false;
}
DEBUG << "numEntries" << parsedObject.offsets.size();
int table = objectOffset;
// finalize the object
if (parsedObject.offsets.size()) {
int tableSize = parsedObject.offsets.size()*sizeof(uint);
table = reserveSpace(tableSize);
#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
memcpy(data + table, parsedObject.offsets.constData(), tableSize);
#else
offset *o = (offset *)(data + table);
for (int i = 0; i < tableSize; ++i)
o[i] = parsedObject.offsets[i];
#endif
}
QJsonPrivate::Object *o = (QJsonPrivate::Object *)(data + objectOffset);
o->tableOffset = table - objectOffset;
o->size = current - objectOffset;
o->is_object = true;
o->length = parsedObject.offsets.size();
DEBUG << "current=" << current;
END;
return true;
}
/*
member = string name-separator value
*/
bool Parser::parseMember(int baseOffset)
{
int entryOffset = reserveSpace(sizeof(QJsonPrivate::Entry));
BEGIN << "parseMember pos=" << entryOffset;
bool latin1;
if (!parseString(&latin1))
return false;
char token = nextToken();
if (token != NameSeparator) {
lastError = QJsonParseError::MissingNameSeparator;
return false;
}
QJsonPrivate::Value val;
if (!parseValue(&val, baseOffset))
return false;
// finalize the entry
QJsonPrivate::Entry *e = (QJsonPrivate::Entry *)(data + entryOffset);
e->value = val;
e->value.latinKey = latin1;
END;
return true;
}
/*
array = begin-array [ value *( value-separator value ) ] end-array
*/
bool Parser::parseArray()
{
BEGIN << "parseArray";
int arrayOffset = reserveSpace(sizeof(QJsonPrivate::Array));
QVarLengthArray<QJsonPrivate::Value> values;
if (!eatSpace()) {
lastError = QJsonParseError::UnterminatedArray;
return false;
}
if (*json == EndArray) {
nextToken();
} else {
while (1) {
QJsonPrivate::Value val;
if (!parseValue(&val, arrayOffset))
return false;
values.append(val);
char token = nextToken();
if (token == EndArray)
break;
else if (token != ValueSeparator) {
if (!eatSpace())
lastError = QJsonParseError::UnterminatedArray;
else
lastError = QJsonParseError::MissingValueSeparator;
return false;
}
}
}
DEBUG << "size =" << values.size();
int table = arrayOffset;
// finalize the object
if (values.size()) {
int tableSize = values.size()*sizeof(QJsonPrivate::Value);
table = reserveSpace(tableSize);
memcpy(data + table, values.constData(), tableSize);
}
QJsonPrivate::Array *a = (QJsonPrivate::Array *)(data + arrayOffset);
a->tableOffset = table - arrayOffset;
a->size = current - arrayOffset;
a->is_object = false;
a->length = values.size();
DEBUG << "current=" << current;
END;
return true;
}
/*
value = false / null / true / object / array / number / string
*/
bool Parser::parseValue(QJsonPrivate::Value *val, int baseOffset)
{
BEGIN << "parse Value" << json;
val->_dummy = 0;
switch (*json++) {
case 'n':
if (end - json < 4) {
lastError = QJsonParseError::IllegalValue;
return false;
}
if (*json++ == 'u' &&
*json++ == 'l' &&
*json++ == 'l') {
val->type = QJsonValue::Null;
DEBUG << "value: null";
END;
return true;
}
lastError = QJsonParseError::IllegalValue;
return false;
case 't':
if (end - json < 4) {
lastError = QJsonParseError::IllegalValue;
return false;
}
if (*json++ == 'r' &&
*json++ == 'u' &&
*json++ == 'e') {
val->type = QJsonValue::Bool;
val->value = true;
DEBUG << "value: true";
END;
return true;
}
lastError = QJsonParseError::IllegalValue;
return false;
case 'f':
if (end - json < 5) {
lastError = QJsonParseError::IllegalValue;
return false;
}
if (*json++ == 'a' &&
*json++ == 'l' &&
*json++ == 's' &&
*json++ == 'e') {
val->type = QJsonValue::Bool;
val->value = false;
DEBUG << "value: false";
END;
return true;
}
lastError = QJsonParseError::IllegalValue;
return false;
case Quote: {
val->type = QJsonValue::String;
val->value = current - baseOffset;
bool latin1;
if (!parseString(&latin1))
return false;
val->latinOrIntValue = latin1;
DEBUG << "value: string";
END;
return true;
}
case BeginArray:
val->type = QJsonValue::Array;
val->value = current - baseOffset;
if (!parseArray())
return false;
DEBUG << "value: array";
END;
return true;
case BeginObject:
val->type = QJsonValue::Object;
val->value = current - baseOffset;
if (!parseObject())
return false;
DEBUG << "value: object";
END;
return true;
case EndArray:
lastError = QJsonParseError::MissingObject;
return false;
default:
--json;
if (!parseNumber(val, baseOffset))
return false;
DEBUG << "value: number";
END;
}
return true;
}
/*
number = [ minus ] int [ frac ] [ exp ]
decimal-point = %x2E ; .
digit1-9 = %x31-39 ; 1-9
e = %x65 / %x45 ; e E
exp = e [ minus / plus ] 1*DIGIT
frac = decimal-point 1*DIGIT
int = zero / ( digit1-9 *DIGIT )
minus = %x2D ; -
plus = %x2B ; +
zero = %x30 ; 0
*/
bool Parser::parseNumber(QJsonPrivate::Value *val, int baseOffset)
{
BEGIN << "parseNumber" << json;
val->type = QJsonValue::Double;
const char *start = json;
bool isInt = true;
// minus
if (json < end && *json == '-')
++json;
// int = zero / ( digit1-9 *DIGIT )
if (json < end && *json == '0') {
++json;
} else {
while (json < end && *json >= '0' && *json <= '9')
++json;
}
// frac = decimal-point 1*DIGIT
if (json < end && *json == '.') {
isInt = false;
++json;
while (json < end && *json >= '0' && *json <= '9')
++json;
}
// exp = e [ minus / plus ] 1*DIGIT
if (json < end && (*json == 'e' || *json == 'E')) {
isInt = false;
++json;
if (json < end && (*json == '-' || *json == '+'))
++json;
while (json < end && *json >= '0' && *json <= '9')
++json;
}
if (json >= end) {
lastError = QJsonParseError::EndOfNumber;
return false;
}
QByteArray number(start, json - start);
DEBUG << "numberstring" << number;
if (isInt) {
bool ok;
int n = number.toInt(&ok);
if (ok && n < (1<<25) && n > -(1<<25)) {
val->int_value = n;
val->latinOrIntValue = true;
END;
return true;
}
}
bool ok;
union {
quint64 ui;
double d;
};
d = number.toDouble(&ok);
if (!ok) {
lastError = QJsonParseError::IllegalNumber;
return false;
}
int pos = reserveSpace(sizeof(double));
*(quint64 *)(data + pos) = qToLittleEndian(ui);
val->value = pos - baseOffset;
val->latinOrIntValue = false;
END;
return true;
}
/*
string = quotation-mark *char quotation-mark
char = unescaped /
escape (
%x22 / ; " quotation mark U+0022
%x5C / ; \ reverse solidus U+005C
%x2F / ; / solidus U+002F
%x62 / ; b backspace U+0008
%x66 / ; f form feed U+000C
%x6E / ; n line feed U+000A
%x72 / ; r carriage return U+000D
%x74 / ; t tab U+0009
%x75 4HEXDIG ) ; uXXXX U+XXXX
escape = %x5C ; \
quotation-mark = %x22 ; "
unescaped = %x20-21 / %x23-5B / %x5D-10FFFF
*/
static inline bool addHexDigit(char digit, uint *result)
{
*result <<= 4;
if (digit >= '0' && digit <= '9')
*result |= (digit - '0');
else if (digit >= 'a' && digit <= 'f')
*result |= (digit - 'a') + 10;
else if (digit >= 'A' && digit <= 'F')
*result |= (digit - 'A') + 10;
else
return false;
return true;
}
static inline bool scanEscapeSequence(const char *&json, const char *end, uint *ch)
{
++json;
if (json >= end)
return false;
DEBUG << "scan escape" << (char)*json;
uint escaped = *json++;
switch (escaped) {
case '"':
*ch = '"'; break;
case '\\':
*ch = '\\'; break;
case '/':
*ch = '/'; break;
case 'b':
*ch = 0x8; break;
case 'f':
*ch = 0xc; break;
case 'n':
*ch = 0xa; break;
case 'r':
*ch = 0xd; break;
case 't':
*ch = 0x9; break;
case 'u': {
*ch = 0;
if (json > end - 4)
return false;
for (int i = 0; i < 4; ++i) {
if (!addHexDigit(*json, ch))
return false;
++json;
}
return true;
}
default:
// this is not as strict as one could be, but allows for more Json files
// to be parsed correctly.
*ch = escaped;
return true;
}
return true;
}
static inline bool isUnicodeNonCharacter(uint ucs4)
{
// Unicode has a couple of "non-characters" that one can use internally,
// but are not allowed to be used for text interchange.
//
// Those are the last two entries each Unicode Plane (U+FFFE, U+FFFF,
// U+1FFFE, U+1FFFF, etc.) as well as the entries between U+FDD0 and
// U+FDEF (inclusive)
return (ucs4 & 0xfffe) == 0xfffe
|| (ucs4 - 0xfdd0U) < 16;
}
static inline bool scanUtf8Char(const char *&json, const char *end, uint *result)
{
int need;
uint min_uc;
uint uc;
uchar ch = *json++;
if (ch < 128) {
*result = ch;
return true;
} else if ((ch & 0xe0) == 0xc0) {
uc = ch & 0x1f;
need = 1;
min_uc = 0x80;
} else if ((ch & 0xf0) == 0xe0) {
uc = ch & 0x0f;
need = 2;
min_uc = 0x800;
} else if ((ch&0xf8) == 0xf0) {
uc = ch & 0x07;
need = 3;
min_uc = 0x10000;
} else {
return false;
}
if (json >= end - need)
return false;
for (int i = 0; i < need; ++i) {
ch = *json++;
if ((ch&0xc0) != 0x80)
return false;
uc = (uc << 6) | (ch & 0x3f);
}
if (isUnicodeNonCharacter(uc) || uc >= 0x110000 ||
(uc < min_uc) || (uc >= 0xd800 && uc <= 0xdfff))
return false;
*result = uc;
return true;
}
bool Parser::parseString(bool *latin1)
{
*latin1 = true;
const char *start = json;
int outStart = current;
// try to write out a latin1 string
int stringPos = reserveSpace(2);
BEGIN << "parse string stringPos=" << stringPos << json;
while (json < end) {
uint ch = 0;
if (*json == '"')
break;
else if (*json == '\\') {
if (!scanEscapeSequence(json, end, &ch)) {
lastError = QJsonParseError::StringEscapeSequence;
return false;
}
} else {
if (!scanUtf8Char(json, end, &ch)) {
lastError = QJsonParseError::StringUTF8Scan;
return false;
}
}
if (ch > 0xff) {
*latin1 = false;
break;
}
int pos = reserveSpace(1);
DEBUG << " " << ch << (char)ch;
data[pos] = (uchar)ch;
}
++json;
DEBUG << "end of string";
if (json >= end) {
lastError = QJsonParseError::EndOfString;
return false;
}
// no unicode string, we are done
if (*latin1) {
// write string length
*(QJsonPrivate::qle_ushort *)(data + stringPos) = current - outStart - sizeof(ushort);
int pos = reserveSpace((4 - current) & 3);
while (pos & 3)
data[pos++] = 0;
END;
return true;
}
*latin1 = false;
DEBUG << "not latin";
json = start;
current = outStart + sizeof(int);
while (json < end) {
uint ch = 0;
if (*json == '"')
break;
else if (*json == '\\') {
if (!scanEscapeSequence(json, end, &ch)) {
lastError = QJsonParseError::StringEscapeSequence;
return false;
}
} else {
if (!scanUtf8Char(json, end, &ch)) {
lastError = QJsonParseError::StringUTF8Scan;
return false;
}
}
if (ch > 0xffff) {
int pos = reserveSpace(4);
*(QJsonPrivate::qle_ushort *)(data + pos) = QChar::highSurrogate(ch);
*(QJsonPrivate::qle_ushort *)(data + pos + 2) = QChar::lowSurrogate(ch);
} else {
int pos = reserveSpace(2);
*(QJsonPrivate::qle_ushort *)(data + pos) = (ushort)ch;
}
}
++json;
if (json >= end) {
lastError = QJsonParseError::EndOfString;
return false;
}
// write string length
*(QJsonPrivate::qle_int *)(data + stringPos) = (current - outStart - sizeof(int))/2;
int pos = reserveSpace((4 - current) & 3);
while (pos & 3)
data[pos++] = 0;
END;
return true;
}
QT_END_NAMESPACE
@@ -0,0 +1,33 @@
#ifndef DIALOGINSERTVARI_H
#define DIALOGINSERTVARI_H
#include <QDialog>
namespace Ui {
class DialogInsertVari;
}
class DialogInsertVari : public QDialog
{
Q_OBJECT
public:
explicit DialogInsertVari(QWidget *parent = 0);
~DialogInsertVari();
void getValue(int *varType,int *digitalWidth,unsigned char *splitMode);
void setValue(QString txt);
void EnableHiddenValue(bool select);
protected slots:
void onRanDomPressed(bool Flag);
void onDigitOtherBit(bool Flag);
void onDigitTwoBit(bool Flag);
void onDigitFourBit(bool Flag);
private slots:
void on_buttonBox_accepted();
private:
Ui::DialogInsertVari *ui;
int digitWidth;
};
#endif // DIALOGINSERTVARI_H
@@ -0,0 +1,278 @@
#include <QtGui/QApplication>
#include <QVBoxLayout>
#include <InputMethod.h>
#include <QKeyEvent>
#include <QTextCodec>
#include <QTextEdit>
#include <QFont>
#include <QWSServer>
#include <stdio.h>
#include "InkJetPrinter.h"
#include "logo_form.h"
#include "MyInputMethod.h"
#include "mainwindow.h"
#include <QDebug>
#include <QTranslator>
#include <QMessageBox>
#include <QStyleFactory>
#include "myinclude.h"
#include "Public.h"
#include "Log/filelogger.h"
//#define SYS_CN
/*
1. WenQuanYiMH_12_50.qpf2 是由 Zfull-GB_12_50(Zpix.ttf)在PCMAKEQPF软件下生成的,它包含较完整的字体库 nono 20160302
2. 基于WenQuanYiCN编越南语,中文通用字库
3. 基于WenQuanYiMicroHei编 普通版本字库
#git commit -am "测试提交新数据"
#git push
#git clone xiongnie@119.23.201.56:/var/repo_dir/QtUI.git
#git pull xiongnie@119.23.201.56:/var/repo_dir/QtUI.git
#git remote add origin git@github.com:username/Hello-World.git
#git push origin master 将本地项目给提交到服务器中
#-----------------------------------------------------------
#git pull 本地与服务器端同步
#-----------------------------------------------------------------
#git push (远程仓库名) (分支名) 将本地分支推送到服务器上去。
#git push origin serverfix:awesomebranch
git remote add origin xiongnie@119.23.201.56:/var/repo_dir/QRUIV53.git
###
*/
InkJetPrinter *pInkJectPrinter;
MyInputMethod *myInputMethod;
//#include <X11/Xlib.h>
//#include <X11/X.h>
//#include <X11/Xutil.h>
int main(int argc, char *argv[])
{
// QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
// QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);//控制图片缩放质量
// // Open a display.
// Display *d = XOpenDisplay(NULL);
// // Get width and height of the display
// //int windowHeight = XDisplayHeight (d, 0);
// qreal windowWidth = XDisplayWidth(d, 0);
// qreal windowWidth = 800;
// qreal scale = windowWidth / 640;
// //qputenv("QT_SCALE_FACTOR", QString::number(scale).toLatin1());
//qputenv("QT_AUTO_SCREEN_SCALE_FACTOR", "1.5");
// qputenv("QT_SCALE_FACTOR", QByteArray("1.25"));
// qputenv("QT_IM_MODULE", QByteArray("qtvirtualkeyboard"));
// QByteArray byte = qgetenv("QT_SCALE_FACTOR");
// qDebug() << "qgutenv byte=============================" << byte;
// QByteArray byteModule = qgetenv("QT_IM_MODULE");
// qDebug() << "qgutenv byteModule=============================" << byteModule;
// QLocale::setDefault(QLocale(QLocale::Vietnamese, QLocale::VietNam));
QApplication a(argc, argv,QApplication::GuiServer);
// QDesktopWidget *desktop = a.desktop();
// int screen_number = desktop->primaryScreen();
// QRect rect = desktop->screenGeometry(screen_number);
//qDebug() << QStyleFactory::keys();
QApplication::setStyle(QStyleFactory::create("Windows"));
QFont f = a.font();
QString langurageFile;
QFile file(SYS_ROOT_DIR"UseEn");
if(file.exists())
{
#ifdef VNLG
QString langurageType = Public::ReadLanguageName();//"";//
//qDebug()<<"La:"<<langurageType;
if(langurageType=="中文"){
f.setFamily("WenQuanYiMH");// WenQuanYiMH -- 由 WenQuanYiMicroHei_12_50目录生成,
f.setPointSize(12);
f.setPixelSize(12);
langurageFile ="./qt_zh_CN.qm";/*系统默认的翻译文件在/usr/local/Trolltech/QtEmbedded-4.6.3/translations/ 下面*/
}
else if(langurageType=="Vietnamese") {
f.setFamily("WenQuanYiNX");//f.setFamily("Zfull-GB"); //f.setFamily("WenQuanYiMH");//Cambria
f.setPointSize(13);
//f.setFixedPitch(1);
f.setPixelSize(13);
langurageFile= "./vena.qm";
}
else if(langurageType=="English") {
f.setFamily("WenQuanYiNX");//f.setFamily("Zfull-GB"); //f.setFamily("WenQuanYiMH");//Cambria
f.setPointSize(13);
f.setPixelSize(13);
langurageFile= "./english.qm";
}
else {
f.setPointSize(12);
//f.setFamily("wenquanyi_zh");//WenQuanYiMH
//f.setFamily("WenQuanYiNX");//f.setFamily("Zfull-GB"); //f.setFamily("UnDotum"); //
f.setFamily("WenQuanYiMH");
f.setPixelSize(12);
langurageFile ="./qt_zh_CN.qm";/*系统默认的翻译文件在/usr/local/Trolltech/QtEmbedded-4.6.3/translations/ 下面*/
}
#else
QString langurageType = Public::ReadLanguageName();//"";//
qDebug()<<"La:"<<langurageType;
if(langurageType=="Turkish") {
f.setFamily("wenquanyi_zh");
langurageFile= "./turkey.qm";
f.setPointSize(12);
f.setPixelSize(12);
}
else if(langurageType=="Spanish")
{
//f.setFamily("WenQuanYiNX");//f.setFamily("Zfull-GB"); //f.setFamily("WenQuanYiMH");//Cambria
f.setFamily("wenquanyi_zh");
langurageFile= "./spanish.qm";
f.setPointSize(12);
f.setPixelSize(12);
}
else if(langurageType=="Thai")
{
//f.setFamily("WenQuanYiNX");//f.setFamily("Zfull-GB"); //f.setFamily("WenQuanYiMH");//Cambria
f.setFamily("Kanit");
langurageFile= "./thai.qm";
f.setPointSize(12);
f.setPixelSize(12);
}
else if(langurageType=="Vietnamese") {
f.setFamily("Arial");//f.setFamily("Zfull-GB"); //f.setFamily("WenQuanYiMH");//Cambria
f.setPointSize(12);
//f.setFixedPitch(1);
f.setPixelSize(12);
langurageFile= "./vena.qm";
}
else if(langurageType=="English") {
f.setFamily("Arial");
//#ifdef EnableArabic
// f.setFamily("Arial");
//#endif
#ifdef EnableBangla
f.setFamily("wenquanyi_zh");
#endif
langurageFile= "./english.qm";
f.setPointSize(12);
f.setPixelSize(12);
}
else if(langurageType=="Farsi") {
//f.setFamily("WenQuanYiNX");//f.setFamily("Zfull-GB"); //f.setFamily("WenQuanYiMH");//Cambria
f.setFamily("Arial");
langurageFile= "./farsi.qm";
f.setPointSize(12);
f.setPixelSize(12);
}
else{
f.setPointSize(16);
f.setFamily("WenQuanYiMH");
//f.setFamily("wenquanyi_zh");
f.setPixelSize(16);
langurageFile ="./qt_zh_CN.qm";/*系统默认的翻译文件在/usr/local/Trolltech/QtEmbedded-4.6.3/translations/ 下面*/
}
/*
f.setPointSize(12);
//f.setFamily("wenquanyi_zh");//WenQuanYiMH
//f.setFamily("WenQuanYiNX");//f.setFamily("Zfull-GB"); //f.setFamily("UnDotum"); //
f.setFamily("WenQuanYiMH");
f.setPixelSize(12);
langurageFile ="./qt_zh_CN.qm";
//langurageFile= "./english.qm";
*/
#endif
// qDebug()<<"languageFile:"<<langurageType<<langurageFile;
//Việt Nam
}
else{
langurageFile ="./qt_zh_CN.qm";/*系统默认的翻译文件在/usr/local/Trolltech/QtEmbedded-4.6.3/translations/ 下面*/
#ifdef ENGLISH
langurageFile= "./english.qm";
#endif
#ifdef VNLG
f.setFamily("WenQuanYiMH");
#else
//f.setFamily("wenquanyi_zh");
f.setFamily("wenquanyi");
#endif
//qDebug()<<"languageFile:"<<f.family()<<langurageFile;
}
a.setFont(f);
/*-------------------------------------------------*/
QTextCodec *codec = QTextCodec::codecForName("UTF-8");
QTextCodec::setCodecForLocale(codec);
QTextCodec::setCodecForCStrings(codec);
QTextCodec::setCodecForTr(codec);
/*------------------语言国际化-------------------------*/
QTranslator *translator = new QTranslator();
if(translator->load(langurageFile)==false){
translator->deleteLater();
QMessageBox::critical(0,("错误"),("无法加载中文翻译文件") + langurageFile);
}
else {
QApplication::installTranslator(translator);
}
#ifndef Q_OS_WIN32
//QWSServer::setCurrentInputMethod(new MyInputMethod());
myInputMethod = new MyInputMethod();
QWSServer::setCurrentInputMethod(myInputMethod);
#endif
// 配置日志
//QString configFileName = QCoreApplication::applicationDirPath() + "/config.ini";
QString configFileName = ":/conf/config.ini";
QSettings* logSettings = new QSettings(configFileName, QSettings::IniFormat, &a);
logSettings->beginGroup("logging");
FileLogger* logger = new FileLogger(logSettings, 10000, &a);
logger->installMsgHandler();
InkJetPrinter w;
#ifndef Q_OS_WIN32
w.setWindowTitle(("比洋喷码"));
#if 0
w.setStyleSheet("QTabBar::tab {height:70px;} QTabBar::scroller{ width:40px;} QRadioButton::indicator{ width: 50px; height: 50px; } \
QCheckBox::indicator { width: 18px; height: 18px; } ");
#endif
//edit@11-28
const QString style_main2="QTabBar::tab {height:55px;border-top-left-radius: 6px;border-top-right-radius: 6px;padding-left: 11px;padding-right: 11px;border: 2px solid #C4C4C3;} \
QTabBar::tab:selected {background-color: rgb(255, 170, 127);height:57px;}\
QTabBar::tab:!selected {margin-top: 2px;}\
QTabBar::scroller{ width:40px;} \
QRadioButton::indicator{ width: 45px; height: 45px; } \
QCheckBox::indicator { width: 18px; height: 18px; } ";
w.setStyleSheet(style_main2);
w.showFullScreen(); /*保证全屏,看不到系统标题*/
#endif
w.show();
pInkJectPrinter = &w;
return a.exec();
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 8.1 KiB

@@ -0,0 +1,173 @@
/*
* code39.c -- encoding for code39
*
* Copyright (c) 1999 Alessandro Rubini (rubini@gnu.org)
* Copyright (c) 1999 Prosa Srl. (prosa@prosa.it)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <errno.h>
#include "barcode.h"
/* this is ordered in decades to simplify encoding */
static char alphabet[] =
"1234567890" "ABCDEFGHIJ" "KLMNOPQRST" "UVWXYZ-. *" "$/+%";
/* the checksum alphabet has a different order */
static char checkbet[] =
"0123456789" "ABCDEFGHIJ" "KLMNOPQRST" "UVWXYZ-. $" "/+%";
/* The first 40 symbols repeat this bar pattern */
static char *bars[] = {
"31113","13113","33111","11313","31311",
"13311","11133","31131","13131","11331"};
/* The first 4 decades use these space patterns */
static char *spaces[] = {"1311","1131","1113","3111"};
/* the last four symbols are special */
static char *specialbars[] = {
"11111","11111","11111","11111"};
static char *specialspaces[] = {
"3331","3313","3133","1333"};
static char *fillers[]= {
"0a3a1c1c1a",
"1a3a1c1c1a"
};
/*
* Check that the text can be encoded. Returns 0 or -1.
* If it's all lowecase convert to uppercase and accept it
*/
int Barcode_39_verify(unsigned char *text)
{
int i, lower=0, upper=0;
if (text[0] == '\0')
return -1;
for (i=0; text[i]; i++) {
if (isupper(text[i])) upper++;
if (islower(text[i])) lower++;
if (!strchr(alphabet,toupper(text[i])))
return -1;
}
if (lower && upper)
return -1;
return 0;
}
static int add_one(char *ptr, int code)
{
char *b, *s;
if (code < 40) {
b = bars[code%10];
s = spaces[code/10];
} else {
b = specialbars[code-40];
s = specialspaces[code-40];
}
sprintf(ptr,"1%c%c%c%c%c%c%c%c%c", /* separator */
b[0], s[0], b[1], s[1], b[2], s[2],
b[3], s[3], b[4]);
return 0;
}
/*
* The encoding functions fills the "partial" and "textinfo" fields.
* Lowercase chars are converted to uppercase
*/
int Barcode_39_encode(struct Barcode_Item *bc)
{
static char *text;
static char *partial; /* dynamic */
static char *textinfo; /* dynamic */
char *c, *ptr, *textptr;
int i, code, textpos, checksum = 0;
if (bc->partial)
free(bc->partial);
if (bc->textinfo)
free(bc->textinfo);
bc->partial = bc->textinfo = NULL; /* safe */
if (!bc->encoding)
bc->encoding = strdup("code 39");
text = bc->ascii;
if (!text) {
bc->error = EINVAL;
return -1;
}
/* the partial code is 10* (head + text + check + tail) + margin + term. */
partial = malloc( (strlen(text) + 3) * 10 +2);
if (!partial) {
bc->error = errno;
return -1;
}
/* the text information is at most "nnn:fff:c " * strlen +term */
textinfo = malloc(10*strlen(text) + 2);
if (!textinfo) {
bc->error = errno;
free(partial);
return -1;
}
strcpy(partial, fillers[0]);
ptr = partial + strlen(partial);
textptr = textinfo;
textpos = 22;
for (i=0; text[i]; i++) {
c = strchr(alphabet, toupper(text[i]));
if (!c) {
bc->error = EINVAL; /* impossible if text is verified */
free(partial);
free(textinfo);
return -1;
}
code = c - alphabet;
add_one(ptr, code);
c = strchr(checkbet,*c);
if (c) /* the '*' is not there */
checksum += (c-checkbet);
sprintf(textptr, "%i:12:%c ", textpos, toupper(text[i]));
textpos += 16; /* width of each code */
textptr += strlen(textptr);
ptr += strlen(ptr);
}
/* Add the checksum */
if ( (bc->flags & BARCODE_NO_CHECKSUM)==0 ) {
code = (strchr(alphabet, checkbet[checksum % 43]) - alphabet);
add_one(ptr, code);
}
strcat(ptr, fillers[1]); /* end */
bc->partial = partial;
bc->textinfo = textinfo;
return 0;
}