hlp:桂林国际齿轮泵代码
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
#ifndef MODBUSTCP_H
|
||||
#define MODBUSTCP_H
|
||||
#include <QThread>
|
||||
//#include <QObject>
|
||||
#include "../SysPara.h"
|
||||
#include <stdint.h>
|
||||
#include <QMutex>
|
||||
#include <QTcpServer>
|
||||
#include "myinclude.h"
|
||||
|
||||
#define PRINT_START_COMMAND 0x01
|
||||
#define PRINT_PAUSE_COMMAND 0x02
|
||||
#define PRINT_STOP_COMMAND 0x03
|
||||
enum {
|
||||
TCP,
|
||||
TCP_PI,
|
||||
RTU
|
||||
};
|
||||
enum ThreadState
|
||||
{
|
||||
STOPPED,
|
||||
RUNNING,
|
||||
SHUTDOWN
|
||||
};
|
||||
class ModbusTcp:public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ModbusTcp(ModbusPrintParas *mPara, const ModbusPrintStatus* mStatus);
|
||||
~ModbusTcp();
|
||||
|
||||
uint16_t* input_registers;
|
||||
uint16_t* holding_registers;
|
||||
uint8_t modbus_up_QRCODE;
|
||||
QThread m_thread;
|
||||
enum ThreadState ePollThreadState;
|
||||
enum ThreadState eGetPollingThreadState();
|
||||
void eSetPollingThreadState( enum ThreadState eNewState );
|
||||
qint32 getModbusStatus();
|
||||
qint32 processCommands(qint32 index);
|
||||
|
||||
Q_SIGNALS:
|
||||
void startPrint();
|
||||
void pausePrint();
|
||||
void stopPrint();
|
||||
void openFile(QString,bool);
|
||||
void receivedPrintContent(int);
|
||||
void faultResume();
|
||||
void writeCalendar();
|
||||
void mbLineAndCharSpace(int lineSpace, int charSpace);
|
||||
void updateQRcode();
|
||||
void writeCalendar1();
|
||||
void writeCalendar1EndValue();
|
||||
void writeCalendar2EndValue();
|
||||
void writeCalendar2RepeatValue();
|
||||
void writeCalendar2InitValue();
|
||||
void CNTResetNow();
|
||||
|
||||
public slots:
|
||||
void pvPollingThread();
|
||||
|
||||
private:
|
||||
qint32 modbus_status;
|
||||
QMutex modbusThreadMutex;
|
||||
};
|
||||
|
||||
#endif // MODBUSTCP_H
|
||||
@@ -0,0 +1,130 @@
|
||||
/*
|
||||
* wpa_gui - EventHistory class
|
||||
* Copyright (c) 2005-2006, Jouni Malinen <j@w1.fi>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* Alternatively, this software may be distributed under the terms of BSD
|
||||
* license.
|
||||
*
|
||||
* See README and COPYING for more details.
|
||||
*/
|
||||
|
||||
#include <QHeaderView>
|
||||
#include <QScrollBar>
|
||||
|
||||
#include "eventhistory.h"
|
||||
|
||||
|
||||
int EventListModel::rowCount(const QModelIndex &) const
|
||||
{
|
||||
return msgList.count();
|
||||
}
|
||||
|
||||
|
||||
int EventListModel::columnCount(const QModelIndex &) const
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
|
||||
QVariant EventListModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if (!index.isValid())
|
||||
return QVariant();
|
||||
|
||||
if (role == Qt::DisplayRole)
|
||||
if (index.column() == 0) {
|
||||
if (index.row() >= timeList.size())
|
||||
return QVariant();
|
||||
return timeList.at(index.row());
|
||||
} else {
|
||||
if (index.row() >= msgList.size())
|
||||
return QVariant();
|
||||
return msgList.at(index.row());
|
||||
}
|
||||
else
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
|
||||
QVariant EventListModel::headerData(int section, Qt::Orientation orientation,
|
||||
int role) const
|
||||
{
|
||||
if (role != Qt::DisplayRole)
|
||||
return QVariant();
|
||||
|
||||
if (orientation == Qt::Horizontal) {
|
||||
switch (section) {
|
||||
case 0:
|
||||
return QString(tr("Timestamp"));
|
||||
case 1:
|
||||
return QString(tr("Message"));
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
} else
|
||||
return QString("%1").arg(section);
|
||||
}
|
||||
|
||||
|
||||
void EventListModel::addEvent(QString time, QString msg)
|
||||
{
|
||||
beginInsertRows(QModelIndex(), msgList.size(), msgList.size() + 1);
|
||||
timeList << time;
|
||||
msgList << msg;
|
||||
endInsertRows();
|
||||
}
|
||||
|
||||
|
||||
EventHistory::EventHistory(QWidget *parent, const char *, bool, Qt::WFlags)
|
||||
: QDialog(parent)
|
||||
{
|
||||
setupUi(this);
|
||||
|
||||
connect(closeButton, SIGNAL(clicked()), this, SLOT(close()));
|
||||
|
||||
eventListView->setItemsExpandable(FALSE);
|
||||
eventListView->setRootIsDecorated(FALSE);
|
||||
elm = new EventListModel(parent);
|
||||
eventListView->setModel(elm);
|
||||
}
|
||||
|
||||
|
||||
EventHistory::~EventHistory()
|
||||
{
|
||||
destroy();
|
||||
delete elm;
|
||||
}
|
||||
|
||||
|
||||
void EventHistory::languageChange()
|
||||
{
|
||||
retranslateUi(this);
|
||||
}
|
||||
|
||||
|
||||
void EventHistory::addEvents(WpaMsgList msgs)
|
||||
{
|
||||
WpaMsgList::iterator it;
|
||||
for (it = msgs.begin(); it != msgs.end(); it++)
|
||||
addEvent(*it);
|
||||
}
|
||||
|
||||
|
||||
void EventHistory::addEvent(WpaMsg msg)
|
||||
{
|
||||
bool scroll = true;
|
||||
|
||||
if (eventListView->verticalScrollBar()->value() <
|
||||
eventListView->verticalScrollBar()->maximum())
|
||||
scroll = false;
|
||||
|
||||
elm->addEvent(msg.getTimestamp().toString("yyyy-MM-dd hh:mm:ss.zzz"),
|
||||
msg.getMsg());
|
||||
|
||||
if (scroll)
|
||||
eventListView->scrollToBottom();
|
||||
}
|
||||
@@ -0,0 +1,216 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <QImage>
|
||||
#include <getopt.h>
|
||||
#include <qrencode.h>
|
||||
#include <qdebug.h>
|
||||
#include "mainwindow.h"
|
||||
#include <QApplication>
|
||||
#include "ui_mainwindow.h"
|
||||
|
||||
char *intext = " ";
|
||||
static int casesensitive = 0;
|
||||
static int eightbit = 0;
|
||||
static int kanji = 0;
|
||||
static int version = 0;
|
||||
static int Size = 3;
|
||||
static int margin = 4;
|
||||
static QRecLevel level = QR_ECLEVEL_L;
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent) :
|
||||
QMainWindow(parent),
|
||||
ui(new Ui::MainWindow)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
ui->textEdit->setText(tr("1234567893233695"));
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
enum {
|
||||
O_HELP,
|
||||
O_OUTPUT,
|
||||
O_SIZE,
|
||||
O_VERSION,
|
||||
O_LEVEL,
|
||||
O_MARGIN,
|
||||
O_KANJI,
|
||||
O_CASE,
|
||||
O_8BIT,
|
||||
};
|
||||
|
||||
static const struct option options[] = {
|
||||
{"h", no_argument , NULL, O_HELP},
|
||||
{"o", required_argument, NULL, O_OUTPUT},
|
||||
{"l", required_argument, NULL, O_LEVEL},
|
||||
{"s", required_argument, NULL, O_SIZE},
|
||||
{"v", required_argument, NULL, O_VERSION},
|
||||
{"m", required_argument, NULL, O_MARGIN},
|
||||
{"k", no_argument , NULL, O_KANJI},
|
||||
{"c", no_argument , NULL, O_CASE},
|
||||
{"8", no_argument , NULL, O_8BIT},
|
||||
{NULL, 0, NULL, 0}
|
||||
};
|
||||
|
||||
static void usage(void)
|
||||
{
|
||||
qDebug()<<(
|
||||
"qrencode version %s\n\n"
|
||||
"Usage: qrencode [OPTION]... [STRING]\n"
|
||||
"Encode input data in a QR Code and save as a PNG image.\n\n"
|
||||
" -h display this message.\n"
|
||||
" -o FILENAME write PNG image to FILENAME. If '-' is specified, the result\n"
|
||||
" will be output to standard output.\n"
|
||||
" -s NUMBER specify the size of dot (pixel). (default=3)\n"
|
||||
" -l {LMQH} specify error collectin level from L (lowest) to H (highest).\n"
|
||||
" (default=L)\n"
|
||||
" -v NUMBER specify the version of the symbol. (default=auto)\n"
|
||||
" -m NUMBER specify the width of margin. (default=4)\n"
|
||||
" -k assume that the input text contains kanji (shift-jis).\n"
|
||||
" -c encode alphabet characters in 8-bit mode. If your application\n"
|
||||
" is case-sensitive, choose this.\n"
|
||||
" -8 encode entire data in 8-bit mode. -c and -k will be ignored.\n"
|
||||
" [STRING] input data. If it is not specified, data will be taken from\n"
|
||||
" standard input.\n"
|
||||
);
|
||||
}
|
||||
|
||||
#define MAX_DATA_SIZE 7090 /* from the specification */
|
||||
static char *readStdin(void)
|
||||
{
|
||||
char *buffer;
|
||||
int ret;
|
||||
|
||||
buffer = (char *)malloc(MAX_DATA_SIZE);
|
||||
ret = fread(buffer, 1, MAX_DATA_SIZE, stdin);
|
||||
if(ret == 0) {
|
||||
fprintf(stderr, "No input data.\n");
|
||||
exit(1);
|
||||
}
|
||||
if(!feof(stdin)) {
|
||||
fprintf(stderr, "Input data is too large.\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
buffer[ret] = '\0';
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
static QRcode *encode(const char *intext)
|
||||
{
|
||||
QRencodeMode hint;
|
||||
QRcode *code;
|
||||
|
||||
if(kanji) {
|
||||
hint = QR_MODE_KANJI;
|
||||
} else {
|
||||
hint = QR_MODE_8;
|
||||
}
|
||||
|
||||
if(eightbit) {
|
||||
code = QRcode_encodeString8bit(intext, version, level);
|
||||
} else {
|
||||
code = QRcode_encodeString(intext, version, level, hint, casesensitive);
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
static void qrencode(const char *intext, const char *outfile)
|
||||
{
|
||||
FILE *fp;
|
||||
QRcode *qrcode;
|
||||
//png_structp png_ptr;
|
||||
//png_infop info_ptr;
|
||||
unsigned char *row, *p, *q;
|
||||
int x, y, xx, yy, bit;
|
||||
int realwidth;
|
||||
|
||||
qrcode = encode(intext);
|
||||
if(qrcode == NULL) {
|
||||
fprintf(stderr, "Failed to encode the input data.\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
realwidth = (qrcode->width + margin * 2) * Size;
|
||||
|
||||
row = (unsigned char *)malloc(realwidth);
|
||||
|
||||
// top margin
|
||||
memset(row, 0x0, realwidth );
|
||||
|
||||
qDebug()<<"1: "<< qrcode->width<<realwidth<<margin<<Size<<sizeof(intext);
|
||||
|
||||
// realwidth = (qrcode->width + margin * 2) * Size;
|
||||
QImage QRImage(realwidth,qrcode->width*Size,QImage::Format_ARGB32 );
|
||||
QImage *img;
|
||||
img = &QRImage;
|
||||
img->fill(0x00ffffff);
|
||||
|
||||
/* data */
|
||||
p = qrcode->data;
|
||||
int ypos=0;//margin * Size;
|
||||
int xpos=0;
|
||||
for(y=0; y<qrcode->width; y++) {
|
||||
bit = 7;
|
||||
bit = 7 - (margin * Size % 8);
|
||||
xpos=margin * Size;
|
||||
for(x=0; x<qrcode->width; x++) {
|
||||
for(xx=0; xx<Size; xx++) {
|
||||
if((*p & 1) << bit){
|
||||
for(yy=0; yy<Size; yy++) {
|
||||
img->setPixel(xpos,ypos+yy,0xff000000);
|
||||
}
|
||||
}
|
||||
xpos++;
|
||||
|
||||
}
|
||||
p++;
|
||||
bit--;
|
||||
if(bit < 0) {
|
||||
//q++;
|
||||
bit = 7;
|
||||
}
|
||||
}
|
||||
ypos+=Size;
|
||||
}
|
||||
img->save("Myqr.bmp");
|
||||
|
||||
free(row);
|
||||
QRcode_free(qrcode);
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::on_pushButton_clicked()
|
||||
{
|
||||
QString in;
|
||||
//usage();
|
||||
in = ui->textEdit->toPlainText();
|
||||
//intext = in.toLatin1().data();
|
||||
intext = (char *)malloc(in.length()*2);
|
||||
memset(intext,0,sizeof(intext));
|
||||
//intext =in.unicode();
|
||||
//memcpy(&intext[0], in.unicode (),2*in.length());
|
||||
memcpy(intext,in.toLocal8Bit().data(),2*in.length());
|
||||
|
||||
qDebug()<<in<< intext;
|
||||
Size = ui->comboBox_size->currentIndex()+3;
|
||||
qrencode(intext,outfile);
|
||||
QImage img("Myqr.bmp",0);
|
||||
ui->labQRImage->setPixmap( QPixmap::fromImage(img,Qt::AutoColor));
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
|
||||
QApplication a(argc, argv);
|
||||
MainWindow w;
|
||||
w.show();
|
||||
return a.exec();
|
||||
}
|
||||
@@ -0,0 +1,265 @@
|
||||
#include "ZkEdit.h"
|
||||
#include "ui_zkedit.h"
|
||||
#include "SysPara.h"
|
||||
#include <QMessageBox>
|
||||
#include <QDebug>
|
||||
|
||||
ZkEdit::ZkEdit(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::ZkEdit)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
fileDialog = 0;
|
||||
openedFileName = "";
|
||||
newFileAppending = false;
|
||||
connect(ui->widgetPic,SIGNAL(picWidgetModify(int ,int )),this,SLOT(enableSaveButton(int ,int )));
|
||||
connect(ui->checkBoxPicExpand,SIGNAL(clicked(bool)),this,SLOT(oncheckboxExpandClicked(bool)));
|
||||
connect(ui->checkBoxTrimPic,SIGNAL(clicked(bool)),this,SLOT(oncheckboxTrimPicClicked(bool)));
|
||||
ui->pushButtonSave->setEnabled(false);
|
||||
forcePicWidgetSize = false;
|
||||
#ifdef MYSAVEFILEDLG
|
||||
dialogSaveFile =new DialogSaveFile(0);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
ZkEdit::~ZkEdit()
|
||||
{
|
||||
delete ui;
|
||||
#ifdef MYSAVEFILEDLG
|
||||
if(dialogSaveFile) delete dialogSaveFile;
|
||||
#endif
|
||||
if(fileDialog)
|
||||
delete fileDialog;
|
||||
|
||||
}
|
||||
|
||||
void ZkEdit::oncheckboxExpandClicked(bool)
|
||||
{
|
||||
ui->checkBoxTrimPic->setCheckState(Qt::Unchecked);
|
||||
}
|
||||
|
||||
void ZkEdit::oncheckboxTrimPicClicked(bool)
|
||||
{
|
||||
ui->checkBoxPicExpand->setCheckState(Qt::Unchecked);
|
||||
}
|
||||
|
||||
void ZkEdit::checkNewFileAppending(){
|
||||
if(newFileAppending){
|
||||
ui->widgetPic->initWidget(ui->spinBoxWidthPoint->value(),ui->spinBoxHeightPoint->value());
|
||||
openedFileName = "";
|
||||
}
|
||||
newFileAppending = false;
|
||||
}
|
||||
|
||||
void ZkEdit::onSave_File_reject(){
|
||||
checkNewFileAppending();
|
||||
}
|
||||
|
||||
bool ZkEdit::maybeSave(){
|
||||
if(!ui->widgetPic->isModified())
|
||||
return true;
|
||||
|
||||
QMessageBox msgBox(QMessageBox::Information,tr("提示"),tr("图片已经改变,是否保存?"));
|
||||
QPushButton *saveButton = msgBox.addButton(tr("保存"), QMessageBox::ActionRole);
|
||||
QPushButton *cancleSaveButton = msgBox.addButton(tr("放弃保存"), QMessageBox::ActionRole);
|
||||
QPushButton *abortButton = msgBox.addButton(QMessageBox::Cancel);
|
||||
|
||||
msgBox.exec();
|
||||
|
||||
if (msgBox.clickedButton() == saveButton) {
|
||||
newFileAppending = true;
|
||||
on_pushButtonSave_clicked();
|
||||
return false;
|
||||
} else if (msgBox.clickedButton() == cancleSaveButton) {
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void ZkEdit::on_pushButtonNew_pressed(){
|
||||
if(maybeSave()){
|
||||
ui->widgetPic->initWidget(ui->spinBoxWidthPoint->value(),ui->spinBoxHeightPoint->value());
|
||||
openedFileName = "";
|
||||
}
|
||||
}
|
||||
|
||||
void ZkEdit::enableSaveButton(int w,int h){
|
||||
ui->pushButtonSave->setEnabled(true);
|
||||
ui->spinBoxHeightPoint->setValue(h);
|
||||
ui->spinBoxWidthPoint->setValue(w);
|
||||
}
|
||||
|
||||
void ZkEdit::on_pushButtonEnlarge_pressed()
|
||||
{
|
||||
ui->widgetPic->enlargeDisplay();
|
||||
ui->labelScaleLeval->setText(tr("放大倍数:%1").arg(ui->widgetPic->getScaleValue()));
|
||||
}
|
||||
|
||||
void ZkEdit::on_pushButtonReduce_pressed()
|
||||
{
|
||||
ui->widgetPic->reduceDisplay();
|
||||
ui->labelScaleLeval->setText(tr("放大倍数:%1").arg(ui->widgetPic->getScaleValue()));
|
||||
}
|
||||
|
||||
void ZkEdit::on_pushButtonUp_pressed()
|
||||
{
|
||||
//ui->widgetPic->currPositionMove(0,-1);
|
||||
ui->widgetPic->currPositionMove(0,-1,0,ui->checkBoxTrimPic->isChecked(),ui->checkBoxPicExpand->isChecked());
|
||||
}
|
||||
|
||||
void ZkEdit::on_pushButtonLeft_pressed()
|
||||
{
|
||||
//ui->widgetPic->currPositionMove(-1,0);
|
||||
ui->widgetPic->currPositionMove(-1,0,0,ui->checkBoxTrimPic->isChecked(),ui->checkBoxPicExpand->isChecked());
|
||||
}
|
||||
|
||||
void ZkEdit::on_pushButtonEnsure_pressed()
|
||||
{
|
||||
ui->widgetPic->ensureCurrPos();
|
||||
}
|
||||
|
||||
void ZkEdit::on_pushButtonRight_pressed()
|
||||
{
|
||||
//ui->widgetPic->currPositionMove(1,0);
|
||||
ui->widgetPic->currPositionMove(1,0,0,ui->checkBoxTrimPic->isChecked(),ui->checkBoxPicExpand->isChecked());
|
||||
}
|
||||
|
||||
void ZkEdit::on_pushButtonDown_pressed()
|
||||
{
|
||||
//ui->widgetPic->currPositionMove(0,1);
|
||||
ui->widgetPic->currPositionMove(0,1,0,ui->checkBoxTrimPic->isChecked(),ui->checkBoxPicExpand->isChecked());
|
||||
}
|
||||
|
||||
void ZkEdit::on_pushButtonSaveAs_clicked()
|
||||
{
|
||||
#ifdef MYSAVEFILEDLG
|
||||
disconnect(dialogSaveFile,SIGNAL(saveFile(QString,bool)),0,0);
|
||||
connect(dialogSaveFile,SIGNAL(saveFile(QString,bool)),this,SLOT(onSaveASFile(QString,bool)));
|
||||
dialogSaveFile->setTitleTxt(tr("图片另存为..."));
|
||||
dialogSaveFile->refreshListView(2);
|
||||
dialogSaveFile->setEnterFileName("");
|
||||
dialogSaveFile->show();
|
||||
#else
|
||||
if(fileDialog)
|
||||
delete fileDialog;
|
||||
fileDialog = new MyFileDialog(0);
|
||||
disconnect(fileDialog,SIGNAL(accepted()),0,0);
|
||||
connect(fileDialog,SIGNAL(accepted()),this,SLOT(onSaveAS_FIle_select()));
|
||||
fileDialog->showFileDialog(tr("另存为"),QString(DOC_ROOT_DIR),QString("Picture files (*.jpg )"));
|
||||
#endif
|
||||
|
||||
}
|
||||
void ZkEdit::onSaveASFile(QString fileName,bool Flag){// use for dialogSaveFile class
|
||||
// filename= fileName ;
|
||||
if( !fileName.endsWith(".jpg",Qt::CaseInsensitive) )
|
||||
fileName = QFileInfo(fileName).baseName()+ ".jpg";
|
||||
|
||||
ui->widgetPic->saveImage(fileName);
|
||||
ui->pushButtonSave->setEnabled(false);
|
||||
openedFileName = fileName;
|
||||
ui->labelFileName->setText(fileName);
|
||||
|
||||
checkNewFileAppending();
|
||||
|
||||
}
|
||||
|
||||
void ZkEdit::onSaveAS_FIle_select(){
|
||||
QStringList files = fileDialog->selectedFiles();
|
||||
for(int i = 0;i < files.size(); i++){
|
||||
QString fileName = files[i];
|
||||
if( // !fileName.endsWith(".gif",Qt::CaseInsensitive)
|
||||
//&& !fileName.endsWith(".jpeg",Qt::CaseInsensitive)
|
||||
// &&
|
||||
!fileName.endsWith(".jpg",Qt::CaseInsensitive)
|
||||
//&& !fileName.endsWith(".png",Qt::CaseInsensitive)
|
||||
//&& !fileName.endsWith(".bmp",Qt::CaseInsensitive)
|
||||
)
|
||||
fileName += ".jpg";
|
||||
|
||||
ui->widgetPic->saveImage(fileName);
|
||||
ui->pushButtonSave->setEnabled(false);
|
||||
openedFileName = fileName;
|
||||
ui->labelFileName->setText(fileName);
|
||||
}
|
||||
checkNewFileAppending();
|
||||
}
|
||||
|
||||
void ZkEdit::on_pushButtonOpen_clicked()
|
||||
{
|
||||
forcePicWidgetSize = false;
|
||||
if(fileDialog)
|
||||
delete fileDialog;
|
||||
fileDialog = new MyFileDialog(0);
|
||||
disconnect(fileDialog,SIGNAL(accepted()),0,0);
|
||||
connect(fileDialog,SIGNAL(accepted()),this,SLOT(onOpenFIle_select()));
|
||||
fileDialog->showFileDialog(tr("打开文件"),QString(DOC_ROOT_DIR),
|
||||
QString("Picture files ( *.jpeg *.bmp *.gif *.png *jpg)"));
|
||||
}
|
||||
|
||||
|
||||
void ZkEdit::onOpenFIle_select(){
|
||||
QStringList files = fileDialog->selectedFiles();
|
||||
for(int i = 0;i < files.size(); i++){
|
||||
QString fileName = files.value(i);
|
||||
ui->widgetPic->loadImage(fileName,forcePicWidgetSize);
|
||||
openedFileName = fileName;
|
||||
ui->labelFileName->setText(fileName);
|
||||
ui->labelScaleLeval->setText(tr("放大倍数:%1").arg(ui->widgetPic->getScaleValue()));
|
||||
ui->spinBoxHeightPoint->setValue(ui->widgetPic->getHeight());
|
||||
ui->spinBoxWidthPoint->setValue(ui->widgetPic->getWidth());
|
||||
}
|
||||
}
|
||||
|
||||
void ZkEdit::on_pushButtonSave_clicked()
|
||||
{
|
||||
if(!openedFileName.isEmpty()){
|
||||
ui->widgetPic->saveImage(openedFileName);
|
||||
ui->pushButtonSave->setEnabled(false);
|
||||
}
|
||||
else {
|
||||
#ifdef MYSAVEFILEDLG
|
||||
disconnect(dialogSaveFile,SIGNAL(saveFile(QString,bool)),0,0);
|
||||
connect(dialogSaveFile,SIGNAL(saveFile(QString,bool)),this,SLOT(onSaveASFile(QString,bool)));
|
||||
dialogSaveFile->setTitleTxt(tr("图片保存为..."));
|
||||
dialogSaveFile->refreshListView(2);
|
||||
dialogSaveFile->setEnterFileName("");
|
||||
dialogSaveFile->show();
|
||||
#else
|
||||
if(fileDialog)
|
||||
delete fileDialog;
|
||||
fileDialog = new MyFileDialog(0);
|
||||
disconnect(fileDialog,SIGNAL(accepted()),0,0);
|
||||
connect(fileDialog,SIGNAL(rejected()),this,SLOT(onSave_File_reject()));
|
||||
connect(fileDialog,SIGNAL(accepted()),this,SLOT(onSaveAS_FIle_select()));
|
||||
fileDialog->showFileDialog(tr("保存"),QString(DOC_ROOT_DIR),QString("Picture files ( *.jpg )"));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void ZkEdit::on_pushButtonImport_clicked()
|
||||
{
|
||||
forcePicWidgetSize = true;
|
||||
if(fileDialog)
|
||||
delete fileDialog;
|
||||
fileDialog = new MyFileDialog(0);
|
||||
disconnect(fileDialog,SIGNAL(accepted()),0,0);
|
||||
connect(fileDialog,SIGNAL(accepted()),this,SLOT(onOpenFIle_select()));
|
||||
fileDialog->showFileDialog(tr("导入文件"),QString(DOC_ROOT_DIR),QString("Picture files (*.png *.jpeg *.jpg *.gif *.bmp)"));
|
||||
}
|
||||
|
||||
void ZkEdit::keyPressEvent(QKeyEvent *e)
|
||||
{
|
||||
switch(e->key())
|
||||
{
|
||||
case Qt::Key_Return:on_pushButtonEnsure_pressed();break;
|
||||
case Qt::Key_Up: on_pushButtonUp_pressed();break;
|
||||
case Qt::Key_Left: on_pushButtonLeft_pressed();break;
|
||||
case Qt::Key_Right:on_pushButtonRight_pressed();break;
|
||||
case Qt::Key_Down:on_pushButtonDown_pressed();break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* wpa_gui - EventHistory class
|
||||
* Copyright (c) 2005-2006, Jouni Malinen <j@w1.fi>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* Alternatively, this software may be distributed under the terms of BSD
|
||||
* license.
|
||||
*
|
||||
* See README and COPYING for more details.
|
||||
*/
|
||||
|
||||
#ifndef EVENTHISTORY_H
|
||||
#define EVENTHISTORY_H
|
||||
|
||||
#include <QObject>
|
||||
#include "ui_eventhistory.h"
|
||||
|
||||
|
||||
class EventListModel : public QAbstractTableModel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
EventListModel(QObject *parent = 0)
|
||||
: QAbstractTableModel(parent) {}
|
||||
|
||||
int rowCount(const QModelIndex &parent = QModelIndex()) const;
|
||||
int columnCount(const QModelIndex &parent = QModelIndex()) const;
|
||||
QVariant data(const QModelIndex &index, int role) const;
|
||||
QVariant headerData(int section, Qt::Orientation orientation,
|
||||
int role = Qt::DisplayRole) const;
|
||||
void addEvent(QString time, QString msg);
|
||||
|
||||
private:
|
||||
QStringList timeList;
|
||||
QStringList msgList;
|
||||
};
|
||||
|
||||
|
||||
class EventHistory : public QDialog, public Ui::EventHistory
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
EventHistory(QWidget *parent = 0, const char *name = 0,
|
||||
bool modal = false, Qt::WFlags fl = 0);
|
||||
~EventHistory();
|
||||
|
||||
public slots:
|
||||
virtual void addEvents(WpaMsgList msgs);
|
||||
virtual void addEvent(WpaMsg msg);
|
||||
|
||||
protected slots:
|
||||
virtual void languageChange();
|
||||
|
||||
private:
|
||||
EventListModel *elm;
|
||||
};
|
||||
|
||||
#endif /* EVENTHISTORY_H */
|
||||
Reference in New Issue
Block a user