hlp:桂林国际齿轮泵代码
This commit is contained in:
@@ -0,0 +1,135 @@
|
||||
#include "dlgmutilanguage.h"
|
||||
#include "ui_dlgmutilanguage.h"
|
||||
#include "InputMethod.h"
|
||||
#include <QFile>
|
||||
#include <unistd.h>
|
||||
|
||||
DlgMutiLanguage::DlgMutiLanguage(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::DlgMutiLanguage)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
// ui->listWidget->hide();
|
||||
connect(ui->buttonBox,SIGNAL(accepted()),this,SLOT(SetNewLanguage()));
|
||||
LangIndex=INPUT_METHOD_TYPE_CHINESE;
|
||||
}
|
||||
|
||||
DlgMutiLanguage::~DlgMutiLanguage()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void DlgMutiLanguage::setCurrentLanguage(){
|
||||
|
||||
if(LangIndex==INPUT_METHOD_TYPE_ENGLISH) ui->radioButton_2->setChecked(true);
|
||||
else if(LangIndex==INPUT_METHOD_TYPE_CHINESE) ui->radioButton->setChecked(true);
|
||||
else if(LangIndex==INPUT_METHOD_TYPE_VIETNAM) ui->radioButton_3->setChecked(true);
|
||||
//else if(LangIndex==INPUT_METHOD_TYPE_RUSSIAN) ui->radioButton_4->setChecked(true);
|
||||
//else if(LangIndex==INPUT_METHOD_TYPE_JAPANESE) ui->radioButton_5->setChecked(true);
|
||||
//else if(LangIndex==INPUT_METHOD_TYPE_KOREAN) ui->radioButton_6->setChecked(true);
|
||||
else ui->radioButton->setChecked(true);
|
||||
|
||||
}
|
||||
|
||||
int DlgMutiLanguage::getCurrentLanguage(){
|
||||
// LangIndex = INPUT_METHOD_TYPE_CHINESE;
|
||||
// if(ui->radioButton_2->isChecked()) {
|
||||
// LangIndex = INPUT_METHOD_TYPE_ENGLISH;
|
||||
// QMessageBox::information(this,tr("提示"),tr("重启后切换到英文界面"));
|
||||
// buf.append("English\r\n");
|
||||
// buf.append("WINPY_utf8.txt\r\n");
|
||||
// }
|
||||
// else if(ui->radioButton_3->isChecked()) {
|
||||
// LangIndex = INPUT_METHOD_TYPE_VIETNAM;
|
||||
// QMessageBox::information(this,tr("提示"),tr("重启后切换到越南语界面"));
|
||||
// buf.append("Vietnamese\r\n");
|
||||
// buf.append("YN_utf8.txt\r\n");
|
||||
// }
|
||||
// /*else if(ui->radioButton->isChecked()) {
|
||||
|
||||
// }
|
||||
// else if(ui->radioButton->isChecked()) {
|
||||
|
||||
// }
|
||||
// else if(ui->radioButton->isChecked()) {
|
||||
|
||||
// }*/
|
||||
// else {
|
||||
// QMessageBox::information(this,tr("提示"),tr("重启后切换到中文界面"));
|
||||
// buf.append("Chinese\r\n");
|
||||
// buf.append("WINPY_utf8.txt\r\n");
|
||||
// }
|
||||
return LangIndex;
|
||||
}
|
||||
void DlgMutiLanguage::SetNewLanguage(){
|
||||
|
||||
LangIndex = INPUT_METHOD_TYPE_CHINESE;
|
||||
|
||||
QFile file("/home/plg/UseEn");
|
||||
|
||||
// QMessageBox::StandardButton ret;
|
||||
// ret = QMessageBox::information(this, tr("警告"),
|
||||
// tr("确定要切换显示语言吗?\r\n(重启才能生效)"),
|
||||
// QMessageBox::Ok | QMessageBox::Cancel);
|
||||
// if (ret != QMessageBox::Ok){
|
||||
// return;
|
||||
// }
|
||||
QByteArray buf;
|
||||
buf.clear();
|
||||
|
||||
if(file.open(QIODevice::ReadWrite)) {//怀疑是QIODevice::Truncate 引起参数错误,去掉试试看
|
||||
|
||||
|
||||
if(ui->radioButton_2->isChecked()) {
|
||||
LangIndex = INPUT_METHOD_TYPE_ENGLISH;
|
||||
buf.append("English\r\n");
|
||||
buf.append("WINPY_utf8.txt\r\n");
|
||||
}
|
||||
else if(ui->radioButton_3->isChecked()) {
|
||||
LangIndex = INPUT_METHOD_TYPE_VIETNAM;
|
||||
buf.append("Turkish\r\n");
|
||||
buf.append("WINPY_utf8.txt\r\n");
|
||||
}
|
||||
else if(ui->radioButton_4->isChecked()) {
|
||||
LangIndex = INPUT_METHOD_TYPE_SPANISH;
|
||||
buf.append("Spanish\r\n");
|
||||
buf.append("WINPY_utf8.txt\r\n");
|
||||
}
|
||||
else if(ui->radioButton_5->isChecked()) {
|
||||
LangIndex = INPUT_METHOD_TYPE_THAI;
|
||||
buf.append("Thai\r\n");
|
||||
buf.append("WINPY_utf8.txt\r\n");
|
||||
}
|
||||
else if(ui->radioButton_6->isChecked()) {
|
||||
LangIndex = INPUT_METHOD_TYPE_VIETNAM;
|
||||
buf.append("Vietnamese\r\n");
|
||||
buf.append("WINPY_utf8.txt\r\n");
|
||||
}
|
||||
else if(ui->radioButton_7->isChecked()) {
|
||||
LangIndex = INPUT_METHOD_TYPE_Farsi;
|
||||
buf.append("Farsi\r\n");
|
||||
buf.append("WINPY_utf8.txt\r\n");
|
||||
}
|
||||
/*else if(ui->radioButton->isChecked()) {
|
||||
|
||||
}
|
||||
else if(ui->radioButton->isChecked()) {
|
||||
|
||||
}
|
||||
else if(ui->radioButton->isChecked()) {
|
||||
|
||||
}*/
|
||||
else {
|
||||
//QMessageBox::information(this,tr("提示"),tr("重启后切换到中文界面"));
|
||||
buf.append("Chinese\r\n");
|
||||
buf.append("WINPY_utf8.txt\r\n");
|
||||
}
|
||||
file.write(buf);
|
||||
//#if defined(__CONVERTERBOARD__)|| defined(__VX__)
|
||||
#if 1
|
||||
fsync(file.handle());
|
||||
#endif
|
||||
file.close();
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,239 @@
|
||||
#include "DialogSaveFile.h"
|
||||
#include "ui_dialogsavefile.h"
|
||||
#include <QDir>
|
||||
#include <QStringListModel>
|
||||
#include <SysPara.h>
|
||||
#include <QAbstractItemView>
|
||||
#include <QFile>
|
||||
#include <QTextStream>
|
||||
#include <QMessageBox>
|
||||
#include <Public.h>
|
||||
#include<QStandardItemModel>
|
||||
#include"HtmlDelegate.h"
|
||||
#include <QTextCodec>
|
||||
#include <QByteArray>
|
||||
#include <QDebug>
|
||||
|
||||
DialogSaveFile::DialogSaveFile(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::DialogSaveFile)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
this->setWindowTitle(tr("保存"));
|
||||
ui->textEditView->setReadOnly(true);
|
||||
ui->textEditView->setLineWrapMode(QTextEdit::NoWrap);
|
||||
ui->textEditView->document()->setDocumentMargin(0);
|
||||
this->setFixedSize(this->geometry().width(),this->geometry().height());
|
||||
EditMode=4;
|
||||
#ifdef EnableArabic
|
||||
setFileNameFlag=false;
|
||||
#endif
|
||||
}
|
||||
|
||||
void DialogSaveFile::refreshListView(int mode){
|
||||
|
||||
QString dirPath = ui->radioButtonLocal->isChecked()?DOC_ROOT_DIR:UDISK_DOC_ROOT_DIR;
|
||||
QDir dir(dirPath);
|
||||
QStringList filters;
|
||||
EditMode = mode;
|
||||
if(mode == TXTFILE) filters << "*.html" << "*.txt" << "*.TXT" << "*.jpeg" << "*.gif" << "*.jpg" << "*.bmp"<< "*.BMP"; // txtmode
|
||||
else if(mode == PICFILE) filters << "*.png";// <<"*.jpg" ; // picmode
|
||||
else if(mode == SCENE) filters << "*.xml";// scene mode
|
||||
else filters << "*.html" << "*.bmp" << "*.BMP" <<"*.jpg"<<"*.gif";
|
||||
dir.setNameFilters(filters);
|
||||
dir.setFilter(QDir::Files);
|
||||
#ifndef EnableArabic
|
||||
QStringListModel *model = new QStringListModel(dir.entryList());
|
||||
#else
|
||||
QStringList entries=dir.entryList();
|
||||
QStandardItemModel *model = new QStandardItemModel();
|
||||
for(int i=0;i<entries.size();i++){
|
||||
QStandardItem *item1 = new QStandardItem(entries.at(i));
|
||||
int lastIndex=entries.at(i).lastIndexOf(".");
|
||||
if(lastIndex != -1){
|
||||
int secondLastIndex = entries.at(i).lastIndexOf(".",lastIndex-1);
|
||||
if(secondLastIndex != -1){
|
||||
QString subsuffix=entries.at(i).mid(secondLastIndex);
|
||||
if(subsuffix.contains(".a.")){
|
||||
QString subsuffix2=entries.at(i).mid(lastIndex);
|
||||
QString subname=entries.at(i).mid(0,secondLastIndex);
|
||||
QString stringhtml=QString("<span style=font-family:'biyangarabic';>%1</span><span style=font-family:'biyang';>%2</span>").arg(subname).arg(subsuffix2);
|
||||
QStandardItem *item2 = new QStandardItem(stringhtml);
|
||||
model->appendRow(item2);
|
||||
}
|
||||
}else{
|
||||
model->appendRow(item1);
|
||||
}
|
||||
}
|
||||
}
|
||||
ui->listViewFile->setItemDelegate(new HtmlDelegate);
|
||||
#endif
|
||||
|
||||
ui->listViewFile->setEditTriggers(QAbstractItemView::NoEditTriggers);
|
||||
ui->listViewFile->setModel(model); //useList是个QListView
|
||||
int count = ui->listViewFile->model()->rowCount();
|
||||
if(count){
|
||||
QModelIndex index = ui->listViewFile->model()->index(0 , 0);
|
||||
ui->listViewFile->setCurrentIndex(index);
|
||||
on_listViewFile_entered(index);
|
||||
}
|
||||
|
||||
#ifdef EnableArabic
|
||||
QFont font;
|
||||
if(!setFileNameFlag){
|
||||
font.setFamily("biyang");
|
||||
ui->lineEdit->setFont(font);
|
||||
}else {
|
||||
font.setFamily("biyangarabic");
|
||||
ui->lineEdit->setFont(font);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
DialogSaveFile::~DialogSaveFile()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void DialogSaveFile::on_listViewFile_entered(const QModelIndex &index)
|
||||
{
|
||||
#ifdef EnableArabic
|
||||
QFont font;
|
||||
QString fileName=index.data().toString();
|
||||
if(fileName.endsWith("</span>")){
|
||||
QTextDocument doc;
|
||||
doc.setHtml(fileName);
|
||||
fileName= doc.toPlainText();
|
||||
font.setFamily("biyangarabic");
|
||||
ui->lineEdit->setFont(font);
|
||||
ui->lineEdit->setText(QString(QFileInfo(fileName).baseName()));
|
||||
int position = fileName.lastIndexOf(".");
|
||||
fileName.insert(position,".a");
|
||||
}else{
|
||||
font.setFamily("biyang");
|
||||
ui->lineEdit->setFont(font);
|
||||
ui->lineEdit->setText( QFileInfo(fileName).baseName() );
|
||||
}
|
||||
#endif
|
||||
|
||||
QString dirPath = ui->radioButtonLocal->isChecked()?DOC_ROOT_DIR:UDISK_DOC_ROOT_DIR;
|
||||
#ifndef EnableArabic
|
||||
QString filePath = dirPath + index.data().toString();
|
||||
#else
|
||||
QString filePath = dirPath + fileName;
|
||||
#endif
|
||||
if(filePath.endsWith(".gif") || filePath.endsWith(".jpeg") || filePath.endsWith(".jpg") ||
|
||||
filePath.endsWith(".png") || filePath.endsWith(".bmp")|| filePath.endsWith(".BMP")|| filePath.endsWith(".nda")){
|
||||
ui->textEditView->clear();
|
||||
ui->textEditView->setHtml(QString("<img src='%1'/>").arg(filePath));
|
||||
}
|
||||
else {
|
||||
QFile file(filePath);
|
||||
if (!file.open(QFile::ReadOnly))
|
||||
return ;
|
||||
QByteArray data = file.readAll();
|
||||
QTextCodec *codec = Qt::codecForHtml(data);
|
||||
QString str = codec->toUnicode(data);
|
||||
if (Qt::mightBeRichText(str)) {
|
||||
if(!ui->radioButtonLocal->isChecked())
|
||||
str.replace(DOC_ROOT_DIR,UDISK_DOC_ROOT_DIR); //必须替换相应的路径
|
||||
ui->textEditView->setHtml(str);
|
||||
} else {
|
||||
str = QString::fromLocal8Bit(data);
|
||||
ui->textEditView->setPlainText(str);
|
||||
}
|
||||
}
|
||||
#ifndef EnableArabic
|
||||
ui->lineEdit->setText( QFileInfo(ui->listViewFile->currentIndex().data().toString()).baseName() );
|
||||
#endif
|
||||
}
|
||||
void DialogSaveFile::on_listViewFile_clicked(const QModelIndex &index)
|
||||
{
|
||||
on_listViewFile_entered(index);
|
||||
}
|
||||
|
||||
void DialogSaveFile::on_pushButtonNext_pressed()
|
||||
{
|
||||
QModelIndex currIndex = ui->listViewFile->currentIndex();
|
||||
int count = ui->listViewFile->model()->rowCount();
|
||||
if(count){
|
||||
QModelIndex index = ui->listViewFile->model()->index((currIndex.row() + 1)%count, 0);
|
||||
ui->listViewFile->setCurrentIndex(index);
|
||||
on_listViewFile_entered(index);
|
||||
}
|
||||
ui->lineEdit->setText(QFileInfo(ui->listViewFile->currentIndex().data().toString()).baseName());
|
||||
}
|
||||
|
||||
void DialogSaveFile::on_pushButtonLast_pressed()
|
||||
{
|
||||
QModelIndex currIndex = ui->listViewFile->currentIndex();
|
||||
int count = ui->listViewFile->model()->rowCount();
|
||||
if(count){
|
||||
QModelIndex index = ui->listViewFile->model()->index(currIndex.row() == 0?(count - 1):(currIndex.row() - 1), 0);
|
||||
ui->listViewFile->setCurrentIndex(index);
|
||||
on_listViewFile_entered(index);
|
||||
}
|
||||
ui->lineEdit->setText(QFileInfo(ui->listViewFile->currentIndex().data().toString()).baseName());
|
||||
}
|
||||
|
||||
void DialogSaveFile::on_pushButtonExit_pressed()
|
||||
{
|
||||
hide();
|
||||
}
|
||||
//void DialogSaveFile::on_lostfocuse_pressed()
|
||||
//{
|
||||
// hide();
|
||||
//}
|
||||
void DialogSaveFile::on_pushButtonSave_clicked()
|
||||
{
|
||||
QModelIndex index = ui->listViewFile->currentIndex();
|
||||
QString dirPath = ui->radioButtonLocal->isChecked()?DOC_ROOT_DIR:UDISK_DOC_ROOT_DIR;
|
||||
//QString filePath = dirPath + index.data().toString();
|
||||
QString filePath = dirPath + ui->lineEdit->text();// index.data().toString();
|
||||
#ifdef EnableArabic
|
||||
if(setFileNameFlag){
|
||||
filePath = dirPath + ui->lineEdit->text()+".a";
|
||||
}
|
||||
#endif
|
||||
emit saveFile(filePath,false);
|
||||
hide();
|
||||
}
|
||||
|
||||
void DialogSaveFile::on_radioButtonLocal_released()
|
||||
{
|
||||
refreshListView(EditMode);
|
||||
}
|
||||
|
||||
void DialogSaveFile::on_radioButtonUdisk_released()
|
||||
{
|
||||
|
||||
QDir dir(UDISK_DOC_ROOT_DIR);
|
||||
if(!dir.exists()){
|
||||
QMessageBox::warning(0,tr("警告"),tr("U盘未插入或U盘根目录下的doc文件夹不存在!"));
|
||||
}
|
||||
refreshListView(EditMode);
|
||||
}
|
||||
void DialogSaveFile::setEnterFileName(QString strFile)
|
||||
{
|
||||
ui->lineEdit->setText(strFile);
|
||||
//ui->lineEdit->setFocus();
|
||||
}
|
||||
void DialogSaveFile::setTitleTxt(QString str)
|
||||
{
|
||||
setWindowTitle(str);
|
||||
}
|
||||
|
||||
#ifdef EnableArabic
|
||||
void DialogSaveFile::setFileNameEnglishOrArabic(bool flag){
|
||||
QFont font;
|
||||
setFileNameFlag=flag;
|
||||
//qDebug()<<"setFileNameFlag :"<<flag;
|
||||
if(flag){
|
||||
font.setFamily("biyangarabic");
|
||||
}else {
|
||||
font.setFamily("biyang");
|
||||
}
|
||||
ui->lineEdit->setFont(font);
|
||||
}
|
||||
#endif
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 1.3 KiB |
@@ -0,0 +1,93 @@
|
||||
/****************************************************************************
|
||||
** Meta object code from reading C++ file 'logo_form.h'
|
||||
**
|
||||
** Created by: The Qt Meta Object Compiler version 63 (Qt 4.8.5)
|
||||
**
|
||||
** WARNING! All changes made in this file will be lost!
|
||||
*****************************************************************************/
|
||||
|
||||
#include "../logo_form.h"
|
||||
#if !defined(Q_MOC_OUTPUT_REVISION)
|
||||
#error "The header file 'logo_form.h' doesn't include <QObject>."
|
||||
#elif Q_MOC_OUTPUT_REVISION != 63
|
||||
#error "This file was generated using the moc from 4.8.5. It"
|
||||
#error "cannot be used with the include files from this version of Qt."
|
||||
#error "(The moc has changed too much.)"
|
||||
#endif
|
||||
|
||||
QT_BEGIN_MOC_NAMESPACE
|
||||
static const uint qt_meta_data_logo_Form[] = {
|
||||
|
||||
// content:
|
||||
6, // revision
|
||||
0, // classname
|
||||
0, 0, // classinfo
|
||||
1, 14, // methods
|
||||
0, 0, // properties
|
||||
0, 0, // enums/sets
|
||||
0, 0, // constructors
|
||||
0, // flags
|
||||
0, // signalCount
|
||||
|
||||
// slots: signature, parameters, type, tag, flags
|
||||
11, 10, 10, 10, 0x08,
|
||||
|
||||
0 // eod
|
||||
};
|
||||
|
||||
static const char qt_meta_stringdata_logo_Form[] = {
|
||||
"logo_Form\0\0logo_timer_fun()\0"
|
||||
};
|
||||
|
||||
void logo_Form::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a)
|
||||
{
|
||||
if (_c == QMetaObject::InvokeMetaMethod) {
|
||||
Q_ASSERT(staticMetaObject.cast(_o));
|
||||
logo_Form *_t = static_cast<logo_Form *>(_o);
|
||||
switch (_id) {
|
||||
case 0: _t->logo_timer_fun(); break;
|
||||
default: ;
|
||||
}
|
||||
}
|
||||
Q_UNUSED(_a);
|
||||
}
|
||||
|
||||
const QMetaObjectExtraData logo_Form::staticMetaObjectExtraData = {
|
||||
0, qt_static_metacall
|
||||
};
|
||||
|
||||
const QMetaObject logo_Form::staticMetaObject = {
|
||||
{ &QWidget::staticMetaObject, qt_meta_stringdata_logo_Form,
|
||||
qt_meta_data_logo_Form, &staticMetaObjectExtraData }
|
||||
};
|
||||
|
||||
#ifdef Q_NO_DATA_RELOCATION
|
||||
const QMetaObject &logo_Form::getStaticMetaObject() { return staticMetaObject; }
|
||||
#endif //Q_NO_DATA_RELOCATION
|
||||
|
||||
const QMetaObject *logo_Form::metaObject() const
|
||||
{
|
||||
return QObject::d_ptr->metaObject ? QObject::d_ptr->metaObject : &staticMetaObject;
|
||||
}
|
||||
|
||||
void *logo_Form::qt_metacast(const char *_clname)
|
||||
{
|
||||
if (!_clname) return 0;
|
||||
if (!strcmp(_clname, qt_meta_stringdata_logo_Form))
|
||||
return static_cast<void*>(const_cast< logo_Form*>(this));
|
||||
return QWidget::qt_metacast(_clname);
|
||||
}
|
||||
|
||||
int logo_Form::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
|
||||
{
|
||||
_id = QWidget::qt_metacall(_c, _id, _a);
|
||||
if (_id < 0)
|
||||
return _id;
|
||||
if (_c == QMetaObject::InvokeMetaMethod) {
|
||||
if (_id < 1)
|
||||
qt_static_metacall(this, _c, _id, _a);
|
||||
_id -= 1;
|
||||
}
|
||||
return _id;
|
||||
}
|
||||
QT_END_MOC_NAMESPACE
|
||||
Reference in New Issue
Block a user