去掉旧版本的scanner源代码
This commit is contained in:
parent
ba521be52f
commit
feff858a04
File diff suppressed because it is too large
Load Diff
|
@ -1,260 +0,0 @@
|
||||||
#ifndef __HGIMGTHUMB_H__
|
|
||||||
#define __HGIMGTHUMB_H__
|
|
||||||
|
|
||||||
#include "base/HGDef.h"
|
|
||||||
#include "base/HGBaseErr.h"
|
|
||||||
#include "base/HGLock.h"
|
|
||||||
#include "base/HGEvent.h"
|
|
||||||
#include "base/HGThread.h"
|
|
||||||
#include "base/HGImage.h"
|
|
||||||
#include <QWidget>
|
|
||||||
|
|
||||||
class HGImgThumb : public QWidget
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
public:
|
|
||||||
HGImgThumb(QWidget* parent = nullptr);
|
|
||||||
virtual ~HGImgThumb();
|
|
||||||
|
|
||||||
enum ThumbType
|
|
||||||
{
|
|
||||||
ThumbType_Hori = 0, // 水平, item垂直居中
|
|
||||||
ThumbType_Vert = 1, // 垂直, item水平居中
|
|
||||||
ThumbType_Grid = 2 // 网格, 可以放大缩小
|
|
||||||
};
|
|
||||||
|
|
||||||
enum ThumbRemoveFlag
|
|
||||||
{
|
|
||||||
ThumbRemoveFlag_NULL = 0, // 仅仅从列表中删除,文件不处理
|
|
||||||
ThumbRemoveFlag_AllowUndo = 1, // 从列表中删除,并将文件放入回收站
|
|
||||||
ThumbRemoveFlag_Delete = 2 // 从列表中删除,并删除文件
|
|
||||||
};
|
|
||||||
|
|
||||||
HGResult setGapSize(int size);
|
|
||||||
HGResult setScrollSize(int size);
|
|
||||||
HGResult setMinScrollSliderSize(int size);
|
|
||||||
HGResult setItemSize(int size);
|
|
||||||
HGResult setItemTextHeight(int height);
|
|
||||||
HGResult setDefItemImage(const QImage *image);
|
|
||||||
HGResult setHScrollLeftImage(const QImage *normalImage, const QImage *hotImage, const QImage *pushImage);
|
|
||||||
HGResult setHScrollRightImage(const QImage *normalImage, const QImage *hotImage, const QImage *pushImage);
|
|
||||||
HGResult setVScrollTopImage(const QImage *normalImage, const QImage *hotImage, const QImage *pushImage);
|
|
||||||
HGResult setVScrollBottomImage(const QImage *normalImage, const QImage *hotImage, const QImage *pushImage);
|
|
||||||
HGResult setHScrollImage(const QImage *image, const HGRect *stretch);
|
|
||||||
HGResult setHScrollSliderImage(const QImage *normalImage, const HGRect *normalStretch, const QImage *hotImage, const HGRect *hotStretch,
|
|
||||||
const QImage *pushImage, const HGRect *pushStretch);
|
|
||||||
HGResult setVScrollImage(const QImage *image, const HGRect *stretch);
|
|
||||||
HGResult setVScrollSliderImage(const QImage *normalImage, const HGRect *normalStretch, const QImage *hotImage, const HGRect *hotStretch,
|
|
||||||
const QImage *pushImage, const HGRect *pushStretch);
|
|
||||||
HGResult setNullScrollImage(const QImage *image);
|
|
||||||
|
|
||||||
HGResult setType(ThumbType type);
|
|
||||||
HGResult zoomIn();
|
|
||||||
HGResult zoomOut();
|
|
||||||
|
|
||||||
HGResult getItemCount(int *count);
|
|
||||||
HGResult addItem(const QString &fileName);
|
|
||||||
HGResult addItems(const QStringList &fileNames);
|
|
||||||
HGResult insertItem(const QString &fileName, int pos);
|
|
||||||
HGResult insertItems(const QStringList &fileNames, int pos, bool append = false);
|
|
||||||
HGResult moveItems(const QStringList &fileNames, int pos);
|
|
||||||
HGResult moveItemsTo(const QStringList &fileNames, int index);
|
|
||||||
HGResult getItemFileName(int index, QString &fileName);
|
|
||||||
HGResult getCurrItem(int *index);
|
|
||||||
HGResult setCurrItem(int index);
|
|
||||||
HGResult resetCurrItem();
|
|
||||||
HGResult removeItem(int index, ThumbRemoveFlag flag);
|
|
||||||
HGResult removeItems(const std::vector<int> &indexs, ThumbRemoveFlag flag);
|
|
||||||
HGResult removeAllItems(ThumbRemoveFlag flag);
|
|
||||||
HGResult bookSort();
|
|
||||||
HGResult selectItem(int index, bool select);
|
|
||||||
HGResult itemIsSelect(int index, bool *select);
|
|
||||||
HGResult updateItem(int index, const QString &fileName);
|
|
||||||
HGResult refreshItem(int index);
|
|
||||||
HGResult refreshItem(const QString &fileName);
|
|
||||||
HGResult refreshAllItems();
|
|
||||||
|
|
||||||
void notify_mouse_leave(void);
|
|
||||||
|
|
||||||
signals:
|
|
||||||
void currItemChanged(int index);
|
|
||||||
void itemDoubleClicked(int index);
|
|
||||||
void itemCountChanged(int count);
|
|
||||||
void itemSelectingChanged();
|
|
||||||
void contextMenuEvent(int index);
|
|
||||||
void drop(const QObject *source, const QStringList &fileNames, int pos);
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
struct HGImgThumbItem
|
|
||||||
{
|
|
||||||
HGImgThumbItem()
|
|
||||||
{
|
|
||||||
width = 0;
|
|
||||||
height = 0;
|
|
||||||
image = NULL;
|
|
||||||
selected = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
~HGImgThumbItem()
|
|
||||||
{
|
|
||||||
if (NULL != image)
|
|
||||||
{
|
|
||||||
delete image;
|
|
||||||
image = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
QString fileName;
|
|
||||||
int width; // 实际宽
|
|
||||||
int height; // 实际高
|
|
||||||
QImage *image; // 缩略图
|
|
||||||
bool selected;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct ThumbRect
|
|
||||||
{
|
|
||||||
double left;
|
|
||||||
double top;
|
|
||||||
double right;
|
|
||||||
double bottom;
|
|
||||||
};
|
|
||||||
|
|
||||||
enum MouseStatus
|
|
||||||
{
|
|
||||||
MouseStatus_Null = 0,
|
|
||||||
MouseStatus_HScroll,
|
|
||||||
MouseStatus_HScrollSlider,
|
|
||||||
MouseStatus_HScrollLeft,
|
|
||||||
MouseStatus_HScrollRight,
|
|
||||||
MouseStatus_VScroll,
|
|
||||||
MouseStatus_VScrollSlider,
|
|
||||||
MouseStatus_VScrollTop,
|
|
||||||
MouseStatus_VScrollBottom,
|
|
||||||
MouseStatus_NullScroll
|
|
||||||
};
|
|
||||||
|
|
||||||
protected:
|
|
||||||
virtual void mousePressEvent(QMouseEvent *e);
|
|
||||||
virtual void mouseMoveEvent(QMouseEvent* e);
|
|
||||||
virtual void mouseReleaseEvent(QMouseEvent *e);
|
|
||||||
virtual void enterEvent(QEvent *e);
|
|
||||||
virtual void leaveEvent(QEvent *e);
|
|
||||||
virtual void paintEvent(QPaintEvent* e);
|
|
||||||
virtual void wheelEvent(QWheelEvent* e);
|
|
||||||
virtual void resizeEvent(QResizeEvent* e);
|
|
||||||
virtual void keyPressEvent(QKeyEvent *e);
|
|
||||||
virtual void keyReleaseEvent(QKeyEvent *e);
|
|
||||||
virtual void focusInEvent(QFocusEvent *e);
|
|
||||||
virtual void focusOutEvent(QFocusEvent *e);
|
|
||||||
virtual void contextMenuEvent(QContextMenuEvent* e);
|
|
||||||
virtual void dragEnterEvent(QDragEnterEvent *e);
|
|
||||||
virtual void dragMoveEvent(QDragMoveEvent *e);
|
|
||||||
virtual void dragLeaveEvent(QDragLeaveEvent *e);
|
|
||||||
virtual void dropEvent(QDropEvent *e);
|
|
||||||
virtual void mouseDoubleClickEvent(QMouseEvent *e);
|
|
||||||
|
|
||||||
signals:
|
|
||||||
void updateItem();
|
|
||||||
private slots:
|
|
||||||
void on_updateItem();
|
|
||||||
|
|
||||||
private:
|
|
||||||
static QImage* createItemImage(const QImage *srcImage, int itemSize);
|
|
||||||
static QImage* createItemImage(HGImage srcImage, int itemSize);
|
|
||||||
static void DrawImage(QPainter &painter, const QRect &destRect, const QImage *image, const QRect &stretchRect);
|
|
||||||
static void calcShowSize(int wndWidth, int wndHeight, int gapSize, int scrollSize, int itemSize, int itemTextHeight, ThumbType type, int itemCount,
|
|
||||||
int &showWidth, int &showHeight, bool &hScroll, bool &vScroll);
|
|
||||||
static void recalcShowRect(int wndWidth, int wndHeight, int scrollSize, ThumbType type, bool hScroll, bool vScroll, bool showThumb, ThumbRect &thumbRect);
|
|
||||||
|
|
||||||
void DrawScroll(QPainter &painter);
|
|
||||||
void reset();
|
|
||||||
QPoint getItemPos(int index); // 返回的坐标是相对于thumb区域的
|
|
||||||
void locateItem(int index);
|
|
||||||
void locateInsert(const QPoint &pt1, const QPoint &pt2); // pt1和pt2是相对于thumb区域的
|
|
||||||
int getItemRow(int index);
|
|
||||||
int getItemCol(int index);
|
|
||||||
int getTotalRows();
|
|
||||||
int getTotalCols();
|
|
||||||
int getRowCount(int row); // 获取每行的个数
|
|
||||||
int getItemIndex(const QPoint &pt, MouseStatus &mouseStatus); // pt是相对于窗口的
|
|
||||||
int getInsertPos(const QPoint &pt, bool &get, QPoint &pt1, QPoint &pt2); // pt是相对于窗口的, 返回的pt1和pt2是相对于thumb区域的
|
|
||||||
int findIndex(const QString &fileName);
|
|
||||||
|
|
||||||
QRect getHScrollLeftPos();
|
|
||||||
QRect getHScrollRightPos();
|
|
||||||
QRect getHScrollPos();
|
|
||||||
QRect getHScrollSliderPos();
|
|
||||||
QRect getVScrollTopPos();
|
|
||||||
QRect getVScrollBottomPos();
|
|
||||||
QRect getVScrollPos();
|
|
||||||
QRect getVScrollSliderPos();
|
|
||||||
QRect getNullScrollPos();
|
|
||||||
|
|
||||||
void Show();
|
|
||||||
static void HGAPI ThreadFunc(HGThread thread, HGPointer param);
|
|
||||||
|
|
||||||
private:
|
|
||||||
HGLock m_lockFront;
|
|
||||||
HGLock m_lockBack;
|
|
||||||
HGLock m_lockItemSize;
|
|
||||||
HGEvent m_event;
|
|
||||||
|
|
||||||
int m_gapSize;
|
|
||||||
int m_scrollSize;
|
|
||||||
int m_minScrollSliderSize;
|
|
||||||
int m_itemSize;
|
|
||||||
int m_itemTextHeight;
|
|
||||||
QImage *m_defItemImage;
|
|
||||||
QImage *m_itemImage;
|
|
||||||
QImage *m_hScrollLeftImage[3];
|
|
||||||
QImage *m_hScrollRightImage[3];
|
|
||||||
QImage *m_vScrollTopImage[3];
|
|
||||||
QImage *m_vScrollBottomImage[3];
|
|
||||||
QImage *m_hScrollImage;
|
|
||||||
QRect m_hScrollImageStretch;
|
|
||||||
QImage *m_hScrollSliderImage[3];
|
|
||||||
QRect m_hScrollSliderImageStretch[3];
|
|
||||||
QImage *m_vScrollImage;
|
|
||||||
QRect m_vScrollImageStretch;
|
|
||||||
QImage *m_vScrollSliderImage[3];
|
|
||||||
QRect m_vScrollSliderImageStretch[3];
|
|
||||||
QImage *m_nullScrollImage;
|
|
||||||
ThumbType m_type;
|
|
||||||
|
|
||||||
bool m_mouseOn;
|
|
||||||
int m_curItemIndex;
|
|
||||||
int m_hotItemIndex;
|
|
||||||
int m_pushItemIndex;
|
|
||||||
int m_signItemIndex;
|
|
||||||
bool m_stopThread;
|
|
||||||
HGThread m_thread;
|
|
||||||
std::vector<HGImgThumbItem *> m_frontItems;
|
|
||||||
std::list<QString> m_backList;
|
|
||||||
bool m_hScroll;
|
|
||||||
bool m_vScroll;
|
|
||||||
bool m_showThumb;
|
|
||||||
ThumbRect m_thumbRect;
|
|
||||||
MouseStatus m_mouseMoveStatus;
|
|
||||||
MouseStatus m_mousePressStatus;
|
|
||||||
int m_mousePressBeginX;
|
|
||||||
int m_mousePressBeginY;
|
|
||||||
Qt::MouseButtons m_hitMouseButtons;
|
|
||||||
Qt::KeyboardModifiers m_hitKeyboardModifiers;
|
|
||||||
int m_hitItemIndex; // 点击的索引
|
|
||||||
int m_operate; // 0, 1-拖动 2-框选
|
|
||||||
int m_operateStartX;
|
|
||||||
int m_operateStartY;
|
|
||||||
bool m_draging; // 进入拖动
|
|
||||||
bool m_insertPtValid;
|
|
||||||
QPoint m_insertPt1;
|
|
||||||
QPoint m_insertPt2;
|
|
||||||
int m_curInsertPos;
|
|
||||||
bool m_frameSelection; // 进入框选
|
|
||||||
bool m_frameSelectionRectValid;
|
|
||||||
int m_frameSelectionStartX; // 相对于thumb区域
|
|
||||||
int m_frameSelectionStartY; // 相对于thumb区域
|
|
||||||
HGRect m_frameSelectionRect; // 该区域是相对于thumb区域的
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif /* __HGIMGTHUMB_HPP__ */
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,146 +0,0 @@
|
||||||
#ifndef __HGIMGVIEW_H__
|
|
||||||
#define __HGIMGVIEW_H__
|
|
||||||
|
|
||||||
#include "base/HGDef.h"
|
|
||||||
#include "base/HGBaseErr.h"
|
|
||||||
#include "base/HGImage.h"
|
|
||||||
#include <QWidget>
|
|
||||||
|
|
||||||
class HGImgView : public QWidget
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
public:
|
|
||||||
HGImgView(QWidget* parent = nullptr);
|
|
||||||
virtual ~HGImgView();
|
|
||||||
|
|
||||||
HGResult setScrollSize(int size);
|
|
||||||
HGResult setMinScrollSliderSize(int size);
|
|
||||||
HGResult setHScrollLeftImage(const QImage *normalImage, const QImage *hotImage, const QImage *pushImage);
|
|
||||||
HGResult setHScrollRightImage(const QImage *normalImage, const QImage *hotImage, const QImage *pushImage);
|
|
||||||
HGResult setVScrollTopImage(const QImage *normalImage, const QImage *hotImage, const QImage *pushImage);
|
|
||||||
HGResult setVScrollBottomImage(const QImage *normalImage, const QImage *hotImage, const QImage *pushImage);
|
|
||||||
HGResult setHScrollImage(const QImage *image, const HGRect *stretch);
|
|
||||||
HGResult setHScrollSliderImage(const QImage *normalImage, const HGRect *normalStretch, const QImage *hotImage, const HGRect *hotStretch,
|
|
||||||
const QImage *pushImage, const HGRect *pushStretch);
|
|
||||||
HGResult setVScrollImage(const QImage *image, const HGRect *stretch);
|
|
||||||
HGResult setVScrollSliderImage(const QImage *normalImage, const HGRect *normalStretch, const QImage *hotImage, const HGRect *hotStretch,
|
|
||||||
const QImage *pushImage, const HGRect *pushStretch);
|
|
||||||
HGResult setNullScrollImage(const QImage *image);
|
|
||||||
|
|
||||||
HGResult enableScroll(bool enable);
|
|
||||||
HGResult addImage(HGImage image);
|
|
||||||
HGResult clearImage();
|
|
||||||
HGResult getImage(HGImage *image);
|
|
||||||
|
|
||||||
HGResult rotateLeft();
|
|
||||||
HGResult rotateRight();
|
|
||||||
HGResult rotate180();
|
|
||||||
|
|
||||||
HGResult zoomIn(const HGPoint *pCenter);
|
|
||||||
HGResult zoomOut(const HGPoint *pCenter);
|
|
||||||
HGResult realSize();
|
|
||||||
HGResult fitWndSize();
|
|
||||||
HGResult fitWndWidth();
|
|
||||||
|
|
||||||
HGResult showColorInfo(bool show);
|
|
||||||
|
|
||||||
signals:
|
|
||||||
void escape();
|
|
||||||
void doubleClicked();
|
|
||||||
void mousePos(int x, int y);
|
|
||||||
void scaleChanged(double scale);
|
|
||||||
void drop(const QObject *source, const QStringList &fileNames);
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
enum MouseStatus
|
|
||||||
{
|
|
||||||
MouseStatus_Null = 0,
|
|
||||||
MouseStatus_HScroll,
|
|
||||||
MouseStatus_HScrollSlider,
|
|
||||||
MouseStatus_HScrollLeft,
|
|
||||||
MouseStatus_HScrollRight,
|
|
||||||
MouseStatus_VScroll,
|
|
||||||
MouseStatus_VScrollSlider,
|
|
||||||
MouseStatus_VScrollTop,
|
|
||||||
MouseStatus_VScrollBottom,
|
|
||||||
MouseStatus_NullScroll
|
|
||||||
};
|
|
||||||
|
|
||||||
protected:
|
|
||||||
virtual void mousePressEvent(QMouseEvent *e);
|
|
||||||
virtual void mouseMoveEvent(QMouseEvent* e);
|
|
||||||
virtual void mouseReleaseEvent(QMouseEvent *e);
|
|
||||||
virtual void enterEvent(QEvent *e);
|
|
||||||
virtual void leaveEvent(QEvent *e);
|
|
||||||
virtual void paintEvent(QPaintEvent* e);
|
|
||||||
virtual void wheelEvent(QWheelEvent* e);
|
|
||||||
virtual void resizeEvent(QResizeEvent* e);
|
|
||||||
virtual void keyPressEvent(QKeyEvent *e);
|
|
||||||
virtual void dragEnterEvent(QDragEnterEvent *e);
|
|
||||||
virtual void dragMoveEvent(QDragMoveEvent *e);
|
|
||||||
virtual void dragLeaveEvent(QDragLeaveEvent *e);
|
|
||||||
virtual void dropEvent(QDropEvent *e);
|
|
||||||
virtual void mouseDoubleClickEvent(QMouseEvent* e);
|
|
||||||
|
|
||||||
private:
|
|
||||||
static void GetMinShowImageRect(const HGRect *pWnd, int nImgWidth, int nImgHeight, bool &bShowImage, HGRectF &rcShowImage);
|
|
||||||
static void ResizeShowImageRect(bool &bShowImage, HGRectF &rcShowImage, float fNewWidth, float fNewHeight, const HGPoint *pCenter);
|
|
||||||
static void recalcShowRect(int wndWidth, int wndHeight, int scrollSize, bool hScroll, bool vScroll, bool showImage, HGRectF &imageRect);
|
|
||||||
static void DrawImage(QPainter &painter, const QRect &destRect, const QImage *image, const QRect &stretchRect);
|
|
||||||
|
|
||||||
QImage* createQImage();
|
|
||||||
void DrawScroll(QPainter &painter);
|
|
||||||
void reset();
|
|
||||||
void updateMoveStatusAndCursor();
|
|
||||||
MouseStatus getMouseStatus(const QPoint &pt);
|
|
||||||
|
|
||||||
QRect getHScrollLeftPos();
|
|
||||||
QRect getHScrollRightPos();
|
|
||||||
QRect getHScrollPos();
|
|
||||||
QRect getHScrollSliderPos();
|
|
||||||
QRect getVScrollTopPos();
|
|
||||||
QRect getVScrollBottomPos();
|
|
||||||
QRect getVScrollPos();
|
|
||||||
QRect getVScrollSliderPos();
|
|
||||||
QRect getNullScrollPos();
|
|
||||||
|
|
||||||
void Show();
|
|
||||||
|
|
||||||
private:
|
|
||||||
int m_scrollSize;
|
|
||||||
int m_minScrollSliderSize;
|
|
||||||
QImage *m_hScrollLeftImage[3];
|
|
||||||
QImage *m_hScrollRightImage[3];
|
|
||||||
QImage *m_vScrollTopImage[3];
|
|
||||||
QImage *m_vScrollBottomImage[3];
|
|
||||||
QImage *m_hScrollImage;
|
|
||||||
QRect m_hScrollImageStretch;
|
|
||||||
QImage *m_hScrollSliderImage[3];
|
|
||||||
QRect m_hScrollSliderImageStretch[3];
|
|
||||||
QImage *m_vScrollImage;
|
|
||||||
QRect m_vScrollImageStretch;
|
|
||||||
QImage *m_vScrollSliderImage[3];
|
|
||||||
QRect m_vScrollSliderImageStretch[3];
|
|
||||||
QImage *m_nullScrollImage;
|
|
||||||
|
|
||||||
bool m_enableScroll;
|
|
||||||
bool m_mouseOn;
|
|
||||||
bool m_hScroll;
|
|
||||||
bool m_vScroll;
|
|
||||||
HGImage m_image;
|
|
||||||
QImage *m_qImage;
|
|
||||||
bool m_showImage;
|
|
||||||
HGRectF m_showRect;
|
|
||||||
MouseStatus m_mouseMoveStatus;
|
|
||||||
MouseStatus m_mousePressStatus;
|
|
||||||
int m_mousePressBeginX;
|
|
||||||
int m_mousePressBeginY;
|
|
||||||
bool m_showColorInfo;
|
|
||||||
int m_operate;
|
|
||||||
int m_beginX;
|
|
||||||
int m_beginY;
|
|
||||||
bool m_draging;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif /* __HGIMGVIEW_HPP__ */
|
|
|
@ -1,20 +0,0 @@
|
||||||
#include "HGUIGlobal.h"
|
|
||||||
#include "base/HGDef.h"
|
|
||||||
#include "base/HGInc.h"
|
|
||||||
#include "base/HGUtility.h"
|
|
||||||
|
|
||||||
QString getStdFileName(const QString &fileName)
|
|
||||||
{
|
|
||||||
char result[512] = {0};
|
|
||||||
HGBase_StandardiseFileName(fileName.toStdString().c_str(), result, 512);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string getStdString(const QString &str)
|
|
||||||
{
|
|
||||||
#ifdef HG_CMP_MSC
|
|
||||||
return str.toLocal8Bit().data();
|
|
||||||
#else
|
|
||||||
return str.toStdString();
|
|
||||||
#endif
|
|
||||||
}
|
|
|
@ -1,10 +0,0 @@
|
||||||
#ifndef __HGUIGLOBAL_H__
|
|
||||||
#define __HGUIGLOBAL_H__
|
|
||||||
|
|
||||||
#include <QString>
|
|
||||||
|
|
||||||
QString getStdFileName(const QString &fileName);
|
|
||||||
|
|
||||||
std::string getStdString(const QString &str);
|
|
||||||
|
|
||||||
#endif /* __HGUIGLOBAL_H__ */
|
|
|
@ -1,114 +0,0 @@
|
||||||
<RCC>
|
|
||||||
<qresource prefix="/qt">
|
|
||||||
<file>etc/qt.conf</file>
|
|
||||||
</qresource>
|
|
||||||
<qresource prefix="/translation">
|
|
||||||
<file>Scanner_zh_CN.qm</file>
|
|
||||||
<file>qt_zh_CN.qm</file>
|
|
||||||
<file>Scanner_zh_EN.qm</file>
|
|
||||||
</qresource>
|
|
||||||
<qresource prefix="/images">
|
|
||||||
<file>image_rsc/action/btnEmailScanedImages.png</file>
|
|
||||||
<file>image_rsc/action/btnFitWindow.png</file>
|
|
||||||
<file>image_rsc/action/btnFitWindowWidth.png</file>
|
|
||||||
<file>image_rsc/action/btnHelp.png</file>
|
|
||||||
<file>image_rsc/action/btnNext.png</file>
|
|
||||||
<file>image_rsc/action/btnNextPage.png</file>
|
|
||||||
<file>image_rsc/action/btnOriginalSize.png</file>
|
|
||||||
<file>image_rsc/action/btnPrevious.png</file>
|
|
||||||
<file>image_rsc/action/btnPreviousPage.png</file>
|
|
||||||
<file>image_rsc/action/btnRotateLeft.png</file>
|
|
||||||
<file>image_rsc/action/btnRotateRight.png</file>
|
|
||||||
<file>image_rsc/action/btnSaveScanedImages.png</file>
|
|
||||||
<file>image_rsc/action/btnScan.png</file>
|
|
||||||
<file>image_rsc/action/btnScannerSetting.png</file>
|
|
||||||
<file>image_rsc/action/btnZoomIn.png</file>
|
|
||||||
<file>image_rsc/action/btnZoomOut.png</file>
|
|
||||||
<file>image_rsc/actions/admin.png</file>
|
|
||||||
<file>image_rsc/actions/close.png</file>
|
|
||||||
<file>image_rsc/actions/contrast.png</file>
|
|
||||||
<file>image_rsc/actions/curve.png</file>
|
|
||||||
<file>image_rsc/actions/cut.png</file>
|
|
||||||
<file>image_rsc/actions/fullscreen.png</file>
|
|
||||||
<file>image_rsc/actions/help.png</file>
|
|
||||||
<file>image_rsc/actions/nextfile.png</file>
|
|
||||||
<file>image_rsc/actions/nextpage.png</file>
|
|
||||||
<file>image_rsc/actions/open.png</file>
|
|
||||||
<file>image_rsc/actions/previousfile.png</file>
|
|
||||||
<file>image_rsc/actions/previouspage.png</file>
|
|
||||||
<file>image_rsc/actions/print.png</file>
|
|
||||||
<file>image_rsc/actions/redo.png</file>
|
|
||||||
<file>image_rsc/actions/rotate-anticlockwise.png</file>
|
|
||||||
<file>image_rsc/actions/rotate-clockwise.png</file>
|
|
||||||
<file>image_rsc/actions/save.png</file>
|
|
||||||
<file>image_rsc/actions/saveAs.png</file>
|
|
||||||
<file>image_rsc/actions/scan.png</file>
|
|
||||||
<file>image_rsc/actions/settings.png</file>
|
|
||||||
<file>image_rsc/actions/sortpages.png</file>
|
|
||||||
<file>image_rsc/actions/undo.png</file>
|
|
||||||
<file>image_rsc/actions/zoom-fitscreen.png</file>
|
|
||||||
<file>image_rsc/actions/zoom-fitwidth.png</file>
|
|
||||||
<file>image_rsc/actions/zoom-in.png</file>
|
|
||||||
<file>image_rsc/actions/zoom-origin.png</file>
|
|
||||||
<file>image_rsc/actions/zoom-out.png</file>
|
|
||||||
<file>image_rsc/adjust/Img_BightnessReduce.png</file>
|
|
||||||
<file>image_rsc/adjust/Img_BrightnessIncrease.png</file>
|
|
||||||
<file>image_rsc/adjust/Img_ContrastIncrease.png</file>
|
|
||||||
<file>image_rsc/adjust/Img_ContrastReduce.png</file>
|
|
||||||
<file>image_rsc/example/example_arrow.png</file>
|
|
||||||
<file>image_rsc/example/example_black_after.png</file>
|
|
||||||
<file>image_rsc/example/example_black_before.png</file>
|
|
||||||
<file>image_rsc/example/example_crop_after.png</file>
|
|
||||||
<file>image_rsc/example/example_deskew_after.png</file>
|
|
||||||
<file>image_rsc/example/example_deskew_before.png</file>
|
|
||||||
<file>image_rsc/example/example_fillblack_before.png</file>
|
|
||||||
<file>image_rsc/example/example_fillblack_concave.png</file>
|
|
||||||
<file>image_rsc/example/example_fillblack_convex.png</file>
|
|
||||||
<file>image_rsc/example/example_fillcolor_auto.png</file>
|
|
||||||
<file>image_rsc/example/example_fillcolor_before.png</file>
|
|
||||||
<file>image_rsc/example/example_fillcolor_default.png</file>
|
|
||||||
<file>image_rsc/fullscreen/btnNext.png</file>
|
|
||||||
<file>image_rsc/fullscreen/btnPrevious.png</file>
|
|
||||||
<file>image_rsc/logo/auge_logo.ico</file>
|
|
||||||
<file>image_rsc/logo/Hanvon_logo1.ico</file>
|
|
||||||
<file>image_rsc/logo/Hanvon_logo2.ico</file>
|
|
||||||
<file>image_rsc/logo/HG_Logo.png</file>
|
|
||||||
<file>image_rsc/logo/HUAGO-LOGO-for UI.jpg</file>
|
|
||||||
<file>image_rsc/logo/HUAGO-LOGO-for UI.png</file>
|
|
||||||
<file>image_rsc/logo/Lanxum_logo.ico</file>
|
|
||||||
<file>image_rsc/logo/Cumtenn_logo.ico</file>
|
|
||||||
<file>image_rsc/logo/logo.ico</file>
|
|
||||||
<file>image_rsc/logo/NoBrand_logo.ico</file>
|
|
||||||
<file>image_rsc/logo/RightWay_logo.ico</file>
|
|
||||||
<file>image_rsc/logo/waiting.gif</file>
|
|
||||||
<file>image_rsc/statusbar/statusBar_admin.png</file>
|
|
||||||
<file>image_rsc/scroll/bottom_Hot.png</file>
|
|
||||||
<file>image_rsc/scroll/bottom_Normal.png</file>
|
|
||||||
<file>image_rsc/scroll/bottom_Push.png</file>
|
|
||||||
<file>image_rsc/scroll/defItemImage.png</file>
|
|
||||||
<file>image_rsc/scroll/hScrollImage.png</file>
|
|
||||||
<file>image_rsc/scroll/hScrollSlider_Hot.png</file>
|
|
||||||
<file>image_rsc/scroll/hScrollSlider_Normal.png</file>
|
|
||||||
<file>image_rsc/scroll/hScrollSlider_Push.png</file>
|
|
||||||
<file>image_rsc/scroll/left_Hot.png</file>
|
|
||||||
<file>image_rsc/scroll/left_Normal.png</file>
|
|
||||||
<file>image_rsc/scroll/left_Push.png</file>
|
|
||||||
<file>image_rsc/scroll/nullScrollImage.png</file>
|
|
||||||
<file>image_rsc/scroll/right_Hot.png</file>
|
|
||||||
<file>image_rsc/scroll/right_Normal.png</file>
|
|
||||||
<file>image_rsc/scroll/right_Push.png</file>
|
|
||||||
<file>image_rsc/scroll/top_Hot.png</file>
|
|
||||||
<file>image_rsc/scroll/top_Normal.png</file>
|
|
||||||
<file>image_rsc/scroll/top_Push.png</file>
|
|
||||||
<file>image_rsc/scroll/vScrollImage.png</file>
|
|
||||||
<file>image_rsc/scroll/vScrollSlider_Hot.png</file>
|
|
||||||
<file>image_rsc/scroll/vScrollSlider_Normal.png</file>
|
|
||||||
<file>image_rsc/scroll/vScrollSlider_Push.png</file>
|
|
||||||
<file>image_rsc/action/btnEdit.png</file>
|
|
||||||
<file>image_rsc/logo/Microtek_logo.ico</file>
|
|
||||||
<file>image_rsc/logo/uniscan.ico</file>
|
|
||||||
<file>image_rsc/actions/imageEdit.png</file>
|
|
||||||
<file>image_rsc/actions/scanInto.png</file>
|
|
||||||
<file>image_rsc/logo/deli.ico</file>
|
|
||||||
</qresource>
|
|
||||||
</RCC>
|
|
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
|
@ -1,552 +0,0 @@
|
||||||
#include "VersionDll.h"
|
|
||||||
#include "base/HGDef.h"
|
|
||||||
#include "base/HGInc.h"
|
|
||||||
#include "base/HGUtility.h"
|
|
||||||
|
|
||||||
VersionDll::VersionDll()
|
|
||||||
{
|
|
||||||
m_dll = NULL;
|
|
||||||
m_funcCreateMgr = NULL;
|
|
||||||
m_funcDestroyMgr = NULL;
|
|
||||||
m_funcGetServerConfig = NULL;
|
|
||||||
m_funcGetVersionList = NULL;
|
|
||||||
m_funcGetDriverVersionList = NULL;
|
|
||||||
m_funcBlackListCheck = NULL;
|
|
||||||
m_funcPostCrashInfo = NULL;
|
|
||||||
m_funcPostUserFeedback = NULL;
|
|
||||||
m_funcHttpDownload = NULL;
|
|
||||||
m_funcReleaseVersionList = NULL;
|
|
||||||
m_funcGetCurrVersion = NULL;
|
|
||||||
m_funcCompareVersion = NULL;
|
|
||||||
m_funcPostDeviceOpenInfo = NULL;
|
|
||||||
m_funcPostDeviceCloseInfo = NULL;
|
|
||||||
m_funcPostDeviceScanCountInfo = NULL;
|
|
||||||
m_funcPostDeviceClearRollerInfo = NULL;
|
|
||||||
m_funcPostDeviceHistroyCountInfo = NULL;
|
|
||||||
m_funcPostDeviceRollerCountInfo = NULL;
|
|
||||||
m_funcPostUserOpenInfo = NULL;
|
|
||||||
m_funcPostUserCloseInfo = NULL;
|
|
||||||
m_funcPostUserLoginInfo = NULL;
|
|
||||||
m_funcPostUserLogoutInfo = NULL;
|
|
||||||
m_funcPostDevicePaperJamInfo = NULL;
|
|
||||||
m_funcPostDeviceLockInfo = NULL;
|
|
||||||
m_mgr = NULL;
|
|
||||||
|
|
||||||
Load();
|
|
||||||
}
|
|
||||||
|
|
||||||
VersionDll::~VersionDll()
|
|
||||||
{
|
|
||||||
Free();
|
|
||||||
}
|
|
||||||
|
|
||||||
HGResult VersionDll::Load()
|
|
||||||
{
|
|
||||||
if (NULL != m_dll)
|
|
||||||
{
|
|
||||||
return HGBASE_ERR_FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
HGChar moduleName[256];
|
|
||||||
HGBase_GetModuleName(nullptr, moduleName, 256);
|
|
||||||
HGChar dllPath[256];
|
|
||||||
HGBase_GetFilePath(moduleName, dllPath, 256);
|
|
||||||
|
|
||||||
#if defined(HG_CMP_MSC)
|
|
||||||
#if defined(OEM_HANWANG)
|
|
||||||
strcat(dllPath, "HWVersion.dll");
|
|
||||||
#elif defined(OEM_LISICHENG)
|
|
||||||
strcat(dllPath, "LSCVersion.dll");
|
|
||||||
#elif defined(OEM_CANGTIAN)
|
|
||||||
strcat(dllPath, "CTSVersion.dll");
|
|
||||||
#elif defined(OEM_ZHONGJING)
|
|
||||||
strcat(dllPath, "ZJVersion.dll");
|
|
||||||
#elif defined(OEM_ZIGUANG)
|
|
||||||
strcat(dllPath, "ZGVersion.dll");
|
|
||||||
#elif defined(OEM_NEUTRAL)
|
|
||||||
strcat(dllPath, "HGNeuVersion.dll");
|
|
||||||
#elif defined(OEM_DELI)
|
|
||||||
strcat(dllPath, "DlVersion.dll");
|
|
||||||
#else
|
|
||||||
strcat(dllPath, "HGVersion.dll");
|
|
||||||
#endif
|
|
||||||
#else
|
|
||||||
#if defined(OEM_HANWANG)
|
|
||||||
strcpy(dllPath, "libHwVersion.so");
|
|
||||||
#elif defined(OEM_LISICHENG)
|
|
||||||
strcpy(dllPath, "libLscVersion.so");
|
|
||||||
#elif defined(OEM_CANGTIAN)
|
|
||||||
strcpy(dllPath, "libCtsVersion.so");
|
|
||||||
#elif defined(OEM_ZHONGJING)
|
|
||||||
strcpy(dllPath, "libZjVersion.so");
|
|
||||||
#elif defined(OEM_ZIGUANG)
|
|
||||||
strcpy(dllPath, "libZgVersion.so");
|
|
||||||
#elif defined(OEM_NEUTRAL)
|
|
||||||
strcat(dllPath, "libHGNeuVersion.so");
|
|
||||||
#elif defined(OEM_DELI)
|
|
||||||
strcat(dllPath, "libDlVersion.so");
|
|
||||||
#else
|
|
||||||
strcpy(dllPath, "libHGVersion.so");
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
HGBase_CreateDll(dllPath, &m_dll);
|
|
||||||
if (NULL == m_dll)
|
|
||||||
{
|
|
||||||
return HGBASE_ERR_FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ok = true;
|
|
||||||
do
|
|
||||||
{
|
|
||||||
HGBase_GetDllProcAddress(m_dll, "HGVersion_CreateMgr", (HGPointer *)&m_funcCreateMgr);
|
|
||||||
if (NULL == m_funcCreateMgr)
|
|
||||||
{
|
|
||||||
ok = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
HGBase_GetDllProcAddress(m_dll, "HGVersion_DestroyMgr", (HGPointer *)&m_funcDestroyMgr);
|
|
||||||
if (NULL == m_funcDestroyMgr)
|
|
||||||
{
|
|
||||||
ok = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
HGBase_GetDllProcAddress(m_dll, "HGVersion_GetServerConfig", (HGPointer *)&m_funcGetServerConfig);
|
|
||||||
if (NULL == m_funcGetServerConfig)
|
|
||||||
{
|
|
||||||
ok = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
HGBase_GetDllProcAddress(m_dll, "HGVersion_PostCrashInfo", (HGPointer *)&m_funcPostCrashInfo);
|
|
||||||
if (NULL == m_funcPostCrashInfo)
|
|
||||||
{
|
|
||||||
ok = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
HGBase_GetDllProcAddress(m_dll, "HGVersion_PostUserFeedback", (HGPointer *)&m_funcPostUserFeedback);
|
|
||||||
if (NULL == m_funcPostUserFeedback)
|
|
||||||
{
|
|
||||||
ok = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
HGBase_GetDllProcAddress(m_dll, "HGVersion_GetVersionList", (HGPointer *)&m_funcGetVersionList);
|
|
||||||
if (NULL == m_funcGetVersionList)
|
|
||||||
{
|
|
||||||
ok = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
HGBase_GetDllProcAddress(m_dll, "HGVersion_GetDriverVersionList", (HGPointer*)&m_funcGetDriverVersionList);
|
|
||||||
if (NULL == m_funcGetDriverVersionList)
|
|
||||||
{
|
|
||||||
ok = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
HGBase_GetDllProcAddress(m_dll, "HGVersion_BlackListCheck", (HGPointer*)&m_funcBlackListCheck);
|
|
||||||
if (NULL == m_funcBlackListCheck)
|
|
||||||
{
|
|
||||||
ok = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
HGBase_GetDllProcAddress(m_dll, "HGVersion_HttpDownload", (HGPointer *)&m_funcHttpDownload);
|
|
||||||
if (NULL == m_funcHttpDownload)
|
|
||||||
{
|
|
||||||
ok = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
HGBase_GetDllProcAddress(m_dll, "HGVersion_ReleaseVersionList", (HGPointer *)&m_funcReleaseVersionList);
|
|
||||||
if (NULL == m_funcReleaseVersionList)
|
|
||||||
{
|
|
||||||
ok = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
HGBase_GetDllProcAddress(m_dll, "HGVersion_GetCurrVersion", (HGPointer *)&m_funcGetCurrVersion);
|
|
||||||
if (NULL == m_funcGetCurrVersion)
|
|
||||||
{
|
|
||||||
ok = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
HGBase_GetDllProcAddress(m_dll, "HGVersion_CompareVersion", (HGPointer *)&m_funcCompareVersion);
|
|
||||||
if (NULL == m_funcCompareVersion)
|
|
||||||
{
|
|
||||||
ok = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
HGBase_GetDllProcAddress(m_dll, "HGVersion_PostDeviceOpenInfo", (HGPointer *)&m_funcPostDeviceOpenInfo);
|
|
||||||
if (NULL == m_funcPostDeviceOpenInfo)
|
|
||||||
{
|
|
||||||
ok = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
HGBase_GetDllProcAddress(m_dll, "HGVersion_PostDeviceCloseInfo", (HGPointer *)&m_funcPostDeviceCloseInfo);
|
|
||||||
if (NULL == m_funcPostDeviceCloseInfo)
|
|
||||||
{
|
|
||||||
ok = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
HGBase_GetDllProcAddress(m_dll, "HGVersion_PostDeviceScanCountInfo", (HGPointer *)&m_funcPostDeviceScanCountInfo);
|
|
||||||
if (NULL == m_funcPostDeviceScanCountInfo)
|
|
||||||
{
|
|
||||||
ok = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
HGBase_GetDllProcAddress(m_dll, "HGVersion_PostDeviceClearRollerInfo", (HGPointer *)&m_funcPostDeviceClearRollerInfo);
|
|
||||||
if (NULL == m_funcPostDeviceClearRollerInfo)
|
|
||||||
{
|
|
||||||
ok = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
HGBase_GetDllProcAddress(m_dll, "HGVersion_PostDeviceHistroyCountInfo", (HGPointer *)&m_funcPostDeviceHistroyCountInfo);
|
|
||||||
if (NULL == m_funcPostDeviceHistroyCountInfo)
|
|
||||||
{
|
|
||||||
ok = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
HGBase_GetDllProcAddress(m_dll, "HGVersion_PostDeviceRollerCountInfo", (HGPointer *)&m_funcPostDeviceRollerCountInfo);
|
|
||||||
if (NULL == m_funcPostDeviceRollerCountInfo)
|
|
||||||
{
|
|
||||||
ok = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
HGBase_GetDllProcAddress(m_dll, "HGVersion_PostUserOpenInfo", (HGPointer *)&m_funcPostUserOpenInfo);
|
|
||||||
if (NULL == m_funcPostUserOpenInfo)
|
|
||||||
{
|
|
||||||
ok = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
HGBase_GetDllProcAddress(m_dll, "HGVersion_PostUserCloseInfo", (HGPointer *)&m_funcPostUserCloseInfo);
|
|
||||||
if (NULL == m_funcPostUserCloseInfo)
|
|
||||||
{
|
|
||||||
ok = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
HGBase_GetDllProcAddress(m_dll, "HGVersion_PostUserLoginInfo", (HGPointer *)&m_funcPostUserLoginInfo);
|
|
||||||
if (NULL == m_funcPostUserLoginInfo)
|
|
||||||
{
|
|
||||||
ok = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
HGBase_GetDllProcAddress(m_dll, "HGVersion_PostUserLogoutInfo", (HGPointer *)&m_funcPostUserLogoutInfo);
|
|
||||||
if (NULL == m_funcPostUserLogoutInfo)
|
|
||||||
{
|
|
||||||
ok = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
HGBase_GetDllProcAddress(m_dll, "HGVersion_PostDevicePaperJamInfo", (HGPointer *)&m_funcPostDevicePaperJamInfo);
|
|
||||||
if (NULL == m_funcPostDevicePaperJamInfo)
|
|
||||||
{
|
|
||||||
ok = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
HGBase_GetDllProcAddress(m_dll, "HGVersion_PostDeviceLockInfo", (HGPointer *)&m_funcPostDeviceLockInfo);
|
|
||||||
if (NULL == m_funcPostDeviceLockInfo)
|
|
||||||
{
|
|
||||||
ok = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_funcCreateMgr(&m_mgr);
|
|
||||||
if (NULL == m_mgr)
|
|
||||||
{
|
|
||||||
ok = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
}while (0);
|
|
||||||
|
|
||||||
if (!ok)
|
|
||||||
{
|
|
||||||
m_funcCreateMgr = NULL;
|
|
||||||
m_funcDestroyMgr = NULL;
|
|
||||||
m_funcGetServerConfig = NULL;
|
|
||||||
m_funcGetVersionList = NULL;
|
|
||||||
m_funcGetDriverVersionList = NULL;
|
|
||||||
m_funcBlackListCheck = NULL;
|
|
||||||
m_funcPostCrashInfo = NULL;
|
|
||||||
m_funcPostUserFeedback = NULL;
|
|
||||||
m_funcHttpDownload = NULL;
|
|
||||||
m_funcReleaseVersionList = NULL;
|
|
||||||
m_funcGetCurrVersion = NULL;
|
|
||||||
m_funcCompareVersion = NULL;
|
|
||||||
|
|
||||||
m_funcPostDeviceOpenInfo = NULL;
|
|
||||||
m_funcPostDeviceCloseInfo = NULL;
|
|
||||||
m_funcPostDeviceScanCountInfo = NULL;
|
|
||||||
m_funcPostDeviceClearRollerInfo = NULL;
|
|
||||||
m_funcPostDeviceHistroyCountInfo = NULL;
|
|
||||||
m_funcPostDeviceRollerCountInfo = NULL;
|
|
||||||
m_funcPostUserOpenInfo = NULL;
|
|
||||||
m_funcPostUserCloseInfo = NULL;
|
|
||||||
m_funcPostUserLoginInfo = NULL;
|
|
||||||
m_funcPostUserLogoutInfo = NULL;
|
|
||||||
m_funcPostDevicePaperJamInfo = NULL;
|
|
||||||
m_funcPostDeviceLockInfo = NULL;
|
|
||||||
|
|
||||||
HGBase_DestroyDll(m_dll);
|
|
||||||
m_dll = NULL;
|
|
||||||
return HGBASE_ERR_FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return HGBASE_ERR_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
HGResult VersionDll::Free()
|
|
||||||
{
|
|
||||||
if (NULL == m_dll)
|
|
||||||
{
|
|
||||||
return HGBASE_ERR_FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_funcDestroyMgr(m_mgr);
|
|
||||||
m_mgr = NULL;
|
|
||||||
HGBase_DestroyDll(m_dll);
|
|
||||||
m_dll = NULL;
|
|
||||||
return HGBASE_ERR_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
HGBool VersionDll::IsValid()
|
|
||||||
{
|
|
||||||
return (NULL != m_dll);
|
|
||||||
}
|
|
||||||
|
|
||||||
HGResult VersionDll::GetServerConfig(HGServerConfig *config)
|
|
||||||
{
|
|
||||||
if (NULL == m_funcGetServerConfig)
|
|
||||||
{
|
|
||||||
return HGBASE_ERR_FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return m_funcGetServerConfig(m_mgr, config);
|
|
||||||
}
|
|
||||||
|
|
||||||
HGResult VersionDll::GetVersionList(const HGChar* appName, const HGChar* oemName, HGVersionInfo **info, HGUInt *count)
|
|
||||||
{
|
|
||||||
if (NULL == m_funcGetVersionList)
|
|
||||||
{
|
|
||||||
return HGBASE_ERR_FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return m_funcGetVersionList(m_mgr, appName, oemName, info, count);
|
|
||||||
}
|
|
||||||
|
|
||||||
HGResult VersionDll::GetDriverVersionList(const HGChar* devType, HGVersionInfo** info, HGUInt* count)
|
|
||||||
{
|
|
||||||
if (NULL == m_funcGetDriverVersionList)
|
|
||||||
{
|
|
||||||
return HGBASE_ERR_FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return m_funcGetDriverVersionList(m_mgr, devType, info, count);
|
|
||||||
}
|
|
||||||
|
|
||||||
HGResult VersionDll::BlackListCheck(const HGChar* devSN, HGBool* inList)
|
|
||||||
{
|
|
||||||
if (NULL == m_funcBlackListCheck)
|
|
||||||
{
|
|
||||||
return HGBASE_ERR_FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return m_funcBlackListCheck(m_mgr, devSN, inList);
|
|
||||||
}
|
|
||||||
|
|
||||||
HGResult VersionDll::HttpDownload(const HGChar *url, const HGChar *saveFilePath, HGHttpDownloadFunc func, HGPointer param)
|
|
||||||
{
|
|
||||||
if (NULL == m_funcHttpDownload)
|
|
||||||
{
|
|
||||||
return HGBASE_ERR_FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return m_funcHttpDownload(m_mgr, url, saveFilePath, func, param);
|
|
||||||
}
|
|
||||||
|
|
||||||
HGResult VersionDll::ReleaseVersionList(HGVersionInfo* info, HGUInt count)
|
|
||||||
{
|
|
||||||
if (NULL == m_funcReleaseVersionList)
|
|
||||||
{
|
|
||||||
return HGBASE_ERR_FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return m_funcReleaseVersionList(info, count);
|
|
||||||
}
|
|
||||||
|
|
||||||
HGResult VersionDll::GetCurrVersion(const HGChar* appName, const HGChar* oemName, HGChar* version, HGUInt maxLen)
|
|
||||||
{
|
|
||||||
if (NULL == m_funcGetCurrVersion)
|
|
||||||
{
|
|
||||||
return HGBASE_ERR_FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return m_funcGetCurrVersion(appName, oemName, version, maxLen);
|
|
||||||
}
|
|
||||||
|
|
||||||
HGResult VersionDll::CompareVersion(const HGChar* version1, const HGChar* version2, HGInt* result)
|
|
||||||
{
|
|
||||||
if (NULL == m_funcCompareVersion)
|
|
||||||
{
|
|
||||||
return HGBASE_ERR_FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return m_funcCompareVersion(version1, version2, result);
|
|
||||||
}
|
|
||||||
|
|
||||||
HGResult VersionDll::PostCrashInfo(const HGChar* appName, const HGChar* oemName, const HGChar* desc, const HGChar* crashFilePath, const HGChar* exceptionAddr)
|
|
||||||
{
|
|
||||||
if (NULL == m_funcPostCrashInfo)
|
|
||||||
{
|
|
||||||
return HGBASE_ERR_FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return m_funcPostCrashInfo(m_mgr, appName, oemName, desc, crashFilePath, exceptionAddr);
|
|
||||||
}
|
|
||||||
|
|
||||||
HGResult VersionDll::PostUserFeedback(const HGChar* appName, const HGChar* oemName, const HGChar* desc, const HGChar* feedback, const HGChar* contact)
|
|
||||||
{
|
|
||||||
if (NULL == m_funcPostUserFeedback)
|
|
||||||
{
|
|
||||||
return HGBASE_ERR_FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return m_funcPostUserFeedback(m_mgr, appName, oemName, desc, feedback, contact);
|
|
||||||
}
|
|
||||||
|
|
||||||
HGResult VersionDll::PostDeviceOpenInfo(const HGChar *devName, const HGChar *devSN, const HGChar *devType, const HGChar *devFW)
|
|
||||||
{
|
|
||||||
if (NULL == m_funcPostDeviceOpenInfo)
|
|
||||||
{
|
|
||||||
return HGBASE_ERR_FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return m_funcPostDeviceOpenInfo(m_mgr, devName, devSN, devType, devFW);
|
|
||||||
}
|
|
||||||
|
|
||||||
HGResult VersionDll::PostDeviceCloseInfo(const HGChar *devName, const HGChar *devSN, const HGChar *devType, const HGChar *devFW)
|
|
||||||
{
|
|
||||||
if (NULL == m_funcPostDeviceCloseInfo)
|
|
||||||
{
|
|
||||||
return HGBASE_ERR_FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return m_funcPostDeviceCloseInfo(m_mgr, devName, devSN, devType, devFW);
|
|
||||||
}
|
|
||||||
|
|
||||||
HGResult VersionDll::PostDeviceScanCountInfo(const HGChar *devName, const HGChar *devSN, const HGChar *devType, const HGChar *devFW, HGUInt scanCount)
|
|
||||||
{
|
|
||||||
if (NULL == m_funcPostDeviceScanCountInfo)
|
|
||||||
{
|
|
||||||
return HGBASE_ERR_FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return m_funcPostDeviceScanCountInfo(m_mgr, devName, devSN, devType, devFW, scanCount);
|
|
||||||
}
|
|
||||||
|
|
||||||
HGResult VersionDll::PostDeviceClearRollerInfo(const HGChar *devName, const HGChar *devSN, const HGChar *devType, const HGChar *devFW)
|
|
||||||
{
|
|
||||||
if (NULL == m_funcPostDeviceClearRollerInfo)
|
|
||||||
{
|
|
||||||
return HGBASE_ERR_FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return m_funcPostDeviceClearRollerInfo(m_mgr, devName, devSN, devType, devFW);
|
|
||||||
}
|
|
||||||
|
|
||||||
HGResult VersionDll::PostDeviceHistroyCountInfo(const HGChar *devName, const HGChar *devSN, const HGChar *devType, const HGChar *devFW, HGUInt histroyCount)
|
|
||||||
{
|
|
||||||
if (NULL == m_funcPostDeviceHistroyCountInfo)
|
|
||||||
{
|
|
||||||
return HGBASE_ERR_FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return m_funcPostDeviceHistroyCountInfo(m_mgr, devName, devSN, devType, devFW, histroyCount);
|
|
||||||
}
|
|
||||||
|
|
||||||
HGResult VersionDll::PostDeviceRollerCountInfo(const HGChar *devName, const HGChar *devSN, const HGChar *devType, const HGChar *devFW, HGUInt rollerCount)
|
|
||||||
{
|
|
||||||
if (NULL == m_funcPostDeviceRollerCountInfo)
|
|
||||||
{
|
|
||||||
return HGBASE_ERR_FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return m_funcPostDeviceRollerCountInfo(m_mgr, devName, devSN, devType, devFW, rollerCount);
|
|
||||||
}
|
|
||||||
|
|
||||||
HGResult VersionDll::PostUserOpenInfo(const HGChar *appName, const HGChar* oemName)
|
|
||||||
{
|
|
||||||
if (NULL == m_funcPostUserOpenInfo)
|
|
||||||
{
|
|
||||||
return HGBASE_ERR_FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return m_funcPostUserOpenInfo(m_mgr, appName, oemName);
|
|
||||||
}
|
|
||||||
|
|
||||||
HGResult VersionDll::PostUserCloseInfo(const HGChar *appName, const HGChar* oemName)
|
|
||||||
{
|
|
||||||
if (NULL == m_funcPostUserCloseInfo)
|
|
||||||
{
|
|
||||||
return HGBASE_ERR_FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return m_funcPostUserCloseInfo(m_mgr, appName, oemName);
|
|
||||||
}
|
|
||||||
|
|
||||||
HGResult VersionDll::PostUserLoginInfo(const HGChar *appName, const HGChar* oemName)
|
|
||||||
{
|
|
||||||
if (NULL == m_funcPostUserLoginInfo)
|
|
||||||
{
|
|
||||||
return HGBASE_ERR_FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return m_funcPostUserLoginInfo(m_mgr, appName, oemName);
|
|
||||||
}
|
|
||||||
|
|
||||||
HGResult VersionDll::PostUserLogoutInfo(const HGChar *appName, const HGChar* oemName)
|
|
||||||
{
|
|
||||||
if (NULL == m_funcPostUserLogoutInfo)
|
|
||||||
{
|
|
||||||
return HGBASE_ERR_FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return m_funcPostUserLogoutInfo(m_mgr, appName, oemName);
|
|
||||||
}
|
|
||||||
|
|
||||||
HGResult VersionDll::PostDevicePaperJamInfo(const HGChar* devName, const HGChar* devSN, const HGChar* devType, const HGChar* devFW)
|
|
||||||
{
|
|
||||||
if (NULL == m_funcPostDevicePaperJamInfo)
|
|
||||||
{
|
|
||||||
return HGBASE_ERR_FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return m_funcPostDevicePaperJamInfo(m_mgr, devName, devSN, devType, devFW);
|
|
||||||
}
|
|
||||||
|
|
||||||
HGResult HGAPI VersionDll::PostDeviceLockInfo(const HGChar* devName, const HGChar* devSN, const HGChar* devType, const HGChar* devFW, HGBool isLock)
|
|
||||||
{
|
|
||||||
if (NULL == m_funcPostDeviceLockInfo)
|
|
||||||
{
|
|
||||||
return HGBASE_ERR_FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return m_funcPostDeviceLockInfo(m_mgr, devName, devSN, devType, devFW, isLock);
|
|
||||||
}
|
|
|
@ -1,100 +0,0 @@
|
||||||
#ifndef VERSIONDLL_H
|
|
||||||
#define VERSIONDLL_H
|
|
||||||
|
|
||||||
#include "version/HGVersion.h"
|
|
||||||
#include "base/HGDll.h"
|
|
||||||
|
|
||||||
class VersionDll
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
VersionDll();
|
|
||||||
~VersionDll();
|
|
||||||
|
|
||||||
HGResult Load();
|
|
||||||
HGResult Free();
|
|
||||||
HGBool IsValid();
|
|
||||||
|
|
||||||
HGResult GetServerConfig(HGServerConfig *config);
|
|
||||||
HGResult GetVersionList(const HGChar* appName, const HGChar* oemName, HGVersionInfo **info, HGUInt *count);
|
|
||||||
HGResult GetDriverVersionList(const HGChar* devType, HGVersionInfo** info, HGUInt* count);
|
|
||||||
HGResult BlackListCheck(const HGChar* devSN, HGBool* inList);
|
|
||||||
HGResult HttpDownload(const HGChar *url, const HGChar *saveFilePath, HGHttpDownloadFunc func, HGPointer param);
|
|
||||||
HGResult ReleaseVersionList(HGVersionInfo* info, HGUInt count);
|
|
||||||
HGResult GetCurrVersion(const HGChar* appName, const HGChar* oemName, HGChar* version, HGUInt maxLen);
|
|
||||||
HGResult CompareVersion(const HGChar* version1, const HGChar* version2, HGInt* result);
|
|
||||||
HGResult PostCrashInfo(const HGChar* appName, const HGChar* oemName, const HGChar* desc, const HGChar* crashFilePath, const HGChar* exceptionAddr);
|
|
||||||
HGResult PostUserFeedback(const HGChar* appName, const HGChar* oemName, const HGChar* desc, const HGChar* feedback, const HGChar* contact);
|
|
||||||
|
|
||||||
HGResult PostDeviceOpenInfo(const HGChar* devName, const HGChar* devSN, const HGChar* devType, const HGChar* devFW);
|
|
||||||
HGResult PostDeviceCloseInfo(const HGChar* devName, const HGChar* devSN, const HGChar* devType, const HGChar* devFW);
|
|
||||||
HGResult PostDeviceScanCountInfo(const HGChar* devName, const HGChar* devSN, const HGChar* devType, const HGChar* devFW, HGUInt scanCount);
|
|
||||||
HGResult PostDeviceClearRollerInfo(const HGChar* devName, const HGChar* devSN, const HGChar* devType, const HGChar* devFW);
|
|
||||||
HGResult PostDeviceHistroyCountInfo(const HGChar* devName, const HGChar* devSN, const HGChar* devType, const HGChar* devFW, HGUInt histroyCount);
|
|
||||||
HGResult PostDeviceRollerCountInfo(const HGChar* devName, const HGChar* devSN, const HGChar* devType, const HGChar* devFW, HGUInt rollerCount);
|
|
||||||
HGResult PostUserOpenInfo(const HGChar* appName, const HGChar* oemName);
|
|
||||||
HGResult PostUserCloseInfo(const HGChar* appName, const HGChar* oemName);
|
|
||||||
HGResult PostUserLoginInfo(const HGChar* appName, const HGChar* oemName);
|
|
||||||
HGResult PostUserLogoutInfo(const HGChar* appName, const HGChar* oemName);
|
|
||||||
HGResult PostDevicePaperJamInfo(const HGChar* devName, const HGChar* devSN, const HGChar* devType, const HGChar* devFW);
|
|
||||||
HGResult HGAPI PostDeviceLockInfo(const HGChar* devName, const HGChar* devSN, const HGChar* devType, const HGChar* devFW, HGBool isLock);
|
|
||||||
|
|
||||||
private:
|
|
||||||
typedef HGResult (HGAPI *HGVersion_CreateMgr)(HGVersionMgr *mgr);
|
|
||||||
typedef HGResult (HGAPI *HGVersion_DestroyMgr)(HGVersionMgr mgr);
|
|
||||||
typedef HGResult (HGAPI *HGVersion_GetServerConfig)(HGVersionMgr mgr, HGServerConfig *config);
|
|
||||||
typedef HGResult (HGAPI *HGVersion_GetVersionList)(HGVersionMgr mgr, const HGChar* appName, const HGChar* oemName, HGVersionInfo **info, HGUInt *count);
|
|
||||||
typedef HGResult (HGAPI *HGVersion_GetDriverVersionList)(HGVersionMgr mgr, const HGChar* devType, HGVersionInfo** info, HGUInt* count);
|
|
||||||
typedef HGResult (HGAPI *HGVersion_BlackListCheck)(HGVersionMgr mgr, const HGChar* devSN, HGBool* inList);
|
|
||||||
typedef HGResult (HGAPI *HGVersion_PostCrashInfo)(HGVersionMgr mgr, const HGChar* appName, const HGChar* oemName, const HGChar* desc, const HGChar* crashFilePath, const HGChar* exceptionAddr);
|
|
||||||
typedef HGResult (HGAPI *HGVersion_PostUserFeedback)(HGVersionMgr mgr, const HGChar* appName, const HGChar* oemName, const HGChar* desc, const HGChar* feedback, const HGChar* contact);
|
|
||||||
typedef HGResult (HGAPI *HGVersion_HttpDownload)(HGVersionMgr mgr, const HGChar *url, const HGChar *saveFilePath, HGHttpDownloadFunc func, HGPointer param);
|
|
||||||
typedef HGResult (HGAPI *HGVersion_ReleaseVersionList)(HGVersionInfo* info, HGUInt count);
|
|
||||||
typedef HGResult (HGAPI *HGVersion_GetCurrVersion)(const HGChar* appName, const HGChar* oemName, HGChar* version, HGUInt maxLen);
|
|
||||||
typedef HGResult (HGAPI *HGVersion_CompareVersion)(const HGChar* version1, const HGChar* version2, HGInt* result);
|
|
||||||
|
|
||||||
typedef HGResult (HGAPI *HGVersion_PostDeviceOpenInfo)(HGVersionMgr mgr, const HGChar* devName, const HGChar* devSN, const HGChar* devType, const HGChar* devFW);
|
|
||||||
typedef HGResult (HGAPI *HGVersion_PostDeviceCloseInfo)(HGVersionMgr mgr, const HGChar* devName, const HGChar* devSN, const HGChar* devType, const HGChar* devFW);
|
|
||||||
typedef HGResult (HGAPI *HGVersion_PostDeviceScanCountInfo)(HGVersionMgr mgr, const HGChar* devName, const HGChar* devSN, const HGChar* devType, const HGChar* devFW, HGUInt scanCount);
|
|
||||||
typedef HGResult (HGAPI *HGVersion_PostDeviceClearRollerInfo)(HGVersionMgr mgr, const HGChar* devName, const HGChar* devSN, const HGChar* devType, const HGChar* devFW);
|
|
||||||
typedef HGResult (HGAPI *HGVersion_PostDeviceHistroyCountInfo)(HGVersionMgr mgr, const HGChar* devName, const HGChar* devSN, const HGChar* devType, const HGChar* devFW, HGUInt histroyCount);
|
|
||||||
typedef HGResult (HGAPI *HGVersion_PostDeviceRollerCountInfo)(HGVersionMgr mgr, const HGChar* devName, const HGChar* devSN, const HGChar* devType, const HGChar* devFW, HGUInt rollerCount);
|
|
||||||
typedef HGResult (HGAPI *HGVersion_PostUserOpenInfo)(HGVersionMgr mgr, const HGChar* appName, const HGChar* oemName);
|
|
||||||
typedef HGResult (HGAPI *HGVersion_PostUserCloseInfo)(HGVersionMgr mgr, const HGChar* appName, const HGChar* oemName);
|
|
||||||
typedef HGResult (HGAPI *HGVersion_PostUserLoginInfo)(HGVersionMgr mgr, const HGChar* appName, const HGChar* oemName);
|
|
||||||
typedef HGResult (HGAPI *HGVersion_PostUserLogoutInfo)(HGVersionMgr mgr, const HGChar* appName, const HGChar* oemName);
|
|
||||||
typedef HGResult (HGAPI *HGVersion_PostDevicePaperJamInfo)(HGVersionMgr mgr, const HGChar* devName, const HGChar* devSN, const HGChar* devType, const HGChar* devFW);
|
|
||||||
typedef HGResult (HGAPI *HGVersion_PostDeviceLockInfo)(HGVersionMgr mgr, const HGChar* devName, const HGChar* devSN,
|
|
||||||
const HGChar* devType, const HGChar* devFW, HGBool isLock);
|
|
||||||
|
|
||||||
private:
|
|
||||||
HGDll m_dll;
|
|
||||||
HGVersion_CreateMgr m_funcCreateMgr;
|
|
||||||
HGVersion_DestroyMgr m_funcDestroyMgr;
|
|
||||||
HGVersion_GetServerConfig m_funcGetServerConfig;
|
|
||||||
HGVersion_GetVersionList m_funcGetVersionList;
|
|
||||||
HGVersion_GetDriverVersionList m_funcGetDriverVersionList;
|
|
||||||
HGVersion_BlackListCheck m_funcBlackListCheck;
|
|
||||||
HGVersion_PostCrashInfo m_funcPostCrashInfo;
|
|
||||||
HGVersion_PostUserFeedback m_funcPostUserFeedback;
|
|
||||||
HGVersion_HttpDownload m_funcHttpDownload;
|
|
||||||
HGVersion_ReleaseVersionList m_funcReleaseVersionList;
|
|
||||||
HGVersion_GetCurrVersion m_funcGetCurrVersion;
|
|
||||||
HGVersion_CompareVersion m_funcCompareVersion;
|
|
||||||
|
|
||||||
HGVersion_PostDeviceOpenInfo m_funcPostDeviceOpenInfo;
|
|
||||||
HGVersion_PostDeviceCloseInfo m_funcPostDeviceCloseInfo;
|
|
||||||
HGVersion_PostDeviceScanCountInfo m_funcPostDeviceScanCountInfo;
|
|
||||||
HGVersion_PostDeviceClearRollerInfo m_funcPostDeviceClearRollerInfo;
|
|
||||||
HGVersion_PostDeviceHistroyCountInfo m_funcPostDeviceHistroyCountInfo;
|
|
||||||
HGVersion_PostDeviceRollerCountInfo m_funcPostDeviceRollerCountInfo;
|
|
||||||
HGVersion_PostUserOpenInfo m_funcPostUserOpenInfo;
|
|
||||||
HGVersion_PostUserCloseInfo m_funcPostUserCloseInfo;
|
|
||||||
HGVersion_PostUserLoginInfo m_funcPostUserLoginInfo;
|
|
||||||
HGVersion_PostUserLogoutInfo m_funcPostUserLogoutInfo;
|
|
||||||
HGVersion_PostDevicePaperJamInfo m_funcPostDevicePaperJamInfo;
|
|
||||||
HGVersion_PostDeviceLockInfo m_funcPostDeviceLockInfo;
|
|
||||||
HGVersionMgr m_mgr;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* VERSIONDLL_H */
|
|
|
@ -1,70 +0,0 @@
|
||||||
#include "app_cfg.h"
|
|
||||||
#include "base/HGDef.h"
|
|
||||||
#include "base/HGInc.h"
|
|
||||||
#include "base/HGUtility.h"
|
|
||||||
#include "base/HGIni.h"
|
|
||||||
#include "HGUIGlobal.h"
|
|
||||||
#include "HGString.h"
|
|
||||||
|
|
||||||
QString getCfgValue(const char *appName, const char *key, const QString &def)
|
|
||||||
{
|
|
||||||
HGChar cfgPath[512];
|
|
||||||
HGBase_GetConfigPath(cfgPath, 512);
|
|
||||||
strcat(cfgPath, "config.ini");
|
|
||||||
|
|
||||||
HGChar value[512] = {0};
|
|
||||||
HGBase_GetProfileString(cfgPath, appName, key, getStdString(def).c_str(), value, 512);
|
|
||||||
return StdStringToUtf8(value).c_str();
|
|
||||||
}
|
|
||||||
|
|
||||||
int getCfgValue(const char *appName, const char *key, int def)
|
|
||||||
{
|
|
||||||
HGChar cfgPath[512];
|
|
||||||
HGBase_GetConfigPath(cfgPath, 512);
|
|
||||||
strcat(cfgPath, "config.ini");
|
|
||||||
|
|
||||||
HGInt value = 0;
|
|
||||||
HGBase_GetProfileInt(cfgPath, appName, key, def, &value);
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool getCfgValue(const char *appName, const char *key, bool def)
|
|
||||||
{
|
|
||||||
HGChar cfgPath[512];
|
|
||||||
HGBase_GetConfigPath(cfgPath, 512);
|
|
||||||
strcat(cfgPath, "config.ini");
|
|
||||||
|
|
||||||
HGInt value = 0;
|
|
||||||
HGBase_GetProfileInt(cfgPath, appName, key, (HGInt)def, &value);
|
|
||||||
return (bool)value;
|
|
||||||
}
|
|
||||||
|
|
||||||
void saveCfgValue(const char *appName, const char *key, const QString &value)
|
|
||||||
{
|
|
||||||
HGChar cfgPath[512];
|
|
||||||
HGBase_GetConfigPath(cfgPath, 512);
|
|
||||||
HGBase_CreateDir(cfgPath);
|
|
||||||
strcat(cfgPath, "config.ini");
|
|
||||||
|
|
||||||
HGBase_SetProfileString(cfgPath, appName, key, getStdString(value).c_str());
|
|
||||||
}
|
|
||||||
|
|
||||||
void saveCfgValue(const char *appName, const char *key, int value)
|
|
||||||
{
|
|
||||||
HGChar cfgPath[512];
|
|
||||||
HGBase_GetConfigPath(cfgPath, 512);
|
|
||||||
HGBase_CreateDir(cfgPath);
|
|
||||||
strcat(cfgPath, "config.ini");
|
|
||||||
|
|
||||||
HGBase_SetProfileInt(cfgPath, appName, key, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
void saveCfgValue(const char *appName, const char *key, bool value)
|
|
||||||
{
|
|
||||||
HGChar cfgPath[512];
|
|
||||||
HGBase_GetConfigPath(cfgPath, 512);
|
|
||||||
HGBase_CreateDir(cfgPath);
|
|
||||||
strcat(cfgPath, "config.ini");
|
|
||||||
|
|
||||||
HGBase_SetProfileInt(cfgPath, appName, key, (HGInt)value);
|
|
||||||
}
|
|
|
@ -1,14 +0,0 @@
|
||||||
#ifndef __APP_CFG_H__
|
|
||||||
#define __APP_CFG_H__
|
|
||||||
|
|
||||||
#include <QString>
|
|
||||||
|
|
||||||
QString getCfgValue(const char *appName, const char *key, const QString &def);
|
|
||||||
int getCfgValue(const char *appName, const char *key, int def);
|
|
||||||
bool getCfgValue(const char *appName, const char *key, bool def);
|
|
||||||
|
|
||||||
void saveCfgValue(const char *appName, const char *key, const QString &value);
|
|
||||||
void saveCfgValue(const char *appName, const char *key, int value);
|
|
||||||
void saveCfgValue(const char *appName, const char *key, bool value);
|
|
||||||
|
|
||||||
#endif /* __APP_CFG_H__ */
|
|
|
@ -1,756 +0,0 @@
|
||||||
/*
|
|
||||||
Copyright (c) 2009 Dave Gamble
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
|
||||||
in the Software without restriction, including without limitation the rights
|
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
|
||||||
furnished to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in
|
|
||||||
all copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
||||||
THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* cJSON */
|
|
||||||
/* JSON parser in C. */
|
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <math.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <float.h>
|
|
||||||
#include <limits.h>
|
|
||||||
#include <ctype.h>
|
|
||||||
#include "cJSON.h"
|
|
||||||
|
|
||||||
static const char *ep;
|
|
||||||
|
|
||||||
const char *cJSON_GetErrorPtr(void) {return ep;}
|
|
||||||
|
|
||||||
static int cJSON_strcasecmp(const char *s1,const char *s2)
|
|
||||||
{
|
|
||||||
if (!s1) return (s1==s2)?0:1;if (!s2) return 1;
|
|
||||||
for(; tolower(*s1) == tolower(*s2); ++s1, ++s2) if(*s1 == 0) return 0;
|
|
||||||
return tolower(*(const unsigned char *)s1) - tolower(*(const unsigned char *)s2);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void* ask_memory(size_t bytes)
|
|
||||||
{
|
|
||||||
// printf("allocate %u bytes memory in cJSON\n", bytes);
|
|
||||||
|
|
||||||
return malloc(bytes);
|
|
||||||
}
|
|
||||||
static void *(*cJSON_malloc)(size_t sz) = ask_memory;
|
|
||||||
static void (*cJSON_free)(void *ptr) = free;
|
|
||||||
|
|
||||||
static char* cJSON_strdup(const char* str)
|
|
||||||
{
|
|
||||||
size_t len;
|
|
||||||
char* copy;
|
|
||||||
|
|
||||||
len = strlen(str) + 1;
|
|
||||||
if (!(copy = (char*)cJSON_malloc(len))) return 0;
|
|
||||||
memcpy(copy,str,len);
|
|
||||||
return copy;
|
|
||||||
}
|
|
||||||
|
|
||||||
void cJSON_InitHooks(cJSON_Hooks* hooks)
|
|
||||||
{
|
|
||||||
if (!hooks) { /* Reset hooks */
|
|
||||||
cJSON_malloc = ask_memory;
|
|
||||||
cJSON_free = free;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
cJSON_malloc = (hooks->malloc_fn)?hooks->malloc_fn:ask_memory;
|
|
||||||
cJSON_free = (hooks->free_fn)?hooks->free_fn:free;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Internal constructor. */
|
|
||||||
static cJSON *cJSON_New_Item(void)
|
|
||||||
{
|
|
||||||
cJSON* node = (cJSON*)cJSON_malloc(sizeof(cJSON));
|
|
||||||
if (node) memset(node,0,sizeof(cJSON));
|
|
||||||
return node;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Delete a cJSON structure. */
|
|
||||||
void cJSON_Delete(cJSON *c)
|
|
||||||
{
|
|
||||||
cJSON *next;
|
|
||||||
while (c)
|
|
||||||
{
|
|
||||||
next=c->next;
|
|
||||||
if (!(c->type&cJSON_IsReference) && c->child) cJSON_Delete(c->child);
|
|
||||||
if (!(c->type&cJSON_IsReference) && c->valuestring) cJSON_free(c->valuestring);
|
|
||||||
if (!(c->type&cJSON_StringIsConst) && c->string) cJSON_free(c->string);
|
|
||||||
cJSON_free(c);
|
|
||||||
c=next;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Parse the input text to generate a number, and populate the result into item. */
|
|
||||||
static const char *parse_number(cJSON *item,const char *num)
|
|
||||||
{
|
|
||||||
double n=0,sign=1,scale=0;int subscale=0,signsubscale=1;
|
|
||||||
|
|
||||||
if (*num=='-') sign=-1,num++; /* Has sign? */
|
|
||||||
if (*num=='0') num++; /* is zero */
|
|
||||||
if (*num>='1' && *num<='9') do n=(n*10.0)+(*num++ -'0'); while (*num>='0' && *num<='9'); /* Number? */
|
|
||||||
if (*num=='.' && num[1]>='0' && num[1]<='9') {num++; do n=(n*10.0)+(*num++ -'0'),scale--; while (*num>='0' && *num<='9');} /* Fractional part? */
|
|
||||||
if (*num=='e' || *num=='E') /* Exponent? */
|
|
||||||
{ num++;if (*num=='+') num++; else if (*num=='-') signsubscale=-1,num++; /* With sign? */
|
|
||||||
while (*num>='0' && *num<='9') subscale=(subscale*10)+(*num++ - '0'); /* Number? */
|
|
||||||
}
|
|
||||||
|
|
||||||
n=sign*n*pow(10.0,(scale+subscale*signsubscale)); /* number = +/- number.fraction * 10^+/- exponent */
|
|
||||||
|
|
||||||
item->valuedouble=n;
|
|
||||||
item->valueint=(int)n;
|
|
||||||
item->type=cJSON_Number;
|
|
||||||
return num;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int pow2gt (int x) { --x; x|=x>>1; x|=x>>2; x|=x>>4; x|=x>>8; x|=x>>16; return x+1; }
|
|
||||||
|
|
||||||
typedef struct {char *buffer; int length; int offset; } printbuffer;
|
|
||||||
|
|
||||||
static char* ensure(printbuffer *p,int needed)
|
|
||||||
{
|
|
||||||
char *newbuffer;int newsize;
|
|
||||||
if (!p || !p->buffer) return 0;
|
|
||||||
needed+=p->offset;
|
|
||||||
if (needed<=p->length) return p->buffer+p->offset;
|
|
||||||
|
|
||||||
newsize=pow2gt(needed);
|
|
||||||
newbuffer=(char*)cJSON_malloc(newsize);
|
|
||||||
if (!newbuffer) {cJSON_free(p->buffer);p->length=0,p->buffer=0;return 0;}
|
|
||||||
if (newbuffer) memcpy(newbuffer,p->buffer,p->length);
|
|
||||||
cJSON_free(p->buffer);
|
|
||||||
p->length=newsize;
|
|
||||||
p->buffer=newbuffer;
|
|
||||||
return newbuffer+p->offset;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int update(printbuffer *p)
|
|
||||||
{
|
|
||||||
char *str;
|
|
||||||
if (!p || !p->buffer) return 0;
|
|
||||||
str=p->buffer+p->offset;
|
|
||||||
return p->offset+strlen(str);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Render the number nicely from the given item into a string. */
|
|
||||||
static char *print_number(cJSON *item,printbuffer *p)
|
|
||||||
{
|
|
||||||
char *str=0;
|
|
||||||
double d=item->valuedouble;
|
|
||||||
if (d==0)
|
|
||||||
{
|
|
||||||
if (p) str=ensure(p,2);
|
|
||||||
else str=(char*)cJSON_malloc(2); /* special case for 0. */
|
|
||||||
if (str) strcpy(str,"0");
|
|
||||||
}
|
|
||||||
else if (fabs(((double)item->valueint)-d)<=DBL_EPSILON && d<=INT_MAX && d>=INT_MIN)
|
|
||||||
{
|
|
||||||
if (p) str=ensure(p,21);
|
|
||||||
else str=(char*)cJSON_malloc(21); /* 2^64+1 can be represented in 21 chars. */
|
|
||||||
if (str) sprintf(str,"%d",item->valueint);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (p) str=ensure(p,64);
|
|
||||||
else str=(char*)cJSON_malloc(64); /* This is a nice tradeoff. */
|
|
||||||
if (str)
|
|
||||||
{
|
|
||||||
if (fabs(floor(d)-d)<=DBL_EPSILON && fabs(d)<1.0e60)sprintf(str,"%.0f",d);
|
|
||||||
else if (fabs(d)<1.0e-6 || fabs(d)>1.0e9) sprintf(str,"%e",d);
|
|
||||||
else sprintf(str,"%f",d);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return str;
|
|
||||||
}
|
|
||||||
|
|
||||||
static unsigned parse_hex4(const char *str)
|
|
||||||
{
|
|
||||||
unsigned h=0;
|
|
||||||
if (*str>='0' && *str<='9') h+=(*str)-'0'; else if (*str>='A' && *str<='F') h+=10+(*str)-'A'; else if (*str>='a' && *str<='f') h+=10+(*str)-'a'; else return 0;
|
|
||||||
h=h<<4;str++;
|
|
||||||
if (*str>='0' && *str<='9') h+=(*str)-'0'; else if (*str>='A' && *str<='F') h+=10+(*str)-'A'; else if (*str>='a' && *str<='f') h+=10+(*str)-'a'; else return 0;
|
|
||||||
h=h<<4;str++;
|
|
||||||
if (*str>='0' && *str<='9') h+=(*str)-'0'; else if (*str>='A' && *str<='F') h+=10+(*str)-'A'; else if (*str>='a' && *str<='f') h+=10+(*str)-'a'; else return 0;
|
|
||||||
h=h<<4;str++;
|
|
||||||
if (*str>='0' && *str<='9') h+=(*str)-'0'; else if (*str>='A' && *str<='F') h+=10+(*str)-'A'; else if (*str>='a' && *str<='f') h+=10+(*str)-'a'; else return 0;
|
|
||||||
return h;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Parse the input text into an unescaped cstring, and populate item. */
|
|
||||||
static const unsigned char firstByteMark[7] = { 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC };
|
|
||||||
static const char *parse_string(cJSON *item,const char *str)
|
|
||||||
{
|
|
||||||
const char *ptr=str+1;char *ptr2;char *out;int len=0;unsigned uc,uc2;
|
|
||||||
if (*str!='\"') {ep=str;return 0;} /* not a string! */
|
|
||||||
|
|
||||||
while (*ptr!='\"' && *ptr && ++len) if (*ptr++ == '\\') ptr++; /* Skip escaped quotes. */
|
|
||||||
|
|
||||||
out=(char*)cJSON_malloc(len+1); /* This is how long we need for the string, roughly. */
|
|
||||||
if (!out) return 0;
|
|
||||||
|
|
||||||
ptr=str+1;ptr2=out;
|
|
||||||
while (*ptr!='\"' && *ptr)
|
|
||||||
{
|
|
||||||
if (*ptr!='\\') *ptr2++=*ptr++;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ptr++;
|
|
||||||
switch (*ptr)
|
|
||||||
{
|
|
||||||
case 'b': *ptr2++='\b'; break;
|
|
||||||
case 'f': *ptr2++='\f'; break;
|
|
||||||
case 'n': *ptr2++='\n'; break;
|
|
||||||
case 'r': *ptr2++='\r'; break;
|
|
||||||
case 't': *ptr2++='\t'; break;
|
|
||||||
case 'u': /* transcode utf16 to utf8. */
|
|
||||||
uc=parse_hex4(ptr+1);ptr+=4; /* get the unicode char. */
|
|
||||||
|
|
||||||
if ((uc>=0xDC00 && uc<=0xDFFF) || uc==0) break; /* check for invalid. */
|
|
||||||
|
|
||||||
if (uc>=0xD800 && uc<=0xDBFF) /* UTF16 surrogate pairs. */
|
|
||||||
{
|
|
||||||
if (ptr[1]!='\\' || ptr[2]!='u') break; /* missing second-half of surrogate. */
|
|
||||||
uc2=parse_hex4(ptr+3);ptr+=6;
|
|
||||||
if (uc2<0xDC00 || uc2>0xDFFF) break; /* invalid second-half of surrogate. */
|
|
||||||
uc=0x10000 + (((uc&0x3FF)<<10) | (uc2&0x3FF));
|
|
||||||
}
|
|
||||||
|
|
||||||
len=4;if (uc<0x80) len=1;else if (uc<0x800) len=2;else if (uc<0x10000) len=3; ptr2+=len;
|
|
||||||
|
|
||||||
switch (len) {
|
|
||||||
case 4: *--ptr2 =((uc | 0x80) & 0xBF); uc >>= 6;
|
|
||||||
case 3: *--ptr2 =((uc | 0x80) & 0xBF); uc >>= 6;
|
|
||||||
case 2: *--ptr2 =((uc | 0x80) & 0xBF); uc >>= 6;
|
|
||||||
case 1: *--ptr2 =(uc | firstByteMark[len]);
|
|
||||||
}
|
|
||||||
ptr2+=len;
|
|
||||||
break;
|
|
||||||
default: *ptr2++=*ptr; break;
|
|
||||||
}
|
|
||||||
ptr++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*ptr2=0;
|
|
||||||
if (*ptr=='\"') ptr++;
|
|
||||||
item->valuestring=out;
|
|
||||||
item->type=cJSON_String;
|
|
||||||
return ptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Render the cstring provided to an escaped version that can be printed. */
|
|
||||||
static char *print_string_ptr(const char *str,printbuffer *p)
|
|
||||||
{
|
|
||||||
const char *ptr;char *ptr2,*out;int len=0,flag=0;unsigned char token;
|
|
||||||
|
|
||||||
for (ptr=str;*ptr;ptr++) flag|=((*ptr>0 && *ptr<32)||(*ptr=='\"')||(*ptr=='\\'))?1:0;
|
|
||||||
if (!flag)
|
|
||||||
{
|
|
||||||
len=ptr-str;
|
|
||||||
if (p) out=ensure(p,len+3);
|
|
||||||
else out=(char*)cJSON_malloc(len+3);
|
|
||||||
if (!out) return 0;
|
|
||||||
ptr2=out;*ptr2++='\"';
|
|
||||||
strcpy(ptr2,str);
|
|
||||||
ptr2[len]='\"';
|
|
||||||
ptr2[len+1]=0;
|
|
||||||
return out;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!str)
|
|
||||||
{
|
|
||||||
if (p) out=ensure(p,3);
|
|
||||||
else out=(char*)cJSON_malloc(3);
|
|
||||||
if (!out) return 0;
|
|
||||||
strcpy(out,"\"\"");
|
|
||||||
return out;
|
|
||||||
}
|
|
||||||
ptr=str;while ((token=*ptr) && ++len) {if (strchr("\"\\\b\f\n\r\t",token)) len++; else if (token<32) len+=5;ptr++;}
|
|
||||||
|
|
||||||
if (p) out=ensure(p,len+3);
|
|
||||||
else out=(char*)cJSON_malloc(len+3);
|
|
||||||
if (!out) return 0;
|
|
||||||
|
|
||||||
ptr2=out;ptr=str;
|
|
||||||
*ptr2++='\"';
|
|
||||||
while (*ptr)
|
|
||||||
{
|
|
||||||
if ((unsigned char)*ptr>31 && *ptr!='\"' && *ptr!='\\') *ptr2++=*ptr++;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
*ptr2++='\\';
|
|
||||||
switch (token=*ptr++)
|
|
||||||
{
|
|
||||||
case '\\': *ptr2++='\\'; break;
|
|
||||||
case '\"': *ptr2++='\"'; break;
|
|
||||||
case '\b': *ptr2++='b'; break;
|
|
||||||
case '\f': *ptr2++='f'; break;
|
|
||||||
case '\n': *ptr2++='n'; break;
|
|
||||||
case '\r': *ptr2++='r'; break;
|
|
||||||
case '\t': *ptr2++='t'; break;
|
|
||||||
default: sprintf(ptr2,"u%04x",token);ptr2+=5; break; /* escape and print */
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*ptr2++='\"';*ptr2++=0;
|
|
||||||
return out;
|
|
||||||
}
|
|
||||||
/* Invote print_string_ptr (which is useful) on an item. */
|
|
||||||
static char *print_string(cJSON *item,printbuffer *p) {return print_string_ptr(item->valuestring,p);}
|
|
||||||
|
|
||||||
/* Predeclare these prototypes. */
|
|
||||||
static const char *parse_value(cJSON *item,const char *value);
|
|
||||||
static char *print_value(cJSON *item,int depth,int fmt,printbuffer *p);
|
|
||||||
static const char *parse_array(cJSON *item,const char *value);
|
|
||||||
static char *print_array(cJSON *item,int depth,int fmt,printbuffer *p);
|
|
||||||
static const char *parse_object(cJSON *item,const char *value);
|
|
||||||
static char *print_object(cJSON *item,int depth,int fmt,printbuffer *p);
|
|
||||||
|
|
||||||
/* Utility to jump whitespace and cr/lf */
|
|
||||||
static const char *skip(const char *in) {while (in && *in && (unsigned char)*in<=32) in++; return in;}
|
|
||||||
|
|
||||||
/* Parse an object - create a new root, and populate. */
|
|
||||||
cJSON *cJSON_ParseWithOpts(const char *value,const char **return_parse_end,int require_null_terminated)
|
|
||||||
{
|
|
||||||
const char *end=0;
|
|
||||||
cJSON *c=cJSON_New_Item();
|
|
||||||
ep=0;
|
|
||||||
if (!c) return 0; /* memory fail */
|
|
||||||
|
|
||||||
end=parse_value(c,skip(value));
|
|
||||||
if (!end) {cJSON_Delete(c);return 0;} /* parse failure. ep is set. */
|
|
||||||
|
|
||||||
/* if we require null-terminated JSON without appended garbage, skip and then check for a null terminator */
|
|
||||||
if (require_null_terminated) {end=skip(end);if (*end) {cJSON_Delete(c);ep=end;return 0;}}
|
|
||||||
if (return_parse_end) *return_parse_end=end;
|
|
||||||
return c;
|
|
||||||
}
|
|
||||||
/* Default options for cJSON_Parse */
|
|
||||||
cJSON *cJSON_Parse(const char *value) {return cJSON_ParseWithOpts(value,0,0);}
|
|
||||||
|
|
||||||
/* Render a cJSON item/entity/structure to text. */
|
|
||||||
char *cJSON_Print(cJSON *item) {return print_value(item,0,1,0);}
|
|
||||||
char *cJSON_PrintUnformatted(cJSON *item) {return print_value(item,0,0,0);}
|
|
||||||
|
|
||||||
char *cJSON_PrintBuffered(cJSON *item,int prebuffer,int fmt)
|
|
||||||
{
|
|
||||||
printbuffer p;
|
|
||||||
p.buffer=(char*)cJSON_malloc(prebuffer);
|
|
||||||
p.length=prebuffer;
|
|
||||||
p.offset=0;
|
|
||||||
return print_value(item,0,fmt,&p);
|
|
||||||
return p.buffer;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* Parser core - when encountering text, process appropriately. */
|
|
||||||
static const char *parse_value(cJSON *item,const char *value)
|
|
||||||
{
|
|
||||||
if (!value) return 0; /* Fail on null. */
|
|
||||||
if (!strncmp(value,"null",4)) { item->type=cJSON_NULL; return value+4; }
|
|
||||||
if (!strncmp(value,"false",5)) { item->type=cJSON_False; return value+5; }
|
|
||||||
if (!strncmp(value,"true",4)) { item->type=cJSON_True; item->valueint=1; return value+4; }
|
|
||||||
if (*value=='\"') { return parse_string(item,value); }
|
|
||||||
if (*value=='-' || (*value>='0' && *value<='9')) { return parse_number(item,value); }
|
|
||||||
if (*value=='[') { return parse_array(item,value); }
|
|
||||||
if (*value=='{') { return parse_object(item,value); }
|
|
||||||
|
|
||||||
ep=value;return 0; /* failure. */
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Render a value to text. */
|
|
||||||
static char *print_value(cJSON *item,int depth,int fmt,printbuffer *p)
|
|
||||||
{
|
|
||||||
char *out=0;
|
|
||||||
if (!item) return 0;
|
|
||||||
if (p)
|
|
||||||
{
|
|
||||||
switch ((item->type)&255)
|
|
||||||
{
|
|
||||||
case cJSON_NULL: {out=ensure(p,5); if (out) strcpy(out,"null"); break;}
|
|
||||||
case cJSON_False: {out=ensure(p,6); if (out) strcpy(out,"false"); break;}
|
|
||||||
case cJSON_True: {out=ensure(p,5); if (out) strcpy(out,"true"); break;}
|
|
||||||
case cJSON_Number: out=print_number(item,p);break;
|
|
||||||
case cJSON_String: out=print_string(item,p);break;
|
|
||||||
case cJSON_Array: out=print_array(item,depth,fmt,p);break;
|
|
||||||
case cJSON_Object: out=print_object(item,depth,fmt,p);break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
switch ((item->type)&255)
|
|
||||||
{
|
|
||||||
case cJSON_NULL: out=cJSON_strdup("null"); break;
|
|
||||||
case cJSON_False: out=cJSON_strdup("false");break;
|
|
||||||
case cJSON_True: out=cJSON_strdup("true"); break;
|
|
||||||
case cJSON_Number: out=print_number(item,0);break;
|
|
||||||
case cJSON_String: out=print_string(item,0);break;
|
|
||||||
case cJSON_Array: out=print_array(item,depth,fmt,0);break;
|
|
||||||
case cJSON_Object: out=print_object(item,depth,fmt,0);break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return out;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Build an array from input text. */
|
|
||||||
static const char *parse_array(cJSON *item,const char *value)
|
|
||||||
{
|
|
||||||
cJSON *child;
|
|
||||||
if (*value!='[') {ep=value;return 0;} /* not an array! */
|
|
||||||
|
|
||||||
item->type=cJSON_Array;
|
|
||||||
value=skip(value+1);
|
|
||||||
if (*value==']') return value+1; /* empty array. */
|
|
||||||
|
|
||||||
item->child=child=cJSON_New_Item();
|
|
||||||
if (!item->child) return 0; /* memory fail */
|
|
||||||
value=skip(parse_value(child,skip(value))); /* skip any spacing, get the value. */
|
|
||||||
if (!value) return 0;
|
|
||||||
|
|
||||||
while (*value==',')
|
|
||||||
{
|
|
||||||
cJSON *new_item;
|
|
||||||
if (!(new_item=cJSON_New_Item())) return 0; /* memory fail */
|
|
||||||
child->next=new_item;new_item->prev=child;child=new_item;
|
|
||||||
value=skip(parse_value(child,skip(value+1)));
|
|
||||||
if (!value) return 0; /* memory fail */
|
|
||||||
}
|
|
||||||
|
|
||||||
if (*value==']') return value+1; /* end of array */
|
|
||||||
ep=value;return 0; /* malformed. */
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Render an array to text */
|
|
||||||
static char *print_array(cJSON *item,int depth,int fmt,printbuffer *p)
|
|
||||||
{
|
|
||||||
char **entries;
|
|
||||||
char *out=0,*ptr,*ret;int len=5;
|
|
||||||
cJSON *child=item->child;
|
|
||||||
int numentries=0,i=0,fail=0;
|
|
||||||
size_t tmplen=0;
|
|
||||||
|
|
||||||
/* How many entries in the array? */
|
|
||||||
while (child) numentries++,child=child->next;
|
|
||||||
/* Explicitly handle numentries==0 */
|
|
||||||
if (!numentries)
|
|
||||||
{
|
|
||||||
if (p) out=ensure(p,3);
|
|
||||||
else out=(char*)cJSON_malloc(3);
|
|
||||||
if (out) strcpy(out,"[]");
|
|
||||||
return out;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (p)
|
|
||||||
{
|
|
||||||
/* Compose the output array. */
|
|
||||||
i=p->offset;
|
|
||||||
ptr=ensure(p,1);if (!ptr) return 0; *ptr='['; p->offset++;
|
|
||||||
child=item->child;
|
|
||||||
while (child && !fail)
|
|
||||||
{
|
|
||||||
print_value(child,depth+1,fmt,p);
|
|
||||||
p->offset=update(p);
|
|
||||||
if (child->next) {len=fmt?2:1;ptr=ensure(p,len+1);if (!ptr) return 0;*ptr++=',';if(fmt)*ptr++=' ';*ptr=0;p->offset+=len;}
|
|
||||||
child=child->next;
|
|
||||||
}
|
|
||||||
ptr=ensure(p,2);if (!ptr) return 0; *ptr++=']';*ptr=0;
|
|
||||||
out=(p->buffer)+i;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* Allocate an array to hold the values for each */
|
|
||||||
entries=(char**)cJSON_malloc(numentries*sizeof(char*));
|
|
||||||
if (!entries) return 0;
|
|
||||||
memset(entries,0,numentries*sizeof(char*));
|
|
||||||
/* Retrieve all the results: */
|
|
||||||
child=item->child;
|
|
||||||
while (child && !fail)
|
|
||||||
{
|
|
||||||
ret=print_value(child,depth+1,fmt,0);
|
|
||||||
entries[i++]=ret;
|
|
||||||
if (ret) len+=strlen(ret)+2+(fmt?1:0); else fail=1;
|
|
||||||
child=child->next;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* If we didn't fail, try to ask_memory the output string */
|
|
||||||
if (!fail) out=(char*)cJSON_malloc(len);
|
|
||||||
/* If that fails, we fail. */
|
|
||||||
if (!out) fail=1;
|
|
||||||
|
|
||||||
/* Handle failure. */
|
|
||||||
if (fail)
|
|
||||||
{
|
|
||||||
for (i=0;i<numentries;i++) if (entries[i]) cJSON_free(entries[i]);
|
|
||||||
cJSON_free(entries);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Compose the output array. */
|
|
||||||
*out='[';
|
|
||||||
ptr=out+1;*ptr=0;
|
|
||||||
for (i=0;i<numentries;i++)
|
|
||||||
{
|
|
||||||
tmplen=strlen(entries[i]);memcpy(ptr,entries[i],tmplen);ptr+=tmplen;
|
|
||||||
if (i!=numentries-1) {*ptr++=',';if(fmt)*ptr++=' ';*ptr=0;}
|
|
||||||
cJSON_free(entries[i]);
|
|
||||||
}
|
|
||||||
cJSON_free(entries);
|
|
||||||
*ptr++=']';*ptr++=0;
|
|
||||||
}
|
|
||||||
return out;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Build an object from the text. */
|
|
||||||
static const char *parse_object(cJSON *item,const char *value)
|
|
||||||
{
|
|
||||||
cJSON *child;
|
|
||||||
if (*value!='{') {ep=value;return 0;} /* not an object! */
|
|
||||||
|
|
||||||
item->type=cJSON_Object;
|
|
||||||
value=skip(value+1);
|
|
||||||
if (*value=='}') return value+1; /* empty array. */
|
|
||||||
|
|
||||||
item->child=child=cJSON_New_Item();
|
|
||||||
if (!item->child) return 0;
|
|
||||||
value=skip(parse_string(child,skip(value)));
|
|
||||||
if (!value) return 0;
|
|
||||||
child->string=child->valuestring;child->valuestring=0;
|
|
||||||
if (*value!=':') {ep=value;return 0;} /* fail! */
|
|
||||||
value=skip(parse_value(child,skip(value+1))); /* skip any spacing, get the value. */
|
|
||||||
if (!value) return 0;
|
|
||||||
|
|
||||||
while (*value==',')
|
|
||||||
{
|
|
||||||
cJSON *new_item;
|
|
||||||
if (!(new_item=cJSON_New_Item())) return 0; /* memory fail */
|
|
||||||
child->next=new_item;new_item->prev=child;child=new_item;
|
|
||||||
value=skip(parse_string(child,skip(value+1)));
|
|
||||||
if (!value) return 0;
|
|
||||||
child->string=child->valuestring;child->valuestring=0;
|
|
||||||
if (*value!=':') {ep=value;return 0;} /* fail! */
|
|
||||||
value=skip(parse_value(child,skip(value+1))); /* skip any spacing, get the value. */
|
|
||||||
if (!value) return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (*value=='}') return value+1; /* end of array */
|
|
||||||
ep=value;return 0; /* malformed. */
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Render an object to text. */
|
|
||||||
static char *print_object(cJSON *item,int depth,int fmt,printbuffer *p)
|
|
||||||
{
|
|
||||||
char **entries=0,**names=0;
|
|
||||||
char *out=0,*ptr,*ret,*str;int len=7,i=0,j;
|
|
||||||
cJSON *child=item->child;
|
|
||||||
int numentries=0,fail=0;
|
|
||||||
size_t tmplen=0;
|
|
||||||
/* Count the number of entries. */
|
|
||||||
while (child) numentries++,child=child->next;
|
|
||||||
/* Explicitly handle empty object case */
|
|
||||||
if (!numentries)
|
|
||||||
{
|
|
||||||
if (p) out=ensure(p,fmt?depth+4:3);
|
|
||||||
else out=(char*)cJSON_malloc(fmt?depth+4:3);
|
|
||||||
if (!out) return 0;
|
|
||||||
ptr=out;*ptr++='{';
|
|
||||||
if (fmt) {*ptr++='\n';for (i=0;i<depth-1;i++) *ptr++='\t';}
|
|
||||||
*ptr++='}';*ptr++=0;
|
|
||||||
return out;
|
|
||||||
}
|
|
||||||
if (p)
|
|
||||||
{
|
|
||||||
/* Compose the output: */
|
|
||||||
i=p->offset;
|
|
||||||
len=fmt?2:1; ptr=ensure(p,len+1); if (!ptr) return 0;
|
|
||||||
*ptr++='{'; if (fmt) *ptr++='\n'; *ptr=0; p->offset+=len;
|
|
||||||
child=item->child;depth++;
|
|
||||||
while (child)
|
|
||||||
{
|
|
||||||
if (fmt)
|
|
||||||
{
|
|
||||||
ptr=ensure(p,depth); if (!ptr) return 0;
|
|
||||||
for (j=0;j<depth;j++) *ptr++='\t';
|
|
||||||
p->offset+=depth;
|
|
||||||
}
|
|
||||||
print_string_ptr(child->string,p);
|
|
||||||
p->offset=update(p);
|
|
||||||
|
|
||||||
len=fmt?2:1;
|
|
||||||
ptr=ensure(p,len); if (!ptr) return 0;
|
|
||||||
*ptr++=':';if (fmt) *ptr++='\t';
|
|
||||||
p->offset+=len;
|
|
||||||
|
|
||||||
print_value(child,depth,fmt,p);
|
|
||||||
p->offset=update(p);
|
|
||||||
|
|
||||||
len=(fmt?1:0)+(child->next?1:0);
|
|
||||||
ptr=ensure(p,len+1); if (!ptr) return 0;
|
|
||||||
if (child->next) *ptr++=',';
|
|
||||||
if (fmt) *ptr++='\n';*ptr=0;
|
|
||||||
p->offset+=len;
|
|
||||||
child=child->next;
|
|
||||||
}
|
|
||||||
ptr=ensure(p,fmt?(depth+1):2); if (!ptr) return 0;
|
|
||||||
if (fmt) for (i=0;i<depth-1;i++) *ptr++='\t';
|
|
||||||
*ptr++='}';*ptr=0;
|
|
||||||
out=(p->buffer)+i;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* Allocate space for the names and the objects */
|
|
||||||
entries=(char**)cJSON_malloc(numentries*sizeof(char*));
|
|
||||||
if (!entries) return 0;
|
|
||||||
names=(char**)cJSON_malloc(numentries*sizeof(char*));
|
|
||||||
if (!names) {cJSON_free(entries);return 0;}
|
|
||||||
memset(entries,0,sizeof(char*)*numentries);
|
|
||||||
memset(names,0,sizeof(char*)*numentries);
|
|
||||||
|
|
||||||
/* Collect all the results into our arrays: */
|
|
||||||
child=item->child;depth++;if (fmt) len+=depth;
|
|
||||||
while (child)
|
|
||||||
{
|
|
||||||
names[i]=str=print_string_ptr(child->string,0);
|
|
||||||
entries[i++]=ret=print_value(child,depth,fmt,0);
|
|
||||||
if (str && ret) len+=strlen(ret)+strlen(str)+2+(fmt?2+depth:0); else fail=1;
|
|
||||||
child=child->next;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Try to allocate the output string */
|
|
||||||
if (!fail) out=(char*)cJSON_malloc(len);
|
|
||||||
if (!out) fail=1;
|
|
||||||
|
|
||||||
/* Handle failure */
|
|
||||||
if (fail)
|
|
||||||
{
|
|
||||||
for (i=0;i<numentries;i++) {if (names[i]) cJSON_free(names[i]);if (entries[i]) cJSON_free(entries[i]);}
|
|
||||||
cJSON_free(names);cJSON_free(entries);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Compose the output: */
|
|
||||||
*out='{';ptr=out+1;if (fmt)*ptr++='\n';*ptr=0;
|
|
||||||
for (i=0;i<numentries;i++)
|
|
||||||
{
|
|
||||||
if (fmt) for (j=0;j<depth;j++) *ptr++='\t';
|
|
||||||
tmplen=strlen(names[i]);memcpy(ptr,names[i],tmplen);ptr+=tmplen;
|
|
||||||
*ptr++=':';if (fmt) *ptr++='\t';
|
|
||||||
strcpy(ptr,entries[i]);ptr+=strlen(entries[i]);
|
|
||||||
if (i!=numentries-1) *ptr++=',';
|
|
||||||
if (fmt) *ptr++='\n';*ptr=0;
|
|
||||||
cJSON_free(names[i]);cJSON_free(entries[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
cJSON_free(names);cJSON_free(entries);
|
|
||||||
if (fmt) for (i=0;i<depth-1;i++) *ptr++='\t';
|
|
||||||
*ptr++='}';*ptr++=0;
|
|
||||||
}
|
|
||||||
return out;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Get Array size/item / object item. */
|
|
||||||
int cJSON_GetArraySize(cJSON *array) {cJSON *c=array->child;int i=0;while(c)i++,c=c->next;return i;}
|
|
||||||
cJSON *cJSON_GetArrayItem(cJSON *array,int item) {cJSON *c=array->child; while (c && item>0) item--,c=c->next; return c;}
|
|
||||||
cJSON *cJSON_GetObjectItem(cJSON *object,const char *string) {cJSON *c=object->child; while (c && cJSON_strcasecmp(c->string,string)) c=c->next; return c;}
|
|
||||||
|
|
||||||
/* Utility for array list handling. */
|
|
||||||
static void suffix_object(cJSON *prev,cJSON *item) {prev->next=item;item->prev=prev;}
|
|
||||||
/* Utility for handling references. */
|
|
||||||
static cJSON *create_reference(cJSON *item) {cJSON *ref=cJSON_New_Item();if (!ref) return 0;memcpy(ref,item,sizeof(cJSON));ref->string=0;ref->type|=cJSON_IsReference;ref->next=ref->prev=0;return ref;}
|
|
||||||
|
|
||||||
/* Add item to array/object. */
|
|
||||||
void cJSON_AddItemToArray(cJSON *array, cJSON *item) {cJSON *c=array->child;if (!item) return; if (!c) {array->child=item;} else {while (c && c->next) c=c->next; suffix_object(c,item);}}
|
|
||||||
void cJSON_AddItemToObject(cJSON *object,const char *string,cJSON *item) {if (!item) return; if (item->string) cJSON_free(item->string);item->string=cJSON_strdup(string);cJSON_AddItemToArray(object,item);}
|
|
||||||
void cJSON_AddItemToObjectCS(cJSON *object,const char *string,cJSON *item) {if (!item) return; if (!(item->type&cJSON_StringIsConst) && item->string) cJSON_free(item->string);item->string=(char*)string;item->type|=cJSON_StringIsConst;cJSON_AddItemToArray(object,item);}
|
|
||||||
void cJSON_AddItemReferenceToArray(cJSON *array, cJSON *item) {cJSON_AddItemToArray(array,create_reference(item));}
|
|
||||||
void cJSON_AddItemReferenceToObject(cJSON *object,const char *string,cJSON *item) {cJSON_AddItemToObject(object,string,create_reference(item));}
|
|
||||||
|
|
||||||
cJSON *cJSON_DetachItemFromArray(cJSON *array,int which) {cJSON *c=array->child;while (c && which>0) c=c->next,which--;if (!c) return 0;
|
|
||||||
if (c->prev) c->prev->next=c->next;if (c->next) c->next->prev=c->prev;if (c==array->child) array->child=c->next;c->prev=c->next=0;return c;}
|
|
||||||
void cJSON_DeleteItemFromArray(cJSON *array,int which) {cJSON_Delete(cJSON_DetachItemFromArray(array,which));}
|
|
||||||
cJSON *cJSON_DetachItemFromObject(cJSON *object,const char *string) {int i=0;cJSON *c=object->child;while (c && cJSON_strcasecmp(c->string,string)) i++,c=c->next;if (c) return cJSON_DetachItemFromArray(object,i);return 0;}
|
|
||||||
void cJSON_DeleteItemFromObject(cJSON *object,const char *string) {cJSON_Delete(cJSON_DetachItemFromObject(object,string));}
|
|
||||||
|
|
||||||
/* Replace array/object items with new ones. */
|
|
||||||
void cJSON_InsertItemInArray(cJSON *array,int which,cJSON *newitem) {cJSON *c=array->child;while (c && which>0) c=c->next,which--;if (!c) {cJSON_AddItemToArray(array,newitem);return;}
|
|
||||||
newitem->next=c;newitem->prev=c->prev;c->prev=newitem;if (c==array->child) array->child=newitem; else newitem->prev->next=newitem;}
|
|
||||||
void cJSON_ReplaceItemInArray(cJSON *array,int which,cJSON *newitem) {cJSON *c=array->child;while (c && which>0) c=c->next,which--;if (!c) return;
|
|
||||||
newitem->next=c->next;newitem->prev=c->prev;if (newitem->next) newitem->next->prev=newitem;
|
|
||||||
if (c==array->child) array->child=newitem; else newitem->prev->next=newitem;c->next=c->prev=0;cJSON_Delete(c);}
|
|
||||||
void cJSON_ReplaceItemInObject(cJSON *object,const char *string,cJSON *newitem){int i=0;cJSON *c=object->child;while(c && cJSON_strcasecmp(c->string,string))i++,c=c->next;if(c){newitem->string=cJSON_strdup(string);cJSON_ReplaceItemInArray(object,i,newitem);}}
|
|
||||||
|
|
||||||
/* Create basic types: */
|
|
||||||
cJSON *cJSON_CreateNull(void) {cJSON *item=cJSON_New_Item();if(item)item->type=cJSON_NULL;return item;}
|
|
||||||
cJSON *cJSON_CreateTrue(void) {cJSON *item=cJSON_New_Item();if(item)item->type=cJSON_True;return item;}
|
|
||||||
cJSON *cJSON_CreateFalse(void) {cJSON *item=cJSON_New_Item();if(item)item->type=cJSON_False;return item;}
|
|
||||||
cJSON *cJSON_CreateBool(int b) {cJSON *item=cJSON_New_Item();if(item)item->type=b?cJSON_True:cJSON_False;return item;}
|
|
||||||
cJSON *cJSON_CreateNumber(double num) {cJSON *item=cJSON_New_Item();if(item){item->type=cJSON_Number;item->valuedouble=num;item->valueint=(int)num;}return item;}
|
|
||||||
cJSON *cJSON_CreateString(const char *string) {cJSON *item=cJSON_New_Item();if(item){item->type=cJSON_String;item->valuestring=cJSON_strdup(string);}return item;}
|
|
||||||
cJSON *cJSON_CreateArray(void) {cJSON *item=cJSON_New_Item();if(item)item->type=cJSON_Array;return item;}
|
|
||||||
cJSON *cJSON_CreateObject(void) {cJSON *item=cJSON_New_Item();if(item)item->type=cJSON_Object;return item;}
|
|
||||||
|
|
||||||
/* Create Arrays: */
|
|
||||||
cJSON *cJSON_CreateIntArray(const int *numbers,int count) {int i;cJSON *n=0,*p=0,*a=cJSON_CreateArray();for(i=0;a && i<count;i++){n=cJSON_CreateNumber(numbers[i]);if(!i)a->child=n;else suffix_object(p,n);p=n;}return a;}
|
|
||||||
cJSON *cJSON_CreateFloatArray(const float *numbers,int count) {int i;cJSON *n=0,*p=0,*a=cJSON_CreateArray();for(i=0;a && i<count;i++){n=cJSON_CreateNumber(numbers[i]);if(!i)a->child=n;else suffix_object(p,n);p=n;}return a;}
|
|
||||||
cJSON *cJSON_CreateDoubleArray(const double *numbers,int count) {int i;cJSON *n=0,*p=0,*a=cJSON_CreateArray();for(i=0;a && i<count;i++){n=cJSON_CreateNumber(numbers[i]);if(!i)a->child=n;else suffix_object(p,n);p=n;}return a;}
|
|
||||||
cJSON *cJSON_CreateStringArray(const char **strings,int count) {int i;cJSON *n=0,*p=0,*a=cJSON_CreateArray();for(i=0;a && i<count;i++){n=cJSON_CreateString(strings[i]);if(!i)a->child=n;else suffix_object(p,n);p=n;}return a;}
|
|
||||||
|
|
||||||
/* Duplication */
|
|
||||||
cJSON *cJSON_Duplicate(cJSON *item,int recurse)
|
|
||||||
{
|
|
||||||
cJSON *newitem,*cptr,*nptr=0,*newchild;
|
|
||||||
/* Bail on bad ptr */
|
|
||||||
if (!item) return 0;
|
|
||||||
/* Create new item */
|
|
||||||
newitem=cJSON_New_Item();
|
|
||||||
if (!newitem) return 0;
|
|
||||||
/* Copy over all vars */
|
|
||||||
newitem->type=item->type&(~cJSON_IsReference),newitem->valueint=item->valueint,newitem->valuedouble=item->valuedouble;
|
|
||||||
if (item->valuestring) {newitem->valuestring=cJSON_strdup(item->valuestring); if (!newitem->valuestring) {cJSON_Delete(newitem);return 0;}}
|
|
||||||
if (item->string) {newitem->string=cJSON_strdup(item->string); if (!newitem->string) {cJSON_Delete(newitem);return 0;}}
|
|
||||||
/* If non-recursive, then we're done! */
|
|
||||||
if (!recurse) return newitem;
|
|
||||||
/* Walk the ->next chain for the child. */
|
|
||||||
cptr=item->child;
|
|
||||||
while (cptr)
|
|
||||||
{
|
|
||||||
newchild=cJSON_Duplicate(cptr,1); /* Duplicate (with recurse) each item in the ->next chain */
|
|
||||||
if (!newchild) {cJSON_Delete(newitem);return 0;}
|
|
||||||
if (nptr) {nptr->next=newchild,newchild->prev=nptr;nptr=newchild;} /* If newitem->child already set, then crosswire ->prev and ->next and move on */
|
|
||||||
else {newitem->child=newchild;nptr=newchild;} /* Set newitem->child and move to it */
|
|
||||||
cptr=cptr->next;
|
|
||||||
}
|
|
||||||
return newitem;
|
|
||||||
}
|
|
||||||
|
|
||||||
void cJSON_Minify(char *json)
|
|
||||||
{
|
|
||||||
char *into=json;
|
|
||||||
while (*json)
|
|
||||||
{
|
|
||||||
if (*json==' ') json++;
|
|
||||||
else if (*json=='\t') json++; /* Whitespace characters. */
|
|
||||||
else if (*json=='\r') json++;
|
|
||||||
else if (*json=='\n') json++;
|
|
||||||
else if (*json=='/' && json[1]=='/') while (*json && *json!='\n') json++; /* double-slash comments, to end of line. */
|
|
||||||
else if (*json=='/' && json[1]=='*') {while (*json && !(*json=='*' && json[1]=='/')) json++;json+=2;} /* multiline comments. */
|
|
||||||
else if (*json=='\"'){*into++=*json++;while (*json && *json!='\"'){if (*json=='\\') *into++=*json++;*into++=*json++;}*into++=*json++;} /* string literals, which are \" sensitive. */
|
|
||||||
else *into++=*json++; /* All other characters. */
|
|
||||||
}
|
|
||||||
*into=0; /* and null-terminate. */
|
|
||||||
}
|
|
|
@ -1,154 +0,0 @@
|
||||||
/*
|
|
||||||
Copyright (c) 2009 Dave Gamble
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
|
||||||
in the Software without restriction, including without limitation the rights
|
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
|
||||||
furnished to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in
|
|
||||||
all copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
||||||
THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef cJSON__h
|
|
||||||
#define cJSON__h
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C"
|
|
||||||
{
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* cJSON Types: */
|
|
||||||
#define cJSON_False 0
|
|
||||||
#define cJSON_True 1
|
|
||||||
#define cJSON_NULL 2
|
|
||||||
#define cJSON_Number 3
|
|
||||||
#define cJSON_String 4
|
|
||||||
#define cJSON_Array 5
|
|
||||||
#define cJSON_Object 6
|
|
||||||
|
|
||||||
#define cJSON_IsReference 256
|
|
||||||
#define cJSON_StringIsConst 512
|
|
||||||
|
|
||||||
|
|
||||||
typedef void *(*malloc_fnxx)(size_t sz);
|
|
||||||
typedef void (*free_fnxx)(void *ptr);
|
|
||||||
|
|
||||||
/* The cJSON structure: */
|
|
||||||
typedef struct cJSON {
|
|
||||||
struct cJSON *next,*prev; /* next/prev allow you to walk array/object chains. Alternatively, use GetArraySize/GetArrayItem/GetObjectItem */
|
|
||||||
struct cJSON *child; /* An array or object item will have a child pointer pointing to a chain of the items in the array/object. */
|
|
||||||
|
|
||||||
int type; /* The type of the item, as above. */
|
|
||||||
|
|
||||||
char *valuestring; /* The item's string, if type==cJSON_String */
|
|
||||||
int valueint; /* The item's number, if type==cJSON_Number */
|
|
||||||
double valuedouble; /* The item's number, if type==cJSON_Number */
|
|
||||||
|
|
||||||
char *string; /* The item's name string, if this item is the child of, or is in the list of subitems of an object. */
|
|
||||||
} cJSON;
|
|
||||||
|
|
||||||
typedef struct cJSON_Hooks {
|
|
||||||
malloc_fnxx malloc_fn;
|
|
||||||
free_fnxx free_fn;
|
|
||||||
} cJSON_Hooks;
|
|
||||||
|
|
||||||
/* Supply malloc, realloc and free functions to cJSON */
|
|
||||||
extern void cJSON_InitHooks(cJSON_Hooks* hooks);
|
|
||||||
|
|
||||||
|
|
||||||
/* Supply a block of JSON, and this returns a cJSON object you can interrogate. Call cJSON_Delete when finished. */
|
|
||||||
extern cJSON *cJSON_Parse(const char *value);
|
|
||||||
/* Render a cJSON entity to text for transfer/storage. Free the char* when finished. */
|
|
||||||
extern char *cJSON_Print(cJSON *item);
|
|
||||||
/* Render a cJSON entity to text for transfer/storage without any formatting. Free the char* when finished. */
|
|
||||||
extern char *cJSON_PrintUnformatted(cJSON *item);
|
|
||||||
/* Render a cJSON entity to text using a buffered strategy. prebuffer is a guess at the final size. guessing well reduces reallocation. fmt=0 gives unformatted, =1 gives formatted */
|
|
||||||
extern char *cJSON_PrintBuffered(cJSON *item,int prebuffer,int fmt);
|
|
||||||
/* Delete a cJSON entity and all subentities. */
|
|
||||||
extern void cJSON_Delete(cJSON *c);
|
|
||||||
|
|
||||||
/* Returns the number of items in an array (or object). */
|
|
||||||
extern int cJSON_GetArraySize(cJSON *array);
|
|
||||||
/* Retrieve item number "item" from array "array". Returns NULL if unsuccessful. */
|
|
||||||
extern cJSON *cJSON_GetArrayItem(cJSON *array,int item);
|
|
||||||
/* Get item "string" from object. Case insensitive. */
|
|
||||||
extern cJSON *cJSON_GetObjectItem(cJSON *object,const char *string);
|
|
||||||
|
|
||||||
/* For analysing failed parses. This returns a pointer to the parse error. You'll probably need to look a few chars back to make sense of it. Defined when cJSON_Parse() returns 0. 0 when cJSON_Parse() succeeds. */
|
|
||||||
extern const char *cJSON_GetErrorPtr(void);
|
|
||||||
|
|
||||||
/* These calls create a cJSON item of the appropriate type. */
|
|
||||||
extern cJSON *cJSON_CreateNull(void);
|
|
||||||
extern cJSON *cJSON_CreateTrue(void);
|
|
||||||
extern cJSON *cJSON_CreateFalse(void);
|
|
||||||
extern cJSON *cJSON_CreateBool(int b);
|
|
||||||
extern cJSON *cJSON_CreateNumber(double num);
|
|
||||||
extern cJSON *cJSON_CreateString(const char *string);
|
|
||||||
extern cJSON *cJSON_CreateArray(void);
|
|
||||||
extern cJSON *cJSON_CreateObject(void);
|
|
||||||
|
|
||||||
/* These utilities create an Array of count items. */
|
|
||||||
extern cJSON *cJSON_CreateIntArray(const int *numbers,int count);
|
|
||||||
extern cJSON *cJSON_CreateFloatArray(const float *numbers,int count);
|
|
||||||
extern cJSON *cJSON_CreateDoubleArray(const double *numbers,int count);
|
|
||||||
extern cJSON *cJSON_CreateStringArray(const char **strings,int count);
|
|
||||||
|
|
||||||
/* Append item to the specified array/object. */
|
|
||||||
extern void cJSON_AddItemToArray(cJSON *array, cJSON *item);
|
|
||||||
extern void cJSON_AddItemToObject(cJSON *object,const char *string,cJSON *item);
|
|
||||||
extern void cJSON_AddItemToObjectCS(cJSON *object,const char *string,cJSON *item); /* Use this when string is definitely const (i.e. a literal, or as good as), and will definitely survive the cJSON object */
|
|
||||||
/* Append reference to item to the specified array/object. Use this when you want to add an existing cJSON to a new cJSON, but don't want to corrupt your existing cJSON. */
|
|
||||||
extern void cJSON_AddItemReferenceToArray(cJSON *array, cJSON *item);
|
|
||||||
extern void cJSON_AddItemReferenceToObject(cJSON *object,const char *string,cJSON *item);
|
|
||||||
|
|
||||||
/* Remove/Detatch items from Arrays/Objects. */
|
|
||||||
extern cJSON *cJSON_DetachItemFromArray(cJSON *array,int which);
|
|
||||||
extern void cJSON_DeleteItemFromArray(cJSON *array,int which);
|
|
||||||
extern cJSON *cJSON_DetachItemFromObject(cJSON *object,const char *string);
|
|
||||||
extern void cJSON_DeleteItemFromObject(cJSON *object,const char *string);
|
|
||||||
|
|
||||||
/* Update array items. */
|
|
||||||
extern void cJSON_InsertItemInArray(cJSON *array,int which,cJSON *newitem); /* Shifts pre-existing items to the right. */
|
|
||||||
extern void cJSON_ReplaceItemInArray(cJSON *array,int which,cJSON *newitem);
|
|
||||||
extern void cJSON_ReplaceItemInObject(cJSON *object,const char *string,cJSON *newitem);
|
|
||||||
|
|
||||||
/* Duplicate a cJSON item */
|
|
||||||
extern cJSON *cJSON_Duplicate(cJSON *item,int recurse);
|
|
||||||
/* Duplicate will create a new, identical cJSON item to the one you pass, in new memory that will
|
|
||||||
need to be released. With recurse!=0, it will duplicate any children connected to the item.
|
|
||||||
The item->next and ->prev pointers are always zero on return from Duplicate. */
|
|
||||||
|
|
||||||
/* ParseWithOpts allows you to require (and check) that the JSON is null terminated, and to retrieve the pointer to the final byte parsed. */
|
|
||||||
extern cJSON *cJSON_ParseWithOpts(const char *value,const char **return_parse_end,int require_null_terminated);
|
|
||||||
|
|
||||||
extern void cJSON_Minify(char *json);
|
|
||||||
|
|
||||||
/* Macros for creating things quickly. */
|
|
||||||
#define cJSON_AddNullToObject(object,name) cJSON_AddItemToObject(object, name, cJSON_CreateNull())
|
|
||||||
#define cJSON_AddTrueToObject(object,name) cJSON_AddItemToObject(object, name, cJSON_CreateTrue())
|
|
||||||
#define cJSON_AddFalseToObject(object,name) cJSON_AddItemToObject(object, name, cJSON_CreateFalse())
|
|
||||||
#define cJSON_AddBoolToObject(object,name,b) cJSON_AddItemToObject(object, name, cJSON_CreateBool(b))
|
|
||||||
#define cJSON_AddNumberToObject(object,name,n) cJSON_AddItemToObject(object, name, cJSON_CreateNumber(n))
|
|
||||||
#define cJSON_AddStringToObject(object,name,s) cJSON_AddItemToObject(object, name, cJSON_CreateString(s))
|
|
||||||
|
|
||||||
/* When assigning an integer value, it needs to be propagated to valuedouble too. */
|
|
||||||
#define cJSON_SetIntValue(object,val) ((object)?(object)->valueint=(object)->valuedouble=(val):(val))
|
|
||||||
#define cJSON_SetNumberValue(object,val) ((object)?(object)->valueint=(object)->valuedouble=(val):(val))
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,233 +0,0 @@
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#if defined(WIN32) || defined(_WIN64)
|
|
||||||
#include <Windows.h>
|
|
||||||
#define PATH_SYMBOL "\\"
|
|
||||||
#else
|
|
||||||
#define PATH_SYMBOL "/"
|
|
||||||
#define NULL nullptr
|
|
||||||
#define DWORD_PTR char*
|
|
||||||
#define _countof(a) sizeof(a) / sizeof(a[0])
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "cJSON.h"
|
|
||||||
//#include "../../code_device/hgsane/cJSON.h"
|
|
||||||
#include <vector>
|
|
||||||
#include <string>
|
|
||||||
#include <map>
|
|
||||||
#include <algorithm>
|
|
||||||
|
|
||||||
namespace gb
|
|
||||||
{
|
|
||||||
class scanner_cfg;
|
|
||||||
class refer
|
|
||||||
{
|
|
||||||
volatile long ref_;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
refer();
|
|
||||||
virtual ~refer();
|
|
||||||
|
|
||||||
public:
|
|
||||||
long add_ref(void);
|
|
||||||
long release(void);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class json : public refer
|
|
||||||
{
|
|
||||||
cJSON *obj_;
|
|
||||||
cJSON *cur_child_;
|
|
||||||
cJSON walk_head_;
|
|
||||||
bool is_array_;
|
|
||||||
|
|
||||||
cJSON* find_sibling(cJSON* first, const char* name, cJSON*** addr);
|
|
||||||
cJSON* find_child(cJSON *parent, std::vector<std::string>& path, bool create, cJSON*** addr = NULL);
|
|
||||||
cJSON* find(const char* path, bool create = false, cJSON*** addr = NULL);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
~json();
|
|
||||||
|
|
||||||
public:
|
|
||||||
json(char* json_txt = 0);
|
|
||||||
|
|
||||||
static std::string to_string(cJSON* root, bool formatted);
|
|
||||||
static std::string get_value_as_string(cJSON* root, bool integer = false);
|
|
||||||
static void free_node_data(cJSON* node);
|
|
||||||
static cJSON* create_element(bool is_array = false);
|
|
||||||
static cJSON* create_element_with_name(const char* name);
|
|
||||||
|
|
||||||
public:
|
|
||||||
bool attach_text(char* json_txt);
|
|
||||||
bool attach_cjson(cJSON* cjson);
|
|
||||||
bool create_empty(bool array = false);
|
|
||||||
void clear(void);
|
|
||||||
std::string to_string(bool formatted);
|
|
||||||
|
|
||||||
// can be path: child/value ...
|
|
||||||
bool get_value(const char* key, bool& val);
|
|
||||||
bool get_value(const char* key, int& val);
|
|
||||||
bool get_value(const char* key, double& val);
|
|
||||||
bool get_value(const char* key, std::string& val);
|
|
||||||
bool get_value(const char* key, json*& val); // caller shoud call "delete" to free the returned object !!!
|
|
||||||
bool get_value_as_string(const char* key, std::string& val, bool integer);
|
|
||||||
bool get_as_array(const char* key, std::vector<std::string>& val);
|
|
||||||
|
|
||||||
int count(void);
|
|
||||||
bool first_child(std::string& val, std::string* name = NULL);
|
|
||||||
bool next_child(std::string& val, std::string* name = NULL);
|
|
||||||
|
|
||||||
bool set_value(const char* key, bool val);
|
|
||||||
bool set_value(const char* key, int val);
|
|
||||||
bool set_value(const char* key, double val);
|
|
||||||
bool set_value(const char* key, std::string val);
|
|
||||||
bool set_value(const char* key, const char* val);
|
|
||||||
bool set_value(const char* key, json* obj);
|
|
||||||
|
|
||||||
bool change_key(const char* old_key, const char* new_key);
|
|
||||||
bool remove(const char* key);
|
|
||||||
};
|
|
||||||
|
|
||||||
class base64
|
|
||||||
{
|
|
||||||
char base64_ind_[128];
|
|
||||||
char base64_char_[80];
|
|
||||||
char padding_char_;
|
|
||||||
|
|
||||||
bool is_valid_base64_table(const char* table);
|
|
||||||
bool initialize_base64_table(const char* table);
|
|
||||||
|
|
||||||
public:
|
|
||||||
base64();
|
|
||||||
~base64();
|
|
||||||
|
|
||||||
public:
|
|
||||||
bool set_base64_table(const char* table = NULL);
|
|
||||||
std::string encode(const char* data, size_t bytes, unsigned int line_bytes = -1, bool need_padding = true);
|
|
||||||
std::string decode(const char* data, size_t bytes);
|
|
||||||
};
|
|
||||||
|
|
||||||
class sane_config_schm : public refer
|
|
||||||
{
|
|
||||||
std::string scheme_name_;
|
|
||||||
scanner_cfg *scanner_;
|
|
||||||
std::string file_;
|
|
||||||
json* jsn_;
|
|
||||||
json* bkp_;
|
|
||||||
json* def_val_;
|
|
||||||
bool in_setting_;
|
|
||||||
std::map<int, std::string> id_name_; // (id, default-val)
|
|
||||||
|
|
||||||
void clear();
|
|
||||||
std::string default_value(const char* name);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
~sane_config_schm();
|
|
||||||
|
|
||||||
public:
|
|
||||||
sane_config_schm(scanner_cfg* scanner = nullptr);
|
|
||||||
|
|
||||||
static std::string opt_data_appendix_;
|
|
||||||
static bool hex(unsigned char ch, unsigned char* val);
|
|
||||||
static bool hex_char(const char* data, unsigned char* val);
|
|
||||||
static std::string to_hex_letter(const char* data, size_t bytes);
|
|
||||||
static std::string from_hex_letter(const char* data, size_t bytes);
|
|
||||||
static bool is_option_data(std::string& name); // reset baase option name into 'name' if name was option data, and return true
|
|
||||||
|
|
||||||
public:
|
|
||||||
sane_config_schm* copy(void);
|
|
||||||
bool load_from_file(const char* file);
|
|
||||||
bool load_from_mem(const char* mem, bool in_b64 = true);
|
|
||||||
bool save_to(const char* file);
|
|
||||||
void set_default_value(int sn, const char* name, const char* val, size_t bytes);
|
|
||||||
void copy_default_value(sane_config_schm* from);
|
|
||||||
bool first_config(std::string& name, std::string& val);
|
|
||||||
bool next_config(std::string& name, std::string& val);
|
|
||||||
bool get_config(const char* name, std::string& val);
|
|
||||||
void begin_setting(bool restore = false);
|
|
||||||
void config_changed(const char* name, const char* val, size_t bytes, bool extra = false);
|
|
||||||
void config_changed(int sn, const char* val, size_t bytes, bool extra = false);
|
|
||||||
void remove_config(const char* name);
|
|
||||||
void set_value(const char* name, const char* val, size_t bytes, bool extra = false);
|
|
||||||
bool has_changed(int* items = nullptr);
|
|
||||||
void end_setting(bool cancel);
|
|
||||||
int id_from_name(const char* name);
|
|
||||||
std::string to_text_stream(bool b64 = true, bool with_ver = true);
|
|
||||||
std::string get_version(void);
|
|
||||||
std::string get_scheme_name(void);
|
|
||||||
void set_scheme_name(const char* name);
|
|
||||||
void update(bool(* is_float)(int, void*), void* param, const char*(* t2n)(const char*), std::string* discard = NULL);
|
|
||||||
};
|
|
||||||
|
|
||||||
class scanner_cfg : public refer
|
|
||||||
{
|
|
||||||
// format: in base64
|
|
||||||
//
|
|
||||||
// {
|
|
||||||
// "global": {
|
|
||||||
// "ver": "4.33",
|
|
||||||
// "cur": -1
|
|
||||||
// },
|
|
||||||
// "scheme_1": sane_config_schm*,
|
|
||||||
// "scheme_2": sane_config_schm*,
|
|
||||||
// "scheme_3": sane_config_schm*,
|
|
||||||
// ...
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
std::string path_;
|
|
||||||
std::string scanner_name_; // scanner type: HUAGOSCAN G100 - 0100
|
|
||||||
json *global_; // version, current scheme, ...
|
|
||||||
|
|
||||||
typedef struct _cfg_schm
|
|
||||||
{
|
|
||||||
std::string name;
|
|
||||||
sane_config_schm* schm;
|
|
||||||
|
|
||||||
bool operator==(const char* n)
|
|
||||||
{
|
|
||||||
return name == n;
|
|
||||||
}
|
|
||||||
}CFGSCHM;
|
|
||||||
std::vector<CFGSCHM> schemes_;
|
|
||||||
|
|
||||||
static std::string global_name_;
|
|
||||||
static std::string cur_sel_;
|
|
||||||
static std::string default_setting_name_;
|
|
||||||
|
|
||||||
void clear(void);
|
|
||||||
void init_version(void);
|
|
||||||
void init_select(void);
|
|
||||||
void walk_sibling_schemes(cJSON* first);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
~scanner_cfg();
|
|
||||||
|
|
||||||
public:
|
|
||||||
scanner_cfg();
|
|
||||||
|
|
||||||
typedef struct _update_func
|
|
||||||
{
|
|
||||||
void(* trans_number)(const char* name, std::string& val, void* param);
|
|
||||||
const char* (* title2name)(const char* title, void* param);
|
|
||||||
std::string discard_msg; // update failed items ...
|
|
||||||
void* func_param;
|
|
||||||
}UDF, *LPUDF;
|
|
||||||
static bool update(const char* file, LPUDF func);
|
|
||||||
|
|
||||||
public:
|
|
||||||
int load_file(const char* file);
|
|
||||||
int load_mem(const char* mem);
|
|
||||||
int save(const char* file = nullptr);
|
|
||||||
|
|
||||||
void get_all_schemes(std::vector<std::string>& schemes); // return all schemes name queue, the first is always be 'Default settings'
|
|
||||||
sane_config_schm* get_scheme(const char* scheme_name = nullptr/*return current scheme if was null*/); // call sane_config_schm::release() if not use anymore
|
|
||||||
std::string get_current_scheme_name(void);
|
|
||||||
bool remove_scheme(const char* scheme_name);
|
|
||||||
void remove_all_schemes(void);
|
|
||||||
bool select_scheme(const char* scheme_name);
|
|
||||||
|
|
||||||
sane_config_schm* copy_scheme(const char* cp_from_name); // for UI setting, call release() if not use anymore
|
|
||||||
bool add_scheme(sane_config_schm* schm, const char* name = nullptr);
|
|
||||||
bool rename_scheme(const char* from, const char* to);
|
|
||||||
};
|
|
||||||
};
|
|
|
@ -1,260 +0,0 @@
|
||||||
#ifndef CUSTOM_FILE_DIALOG_H
|
|
||||||
#define CUSTOM_FILE_DIALOG_H
|
|
||||||
|
|
||||||
#include <QFileDialog>
|
|
||||||
#include <QLineEdit>
|
|
||||||
#include <QPushButton>
|
|
||||||
#include <QListWidget>
|
|
||||||
#include <QLayout>
|
|
||||||
#include <QButtonGroup>
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
#define USE_FILE_DLG_WITHOUT_PROMPT
|
|
||||||
|
|
||||||
template<class T>
|
|
||||||
class custom_file_dlg
|
|
||||||
{
|
|
||||||
QLineEdit* edit_;
|
|
||||||
QLineEdit* new_;
|
|
||||||
QPushButton *save_;
|
|
||||||
QFileDialog *fdlg_;
|
|
||||||
QListView *list_;
|
|
||||||
|
|
||||||
enum find_cls
|
|
||||||
{
|
|
||||||
FIND_BUTTON = 1,
|
|
||||||
FIND_LINE_EDIT,
|
|
||||||
FIND_LIST,
|
|
||||||
};
|
|
||||||
typedef struct _find_ctrl
|
|
||||||
{
|
|
||||||
int cls;
|
|
||||||
std::string title;
|
|
||||||
QObject *found;
|
|
||||||
}FINDCTRL, *LPFINDCTRL;
|
|
||||||
|
|
||||||
static bool find_ctrls(QObject* obj, LPFINDCTRL ret)
|
|
||||||
{
|
|
||||||
if(ret->cls == FIND_BUTTON)
|
|
||||||
{
|
|
||||||
QPushButton* btn = dynamic_cast<QPushButton*>(obj);
|
|
||||||
if(btn)
|
|
||||||
{
|
|
||||||
std::string t(btn->text().toStdString());
|
|
||||||
if(ret->title.empty() || t == ret->title) // "\344\277\235\345\255\230(&S)")
|
|
||||||
{
|
|
||||||
ret->found = obj;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
QButtonGroup* grp = dynamic_cast<QButtonGroup*>(obj);
|
|
||||||
if(grp)
|
|
||||||
{
|
|
||||||
printf("Found button-group with %d buttons\n", grp->buttons().size());
|
|
||||||
QList<QAbstractButton*> btns = grp->buttons();
|
|
||||||
for(auto& b : btns)
|
|
||||||
{
|
|
||||||
btn = dynamic_cast<QPushButton*>(b);
|
|
||||||
if(btn)
|
|
||||||
{
|
|
||||||
std::string t(btn->text().toStdString());
|
|
||||||
if(ret->title.empty() || t == ret->title) // "\344\277\235\345\255\230(&S)")
|
|
||||||
{
|
|
||||||
ret->found = obj;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if(ret->cls == FIND_LINE_EDIT)
|
|
||||||
{
|
|
||||||
QLineEdit* edit = dynamic_cast<QLineEdit*>(obj);
|
|
||||||
if(edit)
|
|
||||||
{
|
|
||||||
std::string t(edit->text().toStdString());
|
|
||||||
if(ret->title.empty() || t == ret->title) // "\344\277\235\345\255\230(&S)")
|
|
||||||
{
|
|
||||||
ret->found = obj;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if(ret->cls == FIND_LIST)
|
|
||||||
{
|
|
||||||
QListView *v = dynamic_cast<QListView*>(obj);
|
|
||||||
if(v)
|
|
||||||
{
|
|
||||||
std::string t(v->objectName().toStdString());
|
|
||||||
if(ret->title.empty() && ret->title.empty()) // || t == ret->title)
|
|
||||||
{
|
|
||||||
ret->found = obj;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
QListWidget *l = dynamic_cast<QListWidget*>(obj);
|
|
||||||
if(l)
|
|
||||||
{
|
|
||||||
printf("Found list widget\n");
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
QListView *v = dynamic_cast<QListView*>(obj);
|
|
||||||
if(v)
|
|
||||||
printf("Found list view: %s\n", v->objectName().toStdString().c_str());
|
|
||||||
}
|
|
||||||
QObjectList objs(obj->children());
|
|
||||||
for(auto& o : objs)
|
|
||||||
{
|
|
||||||
if(find_ctrls(o, ret))
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
QPushButton* save_button(void){return save_;}
|
|
||||||
QLineEdit* input_edit(bool org){return org ? edit_ : new_;}
|
|
||||||
QListView* file_list(void){return list_;}
|
|
||||||
void replace_input(QLineEdit* from, QLineEdit* tobe)
|
|
||||||
{
|
|
||||||
fdlg_->layout()->replaceWidget(from, tobe);
|
|
||||||
from->hide();
|
|
||||||
tobe->show();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected slots:
|
|
||||||
virtual void on_file_dialog_textChanged(const QString &path) = 0;
|
|
||||||
virtual void on_file_dialog_returnPressed() = 0;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
custom_file_dlg() : edit_(nullptr), new_(nullptr), save_(nullptr), fdlg_(nullptr), list_(nullptr)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
~custom_file_dlg()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public:
|
|
||||||
static QLineEdit* find_input_box(QFileDialog* host)
|
|
||||||
{
|
|
||||||
FINDCTRL fc;
|
|
||||||
QObjectList objs(host->children());
|
|
||||||
|
|
||||||
fc.cls = FIND_LINE_EDIT;
|
|
||||||
fc.found = nullptr;
|
|
||||||
for(auto& o : objs)
|
|
||||||
{
|
|
||||||
QString objName = o->objectName();
|
|
||||||
if(custom_file_dlg::find_ctrls(o, &fc))
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return dynamic_cast<QLineEdit*>(fc.found);
|
|
||||||
}
|
|
||||||
static QPushButton* find_button(QFileDialog* host, const char* title)
|
|
||||||
{
|
|
||||||
FINDCTRL fc;
|
|
||||||
QObjectList objs(host->children());
|
|
||||||
|
|
||||||
fc.cls = FIND_BUTTON;
|
|
||||||
fc.title = (title && *title) ? title : "";
|
|
||||||
fc.found = nullptr;
|
|
||||||
for(auto& o : objs)
|
|
||||||
{
|
|
||||||
QString objName = o->objectName();
|
|
||||||
if(custom_file_dlg::find_ctrls(o, &fc))
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return dynamic_cast<QPushButton*>(fc.found);
|
|
||||||
}
|
|
||||||
static QListView* find_list(QFileDialog* host, const char* title)
|
|
||||||
{
|
|
||||||
FINDCTRL fc;
|
|
||||||
QObjectList objs(host->children());
|
|
||||||
|
|
||||||
fc.cls = FIND_LIST;
|
|
||||||
fc.title = (title && *title) ? title : "";
|
|
||||||
fc.found = nullptr;
|
|
||||||
for(auto& o : objs)
|
|
||||||
{
|
|
||||||
if(custom_file_dlg::find_ctrls(o, &fc))
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return dynamic_cast<QListView*>(fc.found);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
protected:
|
|
||||||
bool init_custom_file_dlg(QFileDialog* fdlg)
|
|
||||||
{
|
|
||||||
new_ = new QLineEdit(((T*)this));
|
|
||||||
fdlg_ = fdlg;
|
|
||||||
edit_ = custom_file_dlg::find_input_box(fdlg);
|
|
||||||
save_ = custom_file_dlg::find_button(fdlg, QObject::tr("&Save").toStdString().c_str());
|
|
||||||
list_ = custom_file_dlg::find_list(fdlg, "");
|
|
||||||
if(edit_ && save_ && list_)
|
|
||||||
{
|
|
||||||
enable_prompt(false);
|
|
||||||
((T*)this)->connect(new_, SIGNAL(textChanged(const QString&)), (T*)this, SLOT(on_file_dialog_textChanged(const QString)));
|
|
||||||
((T*)this)->connect(new_, SIGNAL(returnPressed()), (T*)this, SLOT(on_file_dialog_returnPressed()));
|
|
||||||
((T*)this)->connect(fdlg, SIGNAL(currentChanged(const QString&)), (T*)this, SLOT(on_file_dialog_textChanged(const QString)));
|
|
||||||
fdlg->setFocus();
|
|
||||||
new_->setFocus();
|
|
||||||
}
|
|
||||||
return edit_ && save_;
|
|
||||||
}
|
|
||||||
void enable_prompt(bool enable)
|
|
||||||
{
|
|
||||||
if(edit_)
|
|
||||||
{
|
|
||||||
if(enable)
|
|
||||||
replace_input(new_, edit_);
|
|
||||||
else
|
|
||||||
replace_input(edit_, new_);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void on_file_name_changed(const QLineEdit* ctrl, const QString& text)
|
|
||||||
{
|
|
||||||
if(ctrl == nullptr) // send by QFileDialog
|
|
||||||
{
|
|
||||||
std::string name(text.toStdString());
|
|
||||||
size_t pos = name.rfind('/');
|
|
||||||
if(pos++ != std::string::npos)
|
|
||||||
name.erase(0, pos);
|
|
||||||
new_->setText(QString::fromStdString(name));
|
|
||||||
}
|
|
||||||
else if(ctrl == edit_ && new_)
|
|
||||||
new_->setText(text);
|
|
||||||
else if(edit_)
|
|
||||||
{
|
|
||||||
QString ext(text), sel_ext(((T*)this)->getSaveExt());
|
|
||||||
int pos = ext.lastIndexOf('.');
|
|
||||||
|
|
||||||
list_->clearSelection();
|
|
||||||
if(pos == -1)
|
|
||||||
edit_->setText(text + sel_ext);
|
|
||||||
else {
|
|
||||||
ext = ext.right(ext.length() - pos);
|
|
||||||
if(ext.compare(sel_ext, Qt::CaseInsensitive) == 0)
|
|
||||||
edit_->setText(text);
|
|
||||||
else
|
|
||||||
edit_->setText(text + sel_ext);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(save_)
|
|
||||||
save_->setEnabled(!text.isEmpty());
|
|
||||||
}
|
|
||||||
void on_file_name_press_return(void)
|
|
||||||
{
|
|
||||||
emit save_->clicked();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
#endif // CUSTOM_FILE_DIALOG_H
|
|
|
@ -1,465 +0,0 @@
|
||||||
#include "cutdialog.h"
|
|
||||||
#include "ui_cutdialog.h"
|
|
||||||
#include <QDebug>
|
|
||||||
#include <QToolTip>
|
|
||||||
#include <qpainterpath.h>
|
|
||||||
#include "HGString.h"
|
|
||||||
#include "sane/sane_option_definitions.h"
|
|
||||||
|
|
||||||
cutDialog::cutDialog(QWidget *parent) :
|
|
||||||
QWidget(parent),
|
|
||||||
ui(new Ui::cutDialog)
|
|
||||||
{
|
|
||||||
ui->setupUi(this);
|
|
||||||
divisor = 8;
|
|
||||||
dpi = 1;
|
|
||||||
sizeType = 0;
|
|
||||||
paperWidth = 185;
|
|
||||||
h_w = 260.0/185.0;
|
|
||||||
sizeRate = 1;
|
|
||||||
paperHeight = paperWidth*h_w;
|
|
||||||
|
|
||||||
this->setFixedSize(paperWidth,paperHeight);
|
|
||||||
setMouseTracking(true);
|
|
||||||
m_startPoint = QPoint(10,10);
|
|
||||||
m_endPoint = QPoint(50,50);
|
|
||||||
m_mouse_down = false;
|
|
||||||
|
|
||||||
initAllCorner();
|
|
||||||
}
|
|
||||||
|
|
||||||
cutDialog::~cutDialog()
|
|
||||||
{
|
|
||||||
delete ui;
|
|
||||||
}
|
|
||||||
|
|
||||||
void cutDialog::setPaperSize(QString type, const int w)
|
|
||||||
{
|
|
||||||
paperType = type;
|
|
||||||
|
|
||||||
if (paperType == OPTION_VALUE_ZZCC_A3) h_w = 420.0 / 297.0;
|
|
||||||
else if (paperType == OPTION_VALUE_ZZCC_8K) h_w = 390.0 / 270.0;
|
|
||||||
else if (paperType == OPTION_VALUE_ZZCC_16K) h_w = 270.0 / 190.0;
|
|
||||||
else if (paperType == OPTION_VALUE_ZZCC_16KHX) h_w = 190.0 / 270.0;
|
|
||||||
else if (paperType == OPTION_VALUE_ZZCC_A4) h_w = 297.0 / 210.0;
|
|
||||||
else if (paperType == OPTION_VALUE_ZZCC_A4HX) h_w = 210.0 / 297.0;
|
|
||||||
else if (paperType == OPTION_VALUE_ZZCC_A5) h_w = 210.0 / 148.0;
|
|
||||||
else if (paperType == OPTION_VALUE_ZZCC_A5HX) h_w = 148.0 / 210.0;
|
|
||||||
else if (paperType == OPTION_VALUE_ZZCC_A6) h_w = 148.0 / 105.0;
|
|
||||||
else if (paperType == OPTION_VALUE_ZZCC_A6HX) h_w = 105.0 / 148.0;
|
|
||||||
else if (paperType == OPTION_VALUE_ZZCC_B4) h_w = 353.0 / 250.0;
|
|
||||||
else if (paperType == OPTION_VALUE_ZZCC_B5) h_w = 250.0 / 176.0;
|
|
||||||
else if (paperType == OPTION_VALUE_ZZCC_B5HX) h_w = 176.0 / 250.0;
|
|
||||||
else if (paperType == OPTION_VALUE_ZZCC_B6) h_w = 176.0 / 125.0;
|
|
||||||
else if (paperType == OPTION_VALUE_ZZCC_B6HX) h_w = 125.0 / 176.0;
|
|
||||||
else if (paperType == OPTION_VALUE_ZZCC_Letter) h_w = 279.0 / 216.0;
|
|
||||||
else if (paperType == OPTION_VALUE_ZZCC_LetterHX) h_w = 216.0 / 279.0;
|
|
||||||
else if (paperType == OPTION_VALUE_ZZCC_DoubleLetter) h_w = 559.0 / 216.0;
|
|
||||||
else if (paperType == OPTION_VALUE_ZZCC_LEGAL) h_w = 356.0 / 216.0;
|
|
||||||
else if (paperType == OPTION_VALUE_ZZCC_SLSJ) h_w = 560.0 / 270.0;
|
|
||||||
else if(paperType == OPTION_VALUE_ZZCC_ZDSMCC) h_w = 3307.0*2/2338;
|
|
||||||
else if(paperType == OPTION_VALUE_ZZCC_PPYSCC) {
|
|
||||||
if(dpi == 100.0) h_w = 1795.0/1189;
|
|
||||||
if(dpi == 150.0) h_w = 1795.0/1784;
|
|
||||||
if(dpi == 200.0) h_w = 3307.0/2338;
|
|
||||||
if(dpi == 240.0) h_w = 4308.0/2854;
|
|
||||||
if(dpi == 200.0) h_w = 5385.0/3567;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
if(type.contains("3")) divisor = 2;
|
|
||||||
else if (type.contains("4")) divisor = 4;
|
|
||||||
else if (type.contains("5")) divisor = 6;
|
|
||||||
else if (type.contains("6")) divisor = 8;
|
|
||||||
else divisor = 4;
|
|
||||||
paperWidth = w;
|
|
||||||
if(type.contains(StdStringToUtf8("横向").c_str()))
|
|
||||||
paperWidth = paperWidth*h_w*1.5;
|
|
||||||
double realW = paperWidth;
|
|
||||||
|
|
||||||
if (paperType == OPTION_VALUE_ZZCC_A3 || paperType == OPTION_VALUE_ZZCC_A4HX) realRate = 297.0 / realW;
|
|
||||||
else if (paperType == OPTION_VALUE_ZZCC_A4 || paperType == OPTION_VALUE_ZZCC_A5HX) realRate = 210.0 / realW;
|
|
||||||
else if (paperType == OPTION_VALUE_ZZCC_A5 || paperType == OPTION_VALUE_ZZCC_A6HX) realRate = 148.0 / realW;
|
|
||||||
else if (paperType == OPTION_VALUE_ZZCC_A6) realRate = 105.0 / realW;
|
|
||||||
else if (paperType == OPTION_VALUE_ZZCC_16K) realRate = 190.0 / realW;
|
|
||||||
else if (paperType == OPTION_VALUE_ZZCC_8K || paperType == OPTION_VALUE_ZZCC_16KHX) realRate = 270.0 / realW;
|
|
||||||
else if (paperType == OPTION_VALUE_ZZCC_B4 || paperType == OPTION_VALUE_ZZCC_B5HX) realRate = 250.0 / realW;
|
|
||||||
else if (paperType == OPTION_VALUE_ZZCC_B5 || paperType == OPTION_VALUE_ZZCC_B6HX) realRate = 176.0 / realW;
|
|
||||||
else if (paperType == OPTION_VALUE_ZZCC_B6) realRate = 125.0 / realW;
|
|
||||||
else if (paperType == OPTION_VALUE_ZZCC_Letter) realRate = 216.0 / realW;
|
|
||||||
else if (paperType == OPTION_VALUE_ZZCC_LetterHX) realRate = 279.0 / realW;
|
|
||||||
else if (paperType == OPTION_VALUE_ZZCC_DoubleLetter) realRate = 216.0 / realW;
|
|
||||||
else if (paperType == OPTION_VALUE_ZZCC_LEGAL) realRate = 216.0 / realW;
|
|
||||||
else if (paperType == OPTION_VALUE_ZZCC_SLSJ) realRate = 270.0 / realW;
|
|
||||||
else if(paperType == OPTION_VALUE_ZZCC_ZDSMCC) realRate = 297.0/realW;
|
|
||||||
else if(paperType == OPTION_VALUE_ZZCC_PPYSCC) {
|
|
||||||
if(dpi == 100.0) realRate = 1189.0*0.039377/dpi/realW;
|
|
||||||
if(dpi == 150.0) realRate = 1784*0.039377/dpi/realW;
|
|
||||||
if(dpi == 200.0) realRate = 2338*0.039377/dpi/realW;
|
|
||||||
if(dpi == 240.0) realRate = 2854*0.039377/dpi/realW;
|
|
||||||
if(dpi == 200.0) realRate = 3567*0.039377/dpi/realW;
|
|
||||||
};
|
|
||||||
|
|
||||||
paperHeight = paperWidth*h_w;
|
|
||||||
this->setFixedSize(paperWidth+4,paperHeight+4);
|
|
||||||
scaleRec = QRectF(0,0,paperWidth,paperHeight+0.5);
|
|
||||||
m_rect = QRectF(m_startPoint,m_endPoint);
|
|
||||||
update();
|
|
||||||
refreshView();
|
|
||||||
}
|
|
||||||
|
|
||||||
void cutDialog::setDpiValue(const double d)
|
|
||||||
{
|
|
||||||
dpi = d;
|
|
||||||
if(sizeType == PIXEL) sizeRate = 0.03937*dpi;
|
|
||||||
update();
|
|
||||||
}
|
|
||||||
|
|
||||||
void cutDialog::setSizeType(const SIZETYPE &t)
|
|
||||||
{
|
|
||||||
sizeType = t;
|
|
||||||
switch (sizeType) {
|
|
||||||
case MILLIM:
|
|
||||||
sizeRate = 1;
|
|
||||||
break;
|
|
||||||
case INCH:
|
|
||||||
sizeRate = 0.03937;
|
|
||||||
break;
|
|
||||||
case PIXEL:
|
|
||||||
sizeRate = 0.03937*dpi;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
update();
|
|
||||||
}
|
|
||||||
|
|
||||||
void cutDialog::setCutRectWidth(double w)
|
|
||||||
{
|
|
||||||
m_endPoint.setX(m_startPoint.x()+scaleRec.width()*w/getPaperSize().width());
|
|
||||||
update();
|
|
||||||
}
|
|
||||||
|
|
||||||
void cutDialog::setCutRectHeight(double h)
|
|
||||||
{
|
|
||||||
m_endPoint.setY(m_startPoint.y()+scaleRec.height()*h/getPaperSize().height());
|
|
||||||
update();
|
|
||||||
}
|
|
||||||
|
|
||||||
void cutDialog::setCutRectStartX(double x)
|
|
||||||
{
|
|
||||||
m_startPoint.setX(scaleRec.width()*x/getPaperSize().width());
|
|
||||||
update();
|
|
||||||
}
|
|
||||||
|
|
||||||
void cutDialog::setCutRectStartY(double y)
|
|
||||||
{
|
|
||||||
m_startPoint.setY(scaleRec.height()*y/getPaperSize().height());
|
|
||||||
update();
|
|
||||||
}
|
|
||||||
|
|
||||||
QSizeF cutDialog::getPaperSize() const
|
|
||||||
{
|
|
||||||
double realW = paperWidth*realRate*sizeRate;
|
|
||||||
double realH = paperHeight*realRate*sizeRate;
|
|
||||||
return QSizeF(realW,realH);
|
|
||||||
}
|
|
||||||
|
|
||||||
QSizeF cutDialog::getCutRectSize() const
|
|
||||||
{
|
|
||||||
double realCutW = getPaperSize().width()*m_rect.width()/scaleRec.width();
|
|
||||||
double realCutH = getPaperSize().height()*m_rect.height()/scaleRec.height();
|
|
||||||
return QSizeF(realCutW,realCutH);
|
|
||||||
}
|
|
||||||
|
|
||||||
QPointF cutDialog::getCutRectStartPos() const
|
|
||||||
{
|
|
||||||
double realCutX = getPaperSize().width()*m_startPoint.x()/scaleRec.width();
|
|
||||||
double realCutY = getPaperSize().height()*m_startPoint.y()/scaleRec.height();
|
|
||||||
return QPointF(realCutX,realCutY);
|
|
||||||
}
|
|
||||||
|
|
||||||
QRectF cutDialog::getCutRectPixel() const
|
|
||||||
{
|
|
||||||
double x = 0.03937*dpi*paperWidth*realRate*m_startPoint.x()/scaleRec.width();
|
|
||||||
double y = 0.03937*dpi*paperHeight*realRate*m_startPoint.y()/scaleRec.height();
|
|
||||||
double w = 0.03937*dpi*paperWidth*realRate*m_rect.width()/scaleRec.width();
|
|
||||||
double h = 0.03937*dpi*paperHeight*realRate*m_rect.height()/scaleRec.height();
|
|
||||||
return QRectF(x,y,w,h);
|
|
||||||
}
|
|
||||||
|
|
||||||
void cutDialog::setCutRectPixel(QRectF &rect)
|
|
||||||
{
|
|
||||||
m_startPoint.setX(scaleRec.width()*rect.x()/(paperWidth*realRate*0.03937*dpi));
|
|
||||||
m_startPoint.setY(scaleRec.height()*rect.y()/(paperHeight*realRate*0.03937*dpi));
|
|
||||||
m_endPoint.setX(m_startPoint.x()+scaleRec.width()*rect.width()/(paperWidth*realRate*0.03937*dpi));
|
|
||||||
m_endPoint.setY(m_startPoint.y()+scaleRec.height()*rect.height()/(paperHeight*realRate*0.03937*dpi));
|
|
||||||
m_rect = QRectF(m_startPoint,m_endPoint);
|
|
||||||
update();
|
|
||||||
}
|
|
||||||
|
|
||||||
int cutDialog::getCutRectRight() const
|
|
||||||
{
|
|
||||||
return getPaperSize().width()*m_rect.right()/scaleRec.right();
|
|
||||||
}
|
|
||||||
|
|
||||||
int cutDialog::getCutRectBottom() const
|
|
||||||
{
|
|
||||||
return getPaperSize().height()*m_rect.bottom()/scaleRec.bottom();
|
|
||||||
}
|
|
||||||
|
|
||||||
void cutDialog::mousePressEvent(QMouseEvent *event)
|
|
||||||
{
|
|
||||||
int x = event->x()/**paperWidth/width()*/;
|
|
||||||
int y = event->y()/**paperHeight/height()*/;
|
|
||||||
m_moveStart = QPoint(x,y);
|
|
||||||
m_mouse_down = event->button() == Qt::LeftButton;
|
|
||||||
update();
|
|
||||||
}
|
|
||||||
|
|
||||||
void cutDialog::mouseMoveEvent(QMouseEvent *event)
|
|
||||||
{
|
|
||||||
int x = event->x()/**paperWidth/width()*/;
|
|
||||||
int y = event->y()/**paperHeight/height()*/;
|
|
||||||
if(m_mouse_down){
|
|
||||||
int dx = m_moveStart.x() - x;
|
|
||||||
int dy = m_moveStart.y() - y;
|
|
||||||
m_moveStart = QPoint(x,y);
|
|
||||||
|
|
||||||
if(m_leftCorn){
|
|
||||||
m_startPoint.setX(x);
|
|
||||||
}else if(m_rightCorn){
|
|
||||||
m_endPoint.setX(x);
|
|
||||||
}else if(m_topCorn){
|
|
||||||
m_startPoint.setY(y);
|
|
||||||
}else if(m_bottomCorn){
|
|
||||||
m_endPoint.setY(y);
|
|
||||||
}else if(m_leftTop){
|
|
||||||
m_startPoint.setX(x);
|
|
||||||
m_startPoint.setY(y);
|
|
||||||
}else if(m_leftBottom){
|
|
||||||
m_startPoint.setX(x);
|
|
||||||
m_endPoint.setY(y);
|
|
||||||
}else if(m_rightTop){
|
|
||||||
m_startPoint.setY(y);
|
|
||||||
m_endPoint.setX(x);
|
|
||||||
}else if(m_rightBottom){
|
|
||||||
m_endPoint.setX(x);
|
|
||||||
m_endPoint.setY(y);
|
|
||||||
}
|
|
||||||
else if(!m_out){
|
|
||||||
if(m_startPoint.x() - dx < 0) dx = 0;
|
|
||||||
if(m_startPoint.y() - dy < 0) dy = 0;
|
|
||||||
if(m_endPoint.x() - dx > scaleRec.right()) dx = 0;
|
|
||||||
if(m_endPoint.y() - dy > scaleRec.bottom()) dy = 0;
|
|
||||||
m_startPoint.setX(m_rect.left()-dx);
|
|
||||||
m_startPoint.setY(m_rect.top()-dy);
|
|
||||||
m_endPoint.setX(m_rect.right()-dx);
|
|
||||||
m_endPoint.setY(m_rect.bottom()-dy);
|
|
||||||
}
|
|
||||||
if(m_startPoint.x()<=0) m_startPoint.setX(0);
|
|
||||||
if(m_startPoint.y()<=0) m_startPoint.setY(0);
|
|
||||||
if(m_endPoint.x()>=scaleRec.width()) m_endPoint.setX(scaleRec.right());
|
|
||||||
if(m_endPoint.y()>=scaleRec.height()) m_endPoint.setY(scaleRec.bottom());
|
|
||||||
|
|
||||||
|
|
||||||
if(qAbs(m_startPoint.x() - m_endPoint.x()) <= 10 || m_startPoint.x() > m_endPoint.x()){
|
|
||||||
m_startPoint.setX(m_rect.left());
|
|
||||||
m_endPoint.setX(m_rect.right());
|
|
||||||
}
|
|
||||||
if(qAbs(m_startPoint.y() - m_endPoint.y()) <= 10 || m_startPoint.y() > m_endPoint.y()){
|
|
||||||
m_startPoint.setY(m_rect.top());
|
|
||||||
m_endPoint.setY(m_rect.bottom());
|
|
||||||
}
|
|
||||||
|
|
||||||
update();
|
|
||||||
}else{
|
|
||||||
mousePosition(QPoint(x,y));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void cutDialog::mouseReleaseEvent(QMouseEvent *)
|
|
||||||
{
|
|
||||||
m_mouse_down = false;
|
|
||||||
update();
|
|
||||||
}
|
|
||||||
|
|
||||||
void cutDialog::enterEvent(QEvent *)
|
|
||||||
{
|
|
||||||
emit lineEditEnable(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
void cutDialog::leaveEvent(QEvent *)
|
|
||||||
{
|
|
||||||
emit lineEditEnable(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
void cutDialog::paintEvent(QPaintEvent *)
|
|
||||||
{
|
|
||||||
QPainter painter(this);
|
|
||||||
painter.translate(0,0);
|
|
||||||
|
|
||||||
drawScale(painter);
|
|
||||||
drawCutRect(painter);
|
|
||||||
drawTransparentColor(painter);
|
|
||||||
if(m_mouse_down){
|
|
||||||
if(sizeType == INCH || sizeType == MILLIM){
|
|
||||||
emit cutRectX(QString::number(getCutRectStartPos().x(),'f',2).toDouble());
|
|
||||||
emit cutRectY(QString::number(getCutRectStartPos().y(),'f',2).toDouble());
|
|
||||||
emit cutRectWidth(QString::number(getCutRectSize().width(),'f',2).toDouble());
|
|
||||||
emit cutRectHeight(QString::number(getCutRectSize().height(),'f',2).toDouble());
|
|
||||||
}else{
|
|
||||||
emit cutRectX(double(int(getCutRectStartPos().x())));
|
|
||||||
emit cutRectY(double(int(getCutRectStartPos().y())));
|
|
||||||
emit cutRectWidth(double(int(getCutRectSize().width())));
|
|
||||||
emit cutRectHeight(double(int(getCutRectSize().height())));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
painter.end();
|
|
||||||
}
|
|
||||||
|
|
||||||
void cutDialog::drawScale(QPainter& painter)
|
|
||||||
{
|
|
||||||
painter.setPen(QPen(Qt::black,1));
|
|
||||||
scaleRec = QRectF(0,0,paperWidth,paperHeight+0.5);
|
|
||||||
painter.drawRect(scaleRec);
|
|
||||||
for(int i = 6 ; i <= paperWidth-6; i++){
|
|
||||||
if(int(paperWidth/2) == i || int(paperWidth/4) == i || int(paperWidth*3/4) == i){
|
|
||||||
painter.setPen(QPen(Qt::gray,1));
|
|
||||||
painter.drawLine(i,0,i,paperHeight);
|
|
||||||
painter.setPen(QPen(Qt::black,1));
|
|
||||||
}
|
|
||||||
if(i%divisor == 0){
|
|
||||||
painter.drawLine(i,paperHeight-4,i,paperHeight);
|
|
||||||
painter.drawLine(i,0,i,4);
|
|
||||||
}
|
|
||||||
if(i%(divisor*5) == 0){
|
|
||||||
painter.drawLine(i,paperHeight-8,i,paperHeight);
|
|
||||||
painter.drawLine(i,0,i,8);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for(int i = 6 ; i <= paperHeight-6; i++){
|
|
||||||
if(int(paperHeight/2) == i || int(paperHeight/4) == i || int(paperHeight*3/4) == i){
|
|
||||||
painter.setPen(QPen(Qt::gray,1));
|
|
||||||
painter.drawLine(0,i,paperWidth,i);
|
|
||||||
painter.setPen(QPen(Qt::black,1));
|
|
||||||
}
|
|
||||||
if(i%divisor == 0){
|
|
||||||
painter.drawLine(0,i,4,i);
|
|
||||||
painter.drawLine(paperWidth,i,paperWidth-4,i);
|
|
||||||
}
|
|
||||||
if(i%(divisor*5) == 0){
|
|
||||||
painter.drawLine(0,i,8,i);
|
|
||||||
painter.drawLine(paperWidth,i,paperWidth-8,i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void cutDialog::drawCutRect(QPainter &painter)
|
|
||||||
{
|
|
||||||
painter.setPen(QPen(Qt::green,1));
|
|
||||||
m_rect = QRectF(m_startPoint,m_endPoint);
|
|
||||||
|
|
||||||
QRectF r(m_rect);
|
|
||||||
if(r.right() + 6 > paperWidth)
|
|
||||||
r.setRight(paperWidth - 6);
|
|
||||||
if(r.bottom() + 2 > paperHeight)
|
|
||||||
r.setBottom(paperHeight - 2);
|
|
||||||
|
|
||||||
painter.drawRect(r);
|
|
||||||
painter.setPen(QPen(Qt::red,1));
|
|
||||||
painter.setBrush(Qt::red);
|
|
||||||
painter.drawEllipse(r.left()-2,(r.bottom()-r.top())/2+r.top()-2,4,4);
|
|
||||||
painter.drawEllipse(r.left()-2,r.top()-2,4,4);
|
|
||||||
painter.drawEllipse(r.left()-2,r.bottom()-2,4,4);
|
|
||||||
painter.drawEllipse(r.right()-2,r.top()-2,4,4);
|
|
||||||
painter.drawEllipse(r.right()-2,r.bottom()-2,4,4);
|
|
||||||
painter.drawEllipse(r.right()-2,(r.bottom()-r.top())/2+r.top()-2,4,4);
|
|
||||||
painter.drawEllipse((r.right()-r.left())/2+r.left()-2,r.top()-2,4,4);
|
|
||||||
painter.drawEllipse((r.right()-r.left())/2+r.left()-2,r.bottom()-2,4,4);
|
|
||||||
}
|
|
||||||
|
|
||||||
void cutDialog::drawTransparentColor(QPainter &painter)
|
|
||||||
{
|
|
||||||
QPainterPath painterPath;
|
|
||||||
QPainterPath p;
|
|
||||||
p.addRect(scaleRec);
|
|
||||||
painterPath.addRect(m_rect);
|
|
||||||
QPainterPath drawPath =p.subtracted(painterPath);
|
|
||||||
painter.setOpacity(0.7);
|
|
||||||
painter.fillPath(drawPath,QBrush(Qt::gray));
|
|
||||||
}
|
|
||||||
|
|
||||||
void cutDialog::mousePosition(const QPoint& e)
|
|
||||||
{
|
|
||||||
initAllCorner();
|
|
||||||
QRectF r = QRectF(m_rect);
|
|
||||||
int x = e.x();
|
|
||||||
int y = e.y();
|
|
||||||
m_left = qAbs(x - r.left()) < 5;
|
|
||||||
m_right = qAbs(x - r.right()) < 5;
|
|
||||||
m_bottom = qAbs(y - r.bottom()) < 5;
|
|
||||||
m_top = qAbs(y - r.top()) < 5;
|
|
||||||
m_out = r.left()-x>=5 || x-r.right()>=5 || r.top()-y>=5 || y-r.bottom()>=5;
|
|
||||||
bool lorr = m_left | m_right;
|
|
||||||
bool torb = m_top | m_bottom;
|
|
||||||
if(lorr && torb)
|
|
||||||
{
|
|
||||||
if((m_left && m_top) || (m_right && m_bottom))
|
|
||||||
setCursor(Qt::SizeFDiagCursor);
|
|
||||||
else
|
|
||||||
setCursor(Qt::SizeBDiagCursor);
|
|
||||||
}
|
|
||||||
else if(lorr)
|
|
||||||
setCursor(Qt::SizeHorCursor);
|
|
||||||
else if(torb)
|
|
||||||
setCursor(Qt::SizeVerCursor);
|
|
||||||
else if(!m_out)
|
|
||||||
{
|
|
||||||
setCursor(Qt::SizeAllCursor);
|
|
||||||
m_bottom = m_left = m_right = m_top = false;
|
|
||||||
}else if(m_out){
|
|
||||||
setCursor(Qt::ArrowCursor);
|
|
||||||
m_bottom = m_left = m_right = m_top = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(m_left && m_top) m_leftTop = true;
|
|
||||||
else if(m_left && m_bottom) m_leftBottom = true;
|
|
||||||
else if(m_right && m_top) m_rightTop = true;
|
|
||||||
else if(m_right && m_bottom) m_rightBottom = true;
|
|
||||||
else if(m_left && !m_top && !m_bottom) m_leftCorn = true;
|
|
||||||
else if(m_right && !m_top && !m_bottom) m_rightCorn = true;
|
|
||||||
else if(m_top && !m_left && !m_right) m_topCorn = true;
|
|
||||||
else if(m_bottom && !m_left && !m_right) m_bottomCorn = true;
|
|
||||||
else initAllCorner();
|
|
||||||
}
|
|
||||||
|
|
||||||
void cutDialog::refreshView()
|
|
||||||
{
|
|
||||||
if(MILLIM == sizeType || sizeType == INCH){
|
|
||||||
emit cutRectX(QString::number(getCutRectStartPos().x(),'f',2).toDouble());
|
|
||||||
emit cutRectY(QString::number(getCutRectStartPos().y(),'f',2).toDouble());
|
|
||||||
emit cutRectWidth(QString::number(getCutRectSize().width(),'f',2).toDouble());
|
|
||||||
emit cutRectHeight(QString::number(getCutRectSize().height(),'f',2).toDouble());
|
|
||||||
}else{
|
|
||||||
emit cutRectX(QString::number(getCutRectStartPos().x(),'f',0).toDouble());
|
|
||||||
emit cutRectY(QString::number(getCutRectStartPos().y(),'f',0).toDouble());
|
|
||||||
emit cutRectWidth(double(int(getCutRectSize().width())));
|
|
||||||
emit cutRectHeight(double(int(getCutRectSize().height())));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void cutDialog::initAllCorner()
|
|
||||||
{
|
|
||||||
m_left = false;
|
|
||||||
m_right = false;
|
|
||||||
m_bottom = false;
|
|
||||||
m_top = false;
|
|
||||||
m_leftCorn = false;
|
|
||||||
m_rightCorn = false;
|
|
||||||
m_topCorn = false;
|
|
||||||
m_bottomCorn = false;
|
|
||||||
m_leftTop = false;
|
|
||||||
m_leftBottom = false;
|
|
||||||
m_rightTop = false;
|
|
||||||
m_rightBottom = false;
|
|
||||||
}
|
|
|
@ -1,100 +0,0 @@
|
||||||
#ifndef CUTDIALOG_H
|
|
||||||
#define CUTDIALOG_H
|
|
||||||
|
|
||||||
#include <QWidget>
|
|
||||||
#include <QMouseEvent>
|
|
||||||
#include <QPainter>
|
|
||||||
#include <QCursor>
|
|
||||||
|
|
||||||
namespace Ui {
|
|
||||||
class cutDialog;
|
|
||||||
}
|
|
||||||
|
|
||||||
enum SIZETYPE{
|
|
||||||
MILLIM ,
|
|
||||||
INCH,
|
|
||||||
PIXEL
|
|
||||||
};
|
|
||||||
|
|
||||||
class cutDialog : public QWidget
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
explicit cutDialog(QWidget *parent = nullptr);
|
|
||||||
~cutDialog();
|
|
||||||
void setPaperSize(QString type = "A1", const int w = 200);
|
|
||||||
void setDpiValue(const double d);
|
|
||||||
void setSizeType(const SIZETYPE& t);
|
|
||||||
void setCutRectWidth(double w);
|
|
||||||
void setCutRectHeight(double h);
|
|
||||||
void setCutRectStartX(double x);
|
|
||||||
void setCutRectStartY(double y);
|
|
||||||
QSizeF getPaperSize()const;
|
|
||||||
QSizeF getCutRectSize()const;
|
|
||||||
QPointF getCutRectStartPos()const;
|
|
||||||
QRectF getCutRectPixel()const;
|
|
||||||
void setCutRectPixel(QRectF& rect);
|
|
||||||
int getCutRectRight()const;
|
|
||||||
int getCutRectBottom()const;
|
|
||||||
void refreshView();
|
|
||||||
|
|
||||||
signals:
|
|
||||||
void cutRectX(double x);
|
|
||||||
void cutRectY(double y);
|
|
||||||
void cutRectWidth(double w);
|
|
||||||
void cutRectHeight(double h);
|
|
||||||
void lineEditEnable(bool b);
|
|
||||||
|
|
||||||
private:
|
|
||||||
void mousePressEvent(QMouseEvent*);
|
|
||||||
void mouseMoveEvent(QMouseEvent*);
|
|
||||||
void mouseReleaseEvent(QMouseEvent*);
|
|
||||||
void enterEvent(QEvent*);
|
|
||||||
void leaveEvent(QEvent*);
|
|
||||||
//void resizeEvent(QResizeEvent*);
|
|
||||||
void paintEvent(QPaintEvent *);
|
|
||||||
void drawScale(QPainter &painter);
|
|
||||||
void drawCutRect(QPainter &painter);
|
|
||||||
void drawTransparentColor(QPainter &painter);
|
|
||||||
void drawPaperSize();
|
|
||||||
void mousePosition(const QPoint &e);
|
|
||||||
void initAllCorner();
|
|
||||||
//void mouseChangeRect(int dx,int dy);
|
|
||||||
|
|
||||||
private:
|
|
||||||
Ui::cutDialog *ui;
|
|
||||||
QPointF m_startPoint;
|
|
||||||
QPointF m_endPoint;
|
|
||||||
QPointF m_moveStart;
|
|
||||||
|
|
||||||
QRectF m_rect;
|
|
||||||
QRectF scaleRec;
|
|
||||||
|
|
||||||
QString paperType;
|
|
||||||
double paperWidth;
|
|
||||||
double paperHeight;
|
|
||||||
int divisor;
|
|
||||||
int sizeType;
|
|
||||||
double dpi;
|
|
||||||
double h_w;
|
|
||||||
double realRate;
|
|
||||||
double sizeRate;
|
|
||||||
|
|
||||||
bool m_mouse_down;
|
|
||||||
bool m_left;
|
|
||||||
bool m_right;
|
|
||||||
bool m_bottom;
|
|
||||||
bool m_top;
|
|
||||||
bool m_leftCorn;
|
|
||||||
bool m_rightCorn;
|
|
||||||
bool m_topCorn;
|
|
||||||
bool m_bottomCorn;
|
|
||||||
bool m_leftTop;
|
|
||||||
bool m_rightTop;
|
|
||||||
bool m_leftBottom;
|
|
||||||
bool m_rightBottom;
|
|
||||||
bool m_out;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // CUTDIALOG_H
|
|
|
@ -1,44 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<ui version="4.0">
|
|
||||||
<class>cutDialog</class>
|
|
||||||
<widget class="QWidget" name="cutDialog">
|
|
||||||
<property name="enabled">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>0</y>
|
|
||||||
<width>321</width>
|
|
||||||
<height>342</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="minimumSize">
|
|
||||||
<size>
|
|
||||||
<width>2</width>
|
|
||||||
<height>0</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="baseSize">
|
|
||||||
<size>
|
|
||||||
<width>2</width>
|
|
||||||
<height>0</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="mouseTracking">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
<property name="windowTitle">
|
|
||||||
<string>cutDialog</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
<layoutdefault spacing="6" margin="11"/>
|
|
||||||
<resources/>
|
|
||||||
<connections/>
|
|
||||||
</ui>
|
|
|
@ -1,212 +0,0 @@
|
||||||
#include "cutpapertool.h"
|
|
||||||
#include "ui_cutpapertool.h"
|
|
||||||
#include <QDebug>
|
|
||||||
#include <QValidator>
|
|
||||||
|
|
||||||
CutPaperTool::CutPaperTool(int d, const QString& t, int w, int unit, QWidget *parent) :
|
|
||||||
QDialog(parent),
|
|
||||||
ui(new Ui::CutPaperTool)
|
|
||||||
{
|
|
||||||
ui->setupUi(this);
|
|
||||||
setWindowFlags(Qt::Dialog | Qt::WindowCloseButtonHint);
|
|
||||||
connect(ui->widget,SIGNAL(cutRectX(double)),this,SLOT(cutRectXSlot(double)));
|
|
||||||
connect(ui->widget,SIGNAL(cutRectY(double)),this,SLOT(cutRectYSlot(double)));
|
|
||||||
connect(ui->widget,SIGNAL(cutRectWidth(double)),this,SLOT(cutRectWidthSlot(double)));
|
|
||||||
connect(ui->widget,SIGNAL(cutRectHeight(double)),this,SLOT(cutRectHeightSlot(double)));
|
|
||||||
connect(ui->widget,SIGNAL(lineEditEnable(bool)),this,SLOT(lineEditEnableSlot(bool)));
|
|
||||||
ui->widget->setSizeType(MILLIM);
|
|
||||||
|
|
||||||
dpi = d;
|
|
||||||
ui->dpiLab->setText(QString::number(dpi));
|
|
||||||
ui->widget->setDpiValue(dpi);
|
|
||||||
paperType = t;
|
|
||||||
ui->paperLab->setText(paperType);
|
|
||||||
ui->widget->setPaperSize(paperType, w);
|
|
||||||
setSizeLabel();
|
|
||||||
this->setFixedWidth(ui->widget->width()+40);
|
|
||||||
setSizeInit();
|
|
||||||
|
|
||||||
ui->comboBox_2->setCurrentIndex(unit);
|
|
||||||
}
|
|
||||||
|
|
||||||
CutPaperTool::~CutPaperTool()
|
|
||||||
{
|
|
||||||
delete ui;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CutPaperTool::paintEvent(QPaintEvent *)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
QRectF CutPaperTool::getCutRectPixel()
|
|
||||||
{
|
|
||||||
return QRectF(ui->widget->getCutRectPixel());
|
|
||||||
}
|
|
||||||
|
|
||||||
void CutPaperTool::setCutRectPixel(QRectF &rect)
|
|
||||||
{
|
|
||||||
ui->widget->setCutRectPixel(rect);
|
|
||||||
ui->startXEdt->setText(QString::number(rect.x()/dpi/0.03937));
|
|
||||||
ui->startYEdt->setText(QString::number(rect.y()/dpi/0.03937));
|
|
||||||
ui->rectWidth->setText(QString::number(rect.width()/dpi/0.03937));
|
|
||||||
ui->rectHeight->setText(QString::number(rect.height()/dpi/0.03937));
|
|
||||||
|
|
||||||
update();
|
|
||||||
setSizeLabel();
|
|
||||||
ui->widget->refreshView();
|
|
||||||
}
|
|
||||||
|
|
||||||
void CutPaperTool::setSizeLabel()
|
|
||||||
{
|
|
||||||
QString wSize;
|
|
||||||
QString hSize;
|
|
||||||
if(ui->comboBox_2->currentIndex() == INCH){
|
|
||||||
wSize = QString::number(ui->widget->getPaperSize().width(),'f',2);
|
|
||||||
hSize = QString::number(ui->widget->getPaperSize().height(),'f',2);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
wSize = QString::number(int(ui->widget->getPaperSize().width()+0.001));
|
|
||||||
hSize = QString::number(int(ui->widget->getPaperSize().height()+0.001));
|
|
||||||
}
|
|
||||||
ui->sizeLabel->setText("("+wSize + " * " +hSize+")");
|
|
||||||
}
|
|
||||||
|
|
||||||
void CutPaperTool::setSizeInit()
|
|
||||||
{
|
|
||||||
ui->widget->setCutRectStartX(0);
|
|
||||||
ui->widget->setCutRectStartY(0);
|
|
||||||
ui->widget->setCutRectWidth(ui->widget->getPaperSize().width());
|
|
||||||
ui->widget->setCutRectHeight(ui->widget->getPaperSize().height());
|
|
||||||
ui->startXEdt->setText("0");
|
|
||||||
ui->startYEdt->setText("0");
|
|
||||||
ui->rectWidth->setText(QString::number(int(ui->widget->getPaperSize().width())));
|
|
||||||
ui->rectHeight->setText(QString::number(int(ui->widget->getPaperSize().height())));
|
|
||||||
}
|
|
||||||
|
|
||||||
void CutPaperTool::cutRectXSlot(double x)
|
|
||||||
{
|
|
||||||
ui->startXEdt->setText(QString::number(x));
|
|
||||||
}
|
|
||||||
|
|
||||||
void CutPaperTool::cutRectYSlot(double y)
|
|
||||||
{
|
|
||||||
ui->startYEdt->setText(QString::number(y));
|
|
||||||
}
|
|
||||||
|
|
||||||
void CutPaperTool::cutRectWidthSlot(double w)
|
|
||||||
{
|
|
||||||
ui->rectWidth->setText(QString::number(w));
|
|
||||||
}
|
|
||||||
|
|
||||||
void CutPaperTool::cutRectHeightSlot(double h)
|
|
||||||
{
|
|
||||||
ui->rectHeight->setText(QString::number(h));
|
|
||||||
}
|
|
||||||
|
|
||||||
void CutPaperTool::lineEditEnableSlot(bool b)
|
|
||||||
{
|
|
||||||
ui->startXEdt->setEnabled(b);
|
|
||||||
ui->startYEdt->setEnabled(b);
|
|
||||||
ui->rectWidth->setEnabled(b);
|
|
||||||
ui->rectHeight->setEnabled(b);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CutPaperTool::on_startXEdt_textEdited(QString arg1)
|
|
||||||
{
|
|
||||||
double x = arg1.toDouble();
|
|
||||||
if(x >ui->widget->getCutRectRight()) {
|
|
||||||
//arg1.chop(1);
|
|
||||||
//x = arg1.toDouble();
|
|
||||||
//x = ui->widget->getCutRectRight();
|
|
||||||
return ;
|
|
||||||
}
|
|
||||||
if(type == PIXEL) x = arg1.toInt();
|
|
||||||
ui->widget->setCutRectStartX(x);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CutPaperTool::on_startYEdt_textEdited(QString arg1)
|
|
||||||
{
|
|
||||||
double y = arg1.toDouble();
|
|
||||||
if(y >ui->widget->getCutRectBottom()) {
|
|
||||||
//arg1.chop(1);
|
|
||||||
//y = arg1.toDouble();
|
|
||||||
return ;
|
|
||||||
}
|
|
||||||
if(type == PIXEL) y = arg1.toInt();
|
|
||||||
ui->widget->setCutRectStartY(y);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CutPaperTool::on_rectWidth_textEdited(QString arg1)
|
|
||||||
{
|
|
||||||
double v = arg1.toDouble();
|
|
||||||
if(v > ui->widget->getPaperSize().width() - ui->widget->getCutRectStartPos().x()) {
|
|
||||||
//arg1.chop(1);
|
|
||||||
//v = arg1.toDouble();
|
|
||||||
//v=ui->widget->getPaperSize().width() - ui->widget->getCutRectStartPos().x();
|
|
||||||
return ;
|
|
||||||
}
|
|
||||||
if(type == PIXEL) v = arg1.toInt();
|
|
||||||
ui->widget->setCutRectWidth(v);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CutPaperTool::on_rectHeight_textEdited(QString arg1)
|
|
||||||
{
|
|
||||||
double v = arg1.toDouble();
|
|
||||||
if(v > ui->widget->getPaperSize().height() - ui->widget->getCutRectStartPos().y()) {
|
|
||||||
//arg1.chop(1);
|
|
||||||
//v = arg1.toDouble();
|
|
||||||
//v = ui->widget->getPaperSize().height() - ui->widget->getCutRectStartPos().y();
|
|
||||||
return ;
|
|
||||||
}
|
|
||||||
if(type == PIXEL) v = arg1.toInt();
|
|
||||||
ui->widget->setCutRectHeight(v);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CutPaperTool::on_comboBox_2_currentIndexChanged(int index)
|
|
||||||
{
|
|
||||||
switch(index)
|
|
||||||
{
|
|
||||||
case 0:
|
|
||||||
ui->xLabel->setText("mm");
|
|
||||||
ui->yLabel->setText("mm");
|
|
||||||
ui->wLabel->setText("mm");
|
|
||||||
ui->hLabel->setText("mm");
|
|
||||||
ui->widget->setSizeType(MILLIM);
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
ui->xLabel->setText("in");
|
|
||||||
ui->yLabel->setText("in");
|
|
||||||
ui->wLabel->setText("in");
|
|
||||||
ui->hLabel->setText("in");
|
|
||||||
ui->widget->setSizeType(INCH);
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
ui->xLabel->setText("px");
|
|
||||||
ui->yLabel->setText("px");
|
|
||||||
ui->wLabel->setText("px");
|
|
||||||
ui->hLabel->setText("px");
|
|
||||||
ui->widget->setSizeType(PIXEL);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
update();
|
|
||||||
setSizeLabel();
|
|
||||||
ui->widget->refreshView();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void CutPaperTool::on_buttonBox_accepted()
|
|
||||||
{
|
|
||||||
accept();
|
|
||||||
}
|
|
||||||
|
|
||||||
void CutPaperTool::on_buttonBox_rejected()
|
|
||||||
{
|
|
||||||
reject();
|
|
||||||
}
|
|
||||||
|
|
||||||
void CutPaperTool::on_pbtn_init_clicked()
|
|
||||||
{
|
|
||||||
setSizeInit();
|
|
||||||
}
|
|
|
@ -1,56 +0,0 @@
|
||||||
#ifndef CUTPAPERTOOL_H
|
|
||||||
#define CUTPAPERTOOL_H
|
|
||||||
|
|
||||||
#include <QDialog>
|
|
||||||
#include "cutdialog.h"
|
|
||||||
|
|
||||||
namespace Ui {
|
|
||||||
class CutPaperTool;
|
|
||||||
}
|
|
||||||
|
|
||||||
class CutPaperTool : public QDialog
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
explicit CutPaperTool(int d, const QString& t, int w, int unit, QWidget *parent = nullptr);
|
|
||||||
~CutPaperTool();
|
|
||||||
QRectF getCutRectPixel();
|
|
||||||
void setCutRectPixel(QRectF& rect);
|
|
||||||
|
|
||||||
private:
|
|
||||||
void paintEvent(QPaintEvent *);
|
|
||||||
void setSizeLabel();
|
|
||||||
void setSizeInit();
|
|
||||||
|
|
||||||
private slots:
|
|
||||||
void cutRectXSlot(double x);
|
|
||||||
void cutRectYSlot(double y);
|
|
||||||
void cutRectWidthSlot(double w);
|
|
||||||
void cutRectHeightSlot(double h);
|
|
||||||
void lineEditEnableSlot(bool b);
|
|
||||||
|
|
||||||
void on_startXEdt_textEdited(QString arg1);
|
|
||||||
|
|
||||||
void on_startYEdt_textEdited(QString arg1);
|
|
||||||
|
|
||||||
void on_rectWidth_textEdited(QString arg1);
|
|
||||||
|
|
||||||
void on_rectHeight_textEdited(QString arg1);
|
|
||||||
|
|
||||||
void on_comboBox_2_currentIndexChanged(int index);
|
|
||||||
|
|
||||||
void on_buttonBox_accepted();
|
|
||||||
|
|
||||||
void on_buttonBox_rejected();
|
|
||||||
|
|
||||||
void on_pbtn_init_clicked();
|
|
||||||
|
|
||||||
private:
|
|
||||||
Ui::CutPaperTool *ui;
|
|
||||||
SIZETYPE type;
|
|
||||||
int dpi;
|
|
||||||
QString paperType;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // CUTPAPERTOOL_H
|
|
|
@ -1,298 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<ui version="4.0">
|
|
||||||
<class>CutPaperTool</class>
|
|
||||||
<widget class="QWidget" name="CutPaperTool">
|
|
||||||
<property name="enabled">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>0</y>
|
|
||||||
<width>439</width>
|
|
||||||
<height>676</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="windowTitle">
|
|
||||||
<string>自定义扫描区域</string>
|
|
||||||
</property>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
|
||||||
<item>
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="label_6">
|
|
||||||
<property name="text">
|
|
||||||
<string>纸张尺寸:</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="paperLab">
|
|
||||||
<property name="text">
|
|
||||||
<string>A4</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="sizeLabel">
|
|
||||||
<property name="text">
|
|
||||||
<string>(210*297)</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<spacer name="horizontalSpacer_4">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>40</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_5">
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="label_8">
|
|
||||||
<property name="text">
|
|
||||||
<string>DPI(像素/英寸):</string>
|
|
||||||
</property>
|
|
||||||
<property name="alignment">
|
|
||||||
<set>Qt::AlignJustify|Qt::AlignVCenter</set>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="dpiLab">
|
|
||||||
<property name="text">
|
|
||||||
<string>200</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<spacer name="horizontalSpacer_5">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>40</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="label_5">
|
|
||||||
<property name="text">
|
|
||||||
<string>单位:</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QComboBox" name="comboBox_2">
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>毫米(mm)</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>英寸(in)</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>像素(px)</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<spacer name="horizontalSpacer_3">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>40</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="pbtn_init">
|
|
||||||
<property name="text">
|
|
||||||
<string>初始化选择区域</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QScrollArea" name="scrollArea">
|
|
||||||
<property name="widgetResizable">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
<widget class="QWidget" name="scrollAreaWidgetContents_4">
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>0</y>
|
|
||||||
<width>421</width>
|
|
||||||
<height>430</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
|
||||||
<item>
|
|
||||||
<widget class="cutDialog" name="widget" native="true">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="label">
|
|
||||||
<property name="text">
|
|
||||||
<string>x:</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QLineEdit" name="startXEdt"/>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="xLabel">
|
|
||||||
<property name="text">
|
|
||||||
<string>mm</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<spacer name="horizontalSpacer">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>40</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="label_2">
|
|
||||||
<property name="text">
|
|
||||||
<string>y:</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QLineEdit" name="startYEdt"/>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="yLabel">
|
|
||||||
<property name="text">
|
|
||||||
<string>mm</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="wLabel_2">
|
|
||||||
<property name="text">
|
|
||||||
<string>w:</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QLineEdit" name="rectWidth"/>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="wLabel">
|
|
||||||
<property name="text">
|
|
||||||
<string>mm</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<spacer name="horizontalSpacer_2">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>40</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="label_4">
|
|
||||||
<property name="text">
|
|
||||||
<string>h:</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QLineEdit" name="rectHeight"/>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="hLabel">
|
|
||||||
<property name="text">
|
|
||||||
<string>mm</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QDialogButtonBox" name="buttonBox">
|
|
||||||
<property name="standardButtons">
|
|
||||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
<customwidgets>
|
|
||||||
<customwidget>
|
|
||||||
<class>cutDialog</class>
|
|
||||||
<extends>QWidget</extends>
|
|
||||||
<header location="global">cutdialog.h</header>
|
|
||||||
<container>1</container>
|
|
||||||
</customwidget>
|
|
||||||
</customwidgets>
|
|
||||||
<resources/>
|
|
||||||
<connections/>
|
|
||||||
</ui>
|
|
|
@ -1,189 +0,0 @@
|
||||||
#include "device_menu.h"
|
|
||||||
|
|
||||||
#define ACTION_DEVICE_NAME_PROPERTY "device_name"
|
|
||||||
|
|
||||||
device_menu::device_menu(QWidget *parent)
|
|
||||||
: QMenu(parent)
|
|
||||||
, cur_action_(nullptr), none_action_(nullptr)
|
|
||||||
{
|
|
||||||
group_action_ = new QActionGroup(this);
|
|
||||||
deviceMenuUpdate(nullptr);
|
|
||||||
connect(group_action_, SIGNAL(triggered(QAction*)), this, SLOT(on_act_triggered(QAction*)));
|
|
||||||
}
|
|
||||||
|
|
||||||
device_menu::device_menu(const QString &title, QWidget *parent)
|
|
||||||
: QMenu(title, parent)
|
|
||||||
, cur_action_(nullptr), none_action_(nullptr)
|
|
||||||
{
|
|
||||||
group_action_ = new QActionGroup(this);
|
|
||||||
deviceMenuUpdate(nullptr);
|
|
||||||
connect(group_action_, SIGNAL(triggered(QAction*)), this, SLOT(on_act_triggered(QAction*)));
|
|
||||||
}
|
|
||||||
|
|
||||||
QMenu* device_menu::find_device_menu(const QString& dev_name)
|
|
||||||
{
|
|
||||||
std::lock_guard<std::mutex> lock(mutex_);
|
|
||||||
std::vector<POPMENU>::iterator it = std::find(menus_.begin(), menus_.end(), dev_name);
|
|
||||||
|
|
||||||
if(it == menus_.end())
|
|
||||||
return nullptr;
|
|
||||||
else
|
|
||||||
return it->menu;
|
|
||||||
}
|
|
||||||
QAction* device_menu::find_device_config(const QString& dev_name, const QString& cfg_name)
|
|
||||||
{
|
|
||||||
std::lock_guard<std::mutex> lock(mutex_);
|
|
||||||
std::vector<POPMENU>::iterator it = std::find(menus_.begin(), menus_.end(), dev_name);
|
|
||||||
|
|
||||||
if(it == menus_.end())
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
for(size_t i = 0; i < it->actions.size(); ++i)
|
|
||||||
{
|
|
||||||
if(it->actions[i]->text() == cfg_name)
|
|
||||||
return it->actions[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
void device_menu::connectedDevice(const QString &device)
|
|
||||||
{
|
|
||||||
QMenu* menu = find_device_menu(device);
|
|
||||||
if (menu)
|
|
||||||
menu->setEnabled(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
void device_menu::disconnectedDevice(const QString &device)
|
|
||||||
{
|
|
||||||
QMenu* menu = find_device_menu(device);
|
|
||||||
if (menu)
|
|
||||||
menu->setEnabled(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
void device_menu::setOptionChecked(const QString &device, const QString &opt, bool checked)
|
|
||||||
{
|
|
||||||
QAction* act = find_device_config(device, opt);
|
|
||||||
|
|
||||||
if(act)
|
|
||||||
{
|
|
||||||
act->setChecked(checked);
|
|
||||||
if(checked)
|
|
||||||
cur_action_ = act;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if(cur_action_ == act)
|
|
||||||
cur_action_ = nullptr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if(checked)
|
|
||||||
cur_action_ = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
void device_menu::get_online_devices(QList<QString>& dev_names)
|
|
||||||
{
|
|
||||||
std::lock_guard<std::mutex> lock(mutex_);
|
|
||||||
|
|
||||||
for(size_t i = 0; i < menus_.size(); ++i)
|
|
||||||
{
|
|
||||||
if(menus_[i].menu->isEnabled())
|
|
||||||
dev_names.push_back(menus_[i].menu->title());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void device_menu::deviceMenuUpdate(dev_que* que)
|
|
||||||
{
|
|
||||||
std::lock_guard<std::mutex> lock(mutex_);
|
|
||||||
|
|
||||||
cur_action_ = nullptr;
|
|
||||||
if(none_action_)
|
|
||||||
{
|
|
||||||
removeAction(none_action_);
|
|
||||||
none_action_ = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
for(size_t i = 0; i < menus_.size(); ++i)
|
|
||||||
menus_[i].menu->setEnabled(false);
|
|
||||||
if (!que || que->scanners() == 0)
|
|
||||||
{
|
|
||||||
if(menus_.empty())
|
|
||||||
{
|
|
||||||
none_action_ = addAction(tr("no device"));
|
|
||||||
none_action_->setEnabled(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (size_t i = 0; i < que->scanners(); i++)
|
|
||||||
{
|
|
||||||
SCANNER s = que->get_at(i);
|
|
||||||
std::vector<POPMENU>::iterator it = std::find(menus_.begin(), menus_.end(), QString::fromStdString((s.name)));
|
|
||||||
POPMENU pm;
|
|
||||||
std::vector<std::string> schemes;
|
|
||||||
|
|
||||||
if(it == menus_.end())
|
|
||||||
pm.menu = addMenu(QString::fromStdString(s.name));
|
|
||||||
else
|
|
||||||
{
|
|
||||||
pm = *it;
|
|
||||||
menus_.erase(it);
|
|
||||||
}
|
|
||||||
pm.menu->setEnabled(true);
|
|
||||||
pm.menu->setToolTipsVisible(true);
|
|
||||||
for(size_t j = 0; j < pm.actions.size(); ++j)
|
|
||||||
{
|
|
||||||
pm.menu->removeAction(pm.actions[j]);
|
|
||||||
group_action_->removeAction(pm.actions[j]);
|
|
||||||
}
|
|
||||||
pm.actions.clear();
|
|
||||||
s.cfg->get_all_schemes(schemes);
|
|
||||||
for (size_t j = 0; j < schemes.size(); j++)
|
|
||||||
{
|
|
||||||
QAction *child = group_action_->addAction(QString::fromStdString(schemes[j]));
|
|
||||||
child->setProperty(ACTION_DEVICE_NAME_PROPERTY, QVariant(QString::fromStdString(s.name)));
|
|
||||||
child->setCheckable(true);
|
|
||||||
|
|
||||||
if(que->opened_scanner_name() == s.name &&
|
|
||||||
schemes[j] == s.cfg->get_current_scheme_name())
|
|
||||||
{
|
|
||||||
cur_action_ = child;
|
|
||||||
child->setChecked(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
pm.menu->addAction(child);
|
|
||||||
pm.actions.push_back(child);
|
|
||||||
|
|
||||||
QString tips;
|
|
||||||
if(tips.isNull())
|
|
||||||
{
|
|
||||||
tips = tr("default setting");
|
|
||||||
}
|
|
||||||
// child->setToolTip(tips);
|
|
||||||
}
|
|
||||||
menus_.push_back(pm);
|
|
||||||
s.cfg->release();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void device_menu::on_act_triggered(QAction* act)
|
|
||||||
{
|
|
||||||
QString deviceName = act->property(ACTION_DEVICE_NAME_PROPERTY).toString();
|
|
||||||
QString opt = act->text();
|
|
||||||
bool checked_now = act->isChecked();
|
|
||||||
|
|
||||||
if(cur_action_ == act)
|
|
||||||
{
|
|
||||||
checked_now = false;
|
|
||||||
act->setChecked(false);
|
|
||||||
cur_action_ = nullptr;
|
|
||||||
// emit scanOptionsChanged("", "", false);
|
|
||||||
// return;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
cur_action_ = act;
|
|
||||||
checked_now = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
emit scanOptionsChanged(deviceName, opt, checked_now);
|
|
||||||
}
|
|
|
@ -1,506 +0,0 @@
|
||||||
#ifndef DEVICE_MENU_H
|
|
||||||
#define DEVICE_MENU_H
|
|
||||||
|
|
||||||
#include <QMenu>
|
|
||||||
#include <mutex>
|
|
||||||
#include "sane/sane_ex.h"
|
|
||||||
#include "sane/sane_option_definitions.h"
|
|
||||||
#include "../../../sdk/include/huagao/hgscanner_error.h"
|
|
||||||
|
|
||||||
#include "cfg/gb_json.h"
|
|
||||||
#include "lang/app_language.h"
|
|
||||||
|
|
||||||
typedef struct _scanner
|
|
||||||
{
|
|
||||||
std::string name;
|
|
||||||
std::string model;
|
|
||||||
bool online;
|
|
||||||
gb::scanner_cfg *cfg;
|
|
||||||
}SCANNER;
|
|
||||||
class dev_que
|
|
||||||
{
|
|
||||||
std::vector<SCANNER> que_;
|
|
||||||
std::string root_dir_;
|
|
||||||
std::string opened_scanner_;
|
|
||||||
std::string applied_scheme_;
|
|
||||||
SANE_Handle handle_;
|
|
||||||
|
|
||||||
|
|
||||||
static void trans_number(const char* name, std::string& val, void* param)
|
|
||||||
{
|
|
||||||
if (strcmp(name, "tl-x") == 0
|
|
||||||
|| strcmp(name, "br-x") == 0
|
|
||||||
|| strcmp(name, "tl-y") == 0
|
|
||||||
|| strcmp(name, "br-y") == 0
|
|
||||||
|| strcmp(name, "gamma") == 0
|
|
||||||
|| strcmp(name, "search-hole-range-l") == 0
|
|
||||||
|| strcmp(name, "search-hole-range-r") == 0
|
|
||||||
|| strcmp(name, "search-hole-range-t") == 0
|
|
||||||
|| strcmp(name, "search-hole-range-b") == 0
|
|
||||||
|| strcmp(name, "feed-strength-value") == 0
|
|
||||||
)
|
|
||||||
{
|
|
||||||
float v = atof(val.c_str());
|
|
||||||
SANE_Fixed f = SANE_FIX(v);
|
|
||||||
|
|
||||||
val = std::string((char*)&f, sizeof(f));
|
|
||||||
}
|
|
||||||
else if (strcmp(name, "binary-threshold") == 0
|
|
||||||
|| strcmp(name, "bkg-color-range") == 0
|
|
||||||
|| strcmp(name, "noise-size") == 0
|
|
||||||
|| strcmp(name, "blank-sensitivity") == 0
|
|
||||||
|| strcmp(name, "resolution") == 0
|
|
||||||
|| strcmp(name, "brightness") == 0
|
|
||||||
|| strcmp(name, "contrast") == 0
|
|
||||||
|| strcmp(name, "threshold") == 0
|
|
||||||
|| strcmp(name, "anti-noise-level") == 0
|
|
||||||
|| strcmp(name, "margin") == 0
|
|
||||||
|| strcmp(name, "scan-count") == 0
|
|
||||||
|| strcmp(name, "askew-range") == 0
|
|
||||||
|| strcmp(name, "dog-ear-size") == 0
|
|
||||||
)
|
|
||||||
{
|
|
||||||
SANE_Int v = atoi(val.c_str());
|
|
||||||
val = std::string((char*)&v, sizeof(v));
|
|
||||||
}
|
|
||||||
else if (strcmp(val.c_str(), "true") == 0)
|
|
||||||
{
|
|
||||||
SANE_Bool b = SANE_TRUE;
|
|
||||||
val = std::string((char*)&b, sizeof(b));
|
|
||||||
}
|
|
||||||
else if (strcmp(val.c_str(), "false") == 0)
|
|
||||||
{
|
|
||||||
SANE_Bool b = SANE_FALSE;
|
|
||||||
val = std::string((char*)&b, sizeof(b));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
static const char* title_2_name(const char* title, void* param)
|
|
||||||
{
|
|
||||||
struct
|
|
||||||
{
|
|
||||||
const char* name;
|
|
||||||
const char* title;
|
|
||||||
}g_opts[] = { {SANE_STD_OPT_NAME_RESTORE , OPTION_TITLE_HFMRSZ}
|
|
||||||
, {SANE_STD_OPT_NAME_HELP , OPTION_TITLE_BZ}
|
|
||||||
, {SANE_STD_OPT_NAME_IS_MULTI_OUT , OPTION_TITLE_DLSC}
|
|
||||||
, {SANE_STD_OPT_NAME_MULTI_OUT_TYPE , OPTION_TITLE_DLSCLX}
|
|
||||||
, {SANE_STD_OPT_NAME_COLOR_MODE , OPTION_TITLE_YSMS}
|
|
||||||
, {SANE_STD_OPT_NAME_BINARY_THRESHOLD , OPTION_TITLE_HBTXYZ}
|
|
||||||
, {SANE_STD_OPT_NAME_REVERSE_01 , OPTION_TITLE_HBTXFSSC}
|
|
||||||
, {SANE_STD_OPT_NAME_FILTER , OPTION_TITLE_HDHHBTX_CSYZQ}
|
|
||||||
, {SANE_STD_OPT_NAME_RID_MULTIOUT_RED , OPTION_TITLE_24WCSTX_DLSCCH}
|
|
||||||
, {SANE_STD_OPT_NAME_RID_ANSWER_SHEET_RED , OPTION_TITLE_24WCSTX_DTKCH}
|
|
||||||
, {SANE_STD_OPT_NAME_ERASE_BACKGROUND , OPTION_TITLE_BJYC}
|
|
||||||
, {SANE_STD_OPT_NAME_BKG_COLOR_RANGE , OPTION_TITLE_BJSCFDFW}
|
|
||||||
, {SANE_STD_OPT_NAME_SHARPEN , OPTION_TITLE_RHYMH}
|
|
||||||
, {SANE_STD_OPT_NAME_RID_MORR , OPTION_TITLE_QCMW}
|
|
||||||
, {SANE_STD_OPT_NAME_RID_GRID , OPTION_TITLE_CWW}
|
|
||||||
, {SANE_STD_OPT_NAME_ERROR_EXTENSION , OPTION_TITLE_CWKS}
|
|
||||||
, {SANE_STD_OPT_NAME_NOISE_OPTIMIZE , OPTION_TITLE_HBTXZDYH}
|
|
||||||
, {SANE_STD_OPT_NAME_NOISE_SIZE , OPTION_TITLE_ZDYHCC}
|
|
||||||
, {SANE_STD_OPT_NAME_PAPER , OPTION_TITLE_ZZCC}
|
|
||||||
, {SANE_STD_OPT_NAME_CUSTOM_AREA , OPTION_TITLE_ZDYSMQY}
|
|
||||||
, {SANE_STD_OPT_NAME_CUSTOM_AREA_LEFT , OPTION_TITLE_SMQYZCmm}
|
|
||||||
, {SANE_STD_OPT_NAME_CUSTOM_AREA_RIGHT , OPTION_TITLE_SMQYYCmm}
|
|
||||||
, {SANE_STD_OPT_NAME_CUSTOM_AREA_TOP , OPTION_TITLE_SMQYSCmm}
|
|
||||||
, {SANE_STD_OPT_NAME_CUSTOM_AREA_BOTTOM , OPTION_TITLE_SMQYXCmm}
|
|
||||||
, {SANE_STD_OPT_NAME_SIZE_CHECK , OPTION_TITLE_CCJC}
|
|
||||||
, {SANE_STD_OPT_NAME_PAGE , OPTION_TITLE_SMYM}
|
|
||||||
, {SANE_STD_OPT_NAME_DISCARD_BLANK_SENS , OPTION_TITLE_TGKBYLMD}
|
|
||||||
, {SANE_STD_OPT_NAME_RESOLUTION , OPTION_TITLE_FBL}
|
|
||||||
, {SANE_STD_OPT_NAME_TIME_TO_SLEEP , OPTION_TITLE_XMSJ}
|
|
||||||
, {SANE_STD_OPT_NAME_IMAGE_QUALITY , OPTION_TITLE_HZ}
|
|
||||||
, {SANE_STD_OPT_NAME_EXCHANGE ,OPTION_TITLE_JHZFM}
|
|
||||||
, {SANE_STD_OPT_NAME_SPLIT ,OPTION_TITLE_TXCF }
|
|
||||||
, {SANE_STD_OPT_NAME_ANTI_SKEW , OPTION_TITLE_ZDJP}
|
|
||||||
, {SANE_STD_OPT_NAME_IS_CUSTOM_GAMMA , OPTION_TITLE_QYSDQX}
|
|
||||||
, {SANE_STD_OPT_NAME_GAMMA , OPTION_TITLE_JMZ}
|
|
||||||
, {SANE_STD_OPT_NAME_BRIGHTNESS , OPTION_TITLE_LDZ}
|
|
||||||
, {SANE_STD_OPT_NAME_CONTRAST , OPTION_TITLE_DBD}
|
|
||||||
, {SANE_STD_OPT_NAME_IS_PHOTO_MODE , OPTION_TITLE_ZPMS}
|
|
||||||
, {SANE_STD_OPT_NAME_ERASE_BLACK_FRAME , OPTION_TITLE_XCHK}
|
|
||||||
, {SANE_STD_OPT_NAME_DARK_SAMPLE , OPTION_TITLE_SSYZ}
|
|
||||||
, {SANE_STD_OPT_NAME_THRESHOLD , OPTION_TITLE_YZ}
|
|
||||||
, {SANE_STD_OPT_NAME_ANTI_NOISE_LEVEL , OPTION_TITLE_BJKZDJ}
|
|
||||||
, {SANE_STD_OPT_NAME_MARGIN , OPTION_TITLE_BYSJ}
|
|
||||||
, {SANE_STD_OPT_NAME_FILL_BKG_MODE , OPTION_TITLE_BJTCFS}
|
|
||||||
, {SANE_STD_OPT_NAME_IS_ANTI_PERMEATE , OPTION_TITLE_FZST}
|
|
||||||
, {SANE_STD_OPT_NAME_ANTI_PERMEATE_LEVEL , OPTION_TITLE_FZSTDJ}
|
|
||||||
, {SANE_STD_OPT_NAME_RID_HOLE_L , OPTION_TITLE_CKYCZC}
|
|
||||||
, {SANE_STD_OPT_NAME_SEARCH_HOLE_RANGE_L , OPTION_TITLE_ZCCKSSFWZFMBL}
|
|
||||||
, {SANE_STD_OPT_NAME_RID_HOLE_R , OPTION_TITLE_CKYCYC}
|
|
||||||
, {SANE_STD_OPT_NAME_SEARCH_HOLE_RANGE_R , OPTION_TITLE_YCCKSSFWZFMBL}
|
|
||||||
, {SANE_STD_OPT_NAME_RID_HOLE_T , OPTION_TITLE_CKYCSC}
|
|
||||||
, {SANE_STD_OPT_NAME_SEARCH_HOLE_RANGE_T , OPTION_TITLE_SCCKSSFWZFMBL}
|
|
||||||
, {SANE_STD_OPT_NAME_RID_HOLE_B , OPTION_TITLE_CKYCXC}
|
|
||||||
, {SANE_STD_OPT_NAME_SEARCH_HOLE_RANGE_B , OPTION_TITLE_XCCKSSFWZFMBL}
|
|
||||||
, {SANE_STD_OPT_NAME_IS_FILL_COLOR , OPTION_TITLE_SCTC}
|
|
||||||
, {SANE_STD_OPT_NAME_IS_ULTROSONIC_CHECK , OPTION_TITLE_CSBJC}
|
|
||||||
, {SANE_STD_OPT_NAME_DOUBLE_FEED_HANDLE , OPTION_TITLE_SZTPCL}
|
|
||||||
, {SANE_STD_OPT_NAME_IS_CHECK_STAPLE , OPTION_TITLE_ZDJC}
|
|
||||||
, {SANE_STD_OPT_NAME_SCAN_MODE , OPTION_TITLE_SMZS}
|
|
||||||
, {SANE_STD_OPT_NAME_SCAN_COUNT , OPTION_TITLE_SMSL}
|
|
||||||
, {SANE_STD_OPT_NAME_TEXT_DIRECTION , OPTION_TITLE_WGFX}
|
|
||||||
, {SANE_STD_OPT_NAME_IS_ROTATE_BKG_180 , OPTION_TITLE_BMXZ180}
|
|
||||||
, {SANE_STD_OPT_NAME_IS_CHECK_DOG_EAR , OPTION_TITLE_ZJJC}
|
|
||||||
, {SANE_STD_OPT_NAME_DOG_EAR_SIZE , OPTION_TITLE_ZJDX}
|
|
||||||
, {SANE_STD_OPT_NAME_IS_CHECK_ASKEW , OPTION_TITLE_WXJC}
|
|
||||||
, {SANE_STD_OPT_NAME_ASKEW_RANGE , OPTION_TITLE_WXRRD}
|
|
||||||
, {SANE_STD_OPT_NAME_FEED_STRENGTH , OPTION_TITLE_FZQD}
|
|
||||||
, {SANE_STD_OPT_NAME_IS_AUTO_FEED_STRENGTH , OPTION_TITLE_ZDFZQD}
|
|
||||||
, {SANE_STD_OPT_NAME_FEED_STRENGTH_VALUE , OPTION_TITLE_JZSBL}
|
|
||||||
, {SANE_STD_OPT_NAME_WAIT_TO_SCAN , OPTION_TITLE_DZSM}
|
|
||||||
, {SANE_STD_OPT_NAME_FOLD_TYPE , OPTION_TITLE_DZMS}
|
|
||||||
},
|
|
||||||
g_discard[] = { {SANE_STD_OPT_NAME_REVERSE_01 , "\351\273\221\347\231\275\345\233\276\345\203\217\345\217\215\350\211\262\350\276\223\345\207\272\357\274\210\346\255\243\345\270\270\351\242\234\350\211\262\344\270\272\357\274\2320-\351\273\221\350\211\262\357\274\2331-\347\231\275\350\211\262\357\274\211"} // 黑白图像反色输出(正常颜色为:0-黑色;1-白色)
|
|
||||||
, {SANE_STD_OPT_NAME_FILTER , "\347\201\260\345\272\246\346\210\226\351\273\221\347\231\275\345\233\276\345\203\217 - \351\231\244\350\211\262"} // 灰度或黑白图像 - 除色
|
|
||||||
, {SANE_STD_OPT_NAME_IS_AUTO_FEED_STRENGTH , "\350\207\252\345\212\250\346\220\223\347\272\270\345\274\272\345\272\246"} // 自动搓纸强度
|
|
||||||
, {SANE_STD_OPT_NAME_FEED_STRENGTH_VALUE , "\346\220\223\347\272\270\351\230\210\345\200\274"} // " 搓纸阈值"
|
|
||||||
};
|
|
||||||
while (*title == ' ')
|
|
||||||
title++;
|
|
||||||
|
|
||||||
for (size_t i = 0; i < _countof(g_opts); ++i)
|
|
||||||
{
|
|
||||||
if (strcmp(title, g_opts[i].title) == 0)
|
|
||||||
return g_opts[i].name;
|
|
||||||
}
|
|
||||||
for (size_t i = 0; i < _countof(g_discard); ++i)
|
|
||||||
{
|
|
||||||
if (strcmp(title, g_discard[i].title) == 0)
|
|
||||||
return g_discard[i].name;
|
|
||||||
}
|
|
||||||
|
|
||||||
return title;
|
|
||||||
}
|
|
||||||
|
|
||||||
public:
|
|
||||||
dev_que() : handle_(nullptr)
|
|
||||||
{}
|
|
||||||
~dev_que()
|
|
||||||
{
|
|
||||||
close_scanner();
|
|
||||||
|
|
||||||
for(auto& v : que_)
|
|
||||||
v.cfg->release();
|
|
||||||
}
|
|
||||||
|
|
||||||
static void update_old_cfg(const char* conf)
|
|
||||||
{
|
|
||||||
gb::scanner_cfg::UDF func;
|
|
||||||
|
|
||||||
func.func_param = nullptr;
|
|
||||||
func.title2name = &dev_que::title_2_name;
|
|
||||||
func.trans_number = &dev_que::trans_number;
|
|
||||||
|
|
||||||
gb::scanner_cfg::update(conf, &func);
|
|
||||||
}
|
|
||||||
static void apply_scheme(SANE_Handle h, gb::sane_config_schm* schm)
|
|
||||||
{
|
|
||||||
SANE_Int count = 0, none = 0;
|
|
||||||
std::string name(""), val("");
|
|
||||||
|
|
||||||
none = sane_io_control(h, IO_CTRL_CODE_RESTORE_SETTINGS, NULL, NULL);
|
|
||||||
if(schm && schm->id_from_name(SANE_STD_OPT_NAME_COLOR_MODE) == -1)
|
|
||||||
{
|
|
||||||
SANE_Int dev_options = 0;
|
|
||||||
sane_control_option(h, 0, SANE_ACTION_GET_VALUE, &dev_options, nullptr);
|
|
||||||
for(int i = 1; i < dev_options; ++i)
|
|
||||||
{
|
|
||||||
const SANE_Option_Descriptor* opt = sane_get_option_descriptor(h, i);
|
|
||||||
if(!opt)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
unsigned int n = i;
|
|
||||||
if(opt->type == SANE_TYPE_BOOL)
|
|
||||||
{
|
|
||||||
SANE_Bool v = SANE_TRUE;
|
|
||||||
sane_io_control(h, IO_CTRL_CODE_GET_DEFAULT_VALUE, &v, &n);
|
|
||||||
schm->set_default_value(i, opt->name, (char*)&v, sizeof(v));
|
|
||||||
}
|
|
||||||
else if (opt->type == SANE_TYPE_INT) {
|
|
||||||
SANE_Int v = 0;
|
|
||||||
sane_io_control(h, IO_CTRL_CODE_GET_DEFAULT_VALUE, &v, &n);
|
|
||||||
schm->set_default_value(i, opt->name, (char*)&v, sizeof(v));
|
|
||||||
}
|
|
||||||
else if(opt->type == SANE_TYPE_FIXED)
|
|
||||||
{
|
|
||||||
SANE_Fixed v = 0;
|
|
||||||
sane_io_control(h, IO_CTRL_CODE_GET_DEFAULT_VALUE, &v, &n);
|
|
||||||
schm->set_default_value(i, opt->name, (char*)&v, sizeof(v));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
char *buf = new char[opt->size + 4];
|
|
||||||
memset(buf, 0, opt->size + 4);
|
|
||||||
sane_io_control(h, IO_CTRL_CODE_GET_DEFAULT_VALUE, buf, &n);
|
|
||||||
std::string langCN(to_default_language(buf, nullptr));
|
|
||||||
schm->set_default_value(i, opt->name, &langCN[0], langCN.length());
|
|
||||||
delete[] buf;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(schm && schm->first_config(name, val))
|
|
||||||
{
|
|
||||||
do
|
|
||||||
{
|
|
||||||
int id = schm->id_from_name(name.c_str());
|
|
||||||
if(id == -1)
|
|
||||||
{
|
|
||||||
if(gb::sane_config_schm::is_option_data(name))
|
|
||||||
{
|
|
||||||
if(name == SANE_STD_OPT_NAME_IS_CUSTOM_GAMMA && val.length() == sizeof(SANE_Gamma))
|
|
||||||
{
|
|
||||||
unsigned int l = val.length();
|
|
||||||
sane_io_control(h, IO_CTRL_CODE_SET_CUSTOM_GAMMA, &val[0], &l);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
const SANE_Option_Descriptor* opt = reinterpret_cast<const SANE_Option_Descriptor*>(sane_get_option_descriptor(h, id));
|
|
||||||
if(opt)
|
|
||||||
{
|
|
||||||
if(opt->type == SANE_TYPE_STRING)
|
|
||||||
{
|
|
||||||
char *buf = new char[opt->size + 4];
|
|
||||||
memset(buf, 0, opt->size + 4);
|
|
||||||
strcpy(buf, val.c_str());
|
|
||||||
std::string langCN(from_default_language(buf, nullptr));
|
|
||||||
sane_control_option(h, id, SANE_ACTION_SET_VALUE, &langCN[0], &none);
|
|
||||||
delete[] buf;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
sane_control_option(h, id, SANE_ACTION_SET_VALUE, &val[0], &none);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}while(schm->next_config(name, val));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public:
|
|
||||||
void set_root_dir(const char* root)
|
|
||||||
{
|
|
||||||
root_dir_ = std::string(root) + PATH_SYMBOL;
|
|
||||||
}
|
|
||||||
void add_scanner(const char* sane_name)
|
|
||||||
{
|
|
||||||
bool found = false;
|
|
||||||
|
|
||||||
for(auto& v: que_)
|
|
||||||
{
|
|
||||||
if(v.name == sane_name)
|
|
||||||
{
|
|
||||||
found = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!found)
|
|
||||||
{
|
|
||||||
SCANNER s;
|
|
||||||
size_t pos = 0;
|
|
||||||
|
|
||||||
s.model = s.name = sane_name;
|
|
||||||
s.cfg = nullptr;
|
|
||||||
pos = s.model.find(" - ");
|
|
||||||
if(pos != std::string::npos)
|
|
||||||
{
|
|
||||||
pos = s.model.find(" - ", pos + 3);
|
|
||||||
if(pos != std::string::npos)
|
|
||||||
s.model.erase(pos);
|
|
||||||
}
|
|
||||||
for(auto& v: que_)
|
|
||||||
{
|
|
||||||
if(v.model == s.model)
|
|
||||||
{
|
|
||||||
s.cfg = v.cfg;
|
|
||||||
s.cfg->add_ref();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!s.cfg)
|
|
||||||
{
|
|
||||||
s.cfg = new gb::scanner_cfg();
|
|
||||||
s.cfg->load_file((root_dir_ + s.model + ".cfg").c_str());
|
|
||||||
}
|
|
||||||
s.online = true;
|
|
||||||
que_.push_back(s);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void get_schemes(const char* scanner_name, std::vector<std::string>& schemes)
|
|
||||||
{
|
|
||||||
schemes.clear();
|
|
||||||
for(auto& v : que_)
|
|
||||||
{
|
|
||||||
if(v.name == scanner_name)
|
|
||||||
{
|
|
||||||
v.cfg->get_all_schemes(schemes);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
SANE_Handle handle(void)
|
|
||||||
{
|
|
||||||
return handle_;
|
|
||||||
}
|
|
||||||
std::string opened_scanner_name(void)
|
|
||||||
{
|
|
||||||
return opened_scanner_;
|
|
||||||
}
|
|
||||||
std::string applied_scheme(void)
|
|
||||||
{
|
|
||||||
return applied_scheme_;
|
|
||||||
}
|
|
||||||
int open_scanner(const char* scanner_name, const char* scheme = nullptr)
|
|
||||||
{
|
|
||||||
SANE_Status statu = SANE_STATUS_GOOD;
|
|
||||||
|
|
||||||
close_scanner();
|
|
||||||
statu = sane_open(scanner_name, &handle_);
|
|
||||||
if(statu == SANE_STATUS_GOOD && handle_)
|
|
||||||
{
|
|
||||||
opened_scanner_ = scanner_name;
|
|
||||||
apply_scheme(scheme);
|
|
||||||
}
|
|
||||||
|
|
||||||
return statu;
|
|
||||||
}
|
|
||||||
int close_scanner(void)
|
|
||||||
{
|
|
||||||
if(handle_)
|
|
||||||
{
|
|
||||||
sane_close(handle_);
|
|
||||||
handle_ = nullptr;
|
|
||||||
opened_scanner_ = "";
|
|
||||||
applied_scheme_ = "";
|
|
||||||
}
|
|
||||||
|
|
||||||
return SANE_STATUS_GOOD;
|
|
||||||
}
|
|
||||||
int scanners(void)
|
|
||||||
{
|
|
||||||
return que_.size();
|
|
||||||
}
|
|
||||||
SCANNER get_at(int pos)
|
|
||||||
{
|
|
||||||
SCANNER s;
|
|
||||||
|
|
||||||
s.name = s.model = "";
|
|
||||||
s.cfg = nullptr;
|
|
||||||
if(pos >= 0 && pos < que_.size())
|
|
||||||
{
|
|
||||||
s = que_[pos];
|
|
||||||
s.cfg->add_ref();
|
|
||||||
}
|
|
||||||
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
bool is_online(const char* scanner = nullptr)
|
|
||||||
{
|
|
||||||
if(!scanner)
|
|
||||||
scanner = opened_scanner_.c_str();
|
|
||||||
|
|
||||||
for(auto& v : que_)
|
|
||||||
{
|
|
||||||
if(v.name == scanner)
|
|
||||||
return v.online;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
void set_online(bool online, const char* scanner = nullptr)
|
|
||||||
{
|
|
||||||
if(!scanner)
|
|
||||||
scanner = opened_scanner_.c_str();
|
|
||||||
|
|
||||||
for(auto& v : que_)
|
|
||||||
{
|
|
||||||
if(v.name == scanner)
|
|
||||||
{
|
|
||||||
v.online = online;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void get_scanners(std::vector<std::string>& que)
|
|
||||||
{
|
|
||||||
for(auto& v: que_)
|
|
||||||
que.push_back(v.name);
|
|
||||||
}
|
|
||||||
int apply_scheme(const char* scheme_name)
|
|
||||||
{
|
|
||||||
if(!handle_)
|
|
||||||
return SCANNER_ERR_NOT_OPEN;
|
|
||||||
|
|
||||||
for(auto& v: que_)
|
|
||||||
{
|
|
||||||
if(v.name == opened_scanner_)
|
|
||||||
{
|
|
||||||
gb::sane_config_schm* schm = v.cfg->get_scheme(scheme_name);
|
|
||||||
dev_que::apply_scheme(handle_, schm);
|
|
||||||
if(schm)
|
|
||||||
{
|
|
||||||
v.cfg->select_scheme(schm->get_scheme_name().c_str());
|
|
||||||
schm->release();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
v.cfg->select_scheme(scheme_name);
|
|
||||||
}
|
|
||||||
applied_scheme_ = v.cfg->get_current_scheme_name();
|
|
||||||
v.cfg->save();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return SCANNER_ERR_OK;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class device_menu : public QMenu
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
typedef struct _pop_menu
|
|
||||||
{
|
|
||||||
QMenu* menu;
|
|
||||||
std::vector<QAction*> actions;
|
|
||||||
|
|
||||||
bool operator==(const QString& menu_title)
|
|
||||||
{
|
|
||||||
return menu->title() == menu_title;
|
|
||||||
}
|
|
||||||
}POPMENU;
|
|
||||||
std::vector<POPMENU> menus_;
|
|
||||||
QAction* cur_action_;
|
|
||||||
QAction* none_action_;
|
|
||||||
QActionGroup* group_action_;
|
|
||||||
std::mutex mutex_;
|
|
||||||
|
|
||||||
QMenu* find_device_menu(const QString& dev_name);
|
|
||||||
QAction* find_device_config(const QString& dev_name, const QString& cfg_name);
|
|
||||||
|
|
||||||
public:
|
|
||||||
device_menu(QWidget* parent = nullptr);
|
|
||||||
device_menu(const QString& title, QWidget* parent = nullptr);
|
|
||||||
|
|
||||||
void deviceMenuUpdate(dev_que* que);
|
|
||||||
|
|
||||||
void connectedDevice(const QString& device);
|
|
||||||
|
|
||||||
void disconnectedDevice(const QString& device);
|
|
||||||
|
|
||||||
void setOptionChecked(const QString& device, const QString& opt, bool checked);
|
|
||||||
|
|
||||||
void get_online_devices(QList<QString>& dev_names);
|
|
||||||
|
|
||||||
signals:
|
|
||||||
void scanOptionsChanged(const QString& device, const QString& opt, bool checked_now);
|
|
||||||
|
|
||||||
private slots:
|
|
||||||
void on_act_triggered(QAction* act);
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // DEVICE_MENU_H
|
|
|
@ -1,51 +0,0 @@
|
||||||
#include "dialog_admin.h"
|
|
||||||
#include "ui_dialog_admin.h"
|
|
||||||
#include <QMessageBox>
|
|
||||||
|
|
||||||
Dialog_Admin::Dialog_Admin(const QString& password, QWidget *parent)
|
|
||||||
: QDialog(parent)
|
|
||||||
, ui(new Ui::Dialog_Admin)
|
|
||||||
{
|
|
||||||
ui->setupUi(this);
|
|
||||||
setWindowFlags(Qt::Dialog | Qt::WindowCloseButtonHint);
|
|
||||||
|
|
||||||
ui->lineEdit->setPlaceholderText(tr("Type password"));
|
|
||||||
ui->lineEdit->setEchoMode(QLineEdit::Password);
|
|
||||||
ui->lineEdit->setMaxLength(20);
|
|
||||||
m_password = password;
|
|
||||||
|
|
||||||
QPixmap pixmap(":images/image_rsc/statusbar/statusBar_admin.png");
|
|
||||||
pixmap = pixmap.scaled(ui->lab_adminIcon->size());
|
|
||||||
ui->lab_adminIcon->setPixmap(pixmap);
|
|
||||||
}
|
|
||||||
|
|
||||||
Dialog_Admin::~Dialog_Admin()
|
|
||||||
{
|
|
||||||
delete ui;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Dialog_Admin::on_btn_signIn_clicked()
|
|
||||||
{
|
|
||||||
if (ui->lineEdit->text() == m_password)
|
|
||||||
done(1);
|
|
||||||
else
|
|
||||||
QMessageBox::warning(this,
|
|
||||||
tr("Warning"),
|
|
||||||
tr("Password incorrect. Please try again."));
|
|
||||||
}
|
|
||||||
|
|
||||||
void Dialog_Admin::on_btn_cancel_clicked()
|
|
||||||
{
|
|
||||||
done(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Dialog_Admin::on_cbtn_showPassword_toggled(bool checked)
|
|
||||||
{
|
|
||||||
ui->lineEdit->setEchoMode(checked ? QLineEdit::Normal : QLineEdit::Password);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Dialog_Admin::on_lineEdit_textChanged(const QString &arg1)
|
|
||||||
{
|
|
||||||
ui->btn_signIn->setEnabled(!arg1.isEmpty());
|
|
||||||
}
|
|
|
@ -1,32 +0,0 @@
|
||||||
#ifndef DIALOG_ADMIN_H
|
|
||||||
#define DIALOG_ADMIN_H
|
|
||||||
|
|
||||||
#include <QDialog>
|
|
||||||
|
|
||||||
namespace Ui {
|
|
||||||
class Dialog_Admin;
|
|
||||||
}
|
|
||||||
|
|
||||||
class Dialog_Admin : public QDialog
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
explicit Dialog_Admin(const QString &password, QWidget *parent = nullptr);
|
|
||||||
~Dialog_Admin();
|
|
||||||
|
|
||||||
private slots:
|
|
||||||
void on_btn_signIn_clicked();
|
|
||||||
|
|
||||||
void on_btn_cancel_clicked();
|
|
||||||
|
|
||||||
void on_cbtn_showPassword_toggled(bool checked);
|
|
||||||
|
|
||||||
void on_lineEdit_textChanged(const QString &arg1);
|
|
||||||
|
|
||||||
private:
|
|
||||||
Ui::Dialog_Admin *ui;
|
|
||||||
QString m_password;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // DIALOG_ADMIN_H
|
|
|
@ -1,142 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<ui version="4.0">
|
|
||||||
<class>Dialog_Admin</class>
|
|
||||||
<widget class="QDialog" name="Dialog_Admin">
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>0</y>
|
|
||||||
<width>379</width>
|
|
||||||
<height>119</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="maximumSize">
|
|
||||||
<size>
|
|
||||||
<width>400</width>
|
|
||||||
<height>130</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="windowTitle">
|
|
||||||
<string>Account sign in</string>
|
|
||||||
</property>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
|
||||||
<item>
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="lab_account">
|
|
||||||
<property name="minimumSize">
|
|
||||||
<size>
|
|
||||||
<width>54</width>
|
|
||||||
<height>0</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Account:</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="lab_adminIcon">
|
|
||||||
<property name="maximumSize">
|
|
||||||
<size>
|
|
||||||
<width>20</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string/>
|
|
||||||
</property>
|
|
||||||
<property name="pixmap">
|
|
||||||
<pixmap>:/images/statusbar/image_rsc/statusbar/statusBar_admin.png</pixmap>
|
|
||||||
</property>
|
|
||||||
<property name="scaledContents">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="lab_accountName">
|
|
||||||
<property name="text">
|
|
||||||
<string>Administrator</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<spacer name="horizontalSpacer_2">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>40</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout" stretch="0,1,0">
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="lab_password">
|
|
||||||
<property name="text">
|
|
||||||
<string>password:</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QLineEdit" name="lineEdit">
|
|
||||||
<property name="echoMode">
|
|
||||||
<enum>QLineEdit::Password</enum>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QCheckBox" name="cbtn_showPassword">
|
|
||||||
<property name="text">
|
|
||||||
<string>Show password</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
|
||||||
<item>
|
|
||||||
<spacer name="horizontalSpacer">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>40</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="btn_signIn">
|
|
||||||
<property name="enabled">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Sign In</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="btn_cancel">
|
|
||||||
<property name="text">
|
|
||||||
<string>Cancel</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
<resources/>
|
|
||||||
<connections/>
|
|
||||||
</ui>
|
|
|
@ -1,530 +0,0 @@
|
||||||
#include "dialog_aquireinto.h"
|
|
||||||
#include "ui_dialog_aquireinto.h"
|
|
||||||
#include "dialog_writesettings.h"
|
|
||||||
#include <QFileDialog>
|
|
||||||
#include <QDateTime>
|
|
||||||
#include <QRegExpValidator>
|
|
||||||
#include <QStandardPaths>
|
|
||||||
#include "base/HGDef.h"
|
|
||||||
#include "base/HGInc.h"
|
|
||||||
#include "base/HGUtility.h"
|
|
||||||
#include "base/HGIni.h"
|
|
||||||
#include "HGUIGlobal.h"
|
|
||||||
#include "HGString.h"
|
|
||||||
#include "app_cfg.h"
|
|
||||||
#include "dialog_input.h"
|
|
||||||
#include <QDebug>
|
|
||||||
#include <QMessageBox>
|
|
||||||
|
|
||||||
Dialog_AquireInto::Dialog_AquireInto(QWidget* parent) :
|
|
||||||
QDialog(parent),
|
|
||||||
ui(new Ui::Dialog_AquireInto)
|
|
||||||
{
|
|
||||||
ui->setupUi(this);
|
|
||||||
|
|
||||||
setWindowFlags(Qt::Dialog | Qt::WindowCloseButtonHint);
|
|
||||||
|
|
||||||
QRegExp rx("[^\\\\/:*?\"<>|]+$");
|
|
||||||
ui->lineEdit_fileName->setValidator(new QRegExpValidator(rx, this));
|
|
||||||
|
|
||||||
ui->comboBox_cfgScheme->addItem(tr("default scheme"));
|
|
||||||
|
|
||||||
QString allCfgName = getCfgValue("aquire", "cfgNameList", QString(""));
|
|
||||||
QStringList allCfgNameList = allCfgName.split(",");
|
|
||||||
if (!allCfgNameList.contains(QString("")))
|
|
||||||
{
|
|
||||||
ui->comboBox_cfgScheme->addItems(allCfgNameList);
|
|
||||||
ui->comboBox_cfgScheme->setCurrentText(getCurrentCfgName());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
allCfgNameList.removeOne(QString(""));
|
|
||||||
ui->comboBox_cfgScheme->setCurrentIndex(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
setCfgBaseOnSection(getCurrentCfgName());
|
|
||||||
|
|
||||||
ui->lab_digitExp->setText(QString(tr("e.g. '%1%2'")).arg(ui->lineEdit_fileName->text())
|
|
||||||
.arg(ui->spin_index->value(), ui->cbox_digit->currentIndex() + 1, 10, QLatin1Char('0')));
|
|
||||||
ui->btn_option->setEnabled(0 == ui->cbox_format->currentIndex() || 6 == ui->cbox_format->currentIndex());
|
|
||||||
ui->cbtn_multiFile->setEnabled(ui->cbox_format->currentIndex() > 5 && ui->cbox_format->currentIndex() < 10); //Ocr does not export multiple pages
|
|
||||||
ui->radio_multiAll->setEnabled(ui->cbtn_multiFile->isChecked());
|
|
||||||
ui->radio_multiCustom->setEnabled(ui->cbtn_multiFile->isChecked());
|
|
||||||
ui->spinBox_multiPages->setEnabled(ui->cbtn_multiFile->isChecked() ? ui->radio_multiCustom->isChecked() : false);
|
|
||||||
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(!ui->lineEdit_directory->text().isEmpty());
|
|
||||||
|
|
||||||
ui->buttonBox->button(QDialogButtonBox::Ok)->setText(tr("ok"));
|
|
||||||
ui->buttonBox->button(QDialogButtonBox::Cancel)->setText(tr("cancel"));
|
|
||||||
|
|
||||||
ui->spin_index->setFixedWidth(160);
|
|
||||||
ui->cbox_digit->setFixedWidth(80);
|
|
||||||
}
|
|
||||||
|
|
||||||
Dialog_AquireInto::~Dialog_AquireInto()
|
|
||||||
{
|
|
||||||
delete ui;
|
|
||||||
}
|
|
||||||
|
|
||||||
AquireIntoSaveParam Dialog_AquireInto::getSaveParam()
|
|
||||||
{
|
|
||||||
AquireIntoSaveParam param;
|
|
||||||
param.m_savePath = ui->lineEdit_directory->text();
|
|
||||||
param.m_isUseSubfolderByTime = ui->cbtn_subFolder->isChecked();
|
|
||||||
param.m_isUseSubfolderByBlankPages = ui->cbtn_subFolderByBlank->isChecked();
|
|
||||||
param.m_isUseSubfolderByColor = ui->cbtn_subFolderByColor->isChecked();
|
|
||||||
param.m_jpegQuality = getCfgValue("saveParam", "jpegQuality", 80);
|
|
||||||
param.m_tiffCompressionBW = getCfgValue("saveParam", "tiffCompBW", 1);
|
|
||||||
param.m_tiffCompression = getCfgValue("saveParam", "tiffCompClr", 1);
|
|
||||||
param.m_tiffQuality = getCfgValue("saveParam", "tiffQuality", 80);
|
|
||||||
param.m_fileNamePrefix = ui->lineEdit_fileName->text();
|
|
||||||
param.m_fileNameStartIndex = ui->spin_index->value();
|
|
||||||
param.m_fileNameDigits = ui->cbox_digit->currentIndex() + 1;
|
|
||||||
param.m_fileNameOddEventType = ui->cbox_evenOdd->currentIndex();
|
|
||||||
|
|
||||||
QString format = "jpg";
|
|
||||||
switch (ui->cbox_format->currentIndex())
|
|
||||||
{
|
|
||||||
case 1:
|
|
||||||
format = "bmp";
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
format = "png";
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
format = "ppm";
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
format = "pgm";
|
|
||||||
break;
|
|
||||||
case 5:
|
|
||||||
format = "pbm";
|
|
||||||
break;
|
|
||||||
case 6:
|
|
||||||
format = "tif";
|
|
||||||
break;
|
|
||||||
case 7:
|
|
||||||
format = "pdf";
|
|
||||||
break;
|
|
||||||
case 8:
|
|
||||||
format = "ofd";
|
|
||||||
break;
|
|
||||||
case 9:
|
|
||||||
format = "gif";
|
|
||||||
break;
|
|
||||||
case 10:
|
|
||||||
format = "pdf";
|
|
||||||
break;
|
|
||||||
case 11:
|
|
||||||
format = "ofd";
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
param.m_fileNameExt = format;
|
|
||||||
param.m_isOcr = (ui->cbox_format->currentIndex() >= 10);
|
|
||||||
|
|
||||||
param.m_isSaveAsMultiPage = ui->cbtn_multiFile->isChecked();
|
|
||||||
param.m_multiPagesType = (ui->radio_multiAll->isChecked()) ? 0 : 1;
|
|
||||||
param.m_customMultiPages = ui->spinBox_multiPages->value();
|
|
||||||
return param;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Dialog_AquireInto::setConfig(QString schemeName)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < ui->comboBox_cfgScheme->count(); ++i)
|
|
||||||
{
|
|
||||||
if (ui->comboBox_cfgScheme->itemText(i) == schemeName)
|
|
||||||
{
|
|
||||||
setCfgBaseOnSection(schemeName);
|
|
||||||
saveCfgValue("aquire", "currentKeyName", schemeName);
|
|
||||||
saveCfgBaseOnSection(schemeName);
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
QString Dialog_AquireInto::getCurrentCfgName()
|
|
||||||
{
|
|
||||||
return getCfgValue("aquire", "currentKeyName", QString("aquire"));
|
|
||||||
}
|
|
||||||
|
|
||||||
void Dialog_AquireInto::replaceCfgName(QString originName, QString newName)
|
|
||||||
{
|
|
||||||
HGChar cfgPath[512];
|
|
||||||
HGBase_GetConfigPath(cfgPath, 512);
|
|
||||||
strcat(cfgPath, "config.ini");
|
|
||||||
|
|
||||||
QString currentKeyName = getCurrentCfgName();
|
|
||||||
if (currentKeyName == originName)
|
|
||||||
{
|
|
||||||
saveCfgValue("aquire", "currentKeyName", newName);
|
|
||||||
}
|
|
||||||
|
|
||||||
QString allCfgName = getCfgValue("aquire", "cfgNameList", QString(""));
|
|
||||||
QStringList allCfgNameList = allCfgName.split(",");
|
|
||||||
for (int i = 0; i < allCfgNameList.size(); ++i)
|
|
||||||
{
|
|
||||||
if (allCfgNameList[i] == originName)
|
|
||||||
{
|
|
||||||
allCfgNameList.replace(i, newName);
|
|
||||||
HGBase_RenameProfileSection(cfgPath, originName.toLocal8Bit().toStdString().c_str(), newName.toLocal8Bit().toStdString().c_str());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
QString cfgNameList;
|
|
||||||
saveCfgValue("aquire", "cfgNameList", QString(""));
|
|
||||||
for (int j = 0; j < allCfgNameList.size(); ++j)
|
|
||||||
{
|
|
||||||
if (getCfgValue("aquire", "cfgNameList", QString("")).isEmpty())
|
|
||||||
{
|
|
||||||
saveCfgValue("aquire", "cfgNameList", allCfgNameList[j]);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
cfgNameList = getCfgValue("aquire", "cfgNameList", QString(""));
|
|
||||||
cfgNameList.append(",").append(allCfgNameList[j]);
|
|
||||||
saveCfgValue("aquire", "cfgNameList", cfgNameList);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Dialog_AquireInto::saveCfgBaseOnSection(QString section)
|
|
||||||
{
|
|
||||||
std::string section2 = section.toLocal8Bit().toStdString();
|
|
||||||
|
|
||||||
saveCfgValue(section2.c_str(), "aquireIntoPath", ui->lineEdit_directory->text());
|
|
||||||
saveCfgValue(section2.c_str(), "namePrefix", ui->lineEdit_fileName->text());
|
|
||||||
saveCfgValue(section2.c_str(), "subFolderByTime", ui->cbtn_subFolder->isChecked());
|
|
||||||
saveCfgValue(section2.c_str(), "subFolderByBlank", ui->cbtn_subFolderByBlank->isChecked());
|
|
||||||
saveCfgValue(section2.c_str(), "subFolderByColor", ui->cbtn_subFolderByColor->isChecked());
|
|
||||||
saveCfgValue(section2.c_str(), "startIndex", ui->spin_index->value());
|
|
||||||
saveCfgValue(section2.c_str(), "digit", ui->cbox_digit->currentIndex());
|
|
||||||
saveCfgValue(section2.c_str(), "evenOdd", ui->cbox_evenOdd->currentIndex());
|
|
||||||
saveCfgValue(section2.c_str(), "format", ui->cbox_format->currentIndex());
|
|
||||||
saveCfgValue(section2.c_str(), "multiFile", ui->cbtn_multiFile->isChecked());
|
|
||||||
saveCfgValue(section2.c_str(), "multiAll", ui->radio_multiAll->isChecked());
|
|
||||||
saveCfgValue(section2.c_str(), "multiPages", ui->spinBox_multiPages->value());
|
|
||||||
saveCfgValue(section2.c_str(), "multiCustom", ui->radio_multiCustom->isChecked());
|
|
||||||
}
|
|
||||||
|
|
||||||
void Dialog_AquireInto::setCfgBaseOnSection(QString section)
|
|
||||||
{
|
|
||||||
HGChar aquireIntoPath[512];
|
|
||||||
HGBase_GetDocumentsPath(aquireIntoPath, 512);
|
|
||||||
HGChar procName[512];
|
|
||||||
HGBase_GetProcessName(procName, 512);
|
|
||||||
strcat(aquireIntoPath, procName);
|
|
||||||
strcat(aquireIntoPath, "/AquireInto/");
|
|
||||||
QString filePath = getStdFileName(StdStringToUtf8(aquireIntoPath).c_str());
|
|
||||||
|
|
||||||
std::string section2 = section.toLocal8Bit().toStdString();
|
|
||||||
|
|
||||||
ui->lineEdit_directory->setText(getCfgValue(section2.c_str(), "aquireIntoPath", filePath));
|
|
||||||
ui->cbtn_subFolder->setChecked(getCfgValue(section2.c_str(), "subFolderByTime", false));
|
|
||||||
ui->cbtn_subFolderByBlank->setChecked(getCfgValue(section2.c_str(), "subFolderByBlank", false));
|
|
||||||
ui->cbtn_subFolderByColor->setChecked(getCfgValue(section2.c_str(), "subFolderByColor", false));
|
|
||||||
#if defined(OEM_HANWANG)
|
|
||||||
ui->lineEdit_fileName->setText(getCfgValue(section2.c_str(), "namePrefix", QString("HWScan")));
|
|
||||||
#elif defined(OEM_LISICHENG)
|
|
||||||
ui->lineEdit_fileName->setText(getCfgValue(section2.c_str(), "namePrefix", QString("LXScan")));
|
|
||||||
#elif defined(OEM_CANGTIAN)
|
|
||||||
ui->lineEdit_fileName->setText(getCfgValue(section2.c_str(), "namePrefix", QString("CTSScan")));
|
|
||||||
#elif defined(OEM_ZHONGJING)
|
|
||||||
ui->lineEdit_fileName->setText(getCfgValue(section2.c_str(), "namePrefix", QString("ZJScan")));
|
|
||||||
#elif defined(OEM_ZIGUANG)
|
|
||||||
ui->lineEdit_fileName->setText(getCfgValue(section2.c_str(), "namePrefix", QString("ZGScan")));
|
|
||||||
#elif defined(OEM_NEUTRAL)
|
|
||||||
ui->lineEdit_fileName->setText(getCfgValue(section2.c_str(), "namePrefix", QString("Scan")));
|
|
||||||
#elif defined(OEM_DELI)
|
|
||||||
ui->lineEdit_fileName->setText(getCfgValue(section2.c_str(), "namePrefix", QString("DLScan")));
|
|
||||||
#else
|
|
||||||
ui->lineEdit_fileName->setText(getCfgValue(section2.c_str(), "namePrefix", QString("HGScan")));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
ui->spin_index->setValue(getCfgValue(section2.c_str(), "startIndex", 1));
|
|
||||||
ui->cbox_digit->setCurrentIndex(getCfgValue(section2.c_str(), "digit", 2));
|
|
||||||
ui->cbox_evenOdd->setCurrentIndex(getCfgValue(section2.c_str(), "evenOdd", 0));
|
|
||||||
int format = getCfgValue(section2.c_str(), "format", 0);
|
|
||||||
if (format > 9)
|
|
||||||
format = 0;
|
|
||||||
ui->cbox_format->setCurrentIndex(format);
|
|
||||||
ui->cbtn_multiFile->setChecked(format > 5 ? getCfgValue(section2.c_str(), "multiFile", false) : false);
|
|
||||||
ui->radio_multiAll->setChecked(getCfgValue(section2.c_str(), "multiAll", true));
|
|
||||||
ui->radio_multiCustom->setChecked(getCfgValue(section2.c_str(), "multiCustom", false));
|
|
||||||
ui->spinBox_multiPages->setValue(getCfgValue(section2.c_str(), "multiPages", 1));
|
|
||||||
}
|
|
||||||
|
|
||||||
void Dialog_AquireInto::on_btn_directory_clicked()
|
|
||||||
{
|
|
||||||
QString save_dir = QFileDialog::getExistingDirectory(this, tr("Browse directory"), "");
|
|
||||||
if (!save_dir.isEmpty())
|
|
||||||
{
|
|
||||||
if (save_dir[save_dir.size() - 1] != '/')
|
|
||||||
save_dir += "/";
|
|
||||||
ui->lineEdit_directory->setText(getStdFileName(save_dir));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Dialog_AquireInto::on_btn_option_clicked()
|
|
||||||
{
|
|
||||||
Dialog_WriteSettings dlg(ui->cbox_format->currentIndex(), this);
|
|
||||||
dlg.exec();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Dialog_AquireInto::on_cbox_format_currentIndexChanged(int index)
|
|
||||||
{
|
|
||||||
ui->cbtn_multiFile->setEnabled(index > 5 && index < 10);
|
|
||||||
if (index < 6 || index >= 10 )
|
|
||||||
ui->cbtn_multiFile->setChecked(false);
|
|
||||||
|
|
||||||
ui->btn_option->setEnabled(0 == index || 6 == index || 7 == index || 8 == index);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Dialog_AquireInto::on_lineEdit_directory_textChanged(const QString& arg1)
|
|
||||||
{
|
|
||||||
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(!arg1.isEmpty());
|
|
||||||
}
|
|
||||||
|
|
||||||
void Dialog_AquireInto::on_buttonBox_accepted()
|
|
||||||
{
|
|
||||||
QString currentCfgName = ui->comboBox_cfgScheme->currentText();
|
|
||||||
|
|
||||||
if (ui->comboBox_cfgScheme->currentIndex() != 0)
|
|
||||||
{
|
|
||||||
if (getCfgValue("aquire", "cfgNameList", QString("")).isEmpty())
|
|
||||||
{
|
|
||||||
saveCfgValue("aquire", "cfgNameList", currentCfgName);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
QString allCfgName = getCfgValue("aquire", "cfgNameList", QString(""));
|
|
||||||
QStringList allCfgNameList = allCfgName.split(",");
|
|
||||||
if (!allCfgNameList.contains(currentCfgName))
|
|
||||||
{
|
|
||||||
allCfgName.append(",").append(currentCfgName);
|
|
||||||
saveCfgValue("aquire", "cfgNameList", allCfgName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
saveCfgBaseOnSection(currentCfgName);
|
|
||||||
saveCfgValue("aquire", "currentKeyName", currentCfgName);
|
|
||||||
|
|
||||||
emit reloadAcquireIntoCfg();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Dialog_AquireInto::on_cbox_digit_currentIndexChanged(int index)
|
|
||||||
{
|
|
||||||
(void)index;
|
|
||||||
ui->lab_digitExp->setText(QString(tr("e.g. '%1%2'")).arg(ui->lineEdit_fileName->text()).
|
|
||||||
arg(ui->spin_index->value(), ui->cbox_digit->currentIndex() + 1, 10, QLatin1Char('0')));
|
|
||||||
}
|
|
||||||
|
|
||||||
void Dialog_AquireInto::on_cbtn_multiFile_toggled(bool checked)
|
|
||||||
{
|
|
||||||
if (checked)
|
|
||||||
{
|
|
||||||
ui->spinBox_multiPages->setEnabled(ui->radio_multiCustom->isChecked());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ui->spinBox_multiPages->setEnabled(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
ui->radio_multiAll->setEnabled(checked);
|
|
||||||
ui->radio_multiCustom->setEnabled(checked);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Dialog_AquireInto::on_radio_multiCustom_toggled(bool checked)
|
|
||||||
{
|
|
||||||
ui->spinBox_multiPages->setEnabled(checked && ui->cbtn_multiFile->isEnabled());
|
|
||||||
}
|
|
||||||
|
|
||||||
void Dialog_AquireInto::on_lineEdit_fileName_textChanged(const QString &arg1)
|
|
||||||
{
|
|
||||||
(void)arg1;
|
|
||||||
ui->lab_digitExp->setText(QString(tr("e.g. '%1%2'")).arg(ui->lineEdit_fileName->text()).
|
|
||||||
arg(ui->spin_index->value(), ui->cbox_digit->currentIndex() + 1, 10, QLatin1Char('0')));
|
|
||||||
}
|
|
||||||
|
|
||||||
void Dialog_AquireInto::on_spin_index_valueChanged(int arg1)
|
|
||||||
{
|
|
||||||
(void)arg1;
|
|
||||||
ui->lab_digitExp->setText(QString(tr("e.g. '%1%2'")).arg(ui->lineEdit_fileName->text()).
|
|
||||||
arg(ui->spin_index->value(), ui->cbox_digit->currentIndex() + 1, 10, QLatin1Char('0')));
|
|
||||||
}
|
|
||||||
|
|
||||||
void Dialog_AquireInto::on_pbtn_changeName_clicked()
|
|
||||||
{
|
|
||||||
QString curCfgName = ui->comboBox_cfgScheme->currentText();
|
|
||||||
Dialog_Input dlg;
|
|
||||||
dlg.setEditText(curCfgName);
|
|
||||||
if (dlg.exec())
|
|
||||||
{
|
|
||||||
QString newCfgName = dlg.getText();
|
|
||||||
|
|
||||||
for (int i = 0; i < ui->comboBox_cfgScheme->count(); ++i)
|
|
||||||
{
|
|
||||||
if (newCfgName == ui->comboBox_cfgScheme->itemText(i))
|
|
||||||
{
|
|
||||||
QMessageBox::information(this, tr("tips"), tr("The configuration scheme already exists"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int count = ui->comboBox_cfgScheme->count();
|
|
||||||
for (int i = 0; i < count; ++i)
|
|
||||||
{
|
|
||||||
if (ui->comboBox_cfgScheme->itemText(i) == curCfgName)
|
|
||||||
{
|
|
||||||
ui->comboBox_cfgScheme->removeItem(i);
|
|
||||||
ui->comboBox_cfgScheme->insertItem(i, newCfgName);
|
|
||||||
ui->comboBox_cfgScheme->setCurrentText(newCfgName);
|
|
||||||
replaceCfgName(curCfgName, newCfgName);
|
|
||||||
setCfgBaseOnSection(newCfgName);
|
|
||||||
emit reloadAcquireIntoCfg();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Dialog_AquireInto::on_pbtn_delete_clicked()
|
|
||||||
{
|
|
||||||
HGChar cfgPath[512];
|
|
||||||
HGBase_GetConfigPath(cfgPath, 512);
|
|
||||||
strcat(cfgPath, "config.ini");
|
|
||||||
|
|
||||||
QString selectedCfgName = ui->comboBox_cfgScheme->currentText();
|
|
||||||
int count = ui->comboBox_cfgScheme->count();
|
|
||||||
for (int i = 0; i < count; ++i)
|
|
||||||
{
|
|
||||||
if (ui->comboBox_cfgScheme->itemText(i) == selectedCfgName)
|
|
||||||
{
|
|
||||||
ui->comboBox_cfgScheme->removeItem(i);
|
|
||||||
QString allCfgName = getCfgValue("aquire", "cfgNameList", QString(""));
|
|
||||||
QStringList allCfgNameList = allCfgName.split(",");
|
|
||||||
allCfgNameList.removeOne(selectedCfgName);
|
|
||||||
|
|
||||||
QString cfgNameList;
|
|
||||||
saveCfgValue("aquire", "cfgNameList", QString(""));
|
|
||||||
for (int j = 0; j < allCfgNameList.size(); ++j)
|
|
||||||
{
|
|
||||||
if (getCfgValue("aquire", "cfgNameList", QString("")).isEmpty())
|
|
||||||
{
|
|
||||||
saveCfgValue("aquire", "cfgNameList", allCfgNameList[j]);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
cfgNameList = getCfgValue("aquire", "cfgNameList", QString(""));
|
|
||||||
cfgNameList.append(",").append(allCfgNameList[j]);
|
|
||||||
saveCfgValue("aquire", "cfgNameList", cfgNameList);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
HGBase_RemoveProfileSection(cfgPath, selectedCfgName.toLocal8Bit().toStdString().c_str());
|
|
||||||
|
|
||||||
ui->comboBox_cfgScheme->setCurrentIndex(0);
|
|
||||||
QString defaultScheme = ui->comboBox_cfgScheme->itemText(0);
|
|
||||||
saveCfgValue("aquire", "currentKeyName", defaultScheme);
|
|
||||||
setCfgBaseOnSection(defaultScheme);
|
|
||||||
|
|
||||||
emit reloadAcquireIntoCfg();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Dialog_AquireInto::on_pbtn_deleteAll_clicked()
|
|
||||||
{
|
|
||||||
HGChar cfgPath[512];
|
|
||||||
HGBase_GetConfigPath(cfgPath, 512);
|
|
||||||
strcat(cfgPath, "config.ini");
|
|
||||||
|
|
||||||
ui->comboBox_cfgScheme->clear();
|
|
||||||
ui->comboBox_cfgScheme->addItem(tr("default scheme"));
|
|
||||||
|
|
||||||
QString allCfgName = getCfgValue("aquire", "cfgNameList", QString(""));
|
|
||||||
QStringList allCfgNameList = allCfgName.split(",");
|
|
||||||
for (int i = 0; i < allCfgNameList.size(); ++i)
|
|
||||||
{
|
|
||||||
std::string section = allCfgNameList[i].toLocal8Bit().toStdString();
|
|
||||||
HGBase_RemoveProfileSection(cfgPath, section.c_str());
|
|
||||||
}
|
|
||||||
|
|
||||||
saveCfgValue("aquire", "cfgNameList", QString(""));
|
|
||||||
ui->comboBox_cfgScheme->setCurrentIndex(0);
|
|
||||||
QString defaultScheme = ui->comboBox_cfgScheme->itemText(0);
|
|
||||||
saveCfgValue("aquire", "currentKeyName", defaultScheme);
|
|
||||||
setCfgBaseOnSection(defaultScheme);
|
|
||||||
|
|
||||||
emit reloadAcquireIntoCfg();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Dialog_AquireInto::on_comboBox_cfgScheme_currentTextChanged(const QString &arg1)
|
|
||||||
{
|
|
||||||
ui->pbtn_changeName->setEnabled(true);
|
|
||||||
ui->pbtn_delete->setEnabled(true);
|
|
||||||
|
|
||||||
if (ui->comboBox_cfgScheme->currentIndex() == 0)
|
|
||||||
{
|
|
||||||
ui->pbtn_changeName->setEnabled(false);
|
|
||||||
ui->pbtn_delete->setEnabled(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
setCfgBaseOnSection(arg1);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Dialog_AquireInto::on_pbtn_foundScheme_clicked()
|
|
||||||
{
|
|
||||||
QString cfgName = getCurrentCfgName();
|
|
||||||
if(cfgName.isEmpty())
|
|
||||||
{
|
|
||||||
cfgName = ui->comboBox_cfgScheme->currentText();
|
|
||||||
}
|
|
||||||
|
|
||||||
Dialog_Input dlg;
|
|
||||||
dlg.setEditText(cfgName);
|
|
||||||
if (dlg.exec())
|
|
||||||
{
|
|
||||||
cfgName = dlg.getText();
|
|
||||||
|
|
||||||
for (int i = 0; i < ui->comboBox_cfgScheme->count(); ++i)
|
|
||||||
{
|
|
||||||
if (cfgName == ui->comboBox_cfgScheme->itemText(i))
|
|
||||||
{
|
|
||||||
QMessageBox::information(this, tr("tips"), tr("The configuration scheme already exists"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ui->comboBox_cfgScheme->addItem(cfgName);
|
|
||||||
|
|
||||||
if (getCfgValue("aquire", "cfgNameList", QString("")).isEmpty())
|
|
||||||
{
|
|
||||||
saveCfgValue("aquire", "cfgNameList", cfgName);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
QString allCfgName = getCfgValue("aquire", "cfgNameList", QString(""));
|
|
||||||
QStringList allCfgNameList = allCfgName.split(",");
|
|
||||||
if (!allCfgNameList.contains(cfgName))
|
|
||||||
{
|
|
||||||
allCfgName.append(",").append(cfgName);
|
|
||||||
saveCfgValue("aquire", "cfgNameList", allCfgName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
saveCfgBaseOnSection(cfgName);
|
|
||||||
setCfgBaseOnSection(cfgName);
|
|
||||||
ui->comboBox_cfgScheme->setCurrentText(cfgName);
|
|
||||||
emit reloadAcquireIntoCfg();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Dialog_AquireInto::on_pbtn_restore_clicked()
|
|
||||||
{
|
|
||||||
setCfgBaseOnSection(QString(""));
|
|
||||||
}
|
|
|
@ -1,90 +0,0 @@
|
||||||
#ifndef DIALOG_AQUIREINTO_H
|
|
||||||
#define DIALOG_AQUIREINTO_H
|
|
||||||
|
|
||||||
#include <QDialog>
|
|
||||||
|
|
||||||
class QRegExpValidator;
|
|
||||||
namespace Ui {
|
|
||||||
class Dialog_AquireInto;
|
|
||||||
}
|
|
||||||
|
|
||||||
class AquireIntoSaveParam
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
QString m_savePath;
|
|
||||||
bool m_isUseSubfolderByTime;
|
|
||||||
bool m_isUseSubfolderByBlankPages;
|
|
||||||
bool m_isUseSubfolderByColor;
|
|
||||||
int m_jpegQuality;
|
|
||||||
int m_tiffCompressionBW;
|
|
||||||
int m_tiffCompression;
|
|
||||||
int m_tiffQuality;
|
|
||||||
QString m_fileNamePrefix;
|
|
||||||
int m_fileNameStartIndex;
|
|
||||||
int m_fileNameDigits;
|
|
||||||
int m_fileNameOddEventType;
|
|
||||||
QString m_fileNameExt;
|
|
||||||
bool m_isOcr;
|
|
||||||
bool m_isSaveAsMultiPage;
|
|
||||||
int m_multiPagesType;
|
|
||||||
int m_customMultiPages;
|
|
||||||
};
|
|
||||||
|
|
||||||
class Dialog_AquireInto : public QDialog
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
explicit Dialog_AquireInto(QWidget* parent = nullptr);
|
|
||||||
~Dialog_AquireInto();
|
|
||||||
|
|
||||||
AquireIntoSaveParam getSaveParam();
|
|
||||||
void setConfig(QString schemeName);
|
|
||||||
|
|
||||||
private:
|
|
||||||
QString getCurrentCfgName();
|
|
||||||
void replaceCfgName(QString originName, QString newName);
|
|
||||||
void saveCfgBaseOnSection(QString section);
|
|
||||||
void setCfgBaseOnSection(QString section);
|
|
||||||
|
|
||||||
signals:
|
|
||||||
void reloadAcquireIntoCfg();
|
|
||||||
|
|
||||||
private slots:
|
|
||||||
void on_btn_directory_clicked();
|
|
||||||
|
|
||||||
void on_btn_option_clicked();
|
|
||||||
|
|
||||||
void on_cbox_format_currentIndexChanged(int index);
|
|
||||||
|
|
||||||
void on_lineEdit_directory_textChanged(const QString& arg1);
|
|
||||||
|
|
||||||
void on_buttonBox_accepted();
|
|
||||||
|
|
||||||
void on_cbox_digit_currentIndexChanged(int index);
|
|
||||||
|
|
||||||
void on_cbtn_multiFile_toggled(bool checked);
|
|
||||||
|
|
||||||
void on_radio_multiCustom_toggled(bool checked);
|
|
||||||
|
|
||||||
void on_lineEdit_fileName_textChanged(const QString &arg1);
|
|
||||||
|
|
||||||
void on_spin_index_valueChanged(int arg1);
|
|
||||||
|
|
||||||
void on_pbtn_changeName_clicked();
|
|
||||||
|
|
||||||
void on_pbtn_delete_clicked();
|
|
||||||
|
|
||||||
void on_pbtn_deleteAll_clicked();
|
|
||||||
|
|
||||||
void on_comboBox_cfgScheme_currentTextChanged(const QString &arg1);
|
|
||||||
|
|
||||||
void on_pbtn_foundScheme_clicked();
|
|
||||||
|
|
||||||
void on_pbtn_restore_clicked();
|
|
||||||
|
|
||||||
private:
|
|
||||||
Ui::Dialog_AquireInto* ui;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // DIALOG_AQUIREINTO_H
|
|
|
@ -1,570 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<ui version="4.0">
|
|
||||||
<class>Dialog_AquireInto</class>
|
|
||||||
<widget class="QDialog" name="Dialog_AquireInto">
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>0</y>
|
|
||||||
<width>699</width>
|
|
||||||
<height>398</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="maximumSize">
|
|
||||||
<size>
|
|
||||||
<width>16777215</width>
|
|
||||||
<height>16777215</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="windowTitle">
|
|
||||||
<string>Batch scanning</string>
|
|
||||||
</property>
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_8">
|
|
||||||
<item>
|
|
||||||
<widget class="QGroupBox" name="groupBox_2">
|
|
||||||
<property name="maximumSize">
|
|
||||||
<size>
|
|
||||||
<width>211</width>
|
|
||||||
<height>16777215</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="title">
|
|
||||||
<string>configuration scheme management</string>
|
|
||||||
</property>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="label">
|
|
||||||
<property name="text">
|
|
||||||
<string>existing configuration scheme</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QComboBox" name="comboBox_cfgScheme">
|
|
||||||
<property name="minimumSize">
|
|
||||||
<size>
|
|
||||||
<width>0</width>
|
|
||||||
<height>31</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="maximumSize">
|
|
||||||
<size>
|
|
||||||
<width>16777215</width>
|
|
||||||
<height>16777215</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_7">
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="pbtn_foundScheme">
|
|
||||||
<property name="minimumSize">
|
|
||||||
<size>
|
|
||||||
<width>0</width>
|
|
||||||
<height>31</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>found scheme</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="pbtn_changeName">
|
|
||||||
<property name="minimumSize">
|
|
||||||
<size>
|
|
||||||
<width>0</width>
|
|
||||||
<height>31</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="maximumSize">
|
|
||||||
<size>
|
|
||||||
<width>16777215</width>
|
|
||||||
<height>16777215</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>change name</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_9">
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="pbtn_delete">
|
|
||||||
<property name="minimumSize">
|
|
||||||
<size>
|
|
||||||
<width>0</width>
|
|
||||||
<height>31</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="maximumSize">
|
|
||||||
<size>
|
|
||||||
<width>16777215</width>
|
|
||||||
<height>16777215</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>delete</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="pbtn_deleteAll">
|
|
||||||
<property name="minimumSize">
|
|
||||||
<size>
|
|
||||||
<width>0</width>
|
|
||||||
<height>31</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="maximumSize">
|
|
||||||
<size>
|
|
||||||
<width>16777215</width>
|
|
||||||
<height>16777215</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>delete all configurations</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="pbtn_restore">
|
|
||||||
<property name="minimumSize">
|
|
||||||
<size>
|
|
||||||
<width>0</width>
|
|
||||||
<height>31</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Restore Defaults</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<spacer name="verticalSpacer">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Vertical</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>17</width>
|
|
||||||
<height>279</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QWidget" name="widget" native="true">
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
|
||||||
<item>
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="lab_directory">
|
|
||||||
<property name="text">
|
|
||||||
<string>Directory</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QLineEdit" name="lineEdit_directory">
|
|
||||||
<property name="readOnly">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QToolButton" name="btn_directory">
|
|
||||||
<property name="text">
|
|
||||||
<string>...</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QCheckBox" name="cbtn_subFolder">
|
|
||||||
<property name="text">
|
|
||||||
<string>Use subfolder based on current date</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QCheckBox" name="cbtn_subFolderByBlank">
|
|
||||||
<property name="text">
|
|
||||||
<string>Use subfolder based on blank pages</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QCheckBox" name="cbtn_subFolderByColor">
|
|
||||||
<property name="text">
|
|
||||||
<string>Use subfolder based on image color type</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="lab_fileName">
|
|
||||||
<property name="text">
|
|
||||||
<string>File name</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QLineEdit" name="lineEdit_fileName"/>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<spacer name="horizontalSpacer">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>40</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QGroupBox" name="groupBox">
|
|
||||||
<property name="title">
|
|
||||||
<string>File name index</string>
|
|
||||||
</property>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
|
||||||
<item>
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="lab_startIndex">
|
|
||||||
<property name="text">
|
|
||||||
<string>Start index</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QSpinBox" name="spin_index">
|
|
||||||
<property name="minimumSize">
|
|
||||||
<size>
|
|
||||||
<width>0</width>
|
|
||||||
<height>0</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="maximum">
|
|
||||||
<number>99999</number>
|
|
||||||
</property>
|
|
||||||
<property name="value">
|
|
||||||
<number>1</number>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<spacer name="horizontalSpacer_2">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>40</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="lab_digit">
|
|
||||||
<property name="text">
|
|
||||||
<string>Digit(s)</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QComboBox" name="cbox_digit">
|
|
||||||
<property name="currentIndex">
|
|
||||||
<number>2</number>
|
|
||||||
</property>
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>1</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>2</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>3</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>4</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>5</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="lab_digitExp">
|
|
||||||
<property name="text">
|
|
||||||
<string>e.g. 'HGScan001'</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<spacer name="horizontalSpacer_3">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>40</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_6">
|
|
||||||
<item>
|
|
||||||
<widget class="QComboBox" name="cbox_evenOdd">
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>Even and odd pages</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>Odd pages</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>Even pages</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<spacer name="horizontalSpacer_4">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>40</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_5">
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="lab_format">
|
|
||||||
<property name="text">
|
|
||||||
<string>Format</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QComboBox" name="cbox_format">
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>JPG - JPG / JFIF(*.jpg)</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>BMP - Windows Bitmap(*.bmp)</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>PNG - Portable Network Graphics(*.png)</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>PPM - Portable Pixmap(*.ppm)</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>PGM - Portable Greymap(*.pgm)</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>PBM - Portable Bitmap(*.pbm)</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>TIF - TIFF Revision 6(*.tif)</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>PDF - Portable Document Format(*.pdf)</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>OFD - Open Fixed-layout Document(*.ofd)</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>GIF - Graphics Interchange Format(*.gif)</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="btn_option">
|
|
||||||
<property name="text">
|
|
||||||
<string>Compression option</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
|
||||||
<item row="0" column="0" colspan="2">
|
|
||||||
<widget class="QCheckBox" name="cbtn_multiFile">
|
|
||||||
<property name="text">
|
|
||||||
<string>Save as multipages (TIFF/PDF/OFD/GIF)</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="0">
|
|
||||||
<widget class="QRadioButton" name="radio_multiAll">
|
|
||||||
<property name="enabled">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>所有页</string>
|
|
||||||
</property>
|
|
||||||
<property name="checked">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="1">
|
|
||||||
<widget class="QRadioButton" name="radio_multiCustom">
|
|
||||||
<property name="enabled">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>用户自定义页数</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="2">
|
|
||||||
<widget class="QSpinBox" name="spinBox_multiPages">
|
|
||||||
<property name="enabled">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="minimum">
|
|
||||||
<number>1</number>
|
|
||||||
</property>
|
|
||||||
<property name="maximum">
|
|
||||||
<number>1000</number>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QDialogButtonBox" name="buttonBox">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="standardButtons">
|
|
||||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
<resources/>
|
|
||||||
<connections>
|
|
||||||
<connection>
|
|
||||||
<sender>buttonBox</sender>
|
|
||||||
<signal>accepted()</signal>
|
|
||||||
<receiver>Dialog_AquireInto</receiver>
|
|
||||||
<slot>accept()</slot>
|
|
||||||
<hints>
|
|
||||||
<hint type="sourcelabel">
|
|
||||||
<x>248</x>
|
|
||||||
<y>254</y>
|
|
||||||
</hint>
|
|
||||||
<hint type="destinationlabel">
|
|
||||||
<x>157</x>
|
|
||||||
<y>274</y>
|
|
||||||
</hint>
|
|
||||||
</hints>
|
|
||||||
</connection>
|
|
||||||
<connection>
|
|
||||||
<sender>buttonBox</sender>
|
|
||||||
<signal>rejected()</signal>
|
|
||||||
<receiver>Dialog_AquireInto</receiver>
|
|
||||||
<slot>reject()</slot>
|
|
||||||
<hints>
|
|
||||||
<hint type="sourcelabel">
|
|
||||||
<x>316</x>
|
|
||||||
<y>260</y>
|
|
||||||
</hint>
|
|
||||||
<hint type="destinationlabel">
|
|
||||||
<x>286</x>
|
|
||||||
<y>274</y>
|
|
||||||
</hint>
|
|
||||||
</hints>
|
|
||||||
</connection>
|
|
||||||
</connections>
|
|
||||||
</ui>
|
|
|
@ -1,188 +0,0 @@
|
||||||
#include "dialog_clrcache.h"
|
|
||||||
#include "ui_dialog_clrcache.h"
|
|
||||||
#include <QMessageBox>
|
|
||||||
#include <QDir>
|
|
||||||
#include <QFileInfo>
|
|
||||||
#include <QKeyEvent>
|
|
||||||
#include <QFileDialog>
|
|
||||||
#include "base/HGUtility.h"
|
|
||||||
#include "HGUIGlobal.h"
|
|
||||||
#include "HGString.h"
|
|
||||||
#include "app_cfg.h"
|
|
||||||
|
|
||||||
Dialog_ClrCache::Dialog_ClrCache(QWidget *parent)
|
|
||||||
: QDialog(parent)
|
|
||||||
, ui(new Ui::Dialog_ClrCache)
|
|
||||||
, m_mainWindow(nullptr)
|
|
||||||
{
|
|
||||||
ui->setupUi(this);
|
|
||||||
|
|
||||||
ui->lineEdit->setEnabled(false);
|
|
||||||
|
|
||||||
m_cachePath = getCachePath();
|
|
||||||
ui->lineEdit->setText(m_cachePath);
|
|
||||||
setInformation(m_cachePath);
|
|
||||||
}
|
|
||||||
|
|
||||||
Dialog_ClrCache::~Dialog_ClrCache()
|
|
||||||
{
|
|
||||||
delete ui;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString Dialog_ClrCache::getCachePath()
|
|
||||||
{
|
|
||||||
HGChar cachePath[512];
|
|
||||||
HGBase_GetDocumentsPath(cachePath, 512);
|
|
||||||
HGChar procName[512];
|
|
||||||
HGBase_GetProcessName(procName, 512);
|
|
||||||
strcat(cachePath, procName);
|
|
||||||
strcat(cachePath, "/Cache/");
|
|
||||||
|
|
||||||
return getCfgValue("save", "cachePath", getStdFileName(StdStringToUtf8(cachePath).c_str()));
|
|
||||||
}
|
|
||||||
|
|
||||||
void Dialog_ClrCache::on_btn_clr_clicked()
|
|
||||||
{
|
|
||||||
QFileInfo file(m_cachePath);
|
|
||||||
|
|
||||||
if (!file.exists())
|
|
||||||
{
|
|
||||||
QMessageBox::information(this, tr("Information"), tr("No cached file is available"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
QMessageBox msg(QMessageBox::Question, tr("Question"),
|
|
||||||
tr("Main window contains temporary files, clear cache would remove all of them.\n Continue to clear?"),
|
|
||||||
QMessageBox::Yes | QMessageBox::No, this);
|
|
||||||
msg.exec();
|
|
||||||
if (msg.clickedButton() != msg.button(QMessageBox::Yes))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ret = clrCache(m_cachePath);
|
|
||||||
if (ret)
|
|
||||||
{
|
|
||||||
emit clearCache();
|
|
||||||
QMessageBox::information(this, tr("Information"), tr("Cache clear successfully."));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
QMessageBox::warning(this, tr("Warning"), tr("Cache clear failed or incompletely clear."));
|
|
||||||
}
|
|
||||||
|
|
||||||
setInformation(m_cachePath);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Dialog_ClrCache::clrCache(const QString &path)
|
|
||||||
{
|
|
||||||
bool isSuccessful = false;
|
|
||||||
QDir dir = QDir(path);
|
|
||||||
if (!path.isEmpty() && (path.endsWith("Cache/") || path.endsWith("Cache\\")))
|
|
||||||
{
|
|
||||||
isSuccessful = dir.removeRecursively();
|
|
||||||
}
|
|
||||||
|
|
||||||
return isSuccessful;
|
|
||||||
}
|
|
||||||
|
|
||||||
qint64 Dialog_ClrCache::getDirSize(const QString &path)
|
|
||||||
{
|
|
||||||
QDir dir(path);
|
|
||||||
qint64 size = 0;
|
|
||||||
foreach(QFileInfo info, dir.entryInfoList(QDir::Files))
|
|
||||||
size += info.size();
|
|
||||||
foreach(QString subDir, dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot))
|
|
||||||
size += getDirSize(path + QDir::separator() + subDir);
|
|
||||||
|
|
||||||
return size;
|
|
||||||
}
|
|
||||||
|
|
||||||
int Dialog_ClrCache::getFileNum(const QString &path)
|
|
||||||
{
|
|
||||||
QDir dir(path);
|
|
||||||
int num = 0;
|
|
||||||
foreach(QFileInfo info, dir.entryInfoList(QDir::Files))
|
|
||||||
num++;
|
|
||||||
foreach(QString subDir, dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot))
|
|
||||||
num += getFileNum(path + QDir::separator() + subDir);
|
|
||||||
|
|
||||||
return num;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Dialog_ClrCache::setInformation(const QString &path)
|
|
||||||
{
|
|
||||||
//生成缓存占用空间大小信息
|
|
||||||
qint64 size = getDirSize(path);
|
|
||||||
double s = size;
|
|
||||||
int unit = 0;
|
|
||||||
while(true)
|
|
||||||
{
|
|
||||||
if(s > 1024.0)
|
|
||||||
{
|
|
||||||
s /= 1024.0;
|
|
||||||
unit += 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
QString sstring = QString::number(s, 'f', 2);
|
|
||||||
ui->lab_size->setText(sstring);
|
|
||||||
QString unitstring = unit == 3 ? "GB" : (unit == 2 ? "MB" : (unit == 1 ? "KB" : "B"));
|
|
||||||
ui->lab_unit->setText(unitstring);
|
|
||||||
|
|
||||||
QString Bstring = QString::number(size);
|
|
||||||
int commaNum = Bstring.size() / 3;
|
|
||||||
if(Bstring.size() % 3 == 0)
|
|
||||||
commaNum -= 1;
|
|
||||||
int offset = 0;
|
|
||||||
for(int i = 0; i < commaNum; i++)
|
|
||||||
{
|
|
||||||
Bstring.insert(Bstring.size() - 3 - offset * 4, ",");
|
|
||||||
offset += 1;
|
|
||||||
}
|
|
||||||
ui->lab_sizeByB->setText("(" + Bstring + " Byte)");
|
|
||||||
//生成文件个数信息
|
|
||||||
ui->lab_num->setNum(getFileNum(path));
|
|
||||||
}
|
|
||||||
|
|
||||||
void Dialog_ClrCache::on_btn_directory_clicked()
|
|
||||||
{
|
|
||||||
QString save_dir = QFileDialog::getExistingDirectory(this, tr("Browse directory"), "");
|
|
||||||
if (!save_dir.isEmpty())
|
|
||||||
{
|
|
||||||
if (save_dir[save_dir.size() - 1] != '/')
|
|
||||||
save_dir += "/";
|
|
||||||
|
|
||||||
if (save_dir.endsWith(QString("Cache/"), Qt::CaseInsensitive))
|
|
||||||
ui->lineEdit->setText(getStdFileName(save_dir));
|
|
||||||
else
|
|
||||||
ui->lineEdit->setText(getStdFileName(save_dir + "Cache/"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Dialog_ClrCache::on_pbtn_ok_clicked()
|
|
||||||
{
|
|
||||||
if(ui->lineEdit->text().isEmpty())
|
|
||||||
{
|
|
||||||
QMessageBox::information(this, tr("tips"), tr("directory can not be empty"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString filePath = ui->lineEdit->text();
|
|
||||||
HGResult ret = HGBase_CreateDir(getStdString(filePath).c_str());
|
|
||||||
if (ret != HGBASE_ERR_OK)
|
|
||||||
{
|
|
||||||
QMessageBox::information(this, tr("tips"), tr("create cachePath failed: ") + m_mainWindow->getLogInfo(ret));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
saveCfgValue("save", "cachePath", getStdFileName(filePath));
|
|
||||||
|
|
||||||
close();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Dialog_ClrCache::on_pbtn_cancel_clicked()
|
|
||||||
{
|
|
||||||
close();
|
|
||||||
}
|
|
|
@ -1,45 +0,0 @@
|
||||||
#ifndef DIALOG_CLRCACHE_H
|
|
||||||
#define DIALOG_CLRCACHE_H
|
|
||||||
|
|
||||||
#include <QDialog>
|
|
||||||
#include <QButtonGroup>
|
|
||||||
#include <QPushButton>
|
|
||||||
#include "mainwindow.h"
|
|
||||||
|
|
||||||
namespace Ui {
|
|
||||||
class Dialog_ClrCache;
|
|
||||||
}
|
|
||||||
|
|
||||||
class Dialog_ClrCache : public QDialog
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
explicit Dialog_ClrCache(QWidget *parent = nullptr);
|
|
||||||
~Dialog_ClrCache();
|
|
||||||
|
|
||||||
static QString getCachePath();
|
|
||||||
|
|
||||||
signals:
|
|
||||||
void clearCache();
|
|
||||||
|
|
||||||
private slots:
|
|
||||||
void on_btn_clr_clicked();
|
|
||||||
void on_btn_directory_clicked();
|
|
||||||
void on_pbtn_ok_clicked();
|
|
||||||
void on_pbtn_cancel_clicked();
|
|
||||||
|
|
||||||
private:
|
|
||||||
bool clrCache(const QString &path);
|
|
||||||
qint64 getDirSize(const QString &path);
|
|
||||||
int getFileNum(const QString &path);
|
|
||||||
void setInformation(const QString &path);
|
|
||||||
|
|
||||||
private:
|
|
||||||
Ui::Dialog_ClrCache *ui;
|
|
||||||
QString m_cachePath;
|
|
||||||
|
|
||||||
MainWindow *m_mainWindow;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // DIALOG_CLRCACHE_H
|
|
|
@ -1,172 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<ui version="4.0">
|
|
||||||
<class>Dialog_ClrCache</class>
|
|
||||||
<widget class="QDialog" name="Dialog_ClrCache">
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>0</y>
|
|
||||||
<width>490</width>
|
|
||||||
<height>159</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="minimumSize">
|
|
||||||
<size>
|
|
||||||
<width>0</width>
|
|
||||||
<height>159</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="maximumSize">
|
|
||||||
<size>
|
|
||||||
<width>16777215</width>
|
|
||||||
<height>159</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="windowTitle">
|
|
||||||
<string>Dialog</string>
|
|
||||||
</property>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
|
||||||
<item>
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="label">
|
|
||||||
<property name="text">
|
|
||||||
<string>Cache path:</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QLineEdit" name="lineEdit">
|
|
||||||
<property name="enabled">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QToolButton" name="btn_directory">
|
|
||||||
<property name="text">
|
|
||||||
<string>...</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="label_2">
|
|
||||||
<property name="text">
|
|
||||||
<string>Cache occupied space:</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="lab_size">
|
|
||||||
<property name="text">
|
|
||||||
<string>0</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="lab_unit">
|
|
||||||
<property name="text">
|
|
||||||
<string>B</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="lab_sizeByB">
|
|
||||||
<property name="text">
|
|
||||||
<string>(0 Byte)</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<spacer name="horizontalSpacer">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>40</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="label_3">
|
|
||||||
<property name="text">
|
|
||||||
<string>Number of files:</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="lab_num">
|
|
||||||
<property name="text">
|
|
||||||
<string>0</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<spacer name="horizontalSpacer_3">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>40</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
|
||||||
<item>
|
|
||||||
<spacer name="horizontalSpacer_2">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>40</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="btn_clr">
|
|
||||||
<property name="text">
|
|
||||||
<string>Clear Cache</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="pbtn_ok">
|
|
||||||
<property name="text">
|
|
||||||
<string>ok</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="pbtn_cancel">
|
|
||||||
<property name="text">
|
|
||||||
<string>cancel</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
<resources/>
|
|
||||||
<connections/>
|
|
||||||
</ui>
|
|
|
@ -1,654 +0,0 @@
|
||||||
#include "dialog_export.h"
|
|
||||||
#include "ui_dialog_export.h"
|
|
||||||
#include <QButtonGroup>
|
|
||||||
#include <QMessageBox>
|
|
||||||
#include <QDialogButtonBox>
|
|
||||||
#include <algorithm>
|
|
||||||
#include <QRegExpValidator>
|
|
||||||
#include "dialog_writesettings.h"
|
|
||||||
#include "base/HGBase.h"
|
|
||||||
#include "HGUIGlobal.h"
|
|
||||||
#include "app_cfg.h"
|
|
||||||
#include "ocrPdf.h"
|
|
||||||
#include <assert.h>
|
|
||||||
|
|
||||||
#define ARRAY_SIZE(a) sizeof(a) / sizeof(a[0])
|
|
||||||
|
|
||||||
enum file_type_attr
|
|
||||||
{
|
|
||||||
FILE_TYPE_ATTR_NO_MORE_OPTION = 0x0,
|
|
||||||
FILE_TYPE_ATTR_MORE_OPTIONS = 0x01 << 0, // this type supports more-parameters
|
|
||||||
FILE_TYPE_ATTR_CONTAIN_MULTI_PAGES = 0x01 << 1, // this type supports multi-images to be saved into one file
|
|
||||||
FILE_TYPE_ATTR_THIRD_HANDLER = 0x01 << 2, // this type supports third-handling methods
|
|
||||||
};
|
|
||||||
|
|
||||||
Dialog_Export::Dialog_Export(int total, const std::vector<int> &selectedIndexs, QWidget *parent) :
|
|
||||||
QDialog(parent)
|
|
||||||
, ui(new Ui::Dialog_Export)
|
|
||||||
, m_total(total)
|
|
||||||
, m_selectedIndexs(selectedIndexs)
|
|
||||||
{
|
|
||||||
ui->setupUi(this);
|
|
||||||
setWindowFlags(Qt::Dialog | Qt::WindowCloseButtonHint);
|
|
||||||
|
|
||||||
m_supportType.push_back(SupportType(".jpg", "JPG - JPEG / JFIF", FILE_TYPE_ATTR_MORE_OPTIONS));
|
|
||||||
m_supportType.push_back(SupportType(".bmp", "BMP - Windows Bitmap", FILE_TYPE_ATTR_NO_MORE_OPTION));
|
|
||||||
m_supportType.push_back(SupportType(".png", "PNG - Portable Network Graphics", FILE_TYPE_ATTR_NO_MORE_OPTION));
|
|
||||||
m_supportType.push_back(SupportType(".ppm", "PPM - Portable PixMap", FILE_TYPE_ATTR_NO_MORE_OPTION));
|
|
||||||
m_supportType.push_back(SupportType(".pgm", "PGM - Portable GreyMap", FILE_TYPE_ATTR_NO_MORE_OPTION));
|
|
||||||
m_supportType.push_back(SupportType(".pbm", "PBM - Portable BitMap", FILE_TYPE_ATTR_NO_MORE_OPTION));
|
|
||||||
m_supportType.push_back(SupportType(".tif", "TIF - TIFF Revision 6", FILE_TYPE_ATTR_CONTAIN_MULTI_PAGES | FILE_TYPE_ATTR_MORE_OPTIONS));
|
|
||||||
m_supportType.push_back(SupportType(".pdf", "PDF - Portable Document Format", FILE_TYPE_ATTR_CONTAIN_MULTI_PAGES | FILE_TYPE_ATTR_MORE_OPTIONS));
|
|
||||||
m_supportType.push_back(SupportType(".ofd", "OFD - Open Fixed-layout Document", FILE_TYPE_ATTR_CONTAIN_MULTI_PAGES | FILE_TYPE_ATTR_MORE_OPTIONS));
|
|
||||||
m_supportType.push_back(SupportType(".gif", "GIF - Graphics Interchange Format", FILE_TYPE_ATTR_CONTAIN_MULTI_PAGES));
|
|
||||||
#if 0
|
|
||||||
if (!getOcrPath().empty())
|
|
||||||
m_supportType.push_back(SupportType(".pdf", "OCR->PDF - Portable Document Format", FILE_TYPE_ATTR_THIRD_HANDLER | FILE_TYPE_ATTR_CONTAIN_MULTI_PAGES));
|
|
||||||
#elif !defined (x86_64) && !defined (loongarch64)
|
|
||||||
m_supportType.push_back(SupportType(".pdf", "OCR->PDF - Portable Document Format", FILE_TYPE_ATTR_THIRD_HANDLER | FILE_TYPE_ATTR_CONTAIN_MULTI_PAGES));
|
|
||||||
m_supportType.push_back(SupportType(".ofd", "OCR->OFD - Open Fixed-layout Document", FILE_TYPE_ATTR_THIRD_HANDLER | FILE_TYPE_ATTR_CONTAIN_MULTI_PAGES));
|
|
||||||
m_supportType.push_back(SupportType(".rtf", "OCR->RTF - Rich Text Format", FILE_TYPE_ATTR_THIRD_HANDLER | FILE_TYPE_ATTR_CONTAIN_MULTI_PAGES));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
ui->fileDialog->setAcceptMode(QFileDialog::AcceptSave);
|
|
||||||
ui->fileDialog->setWindowFlags(ui->fileDialog->windowFlags() & ~Qt::Dialog);
|
|
||||||
ui->fileDialog->setOption(QFileDialog::DontUseNativeDialog, true);
|
|
||||||
ui->fileDialog->setOption(QFileDialog::ReadOnly, true); // disable 'Delete' menu item
|
|
||||||
ui->fileDialog->setSizeGripEnabled(false);
|
|
||||||
|
|
||||||
// ui->fileDialog->setNameFilter("JPG - JPEG / JFIF(*.jpg);;"
|
|
||||||
// "BMP - Windows Bitmap(*.bmp);;"
|
|
||||||
// "PNG - Portable Network Graphics(*.png);;"
|
|
||||||
// "TIF - TIFF Revision 6(*.tif);;"
|
|
||||||
// "PDF - Portable Document Format(*.pdf);;"
|
|
||||||
// "OFD - Open Fixed-layout Document(*.ofd);;"
|
|
||||||
// "OCR->PDF - Portable Document Format(*.pdf);;"
|
|
||||||
// "OCR->OFD - Open Fixed-layout Document(*.ofd)");
|
|
||||||
QStringList filters;
|
|
||||||
for(int i = 0; i < m_supportType.size(); ++i)
|
|
||||||
filters.push_back(m_supportType[i].title + "(*" + m_supportType[i].ext + ")");
|
|
||||||
ui->fileDialog->setNameFilters(filters);
|
|
||||||
|
|
||||||
connect(ui->fileDialog, SIGNAL(accepted()), this, SLOT(on_dialog_accepted()));
|
|
||||||
connect(ui->fileDialog, SIGNAL(rejected()), this, SLOT(close()));
|
|
||||||
connect(ui->fileDialog, SIGNAL(filterSelected(const QString&)), this, SLOT(on_filterSelected(const QString&)));
|
|
||||||
|
|
||||||
#ifdef USE_FILE_DLG_WITHOUT_PROMPT
|
|
||||||
init_custom_file_dlg(ui->fileDialog);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
QButtonGroup* btn_group = new QButtonGroup(this);
|
|
||||||
btn_group->addButton(ui->radio_chosenPages, 0);
|
|
||||||
btn_group->addButton(ui->radio_allPages, 1);
|
|
||||||
btn_group->addButton(ui->radio_nominatedPages, 2);
|
|
||||||
|
|
||||||
QRegExp rx("[0-9,-]+$");
|
|
||||||
ui->lineEdit_nominatePages->setValidator(new QRegExpValidator(rx, this));
|
|
||||||
|
|
||||||
m_suffix = getCfgValue("export", "suffix", 0);
|
|
||||||
if(m_suffix < 0 || m_suffix >= m_supportType.size())
|
|
||||||
m_suffix = 0;
|
|
||||||
ui->fileDialog->selectNameFilter(ui->fileDialog->nameFilters().at(m_suffix));
|
|
||||||
m_saveExt = m_supportType[m_suffix].ext;
|
|
||||||
// ui->check_saveAsMulti->setEnabled(m_suffix > 2 && m_suffix < 6);
|
|
||||||
ui->check_saveAsMulti->setEnabled((m_supportType[m_suffix].attr & FILE_TYPE_ATTR_CONTAIN_MULTI_PAGES) == FILE_TYPE_ATTR_CONTAIN_MULTI_PAGES);
|
|
||||||
ui->check_saveAsMulti->setChecked(getCfgValue("export", "saveAsMulti", false));
|
|
||||||
// ui->btn_option->setEnabled(m_suffix == 0 || m_suffix == 3);
|
|
||||||
ui->btn_option->setEnabled((m_supportType[m_suffix].attr & FILE_TYPE_ATTR_MORE_OPTIONS) == FILE_TYPE_ATTR_MORE_OPTIONS);
|
|
||||||
|
|
||||||
int exportType = getCfgValue("export", "exportType", 0);
|
|
||||||
if (0 == exportType)
|
|
||||||
{
|
|
||||||
ui->radio_chosenPages->setChecked(true);
|
|
||||||
ui->lab_nominatePages->setEnabled(false);
|
|
||||||
ui->lineEdit_nominatePages->setEnabled(false);
|
|
||||||
ui->lab_warning->setVisible(false);
|
|
||||||
}
|
|
||||||
else if (1 == exportType)
|
|
||||||
{
|
|
||||||
ui->radio_allPages->setChecked(true);
|
|
||||||
ui->lab_nominatePages->setEnabled(false);
|
|
||||||
ui->lineEdit_nominatePages->setEnabled(false);
|
|
||||||
ui->lab_warning->setVisible(false);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ui->radio_nominatedPages->setChecked(true);
|
|
||||||
ui->lab_nominatePages->setEnabled(true);
|
|
||||||
ui->lineEdit_nominatePages->setEnabled(true);
|
|
||||||
ui->lab_warning->setVisible(true);
|
|
||||||
ui->lab_warning->setText(tr("Input is not valid.\nPage range will be 'Chosen Pages'."));
|
|
||||||
}
|
|
||||||
|
|
||||||
ui->label_ocrType->setVisible(false);
|
|
||||||
ui->comboBox_ocrType->setVisible(false);
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
if (!getOcrPath().empty())
|
|
||||||
{
|
|
||||||
ui->label_ocrType->setVisible(isOcr());
|
|
||||||
ui->comboBox_ocrType->setVisible(isOcr());
|
|
||||||
QStringList ocrType = { tr("English"), tr("Simplified Chinese"), tr("Traditional Chinese"), tr("Japanese"), tr("Korean") };
|
|
||||||
ui->comboBox_ocrType->addItems(ocrType);
|
|
||||||
ui->comboBox_ocrType->setCurrentIndex(getCfgValue("export", "ocrLanguage", 0));
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
Dialog_Export::~Dialog_Export()
|
|
||||||
{
|
|
||||||
delete ui;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString Dialog_Export::getSavePath()
|
|
||||||
{
|
|
||||||
return m_savePath;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString Dialog_Export::getSaveName()
|
|
||||||
{
|
|
||||||
return m_saveName;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString Dialog_Export::getSaveExt()
|
|
||||||
{
|
|
||||||
return m_saveExt;
|
|
||||||
}
|
|
||||||
|
|
||||||
int Dialog_Export::getJpegQuality()
|
|
||||||
{
|
|
||||||
return getCfgValue("saveParam", "jpegQuality", 80);
|
|
||||||
}
|
|
||||||
|
|
||||||
int Dialog_Export::getTiffCompressionBW()
|
|
||||||
{
|
|
||||||
return getCfgValue("saveParam", "tiffCompBW", 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
int Dialog_Export::getTiffCompression()
|
|
||||||
{
|
|
||||||
return getCfgValue("saveParam", "tiffCompClr", 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
int Dialog_Export::getTiffQuality()
|
|
||||||
{
|
|
||||||
return getCfgValue("saveParam", "tiffQuality", 80);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Dialog_Export::isOcr()
|
|
||||||
{
|
|
||||||
// return (m_suffix >= 6);
|
|
||||||
return (m_supportType[m_suffix].attr & FILE_TYPE_ATTR_THIRD_HANDLER) == FILE_TYPE_ATTR_THIRD_HANDLER;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Dialog_Export::isSaveAsMultiPage()
|
|
||||||
{
|
|
||||||
return ui->check_saveAsMulti->isChecked();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Dialog_Export::getSaveIndexs(std::vector<int> &indexs)
|
|
||||||
{
|
|
||||||
indexs = m_saveIndexs;
|
|
||||||
}
|
|
||||||
|
|
||||||
int Dialog_Export::getOcrLanguageType()
|
|
||||||
{
|
|
||||||
return ui->comboBox_ocrType->currentIndex();// 0-english, 1-chinese_sim, 2-chinese_tra, 3-japanese, 4-korean...
|
|
||||||
}
|
|
||||||
|
|
||||||
void Dialog_Export::on_dialog_accepted()
|
|
||||||
{
|
|
||||||
QString extName(m_supportType[m_suffix].ext);
|
|
||||||
// switch (m_suffix)
|
|
||||||
// {
|
|
||||||
// case 0:
|
|
||||||
// extName = ".jpg";
|
|
||||||
// break;
|
|
||||||
// case 1:
|
|
||||||
// extName = ".bmp";
|
|
||||||
// break;
|
|
||||||
// case 2:
|
|
||||||
// extName = ".png";
|
|
||||||
// break;
|
|
||||||
// case 3:
|
|
||||||
// extName = ".tif";
|
|
||||||
// break;
|
|
||||||
// case 4:
|
|
||||||
// extName = ".pdf";
|
|
||||||
// break;
|
|
||||||
// case 5:
|
|
||||||
// extName = ".ofd";
|
|
||||||
// break;
|
|
||||||
// case 6:
|
|
||||||
// extName = ".pdf";
|
|
||||||
// break;
|
|
||||||
// case 7:
|
|
||||||
// extName = ".ofd";
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
|
|
||||||
assert(!extName.isEmpty());
|
|
||||||
|
|
||||||
bool warning = true;
|
|
||||||
QString selectedFile = ui->fileDialog->selectedFiles()[0];
|
|
||||||
int pos = selectedFile.lastIndexOf('/');
|
|
||||||
if (-1 != pos)
|
|
||||||
{
|
|
||||||
QString path = selectedFile.left(pos + 1);
|
|
||||||
QString name = selectedFile.right(selectedFile.count() - pos - 1);
|
|
||||||
pos = name.lastIndexOf('.');
|
|
||||||
if (-1 != pos
|
|
||||||
&& is_support_file_type(name.right(name.length() - pos)))
|
|
||||||
{
|
|
||||||
warning = false; // 带扩展名,系统已经警告同名文件
|
|
||||||
name = name.left(pos);
|
|
||||||
}
|
|
||||||
|
|
||||||
m_savePath = getStdFileName(path);
|
|
||||||
m_saveName = name;
|
|
||||||
m_saveExt = extName;
|
|
||||||
}
|
|
||||||
|
|
||||||
makeSaveIndexs();
|
|
||||||
|
|
||||||
// 同名警告
|
|
||||||
if(warning && avoid_overwriting(m_savePath + "/" + m_saveName + m_saveExt))
|
|
||||||
return;
|
|
||||||
|
|
||||||
saveCfgValue("export", "suffix", m_suffix);
|
|
||||||
|
|
||||||
int exportType = 0;
|
|
||||||
if (ui->radio_chosenPages->isChecked())
|
|
||||||
exportType = 0;
|
|
||||||
else if (ui->radio_allPages->isChecked())
|
|
||||||
exportType = 1;
|
|
||||||
else if (ui->radio_nominatedPages->isChecked())
|
|
||||||
exportType = 2;
|
|
||||||
saveCfgValue("export", "exportType", exportType);
|
|
||||||
saveCfgValue("export", "saveAsMulti", ui->check_saveAsMulti->isChecked());
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
int ocrLanguage = ui->comboBox_ocrType->currentIndex();
|
|
||||||
saveCfgValue("export", "ocrLanguage", ocrLanguage);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
accept();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Dialog_Export::on_filterSelected(const QString& filterName)
|
|
||||||
{
|
|
||||||
bool enabled = false;
|
|
||||||
|
|
||||||
m_suffix = ui->fileDialog->nameFilters().indexOf(filterName);
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
ui->label_ocrType->setVisible(isOcr());
|
|
||||||
ui->comboBox_ocrType->setVisible(isOcr());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
enabled = (m_supportType[m_suffix].attr & FILE_TYPE_ATTR_CONTAIN_MULTI_PAGES) == FILE_TYPE_ATTR_CONTAIN_MULTI_PAGES;
|
|
||||||
ui->check_saveAsMulti->setEnabled(enabled);
|
|
||||||
// ui->check_saveAsMulti->setEnabled(m_suffix > 2 && m_suffix < 6);
|
|
||||||
// if (m_suffix <= 2 || m_suffix >= 6)
|
|
||||||
if(!enabled)
|
|
||||||
ui->check_saveAsMulti->setChecked(false);
|
|
||||||
|
|
||||||
enabled = (m_supportType[m_suffix].attr & FILE_TYPE_ATTR_MORE_OPTIONS) == FILE_TYPE_ATTR_MORE_OPTIONS;
|
|
||||||
// ui->btn_option->setEnabled(0 == m_suffix || 3 == m_suffix);
|
|
||||||
ui->btn_option->setEnabled(enabled);
|
|
||||||
m_saveExt = m_supportType[m_suffix].ext;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Dialog_Export::on_btn_option_clicked()
|
|
||||||
{
|
|
||||||
Dialog_WriteSettings dlg(m_suffix, this);
|
|
||||||
dlg.exec();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Dialog_Export::on_radio_nominatedPages_toggled(bool checked)
|
|
||||||
{
|
|
||||||
ui->lab_nominatePages->setEnabled(checked);
|
|
||||||
ui->lineEdit_nominatePages->setEnabled(checked);
|
|
||||||
if (!checked)
|
|
||||||
{
|
|
||||||
ui->lab_warning->setVisible(false);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
bool isVaild = isNominatedPagesLegal(ui->lineEdit_nominatePages->text());
|
|
||||||
ui->lab_warning->setVisible(!isVaild);
|
|
||||||
if (!isVaild)
|
|
||||||
ui->lab_warning->setText(tr("Input is not valid.\nPage range will be 'Chosen Pages'."));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Dialog_Export::on_lineEdit_nominatePages_textChanged(const QString& arg1)
|
|
||||||
{
|
|
||||||
(void)arg1;
|
|
||||||
|
|
||||||
bool isVaild = isNominatedPagesLegal(ui->lineEdit_nominatePages->text());
|
|
||||||
ui->lab_warning->setVisible(!isVaild);
|
|
||||||
if (!isVaild)
|
|
||||||
ui->lab_warning->setText(tr("Input is not valid.\nPage range will be 'Chosen Pages'."));
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef USE_FILE_DLG_WITHOUT_PROMPT
|
|
||||||
void Dialog_Export::on_file_dialog_textChanged(const QString &path)
|
|
||||||
{
|
|
||||||
QLineEdit* edit = dynamic_cast<QLineEdit*>(sender());
|
|
||||||
|
|
||||||
on_file_name_changed(edit, path);
|
|
||||||
}
|
|
||||||
void Dialog_Export::on_file_dialog_returnPressed()
|
|
||||||
{
|
|
||||||
on_file_name_press_return();
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
bool Dialog_Export::isNominatedPagesLegal(const QString& page)
|
|
||||||
{
|
|
||||||
if (page.isEmpty())
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
QStringList commalist = page.split(',');
|
|
||||||
for (int i = 0; i < commalist.size(); ++i)
|
|
||||||
{
|
|
||||||
QString number1, number2;
|
|
||||||
bool setNumber2 = false;
|
|
||||||
for (int j = 0; j < commalist[i].size(); j++)
|
|
||||||
{
|
|
||||||
if (number1.isEmpty() && number2.isEmpty())
|
|
||||||
{
|
|
||||||
if (commalist[i][j] == '-')
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
number1.append(commalist[i][j]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (!number1.isEmpty() && number2.isEmpty())
|
|
||||||
{
|
|
||||||
if (commalist[i][j] == '-')
|
|
||||||
{
|
|
||||||
if (setNumber2)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
setNumber2 = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (!setNumber2)
|
|
||||||
{
|
|
||||||
number1.append(commalist[i][j]);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
number2.append(commalist[i][j]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
assert(!number1.isEmpty() && !number2.isEmpty());
|
|
||||||
|
|
||||||
assert(setNumber2);
|
|
||||||
if (commalist[i][j] == '-')
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
number2.append(commalist[i][j]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (number1.isEmpty())
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (setNumber2 && number2.isEmpty())
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!number1.isEmpty() && number2.isEmpty())
|
|
||||||
{
|
|
||||||
int num1 = number1.toInt();
|
|
||||||
if (num1 < 1 || num1 > m_total)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
assert(!number1.isEmpty() && !number2.isEmpty());
|
|
||||||
|
|
||||||
int num1 = number1.toInt();
|
|
||||||
int num2 = number2.toInt();
|
|
||||||
if (num1 < 1 || num1 > m_total || num2 < 1 || num2 > m_total || num1 > num2)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool indexSortCompare(int iter1, int iter2)
|
|
||||||
{
|
|
||||||
return iter1 < iter2;
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool indexUniqueCompare(int iter1, int iter2)
|
|
||||||
{
|
|
||||||
return iter1 == iter2;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Dialog_Export::makeSaveIndexs()
|
|
||||||
{
|
|
||||||
if (ui->radio_chosenPages->isChecked())
|
|
||||||
{
|
|
||||||
m_saveIndexs = m_selectedIndexs;
|
|
||||||
}
|
|
||||||
else if (ui->radio_allPages->isChecked())
|
|
||||||
{
|
|
||||||
for (int i = 0; i < m_total; ++i)
|
|
||||||
{
|
|
||||||
m_saveIndexs.push_back(i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
assert(ui->radio_nominatedPages->isChecked());
|
|
||||||
|
|
||||||
QString page = ui->lineEdit_nominatePages->text();
|
|
||||||
if (!page.isEmpty())
|
|
||||||
{
|
|
||||||
bool success = true;
|
|
||||||
QStringList commalist = page.split(',');
|
|
||||||
for (int i = 0; i < commalist.size(); ++i)
|
|
||||||
{
|
|
||||||
bool ret = true;
|
|
||||||
|
|
||||||
QString number1, number2;
|
|
||||||
bool setNumber2 = false;
|
|
||||||
for (int j = 0; j < commalist[i].size(); j++)
|
|
||||||
{
|
|
||||||
if (number1.isEmpty() && number2.isEmpty())
|
|
||||||
{
|
|
||||||
if (commalist[i][j] == '-')
|
|
||||||
{
|
|
||||||
ret = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
number1.append(commalist[i][j]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (!number1.isEmpty() && number2.isEmpty())
|
|
||||||
{
|
|
||||||
if (commalist[i][j] == '-')
|
|
||||||
{
|
|
||||||
if (setNumber2)
|
|
||||||
{
|
|
||||||
ret = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
setNumber2 = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (!setNumber2)
|
|
||||||
{
|
|
||||||
number1.append(commalist[i][j]);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
number2.append(commalist[i][j]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
assert(!number1.isEmpty() && !number2.isEmpty());
|
|
||||||
|
|
||||||
assert(setNumber2);
|
|
||||||
if (commalist[i][j] == '-')
|
|
||||||
{
|
|
||||||
ret = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
number2.append(commalist[i][j]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!ret)
|
|
||||||
{
|
|
||||||
success = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (number1.isEmpty())
|
|
||||||
{
|
|
||||||
ret = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (setNumber2 && number2.isEmpty())
|
|
||||||
{
|
|
||||||
ret = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!number1.isEmpty() && number2.isEmpty())
|
|
||||||
{
|
|
||||||
int num1 = number1.toInt();
|
|
||||||
if (num1 < 1 || num1 > m_total)
|
|
||||||
{
|
|
||||||
ret = false;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
m_saveIndexs.push_back(num1 - 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
assert(!number1.isEmpty() && !number2.isEmpty());
|
|
||||||
|
|
||||||
int num1 = number1.toInt();
|
|
||||||
int num2 = number2.toInt();
|
|
||||||
if (num1 < 1 || num1 > m_total || num2 < 1 || num2 > m_total || num1 > num2)
|
|
||||||
{
|
|
||||||
ret = false;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
for (int k = num1; k <= num2; ++k)
|
|
||||||
{
|
|
||||||
m_saveIndexs.push_back(k - 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!ret)
|
|
||||||
{
|
|
||||||
success = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!success)
|
|
||||||
{
|
|
||||||
m_saveIndexs = m_selectedIndexs;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
m_saveIndexs = m_selectedIndexs;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 排序和去重
|
|
||||||
std::sort(m_saveIndexs.begin(), m_saveIndexs.end(), indexSortCompare);
|
|
||||||
std::vector<int>::iterator iter = std::unique(m_saveIndexs.begin(), m_saveIndexs.end(), indexUniqueCompare);
|
|
||||||
m_saveIndexs.erase(iter, m_saveIndexs.end());
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Dialog_Export::is_support_file_type(const QString& ext)
|
|
||||||
{
|
|
||||||
return ext.compare(m_supportType[m_suffix].ext, Qt::CaseInsensitive) == 0;
|
|
||||||
|
|
||||||
for(int i = 0; i < m_supportType.size(); ++i)
|
|
||||||
{
|
|
||||||
if(ext.compare(m_supportType[i].ext, Qt::CaseInsensitive) == 0)
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
bool Dialog_Export::avoid_overwriting(const QString& path_file)
|
|
||||||
{
|
|
||||||
return false; // 不能阻止文件对话框关闭,暂时不做处理
|
|
||||||
|
|
||||||
bool ret = false;
|
|
||||||
QFileInfo fi(path_file);
|
|
||||||
|
|
||||||
if(fi.exists())
|
|
||||||
{
|
|
||||||
// 单个文件才判断
|
|
||||||
if((ui->radio_allPages->isChecked() && m_total == 1) ||
|
|
||||||
(ui->radio_chosenPages->isChecked() && m_saveIndexs.size() == 1) ||
|
|
||||||
(ui->radio_nominatedPages->isChecked() && m_saveIndexs.size() == 1))
|
|
||||||
{
|
|
||||||
QString title(QString::fromStdString("\345\257\274\345\207\272\344\270\272")), info("");
|
|
||||||
int pos = path_file.lastIndexOf('/');
|
|
||||||
|
|
||||||
if(pos++ == -1)
|
|
||||||
info = path_file;
|
|
||||||
else
|
|
||||||
info = path_file.right(path_file.length() - pos);
|
|
||||||
info += QString::fromStdString("\345\267\262\347\273\217\345\255\230\345\234\250\357\274\214\n\346\202\250\346\203\263\350\246\201\346\233\277\346\215\242\345\256\203\345\220\227\357\274\237");
|
|
||||||
ret = QMessageBox::question(this, title, info) == QMessageBox::No;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
|
@ -1,85 +0,0 @@
|
||||||
#ifndef DIALOG_EXPORT_H
|
|
||||||
#define DIALOG_EXPORT_H
|
|
||||||
|
|
||||||
#include <QDialog>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
// u can ONLY comment following line if u want to use filedialog as system present !
|
|
||||||
#include "custom_file_dialog.h"
|
|
||||||
|
|
||||||
struct SupportType
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
SupportType(const QString &e, const QString &t, int a)
|
|
||||||
{
|
|
||||||
ext = e;
|
|
||||||
title = t;
|
|
||||||
attr = a;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString ext;
|
|
||||||
QString title;
|
|
||||||
int attr;
|
|
||||||
};
|
|
||||||
|
|
||||||
namespace Ui {
|
|
||||||
class Dialog_Export;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
class Dialog_Export : public QDialog
|
|
||||||
#ifdef USE_FILE_DLG_WITHOUT_PROMPT
|
|
||||||
, public custom_file_dlg<Dialog_Export>
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
|
|
||||||
public:
|
|
||||||
explicit Dialog_Export(int total, const std::vector<int> &selectedIndexs, QWidget *parent = nullptr);
|
|
||||||
~Dialog_Export();
|
|
||||||
|
|
||||||
QString getSavePath();
|
|
||||||
QString getSaveName();
|
|
||||||
QString getSaveExt();
|
|
||||||
int getJpegQuality();
|
|
||||||
int getTiffCompressionBW();
|
|
||||||
int getTiffCompression();
|
|
||||||
int getTiffQuality();
|
|
||||||
bool isOcr();
|
|
||||||
bool isSaveAsMultiPage();
|
|
||||||
void getSaveIndexs(std::vector<int> &indexs);
|
|
||||||
int getOcrLanguageType();
|
|
||||||
|
|
||||||
private slots:
|
|
||||||
void on_dialog_accepted();
|
|
||||||
void on_filterSelected(const QString& filterName);
|
|
||||||
void on_btn_option_clicked();
|
|
||||||
void on_radio_nominatedPages_toggled(bool checked);
|
|
||||||
void on_lineEdit_nominatePages_textChanged(const QString& arg1);
|
|
||||||
|
|
||||||
#ifdef USE_FILE_DLG_WITHOUT_PROMPT
|
|
||||||
void on_file_dialog_textChanged(const QString &path) override;
|
|
||||||
void on_file_dialog_returnPressed() override;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
private:
|
|
||||||
bool isNominatedPagesLegal(const QString& page);
|
|
||||||
void makeSaveIndexs();
|
|
||||||
bool is_support_file_type(const QString& ext); // ext is like as '.bmp' '.png' ...
|
|
||||||
bool avoid_overwriting(const QString& path_file); // 判断文件是否存在,若存在则提示用户是否覆盖。返回true表示用户希望重新选择
|
|
||||||
|
|
||||||
private:
|
|
||||||
Ui::Dialog_Export *ui;
|
|
||||||
std::vector<SupportType> m_supportType;
|
|
||||||
int m_total;
|
|
||||||
std::vector<int> m_selectedIndexs;
|
|
||||||
|
|
||||||
QString m_savePath;
|
|
||||||
QString m_saveName;
|
|
||||||
QString m_saveExt;
|
|
||||||
std::vector<int> m_saveIndexs;
|
|
||||||
int m_suffix;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // DIALOG_EXPORT_H
|
|
|
@ -1,202 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<ui version="4.0">
|
|
||||||
<class>Dialog_Export</class>
|
|
||||||
<widget class="QDialog" name="Dialog_Export">
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>0</y>
|
|
||||||
<width>650</width>
|
|
||||||
<height>530</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="windowTitle">
|
|
||||||
<string>Export</string>
|
|
||||||
</property>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_3" stretch="1,0">
|
|
||||||
<item>
|
|
||||||
<widget class="QFileDialog" name="fileDialog" native="true"/>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
|
||||||
<item>
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
|
||||||
<item>
|
|
||||||
<widget class="QGroupBox" name="gbox_pageRange">
|
|
||||||
<property name="title">
|
|
||||||
<string>Page Range</string>
|
|
||||||
</property>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
|
||||||
<item>
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
|
||||||
<item>
|
|
||||||
<widget class="QRadioButton" name="radio_nominatedPages">
|
|
||||||
<property name="text">
|
|
||||||
<string>Nominate Pages(example:1,3,6 or 3-6)</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<spacer name="horizontalSpacer_3">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>40</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QRadioButton" name="radio_chosenPages">
|
|
||||||
<property name="text">
|
|
||||||
<string>Chosen Pages</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<spacer name="horizontalSpacer_4">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>40</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QRadioButton" name="radio_allPages">
|
|
||||||
<property name="text">
|
|
||||||
<string>All Pages</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_2" stretch="0,0,1,0">
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="lab_nominatePages">
|
|
||||||
<property name="text">
|
|
||||||
<string>Page:</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QLineEdit" name="lineEdit_nominatePages"/>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="lab_warning">
|
|
||||||
<property name="enabled">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
<property name="styleSheet">
|
|
||||||
<string notr="true">color: rgb(216, 0, 0);</string>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>
|
|
||||||
Input is not valid.
|
|
||||||
Page range will be "Chosen Pages".
|
|
||||||
</string>
|
|
||||||
</property>
|
|
||||||
<property name="wordWrap">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<spacer name="horizontalSpacer_2">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>40</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
|
||||||
<item>
|
|
||||||
<widget class="QCheckBox" name="check_saveAsMulti">
|
|
||||||
<property name="text">
|
|
||||||
<string>Save as multipages (TIFF/PDF/OFD/GIF)</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="label_ocrType">
|
|
||||||
<property name="text">
|
|
||||||
<string>Ocr type:</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QComboBox" name="comboBox_ocrType">
|
|
||||||
<property name="minimumSize">
|
|
||||||
<size>
|
|
||||||
<width>111</width>
|
|
||||||
<height>0</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<spacer name="horizontalSpacer">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>40</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="btn_option">
|
|
||||||
<property name="text">
|
|
||||||
<string>Compression Option</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
<customwidgets>
|
|
||||||
<customwidget>
|
|
||||||
<class>QFileDialog</class>
|
|
||||||
<extends>QWidget</extends>
|
|
||||||
<header location="global">qfiledialog.h</header>
|
|
||||||
<container>1</container>
|
|
||||||
</customwidget>
|
|
||||||
</customwidgets>
|
|
||||||
<tabstops>
|
|
||||||
<tabstop>radio_chosenPages</tabstop>
|
|
||||||
<tabstop>radio_nominatedPages</tabstop>
|
|
||||||
<tabstop>radio_allPages</tabstop>
|
|
||||||
<tabstop>lineEdit_nominatePages</tabstop>
|
|
||||||
<tabstop>check_saveAsMulti</tabstop>
|
|
||||||
<tabstop>btn_option</tabstop>
|
|
||||||
</tabstops>
|
|
||||||
<resources/>
|
|
||||||
<connections/>
|
|
||||||
</ui>
|
|
|
@ -1,367 +0,0 @@
|
||||||
#include "dialog_exportimagefile.h"
|
|
||||||
#include "ui_dialog_exportimagefile.h"
|
|
||||||
#include "mainwindow.h"
|
|
||||||
#include "base/HGInfo.h"
|
|
||||||
#include "base/HGUtility.h"
|
|
||||||
#include "imgfmt/HGImgFmt.h"
|
|
||||||
#include "imgproc/HGOCR.h"
|
|
||||||
#include "HGUIGlobal.h"
|
|
||||||
#include "HGString.h"
|
|
||||||
#include <QMessageBox>
|
|
||||||
#include <QFile>
|
|
||||||
#include "ocrPdf.h"
|
|
||||||
#include "app_cfg.h"
|
|
||||||
|
|
||||||
Dialog_ExportImageFile::Dialog_ExportImageFile(const QString &destPath, const QString &destName, const QString &destExt,
|
|
||||||
bool isSaveAsMulti, int jpegQuality, int tiffCompressionBW, int tiffCompression, int tiffQuality, bool isOcr,
|
|
||||||
int ocrLanguageType, const QStringList &srcFiles, QWidget *parent)
|
|
||||||
: QDialog(parent)
|
|
||||||
, ui(new Ui::Dialog_ExportImageFile)
|
|
||||||
, m_destPath(destPath)
|
|
||||||
, m_destName(destName)
|
|
||||||
, m_destExt(destExt)
|
|
||||||
, m_isSaveAsMulti(isSaveAsMulti)
|
|
||||||
, m_jpegQuality(jpegQuality)
|
|
||||||
, m_tiffCompressionBW(tiffCompressionBW)
|
|
||||||
, m_tiffCompression(tiffCompression)
|
|
||||||
, m_tiffQuality(tiffQuality)
|
|
||||||
, m_isOcr(isOcr)
|
|
||||||
, m_ocrLanguageType(ocrLanguageType)
|
|
||||||
, m_srcFiles(srcFiles)
|
|
||||||
{
|
|
||||||
ui->setupUi(this);
|
|
||||||
|
|
||||||
ui->progressBar->setMinimum(0);
|
|
||||||
ui->progressBar->setMaximum(srcFiles.size());
|
|
||||||
ui->progressBar->setValue(0);
|
|
||||||
|
|
||||||
connect(this, SIGNAL(updateProgress(int)), this, SLOT(on_updateProgress(int)), Qt::QueuedConnection);
|
|
||||||
connect(this, SIGNAL(finish(int)), this, SLOT(on_finish(int)), Qt::QueuedConnection);
|
|
||||||
|
|
||||||
m_stopThread = false;
|
|
||||||
HGBase_OpenThread(ThreadFunc, this, &m_thread);
|
|
||||||
}
|
|
||||||
|
|
||||||
Dialog_ExportImageFile::~Dialog_ExportImageFile()
|
|
||||||
{
|
|
||||||
if (nullptr != m_thread)
|
|
||||||
{
|
|
||||||
HGBase_CloseThread(m_thread);
|
|
||||||
m_thread = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
delete ui;
|
|
||||||
}
|
|
||||||
|
|
||||||
void HGAPI Dialog_ExportImageFile::ThreadFunc(HGThread thread, HGPointer param)
|
|
||||||
{
|
|
||||||
(void)thread;
|
|
||||||
Dialog_ExportImageFile *p = (Dialog_ExportImageFile *)param;
|
|
||||||
HGResult ret = HGBASE_ERR_FAIL;
|
|
||||||
|
|
||||||
if (p->m_isSaveAsMulti)
|
|
||||||
{
|
|
||||||
QString fileName = p->m_destPath + p->m_destName + p->m_destExt;
|
|
||||||
|
|
||||||
if (p->m_isOcr)
|
|
||||||
{
|
|
||||||
#if 0
|
|
||||||
|
|
||||||
HGChar tmpFileName[256];
|
|
||||||
HGBase_GetTmpFileName("tif", tmpFileName, 256);
|
|
||||||
|
|
||||||
HGImgFmtWriter writer = NULL;
|
|
||||||
HGImgFmt_OpenImageWriter(tmpFileName, 0, &writer);
|
|
||||||
|
|
||||||
for (int i = 0; i < p->m_srcFiles.size(); ++i)
|
|
||||||
{
|
|
||||||
if (p->m_stopThread)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
emit p->updateProgress(i);
|
|
||||||
|
|
||||||
HGImgFmtReader imgFmtReader = nullptr;
|
|
||||||
ret = HGImgFmt_OpenImageReader(getStdString(p->m_srcFiles[i]).c_str(), 0, &imgFmtReader);
|
|
||||||
if (HGBASE_ERR_OK == ret)
|
|
||||||
{
|
|
||||||
HGUInt count = 0;
|
|
||||||
HGImgFmt_GetImagePageCount(imgFmtReader, &count);
|
|
||||||
for (HGUInt j = 0; j < count; ++j)
|
|
||||||
{
|
|
||||||
if (p->m_stopThread)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
HGImage img = nullptr;
|
|
||||||
ret = HGImgFmt_LoadImageFromReader(imgFmtReader, j, nullptr, 0, HGBASE_IMGORIGIN_TOP, &img);
|
|
||||||
if (HGBASE_ERR_OK == ret)
|
|
||||||
{
|
|
||||||
ret = HGImgFmt_SaveImageToWriter(writer, img, NULL);
|
|
||||||
HGBase_DestroyImage(img);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ret != HGBASE_ERR_OK)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
HGImgFmt_CloseImageReader(imgFmtReader);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ret != HGBASE_ERR_OK)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
HGImgFmt_CloseImageWriter(writer);
|
|
||||||
|
|
||||||
bool result = createOcrPdf(tmpFileName, getStdString(fileName).c_str(), m_ocrLanguageType);
|
|
||||||
QFile::remove(tmpFileName);
|
|
||||||
if (!result)
|
|
||||||
{
|
|
||||||
ret = HGIMGPROC_ERR_OCR;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
HGOCRMgr ocrMgr = nullptr;
|
|
||||||
ret = HGImgProc_CreateOCRMgr(0, &ocrMgr);
|
|
||||||
if (HGBASE_ERR_OK == ret)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < p->m_srcFiles.size(); ++i)
|
|
||||||
{
|
|
||||||
if (p->m_stopThread)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
emit p->updateProgress(i);
|
|
||||||
|
|
||||||
HGImgFmtReader imgFmtReader = nullptr;
|
|
||||||
ret = HGImgFmt_OpenImageReader(getStdString(p->m_srcFiles[i]).c_str(), 0, &imgFmtReader);
|
|
||||||
if (HGBASE_ERR_OK == ret)
|
|
||||||
{
|
|
||||||
HGUInt count = 0;
|
|
||||||
HGImgFmt_GetImagePageCount(imgFmtReader, &count);
|
|
||||||
for (HGUInt j = 0; j < count; ++j)
|
|
||||||
{
|
|
||||||
if (p->m_stopThread)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
HGImage img = nullptr;
|
|
||||||
ret = HGImgFmt_LoadImageFromReader(imgFmtReader, j, nullptr, 0, HGBASE_IMGORIGIN_TOP, &img);
|
|
||||||
if (HGBASE_ERR_OK == ret)
|
|
||||||
{
|
|
||||||
ret = HGImgProc_AddToImageOCRList(ocrMgr, img);
|
|
||||||
HGBase_DestroyImage(img);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ret != HGBASE_ERR_OK)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
HGImgFmt_CloseImageReader(imgFmtReader);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ret != HGBASE_ERR_OK)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ret == HGBASE_ERR_OK)
|
|
||||||
{
|
|
||||||
ret = HGImgProc_ImageListOCRToFile(ocrMgr, 0, getStdString(fileName).c_str(), NULL, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
HGImgProc_DestroyOCRMgr(ocrMgr);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
HGImgFmtWriter imgFmtWriter = nullptr;
|
|
||||||
ret = HGImgFmt_OpenImageWriter(getStdString(fileName).c_str(), 0, &imgFmtWriter);
|
|
||||||
if (HGBASE_ERR_OK == ret)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < p->m_srcFiles.size(); ++i)
|
|
||||||
{
|
|
||||||
if (p->m_stopThread)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
emit p->updateProgress(i);
|
|
||||||
|
|
||||||
HGImgFmtReader imgFmtReader = nullptr;
|
|
||||||
ret = HGImgFmt_OpenImageReader(getStdString(p->m_srcFiles[i]).c_str(), 0, &imgFmtReader);
|
|
||||||
if (HGBASE_ERR_OK == ret)
|
|
||||||
{
|
|
||||||
HGUInt count = 0;
|
|
||||||
HGImgFmt_GetImagePageCount(imgFmtReader, &count);
|
|
||||||
for (HGUInt j = 0; j < count; ++j)
|
|
||||||
{
|
|
||||||
if (p->m_stopThread)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
HGImage img = nullptr;
|
|
||||||
ret = HGImgFmt_LoadImageFromReader(imgFmtReader, j, nullptr, 0, HGBASE_IMGORIGIN_TOP, &img);
|
|
||||||
if (HGBASE_ERR_OK == ret)
|
|
||||||
{
|
|
||||||
HGImgFmtSaveInfo saveInfo;
|
|
||||||
saveInfo.jpegQuality = (HGUInt)p->m_jpegQuality;
|
|
||||||
saveInfo.tiffCompression = HGIMGFMT_TIFFCOMP_NONE;
|
|
||||||
saveInfo.tiffJpegQuality = (HGUInt)p->m_tiffQuality;
|
|
||||||
|
|
||||||
HGImageInfo imgInfo;
|
|
||||||
HGBase_GetImageInfo(img, &imgInfo);
|
|
||||||
if (HGBASE_IMGTYPE_BINARY == imgInfo.type)
|
|
||||||
{
|
|
||||||
if (1 == p->m_tiffCompressionBW)
|
|
||||||
saveInfo.tiffCompression = HGIMGFMT_TIFFCOMP_LZW;
|
|
||||||
else if (2 == p->m_tiffCompressionBW)
|
|
||||||
saveInfo.tiffCompression = HGIMGFMT_TIFFCOMP_CCITTFAX4;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (1 == p->m_tiffCompression)
|
|
||||||
saveInfo.tiffCompression = HGIMGFMT_TIFFCOMP_LZW;
|
|
||||||
else if (2 == p->m_tiffCompression)
|
|
||||||
saveInfo.tiffCompression = HGIMGFMT_TIFFCOMP_JPEG;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = HGImgFmt_SaveImageToWriter(imgFmtWriter, img, &saveInfo);
|
|
||||||
HGBase_DestroyImage(img);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ret != HGBASE_ERR_OK)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
HGImgFmt_CloseImageReader(imgFmtReader);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ret != HGBASE_ERR_OK)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
HGImgFmt_CloseImageWriter(imgFmtWriter);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
int index = 1;
|
|
||||||
|
|
||||||
for (int i = 0; i < p->m_srcFiles.size(); ++i)
|
|
||||||
{
|
|
||||||
if (p->m_stopThread)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
emit p->updateProgress(i);
|
|
||||||
|
|
||||||
HGImgFmtReader imgFmtReader = nullptr;
|
|
||||||
ret = HGImgFmt_OpenImageReader(getStdString(p->m_srcFiles[i]).c_str(), 0, &imgFmtReader);
|
|
||||||
if (HGBASE_ERR_OK == ret)
|
|
||||||
{
|
|
||||||
HGUInt count = 0;
|
|
||||||
HGImgFmt_GetImagePageCount(imgFmtReader, &count);
|
|
||||||
for (HGUInt j = 0; j < count; ++j)
|
|
||||||
{
|
|
||||||
if (p->m_stopThread)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
HGImage img = nullptr;
|
|
||||||
ret = HGImgFmt_LoadImageFromReader(imgFmtReader, j, nullptr, 0, HGBASE_IMGORIGIN_TOP, &img);
|
|
||||||
if (HGBASE_ERR_OK == ret)
|
|
||||||
{
|
|
||||||
char fileName[512];
|
|
||||||
if(p->m_srcFiles.size() > 1)
|
|
||||||
{
|
|
||||||
sprintf(fileName, "%s%03d", getStdString(p->m_destName).c_str(), index);
|
|
||||||
}else
|
|
||||||
sprintf(fileName, "%s", getStdString(p->m_destName).c_str());
|
|
||||||
|
|
||||||
++index;
|
|
||||||
|
|
||||||
QString saveFileName = p->m_destPath + QString(StdStringToUtf8(fileName).c_str()) + p->m_destExt;
|
|
||||||
|
|
||||||
HGImgFmtSaveInfo saveInfo;
|
|
||||||
saveInfo.jpegQuality = (HGUInt)p->m_jpegQuality;
|
|
||||||
saveInfo.tiffCompression = HGIMGFMT_TIFFCOMP_NONE;
|
|
||||||
saveInfo.tiffJpegQuality = (HGUInt)p->m_tiffQuality;
|
|
||||||
|
|
||||||
HGImageInfo imgInfo;
|
|
||||||
HGBase_GetImageInfo(img, &imgInfo);
|
|
||||||
if (HGBASE_IMGTYPE_BINARY == imgInfo.type)
|
|
||||||
{
|
|
||||||
if (1 == p->m_tiffCompressionBW)
|
|
||||||
saveInfo.tiffCompression = HGIMGFMT_TIFFCOMP_LZW;
|
|
||||||
else if (2 == p->m_tiffCompressionBW)
|
|
||||||
saveInfo.tiffCompression = HGIMGFMT_TIFFCOMP_CCITTFAX4;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (1 == p->m_tiffCompression)
|
|
||||||
saveInfo.tiffCompression = HGIMGFMT_TIFFCOMP_LZW;
|
|
||||||
else if (2 == p->m_tiffCompression)
|
|
||||||
saveInfo.tiffCompression = HGIMGFMT_TIFFCOMP_JPEG;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = MainWindow::saveImage(img, &saveInfo, p->m_isOcr, p->m_ocrLanguageType, getStdString(saveFileName).c_str());
|
|
||||||
HGBase_DestroyImage(img);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ret != HGBASE_ERR_OK)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
HGImgFmt_CloseImageReader(imgFmtReader);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ret != HGBASE_ERR_OK)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
emit p->finish((int)ret);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Dialog_ExportImageFile::on_updateProgress(int value)
|
|
||||||
{
|
|
||||||
ui->progressBar->setValue(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Dialog_ExportImageFile::on_finish(int ret)
|
|
||||||
{
|
|
||||||
QString str = (ret == HGBASE_ERR_OK) ? tr("export succeed") : tr("export failed: ") + MainWindow::getLogInfo(ret);
|
|
||||||
QMessageBox msg(QMessageBox::Information, tr("tip"), str, QMessageBox::Ok, this);
|
|
||||||
close();
|
|
||||||
msg.exec();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Dialog_ExportImageFile::on_pushButton_clicked()
|
|
||||||
{
|
|
||||||
m_stopThread = true;
|
|
||||||
HGBase_CloseThread(m_thread);
|
|
||||||
m_thread = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Dialog_ExportImageFile::closeEvent(QCloseEvent *e)
|
|
||||||
{
|
|
||||||
(void)e;
|
|
||||||
m_stopThread = true;
|
|
||||||
HGBase_CloseThread(m_thread);
|
|
||||||
m_thread = nullptr;
|
|
||||||
}
|
|
|
@ -1,55 +0,0 @@
|
||||||
#ifndef DIALOG_EXPORTIMAGEFILE_H
|
|
||||||
#define DIALOG_EXPORTIMAGEFILE_H
|
|
||||||
|
|
||||||
#include <QDialog>
|
|
||||||
#include "base/HGThread.h"
|
|
||||||
|
|
||||||
namespace Ui {
|
|
||||||
class Dialog_ExportImageFile;
|
|
||||||
}
|
|
||||||
|
|
||||||
class Dialog_ExportImageFile : public QDialog
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
explicit Dialog_ExportImageFile(const QString &destPath, const QString &destName, const QString &destExt,
|
|
||||||
bool isSaveAsMulti, int jpegQuality, int tiffCompressionBW, int tiffCompression, int tiffQuality, bool isOcr,
|
|
||||||
int ocrLanguageType, const QStringList &srcFiles, QWidget *parent = nullptr);
|
|
||||||
~Dialog_ExportImageFile();
|
|
||||||
|
|
||||||
private:
|
|
||||||
static void HGAPI ThreadFunc(HGThread thread, HGPointer param);
|
|
||||||
|
|
||||||
signals:
|
|
||||||
void updateProgress(int value);
|
|
||||||
void finish(int ret);
|
|
||||||
private slots:
|
|
||||||
void on_updateProgress(int value);
|
|
||||||
void on_finish(int ret);
|
|
||||||
|
|
||||||
void on_pushButton_clicked();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
virtual void closeEvent(QCloseEvent *e);
|
|
||||||
|
|
||||||
private:
|
|
||||||
Ui::Dialog_ExportImageFile *ui;
|
|
||||||
|
|
||||||
QString m_destPath;
|
|
||||||
QString m_destName;
|
|
||||||
QString m_destExt;
|
|
||||||
bool m_isSaveAsMulti;
|
|
||||||
int m_jpegQuality;
|
|
||||||
int m_tiffCompressionBW;
|
|
||||||
int m_tiffCompression;
|
|
||||||
int m_tiffQuality;
|
|
||||||
bool m_isOcr;
|
|
||||||
int m_ocrLanguageType;
|
|
||||||
QStringList m_srcFiles;
|
|
||||||
|
|
||||||
bool m_stopThread;
|
|
||||||
HGThread m_thread;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // DIALOG_EXPORTIMAGEFILE_H
|
|
|
@ -1,78 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<ui version="4.0">
|
|
||||||
<class>Dialog_ExportImageFile</class>
|
|
||||||
<widget class="QDialog" name="Dialog_ExportImageFile">
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>0</y>
|
|
||||||
<width>400</width>
|
|
||||||
<height>300</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="windowTitle">
|
|
||||||
<string>Dialog</string>
|
|
||||||
</property>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
|
||||||
<item>
|
|
||||||
<spacer name="horizontalSpacer">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>40</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QProgressBar" name="progressBar">
|
|
||||||
<property name="value">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
|
||||||
<item>
|
|
||||||
<spacer name="horizontalSpacer_2">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>40</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="pushButton">
|
|
||||||
<property name="text">
|
|
||||||
<string>stop</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<spacer name="horizontalSpacer_3">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>40</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
<resources/>
|
|
||||||
<connections/>
|
|
||||||
</ui>
|
|
|
@ -1,73 +0,0 @@
|
||||||
#include "dialog_feedback.h"
|
|
||||||
#include "ui_dialog_feedback.h"
|
|
||||||
#include <QMessageBox>
|
|
||||||
|
|
||||||
Dialog_Feedback::Dialog_Feedback(class VersionDll *versionDll, QWidget *parent) :
|
|
||||||
QDialog(parent)
|
|
||||||
, ui(new Ui::Dialog_Feedback)
|
|
||||||
, m_versionDll(versionDll)
|
|
||||||
{
|
|
||||||
ui->setupUi(this);
|
|
||||||
|
|
||||||
setWindowTitle(tr("feedback"));
|
|
||||||
setWindowFlags(Qt::Dialog | Qt::WindowCloseButtonHint);
|
|
||||||
|
|
||||||
ui->textEdit->setPlaceholderText(tr("Please leave your valuable comments and suggestions (required field)."));
|
|
||||||
ui->lineEdit->setPlaceholderText(tr("Please leave your phone number, QQ or email address (required field)."));
|
|
||||||
}
|
|
||||||
|
|
||||||
Dialog_Feedback::~Dialog_Feedback()
|
|
||||||
{
|
|
||||||
delete ui;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Dialog_Feedback::on_pbtn_submit_clicked()
|
|
||||||
{
|
|
||||||
const HGChar *oemName = nullptr;
|
|
||||||
|
|
||||||
#if defined(OEM_HANWANG)
|
|
||||||
oemName = HGVERSION_OEMNAME_HANVON;
|
|
||||||
#elif defined(OEM_LISICHENG)
|
|
||||||
oemName = HGVERSION_OEMNAME_LANXUM;
|
|
||||||
#elif defined(OEM_CANGTIAN)
|
|
||||||
oemName = HGVERSION_OEMNAME_CUMTENN;
|
|
||||||
#elif defined(OEM_ZHONGJING)
|
|
||||||
oemName = HGVERSION_OEMNAME_MICROTEK;
|
|
||||||
#elif defined(OEM_ZIGUANG)
|
|
||||||
oemName = HGVERSION_OEMNAME_UNIS;
|
|
||||||
#elif defined(OEM_NEUTRAL)
|
|
||||||
oemName = HGVERSION_OEMNAME_NEUTRAL;
|
|
||||||
#elif defined(OEM_DELI)
|
|
||||||
oemName = HGVERSION_OEMNAME_DELI;
|
|
||||||
#else
|
|
||||||
oemName = HGVERSION_OEMNAME_HUAGO;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
QString feedback = ui->textEdit->toPlainText();
|
|
||||||
QString contact = ui->lineEdit->text();
|
|
||||||
if(ui->textEdit->document()->isEmpty())
|
|
||||||
{
|
|
||||||
QMessageBox::critical(this, tr("error"), tr("Comments and suggestions cannot be empty."));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if(ui->lineEdit->text().isEmpty())
|
|
||||||
{
|
|
||||||
QMessageBox::critical(this, tr("error"), tr("The contact information column cannot be empty."));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
HGResult ret = m_versionDll->PostUserFeedback(HGVERSION_APPNAME_SCANNER, oemName, "feedback", feedback.toStdString().c_str(), contact.toStdString().c_str());
|
|
||||||
if(HGBASE_ERR_OK == ret)
|
|
||||||
{
|
|
||||||
QMessageBox::information(this, tr("tip"), tr("submit succeed."));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
QMessageBox::critical(this, tr("error"), tr("submit failed."));
|
|
||||||
}
|
|
||||||
close();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Dialog_Feedback::on_pbtn_cancel_clicked()
|
|
||||||
{
|
|
||||||
close();
|
|
||||||
}
|
|
|
@ -1,30 +0,0 @@
|
||||||
#ifndef DIALOG_FEEDBACK_H
|
|
||||||
#define DIALOG_FEEDBACK_H
|
|
||||||
|
|
||||||
#include <QDialog>
|
|
||||||
#include "VersionDll.h"
|
|
||||||
|
|
||||||
namespace Ui {
|
|
||||||
class Dialog_Feedback;
|
|
||||||
}
|
|
||||||
|
|
||||||
class Dialog_Feedback : public QDialog
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
explicit Dialog_Feedback(class VersionDll *versionDll, QWidget *parent = nullptr);
|
|
||||||
~Dialog_Feedback();
|
|
||||||
|
|
||||||
private slots:
|
|
||||||
void on_pbtn_submit_clicked();
|
|
||||||
|
|
||||||
void on_pbtn_cancel_clicked();
|
|
||||||
|
|
||||||
private:
|
|
||||||
Ui::Dialog_Feedback *ui;
|
|
||||||
|
|
||||||
VersionDll *m_versionDll;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // DIALOG_FEEDBACK_H
|
|
|
@ -1,76 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<ui version="4.0">
|
|
||||||
<class>Dialog_Feedback</class>
|
|
||||||
<widget class="QDialog" name="Dialog_Feedback">
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>0</y>
|
|
||||||
<width>488</width>
|
|
||||||
<height>281</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="windowTitle">
|
|
||||||
<string>Dialog</string>
|
|
||||||
</property>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="label_feedback">
|
|
||||||
<property name="text">
|
|
||||||
<string>feedback:</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QTextEdit" name="textEdit"/>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="label_contact">
|
|
||||||
<property name="text">
|
|
||||||
<string>contact:</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QLineEdit" name="lineEdit"/>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
|
||||||
<item>
|
|
||||||
<spacer name="horizontalSpacer">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>40</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="pbtn_submit">
|
|
||||||
<property name="text">
|
|
||||||
<string>submit</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="pbtn_cancel">
|
|
||||||
<property name="text">
|
|
||||||
<string>cancel</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
<resources/>
|
|
||||||
<connections/>
|
|
||||||
</ui>
|
|
|
@ -1,214 +0,0 @@
|
||||||
#include "dialog_fullscreen.h"
|
|
||||||
#include "ui_dialog_fullscreen.h"
|
|
||||||
#include "mainwindow.h"
|
|
||||||
#include "imgfmt/HGPdf.h"
|
|
||||||
#include "imgfmt/HGImgFmt.h"
|
|
||||||
#include "HGUIGlobal.h"
|
|
||||||
#include <assert.h>
|
|
||||||
|
|
||||||
Dialog_FullScreen::Dialog_FullScreen(class MainWindow *mainWidget, const QStringList &fileNames, int currIndex, int multiIndex)
|
|
||||||
: QDialog(nullptr)
|
|
||||||
, ui(new Ui::Dialog_FullScreen)
|
|
||||||
, m_mainWidget(mainWidget)
|
|
||||||
, m_fileNames(fileNames)
|
|
||||||
, m_currFilePath("")
|
|
||||||
, m_currIndex(currIndex)
|
|
||||||
, m_multiPageCount(0)
|
|
||||||
, m_multiIndex(multiIndex)
|
|
||||||
, m_pa_contrlWidget(new QPropertyAnimation(&m_effect_contrlWidget, "opacity", this))
|
|
||||||
, m_pa_text(new QPropertyAnimation(&m_effect_exit, "opacity", this))
|
|
||||||
{
|
|
||||||
ui->setupUi(this);
|
|
||||||
|
|
||||||
QFont font;
|
|
||||||
font.setFamily("微软雅黑");
|
|
||||||
font.setPointSize(35);//文字大小
|
|
||||||
font.setBold(true);//粗体
|
|
||||||
ui->btn_exit->setFont(font);
|
|
||||||
ui->btn_exit->setText(tr("Exit fullscreen"));
|
|
||||||
ui->btn_exit->setStyleSheet("color: rgb(255, 255, 255); background-color: rgb(0, 0, 0);");
|
|
||||||
|
|
||||||
connect(&m_timer_hide, SIGNAL(timeout()), this, SLOT(on_hide()));
|
|
||||||
connect(ui->view, SIGNAL(escape()), this, SLOT(on_escape()));
|
|
||||||
connect(ui->view, SIGNAL(mousePos(int, int)), this, SLOT(on_mousePos(int, int)));
|
|
||||||
|
|
||||||
this->setWindowFlags(Qt::FramelessWindowHint);
|
|
||||||
this->setWindowState(Qt::WindowFullScreen);
|
|
||||||
this->showFullScreen();
|
|
||||||
ui->view->setFocus();
|
|
||||||
|
|
||||||
m_pa_contrlWidget->setStartValue(0.7);
|
|
||||||
m_pa_contrlWidget->setEndValue(0.0);
|
|
||||||
m_pa_contrlWidget->setDuration(4000);
|
|
||||||
|
|
||||||
m_pa_text->setStartValue(0.7);
|
|
||||||
m_pa_text->setEndValue(0.0);
|
|
||||||
m_pa_text->setDuration(4000);
|
|
||||||
|
|
||||||
if (m_fileNames.count() > 0)
|
|
||||||
{
|
|
||||||
if (-1 != m_currIndex)
|
|
||||||
{
|
|
||||||
assert(-1 != m_multiIndex);
|
|
||||||
m_currFilePath = m_fileNames.at(m_currIndex);
|
|
||||||
m_multiPageCount = getMultiPageCount();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
assert(-1 == m_multiIndex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
assert(-1 == m_currIndex && -1 == m_multiIndex);
|
|
||||||
}
|
|
||||||
|
|
||||||
showImage();
|
|
||||||
}
|
|
||||||
|
|
||||||
Dialog_FullScreen::~Dialog_FullScreen()
|
|
||||||
{
|
|
||||||
delete ui;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Dialog_FullScreen::showImage()
|
|
||||||
{
|
|
||||||
if (-1 != m_currIndex && -1 != m_multiIndex)
|
|
||||||
{
|
|
||||||
assert(!m_currFilePath.isEmpty());
|
|
||||||
|
|
||||||
HGImage img = nullptr;
|
|
||||||
HGImgFmtReader imgFmtReader = nullptr;
|
|
||||||
HGImgFmt_OpenImageReader(getStdString(m_currFilePath).c_str(), 0, &imgFmtReader);
|
|
||||||
if (nullptr != imgFmtReader)
|
|
||||||
{
|
|
||||||
HGImgFmt_LoadImageFromReader(imgFmtReader, (HGUInt)m_multiIndex, nullptr, 0, HGBASE_IMGORIGIN_TOP, &img);
|
|
||||||
HGImgFmt_CloseImageReader(imgFmtReader);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (nullptr != img)
|
|
||||||
{
|
|
||||||
ui->view->addImage(img);
|
|
||||||
HGBase_DestroyImage(img);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ui->view->clearImage();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
setBtnOpacity(0.7);
|
|
||||||
setBtnEnable();
|
|
||||||
}
|
|
||||||
|
|
||||||
int Dialog_FullScreen::getMultiPageCount()
|
|
||||||
{
|
|
||||||
assert(-1 != m_currIndex);
|
|
||||||
assert(!m_currFilePath.isEmpty());
|
|
||||||
|
|
||||||
int count = 0;
|
|
||||||
|
|
||||||
HGImgFmtReader imgFmtReader = nullptr;
|
|
||||||
HGImgFmt_OpenImageReader(getStdString(m_currFilePath).c_str(), 0, &imgFmtReader);
|
|
||||||
if (nullptr != imgFmtReader)
|
|
||||||
{
|
|
||||||
HGImgFmt_GetImagePageCount(imgFmtReader, (HGUInt *)&count);
|
|
||||||
HGImgFmt_CloseImageReader(imgFmtReader);
|
|
||||||
}
|
|
||||||
|
|
||||||
return count;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Dialog_FullScreen::on_btn_exit_clicked()
|
|
||||||
{
|
|
||||||
m_mainWidget->exitFullScreen();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Dialog_FullScreen::on_btn_prePage_clicked()
|
|
||||||
{
|
|
||||||
if (m_fileNames.size() > 0 && (-1 == m_currIndex || m_currIndex > 0))
|
|
||||||
{
|
|
||||||
if (-1 == m_currIndex)
|
|
||||||
m_currIndex = 0;
|
|
||||||
else if (m_currIndex > 0)
|
|
||||||
--m_currIndex;
|
|
||||||
|
|
||||||
m_currFilePath = m_fileNames.at(m_currIndex);
|
|
||||||
m_multiPageCount = getMultiPageCount();
|
|
||||||
m_multiIndex = 0;
|
|
||||||
showImage();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Dialog_FullScreen::on_btn_nextPage_clicked()
|
|
||||||
{
|
|
||||||
if (m_fileNames.size() > 0 && (-1 == m_currIndex || m_currIndex < m_fileNames.size() - 1))
|
|
||||||
{
|
|
||||||
if (-1 == m_currIndex)
|
|
||||||
m_currIndex = 0;
|
|
||||||
else if (m_currIndex < m_fileNames.size() - 1)
|
|
||||||
++m_currIndex;
|
|
||||||
|
|
||||||
m_currFilePath = m_fileNames.at(m_currIndex);
|
|
||||||
m_multiPageCount = getMultiPageCount();
|
|
||||||
m_multiIndex = 0;
|
|
||||||
showImage();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Dialog_FullScreen::on_btn_pre_clicked()
|
|
||||||
{
|
|
||||||
if (-1 != m_currIndex && m_multiPageCount > 0 && m_multiIndex > 0)
|
|
||||||
{
|
|
||||||
--m_multiIndex;
|
|
||||||
showImage();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Dialog_FullScreen::on_btn_next_clicked()
|
|
||||||
{
|
|
||||||
if (-1 != m_currIndex && m_multiPageCount > 0 && m_multiIndex != -1 && m_multiIndex < m_multiPageCount - 1)
|
|
||||||
{
|
|
||||||
++m_multiIndex;
|
|
||||||
showImage();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Dialog_FullScreen::on_hide()
|
|
||||||
{
|
|
||||||
m_pa_contrlWidget->start();
|
|
||||||
m_pa_text->start();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Dialog_FullScreen::on_escape()
|
|
||||||
{
|
|
||||||
m_mainWidget->exitFullScreen();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Dialog_FullScreen::on_mousePos(int x, int y)
|
|
||||||
{
|
|
||||||
(void)x;
|
|
||||||
(void)y;
|
|
||||||
setBtnOpacity(0.7);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Dialog_FullScreen::setBtnOpacity(qreal opacity)
|
|
||||||
{
|
|
||||||
m_effect_contrlWidget.setOpacity(opacity);
|
|
||||||
ui->contrlWidget->setGraphicsEffect(&m_effect_contrlWidget);
|
|
||||||
m_effect_exit.setOpacity(opacity);
|
|
||||||
ui->btn_exit->setGraphicsEffect(&m_effect_exit);
|
|
||||||
m_pa_contrlWidget->stop();
|
|
||||||
m_pa_text->stop();
|
|
||||||
m_timer_hide.setSingleShot(true); //设置按钮显示计时为单次触发模式
|
|
||||||
m_timer_hide.start(1000); //设置按钮1秒后开始淡化
|
|
||||||
}
|
|
||||||
|
|
||||||
void Dialog_FullScreen::setBtnEnable()
|
|
||||||
{
|
|
||||||
ui->btn_prePage->setEnabled(m_fileNames.size() > 0 && (-1 == m_currIndex || m_currIndex > 0));
|
|
||||||
ui->btn_nextPage->setEnabled(m_fileNames.size() > 0 && (-1 == m_currIndex || m_currIndex < m_fileNames.size() - 1));
|
|
||||||
ui->btn_pre->setEnabled(-1 != m_currIndex && m_multiPageCount > 0 && m_multiIndex > 0);
|
|
||||||
ui->btn_next->setEnabled(-1 != m_currIndex && m_multiPageCount > 0 && m_multiIndex != -1 && m_multiIndex < m_multiPageCount - 1);
|
|
||||||
ui->btn_exit->setEnabled(true);
|
|
||||||
}
|
|
|
@ -1,59 +0,0 @@
|
||||||
#ifndef DIALOG_FULLSCREEN_H
|
|
||||||
#define DIALOG_FULLSCREEN_H
|
|
||||||
|
|
||||||
#include <QDialog>
|
|
||||||
#include <QTimer>
|
|
||||||
#include <QGraphicsOpacityEffect>
|
|
||||||
#include <QPropertyAnimation>
|
|
||||||
|
|
||||||
namespace Ui {
|
|
||||||
class Dialog_FullScreen;
|
|
||||||
}
|
|
||||||
|
|
||||||
class Dialog_FullScreen : public QDialog
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
explicit Dialog_FullScreen(class MainWindow *mainWidget, const QStringList &fileNames, int currIndex, int multiIndex);
|
|
||||||
~Dialog_FullScreen();
|
|
||||||
|
|
||||||
private slots:
|
|
||||||
void on_btn_exit_clicked();
|
|
||||||
|
|
||||||
void on_btn_prePage_clicked();
|
|
||||||
|
|
||||||
void on_btn_nextPage_clicked();
|
|
||||||
|
|
||||||
void on_btn_pre_clicked();
|
|
||||||
|
|
||||||
void on_btn_next_clicked();
|
|
||||||
|
|
||||||
void on_hide();
|
|
||||||
void on_escape();
|
|
||||||
void on_mousePos(int x, int y);
|
|
||||||
|
|
||||||
private:
|
|
||||||
void setBtnOpacity(qreal opacity);
|
|
||||||
void setBtnEnable(); //根据当前图像序号刷新按钮可见情况
|
|
||||||
void showImage();
|
|
||||||
int getMultiPageCount();
|
|
||||||
|
|
||||||
private:
|
|
||||||
Ui::Dialog_FullScreen *ui;
|
|
||||||
|
|
||||||
class MainWindow *m_mainWidget;
|
|
||||||
QStringList m_fileNames;
|
|
||||||
QString m_currFilePath;
|
|
||||||
int m_currIndex;
|
|
||||||
int m_multiPageCount;
|
|
||||||
int m_multiIndex;
|
|
||||||
|
|
||||||
QTimer m_timer_hide;
|
|
||||||
QGraphicsOpacityEffect m_effect_contrlWidget;
|
|
||||||
QGraphicsOpacityEffect m_effect_exit;
|
|
||||||
QPropertyAnimation* m_pa_contrlWidget;
|
|
||||||
QPropertyAnimation* m_pa_text;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // DIALOG_FULLSCREEN_H
|
|
|
@ -1,359 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<ui version="4.0">
|
|
||||||
<class>Dialog_FullScreen</class>
|
|
||||||
<widget class="QDialog" name="Dialog_FullScreen">
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>0</y>
|
|
||||||
<width>689</width>
|
|
||||||
<height>492</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="mouseTracking">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
<property name="windowTitle">
|
|
||||||
<string>Full Screen</string>
|
|
||||||
</property>
|
|
||||||
<property name="autoFillBackground">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
<property name="styleSheet">
|
|
||||||
<string notr="true">background-color: rgb(0, 0, 0);</string>
|
|
||||||
</property>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
|
||||||
<item>
|
|
||||||
<widget class="HGImgView" name="view" native="true">
|
|
||||||
<property name="mouseTracking">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
|
||||||
<item>
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
|
||||||
<item>
|
|
||||||
<spacer name="horizontalSpacer_9">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>40</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="btn_exit">
|
|
||||||
<property name="focusPolicy">
|
|
||||||
<enum>Qt::NoFocus</enum>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string/>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<spacer name="horizontalSpacer_10">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>40</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<spacer name="verticalSpacer">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Vertical</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>20</width>
|
|
||||||
<height>40</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
|
||||||
<item>
|
|
||||||
<spacer name="horizontalSpacer">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>40</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QWidget" name="contrlWidget" native="true">
|
|
||||||
<property name="mouseTracking">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
|
||||||
<item row="2" column="2">
|
|
||||||
<spacer name="horizontalSpacer_5">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeType">
|
|
||||||
<enum>QSizePolicy::Fixed</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>62</width>
|
|
||||||
<height>1</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
<item row="3" column="3">
|
|
||||||
<widget class="QPushButton" name="btn_next">
|
|
||||||
<property name="enabled">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
<property name="mouseTracking">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
<property name="focusPolicy">
|
|
||||||
<enum>Qt::NoFocus</enum>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string/>
|
|
||||||
</property>
|
|
||||||
<property name="icon">
|
|
||||||
<iconset resource="Scanner_resource.qrc">
|
|
||||||
<normaloff>:/images/image_rsc/actions/nextpage.png</normaloff>:/images/image_rsc/actions/nextpage.png</iconset>
|
|
||||||
</property>
|
|
||||||
<property name="iconSize">
|
|
||||||
<size>
|
|
||||||
<width>50</width>
|
|
||||||
<height>50</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="shortcut">
|
|
||||||
<string>Ctrl+Right</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="2" column="1">
|
|
||||||
<spacer name="horizontalSpacer_4">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeType">
|
|
||||||
<enum>QSizePolicy::Fixed</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>62</width>
|
|
||||||
<height>1</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
<item row="3" column="1">
|
|
||||||
<widget class="QPushButton" name="btn_prePage">
|
|
||||||
<property name="enabled">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
<property name="mouseTracking">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
<property name="focusPolicy">
|
|
||||||
<enum>Qt::NoFocus</enum>
|
|
||||||
</property>
|
|
||||||
<property name="styleSheet">
|
|
||||||
<string notr="true"/>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string/>
|
|
||||||
</property>
|
|
||||||
<property name="icon">
|
|
||||||
<iconset resource="Scanner_resource.qrc">
|
|
||||||
<normaloff>:/images/image_rsc/actions/previousfile.png</normaloff>:/images/image_rsc/actions/previousfile.png</iconset>
|
|
||||||
</property>
|
|
||||||
<property name="iconSize">
|
|
||||||
<size>
|
|
||||||
<width>50</width>
|
|
||||||
<height>50</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="shortcut">
|
|
||||||
<string>Left</string>
|
|
||||||
</property>
|
|
||||||
<property name="flat">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="2" column="5">
|
|
||||||
<spacer name="horizontalSpacer_8">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>40</width>
|
|
||||||
<height>1</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
<item row="3" column="4">
|
|
||||||
<widget class="QPushButton" name="btn_nextPage">
|
|
||||||
<property name="enabled">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
<property name="mouseTracking">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
<property name="focusPolicy">
|
|
||||||
<enum>Qt::NoFocus</enum>
|
|
||||||
</property>
|
|
||||||
<property name="styleSheet">
|
|
||||||
<string notr="true"/>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string/>
|
|
||||||
</property>
|
|
||||||
<property name="icon">
|
|
||||||
<iconset resource="Scanner_resource.qrc">
|
|
||||||
<normaloff>:/images/image_rsc/actions/nextfile.png</normaloff>:/images/image_rsc/actions/nextfile.png</iconset>
|
|
||||||
</property>
|
|
||||||
<property name="iconSize">
|
|
||||||
<size>
|
|
||||||
<width>50</width>
|
|
||||||
<height>50</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="shortcut">
|
|
||||||
<string>Right</string>
|
|
||||||
</property>
|
|
||||||
<property name="flat">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="2" column="4">
|
|
||||||
<spacer name="horizontalSpacer_7">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeType">
|
|
||||||
<enum>QSizePolicy::Fixed</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>62</width>
|
|
||||||
<height>1</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
<item row="2" column="0">
|
|
||||||
<spacer name="horizontalSpacer_3">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>40</width>
|
|
||||||
<height>1</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
<item row="2" column="3">
|
|
||||||
<spacer name="horizontalSpacer_6">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeType">
|
|
||||||
<enum>QSizePolicy::Fixed</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>62</width>
|
|
||||||
<height>1</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
<item row="3" column="2">
|
|
||||||
<widget class="QPushButton" name="btn_pre">
|
|
||||||
<property name="enabled">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
<property name="mouseTracking">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
<property name="focusPolicy">
|
|
||||||
<enum>Qt::NoFocus</enum>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string/>
|
|
||||||
</property>
|
|
||||||
<property name="icon">
|
|
||||||
<iconset resource="Scanner_resource.qrc">
|
|
||||||
<normaloff>:/images/image_rsc/actions/previouspage.png</normaloff>:/images/image_rsc/actions/previouspage.png</iconset>
|
|
||||||
</property>
|
|
||||||
<property name="iconSize">
|
|
||||||
<size>
|
|
||||||
<width>50</width>
|
|
||||||
<height>50</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="shortcut">
|
|
||||||
<string>Ctrl+Left</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<spacer name="horizontalSpacer_2">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>40</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
<customwidgets>
|
|
||||||
<customwidget>
|
|
||||||
<class>HGImgView</class>
|
|
||||||
<extends>QWidget</extends>
|
|
||||||
<header>HGImgView.h</header>
|
|
||||||
<container>1</container>
|
|
||||||
</customwidget>
|
|
||||||
</customwidgets>
|
|
||||||
<resources>
|
|
||||||
<include location="Scanner_resource.qrc"/>
|
|
||||||
</resources>
|
|
||||||
<connections/>
|
|
||||||
</ui>
|
|
|
@ -1,257 +0,0 @@
|
||||||
#include "dialog_imageeditor.h"
|
|
||||||
#include "ui_dialog_imageeditor.h"
|
|
||||||
#include "graphicsscene.h"
|
|
||||||
#include <QColorDialog>
|
|
||||||
#include <QResizeEvent>
|
|
||||||
|
|
||||||
int m_textSize[] = { 20, 26, 36, 48, 72, 96, 128, 160, 200 };
|
|
||||||
int m_lineWidth[] = { 1, 3, 5, 8 };
|
|
||||||
float m_scaled[] = { 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.8, 1.0, 1.2, 1.5, 2.0, 2.5, 4.0, 6.0 };
|
|
||||||
Dialog_ImageEditor::Dialog_ImageEditor(QWidget *parent)
|
|
||||||
: QDialog(parent)
|
|
||||||
, ui(new Ui::Dialog_ImageEditor)
|
|
||||||
, m_scene(new GraphicsScene())
|
|
||||||
, m_index_scaled(7)
|
|
||||||
, m_isFit(true)
|
|
||||||
{
|
|
||||||
ui->setupUi(this);
|
|
||||||
setWindowFlags(Qt::Dialog | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint);
|
|
||||||
for (int i = 0; i < ui->comboBox_textSize->count(); i++)
|
|
||||||
ui->comboBox_textSize->setItemData(i, m_textSize[i]);
|
|
||||||
for (int i = 0; i < ui->comboBox_lineWidth->count(); i++)
|
|
||||||
ui->comboBox_lineWidth->setItemData(i, m_lineWidth[i]);
|
|
||||||
|
|
||||||
ui->comboBox_textSize->setCurrentIndex(2);
|
|
||||||
ui->graphicsView->setScene(m_scene);
|
|
||||||
ui->graphicsView->setParent(this);
|
|
||||||
ui->btn_color->setStyleSheet("QPushButton{background-color:red;border:1px solid red;}");
|
|
||||||
|
|
||||||
QColor backgroundColor = qRgb(240, 240, 240);
|
|
||||||
ui->graphicsView->setBackgroundBrush(QBrush(backgroundColor));
|
|
||||||
}
|
|
||||||
|
|
||||||
Dialog_ImageEditor::~Dialog_ImageEditor()
|
|
||||||
{
|
|
||||||
delete m_scene;
|
|
||||||
delete ui;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Dialog_ImageEditor::setImage(const QImage &image)
|
|
||||||
{
|
|
||||||
m_imageSize = image.size();
|
|
||||||
m_dpi_x = image.dotsPerMeterX();
|
|
||||||
m_dpi_y = image.dotsPerMeterY();
|
|
||||||
QPixmap bitmap = QPixmap::fromImage(image);
|
|
||||||
m_scene->addPixmap(bitmap);
|
|
||||||
on_btn_fit_clicked();
|
|
||||||
}
|
|
||||||
|
|
||||||
QImage Dialog_ImageEditor::exportImage()
|
|
||||||
{
|
|
||||||
QImage image(m_imageSize, QImage::Format_RGB888);
|
|
||||||
image.setDotsPerMeterX(m_dpi_x);
|
|
||||||
image.setDotsPerMeterY(m_dpi_y);
|
|
||||||
QPainter painter(&image);
|
|
||||||
m_scene->render(&painter); //¹Ø¼üº¯Êý
|
|
||||||
return image;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Dialog_ImageEditor::on_btn_rect_clicked(bool checked)
|
|
||||||
{
|
|
||||||
if (checked)
|
|
||||||
{
|
|
||||||
m_scene->setItemFlag(GraphicsScene::Rect);
|
|
||||||
ui->btn_arrow->setChecked(false);
|
|
||||||
//ui->btn_rect->setChecked(false);
|
|
||||||
ui->btn_ellipse->setChecked(false);
|
|
||||||
ui->btn_text->setChecked(false);
|
|
||||||
ui->btn_line->setChecked(false);
|
|
||||||
ui->btn_pen->setChecked(false);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
m_scene->setItemFlag(GraphicsScene::None);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Dialog_ImageEditor::on_btn_ellipse_clicked(bool checked)
|
|
||||||
{
|
|
||||||
if (checked)
|
|
||||||
{
|
|
||||||
m_scene->setItemFlag(GraphicsScene::Ellipse);
|
|
||||||
ui->btn_arrow->setChecked(false);
|
|
||||||
ui->btn_rect->setChecked(false);
|
|
||||||
//ui->btn_ellipse->setChecked(false);
|
|
||||||
ui->btn_text->setChecked(false);
|
|
||||||
ui->btn_line->setChecked(false);
|
|
||||||
ui->btn_pen->setChecked(false);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
m_scene->setItemFlag(GraphicsScene::None);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Dialog_ImageEditor::on_btn_line_clicked(bool checked)
|
|
||||||
{
|
|
||||||
if (checked)
|
|
||||||
{
|
|
||||||
m_scene->setItemFlag(GraphicsScene::Line);
|
|
||||||
ui->btn_arrow->setChecked(false);
|
|
||||||
ui->btn_rect->setChecked(false);
|
|
||||||
ui->btn_ellipse->setChecked(false);
|
|
||||||
ui->btn_text->setChecked(false);
|
|
||||||
//ui->btn_line->setChecked(false);
|
|
||||||
ui->btn_pen->setChecked(false);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
m_scene->setItemFlag(GraphicsScene::None);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Dialog_ImageEditor::on_btn_text_clicked(bool checked)
|
|
||||||
{
|
|
||||||
if (checked)
|
|
||||||
{
|
|
||||||
m_scene->setItemFlag(GraphicsScene::Text);
|
|
||||||
ui->btn_arrow->setChecked(false);
|
|
||||||
ui->btn_rect->setChecked(false);
|
|
||||||
ui->btn_ellipse->setChecked(false);
|
|
||||||
//ui->btn_text->setChecked(false);
|
|
||||||
ui->btn_line->setChecked(false);
|
|
||||||
ui->btn_pen->setChecked(false);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
m_scene->setItemFlag(GraphicsScene::None);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Dialog_ImageEditor::on_btn_arrow_clicked(bool checked)
|
|
||||||
{
|
|
||||||
if (checked)
|
|
||||||
{
|
|
||||||
m_scene->setItemFlag(GraphicsScene::Arrow);
|
|
||||||
//ui->btn_arrow->setChecked(false);
|
|
||||||
ui->btn_rect->setChecked(false);
|
|
||||||
ui->btn_ellipse->setChecked(false);
|
|
||||||
ui->btn_text->setChecked(false);
|
|
||||||
ui->btn_line->setChecked(false);
|
|
||||||
ui->btn_pen->setChecked(false);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
m_scene->setItemFlag(GraphicsScene::None);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Dialog_ImageEditor::on_btn_pen_clicked(bool checked)
|
|
||||||
{
|
|
||||||
if (checked)
|
|
||||||
{
|
|
||||||
m_scene->setItemFlag(GraphicsScene::Pen);
|
|
||||||
ui->btn_arrow->setChecked(false);
|
|
||||||
ui->btn_rect->setChecked(false);
|
|
||||||
ui->btn_ellipse->setChecked(false);
|
|
||||||
ui->btn_text->setChecked(false);
|
|
||||||
ui->btn_line->setChecked(false);
|
|
||||||
//ui->btn_pen->setChecked(false);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
m_scene->setItemFlag(GraphicsScene::None);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Dialog_ImageEditor::on_btn_color_clicked()
|
|
||||||
{
|
|
||||||
QColorDialog dlg;
|
|
||||||
if (!dlg.exec()) return;
|
|
||||||
|
|
||||||
ui->btn_color->setStyleSheet(QString("QPushButton{background-color:%1;border:1px solid %2}").arg(dlg.selectedColor().name()).arg(dlg.selectedColor().name()));
|
|
||||||
m_scene->setColor(dlg.selectedColor());
|
|
||||||
}
|
|
||||||
|
|
||||||
void Dialog_ImageEditor::on_comboBox_lineWidth_currentIndexChanged(int index)
|
|
||||||
{
|
|
||||||
m_scene->setLineWidth(ui->comboBox_lineWidth->itemData(index).toInt());
|
|
||||||
}
|
|
||||||
|
|
||||||
void Dialog_ImageEditor::on_comboBox_textSize_currentIndexChanged(int index)
|
|
||||||
{
|
|
||||||
m_scene->setTextSize(ui->comboBox_textSize->itemData(index).toInt());
|
|
||||||
}
|
|
||||||
|
|
||||||
void Dialog_ImageEditor::on_btn_undo_clicked()
|
|
||||||
{
|
|
||||||
m_scene->unDo();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Dialog_ImageEditor::on_btn_ok_clicked()
|
|
||||||
{
|
|
||||||
m_scene->setItemFlag(GraphicsScene::Normal);
|
|
||||||
accept();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Dialog_ImageEditor::on_btn_cancel_clicked()
|
|
||||||
{
|
|
||||||
m_scene->setItemFlag(GraphicsScene::Normal);
|
|
||||||
reject();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Dialog_ImageEditor::on_btn_zoomIn_clicked()
|
|
||||||
{
|
|
||||||
m_isFit = false;
|
|
||||||
m_index_scaled++;
|
|
||||||
QTransform tran;
|
|
||||||
tran.scale(m_scaled[m_index_scaled], m_scaled[m_index_scaled]);
|
|
||||||
ui->graphicsView->setTransform(tran);
|
|
||||||
|
|
||||||
ui->btn_zoomOut->setEnabled(m_index_scaled > 0);
|
|
||||||
ui->btn_zoomIn->setEnabled(m_index_scaled + 1 < sizeof(m_scaled) / sizeof(m_scaled[0]));
|
|
||||||
}
|
|
||||||
|
|
||||||
void Dialog_ImageEditor::on_btn_zoomOut_clicked()
|
|
||||||
{
|
|
||||||
m_isFit = false;
|
|
||||||
m_index_scaled--;
|
|
||||||
QTransform tran;
|
|
||||||
tran.scale(m_scaled[m_index_scaled], m_scaled[m_index_scaled]);
|
|
||||||
ui->graphicsView->setTransform(tran);
|
|
||||||
|
|
||||||
ui->btn_zoomOut->setEnabled(m_index_scaled > 0);
|
|
||||||
ui->btn_zoomIn->setEnabled(m_index_scaled + 1 < sizeof(m_scaled) / sizeof(m_scaled[0]));
|
|
||||||
}
|
|
||||||
|
|
||||||
void Dialog_ImageEditor::on_btn_zoom_clicked()
|
|
||||||
{
|
|
||||||
m_isFit = false;
|
|
||||||
ui->graphicsView->setTransform(QTransform());
|
|
||||||
}
|
|
||||||
|
|
||||||
void Dialog_ImageEditor::on_btn_fit_clicked()
|
|
||||||
{
|
|
||||||
m_isFit = true;
|
|
||||||
QSizeF screenSize = ui->graphicsView->size() - QSizeF(5, 5);
|
|
||||||
QSizeF imageSize = m_imageSize;
|
|
||||||
|
|
||||||
float scale_x = screenSize.width() / imageSize.width();
|
|
||||||
float scale_y = screenSize.height() / imageSize.height();
|
|
||||||
|
|
||||||
QTransform tran;
|
|
||||||
float scale = scale_x < scale_y ? scale_x : scale_y;
|
|
||||||
tran.scale(scale, scale);
|
|
||||||
ui->graphicsView->setTransform(tran);
|
|
||||||
|
|
||||||
m_index_scaled = -1;
|
|
||||||
int scaleShiftNum = sizeof(m_scaled) / sizeof(m_scaled[0]);
|
|
||||||
for (int i = 0; i < scaleShiftNum; i++)
|
|
||||||
if (m_scaled[i] > scale)
|
|
||||||
{
|
|
||||||
m_index_scaled = i;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (scale > m_scaled[scaleShiftNum - 1])
|
|
||||||
m_index_scaled = scaleShiftNum;
|
|
||||||
|
|
||||||
ui->btn_zoomOut->setEnabled(m_index_scaled > 0);
|
|
||||||
ui->btn_zoomIn->setEnabled(m_index_scaled + 1 < scaleShiftNum);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Dialog_ImageEditor::resizeEvent(QResizeEvent* event)
|
|
||||||
{
|
|
||||||
if (m_isFit)
|
|
||||||
on_btn_fit_clicked();
|
|
||||||
|
|
||||||
QDialog::resizeEvent(event);
|
|
||||||
}
|
|
|
@ -1,71 +0,0 @@
|
||||||
#ifndef DIALOG_IMAGEEDITOR_H
|
|
||||||
#define DIALOG_IMAGEEDITOR_H
|
|
||||||
|
|
||||||
#include <QDialog>
|
|
||||||
#include <QImage>
|
|
||||||
|
|
||||||
namespace Ui {
|
|
||||||
class Dialog_ImageEditor;
|
|
||||||
}
|
|
||||||
|
|
||||||
class GraphicsScene;
|
|
||||||
class QResizeEvent;
|
|
||||||
class Dialog_ImageEditor : public QDialog
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
explicit Dialog_ImageEditor(QWidget *parent = nullptr);
|
|
||||||
~Dialog_ImageEditor();
|
|
||||||
|
|
||||||
void setImage(const QImage& image);
|
|
||||||
|
|
||||||
QImage exportImage();
|
|
||||||
|
|
||||||
private slots:
|
|
||||||
void on_btn_rect_clicked(bool checked);
|
|
||||||
|
|
||||||
void on_btn_ellipse_clicked(bool checked);
|
|
||||||
|
|
||||||
void on_btn_line_clicked(bool checked);
|
|
||||||
|
|
||||||
void on_btn_text_clicked(bool checked);
|
|
||||||
|
|
||||||
void on_btn_arrow_clicked(bool checked);
|
|
||||||
|
|
||||||
void on_btn_pen_clicked(bool checked);
|
|
||||||
|
|
||||||
void on_btn_color_clicked();
|
|
||||||
|
|
||||||
void on_comboBox_lineWidth_currentIndexChanged(int index);
|
|
||||||
|
|
||||||
void on_comboBox_textSize_currentIndexChanged(int index);
|
|
||||||
|
|
||||||
void on_btn_undo_clicked();
|
|
||||||
|
|
||||||
void on_btn_ok_clicked();
|
|
||||||
|
|
||||||
void on_btn_cancel_clicked();
|
|
||||||
|
|
||||||
void on_btn_zoomIn_clicked();
|
|
||||||
|
|
||||||
void on_btn_zoomOut_clicked();
|
|
||||||
|
|
||||||
void on_btn_zoom_clicked();
|
|
||||||
|
|
||||||
void on_btn_fit_clicked();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
void resizeEvent(QResizeEvent* event);
|
|
||||||
|
|
||||||
private:
|
|
||||||
Ui::Dialog_ImageEditor *ui;
|
|
||||||
GraphicsScene* m_scene;
|
|
||||||
QSize m_imageSize;
|
|
||||||
int m_dpi_x;
|
|
||||||
int m_dpi_y;
|
|
||||||
int m_index_scaled;
|
|
||||||
bool m_isFit;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // DIALOG_IMAGEEDITOR_H
|
|
|
@ -1,365 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<ui version="4.0">
|
|
||||||
<class>Dialog_ImageEditor</class>
|
|
||||||
<widget class="QDialog" name="Dialog_ImageEditor">
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>0</y>
|
|
||||||
<width>1378</width>
|
|
||||||
<height>378</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="windowTitle">
|
|
||||||
<string>Dialog_ImageEditor</string>
|
|
||||||
</property>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
|
||||||
<property name="topMargin">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<item>
|
|
||||||
<widget class="QGraphicsView" name="graphicsView"/>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="btn_rect">
|
|
||||||
<property name="focusPolicy">
|
|
||||||
<enum>Qt::NoFocus</enum>
|
|
||||||
</property>
|
|
||||||
<property name="toolTip">
|
|
||||||
<string>rect</string>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Rect</string>
|
|
||||||
</property>
|
|
||||||
<property name="checkable">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="btn_ellipse">
|
|
||||||
<property name="focusPolicy">
|
|
||||||
<enum>Qt::NoFocus</enum>
|
|
||||||
</property>
|
|
||||||
<property name="toolTip">
|
|
||||||
<string>ellipse</string>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Ellipse</string>
|
|
||||||
</property>
|
|
||||||
<property name="checkable">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="btn_line">
|
|
||||||
<property name="focusPolicy">
|
|
||||||
<enum>Qt::NoFocus</enum>
|
|
||||||
</property>
|
|
||||||
<property name="toolTip">
|
|
||||||
<string>line</string>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Line</string>
|
|
||||||
</property>
|
|
||||||
<property name="checkable">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="btn_pen">
|
|
||||||
<property name="focusPolicy">
|
|
||||||
<enum>Qt::NoFocus</enum>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Pen</string>
|
|
||||||
</property>
|
|
||||||
<property name="checkable">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="btn_arrow">
|
|
||||||
<property name="focusPolicy">
|
|
||||||
<enum>Qt::NoFocus</enum>
|
|
||||||
</property>
|
|
||||||
<property name="toolTip">
|
|
||||||
<string>arrow</string>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Arrow</string>
|
|
||||||
</property>
|
|
||||||
<property name="checkable">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="btn_text">
|
|
||||||
<property name="focusPolicy">
|
|
||||||
<enum>Qt::NoFocus</enum>
|
|
||||||
</property>
|
|
||||||
<property name="toolTip">
|
|
||||||
<string>text</string>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Text</string>
|
|
||||||
</property>
|
|
||||||
<property name="checkable">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="label_3">
|
|
||||||
<property name="text">
|
|
||||||
<string>Color</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="btn_color">
|
|
||||||
<property name="minimumSize">
|
|
||||||
<size>
|
|
||||||
<width>30</width>
|
|
||||||
<height>30</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="focusPolicy">
|
|
||||||
<enum>Qt::NoFocus</enum>
|
|
||||||
</property>
|
|
||||||
<property name="toolTip">
|
|
||||||
<string>color</string>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string/>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="label">
|
|
||||||
<property name="text">
|
|
||||||
<string>LineWidth</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QComboBox" name="comboBox_lineWidth">
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>1 pix</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>3 pix</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>5 pix</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>8 pix</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="label_2">
|
|
||||||
<property name="text">
|
|
||||||
<string>TextSize</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QComboBox" name="comboBox_textSize">
|
|
||||||
<property name="currentIndex">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>20</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>26</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>36</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>48</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>72</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>96</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>128</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>160</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>200</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<spacer name="horizontalSpacer_2">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>40</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="btn_zoomIn">
|
|
||||||
<property name="focusPolicy">
|
|
||||||
<enum>Qt::NoFocus</enum>
|
|
||||||
</property>
|
|
||||||
<property name="toolTip">
|
|
||||||
<string>zoomin</string>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Zoomin</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="btn_fit">
|
|
||||||
<property name="toolTip">
|
|
||||||
<string>fit</string>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Fit</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="btn_zoom">
|
|
||||||
<property name="focusPolicy">
|
|
||||||
<enum>Qt::NoFocus</enum>
|
|
||||||
</property>
|
|
||||||
<property name="toolTip">
|
|
||||||
<string>100%</string>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>1:1</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="btn_zoomOut">
|
|
||||||
<property name="focusPolicy">
|
|
||||||
<enum>Qt::NoFocus</enum>
|
|
||||||
</property>
|
|
||||||
<property name="toolTip">
|
|
||||||
<string>zoomout</string>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Zoomout</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<spacer name="horizontalSpacer_4">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>40</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="btn_undo">
|
|
||||||
<property name="focusPolicy">
|
|
||||||
<enum>Qt::NoFocus</enum>
|
|
||||||
</property>
|
|
||||||
<property name="toolTip">
|
|
||||||
<string>undo</string>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Undo</string>
|
|
||||||
</property>
|
|
||||||
<property name="shortcut">
|
|
||||||
<string>Ctrl+Z</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<spacer name="horizontalSpacer_3">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>40</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="btn_ok">
|
|
||||||
<property name="toolTip">
|
|
||||||
<string>ok</string>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Ok</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="btn_cancel">
|
|
||||||
<property name="toolTip">
|
|
||||||
<string>cancel</string>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Cancel</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
<layoutdefault spacing="6" margin="11"/>
|
|
||||||
<resources/>
|
|
||||||
<connections/>
|
|
||||||
</ui>
|
|
|
@ -1,78 +0,0 @@
|
||||||
#include "dialog_imageinfo.h"
|
|
||||||
#include "ui_dialog_imageinfo.h"
|
|
||||||
|
|
||||||
Dialog_ImageInfo::Dialog_ImageInfo(const QStringList& file_keys, const QStringList& file_values,
|
|
||||||
const QStringList& image_keys, const QStringList& image_values, QWidget *parent) :
|
|
||||||
QDialog(parent)
|
|
||||||
, ui(new Ui::Dialog_ImageInfo)
|
|
||||||
, m_file_keys(file_keys)
|
|
||||||
, m_file_values(file_values)
|
|
||||||
, m_image_keys(image_keys)
|
|
||||||
, m_image_values(image_values)
|
|
||||||
{
|
|
||||||
ui->setupUi(this);
|
|
||||||
|
|
||||||
this->resize(600,400);
|
|
||||||
setWindowFlags(Qt::Dialog | Qt::WindowCloseButtonHint);
|
|
||||||
|
|
||||||
ui->treeWidget->header()->resizeSections(QHeaderView::ResizeToContents);
|
|
||||||
ui->treeWidget->setColumnCount(2);
|
|
||||||
ui->treeWidget->setColumnWidth(0,180);
|
|
||||||
ui->treeWidget->setAlternatingRowColors(true);
|
|
||||||
|
|
||||||
ui->buttonBox->button(QDialogButtonBox::Ok)->setText(tr("ok"));
|
|
||||||
|
|
||||||
//set primery directory
|
|
||||||
QStringList list;
|
|
||||||
list<<tr("File");
|
|
||||||
QTreeWidgetItem *class1 = new QTreeWidgetItem(ui->treeWidget,list);
|
|
||||||
ui->treeWidget->addTopLevelItem(class1);
|
|
||||||
list.clear();
|
|
||||||
list<<tr("Image");
|
|
||||||
QTreeWidgetItem *class2 = new QTreeWidgetItem(ui->treeWidget,list);
|
|
||||||
ui->treeWidget->addTopLevelItem(class2);
|
|
||||||
|
|
||||||
QList<QTreeWidgetItem*> list_class;
|
|
||||||
|
|
||||||
//set class1 secondary directory
|
|
||||||
m_file_values = makeList(m_file_keys, m_file_values);
|
|
||||||
for(int i=0;i< m_file_keys.size();i++)
|
|
||||||
{
|
|
||||||
QStringList list_string;
|
|
||||||
list_string<< m_file_keys[i]<< m_file_values[i];
|
|
||||||
QTreeWidgetItem *class1_child = new QTreeWidgetItem(class1, list_string);
|
|
||||||
list_class.append(class1_child);
|
|
||||||
}
|
|
||||||
class1->addChildren(list_class);
|
|
||||||
|
|
||||||
//set class2 secondary directory
|
|
||||||
list_class.clear();
|
|
||||||
m_image_values = makeList(m_image_keys, m_image_values);
|
|
||||||
for(int i=0;i< m_image_keys.size();i++)
|
|
||||||
{
|
|
||||||
QStringList list_string;
|
|
||||||
list_string<< m_image_keys[i]<< m_image_values[i];
|
|
||||||
QTreeWidgetItem *class2_child = new QTreeWidgetItem(class2, list_string);
|
|
||||||
list_class.append(class2_child);
|
|
||||||
}
|
|
||||||
class2->addChildren(list_class);
|
|
||||||
|
|
||||||
ui->treeWidget->expandAll();
|
|
||||||
}
|
|
||||||
|
|
||||||
Dialog_ImageInfo::~Dialog_ImageInfo()
|
|
||||||
{
|
|
||||||
delete ui;
|
|
||||||
}
|
|
||||||
|
|
||||||
QStringList Dialog_ImageInfo::makeList(const QStringList& keys, QStringList values)
|
|
||||||
{
|
|
||||||
if (keys.size() < values.size())
|
|
||||||
return values.mid(0, keys.size());
|
|
||||||
else if (keys.size() > values.size())
|
|
||||||
{
|
|
||||||
for (int i = 0; i < keys.size() - values.size(); i++)
|
|
||||||
values.append(tr("None"));
|
|
||||||
}
|
|
||||||
return values;
|
|
||||||
}
|
|
|
@ -1,28 +0,0 @@
|
||||||
#ifndef DIALOG_IMAGEINFO_H
|
|
||||||
#define DIALOG_IMAGEINFO_H
|
|
||||||
|
|
||||||
#include <QDialog>
|
|
||||||
#include <QPushButton>
|
|
||||||
|
|
||||||
namespace Ui {
|
|
||||||
class Dialog_ImageInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
class Dialog_ImageInfo : public QDialog
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
explicit Dialog_ImageInfo(const QStringList& file_keys, const QStringList& file_values,
|
|
||||||
const QStringList& image_keys, const QStringList& image_values, QWidget *parent = nullptr);
|
|
||||||
~Dialog_ImageInfo();
|
|
||||||
|
|
||||||
private:
|
|
||||||
QStringList makeList(const QStringList& keys, QStringList values);
|
|
||||||
|
|
||||||
private:
|
|
||||||
Ui::Dialog_ImageInfo *ui;
|
|
||||||
QStringList m_file_keys, m_file_values, m_image_keys, m_image_values;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // DIALOG_IMAGEINFO_H
|
|
|
@ -1,85 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<ui version="4.0">
|
|
||||||
<class>Dialog_ImageInfo</class>
|
|
||||||
<widget class="QDialog" name="Dialog_ImageInfo">
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>0</y>
|
|
||||||
<width>400</width>
|
|
||||||
<height>300</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="windowTitle">
|
|
||||||
<string>Image information</string>
|
|
||||||
</property>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
|
||||||
<item>
|
|
||||||
<widget class="QTreeWidget" name="treeWidget">
|
|
||||||
<property name="editTriggers">
|
|
||||||
<set>QAbstractItemView::NoEditTriggers</set>
|
|
||||||
</property>
|
|
||||||
<property name="wordWrap">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
<attribute name="headerVisible">
|
|
||||||
<bool>false</bool>
|
|
||||||
</attribute>
|
|
||||||
<attribute name="headerStretchLastSection">
|
|
||||||
<bool>true</bool>
|
|
||||||
</attribute>
|
|
||||||
<column>
|
|
||||||
<property name="text">
|
|
||||||
<string notr="true">1</string>
|
|
||||||
</property>
|
|
||||||
</column>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QDialogButtonBox" name="buttonBox">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="standardButtons">
|
|
||||||
<set>QDialogButtonBox::Ok</set>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
<resources/>
|
|
||||||
<connections>
|
|
||||||
<connection>
|
|
||||||
<sender>buttonBox</sender>
|
|
||||||
<signal>accepted()</signal>
|
|
||||||
<receiver>Dialog_ImageInfo</receiver>
|
|
||||||
<slot>accept()</slot>
|
|
||||||
<hints>
|
|
||||||
<hint type="sourcelabel">
|
|
||||||
<x>248</x>
|
|
||||||
<y>254</y>
|
|
||||||
</hint>
|
|
||||||
<hint type="destinationlabel">
|
|
||||||
<x>157</x>
|
|
||||||
<y>274</y>
|
|
||||||
</hint>
|
|
||||||
</hints>
|
|
||||||
</connection>
|
|
||||||
<connection>
|
|
||||||
<sender>buttonBox</sender>
|
|
||||||
<signal>rejected()</signal>
|
|
||||||
<receiver>Dialog_ImageInfo</receiver>
|
|
||||||
<slot>reject()</slot>
|
|
||||||
<hints>
|
|
||||||
<hint type="sourcelabel">
|
|
||||||
<x>316</x>
|
|
||||||
<y>260</y>
|
|
||||||
</hint>
|
|
||||||
<hint type="destinationlabel">
|
|
||||||
<x>286</x>
|
|
||||||
<y>274</y>
|
|
||||||
</hint>
|
|
||||||
</hints>
|
|
||||||
</connection>
|
|
||||||
</connections>
|
|
||||||
</ui>
|
|
|
@ -1,146 +0,0 @@
|
||||||
#include "dialog_imgproc_adjust.h"
|
|
||||||
#include "ui_dialog_imgproc_adjust.h"
|
|
||||||
#include "imgproc/HGImgProc.h"
|
|
||||||
#include "app_cfg.h"
|
|
||||||
#include <assert.h>
|
|
||||||
|
|
||||||
Dialog_ImgProc_Adjust::Dialog_ImgProc_Adjust(HGImage img, QWidget *parent) :
|
|
||||||
QDialog(parent),
|
|
||||||
ui(new Ui::Dialog_ImgProc_Adjust)
|
|
||||||
{
|
|
||||||
ui->setupUi(this);
|
|
||||||
setWindowFlags(Qt::Dialog | Qt::WindowCloseButtonHint);
|
|
||||||
|
|
||||||
m_base_widget = new Widget_Imgproc_Base(this);
|
|
||||||
reinterpret_cast<QVBoxLayout*>(this->layout())->insertWidget(2, m_base_widget);
|
|
||||||
connect(m_base_widget, SIGNAL(brightness_change(int)), this, SLOT(on_brightness_change(int)));
|
|
||||||
connect(m_base_widget, SIGNAL(contrast_change(int)), this, SLOT(on_contrast_change(int)));
|
|
||||||
connect(m_base_widget, SIGNAL(gamma_change(double)), this, SLOT(on_gamma_change(double)));
|
|
||||||
|
|
||||||
ui->view_before->addImage(img);
|
|
||||||
ui->view_after->addImage(img);
|
|
||||||
|
|
||||||
m_brightness = getCfgValue("adjust", "brightness", 0);
|
|
||||||
m_base_widget->setBrightness(m_brightness);
|
|
||||||
m_contrast = getCfgValue("adjust", "contrast", 0);
|
|
||||||
m_base_widget->setContrast(m_contrast);
|
|
||||||
QString gamma = getCfgValue("adjust", "gamma", QString("1.0"));
|
|
||||||
m_gamma = atof(gamma.toStdString().c_str());
|
|
||||||
m_base_widget->setGamma(m_gamma);
|
|
||||||
|
|
||||||
ui->cbtn_preview->setChecked(getCfgValue("adjust", "preview", false));
|
|
||||||
ui->cbtn_applyImg->setChecked(getCfgValue("adjust", "applyImg", false));
|
|
||||||
|
|
||||||
ui->gbox_before->setVisible(ui->cbtn_preview->isChecked());
|
|
||||||
ui->gbox_after->setVisible(ui->cbtn_preview->isChecked());
|
|
||||||
|
|
||||||
ui->buttonBox->button(QDialogButtonBox::Ok)->setText(tr("ok"));
|
|
||||||
ui->buttonBox->button(QDialogButtonBox::Cancel)->setText(tr("cancel"));
|
|
||||||
ui->buttonBox->button(QDialogButtonBox::RestoreDefaults)->setText(tr("restore default"));
|
|
||||||
}
|
|
||||||
|
|
||||||
Dialog_ImgProc_Adjust::~Dialog_ImgProc_Adjust()
|
|
||||||
{
|
|
||||||
delete ui;
|
|
||||||
}
|
|
||||||
|
|
||||||
HGImage Dialog_ImgProc_Adjust::getBeforeImage()
|
|
||||||
{
|
|
||||||
HGImage img = nullptr;
|
|
||||||
ui->view_before->getImage(&img);
|
|
||||||
return img;
|
|
||||||
}
|
|
||||||
|
|
||||||
HGImage Dialog_ImgProc_Adjust::getAfterImage()
|
|
||||||
{
|
|
||||||
HGImage img = nullptr;
|
|
||||||
ui->view_after->getImage(&img);
|
|
||||||
return img;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Dialog_ImgProc_Adjust::on_brightness_change(int value)
|
|
||||||
{
|
|
||||||
m_brightness = value;
|
|
||||||
process();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Dialog_ImgProc_Adjust::on_contrast_change(int value)
|
|
||||||
{
|
|
||||||
m_contrast = value;
|
|
||||||
process();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Dialog_ImgProc_Adjust::on_gamma_change(double value)
|
|
||||||
{
|
|
||||||
m_gamma = value;
|
|
||||||
process();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Dialog_ImgProc_Adjust::on_cbtn_preview_toggled(bool checked)
|
|
||||||
{
|
|
||||||
reinterpret_cast<QVBoxLayout*>(this->layout())->setStretch(1, checked ? 1 : 0);
|
|
||||||
ui->gbox_before->setVisible(checked);
|
|
||||||
ui->gbox_after->setVisible(checked);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Dialog_ImgProc_Adjust::on_cbtn_applyImg_toggled(bool checked)
|
|
||||||
{
|
|
||||||
HGImage img = nullptr;
|
|
||||||
if (checked)
|
|
||||||
ui->view_after->getImage(&img);
|
|
||||||
else
|
|
||||||
ui->view_before->getImage(&img);
|
|
||||||
assert(nullptr != img);
|
|
||||||
emit applyToImage(img);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Dialog_ImgProc_Adjust::on_buttonBox_clicked(QAbstractButton *button)
|
|
||||||
{
|
|
||||||
if (ui->buttonBox->standardButton(button) == QDialogButtonBox::RestoreDefaults)
|
|
||||||
{
|
|
||||||
m_base_widget->setDefault();
|
|
||||||
m_brightness = 0;
|
|
||||||
m_contrast = 0;
|
|
||||||
m_gamma = 1.0;
|
|
||||||
process();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Dialog_ImgProc_Adjust::process()
|
|
||||||
{
|
|
||||||
HGImage img = nullptr;
|
|
||||||
ui->view_before->getImage(&img);
|
|
||||||
assert(nullptr != img);
|
|
||||||
|
|
||||||
HGImageInfo imgInfo;
|
|
||||||
HGBase_GetImageInfo(img, &imgInfo);
|
|
||||||
|
|
||||||
HGImage destImg = nullptr;
|
|
||||||
HGBase_CreateImage(imgInfo.width, imgInfo.height, imgInfo.type, imgInfo.origin, &destImg);
|
|
||||||
if (nullptr != destImg)
|
|
||||||
{
|
|
||||||
HGImgProc_ImageAdjustColors(img, destImg, m_brightness, m_contrast, (HGFloat)m_gamma);
|
|
||||||
ui->view_after->addImage(destImg);
|
|
||||||
HGBase_DestroyImage(destImg);
|
|
||||||
|
|
||||||
if (ui->cbtn_applyImg->isChecked())
|
|
||||||
{
|
|
||||||
HGImage emitImg = nullptr;
|
|
||||||
ui->view_after->getImage(&emitImg);
|
|
||||||
assert(nullptr != emitImg);
|
|
||||||
emit applyToImage(emitImg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Dialog_ImgProc_Adjust::on_buttonBox_accepted()
|
|
||||||
{
|
|
||||||
saveCfgValue("adjust", "preview", ui->cbtn_preview->isChecked());
|
|
||||||
saveCfgValue("adjust", "applyImg", ui->cbtn_applyImg->isChecked());
|
|
||||||
|
|
||||||
saveCfgValue("adjust", "brightness", m_brightness);
|
|
||||||
saveCfgValue("adjust", "contrast", m_contrast);
|
|
||||||
char gamma[32];
|
|
||||||
sprintf(gamma, "%f", m_gamma);
|
|
||||||
saveCfgValue("adjust", "gamma", QString(gamma));
|
|
||||||
}
|
|
|
@ -1,53 +0,0 @@
|
||||||
#ifndef DIALOG_IMGPROC_ADJUST_H
|
|
||||||
#define DIALOG_IMGPROC_ADJUST_H
|
|
||||||
|
|
||||||
#include <QDialog>
|
|
||||||
#include <QAbstractButton>
|
|
||||||
#include <QPushButton>
|
|
||||||
#include "widget_imgproc_base.h"
|
|
||||||
#include "base/HGImage.h"
|
|
||||||
|
|
||||||
namespace Ui {
|
|
||||||
class Dialog_ImgProc_Adjust;
|
|
||||||
}
|
|
||||||
|
|
||||||
class Dialog_ImgProc_Adjust : public QDialog
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
explicit Dialog_ImgProc_Adjust(HGImage img, QWidget *parent = nullptr);
|
|
||||||
~Dialog_ImgProc_Adjust();
|
|
||||||
|
|
||||||
HGImage getBeforeImage();
|
|
||||||
HGImage getAfterImage();
|
|
||||||
|
|
||||||
signals:
|
|
||||||
void applyToImage(HGImage img);
|
|
||||||
|
|
||||||
private slots:
|
|
||||||
void on_brightness_change(int value);
|
|
||||||
void on_contrast_change(int value);
|
|
||||||
void on_gamma_change(double value);
|
|
||||||
|
|
||||||
void on_cbtn_preview_toggled(bool checked);
|
|
||||||
|
|
||||||
void on_cbtn_applyImg_toggled(bool checked);
|
|
||||||
|
|
||||||
void on_buttonBox_clicked(QAbstractButton *button);
|
|
||||||
|
|
||||||
void on_buttonBox_accepted();
|
|
||||||
|
|
||||||
private:
|
|
||||||
void process();
|
|
||||||
|
|
||||||
private:
|
|
||||||
Ui::Dialog_ImgProc_Adjust *ui;
|
|
||||||
|
|
||||||
Widget_Imgproc_Base* m_base_widget;
|
|
||||||
int m_brightness;
|
|
||||||
int m_contrast;
|
|
||||||
double m_gamma;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // DIALOG_IMGPROC_ADJUST_H
|
|
|
@ -1,169 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<ui version="4.0">
|
|
||||||
<class>Dialog_ImgProc_Adjust</class>
|
|
||||||
<widget class="QDialog" name="Dialog_ImgProc_Adjust">
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>0</y>
|
|
||||||
<width>463</width>
|
|
||||||
<height>543</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="windowTitle">
|
|
||||||
<string>Adjust</string>
|
|
||||||
</property>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout" stretch="0,0,0,0,0">
|
|
||||||
<item>
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_4" stretch="0,1">
|
|
||||||
<item>
|
|
||||||
<widget class="QCheckBox" name="cbtn_preview">
|
|
||||||
<property name="text">
|
|
||||||
<string>Show preview</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="Line" name="line">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
|
||||||
<item>
|
|
||||||
<widget class="QGroupBox" name="gbox_before">
|
|
||||||
<property name="title">
|
|
||||||
<string>Before</string>
|
|
||||||
</property>
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
|
||||||
<item>
|
|
||||||
<widget class="HGImgView" name="view_before" native="true">
|
|
||||||
<property name="minimumSize">
|
|
||||||
<size>
|
|
||||||
<width>150</width>
|
|
||||||
<height>100</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QGroupBox" name="gbox_after">
|
|
||||||
<property name="title">
|
|
||||||
<string>After</string>
|
|
||||||
</property>
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
|
||||||
<item>
|
|
||||||
<widget class="HGImgView" name="view_after" native="true">
|
|
||||||
<property name="minimumSize">
|
|
||||||
<size>
|
|
||||||
<width>150</width>
|
|
||||||
<height>100</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_8">
|
|
||||||
<item>
|
|
||||||
<widget class="QCheckBox" name="cbtn_applyImg">
|
|
||||||
<property name="text">
|
|
||||||
<string>Apply to image</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<spacer name="horizontalSpacer_2">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>40</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<spacer name="verticalSpacer">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Vertical</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>20</width>
|
|
||||||
<height>40</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QDialogButtonBox" name="buttonBox">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="standardButtons">
|
|
||||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok|QDialogButtonBox::RestoreDefaults</set>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
<customwidgets>
|
|
||||||
<customwidget>
|
|
||||||
<class>HGImgView</class>
|
|
||||||
<extends>QWidget</extends>
|
|
||||||
<header location="global">HGImgView.h</header>
|
|
||||||
<container>1</container>
|
|
||||||
</customwidget>
|
|
||||||
</customwidgets>
|
|
||||||
<resources/>
|
|
||||||
<connections>
|
|
||||||
<connection>
|
|
||||||
<sender>buttonBox</sender>
|
|
||||||
<signal>accepted()</signal>
|
|
||||||
<receiver>Dialog_ImgProc_Adjust</receiver>
|
|
||||||
<slot>accept()</slot>
|
|
||||||
<hints>
|
|
||||||
<hint type="sourcelabel">
|
|
||||||
<x>248</x>
|
|
||||||
<y>254</y>
|
|
||||||
</hint>
|
|
||||||
<hint type="destinationlabel">
|
|
||||||
<x>157</x>
|
|
||||||
<y>274</y>
|
|
||||||
</hint>
|
|
||||||
</hints>
|
|
||||||
</connection>
|
|
||||||
<connection>
|
|
||||||
<sender>buttonBox</sender>
|
|
||||||
<signal>rejected()</signal>
|
|
||||||
<receiver>Dialog_ImgProc_Adjust</receiver>
|
|
||||||
<slot>reject()</slot>
|
|
||||||
<hints>
|
|
||||||
<hint type="sourcelabel">
|
|
||||||
<x>316</x>
|
|
||||||
<y>260</y>
|
|
||||||
</hint>
|
|
||||||
<hint type="destinationlabel">
|
|
||||||
<x>286</x>
|
|
||||||
<y>274</y>
|
|
||||||
</hint>
|
|
||||||
</hints>
|
|
||||||
</connection>
|
|
||||||
</connections>
|
|
||||||
</ui>
|
|
|
@ -1,180 +0,0 @@
|
||||||
#include "dialog_imgproc_autocrop.h"
|
|
||||||
#include "ui_dialog_imgproc_autocrop.h"
|
|
||||||
#include <QAbstractButton>
|
|
||||||
#include <QPushButton>
|
|
||||||
#include <QMouseEvent>
|
|
||||||
#include <QDebug>
|
|
||||||
#include "app_cfg.h"
|
|
||||||
|
|
||||||
Dialog_ImgProc_AutoCrop::Dialog_ImgProc_AutoCrop(QWidget *parent)
|
|
||||||
: QDialog(parent)
|
|
||||||
, ui(new Ui::Dialog_ImgProc_AutoCrop)
|
|
||||||
, m_example_flag(-1)
|
|
||||||
, m_btnGroup_polygon(this)
|
|
||||||
, m_btnGroup_backgroundColor(this)
|
|
||||||
, m_isCrop(false)
|
|
||||||
, m_isDeskew(false)
|
|
||||||
, m_isFillBlank(false)
|
|
||||||
, m_isConvex(true)
|
|
||||||
, m_isAutoColor(true)
|
|
||||||
, m_isUseAdvancedParam(false)
|
|
||||||
, m_threshold(40)
|
|
||||||
, m_noise(8)
|
|
||||||
, m_indent(5)
|
|
||||||
{
|
|
||||||
ui->setupUi(this);
|
|
||||||
setWindowFlags(Qt::Dialog | Qt::WindowCloseButtonHint);
|
|
||||||
setWindowTitle(tr("Image crop"));
|
|
||||||
|
|
||||||
ui->spin_noise->setMinimum(2);
|
|
||||||
|
|
||||||
m_btnGroup_polygon.addButton(ui->rbtn_convex);
|
|
||||||
m_btnGroup_polygon.addButton(ui->rbtn_concave);
|
|
||||||
m_btnGroup_backgroundColor.addButton(ui->rbtn_autoColor);
|
|
||||||
m_btnGroup_backgroundColor.addButton(ui->rbtn_defaultColor);
|
|
||||||
|
|
||||||
ui->cbtn_crop->setChecked(getCfgValue("autoCrop", "crop", false));
|
|
||||||
ui->cbtn_corrSkew->setChecked(getCfgValue("autoCrop", "deskew", false));
|
|
||||||
ui->gbox_fillBlank->setChecked(getCfgValue("autoCrop", "fillBlank", false));
|
|
||||||
bool convex = getCfgValue("autoCrop", "convex", true);
|
|
||||||
if (convex)
|
|
||||||
ui->rbtn_convex->setChecked(true);
|
|
||||||
else
|
|
||||||
ui->rbtn_concave->setChecked(true);
|
|
||||||
bool autoColor = getCfgValue("autoCrop", "autoColor", true);
|
|
||||||
if (autoColor)
|
|
||||||
ui->rbtn_autoColor->setChecked(true);
|
|
||||||
else
|
|
||||||
ui->rbtn_defaultColor->setChecked(true);
|
|
||||||
ui->gbox_param->setChecked(getCfgValue("autoCrop", "useAdvancedParam", false));
|
|
||||||
ui->spin_threshold->setValue(getCfgValue("autoCrop", "threshold", 40));
|
|
||||||
ui->spin_noise->setValue(getCfgValue("autoCrop", "noise", 8));
|
|
||||||
ui->spin_indent->setValue(getCfgValue("autoCrop", "indent", 5));
|
|
||||||
|
|
||||||
ui->lab_imgBefore->setPixmap(QPixmap::fromImage(QImage()));
|
|
||||||
ui->lab_arrow->setPixmap(QPixmap::fromImage(QImage()));
|
|
||||||
ui->lab_imgAfter->setPixmap(QPixmap::fromImage(QImage()));
|
|
||||||
|
|
||||||
ui->buttonBox->button(QDialogButtonBox::Ok)->setText(tr("ok"));
|
|
||||||
ui->buttonBox->button(QDialogButtonBox::Cancel)->setText(tr("cancel"));
|
|
||||||
ui->buttonBox->button(QDialogButtonBox::RestoreDefaults)->setText(tr("restore default"));
|
|
||||||
|
|
||||||
this->setMouseTracking(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
Dialog_ImgProc_AutoCrop::~Dialog_ImgProc_AutoCrop()
|
|
||||||
{
|
|
||||||
delete ui;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Dialog_ImgProc_AutoCrop::mouseMoveEvent(QMouseEvent *event)
|
|
||||||
{
|
|
||||||
QRect rect_cbtn_crop(ui->cbtn_crop->mapTo(this, QPoint(0, 0)), ui->cbtn_crop->size());
|
|
||||||
QRect rect_cbtn_corrSkew(ui->cbtn_corrSkew->mapTo(this, QPoint(0, 0)), ui->cbtn_corrSkew->size());
|
|
||||||
QRect rect_gbox_fillBlank(ui->gbox_fillBlank->mapTo(this, QPoint(0, 0)), ui->gbox_fillBlank->size());
|
|
||||||
QRect rect_rbtn_convex(ui->rbtn_convex->mapTo(this, QPoint(0, 0)), ui->rbtn_convex->size());
|
|
||||||
QRect rect_rbtn_concave(ui->rbtn_concave->mapTo(this, QPoint(0, 0)), ui->rbtn_concave->size());
|
|
||||||
QRect rect_rbtn_autoColor(ui->rbtn_autoColor->mapTo(this, QPoint(0, 0)), ui->rbtn_autoColor->size());
|
|
||||||
QRect rect_rbtn_defaultColor(ui->rbtn_defaultColor->mapTo(this, QPoint(0, 0)), ui->rbtn_defaultColor->size());
|
|
||||||
|
|
||||||
if (rect_cbtn_crop.contains(event->pos()) && m_example_flag != 0)
|
|
||||||
updateExample(0);
|
|
||||||
else if (rect_cbtn_corrSkew.contains(event->pos()) && m_example_flag != 1)
|
|
||||||
updateExample(1);
|
|
||||||
else if (rect_gbox_fillBlank.contains(event->pos()))
|
|
||||||
{
|
|
||||||
if(ui->gbox_fillBlank->isChecked())
|
|
||||||
{
|
|
||||||
if(rect_rbtn_convex.contains(event->pos()) && m_example_flag != 3)
|
|
||||||
updateExample(3);
|
|
||||||
else if(rect_rbtn_concave.contains(event->pos()) && m_example_flag != 4)
|
|
||||||
updateExample(4);
|
|
||||||
else if (rect_rbtn_autoColor.contains(event->pos()) && m_example_flag != 5)
|
|
||||||
updateExample(5);
|
|
||||||
else if (rect_rbtn_defaultColor.contains(event->pos()) && m_example_flag != 6)
|
|
||||||
updateExample(6);
|
|
||||||
else if(m_example_flag < 2 || m_example_flag > 6)
|
|
||||||
updateExample(2);
|
|
||||||
}
|
|
||||||
else if(m_example_flag != 2)
|
|
||||||
updateExample(2);
|
|
||||||
}
|
|
||||||
QDialog::mouseMoveEvent(event);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Dialog_ImgProc_AutoCrop::on_buttonBox_clicked(QAbstractButton *button)
|
|
||||||
{
|
|
||||||
if(ui->buttonBox->standardButton(button) == QDialogButtonBox::RestoreDefaults)
|
|
||||||
{
|
|
||||||
ui->cbtn_crop->setChecked(false);
|
|
||||||
ui->cbtn_corrSkew->setChecked(false);
|
|
||||||
ui->gbox_fillBlank->setChecked(false);
|
|
||||||
ui->rbtn_convex->setChecked(true);
|
|
||||||
ui->rbtn_autoColor->setChecked(true);
|
|
||||||
ui->gbox_param->setChecked(false);
|
|
||||||
ui->spin_threshold->setValue(40);
|
|
||||||
ui->spin_noise->setValue(8);
|
|
||||||
ui->spin_indent->setValue(5);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Dialog_ImgProc_AutoCrop::on_buttonBox_accepted()
|
|
||||||
{
|
|
||||||
m_isCrop = ui->cbtn_crop->isChecked();
|
|
||||||
saveCfgValue("autoCrop", "crop", m_isCrop);
|
|
||||||
m_isDeskew = ui->cbtn_corrSkew->isChecked();
|
|
||||||
saveCfgValue("autoCrop", "deskew", m_isDeskew);
|
|
||||||
m_isFillBlank = ui->gbox_fillBlank->isChecked();
|
|
||||||
saveCfgValue("autoCrop", "fillBlank", m_isFillBlank);
|
|
||||||
m_isConvex = ui->rbtn_convex->isChecked();
|
|
||||||
saveCfgValue("autoCrop", "convex", m_isConvex);
|
|
||||||
m_isAutoColor = ui->rbtn_autoColor->isChecked();
|
|
||||||
saveCfgValue("autoCrop", "autoColor", m_isAutoColor);
|
|
||||||
m_isUseAdvancedParam = ui->gbox_param->isChecked();
|
|
||||||
saveCfgValue("autoCrop", "useAdvancedParam", m_isUseAdvancedParam);
|
|
||||||
m_threshold = ui->spin_threshold->value();
|
|
||||||
saveCfgValue("autoCrop", "threshold", m_threshold);
|
|
||||||
m_noise = ui->spin_noise->value();
|
|
||||||
saveCfgValue("autoCrop", "noise", m_noise);
|
|
||||||
m_indent = ui->spin_indent->value();
|
|
||||||
saveCfgValue("autoCrop", "indent", m_indent);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Dialog_ImgProc_AutoCrop::updateExample(int example)
|
|
||||||
{
|
|
||||||
if(m_example_flag == -1)
|
|
||||||
ui->lab_arrow->setPixmap(QPixmap::fromImage(QImage(":images/image_rsc/example/example_arrow.png")));
|
|
||||||
m_example_flag = example;
|
|
||||||
switch (example) {
|
|
||||||
case 0:
|
|
||||||
ui->lab_imgBefore->setPixmap(QPixmap::fromImage(QImage(":images/image_rsc/example/example_black_before.png")));
|
|
||||||
ui->lab_imgAfter->setPixmap(QPixmap::fromImage(QImage(":images/image_rsc/example/example_crop_after.png")));
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
ui->lab_imgBefore->setPixmap(QPixmap::fromImage(QImage(":images/image_rsc/example/example_deskew_before.png")));
|
|
||||||
ui->lab_imgAfter->setPixmap(QPixmap::fromImage(QImage(":images/image_rsc/example/example_deskew_after.png")));
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
ui->lab_imgBefore->setPixmap(QPixmap::fromImage(QImage(":images/image_rsc/example/example_black_before.png")));
|
|
||||||
ui->lab_imgAfter->setPixmap(QPixmap::fromImage(QImage(":images/image_rsc/example/example_black_after.png")));
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
ui->lab_imgBefore->setPixmap(QPixmap::fromImage(QImage(":images/image_rsc/example/example_fillblack_before.png")));
|
|
||||||
ui->lab_imgAfter->setPixmap(QPixmap::fromImage(QImage(":images/image_rsc/example/example_fillblack_convex.png")));
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
ui->lab_imgBefore->setPixmap(QPixmap::fromImage(QImage(":images/image_rsc/example/example_fillblack_before.png")));
|
|
||||||
ui->lab_imgAfter->setPixmap(QPixmap::fromImage(QImage(":images/image_rsc/example/example_fillblack_concave.png")));
|
|
||||||
break;
|
|
||||||
case 5:
|
|
||||||
ui->lab_imgBefore->setPixmap(QPixmap::fromImage(QImage(":images/image_rsc/example/example_fillcolor_before.png")));
|
|
||||||
ui->lab_imgAfter->setPixmap(QPixmap::fromImage(QImage(":images/image_rsc/example/example_fillcolor_auto.png")));
|
|
||||||
break;
|
|
||||||
case 6:
|
|
||||||
ui->lab_imgBefore->setPixmap(QPixmap::fromImage(QImage(":images/image_rsc/example/example_fillcolor_before.png")));
|
|
||||||
ui->lab_imgAfter->setPixmap(QPixmap::fromImage(QImage(":images/image_rsc/example/example_fillcolor_default.png")));
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,58 +0,0 @@
|
||||||
#ifndef DIALOG_IMGPROC_AUTOCROP_H
|
|
||||||
#define DIALOG_IMGPROC_AUTOCROP_H
|
|
||||||
|
|
||||||
#include <QDialog>
|
|
||||||
#include <QButtonGroup>
|
|
||||||
|
|
||||||
class QAbstractButton;
|
|
||||||
namespace Ui {
|
|
||||||
class Dialog_ImgProc_AutoCrop;
|
|
||||||
}
|
|
||||||
|
|
||||||
class Dialog_ImgProc_AutoCrop : public QDialog
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
explicit Dialog_ImgProc_AutoCrop(QWidget *parent = nullptr);
|
|
||||||
~Dialog_ImgProc_AutoCrop();
|
|
||||||
|
|
||||||
bool isCrop() {return m_isCrop;}
|
|
||||||
bool isDeskew() {return m_isDeskew;}
|
|
||||||
bool isFillBlank() {return m_isFillBlank;}
|
|
||||||
bool isConvex() {return m_isConvex;}
|
|
||||||
bool isAutoColor() {return m_isAutoColor;}
|
|
||||||
bool isUseAdvancedParam() {return m_isUseAdvancedParam;}
|
|
||||||
int getThreshold() {return m_threshold;}
|
|
||||||
int getNoise() {return m_noise;}
|
|
||||||
int getIndent() {return m_indent;}
|
|
||||||
|
|
||||||
protected:
|
|
||||||
void mouseMoveEvent(QMouseEvent *event);
|
|
||||||
|
|
||||||
private slots:
|
|
||||||
void on_buttonBox_clicked(QAbstractButton *button);
|
|
||||||
void on_buttonBox_accepted();
|
|
||||||
|
|
||||||
private:
|
|
||||||
void updateExample(int example);//example: 0 - autocrop; 1 - deskew; 2 - fillblack; 3 - fillblack_convex; 4 - fillblack_concave
|
|
||||||
|
|
||||||
private:
|
|
||||||
Ui::Dialog_ImgProc_AutoCrop *ui;
|
|
||||||
int m_example_flag;
|
|
||||||
|
|
||||||
QButtonGroup m_btnGroup_polygon;
|
|
||||||
QButtonGroup m_btnGroup_backgroundColor;
|
|
||||||
|
|
||||||
bool m_isCrop;
|
|
||||||
bool m_isDeskew;
|
|
||||||
bool m_isFillBlank;
|
|
||||||
bool m_isConvex;
|
|
||||||
bool m_isAutoColor;
|
|
||||||
bool m_isUseAdvancedParam;
|
|
||||||
int m_threshold;
|
|
||||||
int m_noise;
|
|
||||||
int m_indent;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // DIALOG_IMGPROC_AUTOCROP_H
|
|
|
@ -1,372 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<ui version="4.0">
|
|
||||||
<class>Dialog_ImgProc_AutoCrop</class>
|
|
||||||
<widget class="QDialog" name="Dialog_ImgProc_AutoCrop">
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>0</y>
|
|
||||||
<width>600</width>
|
|
||||||
<height>408</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="minimumSize">
|
|
||||||
<size>
|
|
||||||
<width>0</width>
|
|
||||||
<height>0</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="maximumSize">
|
|
||||||
<size>
|
|
||||||
<width>600</width>
|
|
||||||
<height>420</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="windowTitle">
|
|
||||||
<string>Auto crop</string>
|
|
||||||
</property>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
|
||||||
<item>
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_5">
|
|
||||||
<item>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
|
||||||
<item>
|
|
||||||
<widget class="QCheckBox" name="cbtn_crop">
|
|
||||||
<property name="text">
|
|
||||||
<string>Auto crop</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QCheckBox" name="cbtn_corrSkew">
|
|
||||||
<property name="text">
|
|
||||||
<string>Auto correct skew</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QGroupBox" name="gbox_fillBlank">
|
|
||||||
<property name="mouseTracking">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
<property name="title">
|
|
||||||
<string>Fill black frame type</string>
|
|
||||||
</property>
|
|
||||||
<property name="checkable">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
<property name="checked">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
<layout class="QFormLayout" name="formLayout">
|
|
||||||
<item row="0" column="0">
|
|
||||||
<widget class="QRadioButton" name="rbtn_convex">
|
|
||||||
<property name="text">
|
|
||||||
<string>Convex polygon</string>
|
|
||||||
</property>
|
|
||||||
<property name="checked">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="1">
|
|
||||||
<widget class="QRadioButton" name="rbtn_concave">
|
|
||||||
<property name="text">
|
|
||||||
<string>Concave polygon</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="0">
|
|
||||||
<widget class="QRadioButton" name="rbtn_autoColor">
|
|
||||||
<property name="text">
|
|
||||||
<string>Auto Color</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="1">
|
|
||||||
<widget class="QRadioButton" name="rbtn_defaultColor">
|
|
||||||
<property name="text">
|
|
||||||
<string>Default Color</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QGroupBox" name="gbox_param">
|
|
||||||
<property name="title">
|
|
||||||
<string>Advanced parameters</string>
|
|
||||||
</property>
|
|
||||||
<property name="checkable">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
<property name="checked">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
|
||||||
<item>
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="lab_threshold">
|
|
||||||
<property name="maximumSize">
|
|
||||||
<size>
|
|
||||||
<width>16777215</width>
|
|
||||||
<height>16777215</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Threshold</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QSpinBox" name="spin_threshold">
|
|
||||||
<property name="maximumSize">
|
|
||||||
<size>
|
|
||||||
<width>16777215</width>
|
|
||||||
<height>16777215</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="maximum">
|
|
||||||
<number>255</number>
|
|
||||||
</property>
|
|
||||||
<property name="value">
|
|
||||||
<number>40</number>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="lab_noise">
|
|
||||||
<property name="text">
|
|
||||||
<string>Anti background noise</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QSpinBox" name="spin_noise">
|
|
||||||
<property name="maximumSize">
|
|
||||||
<size>
|
|
||||||
<width>16777215</width>
|
|
||||||
<height>16777215</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="maximum">
|
|
||||||
<number>80</number>
|
|
||||||
</property>
|
|
||||||
<property name="value">
|
|
||||||
<number>40</number>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="lab_indent">
|
|
||||||
<property name="text">
|
|
||||||
<string>Edge indent</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QSpinBox" name="spin_indent">
|
|
||||||
<property name="maximumSize">
|
|
||||||
<size>
|
|
||||||
<width>16777215</width>
|
|
||||||
<height>16777215</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="maximum">
|
|
||||||
<number>20</number>
|
|
||||||
</property>
|
|
||||||
<property name="value">
|
|
||||||
<number>5</number>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<spacer name="verticalSpacer_2">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Vertical</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>20</width>
|
|
||||||
<height>40</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="Line" name="line">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Vertical</enum>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
|
||||||
<item>
|
|
||||||
<spacer name="verticalSpacer_3">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Vertical</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>20</width>
|
|
||||||
<height>40</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_6">
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="lab_imgBefore">
|
|
||||||
<property name="minimumSize">
|
|
||||||
<size>
|
|
||||||
<width>100</width>
|
|
||||||
<height>100</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="maximumSize">
|
|
||||||
<size>
|
|
||||||
<width>100</width>
|
|
||||||
<height>100</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>before</string>
|
|
||||||
</property>
|
|
||||||
<property name="alignment">
|
|
||||||
<set>Qt::AlignCenter</set>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="lab_arrow">
|
|
||||||
<property name="minimumSize">
|
|
||||||
<size>
|
|
||||||
<width>30</width>
|
|
||||||
<height>30</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="maximumSize">
|
|
||||||
<size>
|
|
||||||
<width>36</width>
|
|
||||||
<height>36</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string/>
|
|
||||||
</property>
|
|
||||||
<property name="pixmap">
|
|
||||||
<pixmap>:/image_rsc/example/example_arrow.png</pixmap>
|
|
||||||
</property>
|
|
||||||
<property name="alignment">
|
|
||||||
<set>Qt::AlignCenter</set>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="lab_imgAfter">
|
|
||||||
<property name="minimumSize">
|
|
||||||
<size>
|
|
||||||
<width>100</width>
|
|
||||||
<height>100</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="maximumSize">
|
|
||||||
<size>
|
|
||||||
<width>100</width>
|
|
||||||
<height>100</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>after</string>
|
|
||||||
</property>
|
|
||||||
<property name="alignment">
|
|
||||||
<set>Qt::AlignCenter</set>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<spacer name="verticalSpacer">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Vertical</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>20</width>
|
|
||||||
<height>40</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QDialogButtonBox" name="buttonBox">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="standardButtons">
|
|
||||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok|QDialogButtonBox::RestoreDefaults</set>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
<resources/>
|
|
||||||
<connections>
|
|
||||||
<connection>
|
|
||||||
<sender>buttonBox</sender>
|
|
||||||
<signal>accepted()</signal>
|
|
||||||
<receiver>Dialog_ImgProc_AutoCrop</receiver>
|
|
||||||
<slot>accept()</slot>
|
|
||||||
<hints>
|
|
||||||
<hint type="sourcelabel">
|
|
||||||
<x>248</x>
|
|
||||||
<y>254</y>
|
|
||||||
</hint>
|
|
||||||
<hint type="destinationlabel">
|
|
||||||
<x>157</x>
|
|
||||||
<y>274</y>
|
|
||||||
</hint>
|
|
||||||
</hints>
|
|
||||||
</connection>
|
|
||||||
<connection>
|
|
||||||
<sender>buttonBox</sender>
|
|
||||||
<signal>rejected()</signal>
|
|
||||||
<receiver>Dialog_ImgProc_AutoCrop</receiver>
|
|
||||||
<slot>reject()</slot>
|
|
||||||
<hints>
|
|
||||||
<hint type="sourcelabel">
|
|
||||||
<x>316</x>
|
|
||||||
<y>260</y>
|
|
||||||
</hint>
|
|
||||||
<hint type="destinationlabel">
|
|
||||||
<x>286</x>
|
|
||||||
<y>274</y>
|
|
||||||
</hint>
|
|
||||||
</hints>
|
|
||||||
</connection>
|
|
||||||
</connections>
|
|
||||||
</ui>
|
|
|
@ -1,86 +0,0 @@
|
||||||
#include "dialog_input.h"
|
|
||||||
#include "ui_dialog_input.h"
|
|
||||||
#include <qmessagebox.h>
|
|
||||||
#include <QRegularExpression>
|
|
||||||
|
|
||||||
Dialog_Input::Dialog_Input(QWidget *parent) :
|
|
||||||
QDialog(parent),
|
|
||||||
ui(new Ui::Dialog_Input)
|
|
||||||
{
|
|
||||||
ui->setupUi(this);
|
|
||||||
setWindowFlags(Qt::Dialog | Qt::WindowCloseButtonHint);
|
|
||||||
setWindowTitle(tr("configuration scheme name change"));
|
|
||||||
}
|
|
||||||
|
|
||||||
Dialog_Input::~Dialog_Input()
|
|
||||||
{
|
|
||||||
delete ui;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Dialog_Input::on_pushButton_clicked()
|
|
||||||
{
|
|
||||||
QString text = ui->lineEdit->text();
|
|
||||||
static QRegularExpression re("\\s");
|
|
||||||
text.remove(re);//Remove space
|
|
||||||
|
|
||||||
std::string str(text.toStdString());
|
|
||||||
int pos = 0;
|
|
||||||
while(pos < str.length() && str[pos++] == ' ');
|
|
||||||
if(--pos > 0)
|
|
||||||
str.erase(0, pos);
|
|
||||||
pos = str.length() - 1;
|
|
||||||
while(pos >= 0)
|
|
||||||
{
|
|
||||||
if(str[pos] != ' ')
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
str.erase(pos + 1);
|
|
||||||
|
|
||||||
// if(str.empty())
|
|
||||||
// {
|
|
||||||
// QString title(QString::fromStdString("\351\224\231\350\257\257")),
|
|
||||||
// text(QString::fromStdString("\350\276\223\345\205\245\351\235\236\346\263\225"));
|
|
||||||
|
|
||||||
// QMessageBox::warning(this, title, text);
|
|
||||||
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
|
|
||||||
if (ui->lineEdit->text().isEmpty())
|
|
||||||
{
|
|
||||||
QMessageBox msg(QMessageBox::Information, tr("tips"), tr("The content can not be empty"), QMessageBox::Ok, this);
|
|
||||||
msg.exec();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
val_ = QString::fromStdString(str);
|
|
||||||
accept();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Dialog_Input::on_pushButton_2_clicked()
|
|
||||||
{
|
|
||||||
reject();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Dialog_Input::init_value(const QString& str)
|
|
||||||
{
|
|
||||||
val_ = str;
|
|
||||||
ui->lineEdit->setText(str);
|
|
||||||
ui->lineEdit->setSelection(0, str.length());
|
|
||||||
}
|
|
||||||
QString Dialog_Input::get_inputting_value(void)
|
|
||||||
{
|
|
||||||
return val_;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString Dialog_Input::getText()
|
|
||||||
{
|
|
||||||
QString text = ui->lineEdit->text();
|
|
||||||
return text.toUtf8();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Dialog_Input::setEditText(const QString& text)
|
|
||||||
{
|
|
||||||
ui->lineEdit->setText(text);
|
|
||||||
ui->lineEdit->selectAll();
|
|
||||||
}
|
|
|
@ -1,35 +0,0 @@
|
||||||
#ifndef DIALOG_INPUT_H
|
|
||||||
#define DIALOG_INPUT_H
|
|
||||||
|
|
||||||
#include <QDialog>
|
|
||||||
|
|
||||||
namespace Ui {
|
|
||||||
class Dialog_Input;
|
|
||||||
}
|
|
||||||
|
|
||||||
class Dialog_Input : public QDialog
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
QString val_;
|
|
||||||
|
|
||||||
public:
|
|
||||||
explicit Dialog_Input(QWidget *parent = nullptr);
|
|
||||||
~Dialog_Input();
|
|
||||||
|
|
||||||
public:
|
|
||||||
void init_value(const QString& str);
|
|
||||||
QString get_inputting_value(void);
|
|
||||||
QString getText();
|
|
||||||
void setEditText(const QString& text);
|
|
||||||
|
|
||||||
private slots:
|
|
||||||
void on_pushButton_clicked();
|
|
||||||
|
|
||||||
void on_pushButton_2_clicked();
|
|
||||||
|
|
||||||
private:
|
|
||||||
Ui::Dialog_Input *ui;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // DIALOG_INPUT_H
|
|
|
@ -1,85 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<ui version="4.0">
|
|
||||||
<class>Dialog_Input</class>
|
|
||||||
<widget class="QDialog" name="Dialog_Input">
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>0</y>
|
|
||||||
<width>282</width>
|
|
||||||
<height>82</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="windowTitle">
|
|
||||||
<string>Dialog</string>
|
|
||||||
</property>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
|
||||||
<item>
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="label">
|
|
||||||
<property name="midLineWidth">
|
|
||||||
<number>-1</number>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>输入:</string>
|
|
||||||
</property>
|
|
||||||
<property name="margin">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QLineEdit" name="lineEdit"/>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<spacer name="verticalSpacer">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Vertical</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>20</width>
|
|
||||||
<height>40</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
|
||||||
<item>
|
|
||||||
<spacer name="horizontalSpacer">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>40</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="pushButton">
|
|
||||||
<property name="text">
|
|
||||||
<string>Ok</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="pushButton_2">
|
|
||||||
<property name="text">
|
|
||||||
<string>Cancel</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
<resources/>
|
|
||||||
<connections/>
|
|
||||||
</ui>
|
|
|
@ -1,49 +0,0 @@
|
||||||
#include "dialog_insertindex.h"
|
|
||||||
#include "ui_dialog_insertindex.h"
|
|
||||||
#include <QButtonGroup>
|
|
||||||
#include <QPushButton>
|
|
||||||
#include "app_cfg.h"
|
|
||||||
|
|
||||||
Dialog_InsertIndex::Dialog_InsertIndex(QWidget *parent) :
|
|
||||||
QDialog(parent),
|
|
||||||
ui(new Ui::Dialog_InsertIndex),
|
|
||||||
button_group(new QButtonGroup)
|
|
||||||
{
|
|
||||||
ui->setupUi(this);
|
|
||||||
setWindowFlags(Qt::Dialog | Qt::WindowCloseButtonHint);
|
|
||||||
|
|
||||||
button_group->addButton(ui->rbtn_first, 0);
|
|
||||||
button_group->addButton(ui->rbtn_beforeCurr, 1);
|
|
||||||
button_group->addButton(ui->rbtn_afterCurr, 2);
|
|
||||||
button_group->addButton(ui->rbtn_last, 3);
|
|
||||||
|
|
||||||
ui->buttonBox->button(QDialogButtonBox::Ok)->setText(tr("ok"));
|
|
||||||
ui->buttonBox->button(QDialogButtonBox::Cancel)->setText(tr("cancel"));
|
|
||||||
connect(button_group, SIGNAL(buttonClicked(int)), this, SLOT(on_rbtn_clicked(int)));
|
|
||||||
|
|
||||||
m_index = getCfgValue("insertScan", "insertType", 3);
|
|
||||||
if (0 == m_index)
|
|
||||||
ui->rbtn_first->setChecked(true);
|
|
||||||
else if (1 == m_index)
|
|
||||||
ui->rbtn_beforeCurr->setChecked(true);
|
|
||||||
else if (2 == m_index)
|
|
||||||
ui->rbtn_afterCurr->setChecked(true);
|
|
||||||
else
|
|
||||||
ui->rbtn_last->setChecked(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
Dialog_InsertIndex::~Dialog_InsertIndex()
|
|
||||||
{
|
|
||||||
delete button_group;
|
|
||||||
delete ui;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Dialog_InsertIndex::on_rbtn_clicked(int id)
|
|
||||||
{
|
|
||||||
m_index = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Dialog_InsertIndex::on_buttonBox_accepted()
|
|
||||||
{
|
|
||||||
saveCfgValue("insertScan", "insertType", m_index);
|
|
||||||
}
|
|
|
@ -1,32 +0,0 @@
|
||||||
#ifndef DIALOG_INSERTINDEX_H
|
|
||||||
#define DIALOG_INSERTINDEX_H
|
|
||||||
|
|
||||||
#include <QDialog>
|
|
||||||
|
|
||||||
class QButtonGroup;
|
|
||||||
namespace Ui {
|
|
||||||
class Dialog_InsertIndex;
|
|
||||||
}
|
|
||||||
|
|
||||||
class Dialog_InsertIndex : public QDialog
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
explicit Dialog_InsertIndex(QWidget *parent = nullptr);
|
|
||||||
~Dialog_InsertIndex();
|
|
||||||
|
|
||||||
int selectedLocation() { return m_index; }
|
|
||||||
|
|
||||||
private slots:
|
|
||||||
void on_rbtn_clicked(int id);
|
|
||||||
|
|
||||||
void on_buttonBox_accepted();
|
|
||||||
|
|
||||||
private:
|
|
||||||
Ui::Dialog_InsertIndex *ui;
|
|
||||||
QButtonGroup *button_group;
|
|
||||||
int m_index;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // DIALOG_INSERTINDEX_H
|
|
|
@ -1,104 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<ui version="4.0">
|
|
||||||
<class>Dialog_InsertIndex</class>
|
|
||||||
<widget class="QDialog" name="Dialog_InsertIndex">
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>0</y>
|
|
||||||
<width>335</width>
|
|
||||||
<height>149</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="windowTitle">
|
|
||||||
<string>Insert index selection</string>
|
|
||||||
</property>
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
|
||||||
<item>
|
|
||||||
<widget class="QGroupBox" name="groupBox">
|
|
||||||
<property name="title">
|
|
||||||
<string>Insert location</string>
|
|
||||||
</property>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
|
||||||
<item>
|
|
||||||
<widget class="QRadioButton" name="rbtn_first">
|
|
||||||
<property name="text">
|
|
||||||
<string>Before first page</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QRadioButton" name="rbtn_beforeCurr">
|
|
||||||
<property name="text">
|
|
||||||
<string>Before current page</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QRadioButton" name="rbtn_afterCurr">
|
|
||||||
<property name="text">
|
|
||||||
<string>After current page</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QRadioButton" name="rbtn_last">
|
|
||||||
<property name="text">
|
|
||||||
<string>After last page</string>
|
|
||||||
</property>
|
|
||||||
<property name="checked">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QDialogButtonBox" name="buttonBox">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Vertical</enum>
|
|
||||||
</property>
|
|
||||||
<property name="standardButtons">
|
|
||||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
<resources/>
|
|
||||||
<connections>
|
|
||||||
<connection>
|
|
||||||
<sender>buttonBox</sender>
|
|
||||||
<signal>accepted()</signal>
|
|
||||||
<receiver>Dialog_InsertIndex</receiver>
|
|
||||||
<slot>accept()</slot>
|
|
||||||
<hints>
|
|
||||||
<hint type="sourcelabel">
|
|
||||||
<x>248</x>
|
|
||||||
<y>254</y>
|
|
||||||
</hint>
|
|
||||||
<hint type="destinationlabel">
|
|
||||||
<x>157</x>
|
|
||||||
<y>274</y>
|
|
||||||
</hint>
|
|
||||||
</hints>
|
|
||||||
</connection>
|
|
||||||
<connection>
|
|
||||||
<sender>buttonBox</sender>
|
|
||||||
<signal>rejected()</signal>
|
|
||||||
<receiver>Dialog_InsertIndex</receiver>
|
|
||||||
<slot>reject()</slot>
|
|
||||||
<hints>
|
|
||||||
<hint type="sourcelabel">
|
|
||||||
<x>316</x>
|
|
||||||
<y>260</y>
|
|
||||||
</hint>
|
|
||||||
<hint type="destinationlabel">
|
|
||||||
<x>286</x>
|
|
||||||
<y>274</y>
|
|
||||||
</hint>
|
|
||||||
</hints>
|
|
||||||
</connection>
|
|
||||||
</connections>
|
|
||||||
</ui>
|
|
|
@ -1,179 +0,0 @@
|
||||||
#include "dialog_log.h"
|
|
||||||
#include "ui_dialog_log.h"
|
|
||||||
#include <QDateTime>
|
|
||||||
#include "app_cfg.h"
|
|
||||||
|
|
||||||
dialog_log::dialog_log(QWidget *parent)
|
|
||||||
: QDialog(parent)
|
|
||||||
, ui(new Ui::dialog_log), ind_scanning_(-1), img_received_(0), msg_fixed_scanning_("")
|
|
||||||
{
|
|
||||||
ui->setupUi(this);
|
|
||||||
setWindowFlags(Qt::Dialog | Qt::WindowCloseButtonHint);
|
|
||||||
|
|
||||||
QHBoxLayout *bottom = new QHBoxLayout();
|
|
||||||
|
|
||||||
pbtn_clear = new QPushButton(this);
|
|
||||||
cBox_autoScroll = new QCheckBox(this);
|
|
||||||
pbtn_stop = new QPushButton(this);
|
|
||||||
pbtn_export = new QPushButton(this);
|
|
||||||
pbtn_continueScan = new QPushButton(this);
|
|
||||||
pbtn_finishScan = new QPushButton(this);
|
|
||||||
|
|
||||||
pbtn_stop->setVisible(false);
|
|
||||||
pbtn_continueScan->setVisible(false);
|
|
||||||
pbtn_finishScan->setVisible(false);
|
|
||||||
|
|
||||||
pbtn_stop->setText(tr("cancel scan"));
|
|
||||||
cBox_autoScroll->setText(tr("auto scroll"));
|
|
||||||
pbtn_clear->setText(tr("clear"));
|
|
||||||
pbtn_export->setText(tr("export images"));
|
|
||||||
pbtn_continueScan->setText(tr("continue scan"));
|
|
||||||
pbtn_finishScan->setText(tr("finish scan"));
|
|
||||||
|
|
||||||
bottom->addWidget(pbtn_clear);
|
|
||||||
bottom->addWidget(cBox_autoScroll);
|
|
||||||
bottom->addStretch();
|
|
||||||
bottom->addWidget(pbtn_stop);
|
|
||||||
bottom->addWidget(pbtn_export);
|
|
||||||
bottom->addWidget(pbtn_continueScan);
|
|
||||||
bottom->addWidget(pbtn_finishScan);
|
|
||||||
|
|
||||||
ui->verticalLayout->addItem(bottom);
|
|
||||||
|
|
||||||
cBox_autoScroll->setChecked(getCfgValue("log", "autoScroll", true));
|
|
||||||
|
|
||||||
connect(cBox_autoScroll, SIGNAL(stateChanged(int)), this, SLOT(on_cbox_autoScroll_stateChanged(int)));
|
|
||||||
connect(pbtn_stop, SIGNAL(clicked(bool)), this, SLOT(on_pbtn_stop_clicked()));
|
|
||||||
connect(pbtn_clear, SIGNAL(clicked(bool)), this, SLOT(on_pbtn_clear_clicked()));
|
|
||||||
connect(pbtn_export, SIGNAL(clicked(bool)), this, SLOT(on_pbtn_export_clicked()));
|
|
||||||
connect(pbtn_continueScan, SIGNAL(clicked(bool)), this, SLOT(on_pbtn_continuScan_cliked()));
|
|
||||||
connect(pbtn_finishScan, SIGNAL(clicked(bool)), this, SLOT(on_pbtn_finishScan_cliked()));
|
|
||||||
}
|
|
||||||
|
|
||||||
dialog_log::~dialog_log()
|
|
||||||
{
|
|
||||||
delete ui;
|
|
||||||
}
|
|
||||||
|
|
||||||
void dialog_log::addLog(const QString &log, bool err, int log_event)
|
|
||||||
{
|
|
||||||
if (ui->listWidget->count() > 1000)
|
|
||||||
{
|
|
||||||
for(int i = 0; i < 100; ++i)
|
|
||||||
{
|
|
||||||
QListWidgetItem *item = ui->listWidget->takeItem(0);
|
|
||||||
delete item;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
QDateTime timeCurrent = QDateTime::currentDateTime();
|
|
||||||
QString time = timeCurrent.toString("[yy-MM-dd hh:mm:ss]");
|
|
||||||
ui->listWidget->addItem(time + " " + log);
|
|
||||||
|
|
||||||
int idx = ui->listWidget->count() - 1;
|
|
||||||
if(log_event == LOG_EVENT_SCAN_BEGINNING)
|
|
||||||
{
|
|
||||||
msg_fixed_scanning_ = (time + " " + log).toStdString();
|
|
||||||
ind_scanning_ = idx;
|
|
||||||
img_received_ = 0;
|
|
||||||
}
|
|
||||||
else if(log_event == LOG_EVENT_SCAN_STOPPED)
|
|
||||||
{
|
|
||||||
char utf8[128] = {0};
|
|
||||||
sprintf(utf8, tr("(epicycle scanning images %u picture)").toStdString().c_str(), img_received_);
|
|
||||||
if(ind_scanning_ >= 0 && ind_scanning_ < idx)
|
|
||||||
ui->listWidget->item(ind_scanning_)->setText(QString::fromStdString(msg_fixed_scanning_));
|
|
||||||
if (idx >= 0)
|
|
||||||
ui->listWidget->item(idx)->setText(time + " " + log + QString::fromStdString(utf8));
|
|
||||||
ind_scanning_ = -1;
|
|
||||||
msg_fixed_scanning_ = "";
|
|
||||||
}
|
|
||||||
if (idx >= 0)
|
|
||||||
ui->listWidget->item(idx)->setTextColor(err ? Qt::red : Qt::black);
|
|
||||||
|
|
||||||
if (cBox_autoScroll->isChecked())
|
|
||||||
{
|
|
||||||
ui->listWidget->scrollToItem(ui->listWidget->item(idx));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void dialog_log::updateStatus(bool online, bool isScanning)
|
|
||||||
{
|
|
||||||
if (!online)
|
|
||||||
{
|
|
||||||
pbtn_stop->hide();
|
|
||||||
pbtn_export->hide();
|
|
||||||
pbtn_continueScan->hide();
|
|
||||||
pbtn_finishScan->hide();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (isScanning)
|
|
||||||
{
|
|
||||||
pbtn_stop->show();
|
|
||||||
pbtn_export->hide();
|
|
||||||
pbtn_continueScan->hide();
|
|
||||||
pbtn_finishScan->hide();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
pbtn_stop->hide();
|
|
||||||
if(img_received_)
|
|
||||||
pbtn_export->show();
|
|
||||||
pbtn_continueScan->show();
|
|
||||||
pbtn_finishScan->show();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void dialog_log::image_received_from_scanner(void)
|
|
||||||
{
|
|
||||||
img_received_++;
|
|
||||||
if(ind_scanning_ >= 0 && ind_scanning_ < ui->listWidget->count())
|
|
||||||
{
|
|
||||||
char count[20];
|
|
||||||
sprintf(count, "(%d)", img_received_);
|
|
||||||
ui->listWidget->item(ind_scanning_)->setText(QString::fromStdString(msg_fixed_scanning_ + count));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void dialog_log::closeEvent(QCloseEvent *event)
|
|
||||||
{
|
|
||||||
(void)event;
|
|
||||||
on_pbtn_stop_clicked();
|
|
||||||
}
|
|
||||||
|
|
||||||
void dialog_log::on_pbtn_export_clicked()
|
|
||||||
{
|
|
||||||
emit exportScanned();
|
|
||||||
}
|
|
||||||
|
|
||||||
void dialog_log::on_pbtn_continuScan_cliked()
|
|
||||||
{
|
|
||||||
img_received_ = 0;
|
|
||||||
emit continueScan();
|
|
||||||
}
|
|
||||||
|
|
||||||
void dialog_log::on_pbtn_finishScan_cliked()
|
|
||||||
{
|
|
||||||
close();
|
|
||||||
}
|
|
||||||
|
|
||||||
void dialog_log::on_cbox_autoScroll_stateChanged(int state)
|
|
||||||
{
|
|
||||||
(void)state;
|
|
||||||
saveCfgValue("log", "autoScroll", cBox_autoScroll->isChecked());
|
|
||||||
}
|
|
||||||
|
|
||||||
void dialog_log::on_pbtn_stop_clicked(void)
|
|
||||||
{
|
|
||||||
emit stopScan();
|
|
||||||
}
|
|
||||||
|
|
||||||
void dialog_log::on_pbtn_clear_clicked()
|
|
||||||
{
|
|
||||||
ui->listWidget->clear();
|
|
||||||
ind_scanning_ = -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
|
@ -1,69 +0,0 @@
|
||||||
#ifndef DIALOG_SCANNERLOG_H
|
|
||||||
#define DIALOG_SCANNERLOG_H
|
|
||||||
|
|
||||||
#include <QDialog>
|
|
||||||
#include <QPushButton>
|
|
||||||
#include <QCheckBox>
|
|
||||||
class QLabel;
|
|
||||||
|
|
||||||
namespace Ui {
|
|
||||||
class dialog_log;
|
|
||||||
}
|
|
||||||
|
|
||||||
enum
|
|
||||||
{
|
|
||||||
INFO_DLG_FLAG_INFO_LIST = 1 << 1,
|
|
||||||
INFO_DLG_FLAG_PROGRESS = 1 << 2
|
|
||||||
};
|
|
||||||
enum
|
|
||||||
{
|
|
||||||
LOG_EVENT_DONT_CARE = 0,
|
|
||||||
LOG_EVENT_SCAN_BEGINNING,
|
|
||||||
LOG_EVENT_SCAN_STOPPED,
|
|
||||||
};
|
|
||||||
class QListWidgetItem;
|
|
||||||
class dialog_log : public QDialog
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
int ind_scanning_;
|
|
||||||
int img_received_;
|
|
||||||
std::string msg_fixed_scanning_;
|
|
||||||
|
|
||||||
public:
|
|
||||||
explicit dialog_log(QWidget *parent = nullptr);
|
|
||||||
~dialog_log();
|
|
||||||
|
|
||||||
void addLog(const QString &log, bool err, int log_event = LOG_EVENT_DONT_CARE);
|
|
||||||
void updateStatus(bool online, bool isScanning);
|
|
||||||
void image_received_from_scanner(void);
|
|
||||||
|
|
||||||
public:
|
|
||||||
QPushButton *pbtn_export;
|
|
||||||
|
|
||||||
signals:
|
|
||||||
void stopScan();
|
|
||||||
void continueScan();
|
|
||||||
void exportScanned();
|
|
||||||
|
|
||||||
private:
|
|
||||||
void closeEvent(QCloseEvent *event);
|
|
||||||
|
|
||||||
private slots:
|
|
||||||
void on_cbox_autoScroll_stateChanged(int state);
|
|
||||||
void on_pbtn_stop_clicked(void);
|
|
||||||
void on_pbtn_clear_clicked();
|
|
||||||
void on_pbtn_export_clicked();
|
|
||||||
void on_pbtn_continuScan_cliked();
|
|
||||||
void on_pbtn_finishScan_cliked();
|
|
||||||
|
|
||||||
private:
|
|
||||||
Ui::dialog_log *ui;
|
|
||||||
QPushButton *pbtn_stop;
|
|
||||||
QCheckBox *cBox_autoScroll;
|
|
||||||
QPushButton *pbtn_clear;
|
|
||||||
QPushButton *pbtn_continueScan;
|
|
||||||
QPushButton *pbtn_finishScan;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // DIALOG_SCANNERLOG_H
|
|
|
@ -1,31 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<ui version="4.0">
|
|
||||||
<class>dialog_log</class>
|
|
||||||
<widget class="QDialog" name="dialog_log">
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>0</y>
|
|
||||||
<width>531</width>
|
|
||||||
<height>161</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="windowTitle">
|
|
||||||
<string>日志</string>
|
|
||||||
</property>
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
|
||||||
<item>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
|
||||||
<item>
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout"/>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QListWidget" name="listWidget"/>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
<resources/>
|
|
||||||
<connections/>
|
|
||||||
</ui>
|
|
|
@ -1,105 +0,0 @@
|
||||||
#include "dialog_logmanager.h"
|
|
||||||
#include "ui_dialog_logmanager.h"
|
|
||||||
#include "base/HGUtility.h"
|
|
||||||
#include "base/HGInfo.h"
|
|
||||||
#include <QDir>
|
|
||||||
#include <QFile>
|
|
||||||
#include <QFileInfo>
|
|
||||||
#include <QFileDialog>
|
|
||||||
#include <QMessageBox>
|
|
||||||
#include <QDesktopServices>
|
|
||||||
|
|
||||||
Dialog_LogManager::Dialog_LogManager(QWidget *parent) :
|
|
||||||
QDialog(parent),
|
|
||||||
ui(new Ui::Dialog_LogManager)
|
|
||||||
{
|
|
||||||
ui->setupUi(this);
|
|
||||||
|
|
||||||
HGChar logFilePath[512];
|
|
||||||
HGBase_GetLogFilePath(logFilePath, 512);
|
|
||||||
m_directory = logFilePath;
|
|
||||||
|
|
||||||
ui->lineEdit_directory->setText(m_directory);
|
|
||||||
m_suffix = "log";
|
|
||||||
ui->cbox_fileType->setItemText(6, m_suffix + "(*." + m_suffix + ")");
|
|
||||||
ui->cbox_fileType->setCurrentIndex(6);
|
|
||||||
ui->listWidget->setSelectionMode(QListWidget::ExtendedSelection);
|
|
||||||
|
|
||||||
ui->btn_directory->setEnabled(false);
|
|
||||||
ui->cbox_fileType->setEnabled(false);
|
|
||||||
|
|
||||||
//Get the list of m_suffix files in the m_directory folder
|
|
||||||
QDir dir(m_directory);
|
|
||||||
QStringList filter;
|
|
||||||
filter << "*." + m_suffix;
|
|
||||||
QFileInfoList log_list;
|
|
||||||
log_list = dir.entryInfoList(filter, QDir::Files);
|
|
||||||
QStringList filename_list;
|
|
||||||
foreach(QFileInfo info, log_list)
|
|
||||||
filename_list.append(info.fileName());
|
|
||||||
ui->listWidget->addItems(filename_list);
|
|
||||||
if(ui->listWidget->count() == 0)
|
|
||||||
ui->btn_export->setEnabled(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
Dialog_LogManager::~Dialog_LogManager()
|
|
||||||
{
|
|
||||||
delete ui;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Dialog_LogManager::on_btn_export_clicked()
|
|
||||||
{
|
|
||||||
if(ui->listWidget->selectedItems().isEmpty())
|
|
||||||
{
|
|
||||||
QMessageBox::warning(this, tr("Warning"), tr("Please select file in the list."));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
QString directory = QFileDialog::getExistingDirectory(nullptr, tr("Choose saving path"), "", QFileDialog::ShowDirsOnly);
|
|
||||||
if (!directory.isEmpty())
|
|
||||||
{
|
|
||||||
QList<QListWidgetItem*> files = ui->listWidget->selectedItems();
|
|
||||||
for(int i = 0; i < files.size(); i++)
|
|
||||||
{
|
|
||||||
QFile::copy(m_directory + "/" + files.at(i)->text(), directory + "/" + files.at(i)->text());
|
|
||||||
}
|
|
||||||
QMessageBox::information(this, tr("Information"), tr("Log files export finished."));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Dialog_LogManager::on_btn_cancel_clicked()
|
|
||||||
{
|
|
||||||
close();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Dialog_LogManager::on_btn_clear_clicked()
|
|
||||||
{
|
|
||||||
int ret = QMessageBox::question(this, tr("Question"), tr("All log files will be cleared.\nContinue to clear?"));
|
|
||||||
if (ret == QMessageBox::Yes)
|
|
||||||
{
|
|
||||||
//获取LOG_PATH文件夹下的Log文件列表
|
|
||||||
QDir dir(m_directory);
|
|
||||||
QStringList filter;
|
|
||||||
filter << "*." + m_suffix;
|
|
||||||
QFileInfoList log_list;
|
|
||||||
log_list = dir.entryInfoList(filter, QDir::Files);
|
|
||||||
|
|
||||||
HGBase_DisableInfo();
|
|
||||||
foreach(QFileInfo info, log_list)
|
|
||||||
{
|
|
||||||
QFile file(info.absoluteFilePath());
|
|
||||||
file.remove();
|
|
||||||
}
|
|
||||||
HGBase_EnableInfo();
|
|
||||||
|
|
||||||
//清空列表显示
|
|
||||||
ui->listWidget->clear();
|
|
||||||
ui->btn_export->setEnabled(false);
|
|
||||||
QMessageBox::information(this, tr("Information"), tr("All log files cleared."));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Dialog_LogManager::on_listWidget_itemDoubleClicked(QListWidgetItem *item)
|
|
||||||
{
|
|
||||||
QString filename = m_directory + "/" + item->text();
|
|
||||||
QDesktopServices::openUrl(QUrl::fromLocalFile(filename));
|
|
||||||
}
|
|
|
@ -1,33 +0,0 @@
|
||||||
#ifndef DIALOG_LOGMANAGER_H
|
|
||||||
#define DIALOG_LOGMANAGER_H
|
|
||||||
|
|
||||||
#include <QDialog>
|
|
||||||
#include <QListWidgetItem>
|
|
||||||
|
|
||||||
namespace Ui {
|
|
||||||
class Dialog_LogManager;
|
|
||||||
}
|
|
||||||
|
|
||||||
class Dialog_LogManager : public QDialog
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
explicit Dialog_LogManager(QWidget *parent = nullptr);
|
|
||||||
~Dialog_LogManager();
|
|
||||||
|
|
||||||
private slots:
|
|
||||||
void on_btn_export_clicked();
|
|
||||||
|
|
||||||
void on_btn_cancel_clicked();
|
|
||||||
|
|
||||||
void on_btn_clear_clicked();
|
|
||||||
|
|
||||||
void on_listWidget_itemDoubleClicked(QListWidgetItem *item);
|
|
||||||
|
|
||||||
private:
|
|
||||||
Ui::Dialog_LogManager *ui;
|
|
||||||
QString m_directory, m_suffix;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // DIALOG_LOGMANAGER_H
|
|
|
@ -1,139 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<ui version="4.0">
|
|
||||||
<class>Dialog_LogManager</class>
|
|
||||||
<widget class="QDialog" name="Dialog_LogManager">
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>0</y>
|
|
||||||
<width>487</width>
|
|
||||||
<height>354</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="windowTitle">
|
|
||||||
<string>Dialog</string>
|
|
||||||
</property>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
|
||||||
<item>
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout" stretch="0,1,0,0">
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="btn_directory">
|
|
||||||
<property name="text">
|
|
||||||
<string>Directory...</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QLineEdit" name="lineEdit_directory">
|
|
||||||
<property name="readOnly">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="lab_fileType">
|
|
||||||
<property name="text">
|
|
||||||
<string>File Type:</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QComboBox" name="cbox_fileType">
|
|
||||||
<property name="maximumSize">
|
|
||||||
<size>
|
|
||||||
<width>100</width>
|
|
||||||
<height>16777215</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>All(*.*)</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>Image(*.jpg,*.bmp,*.png,*.tif)</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>PDF(*.pdf)</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>Text(*.txt)</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>Config(*.ini,*.xml)</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>Website(*.html)</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>HGlog(*.HGLog)</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="Line" name="line">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QListWidget" name="listWidget"/>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_2" stretch="0,1,0,0">
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="btn_clear">
|
|
||||||
<property name="text">
|
|
||||||
<string>Clear</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<spacer name="horizontalSpacer_2">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>40</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="btn_export">
|
|
||||||
<property name="text">
|
|
||||||
<string>Export...</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="btn_cancel">
|
|
||||||
<property name="text">
|
|
||||||
<string>Cancel</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
<resources/>
|
|
||||||
<connections/>
|
|
||||||
</ui>
|
|
|
@ -1,24 +0,0 @@
|
||||||
#include "dialog_moveto.h"
|
|
||||||
#include "ui_dialog_moveto.h"
|
|
||||||
#include "HGImgThumb.h"
|
|
||||||
|
|
||||||
Dialog_MoveTo::Dialog_MoveTo(int count, int index, QWidget *parent) :
|
|
||||||
QDialog(parent),
|
|
||||||
ui(new Ui::Dialog_MoveTo)
|
|
||||||
{
|
|
||||||
ui->setupUi(this);
|
|
||||||
|
|
||||||
ui->spinBox->setMaximum(count);
|
|
||||||
ui->spinBox->setMinimum(1);
|
|
||||||
ui->spinBox->setValue(index + 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
Dialog_MoveTo::~Dialog_MoveTo()
|
|
||||||
{
|
|
||||||
delete ui;
|
|
||||||
}
|
|
||||||
|
|
||||||
int Dialog_MoveTo::getMoveToIndex()
|
|
||||||
{
|
|
||||||
return ui->spinBox->value() - 1;
|
|
||||||
}
|
|
|
@ -1,24 +0,0 @@
|
||||||
#ifndef DIALOG_MOVETO_H
|
|
||||||
#define DIALOG_MOVETO_H
|
|
||||||
|
|
||||||
#include <QDialog>
|
|
||||||
|
|
||||||
namespace Ui {
|
|
||||||
class Dialog_MoveTo;
|
|
||||||
}
|
|
||||||
|
|
||||||
class Dialog_MoveTo : public QDialog
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
explicit Dialog_MoveTo(int count, int index, QWidget *parent = nullptr);
|
|
||||||
~Dialog_MoveTo();
|
|
||||||
|
|
||||||
int getMoveToIndex();
|
|
||||||
|
|
||||||
private:
|
|
||||||
Ui::Dialog_MoveTo *ui;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // DIALOG_MOVETO_H
|
|
|
@ -1,126 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<ui version="4.0">
|
|
||||||
<class>Dialog_MoveTo</class>
|
|
||||||
<widget class="QDialog" name="Dialog_MoveTo">
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>0</y>
|
|
||||||
<width>265</width>
|
|
||||||
<height>83</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="windowTitle">
|
|
||||||
<string>move to</string>
|
|
||||||
</property>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
|
||||||
<item>
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="label">
|
|
||||||
<property name="text">
|
|
||||||
<string>target index: </string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QSpinBox" name="spinBox">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="minimumSize">
|
|
||||||
<size>
|
|
||||||
<width>100</width>
|
|
||||||
<height>0</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="maximumSize">
|
|
||||||
<size>
|
|
||||||
<width>100</width>
|
|
||||||
<height>16777215</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="maximum">
|
|
||||||
<number>100</number>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<spacer name="horizontalSpacer">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>40</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<spacer name="verticalSpacer">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Vertical</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>20</width>
|
|
||||||
<height>40</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QDialogButtonBox" name="buttonBox">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="standardButtons">
|
|
||||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
<resources/>
|
|
||||||
<connections>
|
|
||||||
<connection>
|
|
||||||
<sender>buttonBox</sender>
|
|
||||||
<signal>accepted()</signal>
|
|
||||||
<receiver>Dialog_MoveTo</receiver>
|
|
||||||
<slot>accept()</slot>
|
|
||||||
<hints>
|
|
||||||
<hint type="sourcelabel">
|
|
||||||
<x>248</x>
|
|
||||||
<y>254</y>
|
|
||||||
</hint>
|
|
||||||
<hint type="destinationlabel">
|
|
||||||
<x>157</x>
|
|
||||||
<y>274</y>
|
|
||||||
</hint>
|
|
||||||
</hints>
|
|
||||||
</connection>
|
|
||||||
<connection>
|
|
||||||
<sender>buttonBox</sender>
|
|
||||||
<signal>rejected()</signal>
|
|
||||||
<receiver>Dialog_MoveTo</receiver>
|
|
||||||
<slot>reject()</slot>
|
|
||||||
<hints>
|
|
||||||
<hint type="sourcelabel">
|
|
||||||
<x>316</x>
|
|
||||||
<y>260</y>
|
|
||||||
</hint>
|
|
||||||
<hint type="destinationlabel">
|
|
||||||
<x>286</x>
|
|
||||||
<y>274</y>
|
|
||||||
</hint>
|
|
||||||
</hints>
|
|
||||||
</connection>
|
|
||||||
</connections>
|
|
||||||
</ui>
|
|
|
@ -1,50 +0,0 @@
|
||||||
#include "dialog_multirotate.h"
|
|
||||||
#include "ui_dialog_multirotate.h"
|
|
||||||
#include <QButtonGroup>
|
|
||||||
#include <QPushButton>
|
|
||||||
|
|
||||||
Dialog_MultiRotate::Dialog_MultiRotate(QWidget *parent) :
|
|
||||||
QDialog(parent),
|
|
||||||
ui(new Ui::Dialog_MultiRotate),
|
|
||||||
m_group_rotation(new QButtonGroup),
|
|
||||||
m_group_page(new QButtonGroup),
|
|
||||||
m_rotate_type(0),
|
|
||||||
m_rotate_page_type(0)
|
|
||||||
{
|
|
||||||
ui->setupUi(this);
|
|
||||||
setWindowFlags(Qt::Dialog | Qt::WindowCloseButtonHint);
|
|
||||||
|
|
||||||
m_group_rotation->addButton(ui->rbtn_clockwise, 0);
|
|
||||||
m_group_rotation->addButton(ui->rbtn_180degree, 1);
|
|
||||||
m_group_rotation->addButton(ui->rbtn_anticlockwise, 2);
|
|
||||||
m_group_page->addButton(ui->rbtn_currPage, 0);
|
|
||||||
m_group_page->addButton(ui->rbtn_selectedPage, 1);
|
|
||||||
m_group_page->addButton(ui->rbtn_evenPage, 2);
|
|
||||||
m_group_page->addButton(ui->rbtn_oddPage, 3);
|
|
||||||
m_group_page->addButton(ui->rbtn_allPage, 4);
|
|
||||||
|
|
||||||
ui->buttonBox->button(QDialogButtonBox::Ok)->setText(tr("ok"));
|
|
||||||
ui->buttonBox->button(QDialogButtonBox::Cancel)->setText(tr("cancel"));
|
|
||||||
|
|
||||||
connect(m_group_rotation, SIGNAL(buttonClicked(int)), this, SLOT(on_rotation_rbtn_clicked(int)));
|
|
||||||
connect(m_group_page, SIGNAL(buttonClicked(int)), this, SLOT(on_page_rbtn_clicked(int)));
|
|
||||||
}
|
|
||||||
|
|
||||||
Dialog_MultiRotate::~Dialog_MultiRotate()
|
|
||||||
{
|
|
||||||
delete m_group_page;
|
|
||||||
delete m_group_rotation;
|
|
||||||
delete ui;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Dialog_MultiRotate::on_rotation_rbtn_clicked(int id)
|
|
||||||
{
|
|
||||||
m_rotate_type = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Dialog_MultiRotate::on_page_rbtn_clicked(int id)
|
|
||||||
{
|
|
||||||
m_rotate_page_type = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
|
@ -1,35 +0,0 @@
|
||||||
#ifndef DIALOG_MULTIROTATE_H
|
|
||||||
#define DIALOG_MULTIROTATE_H
|
|
||||||
|
|
||||||
#include <QDialog>
|
|
||||||
|
|
||||||
class QButtonGroup;
|
|
||||||
namespace Ui {
|
|
||||||
class Dialog_MultiRotate;
|
|
||||||
}
|
|
||||||
|
|
||||||
class Dialog_MultiRotate : public QDialog
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
explicit Dialog_MultiRotate(QWidget *parent = nullptr);
|
|
||||||
~Dialog_MultiRotate();
|
|
||||||
|
|
||||||
int getRotateType() { return m_rotate_type; }
|
|
||||||
int getRotatePageType() {return m_rotate_page_type; }
|
|
||||||
|
|
||||||
private slots:
|
|
||||||
void on_rotation_rbtn_clicked(int id);
|
|
||||||
void on_page_rbtn_clicked(int id);
|
|
||||||
|
|
||||||
private:
|
|
||||||
Ui::Dialog_MultiRotate *ui;
|
|
||||||
QButtonGroup *m_group_rotation, *m_group_page;
|
|
||||||
|
|
||||||
int m_rotate_type;
|
|
||||||
int m_rotate_page_type;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // DIALOG_MULTIROTATE_H
|
|
|
@ -1,171 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<ui version="4.0">
|
|
||||||
<class>Dialog_MultiRotate</class>
|
|
||||||
<widget class="QDialog" name="Dialog_MultiRotate">
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>0</y>
|
|
||||||
<width>350</width>
|
|
||||||
<height>250</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="minimumSize">
|
|
||||||
<size>
|
|
||||||
<width>350</width>
|
|
||||||
<height>250</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="maximumSize">
|
|
||||||
<size>
|
|
||||||
<width>350</width>
|
|
||||||
<height>250</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="windowTitle">
|
|
||||||
<string>Multiple rotation</string>
|
|
||||||
</property>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
|
||||||
<item>
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
|
||||||
<item>
|
|
||||||
<widget class="QGroupBox" name="gbox_rotation">
|
|
||||||
<property name="title">
|
|
||||||
<string>Rotation</string>
|
|
||||||
</property>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
|
||||||
<item>
|
|
||||||
<widget class="QRadioButton" name="rbtn_clockwise">
|
|
||||||
<property name="text">
|
|
||||||
<string>90°</string>
|
|
||||||
</property>
|
|
||||||
<property name="checked">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QRadioButton" name="rbtn_180degree">
|
|
||||||
<property name="text">
|
|
||||||
<string>180°</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QRadioButton" name="rbtn_anticlockwise">
|
|
||||||
<property name="text">
|
|
||||||
<string>-90°</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QGroupBox" name="gbox_pages">
|
|
||||||
<property name="title">
|
|
||||||
<string>Pages</string>
|
|
||||||
</property>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
|
||||||
<item>
|
|
||||||
<widget class="QRadioButton" name="rbtn_currPage">
|
|
||||||
<property name="text">
|
|
||||||
<string>Current page</string>
|
|
||||||
</property>
|
|
||||||
<property name="checked">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QRadioButton" name="rbtn_selectedPage">
|
|
||||||
<property name="text">
|
|
||||||
<string>Selected pages</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QRadioButton" name="rbtn_evenPage">
|
|
||||||
<property name="text">
|
|
||||||
<string>All odd pages</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QRadioButton" name="rbtn_oddPage">
|
|
||||||
<property name="text">
|
|
||||||
<string>All even pages</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QRadioButton" name="rbtn_allPage">
|
|
||||||
<property name="text">
|
|
||||||
<string>All pages</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QDialogButtonBox" name="buttonBox">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Vertical</enum>
|
|
||||||
</property>
|
|
||||||
<property name="standardButtons">
|
|
||||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="label">
|
|
||||||
<property name="text">
|
|
||||||
<string>Attentions:
|
|
||||||
This operation will NOT rotate the files that may contain multiple pages, such as .pdf, .tif, etc.</string>
|
|
||||||
</property>
|
|
||||||
<property name="wordWrap">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
<resources/>
|
|
||||||
<connections>
|
|
||||||
<connection>
|
|
||||||
<sender>buttonBox</sender>
|
|
||||||
<signal>accepted()</signal>
|
|
||||||
<receiver>Dialog_MultiRotate</receiver>
|
|
||||||
<slot>accept()</slot>
|
|
||||||
<hints>
|
|
||||||
<hint type="sourcelabel">
|
|
||||||
<x>248</x>
|
|
||||||
<y>254</y>
|
|
||||||
</hint>
|
|
||||||
<hint type="destinationlabel">
|
|
||||||
<x>157</x>
|
|
||||||
<y>274</y>
|
|
||||||
</hint>
|
|
||||||
</hints>
|
|
||||||
</connection>
|
|
||||||
<connection>
|
|
||||||
<sender>buttonBox</sender>
|
|
||||||
<signal>rejected()</signal>
|
|
||||||
<receiver>Dialog_MultiRotate</receiver>
|
|
||||||
<slot>reject()</slot>
|
|
||||||
<hints>
|
|
||||||
<hint type="sourcelabel">
|
|
||||||
<x>316</x>
|
|
||||||
<y>260</y>
|
|
||||||
</hint>
|
|
||||||
<hint type="destinationlabel">
|
|
||||||
<x>286</x>
|
|
||||||
<y>274</y>
|
|
||||||
</hint>
|
|
||||||
</hints>
|
|
||||||
</connection>
|
|
||||||
</connections>
|
|
||||||
</ui>
|
|
|
@ -1,158 +0,0 @@
|
||||||
#include "dialog_multirotateimagefile.h"
|
|
||||||
#include "ui_dialog_multirotateimagefile.h"
|
|
||||||
#include "imgfmt/HGImgFmt.h"
|
|
||||||
#include "HGUIGlobal.h"
|
|
||||||
#include "mainwindow.h"
|
|
||||||
#include <QMessageBox>
|
|
||||||
#include <QFile>
|
|
||||||
|
|
||||||
Dialog_MultiRotateImageFile::Dialog_MultiRotateImageFile(const QStringList &fileList, int rotateType, QWidget *parent) :
|
|
||||||
QDialog(parent),
|
|
||||||
ui(new Ui::Dialog_MultiRotateImageFile),
|
|
||||||
m_fileList(fileList),
|
|
||||||
m_rotateType(rotateType)
|
|
||||||
{
|
|
||||||
ui->setupUi(this);
|
|
||||||
|
|
||||||
ui->progressBar->setMinimum(0);
|
|
||||||
ui->progressBar->setMaximum(fileList.size());
|
|
||||||
ui->progressBar->setValue(0);
|
|
||||||
|
|
||||||
connect(this, SIGNAL(updateProgress(int)), this, SLOT(on_updateProgress(int)), Qt::QueuedConnection);
|
|
||||||
connect(this, SIGNAL(updateImageFile(QString)), this, SLOT(on_updateImageFile(QString)), Qt::QueuedConnection);
|
|
||||||
connect(this, SIGNAL(finish(int)), this, SLOT(on_finish(int)), Qt::QueuedConnection);
|
|
||||||
|
|
||||||
m_stopThread = false;
|
|
||||||
HGBase_OpenThread(ThreadFunc, this, &m_thread);
|
|
||||||
}
|
|
||||||
|
|
||||||
Dialog_MultiRotateImageFile::~Dialog_MultiRotateImageFile()
|
|
||||||
{
|
|
||||||
if (nullptr != m_thread)
|
|
||||||
{
|
|
||||||
HGBase_CloseThread(m_thread);
|
|
||||||
m_thread = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
delete ui;
|
|
||||||
}
|
|
||||||
|
|
||||||
void HGAPI Dialog_MultiRotateImageFile::ThreadFunc(HGThread thread, HGPointer param)
|
|
||||||
{
|
|
||||||
(void)thread;
|
|
||||||
Dialog_MultiRotateImageFile *p = (Dialog_MultiRotateImageFile *)param;
|
|
||||||
HGResult ret = HGBASE_ERR_FAIL;
|
|
||||||
|
|
||||||
for (int i = 0; i < (int)p->m_fileList.count(); ++i)
|
|
||||||
{
|
|
||||||
if (p->m_stopThread)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
emit p->updateProgress(i);
|
|
||||||
|
|
||||||
HGImage img = nullptr;
|
|
||||||
|
|
||||||
HGImgFmtReader imgFmtReader = nullptr;
|
|
||||||
ret = HGImgFmt_OpenImageReader(getStdString(p->m_fileList[i]).c_str(), 0, &imgFmtReader);
|
|
||||||
if (HGBASE_ERR_OK == ret)
|
|
||||||
{
|
|
||||||
HGUInt pageCount = 0;
|
|
||||||
HGImgFmt_GetImagePageCount(imgFmtReader, &pageCount);
|
|
||||||
if (1 == pageCount)
|
|
||||||
{
|
|
||||||
ret = HGImgFmt_LoadImageFromReader(imgFmtReader, 0, nullptr, 0, HGBASE_IMGORIGIN_TOP, &img);
|
|
||||||
if (HGBASE_ERR_OK == ret)
|
|
||||||
{
|
|
||||||
HGImageInfo imgInfo;
|
|
||||||
HGBase_GetImageInfo(img, &imgInfo);
|
|
||||||
|
|
||||||
if (0 == p->m_rotateType)
|
|
||||||
{
|
|
||||||
HGImage img2 = nullptr;
|
|
||||||
ret = HGBase_CreateImage(imgInfo.height, imgInfo.width, imgInfo.type, imgInfo.origin, &img2);
|
|
||||||
|
|
||||||
HGUInt xDpi, yDpi;
|
|
||||||
HGBase_GetImageDpi(img, &xDpi, &yDpi);
|
|
||||||
HGBase_SetImageDpi(img2, xDpi, yDpi);
|
|
||||||
|
|
||||||
HGBase_ImageRotateLeft(img, img2);
|
|
||||||
HGBase_DestroyImage(img);
|
|
||||||
img = img2;
|
|
||||||
}
|
|
||||||
else if (1 == p->m_rotateType)
|
|
||||||
{
|
|
||||||
HGBase_ImageRotate180(img, img);
|
|
||||||
}
|
|
||||||
else if (2 == p->m_rotateType)
|
|
||||||
{
|
|
||||||
HGImage img2 = nullptr;
|
|
||||||
ret = HGBase_CreateImage(imgInfo.height, imgInfo.width, imgInfo.type, imgInfo.origin, &img2);
|
|
||||||
|
|
||||||
HGUInt xDpi, yDpi;
|
|
||||||
HGBase_GetImageDpi(img, &xDpi, &yDpi);
|
|
||||||
HGBase_SetImageDpi(img2, xDpi, yDpi);
|
|
||||||
|
|
||||||
HGBase_ImageRotateRight(img, img2);
|
|
||||||
HGBase_DestroyImage(img);
|
|
||||||
img = img2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
HGImgFmt_CloseImageReader(imgFmtReader);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (nullptr != img)
|
|
||||||
{
|
|
||||||
ret = HGImgFmt_SaveImage(img, 0, nullptr, getStdString(p->m_fileList[i]).c_str());
|
|
||||||
if (HGBASE_ERR_OK == ret)
|
|
||||||
{
|
|
||||||
emit p->updateImageFile(p->m_fileList[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
HGBase_DestroyImage(img);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ret != HGBASE_ERR_OK)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
emit p->finish((int)ret);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Dialog_MultiRotateImageFile::on_updateProgress(int value)
|
|
||||||
{
|
|
||||||
ui->progressBar->setValue(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Dialog_MultiRotateImageFile::on_updateImageFile(QString fileName)
|
|
||||||
{
|
|
||||||
emit refreshImageFile(fileName);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Dialog_MultiRotateImageFile::on_finish(int ret)
|
|
||||||
{
|
|
||||||
QString str = (ret == HGBASE_ERR_OK) ? tr("operation success") : tr("multirotate operation failed: ") + MainWindow::getLogInfo(ret);
|
|
||||||
QMessageBox msg(QMessageBox::Information, tr("tip"), str, QMessageBox::Ok, this);
|
|
||||||
close();
|
|
||||||
msg.exec();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Dialog_MultiRotateImageFile::on_pushButton_clicked()
|
|
||||||
{
|
|
||||||
m_stopThread = true;
|
|
||||||
HGBase_CloseThread(m_thread);
|
|
||||||
m_thread = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Dialog_MultiRotateImageFile::closeEvent(QCloseEvent *e)
|
|
||||||
{
|
|
||||||
(void)e;
|
|
||||||
m_stopThread = true;
|
|
||||||
HGBase_CloseThread(m_thread);
|
|
||||||
m_thread = nullptr;
|
|
||||||
}
|
|
|
@ -1,49 +0,0 @@
|
||||||
#ifndef DIALOG_MULTIROTATEIMAGEFILE_H
|
|
||||||
#define DIALOG_MULTIROTATEIMAGEFILE_H
|
|
||||||
|
|
||||||
#include <QDialog>
|
|
||||||
#include "base/HGThread.h"
|
|
||||||
|
|
||||||
namespace Ui {
|
|
||||||
class Dialog_MultiRotateImageFile;
|
|
||||||
}
|
|
||||||
|
|
||||||
class Dialog_MultiRotateImageFile : public QDialog
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
explicit Dialog_MultiRotateImageFile(const QStringList &fileList, int rotateType, QWidget *parent = nullptr);
|
|
||||||
~Dialog_MultiRotateImageFile();
|
|
||||||
|
|
||||||
signals:
|
|
||||||
void refreshImageFile(const QString &fileName);
|
|
||||||
|
|
||||||
private:
|
|
||||||
static void HGAPI ThreadFunc(HGThread thread, HGPointer param);
|
|
||||||
|
|
||||||
signals:
|
|
||||||
void updateProgress(int value);
|
|
||||||
void updateImageFile(QString fileName);
|
|
||||||
void finish(int ret);
|
|
||||||
private slots:
|
|
||||||
void on_updateProgress(int value);
|
|
||||||
void on_updateImageFile(QString fileName);
|
|
||||||
void on_finish(int ret);
|
|
||||||
|
|
||||||
void on_pushButton_clicked();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
virtual void closeEvent(QCloseEvent *e);
|
|
||||||
|
|
||||||
private:
|
|
||||||
Ui::Dialog_MultiRotateImageFile *ui;
|
|
||||||
|
|
||||||
QStringList m_fileList;
|
|
||||||
int m_rotateType;
|
|
||||||
|
|
||||||
bool m_stopThread;
|
|
||||||
HGThread m_thread;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // DIALOG_MULTIROTATEIMAGEFILE_H
|
|
|
@ -1,78 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<ui version="4.0">
|
|
||||||
<class>Dialog_MultiRotateImageFile</class>
|
|
||||||
<widget class="QDialog" name="Dialog_MultiRotateImageFile">
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>0</y>
|
|
||||||
<width>400</width>
|
|
||||||
<height>300</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="windowTitle">
|
|
||||||
<string>Dialog</string>
|
|
||||||
</property>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
|
||||||
<item>
|
|
||||||
<spacer name="horizontalSpacer">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>40</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QProgressBar" name="progressBar">
|
|
||||||
<property name="value">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
|
||||||
<item>
|
|
||||||
<spacer name="horizontalSpacer_2">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>40</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="pushButton">
|
|
||||||
<property name="text">
|
|
||||||
<string>stop</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<spacer name="horizontalSpacer_3">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>40</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
<resources/>
|
|
||||||
<connections/>
|
|
||||||
</ui>
|
|
|
@ -1,32 +0,0 @@
|
||||||
#include "dialog_openimageindex.h"
|
|
||||||
#include "ui_dialog_openimageindex.h"
|
|
||||||
|
|
||||||
Dialog_OpenImageIndex::Dialog_OpenImageIndex(int total, int currentIndex, QWidget *parent) :
|
|
||||||
QDialog(parent)
|
|
||||||
, ui(new Ui::Dialog_OpenImageIndex)
|
|
||||||
{
|
|
||||||
ui->setupUi(this);
|
|
||||||
setWindowFlags(Qt::Dialog | Qt::WindowCloseButtonHint);
|
|
||||||
|
|
||||||
ui->spinBox->setMinimum(1);
|
|
||||||
ui->spinBox->setMaximum(total);
|
|
||||||
ui->spinBox->setValue(currentIndex + 1);
|
|
||||||
|
|
||||||
ui->buttonBox->button(QDialogButtonBox::Ok)->setText(tr("ok"));
|
|
||||||
ui->buttonBox->button(QDialogButtonBox::Cancel)->setText(tr("cancel"));
|
|
||||||
}
|
|
||||||
|
|
||||||
Dialog_OpenImageIndex::~Dialog_OpenImageIndex()
|
|
||||||
{
|
|
||||||
delete ui;
|
|
||||||
}
|
|
||||||
|
|
||||||
int Dialog_OpenImageIndex::getIndex()
|
|
||||||
{
|
|
||||||
return ui->spinBox->value() - 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Dialog_OpenImageIndex::on_spinBox_valueChanged(int arg1)
|
|
||||||
{
|
|
||||||
(void)arg1;
|
|
||||||
}
|
|
|
@ -1,29 +0,0 @@
|
||||||
#ifndef DIALOG_OPENIMAGEINDEX_H
|
|
||||||
#define DIALOG_OPENIMAGEINDEX_H
|
|
||||||
|
|
||||||
#include <QDialog>
|
|
||||||
#include <QPushButton>
|
|
||||||
|
|
||||||
namespace Ui {
|
|
||||||
class Dialog_OpenImageIndex;
|
|
||||||
}
|
|
||||||
|
|
||||||
class Dialog_OpenImageIndex : public QDialog
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
explicit Dialog_OpenImageIndex(int total, int currentIndex, QWidget *parent = nullptr);
|
|
||||||
~Dialog_OpenImageIndex();
|
|
||||||
|
|
||||||
int getIndex();
|
|
||||||
|
|
||||||
private slots:
|
|
||||||
void on_spinBox_valueChanged(int arg1);
|
|
||||||
|
|
||||||
private:
|
|
||||||
Ui::Dialog_OpenImageIndex *ui;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // DIALOG_OPENIMAGEINDEX_H
|
|
|
@ -1,117 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<ui version="4.0">
|
|
||||||
<class>Dialog_OpenImageIndex</class>
|
|
||||||
<widget class="QDialog" name="Dialog_OpenImageIndex">
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>0</y>
|
|
||||||
<width>255</width>
|
|
||||||
<height>84</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="windowTitle">
|
|
||||||
<string>Open Page</string>
|
|
||||||
</property>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
|
||||||
<item>
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="label">
|
|
||||||
<property name="text">
|
|
||||||
<string>pageIndex:</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QSpinBox" name="spinBox">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="minimumSize">
|
|
||||||
<size>
|
|
||||||
<width>121</width>
|
|
||||||
<height>0</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<spacer name="horizontalSpacer">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>40</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<spacer name="verticalSpacer">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Vertical</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>20</width>
|
|
||||||
<height>0</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QDialogButtonBox" name="buttonBox">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="standardButtons">
|
|
||||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
<resources/>
|
|
||||||
<connections>
|
|
||||||
<connection>
|
|
||||||
<sender>buttonBox</sender>
|
|
||||||
<signal>accepted()</signal>
|
|
||||||
<receiver>Dialog_OpenImageIndex</receiver>
|
|
||||||
<slot>accept()</slot>
|
|
||||||
<hints>
|
|
||||||
<hint type="sourcelabel">
|
|
||||||
<x>248</x>
|
|
||||||
<y>254</y>
|
|
||||||
</hint>
|
|
||||||
<hint type="destinationlabel">
|
|
||||||
<x>157</x>
|
|
||||||
<y>274</y>
|
|
||||||
</hint>
|
|
||||||
</hints>
|
|
||||||
</connection>
|
|
||||||
<connection>
|
|
||||||
<sender>buttonBox</sender>
|
|
||||||
<signal>rejected()</signal>
|
|
||||||
<receiver>Dialog_OpenImageIndex</receiver>
|
|
||||||
<slot>reject()</slot>
|
|
||||||
<hints>
|
|
||||||
<hint type="sourcelabel">
|
|
||||||
<x>316</x>
|
|
||||||
<y>260</y>
|
|
||||||
</hint>
|
|
||||||
<hint type="destinationlabel">
|
|
||||||
<x>286</x>
|
|
||||||
<y>274</y>
|
|
||||||
</hint>
|
|
||||||
</hints>
|
|
||||||
</connection>
|
|
||||||
</connections>
|
|
||||||
</ui>
|
|
|
@ -1,102 +0,0 @@
|
||||||
#include "dialog_passwordchange.h"
|
|
||||||
#include "ui_dialog_passwordchange.h"
|
|
||||||
#include <QMessageBox>
|
|
||||||
#include <QPushButton>
|
|
||||||
#include <QRegExpValidator>
|
|
||||||
#include <QToolTip>
|
|
||||||
|
|
||||||
Dialog_PasswordChange::Dialog_PasswordChange(const QString &old_password, QWidget *parent) :
|
|
||||||
QDialog(parent),
|
|
||||||
ui(new Ui::Dialog_PasswordChange),
|
|
||||||
m_old_password(old_password),
|
|
||||||
m_new_password("")
|
|
||||||
{
|
|
||||||
ui->setupUi(this);
|
|
||||||
setWindowFlags(Qt::Dialog | Qt::WindowCloseButtonHint);
|
|
||||||
QRegExp rx("[a-zA-Z0-9!@#%^&*()_]+$"); //创建一个正则表达式对象rx
|
|
||||||
qReg = new QRegExpValidator(rx, this); //创建一个过滤器对象
|
|
||||||
m_lineEditList<<ui->lineEdit_oldPassword<<ui->lineEdit_newPassword<<ui->lineEdit_confirmPassword;
|
|
||||||
foreach(QLineEdit* item, m_lineEditList)
|
|
||||||
{
|
|
||||||
item->setEchoMode(QLineEdit::Password);
|
|
||||||
item->setMaxLength(20);
|
|
||||||
item->setValidator(qReg);
|
|
||||||
}
|
|
||||||
m_lineEditList[0]->setPlaceholderText(tr("Type old password"));
|
|
||||||
m_lineEditList[1]->setPlaceholderText(tr("Type new password"));
|
|
||||||
m_lineEditList[2]->setPlaceholderText(tr("Retype new password"));
|
|
||||||
}
|
|
||||||
|
|
||||||
Dialog_PasswordChange::~Dialog_PasswordChange()
|
|
||||||
{
|
|
||||||
delete qReg;
|
|
||||||
delete ui;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString Dialog_PasswordChange::getNewPassword()
|
|
||||||
{
|
|
||||||
return m_new_password;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Dialog_PasswordChange::on_cbtn_showPassword_toggled(bool checked)
|
|
||||||
{
|
|
||||||
foreach(QLineEdit* item, m_lineEditList)
|
|
||||||
item->setEchoMode(checked ? QLineEdit::Normal : QLineEdit::PasswordEchoOnEdit);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Dialog_PasswordChange::on_lineEdit_oldPassword_textChanged(const QString &arg1)
|
|
||||||
{
|
|
||||||
ui->btn_ok->setEnabled(arg1.length() >= 8 && ui->lineEdit_newPassword->text().length() >= 8 && ui->lineEdit_confirmPassword->text().length() >= 8);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Dialog_PasswordChange::on_lineEdit_newPassword_textChanged(const QString &arg1)
|
|
||||||
{
|
|
||||||
ui->btn_ok->setEnabled(arg1.length() >= 8 && ui->lineEdit_newPassword->text().length() >= 8 && ui->lineEdit_confirmPassword->text().length() >= 8);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Dialog_PasswordChange::on_lineEdit_confirmPassword_textChanged(const QString &arg1)
|
|
||||||
{
|
|
||||||
ui->btn_ok->setEnabled(arg1.length() >= 8 && ui->lineEdit_newPassword->text().length() >= 8 && ui->lineEdit_confirmPassword->text().length() >= 8);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Dialog_PasswordChange::on_btn_ok_clicked()
|
|
||||||
{
|
|
||||||
if(ui->lineEdit_oldPassword->text() != m_old_password)
|
|
||||||
QMessageBox::warning(this,
|
|
||||||
tr("Warning"),
|
|
||||||
tr("Old password incorrect.\n"
|
|
||||||
"Please try again."));
|
|
||||||
else if(ui->lineEdit_newPassword->text() != ui->lineEdit_confirmPassword->text())
|
|
||||||
QMessageBox::warning(this,
|
|
||||||
tr("Warning"),
|
|
||||||
tr("New password and confirm password are not matched.\n"
|
|
||||||
"Please make sure the two passwords are the same."));
|
|
||||||
else
|
|
||||||
{
|
|
||||||
m_new_password = ui->lineEdit_newPassword->text();
|
|
||||||
done(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Dialog_PasswordChange::on_btn_cancel_clicked()
|
|
||||||
{
|
|
||||||
done(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Dialog_PasswordChange::on_lineEdit_oldPassword_inputRejected()
|
|
||||||
{
|
|
||||||
QToolTip::showText(mapToGlobal(ui->lineEdit_oldPassword->pos()),
|
|
||||||
tr("Password only allowed to use numbers, English and special characters."));
|
|
||||||
}
|
|
||||||
|
|
||||||
void Dialog_PasswordChange::on_lineEdit_newPassword_inputRejected()
|
|
||||||
{
|
|
||||||
QToolTip::showText(mapToGlobal(ui->lineEdit_newPassword->pos()),
|
|
||||||
tr("Password only allowed to use numbers, English and special characters."));
|
|
||||||
}
|
|
||||||
|
|
||||||
void Dialog_PasswordChange::on_lineEdit_confirmPassword_inputRejected()
|
|
||||||
{
|
|
||||||
QToolTip::showText(mapToGlobal(ui->lineEdit_confirmPassword->pos()),
|
|
||||||
tr("Password only allowed to use numbers, English and special characters."));
|
|
||||||
}
|
|
|
@ -1,48 +0,0 @@
|
||||||
#ifndef DIALOG_PASSWORDCHANGE_H
|
|
||||||
#define DIALOG_PASSWORDCHANGE_H
|
|
||||||
|
|
||||||
#include <QDialog>
|
|
||||||
|
|
||||||
class QLineEdit;
|
|
||||||
class QRegExpValidator;
|
|
||||||
namespace Ui {
|
|
||||||
class Dialog_PasswordChange;
|
|
||||||
}
|
|
||||||
|
|
||||||
class Dialog_PasswordChange : public QDialog
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
explicit Dialog_PasswordChange(const QString &old_password, QWidget *parent = nullptr);
|
|
||||||
~Dialog_PasswordChange();
|
|
||||||
|
|
||||||
QString getNewPassword();
|
|
||||||
|
|
||||||
private slots:
|
|
||||||
void on_cbtn_showPassword_toggled(bool checked);
|
|
||||||
|
|
||||||
void on_lineEdit_oldPassword_textChanged(const QString &arg1);
|
|
||||||
|
|
||||||
void on_lineEdit_newPassword_textChanged(const QString &arg1);
|
|
||||||
|
|
||||||
void on_lineEdit_confirmPassword_textChanged(const QString &arg1);
|
|
||||||
|
|
||||||
void on_btn_ok_clicked();
|
|
||||||
|
|
||||||
void on_btn_cancel_clicked();
|
|
||||||
|
|
||||||
void on_lineEdit_oldPassword_inputRejected();
|
|
||||||
|
|
||||||
void on_lineEdit_newPassword_inputRejected();
|
|
||||||
|
|
||||||
void on_lineEdit_confirmPassword_inputRejected();
|
|
||||||
|
|
||||||
private:
|
|
||||||
Ui::Dialog_PasswordChange *ui;
|
|
||||||
QString m_old_password,m_new_password;
|
|
||||||
QList<QLineEdit*> m_lineEditList;
|
|
||||||
QRegExpValidator *qReg;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // DIALOG_PASSWORDCHANGE_H
|
|
|
@ -1,157 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<ui version="4.0">
|
|
||||||
<class>Dialog_PasswordChange</class>
|
|
||||||
<widget class="QDialog" name="Dialog_PasswordChange">
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>0</y>
|
|
||||||
<width>440</width>
|
|
||||||
<height>190</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="maximumSize">
|
|
||||||
<size>
|
|
||||||
<width>440</width>
|
|
||||||
<height>190</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="windowTitle">
|
|
||||||
<string>Change password</string>
|
|
||||||
</property>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
|
||||||
<item>
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="lab_oldPassword">
|
|
||||||
<property name="minimumSize">
|
|
||||||
<size>
|
|
||||||
<width>130</width>
|
|
||||||
<height>0</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="maximumSize">
|
|
||||||
<size>
|
|
||||||
<width>130</width>
|
|
||||||
<height>16777215</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Old password:</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QLineEdit" name="lineEdit_oldPassword"/>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="lab_newPassword">
|
|
||||||
<property name="minimumSize">
|
|
||||||
<size>
|
|
||||||
<width>130</width>
|
|
||||||
<height>0</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="maximumSize">
|
|
||||||
<size>
|
|
||||||
<width>130</width>
|
|
||||||
<height>16777215</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>New password:</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QLineEdit" name="lineEdit_newPassword"/>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="lab_confirmPassword">
|
|
||||||
<property name="minimumSize">
|
|
||||||
<size>
|
|
||||||
<width>130</width>
|
|
||||||
<height>0</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="maximumSize">
|
|
||||||
<size>
|
|
||||||
<width>130</width>
|
|
||||||
<height>16777215</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Confirm new password:</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QLineEdit" name="lineEdit_confirmPassword"/>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QCheckBox" name="cbtn_showPassword">
|
|
||||||
<property name="text">
|
|
||||||
<string>Show password</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="label_4">
|
|
||||||
<property name="text">
|
|
||||||
<string>Password only allowed to use numbers, English and special characters.
|
|
||||||
Password length should between 8-20 charactors.</string>
|
|
||||||
</property>
|
|
||||||
<property name="wordWrap">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
|
||||||
<item>
|
|
||||||
<spacer name="horizontalSpacer">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>40</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="btn_ok">
|
|
||||||
<property name="enabled">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>OK</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="btn_cancel">
|
|
||||||
<property name="text">
|
|
||||||
<string>Cancel</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
<resources/>
|
|
||||||
<connections/>
|
|
||||||
</ui>
|
|
|
@ -1,273 +0,0 @@
|
||||||
#include "dialog_saveas.h"
|
|
||||||
#include "ui_dialog_saveas.h"
|
|
||||||
#include "dialog_writesettings.h"
|
|
||||||
#include "base/HGBase.h"
|
|
||||||
#include "HGUIGlobal.h"
|
|
||||||
#include "app_cfg.h"
|
|
||||||
#include "ocrPdf.h"
|
|
||||||
#include <assert.h>
|
|
||||||
#include <qabstractproxymodel.h>
|
|
||||||
#include <QDateTime>
|
|
||||||
|
|
||||||
class del_delegate : public QAbstractProxyModel
|
|
||||||
{
|
|
||||||
QAbstractProxyModel* prev_ = nullptr;
|
|
||||||
QFileDialog* dlg_ = nullptr;
|
|
||||||
|
|
||||||
public:
|
|
||||||
del_delegate(QFileDialog* fd) : dlg_(fd)
|
|
||||||
{
|
|
||||||
prev_ = dlg_->proxyModel();
|
|
||||||
dlg_->setProxyModel(this);
|
|
||||||
dlg_->setOption(QFileDialog::Option::ReadOnly, true);
|
|
||||||
}
|
|
||||||
~del_delegate()
|
|
||||||
{
|
|
||||||
dlg_->setProxyModel(prev_);
|
|
||||||
prev_ = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
public:
|
|
||||||
virtual bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex()) override
|
|
||||||
{
|
|
||||||
return prev_->removeRows(row, count, parent);
|
|
||||||
}
|
|
||||||
Q_INVOKABLE virtual QModelIndex mapToSource(const QModelIndex &proxyIndex) const override
|
|
||||||
{
|
|
||||||
return prev_->mapToSource(proxyIndex);
|
|
||||||
}
|
|
||||||
Q_INVOKABLE virtual QModelIndex mapFromSource(const QModelIndex &sourceIndex) const override
|
|
||||||
{
|
|
||||||
return prev_->mapFromSource(sourceIndex);
|
|
||||||
}
|
|
||||||
Q_INVOKABLE virtual int rowCount(const QModelIndex &parent = QModelIndex()) const override
|
|
||||||
{
|
|
||||||
return prev_->rowCount(parent);
|
|
||||||
}
|
|
||||||
Q_INVOKABLE virtual int columnCount(const QModelIndex &parent = QModelIndex()) const override
|
|
||||||
{
|
|
||||||
return prev_->columnCount(parent);
|
|
||||||
}
|
|
||||||
Q_INVOKABLE virtual QModelIndex index(int row, int column,
|
|
||||||
const QModelIndex &parent = QModelIndex()) const override
|
|
||||||
{
|
|
||||||
return prev_->index(row, column, parent);
|
|
||||||
}
|
|
||||||
Q_INVOKABLE virtual QModelIndex parent(const QModelIndex &child) const override
|
|
||||||
{
|
|
||||||
return prev_->parent(child);
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
Dialog_SaveAs::Dialog_SaveAs(QWidget *parent) :
|
|
||||||
QDialog(parent)
|
|
||||||
, ui(new Ui::Dialog_SaveAs)
|
|
||||||
{
|
|
||||||
ui->setupUi(this);
|
|
||||||
setWindowFlags(Qt::Dialog | Qt::WindowCloseButtonHint);
|
|
||||||
|
|
||||||
ui->fileDialog->setAcceptMode(QFileDialog::AcceptSave);
|
|
||||||
ui->fileDialog->setWindowFlags(ui->fileDialog->windowFlags() & ~Qt::Dialog);
|
|
||||||
ui->fileDialog->setOption(QFileDialog::DontUseNativeDialog, true);
|
|
||||||
ui->fileDialog->setOption(QFileDialog::ReadOnly, true); // disable 'Delete' menu item
|
|
||||||
ui->fileDialog->setSizeGripEnabled(false);
|
|
||||||
|
|
||||||
QString filter = "JPG - JPEG / JFIF(*.jpg)"
|
|
||||||
";;BMP - Windows Bitmap(*.bmp)"
|
|
||||||
";;PNG - Portable Network Graphics(*.png)"
|
|
||||||
";;PPM - Portable PixMap(*.ppm)"
|
|
||||||
";;PGM - Portable GreyMap(*.pgm)"
|
|
||||||
";;PBM - Portable BitMap(*.pbm)"
|
|
||||||
";;TIF - TIFF Revision 6(*.tif)"
|
|
||||||
";;PDF - Portable Document Format(*.pdf)"
|
|
||||||
";;OFD - Open Fixed-layout Document(*.ofd)"
|
|
||||||
";;GIF - Graphics Interchange Format(*.gif)";
|
|
||||||
#if 0
|
|
||||||
if (!getOcrPath().empty())
|
|
||||||
filter += ";;OCR->PDF - Portable Document Format(*.pdf)";
|
|
||||||
#elif !defined (x86_64) && !defined (loongarch64)
|
|
||||||
filter += ";;OCR->PDF - Portable Document Format(*.pdf)";
|
|
||||||
filter += ";;OCR->OFD - Open Fixed-layout Document(*.ofd)";
|
|
||||||
filter += ";;OCR->RTF - Rich Text Format(*.rtf)";
|
|
||||||
#endif
|
|
||||||
|
|
||||||
ui->fileDialog->setNameFilter(filter);
|
|
||||||
|
|
||||||
connect(ui->fileDialog, SIGNAL(accepted()), this, SLOT(on_dialog_accepted()));
|
|
||||||
connect(ui->fileDialog, SIGNAL(rejected()), this, SLOT(close()));
|
|
||||||
connect(ui->fileDialog, SIGNAL(filterSelected(const QString&)), this, SLOT(on_filterSelected(const QString&)));
|
|
||||||
|
|
||||||
m_suffix = getCfgValue("saveAs", "suffix", 0);
|
|
||||||
if (m_suffix > 10)
|
|
||||||
m_suffix = 10;
|
|
||||||
else if (m_suffix < 0)
|
|
||||||
m_suffix = 0;
|
|
||||||
ui->fileDialog->selectNameFilter(ui->fileDialog->nameFilters().at(m_suffix));
|
|
||||||
ui->btn_option->setEnabled(0 == m_suffix || 6 == m_suffix);
|
|
||||||
ui->cbox_subFolder->setChecked(false);
|
|
||||||
|
|
||||||
ui->cbox_subFolder->setChecked(getCfgValue("saveAs", "subFolderByTime", false));
|
|
||||||
|
|
||||||
ui->label_ocrType->setVisible(false);
|
|
||||||
ui->comboBox_ocrType->setVisible(false);
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
if (!getOcrPath().empty())
|
|
||||||
{
|
|
||||||
ui->label_ocrType->setVisible(isOcr());
|
|
||||||
ui->comboBox_ocrType->setVisible(isOcr());
|
|
||||||
QStringList ocrType = { tr("English"), tr("Simplified Chinese"), tr("Traditional Chinese"), tr("Japanese"), tr("Korean") };
|
|
||||||
ui->comboBox_ocrType->addItems(ocrType);
|
|
||||||
ui->comboBox_ocrType->setCurrentIndex(getCfgValue("saveAs", "ocrLanguage", 0));
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
Dialog_SaveAs::~Dialog_SaveAs()
|
|
||||||
{
|
|
||||||
delete ui;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Dialog_SaveAs::set_current_directory(const QString& dir)
|
|
||||||
{
|
|
||||||
ui->fileDialog->setDirectory(dir);
|
|
||||||
}
|
|
||||||
|
|
||||||
QString Dialog_SaveAs::getSavePath()
|
|
||||||
{
|
|
||||||
return m_savePath;
|
|
||||||
}
|
|
||||||
|
|
||||||
int Dialog_SaveAs::getJpegQuality()
|
|
||||||
{
|
|
||||||
return getCfgValue("saveParam", "jpegQuality", 80);
|
|
||||||
}
|
|
||||||
|
|
||||||
int Dialog_SaveAs::getTiffCompressionBW()
|
|
||||||
{
|
|
||||||
return getCfgValue("saveParam", "tiffCompBW", 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
int Dialog_SaveAs::getTiffCompression()
|
|
||||||
{
|
|
||||||
return getCfgValue("saveParam", "tiffCompClr", 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
int Dialog_SaveAs::getTiffQuality()
|
|
||||||
{
|
|
||||||
return getCfgValue("saveParam", "tiffQuality", 80);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Dialog_SaveAs::isOcr()
|
|
||||||
{
|
|
||||||
return (m_suffix >= 10);
|
|
||||||
}
|
|
||||||
|
|
||||||
int Dialog_SaveAs::getOcrLanguageType()
|
|
||||||
{
|
|
||||||
return ui->comboBox_ocrType->currentIndex();// 0-english, 1-chinese_sim, 2-chinese_tra, 3-japanese, 4-korean...
|
|
||||||
}
|
|
||||||
|
|
||||||
void Dialog_SaveAs::on_dialog_accepted()
|
|
||||||
{
|
|
||||||
QString extName;
|
|
||||||
switch (m_suffix)
|
|
||||||
{
|
|
||||||
case 0:
|
|
||||||
extName = ".jpg";
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
extName = ".bmp";
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
extName = ".png";
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
extName = ".ppm";
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
extName = ".pgm";
|
|
||||||
break;
|
|
||||||
case 5:
|
|
||||||
extName = ".pbm";
|
|
||||||
break;
|
|
||||||
case 6:
|
|
||||||
extName = ".tif";
|
|
||||||
break;
|
|
||||||
case 7:
|
|
||||||
extName = ".pdf";
|
|
||||||
break;
|
|
||||||
case 8:
|
|
||||||
extName = ".ofd";
|
|
||||||
break;
|
|
||||||
case 9:
|
|
||||||
extName = ".gif";
|
|
||||||
break;
|
|
||||||
case 10:
|
|
||||||
extName = ".pdf";
|
|
||||||
break;
|
|
||||||
case 11:
|
|
||||||
extName = ".ofd";
|
|
||||||
break;
|
|
||||||
case 12:
|
|
||||||
extName = ".rtf";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
assert(!extName.isEmpty());
|
|
||||||
|
|
||||||
QString selectedFile = ui->fileDialog->selectedFiles()[0];
|
|
||||||
int pos = selectedFile.lastIndexOf('/');
|
|
||||||
if (-1 != pos)
|
|
||||||
{
|
|
||||||
QString path = selectedFile.left(pos + 1);
|
|
||||||
QString name = selectedFile.right(selectedFile.count() - pos - 1);
|
|
||||||
|
|
||||||
bool checked = ui->cbox_subFolder->isChecked();
|
|
||||||
|
|
||||||
if(checked)
|
|
||||||
{
|
|
||||||
QString dirName = NULL;
|
|
||||||
dirName = path + QDateTime::currentDateTime().toString("yy-MM-dd hh.mm.ss");
|
|
||||||
QDir dir(dirName);
|
|
||||||
if(!dir.exists())
|
|
||||||
{
|
|
||||||
dir.mkdir(dirName);
|
|
||||||
}
|
|
||||||
path = dirName;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(name.endsWith(extName))
|
|
||||||
m_savePath = getStdFileName(path + "/" + name);
|
|
||||||
else
|
|
||||||
m_savePath = getStdFileName(path + "/" + name + extName);
|
|
||||||
}
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
int ocrLanguage = ui->comboBox_ocrType->currentIndex();
|
|
||||||
saveCfgValue("saveAs", "ocrLanguage", ocrLanguage);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
saveCfgValue("saveAs", "suffix", m_suffix);
|
|
||||||
saveCfgValue("saveAs", "subFolderByTime", ui->cbox_subFolder->isChecked());
|
|
||||||
accept();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Dialog_SaveAs::on_filterSelected(const QString& filterName)
|
|
||||||
{
|
|
||||||
m_suffix = ui->fileDialog->nameFilters().indexOf(filterName);
|
|
||||||
ui->btn_option->setEnabled(0 == m_suffix || 6 == m_suffix || 7 == m_suffix || 8 == m_suffix);
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
ui->label_ocrType->setVisible(isOcr());
|
|
||||||
ui->comboBox_ocrType->setVisible(isOcr());
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void Dialog_SaveAs::on_btn_option_clicked()
|
|
||||||
{
|
|
||||||
Dialog_WriteSettings dlg(m_suffix, this);
|
|
||||||
dlg.exec();
|
|
||||||
}
|
|
|
@ -1,39 +0,0 @@
|
||||||
#ifndef DIALOG_SAVEAS_H
|
|
||||||
#define DIALOG_SAVEAS_H
|
|
||||||
|
|
||||||
#include <QDialog>
|
|
||||||
|
|
||||||
namespace Ui {
|
|
||||||
class Dialog_SaveAs;
|
|
||||||
}
|
|
||||||
|
|
||||||
class Dialog_SaveAs : public QDialog
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
explicit Dialog_SaveAs(QWidget *parent = nullptr);
|
|
||||||
~Dialog_SaveAs();
|
|
||||||
|
|
||||||
void set_current_directory(const QString& dir);
|
|
||||||
QString getSavePath();
|
|
||||||
int getJpegQuality();
|
|
||||||
int getTiffCompressionBW();
|
|
||||||
int getTiffCompression();
|
|
||||||
int getTiffQuality();
|
|
||||||
bool isOcr();
|
|
||||||
int getOcrLanguageType();
|
|
||||||
|
|
||||||
private slots:
|
|
||||||
void on_dialog_accepted();
|
|
||||||
void on_filterSelected(const QString& filterName);
|
|
||||||
void on_btn_option_clicked();
|
|
||||||
|
|
||||||
private:
|
|
||||||
Ui::Dialog_SaveAs *ui;
|
|
||||||
|
|
||||||
QString m_savePath;
|
|
||||||
int m_suffix;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // DIALOG_SAVEAS_H
|
|
|
@ -1,80 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<ui version="4.0">
|
|
||||||
<class>Dialog_SaveAs</class>
|
|
||||||
<widget class="QDialog" name="Dialog_SaveAs">
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>0</y>
|
|
||||||
<width>586</width>
|
|
||||||
<height>437</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="windowTitle">
|
|
||||||
<string>Save As</string>
|
|
||||||
</property>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
|
||||||
<item>
|
|
||||||
<widget class="QFileDialog" name="fileDialog" native="true"/>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="btn_option">
|
|
||||||
<property name="text">
|
|
||||||
<string>Compression Option</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QCheckBox" name="cbox_subFolder">
|
|
||||||
<property name="text">
|
|
||||||
<string>Use subfolder based on current date</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="label_ocrType">
|
|
||||||
<property name="text">
|
|
||||||
<string>Ocr type:</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QComboBox" name="comboBox_ocrType">
|
|
||||||
<property name="minimumSize">
|
|
||||||
<size>
|
|
||||||
<width>101</width>
|
|
||||||
<height>0</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<spacer name="horizontalSpacer">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>40</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
<customwidgets>
|
|
||||||
<customwidget>
|
|
||||||
<class>QFileDialog</class>
|
|
||||||
<extends>QWidget</extends>
|
|
||||||
<header>qfiledialog.h</header>
|
|
||||||
<container>1</container>
|
|
||||||
</customwidget>
|
|
||||||
</customwidgets>
|
|
||||||
<resources/>
|
|
||||||
<connections/>
|
|
||||||
</ui>
|
|
|
@ -1,36 +0,0 @@
|
||||||
#include "dialog_savemessagebox.h"
|
|
||||||
#include "ui_dialog_savemessagebox.h"
|
|
||||||
|
|
||||||
Dialog_SaveMessageBox::Dialog_SaveMessageBox(QWidget *parent) :
|
|
||||||
QDialog(parent),
|
|
||||||
ui(new Ui::Dialog_SaveMessageBox)
|
|
||||||
{
|
|
||||||
ui->setupUi(this);
|
|
||||||
|
|
||||||
setWindowFlags(Qt::Dialog | Qt::WindowCloseButtonHint);
|
|
||||||
ui->pbtn_yesToAll->setText(tr("save, do not remind again"));
|
|
||||||
ui->label->setText(tr("modified, save it?"));
|
|
||||||
}
|
|
||||||
|
|
||||||
Dialog_SaveMessageBox::~Dialog_SaveMessageBox()
|
|
||||||
{
|
|
||||||
delete ui;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Dialog_SaveMessageBox::on_pbtn_yes_clicked()
|
|
||||||
{
|
|
||||||
m_result = result_Yes;
|
|
||||||
accept();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Dialog_SaveMessageBox::on_pbtn_yesToAll_clicked()
|
|
||||||
{
|
|
||||||
m_result = result_YesToAll;
|
|
||||||
accept();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Dialog_SaveMessageBox::on_pbtn_No_clicked()
|
|
||||||
{
|
|
||||||
m_result = result_No;
|
|
||||||
reject();
|
|
||||||
}
|
|
|
@ -1,39 +0,0 @@
|
||||||
#ifndef DIALOG_SAVEMESSAGEBOX_H
|
|
||||||
#define DIALOG_SAVEMESSAGEBOX_H
|
|
||||||
|
|
||||||
#include <QDialog>
|
|
||||||
|
|
||||||
namespace Ui {
|
|
||||||
class Dialog_SaveMessageBox;
|
|
||||||
}
|
|
||||||
|
|
||||||
class Dialog_SaveMessageBox : public QDialog
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
explicit Dialog_SaveMessageBox(QWidget *parent = nullptr);
|
|
||||||
~Dialog_SaveMessageBox();
|
|
||||||
|
|
||||||
enum Result
|
|
||||||
{
|
|
||||||
result_Yes = 0,
|
|
||||||
result_YesToAll,
|
|
||||||
result_No
|
|
||||||
};
|
|
||||||
|
|
||||||
Result m_result;
|
|
||||||
|
|
||||||
|
|
||||||
private slots:
|
|
||||||
void on_pbtn_yes_clicked();
|
|
||||||
|
|
||||||
void on_pbtn_yesToAll_clicked();
|
|
||||||
|
|
||||||
void on_pbtn_No_clicked();
|
|
||||||
|
|
||||||
private:
|
|
||||||
Ui::Dialog_SaveMessageBox *ui;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // DIALOG_SAVEMESSAGEBOX_H
|
|
|
@ -1,109 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<ui version="4.0">
|
|
||||||
<class>Dialog_SaveMessageBox</class>
|
|
||||||
<widget class="QDialog" name="Dialog_SaveMessageBox">
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>0</y>
|
|
||||||
<width>387</width>
|
|
||||||
<height>104</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="windowTitle">
|
|
||||||
<string>Dialog</string>
|
|
||||||
</property>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
|
||||||
<item>
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
|
||||||
<item>
|
|
||||||
<spacer name="horizontalSpacer_3">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>40</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="label">
|
|
||||||
<property name="text">
|
|
||||||
<string>TextLabel</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<spacer name="horizontalSpacer_4">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>40</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
|
||||||
<item>
|
|
||||||
<spacer name="horizontalSpacer">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>40</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="pbtn_yes">
|
|
||||||
<property name="text">
|
|
||||||
<string>Yes</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="pbtn_yesToAll">
|
|
||||||
<property name="text">
|
|
||||||
<string>Yes to All</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="pbtn_No">
|
|
||||||
<property name="text">
|
|
||||||
<string>No</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<spacer name="horizontalSpacer_2">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>40</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
<resources/>
|
|
||||||
<connections/>
|
|
||||||
</ui>
|
|
|
@ -1,88 +0,0 @@
|
||||||
#include "dialog_updateprogress.h"
|
|
||||||
#include "ui_dialog_updateprogress.h"
|
|
||||||
#include "base/HGInfo.h"
|
|
||||||
#include <QMessageBox>
|
|
||||||
#include <QFile>
|
|
||||||
#include <QDir>
|
|
||||||
#include <QCryptographicHash>
|
|
||||||
|
|
||||||
Dialog_updateProgress::Dialog_updateProgress(VersionDll *dll, const QString &url,
|
|
||||||
const QString &savePath, QWidget *parent) :
|
|
||||||
QDialog(parent)
|
|
||||||
, m_versionDll(dll)
|
|
||||||
, m_url(url)
|
|
||||||
, m_savePath(savePath)
|
|
||||||
, ui(new Ui::Dialog_updateProgress)
|
|
||||||
{
|
|
||||||
ui->setupUi(this);
|
|
||||||
ui->progressBar->setValue(0);
|
|
||||||
|
|
||||||
connect(this, SIGNAL(updateProgress(int)), this, SLOT(on_updateProgress(int)), Qt::QueuedConnection);
|
|
||||||
connect(this, SIGNAL(finish()), this, SLOT(on_finish()), Qt::QueuedConnection);
|
|
||||||
|
|
||||||
m_stopThread = false;
|
|
||||||
HGBase_OpenThread(ThreadFunc, this, &m_thread);
|
|
||||||
}
|
|
||||||
|
|
||||||
Dialog_updateProgress::~Dialog_updateProgress()
|
|
||||||
{
|
|
||||||
if (nullptr != m_thread)
|
|
||||||
{
|
|
||||||
HGBase_CloseThread(m_thread);
|
|
||||||
m_thread = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
delete ui;
|
|
||||||
}
|
|
||||||
|
|
||||||
HGInt HGAPI Dialog_updateProgress::HttpDownloadThreadFunc(HGULonglong totalSize, HGULonglong nowSize, HGPointer param)
|
|
||||||
{
|
|
||||||
Dialog_updateProgress *p = (Dialog_updateProgress *)param;
|
|
||||||
if (p->m_stopThread)
|
|
||||||
{
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (totalSize != 0)
|
|
||||||
{
|
|
||||||
emit p->updateProgress(((double)nowSize / totalSize) * 100);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void HGAPI Dialog_updateProgress::ThreadFunc(HGThread thread, HGPointer param)
|
|
||||||
{
|
|
||||||
(void)thread;
|
|
||||||
Dialog_updateProgress *p = (Dialog_updateProgress *)param;
|
|
||||||
|
|
||||||
HGResult ret = p->m_versionDll->HttpDownload(p->m_url.toStdString().c_str(), p->m_savePath.toStdString().c_str(), HttpDownloadThreadFunc, p);
|
|
||||||
if (HGBASE_ERR_OK != ret)
|
|
||||||
{
|
|
||||||
QFile::remove(p->m_savePath.toStdString().c_str());
|
|
||||||
|
|
||||||
HGBase_WriteInfo(HGBASE_INFOTYPE_ERROR, "UpgradeHttpDownload:%u", ret);
|
|
||||||
}
|
|
||||||
|
|
||||||
emit p->finish();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Dialog_updateProgress::on_updateProgress(int value)
|
|
||||||
{
|
|
||||||
ui->progressBar->setValue(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Dialog_updateProgress::on_finish()
|
|
||||||
{
|
|
||||||
accept();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Dialog_updateProgress::on_pushButton_clicked()
|
|
||||||
{
|
|
||||||
close();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Dialog_updateProgress::closeEvent(QCloseEvent* e)
|
|
||||||
{
|
|
||||||
m_stopThread = true;
|
|
||||||
}
|
|
|
@ -1,46 +0,0 @@
|
||||||
#ifndef DIALOG_UPDATEPROGRESS_H
|
|
||||||
#define DIALOG_UPDATEPROGRESS_H
|
|
||||||
|
|
||||||
#include <QDialog>
|
|
||||||
#include "base/HGThread.h"
|
|
||||||
#include "VersionDll.h"
|
|
||||||
#include "mainwindow.h"
|
|
||||||
|
|
||||||
namespace Ui {
|
|
||||||
class Dialog_updateProgress;
|
|
||||||
}
|
|
||||||
|
|
||||||
class Dialog_updateProgress : public QDialog
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
explicit Dialog_updateProgress(VersionDll *dll, const QString &url,
|
|
||||||
const QString &savePath, QWidget *parent = nullptr);
|
|
||||||
~Dialog_updateProgress();
|
|
||||||
private:
|
|
||||||
static HGInt HGAPI HttpDownloadThreadFunc(HGULonglong totalSize, HGULonglong nowSize, HGPointer param);
|
|
||||||
static void HGAPI ThreadFunc(HGThread thread, HGPointer param);
|
|
||||||
|
|
||||||
signals:
|
|
||||||
void updateProgress(int value);
|
|
||||||
void finish();
|
|
||||||
private slots:
|
|
||||||
void on_updateProgress(int value);
|
|
||||||
void on_finish();
|
|
||||||
|
|
||||||
void on_pushButton_clicked();
|
|
||||||
protected:
|
|
||||||
virtual void closeEvent(QCloseEvent* e);
|
|
||||||
|
|
||||||
private:
|
|
||||||
Ui::Dialog_updateProgress *ui;
|
|
||||||
|
|
||||||
VersionDll *m_versionDll;
|
|
||||||
QString m_url;
|
|
||||||
QString m_savePath;
|
|
||||||
bool m_stopThread;
|
|
||||||
HGThread m_thread;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // DIALOG_UPDATEPROGRESS_H
|
|
|
@ -1,65 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<ui version="4.0">
|
|
||||||
<class>Dialog_updateProgress</class>
|
|
||||||
<widget class="QDialog" name="Dialog_updateProgress">
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>0</y>
|
|
||||||
<width>500</width>
|
|
||||||
<height>101</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="windowTitle">
|
|
||||||
<string>Dialog</string>
|
|
||||||
</property>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
|
||||||
<item>
|
|
||||||
<widget class="QProgressBar" name="progressBar">
|
|
||||||
<property name="value">
|
|
||||||
<number>24</number>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
|
||||||
<item>
|
|
||||||
<spacer name="horizontalSpacer">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>40</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="pushButton">
|
|
||||||
<property name="text">
|
|
||||||
<string>stop</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<spacer name="horizontalSpacer_2">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>40</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
<resources/>
|
|
||||||
<connections/>
|
|
||||||
</ui>
|
|
|
@ -1,86 +0,0 @@
|
||||||
#include "dialog_upgrade.h"
|
|
||||||
#include "ui_dialog_upgrade.h"
|
|
||||||
#include "base/HGUtility.h"
|
|
||||||
#include <QCryptographicHash>
|
|
||||||
#include <QMessageBox>
|
|
||||||
#include <QDir>
|
|
||||||
#include <QFile>
|
|
||||||
|
|
||||||
Dialog_upgrade::Dialog_upgrade(class VersionDll *versionDll, HGVersionInfo *versionInfo, QWidget *parent) :
|
|
||||||
QDialog(parent)
|
|
||||||
, ui(new Ui::Dialog_upgrade)
|
|
||||||
, m_versionDll(versionDll)
|
|
||||||
, m_versionInfo(versionInfo)
|
|
||||||
{
|
|
||||||
ui->setupUi(this);
|
|
||||||
setWindowTitle(tr("upgrade online"));
|
|
||||||
setWindowFlags(Qt::Dialog | Qt::WindowCloseButtonHint);
|
|
||||||
this->layout()->setSizeConstraint(QLayout::SetFixedSize);
|
|
||||||
|
|
||||||
const HGChar *oemName = nullptr;
|
|
||||||
|
|
||||||
#if defined(OEM_HANWANG)
|
|
||||||
oemName = HGVERSION_OEMNAME_HANVON;
|
|
||||||
#elif defined(OEM_LISICHENG)
|
|
||||||
oemName = HGVERSION_OEMNAME_LANXUM;
|
|
||||||
#elif defined(OEM_CANGTIAN)
|
|
||||||
oemName = HGVERSION_OEMNAME_CUMTENN;
|
|
||||||
#elif defined(OEM_ZHONGJING)
|
|
||||||
oemName = HGVERSION_OEMNAME_MICROTEK;
|
|
||||||
#elif defined(OEM_ZIGUANG)
|
|
||||||
oemName = HGVERSION_OEMNAME_UNIS;
|
|
||||||
#elif defined(OEM_NEUTRAL)
|
|
||||||
oemName = HGVERSION_OEMNAME_NEUTRAL;
|
|
||||||
#elif defined(OEM_DELI)
|
|
||||||
oemName = HGVERSION_OEMNAME_DELI;
|
|
||||||
#else
|
|
||||||
oemName = HGVERSION_OEMNAME_HUAGO;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
HGChar currVersion[64] = {0};
|
|
||||||
m_versionDll->GetCurrVersion(HGVERSION_APPNAME_SCANNER, oemName, currVersion, 64);
|
|
||||||
HGInt result = 0;
|
|
||||||
m_versionDll->CompareVersion(currVersion, m_versionInfo[0].version, &result);
|
|
||||||
if(result >= 0)
|
|
||||||
{
|
|
||||||
ui->label_detectResult->setText(tr("The current version is the latest! The current version number is : ") + currVersion);
|
|
||||||
ui->pbtn_upgrade->setVisible(false);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ui->pbtn_upgrade->setVisible(true);
|
|
||||||
QString str(m_versionInfo[0].desc);
|
|
||||||
if (!str.isEmpty())
|
|
||||||
{
|
|
||||||
ui->label_detectResult->setText(tr("Discover the new version : ") +
|
|
||||||
m_versionInfo[0].version +
|
|
||||||
tr(" ,the current version is : ") + currVersion + "\n" + "\n" +
|
|
||||||
tr("upgrade contents: \n") +
|
|
||||||
str + "\n");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ui->label_detectResult->setText(tr("Discover the new version : ") +
|
|
||||||
m_versionInfo[0].version +
|
|
||||||
tr(" ,the current version is : ") + currVersion);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
Dialog_upgrade::~Dialog_upgrade()
|
|
||||||
{
|
|
||||||
delete ui;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString Dialog_upgrade::getVersionNum()
|
|
||||||
{
|
|
||||||
return m_versionNum;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Dialog_upgrade::on_pbtn_upgrade_clicked()
|
|
||||||
{
|
|
||||||
m_versionNum = m_versionInfo[0].version;
|
|
||||||
accept();
|
|
||||||
}
|
|
|
@ -1,33 +0,0 @@
|
||||||
#ifndef DIALOG_UPGRADE_H
|
|
||||||
#define DIALOG_UPGRADE_H
|
|
||||||
|
|
||||||
#include <QDialog>
|
|
||||||
#include "VersionDll.h"
|
|
||||||
#include "dialog_updateprogress.h"
|
|
||||||
|
|
||||||
namespace Ui {
|
|
||||||
class Dialog_upgrade;
|
|
||||||
}
|
|
||||||
|
|
||||||
class Dialog_upgrade : public QDialog
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
explicit Dialog_upgrade(class VersionDll *versionDll, HGVersionInfo *versionInfo, QWidget *parent = nullptr);
|
|
||||||
~Dialog_upgrade();
|
|
||||||
|
|
||||||
QString getVersionNum();
|
|
||||||
|
|
||||||
private slots:
|
|
||||||
void on_pbtn_upgrade_clicked();
|
|
||||||
|
|
||||||
private:
|
|
||||||
Ui::Dialog_upgrade *ui;
|
|
||||||
|
|
||||||
VersionDll *m_versionDll;
|
|
||||||
HGVersionInfo *m_versionInfo;
|
|
||||||
QString m_versionNum;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // DIALOG_UPGRADE_H
|
|
|
@ -1,65 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<ui version="4.0">
|
|
||||||
<class>Dialog_upgrade</class>
|
|
||||||
<widget class="QDialog" name="Dialog_upgrade">
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>0</y>
|
|
||||||
<width>431</width>
|
|
||||||
<height>253</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="windowTitle">
|
|
||||||
<string>Dialog</string>
|
|
||||||
</property>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="label_detectResult">
|
|
||||||
<property name="text">
|
|
||||||
<string>detect result. versionNum:</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
|
||||||
<item>
|
|
||||||
<spacer name="horizontalSpacer_2">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>40</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="pbtn_upgrade">
|
|
||||||
<property name="text">
|
|
||||||
<string>upgrade the latest version</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<spacer name="horizontalSpacer_3">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>40</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
<resources/>
|
|
||||||
<connections/>
|
|
||||||
</ui>
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue