diff --git a/app/scanner/HGImgThumb.cpp b/app/scanner/HGImgThumb.cpp deleted file mode 100644 index 62517f6b..00000000 --- a/app/scanner/HGImgThumb.cpp +++ /dev/null @@ -1,4699 +0,0 @@ -#include "HGImgThumb.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "base/HGInc.h" -#include "base/HGUtility.h" -#include "imgfmt/HGImgFmt.h" -#include "HGUIGlobal.h" - - -HGImgThumb::HGImgThumb(QWidget* parent) - : QWidget(parent) -{ - HGBase_CreateLock(&m_lockFront); - HGBase_CreateLock(&m_lockBack); - HGBase_CreateLock(&m_lockItemSize); - HGBase_CreateEvent(HGFALSE, HGFALSE, &m_event); - - m_gapSize = 10; - m_scrollSize = 10; - m_minScrollSliderSize = 8; - m_itemSize = 120; - m_itemTextHeight = 20; - m_defItemImage = nullptr; - m_itemImage = nullptr; - for (int i = 0; i < 3; ++i) - { - m_hScrollLeftImage[i] = nullptr; - m_hScrollRightImage[i] = nullptr; - m_vScrollTopImage[i] = nullptr; - m_vScrollBottomImage[i] = nullptr; - m_hScrollSliderImage[i] = nullptr; - m_vScrollSliderImage[i] = nullptr; - } - m_hScrollImage = nullptr; - m_vScrollImage = nullptr; - m_nullScrollImage = nullptr; - m_type = ThumbType_Grid; - - m_mouseOn = false; - m_curItemIndex = -1; - m_hotItemIndex = -1; - m_pushItemIndex = -1; - m_signItemIndex = -1; - m_stopThread = false; - HGBase_OpenThread(ThreadFunc, this, &m_thread); - m_hScroll = false; - m_vScroll = false; - m_showThumb = false; - memset(&m_thumbRect, 0, sizeof(ThumbRect)); - m_mouseMoveStatus = MouseStatus_Null; - m_mousePressStatus = MouseStatus_Null; - m_mousePressBeginX = -1; - m_mousePressBeginY = -1; - m_hitMouseButtons = Qt::NoButton; - m_hitKeyboardModifiers = Qt::NoModifier; - m_hitItemIndex = -1; - m_operate = 0; - m_operateStartX = -1; - m_operateStartY = -1; - m_draging = false; - m_insertPtValid = false; - m_curInsertPos = -1; - m_frameSelection = false; - m_frameSelectionRectValid = false; - - setFocusPolicy(Qt::ClickFocus); - setMouseTracking(true); - setAcceptDrops(true); - connect(this, SIGNAL(updateItem()), this, SLOT(on_updateItem()), Qt::QueuedConnection); -} - -HGImgThumb::~HGImgThumb() -{ - removeAllItems(ThumbRemoveFlag::ThumbRemoveFlag_NULL); - - m_stopThread = true; - HGBase_SetEvent(m_event); - HGBase_CloseThread(m_thread); - m_thread = nullptr; - - delete m_hScrollImage; - m_hScrollImage = nullptr; - delete m_vScrollImage; - m_vScrollImage = nullptr; - delete m_nullScrollImage; - m_nullScrollImage = nullptr; - for (int i = 0; i < 3; ++i) - { - delete m_hScrollLeftImage[i]; - m_hScrollLeftImage[i] = nullptr; - delete m_hScrollRightImage[i]; - m_hScrollRightImage[i] = nullptr; - delete m_vScrollTopImage[i]; - m_vScrollTopImage[i] = nullptr; - delete m_vScrollBottomImage[i]; - m_vScrollBottomImage[i] = nullptr; - delete m_hScrollSliderImage[i]; - m_hScrollSliderImage[i] = nullptr; - delete m_vScrollSliderImage[i]; - m_vScrollSliderImage[i] = nullptr; - } - delete m_itemImage; - m_itemImage = nullptr; - delete m_defItemImage; - m_defItemImage = nullptr; - - HGBase_DestroyEvent(m_event); - m_event = nullptr; - HGBase_DestroyLock(m_lockItemSize); - m_lockItemSize = nullptr; - HGBase_DestroyLock(m_lockBack); - m_lockBack = nullptr; - HGBase_DestroyLock(m_lockFront); - m_lockFront = nullptr; - - qDebug("~HGImgThumb"); -} - -HGResult HGImgThumb::setGapSize(int size) -{ - if (MouseStatus_Null != m_mousePressStatus || 0 != m_operate || m_draging || m_frameSelection) - { - return HGBASE_ERR_FAIL; - } - - if (size < 0 || size > 40) - { - return HGBASE_ERR_INVALIDARG; - } - - if (0 != m_frontItems.size()) - { - return HGBASE_ERR_FAIL; - } - - m_gapSize = size; - return HGBASE_ERR_OK; -} - -HGResult HGImgThumb::setScrollSize(int size) -{ - if (MouseStatus_Null != m_mousePressStatus || 0 != m_operate || m_draging || m_frameSelection) - { - return HGBASE_ERR_FAIL; - } - - if (size < 10 || size > 20) - { - return HGBASE_ERR_INVALIDARG; - } - - if (0 != m_frontItems.size()) - { - return HGBASE_ERR_FAIL; - } - - m_scrollSize = size; - return HGBASE_ERR_OK; -} - -HGResult HGImgThumb::setMinScrollSliderSize(int size) -{ - if (MouseStatus_Null != m_mousePressStatus || 0 != m_operate || m_draging || m_frameSelection) - { - return HGBASE_ERR_FAIL; - } - - if (size < 8 || size > 64) - { - return HGBASE_ERR_INVALIDARG; - } - - if (0 != m_frontItems.size()) - { - return HGBASE_ERR_FAIL; - } - - m_minScrollSliderSize = size; - return HGBASE_ERR_OK; -} - -HGResult HGImgThumb::setItemSize(int size) -{ - if (MouseStatus_Null != m_mousePressStatus || 0 != m_operate || m_draging || m_frameSelection) - { - return HGBASE_ERR_FAIL; - } - - if (size < 60 || size > 240) - { - return HGBASE_ERR_INVALIDARG; - } - - if (0 != m_frontItems.size()) - { - return HGBASE_ERR_FAIL; - } - - if (m_itemSize == size) - { - return HGBASE_ERR_OK; - } - - HGBase_EnterLock(m_lockItemSize); - m_itemSize = size; - HGBase_LeaveLock(m_lockItemSize); - if (nullptr != m_defItemImage) - { - assert(nullptr != m_itemImage); - delete m_itemImage; - m_itemImage = createItemImage(m_defItemImage, m_itemSize); - assert(nullptr != m_itemImage); - } - - return HGBASE_ERR_OK; -} - -HGResult HGImgThumb::setItemTextHeight(int height) -{ - if (MouseStatus_Null != m_mousePressStatus || 0 != m_operate || m_draging || m_frameSelection) - { - return HGBASE_ERR_FAIL; - } - - if (height < 0 || height > 40) - { - return HGBASE_ERR_INVALIDARG; - } - - if (0 != m_frontItems.size()) - { - return HGBASE_ERR_FAIL; - } - - m_itemTextHeight = height; - return HGBASE_ERR_OK; -} - -HGResult HGImgThumb::setDefItemImage(const QImage *image) -{ - if (MouseStatus_Null != m_mousePressStatus || 0 != m_operate || m_draging || m_frameSelection) - { - return HGBASE_ERR_FAIL; - } - - if (0 != m_frontItems.size()) - { - return HGBASE_ERR_FAIL; - } - - if (nullptr == image) - { - delete m_itemImage; - m_itemImage = nullptr; - delete m_defItemImage; - m_defItemImage = nullptr; - return HGBASE_ERR_OK; - } - - QImage *img = new QImage(*image); - if (img->isNull()) - { - delete img; - return HGBASE_ERR_FAIL; - } - - if (nullptr != m_defItemImage) - { - assert(nullptr != m_itemImage); - delete m_itemImage; - delete m_defItemImage; - } - else - { - assert(nullptr == m_itemImage); - } - - m_defItemImage = img; - m_itemImage = createItemImage(m_defItemImage, m_itemSize); - assert(nullptr != m_itemImage); - return HGBASE_ERR_OK; -} - -HGResult HGImgThumb::setHScrollLeftImage(const QImage *normalImage, const QImage *hotImage, const QImage *pushImage) -{ - if (MouseStatus_Null != m_mousePressStatus || 0 != m_operate || m_draging || m_frameSelection) - { - return HGBASE_ERR_FAIL; - } - - if (0 != m_frontItems.size()) - { - return HGBASE_ERR_FAIL; - } - - if (nullptr == normalImage) - { - delete m_hScrollLeftImage[0]; - m_hScrollLeftImage[0] = nullptr; - } - else - { - QImage *img = new QImage(*normalImage); - if (!img->isNull()) - { - if (nullptr != m_hScrollLeftImage[0]) - delete m_hScrollLeftImage[0]; - m_hScrollLeftImage[0] = img; - } - else - { - delete img; - } - } - - if (nullptr == hotImage) - { - delete m_hScrollLeftImage[1]; - m_hScrollLeftImage[1] = nullptr; - } - else - { - QImage *img = new QImage(*hotImage); - if (!img->isNull()) - { - if (nullptr != m_hScrollLeftImage[1]) - delete m_hScrollLeftImage[1]; - m_hScrollLeftImage[1] = img; - } - else - { - delete img; - } - } - - if (nullptr == pushImage) - { - delete m_hScrollLeftImage[2]; - m_hScrollLeftImage[2] = nullptr; - } - else - { - QImage *img = new QImage(*pushImage); - if (!img->isNull()) - { - if (nullptr != m_hScrollLeftImage[2]) - delete m_hScrollLeftImage[2]; - m_hScrollLeftImage[2] = img; - } - else - { - delete img; - } - } - - return HGBASE_ERR_OK; -} - -HGResult HGImgThumb::setHScrollRightImage(const QImage *normalImage, const QImage *hotImage, const QImage *pushImage) -{ - if (MouseStatus_Null != m_mousePressStatus || 0 != m_operate || m_draging || m_frameSelection) - { - return HGBASE_ERR_FAIL; - } - - if (0 != m_frontItems.size()) - { - return HGBASE_ERR_FAIL; - } - - if (nullptr == normalImage) - { - delete m_hScrollRightImage[0]; - m_hScrollRightImage[0] = nullptr; - } - else - { - QImage *img = new QImage(*normalImage); - if (!img->isNull()) - { - if (nullptr != m_hScrollRightImage[0]) - delete m_hScrollRightImage[0]; - m_hScrollRightImage[0] = img; - } - else - { - delete img; - } - } - - if (nullptr == hotImage) - { - delete m_hScrollRightImage[1]; - m_hScrollRightImage[1] = nullptr; - } - else - { - QImage *img = new QImage(*hotImage); - if (!img->isNull()) - { - if (nullptr != m_hScrollRightImage[1]) - delete m_hScrollRightImage[1]; - m_hScrollRightImage[1] = img; - } - else - { - delete img; - } - } - - if (nullptr == pushImage) - { - delete m_hScrollRightImage[2]; - m_hScrollRightImage[2] = nullptr; - } - else - { - QImage *img = new QImage(*pushImage); - if (!img->isNull()) - { - if (nullptr != m_hScrollRightImage[2]) - delete m_hScrollRightImage[2]; - m_hScrollRightImage[2] = img; - } - else - { - delete img; - } - } - - return HGBASE_ERR_OK; -} - -HGResult HGImgThumb::setVScrollTopImage(const QImage *normalImage, const QImage *hotImage, const QImage *pushImage) -{ - if (MouseStatus_Null != m_mousePressStatus || 0 != m_operate || m_draging || m_frameSelection) - { - return HGBASE_ERR_FAIL; - } - - if (0 != m_frontItems.size()) - { - return HGBASE_ERR_FAIL; - } - - if (nullptr == normalImage) - { - delete m_vScrollTopImage[0]; - m_vScrollTopImage[0] = nullptr; - } - else - { - QImage *img = new QImage(*normalImage); - if (!img->isNull()) - { - if (nullptr != m_vScrollTopImage[0]) - delete m_vScrollTopImage[0]; - m_vScrollTopImage[0] = img; - } - else - { - delete img; - } - } - - if (nullptr == hotImage) - { - delete m_vScrollTopImage[1]; - m_vScrollTopImage[1] = nullptr; - } - else - { - QImage *img = new QImage(*hotImage); - if (!img->isNull()) - { - if (nullptr != m_vScrollTopImage[1]) - delete m_vScrollTopImage[1]; - m_vScrollTopImage[1] = img; - } - else - { - delete img; - } - } - - if (nullptr == pushImage) - { - delete m_vScrollTopImage[2]; - m_vScrollTopImage[2] = nullptr; - } - else - { - QImage *img = new QImage(*pushImage); - if (!img->isNull()) - { - if (nullptr != m_vScrollTopImage[2]) - delete m_vScrollTopImage[2]; - m_vScrollTopImage[2] = img; - } - else - { - delete img; - } - } - - return HGBASE_ERR_OK; -} - -HGResult HGImgThumb::setVScrollBottomImage(const QImage *normalImage, const QImage *hotImage, const QImage *pushImage) -{ - if (MouseStatus_Null != m_mousePressStatus || 0 != m_operate || m_draging || m_frameSelection) - { - return HGBASE_ERR_FAIL; - } - - if (0 != m_frontItems.size()) - { - return HGBASE_ERR_FAIL; - } - - if (nullptr == normalImage) - { - delete m_vScrollBottomImage[0]; - m_vScrollBottomImage[0] = nullptr; - } - else - { - QImage *img = new QImage(*normalImage); - if (!img->isNull()) - { - if (nullptr != m_vScrollBottomImage[0]) - delete m_vScrollBottomImage[0]; - m_vScrollBottomImage[0] = img; - } - else - { - delete img; - } - } - - if (nullptr == hotImage) - { - delete m_vScrollBottomImage[1]; - m_vScrollBottomImage[1] = nullptr; - } - else - { - QImage *img = new QImage(*hotImage); - if (!img->isNull()) - { - if (nullptr != m_vScrollBottomImage[1]) - delete m_vScrollBottomImage[1]; - m_vScrollBottomImage[1] = img; - } - else - { - delete img; - } - } - - if (nullptr == pushImage) - { - delete m_vScrollBottomImage[2]; - m_vScrollBottomImage[2] = nullptr; - } - else - { - QImage *img = new QImage(*pushImage); - if (!img->isNull()) - { - if (nullptr != m_vScrollBottomImage[2]) - delete m_vScrollBottomImage[2]; - m_vScrollBottomImage[2] = img; - } - else - { - delete img; - } - } - - return HGBASE_ERR_OK; -} - -HGResult HGImgThumb::setHScrollImage(const QImage *image, const HGRect *stretch) -{ - if (MouseStatus_Null != m_mousePressStatus || 0 != m_operate || m_draging || m_frameSelection) - { - return HGBASE_ERR_FAIL; - } - - if (0 != m_frontItems.size()) - { - return HGBASE_ERR_FAIL; - } - - if (nullptr == image) - { - delete m_hScrollImage; - m_hScrollImage = nullptr; - } - else - { - QImage *img = new QImage(*image); - if (!img->isNull()) - { - if (nullptr != m_hScrollImage) - delete m_hScrollImage; - m_hScrollImage = img; - - if (nullptr == stretch || stretch->left < 0 || stretch->top < 0 - || stretch->right > m_hScrollImage->width() || stretch->bottom > m_hScrollImage->height() - || stretch->left >= stretch->right || stretch->top >= stretch->bottom) - { - m_hScrollImageStretch.setX(0); - m_hScrollImageStretch.setY(0); - m_hScrollImageStretch.setWidth(m_hScrollImage->width()); - m_hScrollImageStretch.setHeight(m_hScrollImage->height()); - } - else - { - m_hScrollImageStretch.setX(stretch->left); - m_hScrollImageStretch.setY(stretch->top); - m_hScrollImageStretch.setWidth(stretch->right - stretch->left); - m_hScrollImageStretch.setHeight(stretch->bottom - stretch->top); - } - } - else - { - delete img; - } - } - - return HGBASE_ERR_OK; -} - -HGResult HGImgThumb::setHScrollSliderImage(const QImage *normalImage, const HGRect *normalStretch, const QImage *hotImage, const HGRect *hotStretch, - const QImage *pushImage, const HGRect *pushStretch) -{ - if (MouseStatus_Null != m_mousePressStatus || 0 != m_operate || m_draging || m_frameSelection) - { - return HGBASE_ERR_FAIL; - } - - if (0 != m_frontItems.size()) - { - return HGBASE_ERR_FAIL; - } - - if (nullptr == normalImage) - { - delete m_hScrollSliderImage[0]; - m_hScrollSliderImage[0] = nullptr; - } - else - { - QImage *img = new QImage(*normalImage); - if (!img->isNull()) - { - if (nullptr != m_hScrollSliderImage[0]) - delete m_hScrollSliderImage[0]; - m_hScrollSliderImage[0] = img; - - if (nullptr == normalStretch || normalStretch->left < 0 || normalStretch->top < 0 - || normalStretch->right > m_hScrollSliderImage[0]->width() || normalStretch->bottom > m_hScrollSliderImage[0]->height() - || normalStretch->left >= normalStretch->right || normalStretch->top >= normalStretch->bottom) - { - m_hScrollSliderImageStretch[0].setX(0); - m_hScrollSliderImageStretch[0].setY(0); - m_hScrollSliderImageStretch[0].setWidth(m_hScrollSliderImage[0]->width()); - m_hScrollSliderImageStretch[0].setHeight(m_hScrollSliderImage[0]->height()); - } - else - { - m_hScrollSliderImageStretch[0].setX(normalStretch->left); - m_hScrollSliderImageStretch[0].setY(normalStretch->top); - m_hScrollSliderImageStretch[0].setWidth(normalStretch->right - normalStretch->left); - m_hScrollSliderImageStretch[0].setHeight(normalStretch->bottom - normalStretch->top); - } - } - else - { - delete img; - } - } - - if (nullptr == hotImage) - { - delete m_hScrollSliderImage[1]; - m_hScrollSliderImage[1] = nullptr; - } - else - { - QImage *img = new QImage(*hotImage); - if (!img->isNull()) - { - if (nullptr != m_hScrollSliderImage[1]) - delete m_hScrollSliderImage[1]; - m_hScrollSliderImage[1] = img; - - if (nullptr == hotStretch || hotStretch->left < 0 || hotStretch->top < 0 - || hotStretch->right > m_hScrollSliderImage[1]->width() || hotStretch->bottom > m_hScrollSliderImage[1]->height() - || hotStretch->left >= hotStretch->right || hotStretch->top >= hotStretch->bottom) - { - m_hScrollSliderImageStretch[1].setX(0); - m_hScrollSliderImageStretch[1].setY(0); - m_hScrollSliderImageStretch[1].setWidth(m_hScrollSliderImage[1]->width()); - m_hScrollSliderImageStretch[1].setHeight(m_hScrollSliderImage[1]->height()); - } - else - { - m_hScrollSliderImageStretch[1].setX(hotStretch->left); - m_hScrollSliderImageStretch[1].setY(hotStretch->top); - m_hScrollSliderImageStretch[1].setWidth(hotStretch->right - hotStretch->left); - m_hScrollSliderImageStretch[1].setHeight(hotStretch->bottom - hotStretch->top); - } - } - else - { - delete img; - } - } - - if (nullptr == pushImage) - { - delete m_hScrollSliderImage[2]; - m_hScrollSliderImage[2] = nullptr; - } - else - { - QImage *img = new QImage(*pushImage); - if (!img->isNull()) - { - if (nullptr != m_hScrollSliderImage[2]) - delete m_hScrollSliderImage[2]; - m_hScrollSliderImage[2] = img; - - if (nullptr == pushStretch || pushStretch->left < 0 || pushStretch->top < 0 - || pushStretch->right > m_hScrollSliderImage[2]->width() || pushStretch->bottom > m_hScrollSliderImage[2]->height() - || pushStretch->left >= pushStretch->right || pushStretch->top >= hotStretch->bottom) - { - m_hScrollSliderImageStretch[2].setX(0); - m_hScrollSliderImageStretch[2].setY(0); - m_hScrollSliderImageStretch[2].setWidth(m_hScrollSliderImage[2]->width()); - m_hScrollSliderImageStretch[2].setHeight(m_hScrollSliderImage[2]->height()); - } - else - { - m_hScrollSliderImageStretch[2].setX(pushStretch->left); - m_hScrollSliderImageStretch[2].setY(pushStretch->top); - m_hScrollSliderImageStretch[2].setWidth(pushStretch->right - pushStretch->left); - m_hScrollSliderImageStretch[2].setHeight(pushStretch->bottom - pushStretch->top); - } - } - else - { - delete img; - } - } - - return HGBASE_ERR_OK; -} - -HGResult HGImgThumb::setVScrollImage(const QImage *image, const HGRect *stretch) -{ - if (MouseStatus_Null != m_mousePressStatus || 0 != m_operate || m_draging || m_frameSelection) - { - return HGBASE_ERR_FAIL; - } - - if (0 != m_frontItems.size()) - { - return HGBASE_ERR_FAIL; - } - - if (nullptr == image) - { - delete m_vScrollImage; - m_vScrollImage = nullptr; - } - else - { - QImage *img = new QImage(*image); - if (!img->isNull()) - { - if (nullptr != m_vScrollImage) - delete m_vScrollImage; - m_vScrollImage = img; - - if (nullptr == stretch || stretch->left < 0 || stretch->top < 0 - || stretch->right > m_vScrollImage->width() || stretch->bottom > m_vScrollImage->height() - || stretch->left >= stretch->right || stretch->top >= stretch->bottom) - { - m_vScrollImageStretch.setX(0); - m_vScrollImageStretch.setY(0); - m_vScrollImageStretch.setWidth(m_vScrollImage->width()); - m_vScrollImageStretch.setHeight(m_vScrollImage->height()); - } - else - { - m_vScrollImageStretch.setX(stretch->left); - m_vScrollImageStretch.setY(stretch->top); - m_vScrollImageStretch.setWidth(stretch->right - stretch->left); - m_vScrollImageStretch.setHeight(stretch->bottom - stretch->top); - } - } - else - { - delete img; - } - } - - return HGBASE_ERR_OK; -} - -HGResult HGImgThumb::setVScrollSliderImage(const QImage *normalImage, const HGRect *normalStretch, const QImage *hotImage, const HGRect *hotStretch, - const QImage *pushImage, const HGRect *pushStretch) -{ - if (MouseStatus_Null != m_mousePressStatus || 0 != m_operate || m_draging || m_frameSelection) - { - return HGBASE_ERR_FAIL; - } - - if (0 != m_frontItems.size()) - { - return HGBASE_ERR_FAIL; - } - - if (nullptr == normalImage) - { - delete m_vScrollSliderImage[0]; - m_vScrollSliderImage[0] = nullptr; - } - else - { - QImage *img = new QImage(*normalImage); - if (!img->isNull()) - { - if (nullptr != m_vScrollSliderImage[0]) - delete m_vScrollSliderImage[0]; - m_vScrollSliderImage[0] = img; - - if (nullptr == normalStretch || normalStretch->left < 0 || normalStretch->top < 0 - || normalStretch->right > m_vScrollSliderImage[0]->width() || normalStretch->bottom > m_vScrollSliderImage[0]->height() - || normalStretch->left >= normalStretch->right || normalStretch->top >= normalStretch->bottom) - { - m_vScrollSliderImageStretch[0].setX(0); - m_vScrollSliderImageStretch[0].setY(0); - m_vScrollSliderImageStretch[0].setWidth(m_vScrollSliderImage[0]->width()); - m_vScrollSliderImageStretch[0].setHeight(m_vScrollSliderImage[0]->height()); - } - else - { - m_vScrollSliderImageStretch[0].setX(normalStretch->left); - m_vScrollSliderImageStretch[0].setY(normalStretch->top); - m_vScrollSliderImageStretch[0].setWidth(normalStretch->right - normalStretch->left); - m_vScrollSliderImageStretch[0].setHeight(normalStretch->bottom - normalStretch->top); - } - } - else - { - delete img; - } - } - - if (nullptr == hotImage) - { - delete m_vScrollSliderImage[1]; - m_vScrollSliderImage[1] = nullptr; - } - else - { - QImage *img = new QImage(*hotImage); - if (!img->isNull()) - { - if (nullptr != m_vScrollSliderImage[1]) - delete m_vScrollSliderImage[1]; - m_vScrollSliderImage[1] = img; - - if (nullptr == hotStretch || hotStretch->left < 0 || hotStretch->top < 0 - || hotStretch->right > m_vScrollSliderImage[1]->width() || hotStretch->bottom > m_vScrollSliderImage[1]->height() - || hotStretch->left >= hotStretch->right || hotStretch->top >= hotStretch->bottom) - { - m_vScrollSliderImageStretch[1].setX(0); - m_vScrollSliderImageStretch[1].setY(0); - m_vScrollSliderImageStretch[1].setWidth(m_vScrollSliderImage[1]->width()); - m_vScrollSliderImageStretch[1].setHeight(m_vScrollSliderImage[1]->height()); - } - else - { - m_vScrollSliderImageStretch[1].setX(hotStretch->left); - m_vScrollSliderImageStretch[1].setY(hotStretch->top); - m_vScrollSliderImageStretch[1].setWidth(hotStretch->right - hotStretch->left); - m_vScrollSliderImageStretch[1].setHeight(hotStretch->bottom - hotStretch->top); - } - } - else - { - delete img; - } - } - - if (nullptr == pushImage) - { - delete m_vScrollSliderImage[2]; - m_vScrollSliderImage[2] = nullptr; - } - else - { - QImage *img = new QImage(*pushImage); - if (!img->isNull()) - { - if (nullptr != m_vScrollSliderImage[2]) - delete m_vScrollSliderImage[2]; - m_vScrollSliderImage[2] = img; - - if (nullptr == pushStretch || pushStretch->left < 0 || pushStretch->top < 0 - || pushStretch->right > m_vScrollSliderImage[2]->width() || pushStretch->bottom > m_vScrollSliderImage[2]->height() - || pushStretch->left >= pushStretch->right || pushStretch->top >= hotStretch->bottom) - { - m_vScrollSliderImageStretch[2].setX(0); - m_vScrollSliderImageStretch[2].setY(0); - m_vScrollSliderImageStretch[2].setWidth(m_vScrollSliderImage[2]->width()); - m_vScrollSliderImageStretch[2].setHeight(m_vScrollSliderImage[2]->height()); - } - else - { - m_vScrollSliderImageStretch[2].setX(pushStretch->left); - m_vScrollSliderImageStretch[2].setY(pushStretch->top); - m_vScrollSliderImageStretch[2].setWidth(pushStretch->right - pushStretch->left); - m_vScrollSliderImageStretch[2].setHeight(pushStretch->bottom - pushStretch->top); - } - } - else - { - delete img; - } - } - - return HGBASE_ERR_OK; -} - -HGResult HGImgThumb::setNullScrollImage(const QImage *image) -{ - if (MouseStatus_Null != m_mousePressStatus || 0 != m_operate || m_draging || m_frameSelection) - { - return HGBASE_ERR_FAIL; - } - - if (0 != m_frontItems.size()) - { - return HGBASE_ERR_FAIL; - } - - if (nullptr == image) - { - delete m_nullScrollImage; - m_nullScrollImage = nullptr; - } - else - { - QImage *img = new QImage(*image); - if (!img->isNull()) - { - if (nullptr != m_nullScrollImage) - delete m_nullScrollImage; - m_nullScrollImage = img; - } - else - { - delete img; - } - } - - return HGBASE_ERR_OK; -} - -HGResult HGImgThumb::setType(ThumbType type) -{ - if (MouseStatus_Null != m_mousePressStatus || 0 != m_operate || m_draging || m_frameSelection) - { - return HGBASE_ERR_FAIL; - } - - if (m_type == type) - { - return HGBASE_ERR_OK; - } - - m_type = type; - - int showWidth = 0, showHeight = 0; - calcShowSize(this->width(), this->height(), m_gapSize, m_scrollSize, m_itemSize, m_itemTextHeight, m_type, (int)m_frontItems.size(), - showWidth, showHeight, m_hScroll, m_vScroll); - m_showThumb = false; - memset(&m_thumbRect, 0, sizeof(ThumbRect)); - if (showWidth > 0 && showHeight > 0) - { - m_showThumb = true; - m_thumbRect.left = 0; - m_thumbRect.top = 0; - m_thumbRect.right = (double)showWidth; - m_thumbRect.bottom = (double)showHeight; - recalcShowRect(this->width(), this->height(), m_scrollSize, m_type, m_hScroll, m_vScroll, m_showThumb, m_thumbRect); - } - - m_hotItemIndex = getItemIndex(mapFromGlobal(QCursor::pos()), m_mouseMoveStatus); - Show(); - return HGBASE_ERR_OK; -} - -HGResult HGImgThumb::zoomIn() -{ - if (MouseStatus_Null != m_mousePressStatus || 0 != m_operate || m_draging || m_frameSelection) - { - return HGBASE_ERR_FAIL; - } - - if (0 == m_frontItems.size()) - { - return HGBASE_ERR_FAIL; - } - - assert(m_showThumb); - - int itemSize = (int)((float)m_itemSize * 1.2f); - int newItemSize = HGMIN(240, HGMAX(60, itemSize)); - if (m_itemSize == newItemSize) - { - return HGBASE_ERR_FAIL; - } - - HGBase_EnterLock(m_lockItemSize); - m_itemSize = newItemSize; - HGBase_LeaveLock(m_lockItemSize); - if (nullptr != m_defItemImage) - { - assert(nullptr != m_itemImage); - delete m_itemImage; - m_itemImage = createItemImage(m_defItemImage, m_itemSize); - assert(nullptr != m_itemImage); - } - - int showWidth = 0, showHeight = 0; - calcShowSize(this->width(), this->height(), m_gapSize, m_scrollSize, m_itemSize, m_itemTextHeight, m_type, (int)m_frontItems.size(), - showWidth, showHeight, m_hScroll, m_vScroll); - assert(showWidth > 0 && showHeight > 0); - m_thumbRect.right = m_thumbRect.left + (double)showWidth; - m_thumbRect.bottom = m_thumbRect.top + (double)showHeight; - recalcShowRect(this->width(), this->height(), m_scrollSize, m_type, m_hScroll, m_vScroll, m_showThumb, m_thumbRect); - - m_hotItemIndex = getItemIndex(mapFromGlobal(QCursor::pos()), m_mouseMoveStatus); - Show(); - - HGBase_EnterLock(m_lockBack); - m_backList.clear(); - for (int i = 0; i < (int)m_frontItems.size(); ++i) - { - m_backList.push_back(m_frontItems[i]->fileName); - } - HGBase_LeaveLock(m_lockBack); - HGBase_SetEvent(m_event); - - return HGBASE_ERR_OK; -} - -HGResult HGImgThumb::zoomOut() -{ - if (MouseStatus_Null != m_mousePressStatus || 0 != m_operate || m_draging || m_frameSelection) - { - return HGBASE_ERR_FAIL; - } - - if (0 == m_frontItems.size()) - { - return HGBASE_ERR_FAIL; - } - - assert(m_showThumb); - - int itemSize = (int)((float)m_itemSize * 1.0f / 1.2f); - int newItemSize = HGMIN(240, HGMAX(60, itemSize)); - if (m_itemSize == newItemSize) - { - return HGBASE_ERR_FAIL; - } - - HGBase_EnterLock(m_lockItemSize); - m_itemSize = newItemSize; - HGBase_LeaveLock(m_lockItemSize); - if (nullptr != m_defItemImage) - { - assert(nullptr != m_itemImage); - delete m_itemImage; - m_itemImage = createItemImage(m_defItemImage, m_itemSize); - assert(nullptr != m_itemImage); - } - - int showWidth = 0, showHeight = 0; - calcShowSize(this->width(), this->height(), m_gapSize, m_scrollSize, m_itemSize, m_itemTextHeight, m_type, (int)m_frontItems.size(), - showWidth, showHeight, m_hScroll, m_vScroll); - assert(showWidth > 0 && showHeight > 0); - m_thumbRect.right = m_thumbRect.left + (double)showWidth; - m_thumbRect.bottom = m_thumbRect.top + (double)showHeight; - recalcShowRect(this->width(), this->height(), m_scrollSize, m_type, m_hScroll, m_vScroll, m_showThumb, m_thumbRect); - - m_hotItemIndex = getItemIndex(mapFromGlobal(QCursor::pos()), m_mouseMoveStatus); - Show(); - - HGBase_EnterLock(m_lockBack); - m_backList.clear(); - for (int i = 0; i < (int)m_frontItems.size(); ++i) - { - m_backList.push_back(m_frontItems[i]->fileName); - } - HGBase_LeaveLock(m_lockBack); - HGBase_SetEvent(m_event); - - return HGBASE_ERR_OK; -} - -HGResult HGImgThumb::getItemCount(int *count) -{ - if (nullptr == count) - { - return HGBASE_ERR_INVALIDARG; - } - - *count = (int)m_frontItems.size(); - return HGBASE_ERR_OK; -} - -HGResult HGImgThumb::addItem(const QString &fileName) -{ - QStringList fileNames; - fileNames.append(fileName); - return addItems(fileNames); -} - -HGResult HGImgThumb::addItems(const QStringList &fileNames) -{ - return insertItems(fileNames, (int)m_frontItems.size(), true); -} - -HGResult HGImgThumb::insertItem(const QString &fileName, int pos) -{ - QStringList fileNames; - fileNames.append(fileName); - return insertItems(fileNames, pos); -} - -HGResult HGImgThumb::insertItems(const QStringList &fileNames, int pos, bool append) -{ - if (pos < 0 || pos > (int)m_frontItems.size()) - { - return HGBASE_ERR_INVALIDARG; - } - - bool findInThumb = false; - std::vector stdFileNames; - for (int i = 0; i < (int)fileNames.size(); ++i) - { - QString stdFileName = getStdFileName(fileNames[i]); - QFileInfo fileInfo(stdFileName); - if (!fileInfo.isFile()) - { - continue; - } - - bool find = false; - for (int j = 0; j < (int)stdFileNames.size(); ++j) - { - if (stdFileNames[j] == stdFileName) - { - find = true; - break; - } - } - - if (!find) - { - HGUInt fmtType = 0; - HGImgFmt_GetImgFmtTypeFromFileName(getStdString(stdFileName).c_str(), &fmtType); - if (0 != fmtType) - { - if (!findInThumb) - { - for (int i = 0; i < (int)m_frontItems.size(); ++i) - { - if (m_frontItems[i]->fileName == stdFileName) - { - findInThumb = true; - break; - } - } - } - - stdFileNames.push_back(stdFileName); - } - } - } - - if (stdFileNames.empty()) - { - if (!fileNames.empty()) - { - QMessageBox::information(this, tr("tips"), tr("unsupported file format")); - } - - return HGBASE_ERR_INVALIDARG; - } - - bool isMove = false; - if (findInThumb) - { - if (1 == stdFileNames.size()) - { - int index = findIndex(stdFileNames[0]); - assert(-1 != index); - - if (pos == index || pos == index + 1) - { - QMessageBox::information(this, tr("tips"), tr("file have been loaded")); - } - else - { - QString info = append ? tr("file have been loaded, do you want to move to end?") - : tr("file have been loaded, do you want to move to specified location?"); - QMessageBox msg(QMessageBox::Question, tr("Question"), - info, - QMessageBox::Yes | QMessageBox::No, this); - msg.exec(); - if (msg.clickedButton() == msg.button(QMessageBox::Yes)) - { - isMove = true; - } - } - } - else - { - QString info = append ? tr("some files have been loaded, do you want to move to end?") - : tr("some files have been loaded, do you want to move to specified location?"); - QMessageBox msg(QMessageBox::Question, tr("Question"), - info, - QMessageBox::Yes | QMessageBox::No, this); - msg.exec(); - if (msg.clickedButton() == msg.button(QMessageBox::Yes)) - { - isMove = true; - } - } - } - - reset(); - - int oldItemCount = (int)m_frontItems.size(); - int oldCurrItemIndex = m_curItemIndex; - QString oldCurrItemFilePath; - if (-1 != oldCurrItemIndex) - oldCurrItemFilePath = m_frontItems[oldCurrItemIndex]->fileName; - - std::vector oldSelectedIndexs; - for (int i = 0; i < (int)m_frontItems.size(); ++i) - { - if (m_frontItems[i]->selected) - oldSelectedIndexs.push_back(i); - m_frontItems[i]->selected = false; - } - - int posEx = pos; - - for (int i = 0; i < (int)stdFileNames.size(); ++i) - { - const QString &stdFileName = stdFileNames[i]; - int oldIndex = findIndex(stdFileName); - if (-1 == oldIndex) - { - HGImgThumbItem *item = new HGImgThumbItem; - item->fileName = stdFileName; - item->selected = true; - - HGBase_EnterLock(m_lockFront); - item->selected = true; - if (posEx != (int)m_frontItems.size()) - m_frontItems.insert(m_frontItems.begin() + posEx, item); - else - m_frontItems.push_back(item); - HGBase_LeaveLock(m_lockFront); - - HGBase_EnterLock(m_lockBack); - m_backList.push_back(stdFileName); - HGBase_LeaveLock(m_lockBack); - HGBase_SetEvent(m_event); - - ++posEx; - } - else - { - if (isMove) - { - HGImgThumbItem *item = m_frontItems[oldIndex]; - item->selected = true; - - if (oldIndex < posEx) - { - if (pos == posEx) - { - --pos; - } - - --posEx; - } - - HGBase_EnterLock(m_lockFront); - m_frontItems.erase(m_frontItems.begin() + oldIndex); - if (posEx != (int)m_frontItems.size()) - m_frontItems.insert(m_frontItems.begin() + posEx, item); - else - m_frontItems.push_back(item); - HGBase_LeaveLock(m_lockFront); - - ++posEx; - } - else - { - m_frontItems[oldIndex]->selected = true; - m_curItemIndex = oldIndex; - m_signItemIndex = oldIndex; - locateItem(oldIndex); - recalcShowRect(this->width(), this->height(), m_scrollSize, m_type, m_hScroll, m_vScroll, m_showThumb, m_thumbRect); - } - } - } - - if (pos != posEx) - { - m_curItemIndex = posEx - 1; - m_signItemIndex = posEx - 1; - - int showWidth = 0, showHeight = 0; - calcShowSize(this->width(), this->height(), m_gapSize, m_scrollSize, m_itemSize, m_itemTextHeight, m_type, (int)m_frontItems.size(), - showWidth, showHeight, m_hScroll, m_vScroll); - assert(showWidth > 0 && showHeight > 0); - m_showThumb = true; - m_thumbRect.right = m_thumbRect.left + (double)showWidth; - m_thumbRect.bottom = m_thumbRect.top + (double)showHeight; - locateItem(posEx - 1); - recalcShowRect(this->width(), this->height(), m_scrollSize, m_type, m_hScroll, m_vScroll, m_showThumb, m_thumbRect); - } - - m_hotItemIndex = getItemIndex(mapFromGlobal(QCursor::pos()), m_mouseMoveStatus); - Show(); - - int newItemCount = (int)m_frontItems.size(); - int newCurrItemIndex = m_curItemIndex; - QString newCurrItemFilePath; - if (-1 != newCurrItemIndex) - newCurrItemFilePath = m_frontItems[newCurrItemIndex]->fileName; - - std::vector newSelectedIndexs; - for (int i = 0; i < (int)m_frontItems.size(); ++i) - { - if (m_frontItems[i]->selected) - newSelectedIndexs.push_back(i); - } - - if (newItemCount != oldItemCount) - emit itemCountChanged((int)m_frontItems.size()); - if (newCurrItemIndex != oldCurrItemIndex || newCurrItemFilePath != oldCurrItemFilePath) - emit currItemChanged(m_curItemIndex); - if (newSelectedIndexs != oldSelectedIndexs) - emit itemSelectingChanged(); - return HGBASE_ERR_OK; -} - -HGResult HGImgThumb::moveItems(const QStringList &fileNames, int pos) -{ - if (pos < 0 || pos > (int)m_frontItems.size()) - { - return HGBASE_ERR_INVALIDARG; - } - - std::vector stdFileNames; - for (int i = 0; i < (int)fileNames.size(); ++i) - { - QString stdFileName = getStdFileName(fileNames[i]); - int oldIndex = findIndex(stdFileName); - if (-1 == oldIndex) - { - continue; - } - - bool find = false; - for (int j = 0; j < (int)stdFileNames.size(); ++j) - { - if (stdFileNames[j] == stdFileName) - { - find = true; - break; - } - } - - if (!find) - { - stdFileNames.push_back(stdFileName); - } - } - - if (stdFileNames.empty()) - { - return HGBASE_ERR_INVALIDARG; - } - - reset(); - - QString curItemFilePath; - if (-1 != m_curItemIndex) - curItemFilePath = m_frontItems[m_curItemIndex]->fileName; - QString signItemFilePath; - if (-1 != m_signItemIndex) - signItemFilePath = m_frontItems[m_signItemIndex]->fileName; - - int oldCurItemIndex = m_curItemIndex; - std::vector oldSelectedIndexs; - for (int i = 0; i < (int)m_frontItems.size(); ++i) - { - if (m_frontItems[i]->selected) - oldSelectedIndexs.push_back(i); - } - - int posEx = pos; - for (int i = 0; i < (int)stdFileNames.size(); ++i) - { - const QString &stdFileName = stdFileNames[i]; - int oldIndex = findIndex(stdFileName); - assert(-1 != oldIndex); - - HGImgThumbItem *item = m_frontItems[oldIndex]; - - if (oldIndex < posEx) - --posEx; - - HGBase_EnterLock(m_lockFront); - m_frontItems.erase(m_frontItems.begin() + oldIndex); - if (posEx != (int)m_frontItems.size()) - m_frontItems.insert(m_frontItems.begin() + posEx, item); - else - m_frontItems.push_back(item); - HGBase_LeaveLock(m_lockFront); - - ++posEx; - } - - m_curItemIndex = findIndex(curItemFilePath); - m_signItemIndex = findIndex(signItemFilePath); - - if (-1 != m_curItemIndex) - { - locateItem(m_curItemIndex); - recalcShowRect(this->width(), this->height(), m_scrollSize, m_type, m_hScroll, m_vScroll, m_showThumb, m_thumbRect); - } - - m_hotItemIndex = getItemIndex(mapFromGlobal(QCursor::pos()), m_mouseMoveStatus); - Show(); - - std::vector newSelectedIndexs; - for (int i = 0; i < (int)m_frontItems.size(); ++i) - { - if (m_frontItems[i]->selected) - newSelectedIndexs.push_back(i); - } - - if (m_curItemIndex != oldCurItemIndex) - emit currItemChanged(m_curItemIndex); - if (newSelectedIndexs != oldSelectedIndexs) - emit itemSelectingChanged(); - return HGBASE_ERR_OK; -} - -HGResult HGImgThumb::moveItemsTo(const QStringList &fileNames, int index) -{ - if (index < 0 || index >= (int)m_frontItems.size()) - { - return HGBASE_ERR_INVALIDARG; - } - - std::vector stdFileNames; - for (int i = 0; i < (int)fileNames.size(); ++i) - { - QString stdFileName = getStdFileName(fileNames[i]); - int oldIndex = findIndex(stdFileName); - if (-1 == oldIndex) - { - continue; - } - - bool find = false; - for (int j = 0; j < (int)stdFileNames.size(); ++j) - { - if (stdFileNames[j] == stdFileName) - { - find = true; - break; - } - } - - if (!find) - { - stdFileNames.push_back(stdFileName); - } - } - - if (stdFileNames.empty()) - { - return HGBASE_ERR_INVALIDARG; - } - - reset(); - - QString curItemFilePath; - if (-1 != m_curItemIndex) - curItemFilePath = m_frontItems[m_curItemIndex]->fileName; - QString signItemFilePath; - if (-1 != m_signItemIndex) - signItemFilePath = m_frontItems[m_signItemIndex]->fileName; - - int oldCurItemIndex = m_curItemIndex; - std::vector oldSelectedIndexs; - for (int i = 0; i < (int)m_frontItems.size(); ++i) - { - if (m_frontItems[i]->selected) - oldSelectedIndexs.push_back(i); - } - - HGBase_EnterLock(m_lockFront); - std::vector items; - for (int i = 0; i < (int)stdFileNames.size(); ++i) - { - const QString &stdFileName = stdFileNames[i]; - int oldIndex = findIndex(stdFileName); - assert(-1 != oldIndex); - - HGImgThumbItem *item = m_frontItems[oldIndex]; - m_frontItems.erase(m_frontItems.begin() + oldIndex); - items.push_back(item); - } - - if (index < (int)m_frontItems.size()) - { - int indexEx = index; - for (int i = 0; i < (int)items.size(); ++i) - { - m_frontItems.insert(m_frontItems.begin() + indexEx, items[i]); - ++indexEx; - } - } - else - { - for (int i = 0; i < (int)items.size(); ++i) - { - m_frontItems.push_back(items[i]); - } - } - HGBase_LeaveLock(m_lockFront); - - m_curItemIndex = findIndex(curItemFilePath); - m_signItemIndex = findIndex(signItemFilePath); - - locateItem(index); - recalcShowRect(this->width(), this->height(), m_scrollSize, m_type, m_hScroll, m_vScroll, m_showThumb, m_thumbRect); - - m_hotItemIndex = getItemIndex(mapFromGlobal(QCursor::pos()), m_mouseMoveStatus); - Show(); - - std::vector newSelectedIndexs; - for (int i = 0; i < (int)m_frontItems.size(); ++i) - { - if (m_frontItems[i]->selected) - newSelectedIndexs.push_back(i); - } - - if (m_curItemIndex != oldCurItemIndex) - emit currItemChanged(m_curItemIndex); - if (newSelectedIndexs != oldSelectedIndexs) - emit itemSelectingChanged(); - return HGBASE_ERR_OK; -} - -HGResult HGImgThumb::getItemFileName(int index, QString &fileName) -{ - if (index < 0 || index >= (int)m_frontItems.size()) - { - return HGBASE_ERR_INVALIDARG; - } - - fileName = m_frontItems[index]->fileName; - return HGBASE_ERR_OK; -} - -HGResult HGImgThumb::getCurrItem(int *index) -{ - if (nullptr == index) - { - return HGBASE_ERR_INVALIDARG; - } - - *index = m_curItemIndex; - return HGBASE_ERR_OK; -} - -HGResult HGImgThumb::setCurrItem(int index) -{ - if (MouseStatus_Null != m_mousePressStatus || 0 != m_operate || m_draging || m_frameSelection) - { - return HGBASE_ERR_FAIL; - } - - if (index < 0 || index >= (int)m_frontItems.size()) - { - return HGBASE_ERR_INVALIDARG; - } - - bool emitCurrItemChanged = false; - bool emitSelectingChanged = false; - - if (m_curItemIndex != index) - { - emitCurrItemChanged = true; - m_curItemIndex = index; - } - m_signItemIndex = index; - - for (int i = 0; i < (int)m_frontItems.size(); ++i) - { - if (i == index) - { - if (!m_frontItems[i]->selected) - emitSelectingChanged = true; - m_frontItems[i]->selected = true; - } - else - { - if (m_frontItems[i]->selected) - emitSelectingChanged = true; - m_frontItems[i]->selected = false; - } - } - - locateItem(index); - recalcShowRect(this->width(), this->height(), m_scrollSize, m_type, m_hScroll, m_vScroll, m_showThumb, m_thumbRect); - - m_hotItemIndex = getItemIndex(mapFromGlobal(QCursor::pos()), m_mouseMoveStatus); - Show(); - if (emitCurrItemChanged) - emit currItemChanged(m_curItemIndex); - if (emitSelectingChanged) - emit itemSelectingChanged(); - return HGBASE_ERR_OK; -} - -HGResult HGImgThumb::resetCurrItem() -{ - if (MouseStatus_Null != m_mousePressStatus || 0 != m_operate || m_draging || m_frameSelection) - { - return HGBASE_ERR_FAIL; - } - - bool emitCurrItemChanged = false; - bool emitSelectingChanged = false; - - if (m_curItemIndex != -1) - { - emitCurrItemChanged = true; - m_curItemIndex = -1; - } - - for (int i = 0; i < (int)m_frontItems.size(); ++i) - { - if (m_frontItems[i]->selected) - emitSelectingChanged = true; - m_frontItems[i]->selected = false; - } - - Show(); - if (emitCurrItemChanged) - emit currItemChanged(m_curItemIndex); - if (emitSelectingChanged) - emit itemSelectingChanged(); - return HGBASE_ERR_OK; -} - -HGResult HGImgThumb::removeItem(int index, ThumbRemoveFlag flag) -{ - std::vector indexs; - indexs.push_back(index); - return removeItems(indexs, flag); -} - -HGResult HGImgThumb::removeItems(const std::vector &indexs, ThumbRemoveFlag flag) -{ - if (MouseStatus_Null != m_mousePressStatus || 0 != m_operate || m_draging || m_frameSelection) - { - return HGBASE_ERR_FAIL; - } - - std::vector indexs2; - for (int i = 0; i < (int)indexs.size(); ++i) - { - if (indexs[i] < 0 || indexs[i] >= (int)m_frontItems.size()) - { - return HGBASE_ERR_INVALIDARG; - } - - bool find = false; - for (int j = 0; j < (int)indexs2.size(); ++j) - { - if (indexs2[j] == indexs[i]) - { - find = true; - break; - } - } - - if (!find) - { - indexs2.push_back(indexs[i]); - } - } - - if (indexs2.empty()) - { - return HGBASE_ERR_INVALIDARG; - } - - bool emitItemSelectingChange = false; - bool emitCurrItemChange = false; - - for (int i = 0; i < (int)indexs2.size(); ++i) - { - int index = indexs2[i]; - if (m_frontItems[index]->selected) - emitItemSelectingChange = true; - - HGBase_EnterLock(m_lockBack); - std::list::iterator iter; - for (iter = m_backList.begin(); iter != m_backList.end(); ++iter) - { - if (0 == (*iter).compare(m_frontItems[index]->fileName)) - { - m_backList.erase(iter); - break; - } - } - HGBase_LeaveLock(m_lockBack); - - if (flag == ThumbRemoveFlag_AllowUndo) - ; - else if (flag == ThumbRemoveFlag_Delete) - QFile::remove(m_frontItems[index]->fileName); - - HGBase_EnterLock(m_lockFront); - delete m_frontItems[index]; - m_frontItems.erase(m_frontItems.begin() + index); - HGBase_LeaveLock(m_lockFront); - - if (m_curItemIndex == index) - { - m_curItemIndex = -1; - emitCurrItemChange = true; - } - else if (m_curItemIndex > index) - { - --m_curItemIndex; - emitCurrItemChange = true; - } - - if (m_signItemIndex == index) - m_signItemIndex = -1; - else if (m_signItemIndex > index) - --m_signItemIndex; - - for (int j = i + 1; j < (int)indexs2.size(); ++j) - { - if (indexs2[j] > index) - { - --indexs2[j]; - } - } - } - - int showWidth = 0, showHeight = 0; - calcShowSize(this->width(), this->height(), m_gapSize, m_scrollSize, m_itemSize, m_itemTextHeight, m_type, (int)m_frontItems.size(), - showWidth, showHeight, m_hScroll, m_vScroll); - if (showWidth <= 0 || showHeight <= 0) - { - m_showThumb = false; - memset(&m_thumbRect, 0, sizeof(ThumbRect)); - } - else - { - m_thumbRect.right = m_thumbRect.left + (double)showWidth; - m_thumbRect.bottom = m_thumbRect.top + (double)showHeight; - recalcShowRect(this->width(), this->height(), m_scrollSize, m_type, m_hScroll, m_vScroll, m_showThumb, m_thumbRect); - } - - m_hotItemIndex = getItemIndex(mapFromGlobal(QCursor::pos()), m_mouseMoveStatus); - Show(); - emit itemCountChanged((int)m_frontItems.size()); - if (emitCurrItemChange) - emit currItemChanged(m_curItemIndex); - if (emitItemSelectingChange) - emit itemSelectingChanged(); - return HGBASE_ERR_OK; -} - -HGResult HGImgThumb::removeAllItems(ThumbRemoveFlag flag) -{ - if (m_frontItems.empty()) - { - return HGBASE_ERR_OK; - } - - reset(); - - bool emitItemSelectingChange = false; - - HGBase_EnterLock(m_lockBack); - m_backList.clear(); - HGBase_LeaveLock(m_lockBack); - - while (!m_frontItems.empty()) - { - if (m_frontItems[0]->selected) - emitItemSelectingChange = true; - - if (flag == ThumbRemoveFlag_AllowUndo) - ; - else if (flag == ThumbRemoveFlag_Delete) - QFile::remove(m_frontItems[0]->fileName); - - HGBase_EnterLock(m_lockFront); - delete m_frontItems[0]; - m_frontItems.erase(m_frontItems.begin()); - HGBase_LeaveLock(m_lockFront); - } - - bool emitItemChange = false; - if (-1 != m_curItemIndex) - { - m_curItemIndex = -1; - emitItemChange = true; - } - - m_signItemIndex = -1; - - m_hScroll = false; - m_vScroll = false; - m_showThumb = false; - memset(&m_thumbRect, 0, sizeof(ThumbRect)); - m_hotItemIndex = getItemIndex(mapFromGlobal(QCursor::pos()), m_mouseMoveStatus); - Show(); - emit itemCountChanged((int)m_frontItems.size()); - if (emitItemChange) - emit currItemChanged(m_curItemIndex); - if (emitItemSelectingChange) - emit itemSelectingChanged(); - return HGBASE_ERR_OK; -} - -HGResult HGImgThumb::bookSort() -{ - if (MouseStatus_Null != m_mousePressStatus || 0 != m_operate || m_draging || m_frameSelection) - { - return HGBASE_ERR_FAIL; - } - - int oldCurItemIndex = m_curItemIndex; - - for (int i = 0; i < (int)m_frontItems.size(); ++i) - { - if (m_curItemIndex == i) - { - if (0 == i % 2) - m_curItemIndex = i / 2; - else - m_curItemIndex = (int)m_frontItems.size() - (i + 1) / 2; - break; - } - } - - for (int i = 0; i < (int)m_frontItems.size(); ++i) - { - if (m_signItemIndex == i) - { - if (0 == i % 2) - m_signItemIndex = i / 2; - else - m_signItemIndex = (int)m_frontItems.size() - (i + 1) / 2; - break; - } - } - - std::list items1, items2; - for (int i = 0; i < (int)m_frontItems.size(); ++i) - { - HGImgThumbItem *item = m_frontItems[i]; - if (0 == i % 2) - items1.push_back(item); - else - items2.push_front(item); - } - - HGBase_EnterLock(m_lockFront); - m_frontItems.clear(); - std::list::const_iterator iter; - for (iter = items1.begin(); iter != items1.end(); ++iter) - m_frontItems.push_back(*iter); - for (iter = items2.begin(); iter != items2.end(); ++iter) - m_frontItems.push_back(*iter); - HGBase_LeaveLock(m_lockFront); - - if (-1 != m_curItemIndex) - { - locateItem(m_curItemIndex); - recalcShowRect(this->width(), this->height(), m_scrollSize, m_type, m_hScroll, m_vScroll, m_showThumb, m_thumbRect); - } - - m_hotItemIndex = getItemIndex(mapFromGlobal(QCursor::pos()), m_mouseMoveStatus); - Show(); - if (oldCurItemIndex != m_curItemIndex) - emit currItemChanged(m_curItemIndex); - - return HGBASE_ERR_OK; -} - -HGResult HGImgThumb::selectItem(int index, bool select) -{ - if (MouseStatus_Null != m_mousePressStatus || 0 != m_operate || m_draging || m_frameSelection) - { - return HGBASE_ERR_FAIL; - } - - if (index < 0 || index >= (int)m_frontItems.size()) - { - return HGBASE_ERR_INVALIDARG; - } - - if (m_frontItems[index]->selected == select) - { - return HGBASE_ERR_OK; - } - - m_frontItems[index]->selected = select; - Show(); - emit itemSelectingChanged(); - return HGBASE_ERR_OK; -} - -HGResult HGImgThumb::itemIsSelect(int index, bool *select) -{ - if (index < 0 || index >= (int)m_frontItems.size() || nullptr == select) - { - return HGBASE_ERR_INVALIDARG; - } - - *select = m_frontItems[index]->selected; - return HGBASE_ERR_OK; -} - -HGResult HGImgThumb::updateItem(int index, const QString &fileName) -{ - if (MouseStatus_Null != m_mousePressStatus || 0 != m_operate || m_draging || m_frameSelection) - { - return HGBASE_ERR_FAIL; - } - - if (index < 0 || index >= (int)m_frontItems.size()) - { - return HGBASE_ERR_INVALIDARG; - } - - QString stdFileName = getStdFileName(fileName); - QFileInfo fileInfo(stdFileName); - if (!fileInfo.isFile()) - { - return HGBASE_ERR_FAIL; - } - - if (-1 != findIndex(stdFileName)) - { - return HGBASE_ERR_FAIL; - } - - QString oldFileName = m_frontItems[index]->fileName; - m_frontItems[index]->fileName = stdFileName; - - HGBase_EnterLock(m_lockBack); - std::list::iterator iter; - for (iter = m_backList.begin(); iter != m_backList.end(); ++iter) - { - if (0 == (*iter).compare(oldFileName)) - { - m_backList.erase(iter); - break; - } - } - m_backList.push_front(stdFileName); - HGBase_LeaveLock(m_lockBack); - HGBase_SetEvent(m_event); - - return HGBASE_ERR_OK; -} - -HGResult HGImgThumb::refreshItem(int index) -{ - if (MouseStatus_Null != m_mousePressStatus || 0 != m_operate || m_draging || m_frameSelection) - { - return HGBASE_ERR_FAIL; - } - - if (index < 0 || index >= (int)m_frontItems.size()) - { - return HGBASE_ERR_INVALIDARG; - } - - QString fileName = m_frontItems[index]->fileName; - - HGBase_EnterLock(m_lockBack); - std::list::iterator iter; - for (iter = m_backList.begin(); iter != m_backList.end(); ++iter) - { - if (0 == (*iter).compare(fileName)) - { - m_backList.erase(iter); - break; - } - } - m_backList.push_front(fileName); - HGBase_LeaveLock(m_lockBack); - HGBase_SetEvent(m_event); - - return HGBASE_ERR_OK; -} - -HGResult HGImgThumb::refreshItem(const QString &fileName) -{ - if (fileName.isEmpty()) - { - return HGBASE_ERR_INVALIDARG; - } - - QString stdFileName = getStdFileName(fileName); - int index = findIndex(fileName); - return refreshItem(index); -} - -HGResult HGImgThumb::refreshAllItems() -{ - if (MouseStatus_Null != m_mousePressStatus || 0 != m_operate || m_draging || m_frameSelection) - { - return HGBASE_ERR_FAIL; - } - - HGBase_EnterLock(m_lockBack); - m_backList.clear(); - for (int i = 0; i < (int)m_frontItems.size(); ++i) - { - m_backList.push_back(m_frontItems[i]->fileName); - } - HGBase_LeaveLock(m_lockBack); - HGBase_SetEvent(m_event); - - return HGBASE_ERR_OK; -} - -void HGImgThumb::notify_mouse_leave(void) -{ - leaveEvent(nullptr); -} - -void HGImgThumb::mousePressEvent(QMouseEvent *e) -{ - m_mouseOn = true; - - MouseStatus mouseStatus = MouseStatus_Null; - int index = getItemIndex(e->pos(), mouseStatus); - - if (-1 == index && MouseStatus_Null != mouseStatus) - { - // 右键不处理滚动条区域 - if (e->button() == Qt::LeftButton) - { - m_mousePressStatus = mouseStatus; - m_mousePressBeginX = e->pos().x(); - m_mousePressBeginY = e->pos().y(); - Show(); - } - - return; - } - - m_hitMouseButtons = e->button(); - m_hitKeyboardModifiers = QGuiApplication::keyboardModifiers(); - m_hitItemIndex = index; - - bool emitCurItemChange = false; - bool emitItemSelectingChange = false; - - if (e->button() == Qt::RightButton) // 右键按下 - { - if (-1 != index) - { - if (Qt::ControlModifier != m_hitKeyboardModifiers) - { - if (!m_frontItems[index]->selected) - { - for (int i = 0; i < (int)m_frontItems.size(); ++i) - { - m_frontItems[i]->selected = (i == index) ? true : false; - } - - emitItemSelectingChange = true; - } - - if (index != m_curItemIndex) - { - m_curItemIndex = index; - emitCurItemChange = true; - } - - m_pushItemIndex = index; - m_signItemIndex = index; - } - } - } - else // 左键按下 - { - if (QGuiApplication::keyboardModifiers() == Qt::ControlModifier) - { - if (-1 != index) - { - if (index != m_curItemIndex) - { - m_curItemIndex = index; - emitCurItemChange = true; - } - - m_pushItemIndex = index; - m_signItemIndex = index; - } - } - else if (QGuiApplication::keyboardModifiers() == Qt::ShiftModifier) - { - if (-1 != index) - { - if (-1 == m_signItemIndex) - { - for (int i = 0; i < (int)m_frontItems.size(); ++i) - { - if (i == index) - { - if (!m_frontItems[i]->selected) - emitItemSelectingChange = true; - m_frontItems[i]->selected = true; - } - else - { - if (m_frontItems[i]->selected) - emitItemSelectingChange = true; - m_frontItems[i]->selected = false; - } - } - } - else - { - for (int i = 0; i < (int)m_frontItems.size(); ++i) - { - if (i >= HGMIN(index, m_signItemIndex) && i <= HGMAX(index, m_signItemIndex)) - { - if (!m_frontItems[i]->selected) - emitItemSelectingChange = true; - m_frontItems[i]->selected = true; - } - else - { - if (m_frontItems[i]->selected) - emitItemSelectingChange = true; - m_frontItems[i]->selected = false; - } - } - } - - if (index != m_curItemIndex) - { - m_curItemIndex = index; - emitCurItemChange = true; - } - - m_pushItemIndex = index; - } - } - else - { - if (-1 != index) - { - if (!m_frontItems[index]->selected) - { - for (int i = 0; i < (int)m_frontItems.size(); ++i) - { - m_frontItems[i]->selected = (i == index) ? true : false; - } - - emitItemSelectingChange = true; - } - - if (index != m_curItemIndex) - { - m_curItemIndex = index; - emitCurItemChange = true; - } - - m_pushItemIndex = index; - m_signItemIndex = index; - } - } - } - - if (-1 != index) - { - if (e->button() == Qt::LeftButton && index == m_curItemIndex) - { - // 准备拖动 - m_operate = 1; - m_operateStartX = e->pos().x(); - m_operateStartY = e->pos().y(); - } - - locateItem(index); - recalcShowRect(this->width(), this->height(), m_scrollSize, m_type, m_hScroll, m_vScroll, m_showThumb, m_thumbRect); - m_hotItemIndex = getItemIndex(mapFromGlobal(QCursor::pos()), m_mouseMoveStatus); - } - else - { - if (e->button() == Qt::LeftButton && 0 != (int)m_frontItems.size()) - { - assert(m_showThumb); - // 准备框选 - m_operate = 2; - m_operateStartX = e->pos().x(); - m_operateStartY = e->pos().y(); - } - } - - Show(); - if (emitCurItemChange) - emit currItemChanged(m_curItemIndex); - if (emitItemSelectingChange) - emit itemSelectingChanged(); -} - -void HGImgThumb::mouseMoveEvent(QMouseEvent* e) -{ - bool emitCurItemChange = false; - bool emitItemSelectingChange = false; - - // 处理拖动 - if (m_frameSelection) - { - m_frameSelectionRect.left = HGMIN(m_frameSelectionStartX, e->pos().x() - round(m_thumbRect.left)); - m_frameSelectionRect.top = HGMIN(m_frameSelectionStartY, e->pos().y() - round(m_thumbRect.top)); - m_frameSelectionRect.right = HGMAX(m_frameSelectionStartX, e->pos().x() - round(m_thumbRect.left)); - m_frameSelectionRect.bottom = HGMAX(m_frameSelectionStartY, e->pos().y() - round(m_thumbRect.top)); - m_frameSelectionRectValid = true; - - QRect rect1(m_frameSelectionRect.left, m_frameSelectionRect.top, - m_frameSelectionRect.right - m_frameSelectionRect.left, m_frameSelectionRect.bottom - m_frameSelectionRect.top); - for (int i = 0; i < (int)m_frontItems.size(); ++i) - { - QPoint pt = getItemPos(i); - QRect rect2(pt.x(), pt.y(), m_itemSize, m_itemSize + m_itemTextHeight); - if (rect1.intersects(rect2)) - { - if (!m_frontItems[i]->selected) - emitItemSelectingChange = true; - m_frontItems[i]->selected = true; - } - else - { - if (m_frontItems[i]->selected) - emitItemSelectingChange = true; - m_frontItems[i]->selected = false; - } - } - - if (e->pos().x() < 0) - { - m_thumbRect.left += -e->pos().x(); - m_thumbRect.right += -e->pos().x(); - recalcShowRect(this->width(), this->height(), m_scrollSize, m_type, m_hScroll, m_vScroll, m_showThumb, m_thumbRect); - } - else if (e->pos().x() > this->width()) - { - m_thumbRect.left -= (e->pos().x() - this->width()); - m_thumbRect.right -= (e->pos().x() - this->width()); - recalcShowRect(this->width(), this->height(), m_scrollSize, m_type, m_hScroll, m_vScroll, m_showThumb, m_thumbRect); - } - - if (e->pos().y() < 0) - { - m_thumbRect.top += -e->pos().y(); - m_thumbRect.bottom += -e->pos().y(); - recalcShowRect(this->width(), this->height(), m_scrollSize, m_type, m_hScroll, m_vScroll, m_showThumb, m_thumbRect); - } - else if (e->pos().y() > this->height()) - { - m_thumbRect.top -= (e->pos().y() - this->height()); - m_thumbRect.bottom -= (e->pos().y() - this->height()); - recalcShowRect(this->width(), this->height(), m_scrollSize, m_type, m_hScroll, m_vScroll, m_showThumb, m_thumbRect); - } - } - - // 处理滚动条 - if (MouseStatus_HScrollSlider == m_mousePressStatus) - { - int lXAmount = e->pos().x() - m_mousePressBeginX; - double offset; - if (!m_vScroll) - { - int rollTotalLen = this->width() - 2 * m_scrollSize; - int rollLeft = round((double)rollTotalLen * (-m_thumbRect.left) / (double)(m_thumbRect.right - m_thumbRect.left)); - int rollRight = round((double)rollTotalLen * (-m_thumbRect.left + this->width()) / (double)(m_thumbRect.right - m_thumbRect.left)); - int rollLen = rollRight - rollLeft; - if (rollLen >= m_minScrollSliderSize) - offset = lXAmount * (m_thumbRect.right - m_thumbRect.left) / rollTotalLen; - else - offset = lXAmount * (m_thumbRect.right - m_thumbRect.left - this->width()) / (rollTotalLen - m_minScrollSliderSize); - } - else - { - int rollTotalLen = this->width() - 3 * m_scrollSize; - int rollLeft = round((double)rollTotalLen * (-m_thumbRect.left) / (double)(m_thumbRect.right - m_thumbRect.left)); - int rollRight = round((double)rollTotalLen * (-m_thumbRect.left + this->width() - m_scrollSize) / (double)(m_thumbRect.right - m_thumbRect.left)); - int rollLen = rollRight - rollLeft; - if (rollLen >= m_minScrollSliderSize) - offset = lXAmount * (m_thumbRect.right - m_thumbRect.left) / rollTotalLen; - else - offset = lXAmount * (m_thumbRect.right - m_thumbRect.left - this->width() + m_scrollSize) / (rollTotalLen - m_minScrollSliderSize); - } - m_thumbRect.left -= offset; - m_thumbRect.right -= offset; - recalcShowRect(this->width(), this->height(), m_scrollSize, m_type, m_hScroll, m_vScroll, m_showThumb, m_thumbRect); - - m_mousePressBeginX = e->pos().x(); - m_mousePressBeginY = e->pos().y(); - } - else if (MouseStatus_VScrollSlider == m_mousePressStatus) - { - int lYAmount = e->pos().y() - m_mousePressBeginY; - double offset; - if (!m_hScroll) - { - int rollTotalLen = this->height() - 2 * m_scrollSize; - int rollTop = round((double)rollTotalLen * (-m_thumbRect.top) / (double)(m_thumbRect.bottom - m_thumbRect.top)); - int rollBottom = round((double)rollTotalLen * (-m_thumbRect.top + this->height()) / (double)(m_thumbRect.bottom - m_thumbRect.top)); - int rollLen = rollBottom - rollTop; - if (rollLen >= m_minScrollSliderSize) - offset = lYAmount * (m_thumbRect.bottom - m_thumbRect.top) / rollTotalLen; - else - offset = lYAmount * (m_thumbRect.bottom - m_thumbRect.top - this->height()) / (rollTotalLen - m_minScrollSliderSize); - } - else - { - int rollTotalLen = this->height() - 3 * m_scrollSize; - int rollTop = round((double)rollTotalLen * (-m_thumbRect.top) / (double)(m_thumbRect.bottom - m_thumbRect.top)); - int rollBottom = round((double)rollTotalLen * (-m_thumbRect.top + this->height() - m_scrollSize) / (double)(m_thumbRect.bottom - m_thumbRect.top)); - int rollLen = rollBottom - rollTop; - if (rollLen >= m_minScrollSliderSize) - offset = lYAmount * (m_thumbRect.bottom - m_thumbRect.top) / rollTotalLen; - else - offset = lYAmount * (m_thumbRect.bottom - m_thumbRect.top - this->height() + m_scrollSize) / (rollTotalLen - m_minScrollSliderSize); - } - m_thumbRect.top -= offset; - m_thumbRect.bottom -= offset; - recalcShowRect(this->width(), this->height(), m_scrollSize, m_type, m_hScroll, m_vScroll, m_showThumb, m_thumbRect); - - m_mousePressBeginX = e->pos().x(); - m_mousePressBeginY = e->pos().y(); - } - - if (0 == m_operate) - { - m_hotItemIndex = getItemIndex(e->pos(), m_mouseMoveStatus); - } - else if (1 == m_operate) - { - if ((e->buttons() & Qt::LeftButton) - && (e->pos() - QPoint(m_operateStartX, m_operateStartY)).manhattanLength() >= QApplication::startDragDistance() - && -1 != m_curItemIndex && m_frontItems[m_curItemIndex]->selected) - { - QList urls; - for (int i = 0; i < (int)m_frontItems.size(); ++i) - { - if (m_frontItems[i]->selected) - urls.append(QUrl::fromLocalFile(m_frontItems[i]->fileName)); - } - - QDrag *drag = new QDrag(this); - QMimeData *mimeData = new QMimeData; - mimeData->setUrls(urls); - drag->setMimeData(mimeData); - - QPixmap pixmap; - HGBase_EnterLock(m_lockFront); - QImage *img = m_frontItems[m_curItemIndex]->image; - if (nullptr == img) - img = m_itemImage; - if (nullptr != img) - pixmap = QPixmap::fromImage(*img); - HGBase_LeaveLock(m_lockFront); - - if (!pixmap.isNull()) - { - QPainter painter(&pixmap); - QRect textRect(0, 0, pixmap.width(), pixmap.height()); - char chCount[12]; - sprintf(chCount, "%d", urls.count()); - QFont countFont("微软雅黑", pixmap.width() / 4); - painter.setFont(countFont); - QPen countPen(QColor(0, 0, 0, 200)); - painter.setPen(countPen); - painter.drawText(textRect, Qt::AlignHCenter | Qt::AlignVCenter, chCount); - - drag->setPixmap(pixmap); - drag->setHotSpot(QPoint(pixmap.width() / 2, 4 * pixmap.height() / 5)); - } - - m_pushItemIndex = -1; - - m_operate = 0; - m_operateStartX = -1; - m_operateStartY = -1; - - m_hitMouseButtons = Qt::NoButton; - m_hitKeyboardModifiers = Qt::NoModifier; - m_hitItemIndex = -1; - - // 开始拖动 - drag->exec(Qt::CopyAction); - } - } - else if (2 == m_operate) - { - if ((e->buttons() & Qt::LeftButton) - && (e->pos() - QPoint(m_operateStartX, m_operateStartY)).manhattanLength() >= QApplication::startDragDistance()) - { - m_frameSelectionStartX = m_operateStartX - round(m_thumbRect.left); - m_frameSelectionStartY = m_operateStartY - round(m_thumbRect.top); - - m_pushItemIndex = -1; - - m_operate = 0; - m_operateStartX = -1; - m_operateStartY = -1; - - m_hitMouseButtons = Qt::NoButton; - m_hitKeyboardModifiers = Qt::NoModifier; - m_hitItemIndex = -1; - - for (int i = 0; i < (int)m_frontItems.size(); ++i) - { - if (m_frontItems[i]->selected) - emitItemSelectingChange = true; - m_frontItems[i]->selected = false; - } - - // 开始框选 - m_frameSelection = true; - m_frameSelectionRect.left = HGMIN(m_frameSelectionStartX, e->pos().x() - round(m_thumbRect.left)); - m_frameSelectionRect.top = HGMIN(m_frameSelectionStartY, e->pos().y() - round(m_thumbRect.top)); - m_frameSelectionRect.right = HGMAX(m_frameSelectionStartX, e->pos().x() - round(m_thumbRect.left)); - m_frameSelectionRect.bottom = HGMAX(m_frameSelectionStartY, e->pos().y() - round(m_thumbRect.top)); - m_frameSelectionRectValid = true; - } - } - - Show(); - if (emitCurItemChange) - emit currItemChanged(m_curItemIndex); - if (emitItemSelectingChange) - emit itemSelectingChanged(); -} - -void HGImgThumb::mouseReleaseEvent(QMouseEvent *e) -{ - Q_UNUSED(e); - - m_frameSelectionRectValid = false; - m_frameSelection = false; - - m_curInsertPos = -1; - m_insertPtValid = false; - m_draging = false; - - m_pushItemIndex = -1; - - m_operateStartX = -1; - m_operateStartY = -1; - m_operate = 0; - - Qt::MouseButtons oldHitMouseButtons = m_hitMouseButtons; - Qt::KeyboardModifiers oldHitKeyboardModifiers = m_hitKeyboardModifiers; - int oldHitItemIndex = m_hitItemIndex; - m_hitMouseButtons = Qt::NoButton; - m_hitKeyboardModifiers = Qt::NoModifier; - m_hitItemIndex = -1; - - MouseStatus oldMousePressStatus = m_mousePressStatus; - m_mousePressStatus = MouseStatus_Null; - m_mousePressBeginX = -1; - m_mousePressBeginY = -1; - - bool emitItemSelectingChanged = false; - bool emitCurrItemChanged = false; - - // 处理拖动 - - // 处理按item区域 - if (oldHitMouseButtons == Qt::RightButton) - { - if (-1 == oldHitItemIndex) - { - if (oldHitKeyboardModifiers == Qt::NoModifier) - { - for (int i = 0; i < (int)m_frontItems.size(); ++i) - { - if (m_frontItems[i]->selected) - emitItemSelectingChanged = true; - m_frontItems[i]->selected = false; - } - } - } - } - else if (oldHitMouseButtons == Qt::LeftButton) - { - if (oldHitKeyboardModifiers == Qt::ControlModifier) - { - if (-1 != oldHitItemIndex) - { - if (m_frontItems[oldHitItemIndex]->selected) - { - m_frontItems[oldHitItemIndex]->selected = false; - } - else - { - m_frontItems[oldHitItemIndex]->selected = true; - } - - emitItemSelectingChanged = true; - } - } - else if (oldHitKeyboardModifiers == Qt::ShiftModifier) - { - // 什么也不做 - } - else - { - if (-1 == oldHitItemIndex) - { - for (int i = 0; i < (int)m_frontItems.size(); ++i) - { - if (m_frontItems[i]->selected) - emitItemSelectingChanged = true; - m_frontItems[i]->selected = false; - } - } - else - { - for (int i = 0; i < (int)m_frontItems.size(); ++i) - { - if (i != oldHitItemIndex) - { - if (m_frontItems[i]->selected) - emitItemSelectingChanged = true; - m_frontItems[i]->selected = false; - } - } - } - } - } - - // 处理按滚动条区域 - MouseStatus mouseMoveStatus = MouseStatus_Null; - getItemIndex(e->pos(), mouseMoveStatus); - if (MouseStatus_HScrollLeft == oldMousePressStatus && MouseStatus_HScrollLeft == mouseMoveStatus) - { - m_thumbRect.left += (double)m_itemSize / 2.0; - m_thumbRect.right += (double)m_itemSize / 2.0; - recalcShowRect(this->width(), this->height(), m_scrollSize, m_type, m_hScroll, m_vScroll, m_showThumb, m_thumbRect); - } - else if (MouseStatus_HScrollRight == oldMousePressStatus && MouseStatus_HScrollRight == mouseMoveStatus) - { - m_thumbRect.left -= (double)m_itemSize / 2.0; - m_thumbRect.right -= (double)m_itemSize / 2.0; - recalcShowRect(this->width(), this->height(), m_scrollSize, m_type, m_hScroll, m_vScroll, m_showThumb, m_thumbRect); - } - else if (MouseStatus_VScrollTop == oldMousePressStatus && MouseStatus_VScrollTop == mouseMoveStatus) - { - m_thumbRect.top += (double)m_itemSize / 2.0; - m_thumbRect.bottom += (double)m_itemSize / 2.0; - recalcShowRect(this->width(), this->height(), m_scrollSize, m_type, m_hScroll, m_vScroll, m_showThumb, m_thumbRect); - } - else if (MouseStatus_VScrollBottom == oldMousePressStatus && MouseStatus_VScrollBottom == mouseMoveStatus) - { - m_thumbRect.top -= (double)m_itemSize / 2.0; - m_thumbRect.bottom -= (double)m_itemSize / 2.0; - recalcShowRect(this->width(), this->height(), m_scrollSize, m_type, m_hScroll, m_vScroll, m_showThumb, m_thumbRect); - } - - m_hotItemIndex = getItemIndex(mapFromGlobal(QCursor::pos()), m_mouseMoveStatus); - Show(); - if (emitCurrItemChanged) - emit currItemChanged(m_curItemIndex); - if (emitItemSelectingChanged) - emit itemSelectingChanged(); -} - -void HGImgThumb::enterEvent(QEvent *e) -{ - Q_UNUSED(e); - m_mouseOn = true; -} - -void HGImgThumb::leaveEvent(QEvent *e) -{ - Q_UNUSED(e); - - m_frameSelectionRectValid = false; - m_frameSelection = false; - - // 拖动状态不能重置 - //m_curInsertPos = -1; - //m_insertPtValid = false; - //m_draging = false; - - m_pushItemIndex = -1; - - m_operateStartX = -1; - m_operateStartY = -1; - m_operate = 0; - - m_hitMouseButtons = Qt::NoButton; - m_hitKeyboardModifiers = Qt::NoModifier; - m_hitItemIndex = -1; - - m_mousePressStatus = MouseStatus_Null; - m_mousePressBeginX = -1; - m_mousePressBeginY = -1; - - m_mouseOn = false; - m_hotItemIndex = -1; - m_mouseMoveStatus = MouseStatus_Null; - Show(); -} - -static void GetShowImageRect(const HGRect *pWnd, int nImgWidth, int nImgHeight, HGRect &rcShowImage) -{ - int nWndWidth = pWnd->right - pWnd->left; - int nWndHeight = pWnd->bottom - pWnd->top; - - int left, top, right, bottom; - if (nImgWidth > nWndWidth || nImgHeight > nWndHeight) - { - if (nImgWidth * nWndHeight < nImgHeight * nWndWidth) - { - int width = nWndHeight * nImgWidth / nImgHeight; - left = (pWnd->left + pWnd->right - width) / 2; - right = (pWnd->left + pWnd->right + width) / 2; - top = pWnd->top; - bottom = pWnd->bottom; - } - else - { - int height = nWndWidth * nImgHeight / nImgWidth; - left = pWnd->left; - right = pWnd->right; - top = (pWnd->top + pWnd->bottom - height) / 2; - bottom = (pWnd->top + pWnd->bottom + height) / 2; - } - } - else - { - left = (pWnd->left + pWnd->right - nImgWidth) / 2; - right = (pWnd->left + pWnd->right + nImgWidth) / 2; - top = (pWnd->top + pWnd->bottom - nImgHeight) / 2; - bottom = (pWnd->top + pWnd->bottom + nImgHeight) / 2; - } - - rcShowImage.left = left; - rcShowImage.top = top; - rcShowImage.right = right; - rcShowImage.bottom = bottom; -} - -void HGImgThumb::paintEvent(QPaintEvent* e) -{ - Q_UNUSED(e); - - QPainter painter(this); - QRect rcWnd(0, 0, this->width(), this->height()); - painter.fillRect(rcWnd, qRgb(250, 250, 250)); - - for (int i = 0; i < (int)m_frontItems.size(); ++i) - { - QPoint pt(getItemPos(i).x() + round(m_thumbRect.left), - getItemPos(i).y() + round(m_thumbRect.top)); - - QRect rcItem(pt.x(), pt.y(), m_itemSize, m_itemSize + m_itemTextHeight); - if (!rcItem.intersects(rcWnd)) - { - continue; - } - - // 绘制图像 - HGBase_EnterLock(m_lockFront); - int imgOriginWidth = m_frontItems[i]->width; - int imgOriginHeight = m_frontItems[i]->height; - QImage *img = m_frontItems[i]->image; - if (nullptr == img && nullptr != m_itemImage) - { - assert(nullptr != m_defItemImage); - imgOriginWidth = m_defItemImage->width(); - imgOriginHeight = m_defItemImage->height(); - img = m_itemImage; - } - if (nullptr != img) - { - HGRect rcShow; - HGRect rcItemShow = {pt.x(), pt.y(), pt.x() + m_itemSize, pt.y() + m_itemSize}; - GetShowImageRect(&rcItemShow, imgOriginWidth, imgOriginHeight, rcShow); - QRect destRect(rcShow.left, rcShow.top, rcShow.right - rcShow.left, rcShow.bottom - rcShow.top); - painter.drawImage(destRect, *img); - } - HGBase_LeaveLock(m_lockFront); - - // 绘制itemIndex - HGChar itemIndex[10] = {0}; - sprintf(itemIndex, "%d", i + 1); - QRect itemIndexRect(pt.x(), pt.y(), m_itemSize, m_itemSize); - QFont itemIndexFont("微软雅黑", m_itemSize / 4); - painter.setFont(itemIndexFont); - QPen itemIndexPen(QColor(0, 0, 0, 100)); - painter.setPen(itemIndexPen); - painter.drawText(itemIndexRect, Qt::AlignHCenter | Qt::AlignVCenter, itemIndex); - - // 绘制文件名 - HGChar fileName[256] = {0}; - HGBase_GetFileName(m_frontItems[i]->fileName.toStdString().c_str(), fileName, 256); - QRect fileNameRect(pt.x(), pt.y() + m_itemSize, m_itemSize, m_itemTextHeight); - QFont fileNameFont("微软雅黑", 8); - painter.setFont(fileNameFont); - QPen fileNamePen(QColor(0, 0, 0, 255)); - painter.setPen(fileNamePen); - painter.drawText(fileNameRect, Qt::AlignHCenter | Qt::AlignVCenter, fileName); - - if (m_frontItems[i]->selected) - { - painter.fillRect(pt.x(), pt.y(), m_itemSize, m_itemSize + m_itemTextHeight, QColor(0, 0, 0, 128)); - } - } - - if (-1 != m_hotItemIndex && !m_frontItems[m_hotItemIndex]->selected) - { - QPoint pt(getItemPos(m_hotItemIndex).x() + round(m_thumbRect.left), - getItemPos(m_hotItemIndex).y() + round(m_thumbRect.top)); - painter.fillRect(pt.x(), pt.y(), m_itemSize, m_itemSize + m_itemTextHeight, QColor(0, 0, 0, 64)); - } - - if (-1 != m_pushItemIndex && !m_frontItems[m_pushItemIndex]->selected) - { - QPoint pt(getItemPos(m_pushItemIndex).x() + round(m_thumbRect.left), - getItemPos(m_pushItemIndex).y() + round(m_thumbRect.top)); - painter.fillRect(pt.x(), pt.y(), m_itemSize, m_itemSize + m_itemTextHeight, QColor(0, 0, 0, 96)); - } - - if (-1 != m_curItemIndex) - { - QPoint pt(getItemPos(m_curItemIndex).x() + round(m_thumbRect.left), - getItemPos(m_curItemIndex).y() + round(m_thumbRect.top)); - - QPen pen(QColor(0, 0, 0, 128)); - painter.setPen(pen); - painter.drawRect(pt.x(), pt.y(), m_itemSize - 1, m_itemSize + m_itemTextHeight - 1); - } - - if (m_insertPtValid) - { - QPen pen(QColor(0, 0, 0, 128), 3); - painter.setPen(pen); - QPoint pt1(m_insertPt1.x() + round(m_thumbRect.left), m_insertPt1.y() + round(m_thumbRect.top)); - QPoint pt2(m_insertPt2.x() + round(m_thumbRect.left), m_insertPt2.y() + round(m_thumbRect.top)); - painter.drawLine(pt1, pt2); - } - - if (m_frameSelectionRectValid) - { - QRect rect(m_frameSelectionRect.left + round(m_thumbRect.left), m_frameSelectionRect.top + round(m_thumbRect.top), - m_frameSelectionRect.right - m_frameSelectionRect.left, - m_frameSelectionRect.bottom - m_frameSelectionRect.top); - painter.fillRect(rect, QColor(0, 0, 0, 128)); - } - - DrawScroll(painter); -} - -void HGImgThumb::wheelEvent(QWheelEvent* e) -{ - if (MouseStatus_Null != m_mousePressStatus || 0 != m_operate || m_draging || m_frameSelection) - { - return; - } - - if (!m_showThumb) - { - return; - } - - if (QGuiApplication::keyboardModifiers() == Qt::ControlModifier) - { - if (e->delta() > 0) - zoomIn(); - else - zoomOut(); - return; - } - - if (e->delta() > 0) - { - if (ThumbType_Hori == m_type) - { - m_thumbRect.left += (double)m_itemSize / 2.0; - m_thumbRect.right += (double)m_itemSize / 2.0; - } - else - { - m_thumbRect.top += (double)m_itemSize / 2.0; - m_thumbRect.bottom += (double)m_itemSize / 2.0; - } - } - else - { - if (ThumbType_Hori == m_type) - { - m_thumbRect.left -= (double)m_itemSize / 2.0; - m_thumbRect.right -= (double)m_itemSize / 2.0; - } - else - { - m_thumbRect.top -= (double)m_itemSize / 2.0; - m_thumbRect.bottom -= (double)m_itemSize / 2.0; - } - } - - recalcShowRect(this->width(), this->height(), m_scrollSize, m_type, m_hScroll, m_vScroll, m_showThumb, m_thumbRect); - m_hotItemIndex = getItemIndex(mapFromGlobal(QCursor::pos()), m_mouseMoveStatus); - Show(); -} - -void HGImgThumb::resizeEvent(QResizeEvent* e) -{ - Q_UNUSED(e); - - reset(); - - if (m_showThumb) - { - int showWidth = 0, showHeight = 0; - calcShowSize(this->width(), this->height(), m_gapSize, m_scrollSize, m_itemSize, m_itemTextHeight, m_type, (int)m_frontItems.size(), - showWidth, showHeight, m_hScroll, m_vScroll); - m_thumbRect.right = m_thumbRect.left + (double)showWidth; - m_thumbRect.bottom = m_thumbRect.top + (double)showHeight; - recalcShowRect(this->width(), this->height(), m_scrollSize, m_type, m_hScroll, m_vScroll, m_showThumb, m_thumbRect); - - m_hotItemIndex = getItemIndex(mapFromGlobal(QCursor::pos()), m_mouseMoveStatus); - } - - Show(); -} - -void HGImgThumb::keyPressEvent(QKeyEvent *e) -{ - if (MouseStatus_Null != m_mousePressStatus || 0 != m_operate || m_draging || m_frameSelection) - { - return; - } - - if (m_frontItems.empty()) - { - return; - } - - if (e->key() != Qt::Key_Left && e->key() != Qt::Key_Right - && e->key() != Qt::Key_Up && e->key() != Qt::Key_Down - && e->key() != Qt::Key_Home && e->key() != Qt::Key_End - && e->key() != Qt::Key_A) - { - return; - } - - bool emitCurItemChange = false; - bool emitItemSelectingChange = false; - - if (e->key() == Qt::Key_Left) - { - if (ThumbType_Vert != m_type) - { - if (QGuiApplication::keyboardModifiers() == Qt::ControlModifier) - { - // 按住Ctrl什么也不干 - } - else if (QGuiApplication::keyboardModifiers() == Qt::ShiftModifier) - { - if (-1 != m_signItemIndex) - { - if (-1 == m_curItemIndex) - { - m_curItemIndex = m_signItemIndex; - emitCurItemChange = true; - } - - if (m_curItemIndex > 0) - { - --m_curItemIndex; - emitCurItemChange = true; - } - - for (int i = 0; i < (int)m_frontItems.size(); ++i) - { - if (i >= HGMIN(m_curItemIndex, m_signItemIndex) && i <= HGMAX(m_curItemIndex, m_signItemIndex)) - { - if (!m_frontItems[i]->selected) - emitItemSelectingChange = true; - m_frontItems[i]->selected = true; - } - else - { - if (m_frontItems[i]->selected) - emitItemSelectingChange = true; - m_frontItems[i]->selected = false; - } - } - } - } - else - { - if (m_curItemIndex > 0) - { - --m_curItemIndex; - emitCurItemChange = true; - for (int i = 0; i < (int)m_frontItems.size(); ++i) - { - if (i == m_curItemIndex) - { - if (!m_frontItems[i]->selected) - emitItemSelectingChange = true; - m_frontItems[i]->selected = true; - } - else - { - if (m_frontItems[i]->selected) - emitItemSelectingChange = true; - m_frontItems[i]->selected = false; - } - } - } - } - } - } - else if (e->key() == Qt::Key_Right) - { - if (ThumbType_Vert != m_type) - { - if (QGuiApplication::keyboardModifiers() == Qt::ControlModifier) - { - // 按住Ctrl什么也不干 - } - else if (QGuiApplication::keyboardModifiers() == Qt::ShiftModifier) - { - if (-1 != m_signItemIndex) - { - if (-1 == m_curItemIndex) - { - m_curItemIndex = m_signItemIndex; - emitCurItemChange = true; - } - - if (m_curItemIndex < (int)m_frontItems.size() - 1) - { - ++m_curItemIndex; - emitCurItemChange = true; - } - - for (int i = 0; i < (int)m_frontItems.size(); ++i) - { - if (i >= HGMIN(m_curItemIndex, m_signItemIndex) && i <= HGMAX(m_curItemIndex, m_signItemIndex)) - { - if (!m_frontItems[i]->selected) - emitItemSelectingChange = true; - m_frontItems[i]->selected = true; - } - else - { - if (m_frontItems[i]->selected) - emitItemSelectingChange = true; - m_frontItems[i]->selected = false; - } - } - } - } - else - { - if (m_curItemIndex != -1 && m_curItemIndex < (int)m_frontItems.size() - 1) - { - ++m_curItemIndex; - emitCurItemChange = true; - for (int i = 0; i < (int)m_frontItems.size(); ++i) - { - if (i == m_curItemIndex) - { - if (!m_frontItems[i]->selected) - emitItemSelectingChange = true; - m_frontItems[i]->selected = true; - } - else - { - if (m_frontItems[i]->selected) - emitItemSelectingChange = true; - m_frontItems[i]->selected = false; - } - } - } - } - } - } - else if (e->key() == Qt::Key_Up) - { - if (ThumbType_Hori != m_type) - { - if (QGuiApplication::keyboardModifiers() == Qt::ControlModifier) - { - // 按住Ctrl什么也不干 - } - else if (QGuiApplication::keyboardModifiers() == Qt::ShiftModifier) - { - if (-1 != m_signItemIndex) - { - if (-1 == m_curItemIndex) - { - m_curItemIndex = m_signItemIndex; - emitCurItemChange = true; - } - - if (getItemRow(m_curItemIndex) > 0) - { - m_curItemIndex -= getTotalCols(); - emitCurItemChange = true; - } - - for (int i = 0; i < (int)m_frontItems.size(); ++i) - { - if (i >= HGMIN(m_curItemIndex, m_signItemIndex) && i <= HGMAX(m_curItemIndex, m_signItemIndex)) - { - if (!m_frontItems[i]->selected) - emitItemSelectingChange = true; - m_frontItems[i]->selected = true; - } - else - { - if (m_frontItems[i]->selected) - emitItemSelectingChange = true; - m_frontItems[i]->selected = false; - } - } - } - } - else - { - if (m_curItemIndex != -1 && getItemRow(m_curItemIndex) > 0) - { - m_curItemIndex -= getTotalCols(); - emitCurItemChange = true; - for (int i = 0; i < (int)m_frontItems.size(); ++i) - { - if (i == m_curItemIndex) - { - if (!m_frontItems[i]->selected) - emitItemSelectingChange = true; - m_frontItems[i]->selected = true; - } - else - { - if (m_frontItems[i]->selected) - emitItemSelectingChange = true; - m_frontItems[i]->selected = false; - } - } - } - } - } - } - else if (e->key() == Qt::Key_Down) - { - if (ThumbType_Hori != m_type) - { - if (QGuiApplication::keyboardModifiers() == Qt::ControlModifier) - { - // 按住Ctrl什么也不干 - } - else if (QGuiApplication::keyboardModifiers() == Qt::ShiftModifier) - { - if (-1 != m_signItemIndex) - { - if (-1 == m_curItemIndex) - { - m_curItemIndex = m_signItemIndex; - emitCurItemChange = true; - } - - if (getItemRow(m_curItemIndex) < getTotalRows() - 1) - { - m_curItemIndex = HGMIN(m_curItemIndex + getTotalCols(), (int)m_frontItems.size() - 1); - emitCurItemChange = true; - } - - for (int i = 0; i < (int)m_frontItems.size(); ++i) - { - if (i >= HGMIN(m_curItemIndex, m_signItemIndex) && i <= HGMAX(m_curItemIndex, m_signItemIndex)) - { - if (!m_frontItems[i]->selected) - emitItemSelectingChange = true; - m_frontItems[i]->selected = true; - } - else - { - if (m_frontItems[i]->selected) - emitItemSelectingChange = true; - m_frontItems[i]->selected = false; - } - } - } - } - else - { - if (m_curItemIndex != -1 && getItemRow(m_curItemIndex) < getTotalRows() - 1) - { - m_curItemIndex = HGMIN(m_curItemIndex + getTotalCols(), (int)m_frontItems.size() - 1); - emitCurItemChange = true; - for (int i = 0; i < (int)m_frontItems.size(); ++i) - { - if (i == m_curItemIndex) - { - if (!m_frontItems[i]->selected) - emitItemSelectingChange = true; - m_frontItems[i]->selected = true; - } - else - { - if (m_frontItems[i]->selected) - emitItemSelectingChange = true; - m_frontItems[i]->selected = false; - } - } - } - } - } - } - else if (e->key() == Qt::Key_Home) - { - if (QGuiApplication::keyboardModifiers() == Qt::ControlModifier) - { - // 按住Ctrl什么也不干 - } - else if (QGuiApplication::keyboardModifiers() == Qt::ShiftModifier) - { - if (-1 != m_signItemIndex) - { - if (0 != m_curItemIndex) - { - m_curItemIndex = 0; - emitCurItemChange = true; - } - - for (int i = 0; i < (int)m_frontItems.size(); ++i) - { - if (i >= HGMIN(m_curItemIndex, m_signItemIndex) && i <= HGMAX(m_curItemIndex, m_signItemIndex)) - { - if (!m_frontItems[i]->selected) - emitItemSelectingChange = true; - m_frontItems[i]->selected = true; - } - else - { - if (m_frontItems[i]->selected) - emitItemSelectingChange = true; - m_frontItems[i]->selected = false; - } - } - } - } - else - { - if (0 != m_curItemIndex) - { - m_curItemIndex = 0; - emitCurItemChange = true; - } - - for (int i = 0; i < (int)m_frontItems.size(); ++i) - { - if (i == m_curItemIndex) - { - if (!m_frontItems[i]->selected) - emitItemSelectingChange = true; - m_frontItems[i]->selected = true; - } - else - { - if (m_frontItems[i]->selected) - emitItemSelectingChange = true; - m_frontItems[i]->selected = false; - } - } - } - } - else if (e->key() == Qt::Key_End) - { - if (QGuiApplication::keyboardModifiers() == Qt::ControlModifier) - { - // 按住Ctrl什么也不干 - } - else if (QGuiApplication::keyboardModifiers() == Qt::ShiftModifier) - { - if (-1 != m_signItemIndex) - { - if ((int)m_frontItems.size() - 1 != m_curItemIndex) - { - m_curItemIndex = (int)m_frontItems.size() - 1; - emitCurItemChange = true; - } - - for (int i = 0; i < (int)m_frontItems.size(); ++i) - { - if (i >= HGMIN(m_curItemIndex, m_signItemIndex) && i <= HGMAX(m_curItemIndex, m_signItemIndex)) - { - if (!m_frontItems[i]->selected) - emitItemSelectingChange = true; - m_frontItems[i]->selected = true; - } - else - { - if (m_frontItems[i]->selected) - emitItemSelectingChange = true; - m_frontItems[i]->selected = false; - } - } - } - } - else - { - if ((int)m_frontItems.size() - 1 != m_curItemIndex) - { - m_curItemIndex = (int)m_frontItems.size() - 1; - emitCurItemChange = true; - } - - for (int i = 0; i < (int)m_frontItems.size(); ++i) - { - if (i == m_curItemIndex) - { - if (!m_frontItems[i]->selected) - emitItemSelectingChange = true; - m_frontItems[i]->selected = true; - } - else - { - if (m_frontItems[i]->selected) - emitItemSelectingChange = true; - m_frontItems[i]->selected = false; - } - } - } - } - else if (e->key() == Qt::Key_A) - { - if (QGuiApplication::keyboardModifiers() == Qt::ControlModifier) - { - for (int i = 0; i < (int)m_frontItems.size(); ++i) - { - if (!m_frontItems[i]->selected) - emitItemSelectingChange = true; - m_frontItems[i]->selected = true; - } - } - } - - if (-1 != m_curItemIndex) - { - locateItem(m_curItemIndex); - recalcShowRect(this->width(), this->height(), m_scrollSize, m_type, m_hScroll, m_vScroll, m_showThumb, m_thumbRect); - m_hotItemIndex = getItemIndex(mapFromGlobal(QCursor::pos()), m_mouseMoveStatus); - } - - Show(); - if (emitCurItemChange) - emit currItemChanged(m_curItemIndex); - if (emitItemSelectingChange) - emit itemSelectingChanged(); -} - -void HGImgThumb::keyReleaseEvent(QKeyEvent *e) -{ - Q_UNUSED(e); -} - -void HGImgThumb::focusInEvent(QFocusEvent *e) -{ - Q_UNUSED(e); -} - -void HGImgThumb::focusOutEvent(QFocusEvent *e) -{ - Q_UNUSED(e); -} - -void HGImgThumb::contextMenuEvent(QContextMenuEvent* e) -{ - if (MouseStatus_Null != m_mousePressStatus || 0 != m_operate || m_draging || m_frameSelection) - { - return; - } - - m_pushItemIndex = -1; - - MouseStatus mouseMoveStatus = MouseStatus_Null; - int index = getItemIndex(e->pos(), mouseMoveStatus); - if (MouseStatus_Null == mouseMoveStatus) - emit contextMenuEvent(index); -} - -void HGImgThumb::dragEnterEvent(QDragEnterEvent *e) -{ - qDebug("dragEnterEvent"); - - if (e->mimeData()->hasUrls()) - { - m_draging = true; - e->accept(); - } -} - -void HGImgThumb::dragMoveEvent(QDragMoveEvent *e) -{ - //qDebug("dragMoveEvent"); - - int insertPos = getInsertPos(e->pos(), m_insertPtValid, m_insertPt1, m_insertPt2); - if (m_insertPtValid && m_curInsertPos != insertPos) - { - locateInsert(m_insertPt1, m_insertPt2); - recalcShowRect(this->width(), this->height(), m_scrollSize, m_type, m_hScroll, m_vScroll, m_showThumb, m_thumbRect); - } - - if (m_curInsertPos != insertPos) - qDebug("current insert pos=%d", insertPos); - m_curInsertPos = insertPos; - Show(); -} - -void HGImgThumb::dragLeaveEvent(QDragLeaveEvent *e) -{ - qDebug("dragLeaveEvent"); - Q_UNUSED(e); - - m_curInsertPos = -1; - m_insertPtValid = false; - m_draging = false; - Show(); -} - -void HGImgThumb::dropEvent(QDropEvent *e) -{ - QStringList fileNames; - QList urls = e->mimeData()->urls(); - for (QUrl url : urls) - { - fileNames.append(url.toLocalFile()); - } - - int pos = m_curInsertPos; - - m_curInsertPos = -1; - m_insertPtValid = false; - m_draging = false; - - m_hotItemIndex = getItemIndex(mapFromGlobal(QCursor::pos()), m_mouseMoveStatus); - Show(); - - emit drop(e->source(), fileNames, pos); -} - -void HGImgThumb::mouseDoubleClickEvent(QMouseEvent *e) -{ - if (MouseStatus_Null != m_mousePressStatus || 0 != m_operate || m_draging || m_frameSelection) - { - return; - } - - MouseStatus mouseMoveStatus = MouseStatus_Null; - int index = getItemIndex(e->pos(), mouseMoveStatus); - if (MouseStatus_Null == mouseMoveStatus && -1 != index) - { - if (m_curItemIndex == index && m_frontItems[index]->selected) - emit itemDoubleClicked(index); - } - else - { - QWidget::mouseDoubleClickEvent(e); - } -} - -void HGImgThumb::on_updateItem() -{ - Show(); -} - -QImage* HGImgThumb::createItemImage(const QImage *srcImage, int itemSize) -{ - assert(nullptr != srcImage); - - QImage *img = nullptr; - if (srcImage->width() > itemSize || srcImage->height() > itemSize) - { - int width, height; - if (srcImage->width() < srcImage->height()) - { - height = itemSize; - width = height * srcImage->width() / srcImage->height(); - } - else - { - width = itemSize; - height = width * srcImage->height() / srcImage->width(); - } - - assert(width != srcImage->width() || height != srcImage->height()); - img = new QImage(srcImage->scaled(width, height, Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); - } - else - { - img = new QImage(srcImage->copy(0, 0, srcImage->width(), srcImage->height())); - } - - if (img->isNull()) - { - delete img; - return nullptr; - } - - return img; -} - -QImage* HGImgThumb::createItemImage(HGImage srcImage, int itemSize) -{ - assert(nullptr != srcImage); - - HGImageInfo info; - HGBase_GetImageInfo(srcImage, &info); - - QImage::Format fmt = QImage::Format_Invalid; - if (info.type == HGBASE_IMGTYPE_BINARY) - fmt = QImage::Format_Mono; - else if (info.type == HGBASE_IMGTYPE_GRAY) - fmt = QImage::Format_Grayscale8; - else if (info.type == HGBASE_IMGTYPE_RGB) - fmt = QImage::Format_RGB888; - else if (info.type == HGBASE_IMGTYPE_RGBA) - fmt = QImage::Format_RGBA8888; - if (QImage::Format_Invalid == fmt) - { - return nullptr; - } - - HGByte *data = nullptr; - HGBase_GetImageData(srcImage, &data); - QImage img(data, info.width, info.height, info.widthStep, fmt); - if (img.isNull()) - { - return nullptr; - } - - if (img.format() == QImage::Format_Mono) - img = img.convertToFormat(QImage::Format_Grayscale8); - - return createItemImage(&img, itemSize); -} - -void HGImgThumb::DrawImage(QPainter &painter, const QRect &destRect, const QImage *image, const QRect &stretchRect) -{ - if (destRect.width() < image->width() - stretchRect.width() - || destRect.height() < image->height() - stretchRect.height()) - { - painter.drawImage(destRect, *image); - return; - } - - for (int i = 0; i < 9; ++i) - { - int DestX = destRect.left(), DestY = destRect.top(), DestWidth = destRect.width(), DestHeight = destRect.height(); - int SrcX = 0, SrcY = 0, SrcWidth = image->width(), SrcHeight = image->height(); - - if (0 == i % 3) - { - DestX = destRect.left(); - DestWidth = stretchRect.left(); - SrcX = 0; - SrcWidth = stretchRect.left(); - } - else if (1 == i % 3) - { - DestX = destRect.left() + stretchRect.left(); - DestWidth = destRect.width() + stretchRect.width() - image->width(); - SrcX = stretchRect.left(); - SrcWidth = stretchRect.width(); - } - else if (2 == i % 3) - { - DestX = destRect.left() + destRect.width() + stretchRect.left() + stretchRect.width() - image->width(); - DestWidth = image->width() - (stretchRect.left() + stretchRect.width()); - SrcX = stretchRect.left() + stretchRect.width(); - SrcWidth = image->width() - (stretchRect.left() + stretchRect.width()); - } - - if (0 == i / 3) - { - DestY = destRect.top(); - DestHeight = stretchRect.top(); - SrcY = 0; - SrcHeight = stretchRect.top(); - } - else if (1 == i / 3) - { - DestY = destRect.top() + stretchRect.top(); - DestHeight = destRect.height() + stretchRect.height() - image->height(); - SrcY = stretchRect.top(); - SrcHeight = stretchRect.height(); - } - else if (2 == i / 3) - { - DestY = destRect.top() + destRect.height() + stretchRect.top() + stretchRect.height() - image->height(); - DestHeight = image->height() - (stretchRect.top() + stretchRect.height()); - SrcY = stretchRect.top() + stretchRect.height(); - SrcHeight = image->height() - (stretchRect.top() + stretchRect.height()); - } - - QRect dest(DestX, DestY, DestWidth, DestHeight); - QRect src(SrcX, SrcY, SrcWidth, SrcHeight); - painter.drawImage(dest, *image, src); - } -} - -void HGImgThumb::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) -{ - showWidth = 0; - showHeight = 0; - hScroll = false; - vScroll = false; - - if (itemCount <= 0) - { - return; - } - - if (ThumbType_Hori == type) - { - showWidth = gapSize + itemCount * (itemSize + gapSize); - showHeight = gapSize * 2 + itemSize + itemTextHeight; - if (showHeight > wndHeight) - { - vScroll = true; - if (showWidth > wndWidth - scrollSize) - hScroll = true; - } - else - { - if (showWidth > wndWidth) - { - hScroll = true; - if (showHeight > wndHeight - scrollSize) - vScroll = true; - } - } - } - else if (ThumbType_Vert == type) - { - showWidth = gapSize * 2 + itemSize; - showHeight = gapSize + itemCount * (itemSize + itemTextHeight + gapSize); - if (showHeight > wndHeight) - { - vScroll = true; - if (showWidth > wndWidth - scrollSize) - hScroll = true; - } - else - { - if (showWidth > wndWidth) - { - hScroll = true; - if (showHeight > wndHeight - scrollSize) - vScroll = true; - } - } - } - else - { - int cols = HGMIN(itemCount, HGMAX(1, (wndWidth - gapSize) / (itemSize + gapSize))); - showWidth = gapSize + cols * (itemSize + gapSize); - int rows = (itemCount - 1) / cols + 1; - showHeight = gapSize + rows * (itemSize + itemTextHeight + gapSize); - if (showHeight > wndHeight) - { - cols = HGMIN(itemCount, HGMAX(1, (wndWidth - scrollSize - gapSize) / (itemSize + gapSize))); - showWidth = gapSize + cols * (itemSize + gapSize); - rows = (itemCount - 1) / cols + 1; - showHeight = gapSize + rows * (itemSize + itemTextHeight + gapSize); - assert(showHeight > wndHeight); - - vScroll = true; - if (showWidth > wndWidth - scrollSize) - hScroll = true; - } - else - { - if (showWidth > wndWidth) - { - hScroll = true; - if (showHeight > wndHeight - scrollSize) - vScroll = true; - } - } - } -} - -void HGImgThumb::recalcShowRect(int wndWidth, int wndHeight, int scrollSize, ThumbType type, bool hScroll, bool vScroll, bool showThumb, ThumbRect &thumbRect) -{ - if (!showThumb) - return; - - double width = thumbRect.right - thumbRect.left; - double height = thumbRect.bottom - thumbRect.top; - - // 调整 - if (ThumbType_Hori == type) - { - if (!vScroll) // 没有垂直滚动条 - { - if (hScroll) // 有水平滚动条 - thumbRect.top = (double)(wndHeight - scrollSize - height) / 2.0; - else // 没有水平滚动条 - thumbRect.top = (double)(wndHeight - height) / 2.0; - thumbRect.bottom = thumbRect.top + height; - } - else // 有垂直滚动条 - { - int hScrollSize = hScroll ? scrollSize : 0; - if (thumbRect.bottom < (double)(wndHeight - hScrollSize)) - { - thumbRect.bottom = wndHeight - hScrollSize; - thumbRect.top = thumbRect.bottom - height; - } - if (thumbRect.top > 0) - { - thumbRect.top = 0; - thumbRect.bottom = thumbRect.top + height; - } - } - - int vScrollSize = vScroll ? scrollSize : 0; - if (thumbRect.right < (double)(wndWidth - vScrollSize)) - { - thumbRect.right = wndWidth - vScrollSize; - thumbRect.left = thumbRect.right - width; - } - if (thumbRect.left > 0) - { - thumbRect.left = 0; - thumbRect.right = thumbRect.left + width; - } - } - else if (ThumbType_Vert == type) - { - if (!hScroll) // 没有水平滚动条 - { - if (vScroll) // 有垂直滚动条 - thumbRect.left = (double)(wndWidth - scrollSize - width) / 2.0; - else // 没有垂直滚动条 - thumbRect.left = (double)(wndWidth - width) / 2.0; - thumbRect.right = thumbRect.left + width; - } - else // 有水平滚动条 - { - int vScrollSize = vScroll ? scrollSize : 0; - if (thumbRect.right < (double)(wndWidth - vScrollSize)) - { - thumbRect.right = wndWidth - vScrollSize; - thumbRect.left = thumbRect.right - width; - } - if (thumbRect.left > 0) - { - thumbRect.left = 0; - thumbRect.right = thumbRect.left + width; - } - } - - int hScrollSize = hScroll ? scrollSize : 0; - if (thumbRect.bottom < (double)(wndHeight - hScrollSize)) - { - thumbRect.bottom = wndHeight - hScrollSize; - thumbRect.top = thumbRect.bottom - height; - } - if (thumbRect.top > 0) - { - thumbRect.top = 0; - thumbRect.bottom = thumbRect.top + height; - } - } - else - { - int vScrollSize = vScroll ? scrollSize : 0; - if (thumbRect.right < (double)(wndWidth - vScrollSize)) - { - thumbRect.right = wndWidth - vScrollSize; - thumbRect.left = thumbRect.right - width; - } - if (thumbRect.left > 0) - { - thumbRect.left = 0; - thumbRect.right = thumbRect.left + width; - } - - int hScrollSize = hScroll ? scrollSize : 0; - if (thumbRect.bottom < (double)(wndHeight - hScrollSize)) - { - thumbRect.bottom = wndHeight - hScrollSize; - thumbRect.top = thumbRect.bottom - height; - } - if (thumbRect.top > 0) - { - thumbRect.top = 0; - thumbRect.bottom = thumbRect.top + height; - } - } -} - -void HGImgThumb::DrawScroll(QPainter &painter) -{ - // 滚动条背景 - QColor clrHScroll = qRgb(220, 220, 220); - QImage *imgHScroll = m_hScrollImage; - QColor clrVScroll = qRgb(220, 220, 220); - QImage *imgVScroll = m_vScrollImage; - QColor clrNullScroll = qRgb(255, 255, 255); - QImage *nullScrollImage = m_nullScrollImage; - - // 水平滑块 - QColor clrHScrollSlider = qRgb(180, 180, 180); - QImage *imgHScrollSlider = m_hScrollSliderImage[0]; - QRect hScrollSliderStretch = m_hScrollSliderImageStretch[0]; - if (MouseStatus_HScrollSlider == m_mousePressStatus) - { - clrHScrollSlider = qRgb(100, 100, 100); - imgHScrollSlider = m_hScrollSliderImage[2]; - hScrollSliderStretch = m_hScrollSliderImageStretch[2]; - } - else if (MouseStatus_HScrollLeft == m_mousePressStatus || MouseStatus_HScrollRight == m_mousePressStatus - || MouseStatus_HScroll == m_mousePressStatus - || MouseStatus_HScrollSlider == m_mouseMoveStatus || MouseStatus_HScroll == m_mouseMoveStatus - || MouseStatus_HScrollLeft == m_mouseMoveStatus || MouseStatus_HScrollRight == m_mouseMoveStatus) - { - clrHScrollSlider = qRgb(140, 140, 140); - imgHScrollSlider = m_hScrollSliderImage[1]; - hScrollSliderStretch = m_hScrollSliderImageStretch[1]; - } - - // 垂直滑块 - QColor clrVScrollSlider = qRgb(180, 180, 180); - QImage *imgVScrollSlider = m_vScrollSliderImage[0]; - QRect vScrollSliderStretch = m_vScrollSliderImageStretch[0]; - if (MouseStatus_VScrollSlider == m_mousePressStatus) - { - clrVScrollSlider = qRgb(100, 100, 100); - imgVScrollSlider = m_vScrollSliderImage[2]; - vScrollSliderStretch = m_vScrollSliderImageStretch[2]; - } - else if (MouseStatus_VScrollTop == m_mousePressStatus || MouseStatus_VScrollBottom == m_mousePressStatus - || MouseStatus_VScroll == m_mousePressStatus - || MouseStatus_VScrollSlider == m_mouseMoveStatus || MouseStatus_VScroll == m_mouseMoveStatus - || MouseStatus_VScrollTop == m_mouseMoveStatus || MouseStatus_VScrollBottom == m_mouseMoveStatus) - { - clrVScrollSlider = qRgb(140, 140, 140); - imgVScrollSlider = m_vScrollSliderImage[1]; - vScrollSliderStretch = m_vScrollSliderImageStretch[1]; - } - - // 水平左键 - QColor clrHScrollLeft = qRgb(220, 220, 220); - QImage *imgHScrollLeft = m_hScrollLeftImage[0]; - if (MouseStatus_HScrollLeft == m_mousePressStatus) - { - clrHScrollLeft = qRgb(140, 140, 140); - imgHScrollLeft = m_hScrollLeftImage[2]; - } - else if (MouseStatus_HScrollRight == m_mousePressStatus || MouseStatus_HScrollSlider == m_mousePressStatus - || MouseStatus_HScroll == m_mousePressStatus - || MouseStatus_HScrollSlider == m_mouseMoveStatus || MouseStatus_HScroll == m_mouseMoveStatus - || MouseStatus_HScrollLeft == m_mouseMoveStatus || MouseStatus_HScrollRight == m_mouseMoveStatus) - { - clrHScrollLeft = qRgb(180, 180, 180); - imgHScrollLeft = m_hScrollLeftImage[1]; - } - - // 水平右键 - QColor clrHScrollRight = qRgb(220, 220, 220); - QImage *imgHScrollRight = m_hScrollRightImage[0]; - if (MouseStatus_HScrollRight == m_mousePressStatus) - { - clrHScrollRight = qRgb(140, 140, 140); - imgHScrollRight = m_hScrollRightImage[2]; - } - else if (MouseStatus_HScrollLeft == m_mousePressStatus || MouseStatus_HScrollSlider == m_mousePressStatus - || MouseStatus_HScroll == m_mousePressStatus - || MouseStatus_HScrollSlider == m_mouseMoveStatus || MouseStatus_HScroll == m_mouseMoveStatus - || MouseStatus_HScrollLeft == m_mouseMoveStatus || MouseStatus_HScrollRight == m_mouseMoveStatus) - { - clrHScrollRight = qRgb(180, 180, 180); - imgHScrollRight = m_hScrollRightImage[1]; - } - - // 垂直上键 - QColor clrVScrollTop = qRgb(220, 220, 220); - QImage *imgVScrollTop = m_vScrollTopImage[0]; - if (MouseStatus_VScrollTop == m_mousePressStatus) - { - clrVScrollTop = qRgb(140, 140, 140); - imgVScrollTop = m_vScrollTopImage[2]; - } - else if (MouseStatus_VScrollSlider == m_mousePressStatus || MouseStatus_VScrollBottom == m_mousePressStatus - || MouseStatus_VScroll == m_mousePressStatus - || MouseStatus_VScrollSlider == m_mouseMoveStatus || MouseStatus_VScroll == m_mouseMoveStatus - || MouseStatus_VScrollTop == m_mouseMoveStatus || MouseStatus_VScrollBottom == m_mouseMoveStatus) - { - clrVScrollTop = qRgb(180, 180, 180); - imgVScrollTop = m_vScrollTopImage[1]; - } - - // 垂直下键 - QColor clrVScrollBottom = qRgb(220, 220, 220); - QImage *imgVScrollBottom = m_vScrollBottomImage[0]; - if (MouseStatus_VScrollBottom == m_mousePressStatus) - { - clrVScrollBottom = qRgb(140, 140, 140); - imgVScrollBottom = m_vScrollBottomImage[2]; - } - else if (MouseStatus_VScrollSlider == m_mousePressStatus || MouseStatus_VScrollTop == m_mousePressStatus - || MouseStatus_VScroll == m_mousePressStatus - || MouseStatus_VScrollSlider == m_mouseMoveStatus || MouseStatus_VScroll == m_mouseMoveStatus - || MouseStatus_VScrollTop == m_mouseMoveStatus || MouseStatus_VScrollBottom == m_mouseMoveStatus) - { - clrVScrollBottom = qRgb(180, 180, 180); - imgVScrollBottom = m_vScrollBottomImage[1]; - } - - if (m_hScroll) - { - if (nullptr == imgHScroll) - painter.fillRect(getHScrollPos(), clrHScroll); - else - DrawImage(painter, getHScrollPos(), imgHScroll, m_hScrollImageStretch); - - if (nullptr == imgHScrollLeft) - painter.fillRect(getHScrollLeftPos(), clrHScrollLeft); - else - painter.drawImage(getHScrollLeftPos(), *imgHScrollLeft); - - if (nullptr == imgHScrollRight) - painter.fillRect(getHScrollRightPos(), clrHScrollRight); - else - painter.drawImage(getHScrollRightPos(), *imgHScrollRight); - - if (nullptr == imgHScrollSlider) - painter.fillRect(getHScrollSliderPos(), clrHScrollSlider); - else - DrawImage(painter, getHScrollSliderPos(), imgHScrollSlider, hScrollSliderStretch); - } - - if (m_vScroll) - { - if (nullptr == imgVScroll) - painter.fillRect(getVScrollPos(), clrVScroll); - else - DrawImage(painter, getVScrollPos(), imgVScroll, m_vScrollImageStretch); - - if (nullptr == imgVScrollTop) - painter.fillRect(getVScrollTopPos(), clrVScrollTop); - else - painter.drawImage(getVScrollTopPos(), *imgVScrollTop); - - if (nullptr == imgVScrollBottom) - painter.fillRect(getVScrollBottomPos(), clrVScrollBottom); - else - painter.drawImage(getVScrollBottomPos(), *imgVScrollBottom); - - if (nullptr == imgVScrollSlider) - painter.fillRect(getVScrollSliderPos(), clrVScrollSlider); - else - DrawImage(painter, getVScrollSliderPos(), imgVScrollSlider, vScrollSliderStretch); - } - - if (m_hScroll && m_vScroll) - { - if (nullptr == nullScrollImage) - painter.fillRect(getNullScrollPos(), clrNullScroll); - else - painter.drawImage(getNullScrollPos(), *nullScrollImage); - } -} - -void HGImgThumb::reset() -{ - m_frameSelectionRectValid = false; - m_frameSelection = false; - - m_curInsertPos = -1; - m_insertPtValid = false; - m_draging = false; - - m_pushItemIndex = -1; - - m_operateStartX = -1; - m_operateStartY = -1; - m_operate = 0; - - m_hitMouseButtons = Qt::NoButton; - m_hitKeyboardModifiers = Qt::NoModifier; - m_hitItemIndex = -1; - - m_mousePressStatus = MouseStatus_Null; - m_mousePressBeginX = -1; - m_mousePressBeginY = -1; -} - -QPoint HGImgThumb::getItemPos(int index) -{ - assert(index >= 0 && index < (int)m_frontItems.size()); - assert(m_showThumb); - - int x, y; - if (ThumbType_Hori == m_type) - { - x = m_gapSize + index * (m_itemSize + m_gapSize); - y = m_gapSize; - } - else if (ThumbType_Vert == m_type) - { - x = m_gapSize; - y = m_gapSize + index * (m_itemSize + m_itemTextHeight + m_gapSize); - } - else - { - int cols = round((m_thumbRect.right - m_thumbRect.left - m_gapSize) / (m_itemSize + m_gapSize)); - x = m_gapSize + (index % cols) * (m_itemSize + m_gapSize); - y = m_gapSize + (index / cols) * (m_itemSize + m_itemTextHeight + m_gapSize); - } - - QPoint pt(x, y); - return pt; -} - -void HGImgThumb::locateItem(int index) -{ - assert(index >= 0 && index < (int)m_frontItems.size()); - assert(m_showThumb); - - int left = getItemPos(index).x() + round(m_thumbRect.left); - int top = getItemPos(index).y() + round(m_thumbRect.top); - int right = left + m_itemSize; - int bottom = top + m_itemSize + m_itemTextHeight; - - int scrollWidth; - int gap; - - scrollWidth = m_vScroll ? m_scrollSize : 0; - gap = m_gapSize; - if (left < gap && right + (gap - left) <= (this->width() - scrollWidth - m_gapSize)) - { - m_thumbRect.left += (gap - left); - m_thumbRect.right += (gap - left); - } - else if (right > (this->width() - scrollWidth - gap) - && left - (right - this->width() + scrollWidth + gap) >= m_gapSize) - { - m_thumbRect.left -= (right - this->width() + scrollWidth + gap); - m_thumbRect.right -= (right - this->width() + scrollWidth + gap); - } - - scrollWidth = m_hScroll ? m_scrollSize : 0; - gap = m_gapSize; - if (top < gap && bottom + (gap - top) <= (this->height() - scrollWidth - m_gapSize)) - { - m_thumbRect.top += (gap - top); - m_thumbRect.bottom += (gap - top); - } - else if (bottom > (this->height() - scrollWidth - gap) - && top - (bottom - this->height() + scrollWidth + gap) >= m_gapSize) - { - m_thumbRect.top -= (bottom - this->height() + scrollWidth + gap); - m_thumbRect.bottom -= (bottom - this->height() + scrollWidth + gap); - } -} - -void HGImgThumb::locateInsert(const QPoint &pt1, const QPoint &pt2) -{ - int left = HGMIN(pt1.x(), pt2.x()) + round(m_thumbRect.left); - int top = HGMIN(pt1.y(), pt2.y()) + round(m_thumbRect.top); - int right = HGMAX(pt1.x(), pt2.x()) + round(m_thumbRect.left); - int bottom = HGMAX(pt1.y(), pt2.y()) + round(m_thumbRect.top); - - int scrollWidth; - int gap; - - scrollWidth = m_vScroll ? m_scrollSize : 0; - gap = m_gapSize; - if (left < gap && right + (gap - left) <= (this->width() - scrollWidth - m_gapSize)) - { - int value = gap - left; - m_thumbRect.left += value; - m_thumbRect.right += value; - } - else if (right > (this->width() - scrollWidth - gap) - && left - (right - this->width() + scrollWidth + gap) >= m_gapSize) - { - int value = right - this->width() + scrollWidth + gap; - m_thumbRect.left -= value; - m_thumbRect.right -= value; - } - - scrollWidth = m_hScroll ? m_scrollSize : 0; - gap = m_gapSize; - if (top < gap && bottom + (gap - top) <= (this->height() - scrollWidth - m_gapSize)) - { - int value = gap - top; - m_thumbRect.top += value; - m_thumbRect.bottom += value; - } - else if (bottom > (this->height() - scrollWidth - gap) - && top - (bottom - this->height() + scrollWidth + gap) >= m_gapSize) - { - int value = bottom - this->height() + scrollWidth + gap; - m_thumbRect.top -= value; - m_thumbRect.bottom -= value; - } -} - -int HGImgThumb::getItemRow(int index) -{ - assert(index >= 0 && index < (int)m_frontItems.size()); - assert(m_showThumb); - - int row; - if (ThumbType_Hori == m_type) - { - row = 0; - } - else if (ThumbType_Vert == m_type) - { - row = index; - } - else - { - int cols = round((m_thumbRect.right - m_thumbRect.left - m_gapSize) / (m_itemSize + m_gapSize)); - row = index / cols; - } - - return row; -} - -int HGImgThumb::getItemCol(int index) -{ - assert(index >= 0 && index < (int)m_frontItems.size()); - assert(m_showThumb); - - int col; - if (ThumbType_Hori == m_type) - { - col = index; - } - else if (ThumbType_Vert == m_type) - { - col = 0; - } - else - { - int cols = round((m_thumbRect.right - m_thumbRect.left - m_gapSize) / (m_itemSize + m_gapSize)); - col = index % cols; - } - - return col; -} - -int HGImgThumb::getTotalRows() -{ - if (!m_showThumb) - { - assert(0 == m_frontItems.size()); - return 0; - } - - int rows; - if (ThumbType_Hori == m_type) - { - rows = 1; - } - else if (ThumbType_Vert == m_type) - { - rows = (int)m_frontItems.size(); - } - else - { - rows = round((m_thumbRect.bottom - m_thumbRect.top - m_gapSize) / (m_itemSize + m_itemTextHeight + m_gapSize)); - } - - return rows; -} - -int HGImgThumb::getTotalCols() -{ - if (!m_showThumb) - { - assert(0 == m_frontItems.size()); - return 0; - } - - int cols; - if (ThumbType_Hori == m_type) - { - cols = (int)m_frontItems.size(); - } - else if (ThumbType_Vert == m_type) - { - cols = 1; - } - else - { - cols = round((m_thumbRect.right - m_thumbRect.left - m_gapSize) / (m_itemSize + m_gapSize)); - } - - return cols; -} - -int HGImgThumb::getRowCount(int row) -{ - assert(row >= 0 && row < getTotalRows()); - - int count; - if (ThumbType_Hori == m_type) - { - count = (int)m_frontItems.size(); - } - else if (ThumbType_Vert == m_type) - { - count = 1; - } - else - { - int cols = round((m_thumbRect.right - m_thumbRect.left - m_gapSize) / (m_itemSize + m_gapSize)); - if ((row + 1) * cols <= (int)m_frontItems.size()) - { - count = cols; - } - else - { - count = (int)m_frontItems.size() - row * cols; - } - } - - return count; -} - -int HGImgThumb::getItemIndex(const QPoint &pt, MouseStatus &mouseStatus) -{ - mouseStatus = MouseStatus_Null; - if (!m_showThumb) - { - assert(0 == m_frontItems.size()); - return -1; - } - - if (MouseStatus_Null != m_mousePressStatus || 0 != m_operate || m_draging || m_frameSelection) - { - return -1; - } - - if (!m_mouseOn) - { - return -1; - } - - if (m_hScroll && m_vScroll) - { - if (getHScrollSliderPos().contains(pt)) - mouseStatus = MouseStatus_HScrollSlider; - else if (getHScrollLeftPos().contains(pt)) - mouseStatus = MouseStatus_HScrollLeft; - else if (getHScrollRightPos().contains(pt)) - mouseStatus = MouseStatus_HScrollRight; - else if (getHScrollPos().contains(pt)) - mouseStatus = MouseStatus_HScroll; - else if (getVScrollSliderPos().contains(pt)) - mouseStatus = MouseStatus_VScrollSlider; - else if (getVScrollTopPos().contains(pt)) - mouseStatus = MouseStatus_VScrollTop; - else if (getVScrollBottomPos().contains(pt)) - mouseStatus = MouseStatus_VScrollBottom; - else if (getVScrollPos().contains(pt)) - mouseStatus = MouseStatus_VScroll; - else if (getNullScrollPos().contains(pt)) - mouseStatus = MouseStatus_NullScroll; - } - else if (m_hScroll && !m_vScroll) - { - if (getHScrollSliderPos().contains(pt)) - mouseStatus = MouseStatus_HScrollSlider; - else if (getHScrollLeftPos().contains(pt)) - mouseStatus = MouseStatus_HScrollLeft; - else if (getHScrollRightPos().contains(pt)) - mouseStatus = MouseStatus_HScrollRight; - else if (getHScrollPos().contains(pt)) - mouseStatus = MouseStatus_HScroll; - } - else if (!m_hScroll && m_vScroll) - { - if (getVScrollSliderPos().contains(pt)) - mouseStatus = MouseStatus_VScrollSlider; - else if (getVScrollTopPos().contains(pt)) - mouseStatus = MouseStatus_VScrollTop; - else if (getVScrollBottomPos().contains(pt)) - mouseStatus = MouseStatus_VScrollBottom; - else if (getVScrollPos().contains(pt)) - mouseStatus = MouseStatus_VScroll; - } - - if (MouseStatus_Null != mouseStatus) - { - return -1; - } - - int index = -1; - for (int i = 0; i < (int)m_frontItems.size(); ++i) - { - int left = getItemPos(i).x() + round(m_thumbRect.left); - int top = getItemPos(i).y() + round(m_thumbRect.top); - int right = left + m_itemSize; - int bottom = top + m_itemSize + m_itemTextHeight; - if (pt.x() >= left && pt.y() >= top && pt.x() < right && pt.y() < bottom) - { - index = i; - break; - } - } - - return index; -} - -int HGImgThumb::getInsertPos(const QPoint &pt, bool &get, QPoint &pt1, QPoint &pt2) -{ - get = false; - if (!m_draging) - { - return -1; - } - - MouseStatus mouseStatus = MouseStatus_Null; - if (m_hScroll && m_vScroll) - { - if (getHScrollSliderPos().contains(pt)) - mouseStatus = MouseStatus_HScrollSlider; - else if (getHScrollLeftPos().contains(pt)) - mouseStatus = MouseStatus_HScrollLeft; - else if (getHScrollRightPos().contains(pt)) - mouseStatus = MouseStatus_HScrollRight; - else if (getHScrollPos().contains(pt)) - mouseStatus = MouseStatus_HScroll; - else if (getVScrollSliderPos().contains(pt)) - mouseStatus = MouseStatus_VScrollSlider; - else if (getVScrollTopPos().contains(pt)) - mouseStatus = MouseStatus_VScrollTop; - else if (getVScrollBottomPos().contains(pt)) - mouseStatus = MouseStatus_VScrollBottom; - else if (getVScrollPos().contains(pt)) - mouseStatus = MouseStatus_VScroll; - else if (getNullScrollPos().contains(pt)) - mouseStatus = MouseStatus_NullScroll; - } - else if (m_hScroll && !m_vScroll) - { - if (getHScrollSliderPos().contains(pt)) - mouseStatus = MouseStatus_HScrollSlider; - else if (getHScrollLeftPos().contains(pt)) - mouseStatus = MouseStatus_HScrollLeft; - else if (getHScrollRightPos().contains(pt)) - mouseStatus = MouseStatus_HScrollRight; - else if (getHScrollPos().contains(pt)) - mouseStatus = MouseStatus_HScroll; - } - else if (!m_hScroll && m_vScroll) - { - if (getVScrollSliderPos().contains(pt)) - mouseStatus = MouseStatus_VScrollSlider; - else if (getVScrollTopPos().contains(pt)) - mouseStatus = MouseStatus_VScrollTop; - else if (getVScrollBottomPos().contains(pt)) - mouseStatus = MouseStatus_VScrollBottom; - else if (getVScrollPos().contains(pt)) - mouseStatus = MouseStatus_VScroll; - } - - if (MouseStatus_Null != mouseStatus) - { - return -1; - } - - if (!m_showThumb) - { - assert(0 == m_frontItems.size()); - return 0; - } - - int pos = -1; - int x1, x2, y1, y2; - - if (ThumbType_Hori == m_type) - { - pos = (int)m_frontItems.size(); - - QPoint pt2 = getItemPos(pos - 1); - x1 = x2 = pt2.x() + m_itemSize + m_gapSize / 2; - y1 = pt2.y(); - y2 = y1 + m_itemSize + m_itemTextHeight; - - for (int i = 0; i < (int)m_frontItems.size(); ++i) - { - QPoint pt2 = getItemPos(i); - - int left = pt2.x(); - int right = left + m_itemSize; - if (pt.x() - round(m_thumbRect.left) < (left + right) / 2) - { - pos = i; - - x1 = x2 = pt2.x() - m_gapSize / 2; - y1 = pt2.y(); - y2 = y1 + m_itemSize + m_itemTextHeight; - break; - } - } - } - else if (ThumbType_Vert == m_type) - { - pos = (int)m_frontItems.size(); - - QPoint pt2 = getItemPos(pos - 1); - y1 = y2 = pt2.y() + m_itemSize + m_itemTextHeight + m_gapSize / 2; - x1 = pt2.x(); - x2 = x1 + m_itemSize; - - for (int i = 0; i < (int)m_frontItems.size(); ++i) - { - QPoint pt2 = getItemPos(i); - - int top = pt2.y(); - int bottom = top + m_itemSize + m_itemTextHeight; - if (pt.y() - round(m_thumbRect.top) < (top + bottom) / 2) - { - pos = i; - - y1 = y2 = pt2.y() - m_gapSize / 2; - x1 = pt2.x(); - x2 = x1 + m_itemSize; - break; - } - } - } - else - { - int rows = getTotalRows(); - int cols = getTotalCols(); - - int row = rows; - for (int i = 0; i < rows; ++i) - { - QPoint pt2 = getItemPos(cols * i); - - int top = pt2.y(); - int bottom = top + m_itemSize + m_itemTextHeight; - if (pt.y() - round(m_thumbRect.top) < bottom + m_gapSize / 2) - { - row = i; - break; - } - } - - if (row == rows) - { - pos = (int)m_frontItems.size(); - - QPoint pt2 = getItemPos(pos - 1); - x1 = x2 = pt2.x() + m_itemSize + m_gapSize / 2; - y1 = pt2.y(); - y2 = y1 + m_itemSize + m_itemTextHeight; - } - else - { - pos = row * cols + getRowCount(row); - - QPoint pt2 = getItemPos(row * cols + getRowCount(row) - 1); - x1 = x2 = pt2.x() + m_itemSize + m_gapSize / 2; - y1 = pt2.y(); - y2 = y1 + m_itemSize + m_itemTextHeight; - - for (int i = 0; i < getRowCount(row); ++i) - { - QPoint pt2 = getItemPos(row * cols + i); - - int left = pt2.x(); - int right = left + m_itemSize; - if (pt.x() - round(m_thumbRect.left) < (left + right) / 2) - { - pos = row * cols + i; - - x1 = x2 = pt2.x() - m_gapSize / 2; - y1 = pt2.y(); - y2 = y1 + m_itemSize + m_itemTextHeight; - break; - } - } - } - } - - assert(-1 != pos); - get = true; - pt1.setX(x1); - pt1.setY(y1); - pt2.setX(x2); - pt2.setY(y2); - return pos; -} - -int HGImgThumb::findIndex(const QString &fileName) -{ - int index = -1; - for (int i = 0; i < (int)m_frontItems.size(); ++i) - { - if (0 == m_frontItems[i]->fileName.compare(fileName)) - { - index = i; - break; - } - } - - return index; -} - -QRect HGImgThumb::getHScrollLeftPos() -{ - assert(m_hScroll); - - return QRect(0, this->height() - m_scrollSize, m_scrollSize, m_scrollSize); -} - -QRect HGImgThumb::getHScrollRightPos() -{ - assert(m_hScroll); - - if (!m_vScroll) - { - return QRect(this->width() - m_scrollSize, this->height() - m_scrollSize, m_scrollSize, m_scrollSize); - } - - return QRect(this->width() - 2 * m_scrollSize, this->height() - m_scrollSize, m_scrollSize, m_scrollSize); -} - -QRect HGImgThumb::getHScrollPos() -{ - assert(m_hScroll); - - if (!m_vScroll) - { - return QRect(0, this->height() - m_scrollSize, this->width(), m_scrollSize); - } - - return QRect(0, this->height() - m_scrollSize, this->width() - m_scrollSize, m_scrollSize); -} - -QRect HGImgThumb::getHScrollSliderPos() -{ - assert(m_hScroll); - - QRect rect; - rect.setY(this->height() - m_scrollSize); - rect.setHeight(m_scrollSize); - if (!m_vScroll) - { - int rollTotalLen = this->width() - 2 * m_scrollSize; - int rollLeft = round((double)rollTotalLen * (-m_thumbRect.left) / (double)(m_thumbRect.right - m_thumbRect.left)); - int rollRight = round((double)rollTotalLen * (-m_thumbRect.left + this->width()) / (double)(m_thumbRect.right - m_thumbRect.left)); - int rollLen = rollRight - rollLeft; - if (rollLen < m_minScrollSliderSize) - { - rollLen = m_minScrollSliderSize; - rollLeft = round((double)(rollTotalLen - m_minScrollSliderSize) * (-m_thumbRect.left) / (double)(m_thumbRect.right - m_thumbRect.left - this->width())); - } - - rect.setX(rollLeft + m_scrollSize); - rect.setWidth(rollLen); - } - else - { - int rollTotalLen = this->width() - 3 * m_scrollSize; - int rollLeft = round((double)rollTotalLen * (-m_thumbRect.left) / (double)(m_thumbRect.right - m_thumbRect.left)); - int rollRight = round((double)rollTotalLen * (-m_thumbRect.left + this->width() - m_scrollSize) / (double)(m_thumbRect.right - m_thumbRect.left)); - int rollLen = rollRight - rollLeft; - if (rollLen < m_minScrollSliderSize) - { - rollLen = m_minScrollSliderSize; - rollLeft = round((double)(rollTotalLen - m_minScrollSliderSize) * (-m_thumbRect.left) / (double)(m_thumbRect.right - m_thumbRect.left - this->width() + m_scrollSize)); - } - - rect.setX(rollLeft + m_scrollSize); - rect.setWidth(rollLen); - } - - return rect; -} - -QRect HGImgThumb::getVScrollTopPos() -{ - assert(m_vScroll); - - return QRect(this->width() - m_scrollSize, 0, m_scrollSize, m_scrollSize); -} - -QRect HGImgThumb::getVScrollBottomPos() -{ - assert(m_vScroll); - - if (!m_hScroll) - { - return QRect(this->width() - m_scrollSize, this->height() - m_scrollSize, m_scrollSize, m_scrollSize); - } - - return QRect(this->width() - m_scrollSize, this->height() - 2 * m_scrollSize, m_scrollSize, m_scrollSize); -} - -QRect HGImgThumb::getVScrollPos() -{ - assert(m_vScroll); - - if (!m_hScroll) - { - return QRect(this->width() - m_scrollSize, 0, m_scrollSize, this->height()); - } - - return QRect(this->width() - m_scrollSize, 0, m_scrollSize, this->height() - m_scrollSize); -} - -QRect HGImgThumb::getVScrollSliderPos() -{ - assert(m_vScroll); - - QRect rect; - rect.setX(this->width() - m_scrollSize); - rect.setWidth(m_scrollSize); - if (!m_hScroll) - { - int rollTotalLen = this->height() - 2 * m_scrollSize; - int rollTop = round((double)rollTotalLen * (-m_thumbRect.top) / (double)(m_thumbRect.bottom - m_thumbRect.top)); - int rollBottom = round((double)rollTotalLen * (-m_thumbRect.top + this->height()) / (double)(m_thumbRect.bottom - m_thumbRect.top)); - int rollLen = rollBottom - rollTop; - if (rollLen < m_minScrollSliderSize) - { - rollLen = m_minScrollSliderSize; - rollTop = round((double)(rollTotalLen - m_minScrollSliderSize) * (-m_thumbRect.top) / (double)(m_thumbRect.bottom - m_thumbRect.top - this->height())); - } - - rect.setY(rollTop + m_scrollSize); - rect.setHeight(rollLen); - } - else - { - int rollTotalLen = this->height() - 3 * m_scrollSize; - int rollTop = round((double)rollTotalLen * (-m_thumbRect.top) / (double)(m_thumbRect.bottom - m_thumbRect.top)); - int rollBottom = round((double)rollTotalLen * (-m_thumbRect.top + this->height() - m_scrollSize) / (double)(m_thumbRect.bottom - m_thumbRect.top)); - int rollLen = rollBottom - rollTop; - if (rollLen < m_minScrollSliderSize) - { - rollLen = m_minScrollSliderSize; - rollTop = round((double)(rollTotalLen - m_minScrollSliderSize) * (-m_thumbRect.top) / (double)(m_thumbRect.bottom - m_thumbRect.top - this->height() + m_scrollSize)); - } - - rect.setY(rollTop + m_scrollSize); - rect.setHeight(rollLen); - } - - return rect; -} - -QRect HGImgThumb::getNullScrollPos() -{ - assert(m_hScroll && m_vScroll); - return QRect(this->width() - m_scrollSize, this->height() - m_scrollSize, m_scrollSize, m_scrollSize); -} - -void HGImgThumb::Show() -{ - repaint(); -} - -void HGAPI HGImgThumb::ThreadFunc(HGThread thread, HGPointer param) -{ - Q_UNUSED(thread); - - HGImgThumb *p = (HGImgThumb *)param; - while (!p->m_stopThread) - { - QString fileName; - - HGBase_EnterLock(p->m_lockBack); - int count = (int)p->m_backList.size(); - if (count > 0) - { - fileName = *p->m_backList.begin(); - p->m_backList.erase(p->m_backList.begin()); - --count; - } - HGBase_LeaveLock(p->m_lockBack); - - if (!fileName.isEmpty()) - { - HGImage image = nullptr; - HGImgFmt_LoadImage(getStdString(fileName).c_str(), 0, nullptr, HGBASE_IMGTYPE_RGB, HGBASE_IMGORIGIN_TOP, &image); - if (nullptr != image) - { - HGBase_EnterLock(p->m_lockItemSize); - int itemSize = p->m_itemSize; - HGBase_LeaveLock(p->m_lockItemSize); - QImage *img = createItemImage(image, itemSize); - if (nullptr != img) - { - HGImageInfo imgInfo; - HGBase_GetImageInfo(image, &imgInfo); - HGBase_EnterLock(p->m_lockFront); - int index = p->findIndex(fileName); - if (-1 != index) - { - p->m_frontItems[index]->width = imgInfo.width; - p->m_frontItems[index]->height = imgInfo.height; - delete p->m_frontItems[index]->image; - p->m_frontItems[index]->image = img; - } - HGBase_LeaveLock(p->m_lockFront); - // 通知UI线程更新 - emit p->updateItem(); - } - - HGBase_DestroyImage(image); - } - } - - if (0 == count) - { - HGBase_WaitEvent(p->m_event); - } - } -} diff --git a/app/scanner/HGImgThumb.h b/app/scanner/HGImgThumb.h deleted file mode 100644 index 071e921d..00000000 --- a/app/scanner/HGImgThumb.h +++ /dev/null @@ -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 - -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 &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 m_frontItems; - std::list 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__ */ diff --git a/app/scanner/HGImgView.cpp b/app/scanner/HGImgView.cpp deleted file mode 100644 index 98ddb67b..00000000 --- a/app/scanner/HGImgView.cpp +++ /dev/null @@ -1,2481 +0,0 @@ -#include "HGImgView.h" -#include -#include -#include -#include -#include -#include -#include "base/HGInc.h" -#include "imgfmt/HGImgFmt.h" -#include "HGUIGlobal.h" -#include - -HGImgView::HGImgView(QWidget* parent) - : QWidget(parent) -{ - m_scrollSize = 10; - m_minScrollSliderSize = 8; - for (int i = 0; i < 3; ++i) - { - m_hScrollLeftImage[i] = nullptr; - m_hScrollRightImage[i] = nullptr; - m_vScrollTopImage[i] = nullptr; - m_vScrollBottomImage[i] = nullptr; - m_hScrollSliderImage[i] = nullptr; - m_vScrollSliderImage[i] = nullptr; - } - m_hScrollImage = nullptr; - m_vScrollImage = nullptr; - m_nullScrollImage = nullptr; - - m_enableScroll = false; - m_mouseOn = false; - m_hScroll = false; - m_vScroll = false; - m_image = nullptr; - m_qImage = nullptr; - m_showImage = false; - memset(&m_showRect, 0, sizeof(HGRectF)); - m_mouseMoveStatus = MouseStatus_Null; - m_mousePressStatus = MouseStatus_Null; - m_mousePressBeginX = -1; - m_mousePressBeginY = -1; - m_showColorInfo = false; - m_operate = 0; - m_beginX = -1; - m_beginY = -1; - m_draging = false; - - setFocusPolicy(Qt::ClickFocus); - setMouseTracking(true); - setAcceptDrops(true); -} - -HGImgView::~HGImgView() -{ - clearImage(); - - delete m_hScrollImage; - m_hScrollImage = nullptr; - delete m_vScrollImage; - m_vScrollImage = nullptr; - delete m_nullScrollImage; - m_nullScrollImage = nullptr; - for (int i = 0; i < 3; ++i) - { - delete m_hScrollLeftImage[i]; - m_hScrollLeftImage[i] = nullptr; - delete m_hScrollRightImage[i]; - m_hScrollRightImage[i] = nullptr; - delete m_vScrollTopImage[i]; - m_vScrollTopImage[i] = nullptr; - delete m_vScrollBottomImage[i]; - m_vScrollBottomImage[i] = nullptr; - delete m_hScrollSliderImage[i]; - m_hScrollSliderImage[i] = nullptr; - delete m_vScrollSliderImage[i]; - m_vScrollSliderImage[i] = nullptr; - } - - qDebug("~HGImgView"); -} - -HGResult HGImgView::setScrollSize(int size) -{ - if (MouseStatus_Null != m_mousePressStatus || 0 != m_operate || m_draging) - { - return HGBASE_ERR_FAIL; - } - - if (size < 10 || size > 20) - { - return HGBASE_ERR_INVALIDARG; - } - - if (nullptr != m_image) - { - return HGBASE_ERR_FAIL; - } - - m_scrollSize = size; - return HGBASE_ERR_OK; -} - -HGResult HGImgView::setMinScrollSliderSize(int size) -{ - if (MouseStatus_Null != m_mousePressStatus || 0 != m_operate || m_draging) - { - return HGBASE_ERR_FAIL; - } - - if (size < 8 || size > 64) - { - return HGBASE_ERR_INVALIDARG; - } - - if (nullptr != m_image) - { - return HGBASE_ERR_FAIL; - } - - m_minScrollSliderSize = size; - return HGBASE_ERR_OK; -} - -HGResult HGImgView::setHScrollLeftImage(const QImage *normalImage, const QImage *hotImage, const QImage *pushImage) -{ - if (MouseStatus_Null != m_mousePressStatus || 0 != m_operate || m_draging) - { - return HGBASE_ERR_FAIL; - } - - if (nullptr != m_image) - { - return HGBASE_ERR_FAIL; - } - - if (nullptr == normalImage) - { - delete m_hScrollLeftImage[0]; - m_hScrollLeftImage[0] = nullptr; - } - else - { - QImage *img = new QImage(*normalImage); - if (!img->isNull()) - { - if (nullptr != m_hScrollLeftImage[0]) - delete m_hScrollLeftImage[0]; - m_hScrollLeftImage[0] = img; - } - else - { - delete img; - } - } - - if (nullptr == hotImage) - { - delete m_hScrollLeftImage[1]; - m_hScrollLeftImage[1] = nullptr; - } - else - { - QImage *img = new QImage(*hotImage); - if (!img->isNull()) - { - if (nullptr != m_hScrollLeftImage[1]) - delete m_hScrollLeftImage[1]; - m_hScrollLeftImage[1] = img; - } - else - { - delete img; - } - } - - if (nullptr == pushImage) - { - delete m_hScrollLeftImage[2]; - m_hScrollLeftImage[2] = nullptr; - } - else - { - QImage *img = new QImage(*pushImage); - if (!img->isNull()) - { - if (nullptr != m_hScrollLeftImage[2]) - delete m_hScrollLeftImage[2]; - m_hScrollLeftImage[2] = img; - } - else - { - delete img; - } - } - - return HGBASE_ERR_OK; -} - -HGResult HGImgView::setHScrollRightImage(const QImage *normalImage, const QImage *hotImage, const QImage *pushImage) -{ - if (MouseStatus_Null != m_mousePressStatus || 0 != m_operate || m_draging) - { - return HGBASE_ERR_FAIL; - } - - if (nullptr != m_image) - { - return HGBASE_ERR_FAIL; - } - - if (nullptr == normalImage) - { - delete m_hScrollRightImage[0]; - m_hScrollRightImage[0] = nullptr; - } - else - { - QImage *img = new QImage(*normalImage); - if (!img->isNull()) - { - if (nullptr != m_hScrollRightImage[0]) - delete m_hScrollRightImage[0]; - m_hScrollRightImage[0] = img; - } - else - { - delete img; - } - } - - if (nullptr == hotImage) - { - delete m_hScrollRightImage[1]; - m_hScrollRightImage[1] = nullptr; - } - else - { - QImage *img = new QImage(*hotImage); - if (!img->isNull()) - { - if (nullptr != m_hScrollRightImage[1]) - delete m_hScrollRightImage[1]; - m_hScrollRightImage[1] = img; - } - else - { - delete img; - } - } - - if (nullptr == pushImage) - { - delete m_hScrollRightImage[2]; - m_hScrollRightImage[2] = nullptr; - } - else - { - QImage *img = new QImage(*pushImage); - if (!img->isNull()) - { - if (nullptr != m_hScrollRightImage[2]) - delete m_hScrollRightImage[2]; - m_hScrollRightImage[2] = img; - } - else - { - delete img; - } - } - - return HGBASE_ERR_OK; -} - -HGResult HGImgView::setVScrollTopImage(const QImage *normalImage, const QImage *hotImage, const QImage *pushImage) -{ - if (MouseStatus_Null != m_mousePressStatus || 0 != m_operate || m_draging) - { - return HGBASE_ERR_FAIL; - } - - if (nullptr != m_image) - { - return HGBASE_ERR_FAIL; - } - - if (nullptr == normalImage) - { - delete m_vScrollTopImage[0]; - m_vScrollTopImage[0] = nullptr; - } - else - { - QImage *img = new QImage(*normalImage); - if (!img->isNull()) - { - if (nullptr != m_vScrollTopImage[0]) - delete m_vScrollTopImage[0]; - m_vScrollTopImage[0] = img; - } - else - { - delete img; - } - } - - if (nullptr == hotImage) - { - delete m_vScrollTopImage[1]; - m_vScrollTopImage[1] = nullptr; - } - else - { - QImage *img = new QImage(*hotImage); - if (!img->isNull()) - { - if (nullptr != m_vScrollTopImage[1]) - delete m_vScrollTopImage[1]; - m_vScrollTopImage[1] = img; - } - else - { - delete img; - } - } - - if (nullptr == pushImage) - { - delete m_vScrollTopImage[2]; - m_vScrollTopImage[2] = nullptr; - } - else - { - QImage *img = new QImage(*pushImage); - if (!img->isNull()) - { - if (nullptr != m_vScrollTopImage[2]) - delete m_vScrollTopImage[2]; - m_vScrollTopImage[2] = img; - } - else - { - delete img; - } - } - - return HGBASE_ERR_OK; -} - -HGResult HGImgView::setVScrollBottomImage(const QImage *normalImage, const QImage *hotImage, const QImage *pushImage) -{ - if (MouseStatus_Null != m_mousePressStatus || 0 != m_operate || m_draging) - { - return HGBASE_ERR_FAIL; - } - - if (nullptr != m_image) - { - return HGBASE_ERR_FAIL; - } - - if (nullptr == normalImage) - { - delete m_vScrollBottomImage[0]; - m_vScrollBottomImage[0] = nullptr; - } - else - { - QImage *img = new QImage(*normalImage); - if (!img->isNull()) - { - if (nullptr != m_vScrollBottomImage[0]) - delete m_vScrollBottomImage[0]; - m_vScrollBottomImage[0] = img; - } - else - { - delete img; - } - } - - if (nullptr == hotImage) - { - delete m_vScrollBottomImage[1]; - m_vScrollBottomImage[1] = nullptr; - } - else - { - QImage *img = new QImage(*hotImage); - if (!img->isNull()) - { - if (nullptr != m_vScrollBottomImage[1]) - delete m_vScrollBottomImage[1]; - m_vScrollBottomImage[1] = img; - } - else - { - delete img; - } - } - - if (nullptr == pushImage) - { - delete m_vScrollBottomImage[2]; - m_vScrollBottomImage[2] = nullptr; - } - else - { - QImage *img = new QImage(*pushImage); - if (!img->isNull()) - { - if (nullptr != m_vScrollBottomImage[2]) - delete m_vScrollBottomImage[2]; - m_vScrollBottomImage[2] = img; - } - else - { - delete img; - } - } - - return HGBASE_ERR_OK; -} - -HGResult HGImgView::setHScrollImage(const QImage *image, const HGRect *stretch) -{ - if (MouseStatus_Null != m_mousePressStatus || 0 != m_operate || m_draging) - { - return HGBASE_ERR_FAIL; - } - - if (nullptr != m_image) - { - return HGBASE_ERR_FAIL; - } - - if (nullptr == image) - { - delete m_hScrollImage; - m_hScrollImage = nullptr; - } - else - { - QImage *img = new QImage(*image); - if (!img->isNull()) - { - if (nullptr != m_hScrollImage) - delete m_hScrollImage; - m_hScrollImage = img; - - if (nullptr == stretch || stretch->left < 0 || stretch->top < 0 - || stretch->right > m_hScrollImage->width() || stretch->bottom > m_hScrollImage->height() - || stretch->left >= stretch->right || stretch->top >= stretch->bottom) - { - m_hScrollImageStretch.setX(0); - m_hScrollImageStretch.setY(0); - m_hScrollImageStretch.setWidth(m_hScrollImage->width()); - m_hScrollImageStretch.setHeight(m_hScrollImage->height()); - } - else - { - m_hScrollImageStretch.setX(stretch->left); - m_hScrollImageStretch.setY(stretch->top); - m_hScrollImageStretch.setWidth(stretch->right - stretch->left); - m_hScrollImageStretch.setHeight(stretch->bottom - stretch->top); - } - } - else - { - delete img; - } - } - - return HGBASE_ERR_OK; -} - -HGResult HGImgView::setHScrollSliderImage(const QImage *normalImage, const HGRect *normalStretch, const QImage *hotImage, const HGRect *hotStretch, - const QImage *pushImage, const HGRect *pushStretch) -{ - if (MouseStatus_Null != m_mousePressStatus || 0 != m_operate || m_draging) - { - return HGBASE_ERR_FAIL; - } - - if (nullptr != m_image) - { - return HGBASE_ERR_FAIL; - } - - if (nullptr == normalImage) - { - delete m_hScrollSliderImage[0]; - m_hScrollSliderImage[0] = nullptr; - } - else - { - QImage *img = new QImage(*normalImage); - if (!img->isNull()) - { - if (nullptr != m_hScrollSliderImage[0]) - delete m_hScrollSliderImage[0]; - m_hScrollSliderImage[0] = img; - - if (nullptr == normalStretch || normalStretch->left < 0 || normalStretch->top < 0 - || normalStretch->right > m_hScrollSliderImage[0]->width() || normalStretch->bottom > m_hScrollSliderImage[0]->height() - || normalStretch->left >= normalStretch->right || normalStretch->top >= normalStretch->bottom) - { - m_hScrollSliderImageStretch[0].setX(0); - m_hScrollSliderImageStretch[0].setY(0); - m_hScrollSliderImageStretch[0].setWidth(m_hScrollSliderImage[0]->width()); - m_hScrollSliderImageStretch[0].setHeight(m_hScrollSliderImage[0]->height()); - } - else - { - m_hScrollSliderImageStretch[0].setX(normalStretch->left); - m_hScrollSliderImageStretch[0].setY(normalStretch->top); - m_hScrollSliderImageStretch[0].setWidth(normalStretch->right - normalStretch->left); - m_hScrollSliderImageStretch[0].setHeight(normalStretch->bottom - normalStretch->top); - } - } - else - { - delete img; - } - } - - if (nullptr == hotImage) - { - delete m_hScrollSliderImage[1]; - m_hScrollSliderImage[1] = nullptr; - } - else - { - QImage *img = new QImage(*hotImage); - if (!img->isNull()) - { - if (nullptr != m_hScrollSliderImage[1]) - delete m_hScrollSliderImage[1]; - m_hScrollSliderImage[1] = img; - - if (nullptr == hotStretch || hotStretch->left < 0 || hotStretch->top < 0 - || hotStretch->right > m_hScrollSliderImage[1]->width() || hotStretch->bottom > m_hScrollSliderImage[1]->height() - || hotStretch->left >= hotStretch->right || hotStretch->top >= hotStretch->bottom) - { - m_hScrollSliderImageStretch[1].setX(0); - m_hScrollSliderImageStretch[1].setY(0); - m_hScrollSliderImageStretch[1].setWidth(m_hScrollSliderImage[1]->width()); - m_hScrollSliderImageStretch[1].setHeight(m_hScrollSliderImage[1]->height()); - } - else - { - m_hScrollSliderImageStretch[1].setX(hotStretch->left); - m_hScrollSliderImageStretch[1].setY(hotStretch->top); - m_hScrollSliderImageStretch[1].setWidth(hotStretch->right - hotStretch->left); - m_hScrollSliderImageStretch[1].setHeight(hotStretch->bottom - hotStretch->top); - } - } - else - { - delete img; - } - } - - if (nullptr == pushImage) - { - delete m_hScrollSliderImage[2]; - m_hScrollSliderImage[2] = nullptr; - } - else - { - QImage *img = new QImage(*pushImage); - if (!img->isNull()) - { - if (nullptr != m_hScrollSliderImage[2]) - delete m_hScrollSliderImage[2]; - m_hScrollSliderImage[2] = img; - - if (nullptr == pushStretch || pushStretch->left < 0 || pushStretch->top < 0 - || pushStretch->right > m_hScrollSliderImage[2]->width() || pushStretch->bottom > m_hScrollSliderImage[2]->height() - || pushStretch->left >= pushStretch->right || pushStretch->top >= hotStretch->bottom) - { - m_hScrollSliderImageStretch[2].setX(0); - m_hScrollSliderImageStretch[2].setY(0); - m_hScrollSliderImageStretch[2].setWidth(m_hScrollSliderImage[2]->width()); - m_hScrollSliderImageStretch[2].setHeight(m_hScrollSliderImage[2]->height()); - } - else - { - m_hScrollSliderImageStretch[2].setX(pushStretch->left); - m_hScrollSliderImageStretch[2].setY(pushStretch->top); - m_hScrollSliderImageStretch[2].setWidth(pushStretch->right - pushStretch->left); - m_hScrollSliderImageStretch[2].setHeight(pushStretch->bottom - pushStretch->top); - } - } - else - { - delete img; - } - } - - return HGBASE_ERR_OK; -} - -HGResult HGImgView::setVScrollImage(const QImage *image, const HGRect *stretch) -{ - if (MouseStatus_Null != m_mousePressStatus || 0 != m_operate || m_draging) - { - return HGBASE_ERR_FAIL; - } - - if (nullptr != m_image) - { - return HGBASE_ERR_FAIL; - } - - if (nullptr == image) - { - delete m_vScrollImage; - m_vScrollImage = nullptr; - } - else - { - QImage *img = new QImage(*image); - if (!img->isNull()) - { - if (nullptr != m_vScrollImage) - delete m_vScrollImage; - m_vScrollImage = img; - - if (nullptr == stretch || stretch->left < 0 || stretch->top < 0 - || stretch->right > m_vScrollImage->width() || stretch->bottom > m_vScrollImage->height() - || stretch->left >= stretch->right || stretch->top >= stretch->bottom) - { - m_vScrollImageStretch.setX(0); - m_vScrollImageStretch.setY(0); - m_vScrollImageStretch.setWidth(m_vScrollImage->width()); - m_vScrollImageStretch.setHeight(m_vScrollImage->height()); - } - else - { - m_vScrollImageStretch.setX(stretch->left); - m_vScrollImageStretch.setY(stretch->top); - m_vScrollImageStretch.setWidth(stretch->right - stretch->left); - m_vScrollImageStretch.setHeight(stretch->bottom - stretch->top); - } - } - else - { - delete img; - } - } - - return HGBASE_ERR_OK; -} - -HGResult HGImgView::setVScrollSliderImage(const QImage *normalImage, const HGRect *normalStretch, const QImage *hotImage, const HGRect *hotStretch, - const QImage *pushImage, const HGRect *pushStretch) -{ - if (MouseStatus_Null != m_mousePressStatus || 0 != m_operate || m_draging) - { - return HGBASE_ERR_FAIL; - } - - if (nullptr != m_image) - { - return HGBASE_ERR_FAIL; - } - - if (nullptr == normalImage) - { - delete m_vScrollSliderImage[0]; - m_vScrollSliderImage[0] = nullptr; - } - else - { - QImage *img = new QImage(*normalImage); - if (!img->isNull()) - { - if (nullptr != m_vScrollSliderImage[0]) - delete m_vScrollSliderImage[0]; - m_vScrollSliderImage[0] = img; - - if (nullptr == normalStretch || normalStretch->left < 0 || normalStretch->top < 0 - || normalStretch->right > m_vScrollSliderImage[0]->width() || normalStretch->bottom > m_vScrollSliderImage[0]->height() - || normalStretch->left >= normalStretch->right || normalStretch->top >= normalStretch->bottom) - { - m_vScrollSliderImageStretch[0].setX(0); - m_vScrollSliderImageStretch[0].setY(0); - m_vScrollSliderImageStretch[0].setWidth(m_vScrollSliderImage[0]->width()); - m_vScrollSliderImageStretch[0].setHeight(m_vScrollSliderImage[0]->height()); - } - else - { - m_vScrollSliderImageStretch[0].setX(normalStretch->left); - m_vScrollSliderImageStretch[0].setY(normalStretch->top); - m_vScrollSliderImageStretch[0].setWidth(normalStretch->right - normalStretch->left); - m_vScrollSliderImageStretch[0].setHeight(normalStretch->bottom - normalStretch->top); - } - } - else - { - delete img; - } - } - - if (nullptr == hotImage) - { - delete m_vScrollSliderImage[1]; - m_vScrollSliderImage[1] = nullptr; - } - else - { - QImage *img = new QImage(*hotImage); - if (!img->isNull()) - { - if (nullptr != m_vScrollSliderImage[1]) - delete m_vScrollSliderImage[1]; - m_vScrollSliderImage[1] = img; - - if (nullptr == hotStretch || hotStretch->left < 0 || hotStretch->top < 0 - || hotStretch->right > m_vScrollSliderImage[1]->width() || hotStretch->bottom > m_vScrollSliderImage[1]->height() - || hotStretch->left >= hotStretch->right || hotStretch->top >= hotStretch->bottom) - { - m_vScrollSliderImageStretch[1].setX(0); - m_vScrollSliderImageStretch[1].setY(0); - m_vScrollSliderImageStretch[1].setWidth(m_vScrollSliderImage[1]->width()); - m_vScrollSliderImageStretch[1].setHeight(m_vScrollSliderImage[1]->height()); - } - else - { - m_vScrollSliderImageStretch[1].setX(hotStretch->left); - m_vScrollSliderImageStretch[1].setY(hotStretch->top); - m_vScrollSliderImageStretch[1].setWidth(hotStretch->right - hotStretch->left); - m_vScrollSliderImageStretch[1].setHeight(hotStretch->bottom - hotStretch->top); - } - } - else - { - delete img; - } - } - - if (nullptr == pushImage) - { - delete m_vScrollSliderImage[2]; - m_vScrollSliderImage[2] = nullptr; - } - else - { - QImage *img = new QImage(*pushImage); - if (!img->isNull()) - { - if (nullptr != m_vScrollSliderImage[2]) - delete m_vScrollSliderImage[2]; - m_vScrollSliderImage[2] = img; - - if (nullptr == pushStretch || pushStretch->left < 0 || pushStretch->top < 0 - || pushStretch->right > m_vScrollSliderImage[2]->width() || pushStretch->bottom > m_vScrollSliderImage[2]->height() - || pushStretch->left >= pushStretch->right || pushStretch->top >= hotStretch->bottom) - { - m_vScrollSliderImageStretch[2].setX(0); - m_vScrollSliderImageStretch[2].setY(0); - m_vScrollSliderImageStretch[2].setWidth(m_vScrollSliderImage[2]->width()); - m_vScrollSliderImageStretch[2].setHeight(m_vScrollSliderImage[2]->height()); - } - else - { - m_vScrollSliderImageStretch[2].setX(pushStretch->left); - m_vScrollSliderImageStretch[2].setY(pushStretch->top); - m_vScrollSliderImageStretch[2].setWidth(pushStretch->right - pushStretch->left); - m_vScrollSliderImageStretch[2].setHeight(pushStretch->bottom - pushStretch->top); - } - } - else - { - delete img; - } - } - - return HGBASE_ERR_OK; -} - -HGResult HGImgView::setNullScrollImage(const QImage *image) -{ - if (MouseStatus_Null != m_mousePressStatus || 0 != m_operate || m_draging) - { - return HGBASE_ERR_FAIL; - } - - if (nullptr != m_image) - { - return HGBASE_ERR_FAIL; - } - - if (nullptr == image) - { - delete m_nullScrollImage; - m_nullScrollImage = nullptr; - } - else - { - QImage *img = new QImage(*image); - if (!img->isNull()) - { - if (nullptr != m_nullScrollImage) - delete m_nullScrollImage; - m_nullScrollImage = img; - } - else - { - delete img; - } - } - - return HGBASE_ERR_OK; -} - -HGResult HGImgView::enableScroll(bool enable) -{ - if (MouseStatus_Null != m_mousePressStatus || 0 != m_operate || m_draging) - { - return HGBASE_ERR_FAIL; - } - - if (nullptr != m_image) - { - return HGBASE_ERR_FAIL; - } - - m_enableScroll = enable; - return HGBASE_ERR_OK; -} - -HGResult HGImgView::addImage(HGImage image) -{ - HGImage img = nullptr; - HGResult ret = HGBase_CloneImage(image, 0, HGBASE_IMGORIGIN_TOP, &img); - if (ret != HGBASE_ERR_OK) - { - return ret; - } - - reset(); - - int oldWidth = 0; - int oldHeight = 0; - if (nullptr != m_image) - { - oldWidth = m_qImage->width(); - oldHeight = m_qImage->height(); - delete m_qImage; - HGBase_DestroyImage(m_image); - } - - m_image = img; - m_qImage = createQImage(); - - if (oldWidth != m_qImage->width() || oldHeight != m_qImage->height()) - { - HGImageInfo info; - HGBase_GetImageInfo(m_image, &info); - HGRect rcWnd = {0, 0, this->width(), this->height()}; - - m_hScroll = false; - m_vScroll = false; - GetMinShowImageRect(&rcWnd, info.width, info.height, m_showImage, m_showRect); - double scale = (double)(m_showRect.right - m_showRect.left) / (double)info.width; - - updateMoveStatusAndCursor(); - emit scaleChanged(scale); - } - - Show(); - return HGBASE_ERR_OK; -} - -HGResult HGImgView::clearImage() -{ - reset(); - - if (nullptr != m_image) - { - delete m_qImage; - m_qImage = nullptr; - HGBase_DestroyImage(m_image); - m_image = nullptr; - } - - m_hScroll = false; - m_vScroll = false; - m_showImage = false; - memset(&m_showRect, 0, sizeof(HGRectF)); - double scale = 0.0; - - updateMoveStatusAndCursor(); - Show(); - emit scaleChanged(scale); - return HGBASE_ERR_OK; -} - -HGResult HGImgView::getImage(HGImage *image) -{ - if (nullptr == image) - { - return HGBASE_ERR_INVALIDARG; - } - - *image = m_image; - return HGBASE_ERR_OK; -} - -HGResult HGImgView::rotateLeft() -{ - if (MouseStatus_Null != m_mousePressStatus || 0 != m_operate || m_draging || nullptr == m_image) - { - return HGBASE_ERR_FAIL; - } - - HGImageInfo info; - HGBase_GetImageInfo(m_image, &info); - - HGImage img = nullptr; - HGResult ret = HGBase_CreateImage(info.height, info.width, info.type, HGBASE_IMGORIGIN_TOP, &img); - if (ret != HGBASE_ERR_OK) - { - return ret; - } - - HGUInt xDpi, yDpi; - HGBase_GetImageDpi(m_image, &xDpi, &yDpi); - HGBase_SetImageDpi(img, xDpi, yDpi); - - HGBase_ImageRotateLeft(m_image, img); - - delete m_qImage; - HGBase_DestroyImage(m_image); - m_image = img; - m_qImage = createQImage(); - - HGBase_GetImageInfo(m_image, &info); - HGRect rcWnd = {0, 0, this->width(), this->height()}; - - m_hScroll = false; - m_vScroll = false; - GetMinShowImageRect(&rcWnd, info.width, info.height, m_showImage, m_showRect); - double scale = (double)(m_showRect.right - m_showRect.left) / (double)info.width; - - updateMoveStatusAndCursor(); - Show(); - emit scaleChanged(scale); - return HGBASE_ERR_OK; -} - -HGResult HGImgView::rotateRight() -{ - if (MouseStatus_Null != m_mousePressStatus || 0 != m_operate || m_draging || nullptr == m_image) - { - return HGBASE_ERR_FAIL; - } - - HGImageInfo info; - HGBase_GetImageInfo(m_image, &info); - - HGImage img = nullptr; - HGResult ret = HGBase_CreateImage(info.height, info.width, info.type, HGBASE_IMGORIGIN_TOP, &img); - if (ret != HGBASE_ERR_OK) - { - return ret; - } - - HGUInt xDpi, yDpi; - HGBase_GetImageDpi(m_image, &xDpi, &yDpi); - HGBase_SetImageDpi(img, xDpi, yDpi); - - HGBase_ImageRotateRight(m_image, img); - - delete m_qImage; - HGBase_DestroyImage(m_image); - m_image = img; - m_qImage = createQImage(); - - HGBase_GetImageInfo(m_image, &info); - HGRect rcWnd = {0, 0, this->width(), this->height()}; - - m_hScroll = false; - m_vScroll = false; - GetMinShowImageRect(&rcWnd, info.width, info.height, m_showImage, m_showRect); - double scale = (double)(m_showRect.right - m_showRect.left) / (double)info.width; - - updateMoveStatusAndCursor(); - Show(); - emit scaleChanged(scale); - return HGBASE_ERR_OK; -} - -HGResult HGImgView::rotate180() -{ - if (MouseStatus_Null != m_mousePressStatus || 0 != m_operate || m_draging || nullptr == m_image) - { - return HGBASE_ERR_FAIL; - } - - HGBase_ImageRotate180(m_image, m_image); - - delete m_qImage; - m_qImage = createQImage(); - - Show(); - return HGBASE_ERR_OK; -} - -HGResult HGImgView::zoomIn(const HGPoint *pCenter) -{ - if (MouseStatus_Null != m_mousePressStatus || 0 != m_operate || m_draging || nullptr == m_image) - { - return HGBASE_ERR_FAIL; - } - - HGImageInfo info; - HGBase_GetImageInfo(m_image, &info); - - // 获取最大值 - float fMaxWidth = info.width * 20.0f; - float fMaxHeight = info.height * 20.0f; - // 获取当前值 - float fCurWidth = m_showRect.right - m_showRect.left; - float fCurHeight = m_showRect.bottom - m_showRect.top; - // 新值 - float fNewWidth = fCurWidth * 1.2f; - float fNewHeight = fCurHeight * 1.2f; - - // support 1% zoom-in when 'ctrl' pressed (added on 2022-05-24) - if(QApplication::queryKeyboardModifiers() == Qt::CTRL) - { - // 1% - fNewWidth = info.width * .01f; - if(fNewWidth < 1.0f) - fNewWidth = 1.0f; - fNewWidth += fCurWidth; - - fNewHeight = info.height * .01f; - if(fNewHeight < 1.0f) - fNewHeight = 1.0f; - fNewHeight += fCurHeight; - } - - if (fabs(fMaxWidth - fCurWidth) > 1e-3 || fabs(fMaxHeight - fCurHeight) > 1e-3) - { - if (fNewWidth - fMaxWidth > -1e-3 || fNewHeight - fMaxHeight > -1e-3 - || round(100.0f * fNewWidth / (float)info.width) == round(100.0f * fMaxWidth / (float)info.width)) - { - fNewWidth = fMaxWidth; - fNewHeight = fMaxHeight; - } - - m_hScroll = false; - m_vScroll = false; - if (m_enableScroll) - { - if (fNewWidth > this->width()) - { - m_hScroll = true; - if (fNewHeight > this->height() - m_scrollSize) - m_vScroll = true; - } - else - { - if (fNewHeight > this->height()) - { - m_vScroll = true; - if (fNewWidth > this->width() - m_scrollSize) - m_hScroll = true; - } - } - } - - ResizeShowImageRect(m_showImage, m_showRect, fNewWidth, fNewHeight, pCenter); - recalcShowRect(this->width(), this->height(), m_scrollSize, m_hScroll, m_vScroll, m_showImage, m_showRect); - double scale = (double)(m_showRect.right - m_showRect.left) / (double)info.width; - - updateMoveStatusAndCursor(); - Show(); - emit scaleChanged(scale); - } - - return HGBASE_ERR_OK; -} - -HGResult HGImgView::zoomOut(const HGPoint *pCenter) -{ - if (MouseStatus_Null != m_mousePressStatus || 0 != m_operate || m_draging || nullptr == m_image) - { - return HGBASE_ERR_FAIL; - } - - HGImageInfo info; - HGBase_GetImageInfo(m_image, &info); - HGRect rcWnd = {0, 0, this->width(), this->height()}; - - // 获取最小值 - bool bMinShow; - HGRectF rcMinShow; - GetMinShowImageRect(&rcWnd, info.width, info.height, bMinShow, rcMinShow); - float fMinWidth = rcMinShow.right - rcMinShow.left; - float fMinHeight = rcMinShow.bottom - rcMinShow.top; - // 获取当前值 - float fCurWidth = m_showRect.right - m_showRect.left; - float fCurHeight = m_showRect.bottom - m_showRect.top; - // 新值 - float fNewWidth = fCurWidth * 1.0f / 1.2f; - float fNewHeight = fCurHeight * 1.0f / 1.2f; - - // support 1% zoom-out when 'ctrl' pressed (added on 2022-05-24) - if(QApplication::queryKeyboardModifiers() == Qt::CTRL) - { - // 1% - fNewWidth = info.width * .01f; - if(fNewWidth < 1.0f) - fNewWidth = 1.0f; - fNewWidth = fCurWidth - fNewWidth; - - fNewHeight = info.height * .01f; - if(fNewHeight < 1.0f) - fNewHeight = 1.0f; - fNewHeight = fCurHeight - fNewHeight; - } - - if (fabs(fMinWidth - fCurWidth) > 1e-3 || fabs(fMinHeight - fCurHeight) > 1e-3) - { - if (fNewWidth - fMinWidth < 1e-3 || fNewHeight - fMinHeight < 1e-3 - || round(100.0f * fNewWidth / (float)info.width) == round(100.0f * fMinWidth / (float)info.width)) - { - fNewWidth = fMinWidth; - fNewHeight = fMinHeight; - } - - m_hScroll = false; - m_vScroll = false; - if (m_enableScroll) - { - if (fNewWidth > this->width()) - { - m_hScroll = true; - if (fNewHeight > this->height() - m_scrollSize) - m_vScroll = true; - } - else - { - if (fNewHeight > this->height()) - { - m_vScroll = true; - if (fNewWidth > this->width() - m_scrollSize) - m_hScroll = true; - } - } - } - - ResizeShowImageRect(m_showImage, m_showRect, fNewWidth, fNewHeight, pCenter); - recalcShowRect(this->width(), this->height(), m_scrollSize, m_hScroll, m_vScroll, m_showImage, m_showRect); - double scale = (double)(m_showRect.right - m_showRect.left) / (double)info.width; - - updateMoveStatusAndCursor(); - Show(); - emit scaleChanged(scale); - } - - return HGBASE_ERR_OK; -} - -HGResult HGImgView::realSize() -{ - if (MouseStatus_Null != m_mousePressStatus || 0 != m_operate || m_draging || nullptr == m_image) - { - return HGBASE_ERR_FAIL; - } - - HGImageInfo info; - HGBase_GetImageInfo(m_image, &info); - - m_hScroll = false; - m_vScroll = false; - if (m_enableScroll) - { - if ((int)info.width > this->width()) - { - m_hScroll = true; - if ((int)info.height > this->height() - m_scrollSize) - m_vScroll = true; - } - else - { - if ((int)info.height > this->height()) - { - m_vScroll = true; - if ((int)info.width > this->width() - m_scrollSize) - m_hScroll = true; - } - } - } - - ResizeShowImageRect(m_showImage, m_showRect, (float)info.width, (float)info.height, nullptr); - recalcShowRect(this->width(), this->height(), m_scrollSize, m_hScroll, m_vScroll, m_showImage, m_showRect); - double scale = 1.0; - - updateMoveStatusAndCursor(); - Show(); - emit scaleChanged(scale); - return HGBASE_ERR_OK; -} - -HGResult HGImgView::fitWndSize() -{ - if (MouseStatus_Null != m_mousePressStatus || 0 != m_operate || m_draging || nullptr == m_image) - { - return HGBASE_ERR_FAIL; - } - - HGImageInfo info; - HGBase_GetImageInfo(m_image, &info); - HGRect rcWnd = {0, 0, this->width(), this->height()}; - - m_hScroll = false; - m_vScroll = false; - GetMinShowImageRect(&rcWnd, info.width, info.height, m_showImage, m_showRect); - double scale = (double)(m_showRect.right - m_showRect.left) / (double)info.width; - - updateMoveStatusAndCursor(); - Show(); - emit scaleChanged(scale); - return HGBASE_ERR_OK; -} - -HGResult HGImgView::fitWndWidth() -{ - if (MouseStatus_Null != m_mousePressStatus || 0 != m_operate || m_draging || nullptr == m_image) - { - return HGBASE_ERR_FAIL; - } - - HGImageInfo info; - HGBase_GetImageInfo(m_image, &info); - HGRect rcWnd = {0, 0, this->width(), this->height()}; - - // 获取最小值 - bool bMinShow; - HGRectF rcMinShow; - GetMinShowImageRect(&rcWnd, info.width, info.height, bMinShow, rcMinShow); - float fMinWidth = rcMinShow.right - rcMinShow.left; - float fMinHeight = rcMinShow.bottom - rcMinShow.top; - // 获取最大值 - float fMaxWidth = info.width * 20.0f; - float fMaxHeight = info.height * 20.0f; - // 新值 - float fNewWidth = (float)this->width(); - float fNewHeight = fNewWidth * (float)info.height / (float)info.width; - fNewWidth = HGMIN(fMaxWidth, HGMAX(fMinWidth, fNewWidth)); - fNewHeight = HGMIN(fMaxHeight, HGMAX(fMinHeight, fNewHeight)); - - m_hScroll = false; - m_vScroll = false; - if (m_enableScroll) - { - if (fNewHeight > this->height()) - { - m_vScroll = true; - fNewWidth = this->width() - m_scrollSize; - fNewHeight = fNewWidth * (float)info.height / (float)info.width; - fNewWidth = HGMIN(fMaxWidth, HGMAX(fMinWidth, fNewWidth)); - fNewHeight = HGMIN(fMaxHeight, HGMAX(fMinHeight, fNewHeight)); - - if (fNewHeight <= this->height()) - { - m_vScroll = false; - fNewWidth = (float)this->width(); - fNewHeight = fNewWidth * (float)info.height / (float)info.width; - fNewWidth = HGMIN(fMaxWidth, HGMAX(fMinWidth, fNewWidth)); - fNewHeight = HGMIN(fMaxHeight, HGMAX(fMinHeight, fNewHeight)); - } - } - } - - ResizeShowImageRect(m_showImage, m_showRect, fNewWidth, fNewHeight, nullptr); - recalcShowRect(this->width(), this->height(), m_scrollSize, m_hScroll, m_vScroll, m_showImage, m_showRect); - double scale = (double)(m_showRect.right - m_showRect.left) / (double)info.width; - - updateMoveStatusAndCursor(); - Show(); - emit scaleChanged(scale); - return HGBASE_ERR_OK; -} - -HGResult HGImgView::showColorInfo(bool show) -{ - if (MouseStatus_Null != m_mousePressStatus || 0 != m_operate || m_draging) - { - return HGBASE_ERR_FAIL; - } - - m_showColorInfo = show; - QToolTip::hideText(); - updateMoveStatusAndCursor(); - return HGBASE_ERR_OK; -} - -void HGImgView::mousePressEvent(QMouseEvent* e) -{ - if (e->button() != Qt::LeftButton) - { - return; - } - - MouseStatus mouseStatus = getMouseStatus(e->pos()); - if (MouseStatus_Null != mouseStatus) - { - // 如果鼠标点到滚动条区域 - m_mousePressStatus = mouseStatus; - m_mousePressBeginX = e->pos().x(); - m_mousePressBeginY = e->pos().y(); - updateMoveStatusAndCursor(); - Show(); - return; - } - - assert(0 == m_operate); - if (nullptr == m_image || !m_showImage) - { - return; - } - - m_operate = 1; - m_beginX = e->pos().x(); - m_beginY = e->pos().y(); - updateMoveStatusAndCursor(); -} - -void HGImgView::mouseMoveEvent(QMouseEvent* e) -{ - // 处理滚动条 - if (MouseStatus_HScrollSlider == m_mousePressStatus) - { - int lXAmount = e->pos().x() - m_mousePressBeginX; - double offset; - if (!m_vScroll) - { - int rollTotalLen = this->width() - 2 * m_scrollSize; - int rollLeft = round((double)rollTotalLen * (-m_showRect.left) / (double)(m_showRect.right - m_showRect.left)); - int rollRight = round((double)rollTotalLen * (-m_showRect.left + this->width()) / (double)(m_showRect.right - m_showRect.left)); - int rollLen = rollRight - rollLeft; - if (rollLen >= m_minScrollSliderSize) - offset = lXAmount * (m_showRect.right - m_showRect.left) / rollTotalLen; - else - offset = lXAmount * (m_showRect.right - m_showRect.left - this->width()) / (rollTotalLen - m_minScrollSliderSize); - } - else - { - int rollTotalLen = this->width() - 3 * m_scrollSize; - int rollLeft = round((double)rollTotalLen * (-m_showRect.left) / (double)(m_showRect.right - m_showRect.left)); - int rollRight = round((double)rollTotalLen * (-m_showRect.left + this->width() - m_scrollSize) / (double)(m_showRect.right - m_showRect.left)); - int rollLen = rollRight - rollLeft; - if (rollLen >= m_minScrollSliderSize) - offset = lXAmount * (m_showRect.right - m_showRect.left) / rollTotalLen; - else - offset = lXAmount * (m_showRect.right - m_showRect.left - this->width() + m_scrollSize) / (rollTotalLen - m_minScrollSliderSize); - } - m_showRect.left -= offset; - m_showRect.right -= offset; - recalcShowRect(this->width(), this->height(), m_scrollSize, m_hScroll, m_vScroll, m_showImage, m_showRect); - - Show(); - m_mousePressBeginX = e->pos().x(); - m_mousePressBeginY = e->pos().y(); - } - else if (MouseStatus_VScrollSlider == m_mousePressStatus) - { - int lYAmount = e->pos().y() - m_mousePressBeginY; - double offset; - if (!m_hScroll) - { - int rollTotalLen = this->height() - 2 * m_scrollSize; - int rollTop = round((double)rollTotalLen * (-m_showRect.top) / (double)(m_showRect.bottom - m_showRect.top)); - int rollBottom = round((double)rollTotalLen * (-m_showRect.top + this->height()) / (double)(m_showRect.bottom - m_showRect.top)); - int rollLen = rollBottom - rollTop; - if (rollLen >= m_minScrollSliderSize) - offset = lYAmount * (m_showRect.bottom - m_showRect.top) / rollTotalLen; - else - offset = lYAmount * (m_showRect.bottom - m_showRect.top - this->height()) / (rollTotalLen - m_minScrollSliderSize); - } - else - { - int rollTotalLen = this->height() - 3 * m_scrollSize; - int rollTop = round((double)rollTotalLen * (-m_showRect.top) / (double)(m_showRect.bottom - m_showRect.top)); - int rollBottom = round((double)rollTotalLen * (-m_showRect.top + this->height() - m_scrollSize) / (double)(m_showRect.bottom - m_showRect.top)); - int rollLen = rollBottom - rollTop; - if (rollLen >= m_minScrollSliderSize) - offset = lYAmount * (m_showRect.bottom - m_showRect.top) / rollTotalLen; - else - offset = lYAmount * (m_showRect.bottom - m_showRect.top - this->height() + m_scrollSize) / (rollTotalLen - m_minScrollSliderSize); - } - m_showRect.top -= offset; - m_showRect.bottom -= offset; - recalcShowRect(this->width(), this->height(), m_scrollSize, m_hScroll, m_vScroll, m_showImage, m_showRect); - - Show(); - m_mousePressBeginX = e->pos().x(); - m_mousePressBeginY = e->pos().y(); - } - - if (1 == m_operate) - { - assert(nullptr != m_image && m_showImage); - - int lXAmount = e->pos().x() - m_beginX; - int lYAmount = e->pos().y() - m_beginY; - - m_showRect.left += lXAmount; - m_showRect.right += lXAmount; - m_showRect.top += lYAmount; - m_showRect.bottom += lYAmount; - recalcShowRect(this->width(), this->height(), m_scrollSize, m_hScroll, m_vScroll, m_showImage, m_showRect); - - Show(); - m_beginX = e->pos().x(); - m_beginY = e->pos().y(); - } - else - { - assert(0 == m_operate); - - MouseStatus mouseStatus = getMouseStatus(e->pos()); - if (nullptr != m_image && m_showImage && !m_draging - && MouseStatus_Null == m_mousePressStatus && MouseStatus_Null == mouseStatus) - { - HGImageInfo info; - HGBase_GetImageInfo(m_image, &info); - - int xShow = e->pos().x() - m_showRect.left; - int yShow = e->pos().y() - m_showRect.top; - int xImg = xShow * (int)info.width / (m_showRect.right - m_showRect.left); - int yImg = yShow * (int)info.height / (m_showRect.bottom - m_showRect.top); - - if (xImg >= 0 && xImg < (int)info.width && yImg >= 0 && yImg < (int)info.height) - { - //qDebug("mousePos, x=%d, y=%d", xImg, yImg); - emit mousePos(xImg, yImg); - - if (m_showColorInfo) - { - HGByte *data = nullptr; - HGBase_GetImageData(m_image, &data); - HGByte *pixel = data + yImg * info.widthStep + xImg * 3; - - HGByte r = pixel[0]; - HGByte g = pixel[1]; - HGByte b = pixel[2]; - //qDebug("colorInfo, r=%d, g=%d, b=%d", r, g, b); - - char colorInfo[1024]; - sprintf(colorInfo, "X: %d, Y: %d\nRGB(%d, %d, %d)\nHTML(#%02X%02X%02X)", - xImg, yImg, r, g, b, r, g, b); - QToolTip::showText(e->globalPos(), colorInfo, this); - } - } - else - { - emit mousePos(0, 0); - QToolTip::hideText(); - } - } - else - { - emit mousePos(0, 0); - QToolTip::hideText(); - } - - updateMoveStatusAndCursor(); - Show(); - } -} - -void HGImgView::mouseReleaseEvent(QMouseEvent* e) -{ - Q_UNUSED(e); - - m_draging = false; - - m_beginX = -1; - m_beginY = -1; - m_operate = 0; - - MouseStatus oldMousePressStatus = m_mousePressStatus; - m_mousePressStatus = MouseStatus_Null; - m_mousePressBeginX = -1; - m_mousePressBeginY = -1; - - // 处理按滚动条区域 - MouseStatus mouseMoveStatus = getMouseStatus(e->pos()); - if (MouseStatus_HScrollLeft == oldMousePressStatus && MouseStatus_HScrollLeft == mouseMoveStatus) - { - double width = m_showRect.right - m_showRect.left; - m_showRect.left += width / 10.0; - m_showRect.right += width / 10.0; - recalcShowRect(this->width(), this->height(), m_scrollSize, m_hScroll, m_vScroll, m_showImage, m_showRect); - } - else if (MouseStatus_HScrollRight == oldMousePressStatus && MouseStatus_HScrollRight == mouseMoveStatus) - { - double width = m_showRect.right - m_showRect.left; - m_showRect.left -= width / 10.0; - m_showRect.right -= width / 10.0; - recalcShowRect(this->width(), this->height(), m_scrollSize, m_hScroll, m_vScroll, m_showImage, m_showRect); - } - else if (MouseStatus_VScrollTop == oldMousePressStatus && MouseStatus_VScrollTop == mouseMoveStatus) - { - double height = m_showRect.bottom - m_showRect.top; - m_showRect.top += height / 10.0; - m_showRect.bottom += height / 10.0; - recalcShowRect(this->width(), this->height(), m_scrollSize, m_hScroll, m_vScroll, m_showImage, m_showRect); - } - else if (MouseStatus_VScrollBottom == oldMousePressStatus && MouseStatus_VScrollBottom == mouseMoveStatus) - { - double height = m_showRect.bottom - m_showRect.top; - m_showRect.top -= height / 10.0; - m_showRect.bottom -= height / 10.0; - recalcShowRect(this->width(), this->height(), m_scrollSize, m_hScroll, m_vScroll, m_showImage, m_showRect); - } - - updateMoveStatusAndCursor(); - Show(); -} - -void HGImgView::enterEvent(QEvent *e) -{ - Q_UNUSED(e); - m_mouseOn = true; -} - -void HGImgView::leaveEvent(QEvent *e) -{ - Q_UNUSED(e); - - // 拖动状态不能重置 - //m_draging = false; - - m_operate = 0; - m_beginX = -1; - m_beginY = -1; - - m_mouseOn = false; - m_mouseMoveStatus = MouseStatus_Null; - Show(); - emit mousePos(0, 0); -} - -void HGImgView::paintEvent(QPaintEvent* e) -{ - Q_UNUSED(e); - - QPainter painter(this); - painter.fillRect(0, 0, this->width(), this->height(), qRgb(250, 250, 250)); - - if (nullptr == m_qImage || !m_showImage) - { - return; - } - -#if 0 - HGRect rcWnd = {0, 0, this->width(), this->height()}; - int nImgWidth = info.width; - int nImgHeight = info.height; - - // 绘制Image - int xDest, yDest, wDest, hDest; - int xSrc, ySrc, wSrc, hSrc; - - HGRect rcShowImage; // 绘制的图像区域 - rcShowImage.left = round(m_showRect.left); - rcShowImage.top = round(m_showRect.top); - rcShowImage.right = round(m_showRect.right); - rcShowImage.bottom = round(m_showRect.bottom); - int nShowWidth = rcShowImage.right - rcShowImage.left; - int nShowHeight = rcShowImage.bottom - rcShowImage.top; - - if (rcShowImage.left <= rcWnd.left) - { - float fPixel = (float)nImgWidth * (rcWnd.left - rcShowImage.left) / nShowWidth; - float fPixelR = (float)nImgWidth * (rcShowImage.right - rcWnd.right) / nShowWidth; - xDest = rcShowImage.left + round((int)fPixel * (float)nShowWidth / nImgWidth); - int xDestR = rcShowImage.right - round((int)fPixelR * (float)nShowWidth / nImgWidth); - wDest = xDestR - xDest; - wSrc = round((float)nImgWidth * wDest / nShowWidth); - xSrc = round((float)(xDest - rcShowImage.left) * nImgWidth / nShowWidth); - } - else - { - xDest = rcShowImage.left; - wDest = nShowWidth; - xSrc = 0; - wSrc = nImgWidth; - } - - if (rcShowImage.top <= rcWnd.top) - { - float fPixel = (float)nImgHeight * (rcWnd.top - rcShowImage.top) / nShowHeight; - float fPixelB = (float)nImgHeight * (rcShowImage.bottom - rcWnd.bottom) / nShowHeight; - yDest = rcShowImage.top + round((int)fPixel * (float)nShowHeight / nImgHeight); - int yDestB = rcShowImage.bottom - round((int)fPixelB * (float)nShowHeight / nImgHeight); - hDest = yDestB - yDest; - hSrc = round((float)nImgHeight * hDest / nShowHeight); - ySrc = round((float)(yDest - rcShowImage.top) * nImgHeight / nShowHeight); - } - else - { - yDest = rcShowImage.top; - hDest = nShowHeight; - ySrc = 0; - hSrc = nImgHeight; - } - - QRect srcRect(xSrc, ySrc, wSrc, hSrc); - QRect destRect(xDest, yDest, wDest, hDest); - painter.setRenderHint(QPainter::SmoothPixmapTransform); - painter.drawImage(destRect, *m_qImage, srcRect); -#else - QRectF destRect(m_showRect.left, m_showRect.top, m_showRect.right - m_showRect.left, m_showRect.bottom - m_showRect.top); - painter.setRenderHint(QPainter::SmoothPixmapTransform); - painter.drawImage(destRect, *m_qImage); -#endif - - DrawScroll(painter); -} - -void HGImgView::wheelEvent(QWheelEvent* e) -{ - if (MouseStatus_Null != m_mousePressStatus || 0 != m_operate || m_draging) - { - return; - } - - MouseStatus mouseStatus = getMouseStatus(e->pos()); - if (MouseStatus_Null != mouseStatus) - { - if (MouseStatus_HScroll == mouseStatus || MouseStatus_HScrollSlider == mouseStatus - || MouseStatus_HScrollLeft == mouseStatus || MouseStatus_HScrollRight == mouseStatus) - { - double width = m_showRect.right - m_showRect.left; - - if (e->delta() > 0) - { - m_showRect.left += width / 10.0; - m_showRect.right += width / 10.0; - } - else - { - m_showRect.left -= width / 10.0; - m_showRect.right -= width / 10.0; - } - - recalcShowRect(this->width(), this->height(), m_scrollSize, m_hScroll, m_vScroll, m_showImage, m_showRect); - } - else if (MouseStatus_VScroll == mouseStatus || MouseStatus_VScrollSlider == mouseStatus - || MouseStatus_VScrollTop == mouseStatus || MouseStatus_VScrollBottom == mouseStatus) - { - double height = m_showRect.bottom - m_showRect.top; - - if (e->delta() > 0) - { - m_showRect.top += height / 10.0; - m_showRect.bottom += height / 10.0; - } - else - { - m_showRect.top -= height / 10.0; - m_showRect.bottom -= height / 10.0; - } - - recalcShowRect(this->width(), this->height(), m_scrollSize, m_hScroll, m_vScroll, m_showImage, m_showRect); - } - - Show(); - return; - } - - HGPoint pt = {e->pos().x(), e->pos().y()}; - - if (e->delta() > 0) - zoomIn(&pt); - else - zoomOut(&pt); -} - -void HGImgView::resizeEvent(QResizeEvent* e) -{ - Q_UNUSED(e); - - reset(); - - if (nullptr != m_image) - { - HGImageInfo info; - HGBase_GetImageInfo(m_image, &info); - HGRect rcWnd = {0, 0, this->width(), this->height()}; - - m_hScroll = false; - m_vScroll = false; - GetMinShowImageRect(&rcWnd, info.width, info.height, m_showImage, m_showRect); - double scale = (double)(m_showRect.right - m_showRect.left) / (double)info.width; - - emit scaleChanged(scale); - } - - updateMoveStatusAndCursor(); - Show(); -} - -void HGImgView::keyPressEvent(QKeyEvent *e) -{ - Q_UNUSED(e); - - if (MouseStatus_Null != m_mousePressStatus || 0 != m_operate || m_draging) - { - return; - } - - if (e->key() == Qt::Key_Escape) - { - emit escape(); - } -} - -void HGImgView::dragEnterEvent(QDragEnterEvent *e) -{ - qDebug("dragEnterEvent"); - - if (e->mimeData()->hasUrls()) - { - m_draging = true; - e->accept(); - } -} - -void HGImgView::dragMoveEvent(QDragMoveEvent *e) -{ - //qDebug("dragMoveEvent"); - Q_UNUSED(e); - - //Show(); -} - -void HGImgView::dragLeaveEvent(QDragLeaveEvent *e) -{ - qDebug("dragLeaveEvent"); - Q_UNUSED(e); - - m_draging = false; - //Show(); -} - -void HGImgView::dropEvent(QDropEvent *e) -{ - Q_UNUSED(e); - - QStringList fileNames; - QList urls = e->mimeData()->urls(); - for (QUrl url : urls) - { - fileNames.append(url.toLocalFile()); - } - - m_draging = false; - emit drop(e->source(), fileNames); -} - -void HGImgView::mouseDoubleClickEvent(QMouseEvent* e) -{ - if (MouseStatus_Null != m_mousePressStatus || 0 != m_operate || m_draging) - { - return; - } - - MouseStatus mouseMoveStatus = getMouseStatus(e->pos()); - if (MouseStatus_Null == mouseMoveStatus) - { - emit doubleClicked(); - } - else - { - QWidget::mouseDoubleClickEvent(e); - } -} - -void HGImgView::GetMinShowImageRect(const HGRect *pWnd, int nImgWidth, int nImgHeight, bool &bShowImage, HGRectF &rcShowImage) -{ - bShowImage = false; - memset(&rcShowImage, 0, sizeof(HGRectF)); - - assert(nullptr != pWnd); - - int nWndWidth = pWnd->right - pWnd->left; - int nWndHeight = pWnd->bottom - pWnd->top; - if (nWndWidth <= 0 || nWndHeight <= 0) - { - return; - } - - if (nImgWidth <= 0 || nImgHeight <= 0) - { - return; - } - - float fLeft, fTop, fRight, fBottom; - - if (nImgWidth > nWndWidth || nImgHeight > nWndHeight) - { - if (nImgWidth * nWndHeight < nImgHeight * nWndWidth) - { - float fWidth = (float)nWndHeight * nImgWidth / nImgHeight; - fLeft = (pWnd->left + pWnd->right - fWidth) / 2.0f; - fRight = (pWnd->left + pWnd->right + fWidth) / 2.0f; - fTop = (float)pWnd->top; - fBottom = (float)pWnd->bottom; - } - else - { - float fHeight = (float)nWndWidth * nImgHeight / nImgWidth; - fLeft = (float)pWnd->left; - fRight = (float)pWnd->right; - fTop = (pWnd->top + pWnd->bottom - fHeight) / 2.0f; - fBottom = (pWnd->top + pWnd->bottom + fHeight) / 2.0f; - } - } - else - { - fLeft = (pWnd->left + pWnd->right - nImgWidth) / 2.0f; - fRight = (pWnd->left + pWnd->right + nImgWidth) / 2.0f; - fTop = (pWnd->top + pWnd->bottom - nImgHeight) / 2.0f; - fBottom = (pWnd->top + pWnd->bottom + nImgHeight) / 2.0f; - } - - if (fRight - fLeft < 1e-3 || fBottom - fTop < 1e-3) - { - return; - } - - bShowImage = true; - rcShowImage.left = fLeft; - rcShowImage.top = fTop; - rcShowImage.right = fRight; - rcShowImage.bottom = fBottom; -} - -void HGImgView::ResizeShowImageRect(bool &bShowImage, HGRectF &rcShowImage, float fNewWidth, float fNewHeight, const HGPoint *pCenter) -{ - if (!bShowImage) - { - return; - } - - if (fNewWidth <= 0 || fNewHeight <= 0) - { - bShowImage = false; - memset(&rcShowImage, 0, sizeof(HGRectF)); - return; - } - - float fCurWidth = rcShowImage.right - rcShowImage.left; - float fCurHeight = rcShowImage.bottom - rcShowImage.top; - - if (nullptr != pCenter) - { - rcShowImage.left = (float)pCenter->x - ((float)pCenter->x - rcShowImage.left) * fNewWidth / fCurWidth; - rcShowImage.top = (float)pCenter->y - ((float)pCenter->y - rcShowImage.top) * fNewHeight / fCurHeight; - } - else - { - rcShowImage.left = rcShowImage.left - (fNewWidth - fCurWidth) / 2.0f; - rcShowImage.top = rcShowImage.top - (fNewHeight - fCurHeight) / 2.0f; - } - - rcShowImage.right = rcShowImage.left + fNewWidth; - rcShowImage.bottom = rcShowImage.top + fNewHeight; - - if (rcShowImage.right - rcShowImage.left < 1e-3 || rcShowImage.bottom - rcShowImage.top < 1e-3) - { - bShowImage = false; - memset(&rcShowImage, 0, sizeof(HGRectF)); - } -} - -void HGImgView::recalcShowRect(int wndWidth, int wndHeight, int scrollSize, bool hScroll, bool vScroll, bool showImage, HGRectF &imageRect) -{ - if (!showImage) - return; - - double width = imageRect.right - imageRect.left; - double height = imageRect.bottom - imageRect.top; - - int vScorllSize = vScroll ? scrollSize : 0; - if (width <= (double)(wndWidth - vScorllSize)) - { - imageRect.left = (wndWidth - vScorllSize - width) / 2.0; - imageRect.right = imageRect.left + width; - } - else - { - if (imageRect.right < (double)(wndWidth - vScorllSize)) - { - imageRect.right = wndWidth - vScorllSize; - imageRect.left = imageRect.right - width; - } - if (imageRect.left > 0) - { - imageRect.left = 0; - imageRect.right = imageRect.left + width; - } - } - - int hScorllSize = hScroll ? scrollSize : 0; - if (height <= (double)(wndHeight - hScorllSize)) - { - imageRect.top = (wndHeight - hScorllSize - height) / 2.0; - imageRect.bottom = imageRect.top + height; - } - else - { - if (imageRect.bottom < (double)(wndHeight - hScorllSize)) - { - imageRect.bottom = wndHeight - hScorllSize; - imageRect.top = imageRect.bottom - height; - } - if (imageRect.top > 0) - { - imageRect.top = 0; - imageRect.bottom = imageRect.top + height; - } - } -} - -void HGImgView::DrawImage(QPainter &painter, const QRect &destRect, const QImage *image, const QRect &stretchRect) -{ - if (destRect.width() < image->width() - stretchRect.width() - || destRect.height() < image->height() - stretchRect.height()) - { - painter.drawImage(destRect, *image); - return; - } - - for (int i = 0; i < 9; ++i) - { - int DestX = destRect.left(), DestY = destRect.top(), DestWidth = destRect.width(), DestHeight = destRect.height(); - int SrcX = 0, SrcY = 0, SrcWidth = image->width(), SrcHeight = image->height(); - - if (0 == i % 3) - { - DestX = destRect.left(); - DestWidth = stretchRect.left(); - SrcX = 0; - SrcWidth = stretchRect.left(); - } - else if (1 == i % 3) - { - DestX = destRect.left() + stretchRect.left(); - DestWidth = destRect.width() + stretchRect.width() - image->width(); - SrcX = stretchRect.left(); - SrcWidth = stretchRect.width(); - } - else if (2 == i % 3) - { - DestX = destRect.left() + destRect.width() + stretchRect.left() + stretchRect.width() - image->width(); - DestWidth = image->width() - (stretchRect.left() + stretchRect.width()); - SrcX = stretchRect.left() + stretchRect.width(); - SrcWidth = image->width() - (stretchRect.left() + stretchRect.width()); - } - - if (0 == i / 3) - { - DestY = destRect.top(); - DestHeight = stretchRect.top(); - SrcY = 0; - SrcHeight = stretchRect.top(); - } - else if (1 == i / 3) - { - DestY = destRect.top() + stretchRect.top(); - DestHeight = destRect.height() + stretchRect.height() - image->height(); - SrcY = stretchRect.top(); - SrcHeight = stretchRect.height(); - } - else if (2 == i / 3) - { - DestY = destRect.top() + destRect.height() + stretchRect.top() + stretchRect.height() - image->height(); - DestHeight = image->height() - (stretchRect.top() + stretchRect.height()); - SrcY = stretchRect.top() + stretchRect.height(); - SrcHeight = image->height() - (stretchRect.top() + stretchRect.height()); - } - - QRect dest(DestX, DestY, DestWidth, DestHeight); - QRect src(SrcX, SrcY, SrcWidth, SrcHeight); - painter.drawImage(dest, *image, src); - } -} - -QImage* HGImgView::createQImage() -{ - if (nullptr == m_image) - return nullptr; - - HGImageInfo info; - HGBase_GetImageInfo(m_image, &info); - - QImage::Format fmt = QImage::Format_Invalid; - if (info.type == HGBASE_IMGTYPE_BINARY) - fmt = QImage::Format_Mono; - else if (info.type == HGBASE_IMGTYPE_GRAY) - fmt = QImage::Format_Grayscale8; - else if (info.type == HGBASE_IMGTYPE_RGB) - fmt = QImage::Format_RGB888; - else if (info.type == HGBASE_IMGTYPE_RGBA) - fmt = QImage::Format_RGBA8888; - if (QImage::Format_Invalid == fmt) - { - return nullptr; - } - - HGByte* data = nullptr; - HGBase_GetImageData(m_image, &data); - QImage* img = new QImage(data, info.width, info.height, info.widthStep, fmt); - if (img->isNull()) - { - delete img; - return nullptr; - } - - if (img->format() != QImage::Format_Mono) - { - return img; - } - - QImage *newImg = new QImage(img->convertToFormat(QImage::Format_Grayscale8)); - delete img; - return newImg; -} - -void HGImgView::DrawScroll(QPainter &painter) -{ - // 滚动条背景 - QColor clrHScroll = qRgb(220, 220, 220); - QImage *imgHScroll = m_hScrollImage; - QColor clrVScroll = qRgb(220, 220, 220); - QImage *imgVScroll = m_vScrollImage; - QColor clrNullScroll = qRgb(255, 255, 255); - QImage *nullScrollImage = m_nullScrollImage; - - // 水平滑块 - QColor clrHScrollSlider = qRgb(180, 180, 180); - QImage *imgHScrollSlider = m_hScrollSliderImage[0]; - QRect hScrollSliderStretch = m_hScrollSliderImageStretch[0]; - if (MouseStatus_HScrollSlider == m_mousePressStatus) - { - clrHScrollSlider = qRgb(100, 100, 100); - imgHScrollSlider = m_hScrollSliderImage[2]; - hScrollSliderStretch = m_hScrollSliderImageStretch[2]; - } - else if (MouseStatus_HScrollLeft == m_mousePressStatus || MouseStatus_HScrollRight == m_mousePressStatus - || MouseStatus_HScroll == m_mousePressStatus - || MouseStatus_HScrollSlider == m_mouseMoveStatus || MouseStatus_HScroll == m_mouseMoveStatus - || MouseStatus_HScrollLeft == m_mouseMoveStatus || MouseStatus_HScrollRight == m_mouseMoveStatus) - { - clrHScrollSlider = qRgb(140, 140, 140); - imgHScrollSlider = m_hScrollSliderImage[1]; - hScrollSliderStretch = m_hScrollSliderImageStretch[1]; - } - - // 垂直滑块 - QColor clrVScrollSlider = qRgb(180, 180, 180); - QImage *imgVScrollSlider = m_vScrollSliderImage[0]; - QRect vScrollSliderStretch = m_vScrollSliderImageStretch[0]; - if (MouseStatus_VScrollSlider == m_mousePressStatus) - { - clrVScrollSlider = qRgb(100, 100, 100); - imgVScrollSlider = m_vScrollSliderImage[2]; - vScrollSliderStretch = m_vScrollSliderImageStretch[2]; - } - else if (MouseStatus_VScrollTop == m_mousePressStatus || MouseStatus_VScrollBottom == m_mousePressStatus - || MouseStatus_VScroll == m_mousePressStatus - || MouseStatus_VScrollSlider == m_mouseMoveStatus || MouseStatus_VScroll == m_mouseMoveStatus - || MouseStatus_VScrollTop == m_mouseMoveStatus || MouseStatus_VScrollBottom == m_mouseMoveStatus) - { - clrVScrollSlider = qRgb(140, 140, 140); - imgVScrollSlider = m_vScrollSliderImage[1]; - vScrollSliderStretch = m_vScrollSliderImageStretch[1]; - } - - // 水平左键 - QColor clrHScrollLeft = qRgb(220, 220, 220); - QImage *imgHScrollLeft = m_hScrollLeftImage[0]; - if (MouseStatus_HScrollLeft == m_mousePressStatus) - { - clrHScrollLeft = qRgb(140, 140, 140); - imgHScrollLeft = m_hScrollLeftImage[2]; - } - else if (MouseStatus_HScrollRight == m_mousePressStatus || MouseStatus_HScrollSlider == m_mousePressStatus - || MouseStatus_HScroll == m_mousePressStatus - || MouseStatus_HScrollSlider == m_mouseMoveStatus || MouseStatus_HScroll == m_mouseMoveStatus - || MouseStatus_HScrollLeft == m_mouseMoveStatus || MouseStatus_HScrollRight == m_mouseMoveStatus) - { - clrHScrollLeft = qRgb(180, 180, 180); - imgHScrollLeft = m_hScrollLeftImage[1]; - } - - // 水平右键 - QColor clrHScrollRight = qRgb(220, 220, 220); - QImage *imgHScrollRight = m_hScrollRightImage[0]; - if (MouseStatus_HScrollRight == m_mousePressStatus) - { - clrHScrollRight = qRgb(140, 140, 140); - imgHScrollRight = m_hScrollRightImage[2]; - } - else if (MouseStatus_HScrollLeft == m_mousePressStatus || MouseStatus_HScrollSlider == m_mousePressStatus - || MouseStatus_HScroll == m_mousePressStatus - || MouseStatus_HScrollSlider == m_mouseMoveStatus || MouseStatus_HScroll == m_mouseMoveStatus - || MouseStatus_HScrollLeft == m_mouseMoveStatus || MouseStatus_HScrollRight == m_mouseMoveStatus) - { - clrHScrollRight = qRgb(180, 180, 180); - imgHScrollRight = m_hScrollRightImage[1]; - } - - // 垂直上键 - QColor clrVScrollTop = qRgb(220, 220, 220); - QImage *imgVScrollTop = m_vScrollTopImage[0]; - if (MouseStatus_VScrollTop == m_mousePressStatus) - { - clrVScrollTop = qRgb(140, 140, 140); - imgVScrollTop = m_vScrollTopImage[2]; - } - else if (MouseStatus_VScrollSlider == m_mousePressStatus || MouseStatus_VScrollBottom == m_mousePressStatus - || MouseStatus_VScroll == m_mousePressStatus - || MouseStatus_VScrollSlider == m_mouseMoveStatus || MouseStatus_VScroll == m_mouseMoveStatus - || MouseStatus_VScrollTop == m_mouseMoveStatus || MouseStatus_VScrollBottom == m_mouseMoveStatus) - { - clrVScrollTop = qRgb(180, 180, 180); - imgVScrollTop = m_vScrollTopImage[1]; - } - - // 垂直下键 - QColor clrVScrollBottom = qRgb(220, 220, 220); - QImage *imgVScrollBottom = m_vScrollBottomImage[0]; - if (MouseStatus_VScrollBottom == m_mousePressStatus) - { - clrVScrollBottom = qRgb(140, 140, 140); - imgVScrollBottom = m_vScrollBottomImage[2]; - } - else if (MouseStatus_VScrollSlider == m_mousePressStatus || MouseStatus_VScrollTop == m_mousePressStatus - || MouseStatus_VScroll == m_mousePressStatus - || MouseStatus_VScrollSlider == m_mouseMoveStatus || MouseStatus_VScroll == m_mouseMoveStatus - || MouseStatus_VScrollTop == m_mouseMoveStatus || MouseStatus_VScrollBottom == m_mouseMoveStatus) - { - clrVScrollBottom = qRgb(180, 180, 180); - imgVScrollBottom = m_vScrollBottomImage[1]; - } - - if (m_hScroll) - { - if (nullptr == imgHScroll) - painter.fillRect(getHScrollPos(), clrHScroll); - else - DrawImage(painter, getHScrollPos(), imgHScroll, m_hScrollImageStretch); - - if (nullptr == imgHScrollLeft) - painter.fillRect(getHScrollLeftPos(), clrHScrollLeft); - else - painter.drawImage(getHScrollLeftPos(), *imgHScrollLeft); - - if (nullptr == imgHScrollRight) - painter.fillRect(getHScrollRightPos(), clrHScrollRight); - else - painter.drawImage(getHScrollRightPos(), *imgHScrollRight); - - if (nullptr == imgHScrollSlider) - painter.fillRect(getHScrollSliderPos(), clrHScrollSlider); - else - DrawImage(painter, getHScrollSliderPos(), imgHScrollSlider, hScrollSliderStretch); - } - - if (m_vScroll) - { - if (nullptr == imgVScroll) - painter.fillRect(getVScrollPos(), clrVScroll); - else - DrawImage(painter, getVScrollPos(), imgVScroll, m_vScrollImageStretch); - - if (nullptr == imgVScrollTop) - painter.fillRect(getVScrollTopPos(), clrVScrollTop); - else - painter.drawImage(getVScrollTopPos(), *imgVScrollTop); - - if (nullptr == imgVScrollBottom) - painter.fillRect(getVScrollBottomPos(), clrVScrollBottom); - else - painter.drawImage(getVScrollBottomPos(), *imgVScrollBottom); - - if (nullptr == imgVScrollSlider) - painter.fillRect(getVScrollSliderPos(), clrVScrollSlider); - else - DrawImage(painter, getVScrollSliderPos(), imgVScrollSlider, vScrollSliderStretch); - } - - if (m_hScroll && m_vScroll) - { - if (nullptr == nullScrollImage) - painter.fillRect(getNullScrollPos(), clrNullScroll); - else - painter.drawImage(getNullScrollPos(), *nullScrollImage); - } -} - -void HGImgView::reset() -{ - // 复位 - m_draging = false; - - m_operate = 0; - m_beginX = -1; - m_beginY = -1; -} - -void HGImgView::updateMoveStatusAndCursor() -{ - m_mouseMoveStatus = getMouseStatus(mapFromGlobal(QCursor::pos())); - - if (0 != m_operate) - { - setCursor(Qt::ClosedHandCursor); - } - else if (MouseStatus_Null != m_mousePressStatus || m_draging) - { - setCursor(Qt::ArrowCursor); - } - else - { - QRect rcWnd(0, 0, this->width(), this->height()); - if (nullptr == m_image || !m_showImage - || !m_showColorInfo || MouseStatus_Null != m_mouseMoveStatus - || !rcWnd.contains(mapFromGlobal(QCursor::pos()))) - { - setCursor(Qt::ArrowCursor); - } - else - { - HGImageInfo info; - HGBase_GetImageInfo(m_image, &info); - - int xShow = mapFromGlobal(QCursor::pos()).x() - m_showRect.left; - int yShow = mapFromGlobal(QCursor::pos()).y() - m_showRect.top; - int xImg = xShow * (int)info.width / (m_showRect.right - m_showRect.left); - int yImg = yShow * (int)info.height / (m_showRect.bottom - m_showRect.top); - - if (xImg >= 0 && xImg < (int)info.width && yImg >= 0 && yImg < (int)info.height) - { - setCursor(Qt::CrossCursor); - } - else - { - setCursor(Qt::ArrowCursor); - } - } - } -} - -HGImgView::MouseStatus HGImgView::getMouseStatus(const QPoint &pt) -{ - MouseStatus mouseStatus = MouseStatus_Null; - if (MouseStatus_Null != m_mousePressStatus || 0 != m_operate || m_draging) - { - return mouseStatus; - } - - if (!m_mouseOn) - { - return mouseStatus; - } - - if (m_hScroll && m_vScroll) - { - if (getHScrollSliderPos().contains(pt)) - mouseStatus = MouseStatus_HScrollSlider; - else if (getHScrollLeftPos().contains(pt)) - mouseStatus = MouseStatus_HScrollLeft; - else if (getHScrollRightPos().contains(pt)) - mouseStatus = MouseStatus_HScrollRight; - else if (getHScrollPos().contains(pt)) - mouseStatus = MouseStatus_HScroll; - else if (getVScrollSliderPos().contains(pt)) - mouseStatus = MouseStatus_VScrollSlider; - else if (getVScrollTopPos().contains(pt)) - mouseStatus = MouseStatus_VScrollTop; - else if (getVScrollBottomPos().contains(pt)) - mouseStatus = MouseStatus_VScrollBottom; - else if (getVScrollPos().contains(pt)) - mouseStatus = MouseStatus_VScroll; - else if (getNullScrollPos().contains(pt)) - mouseStatus = MouseStatus_NullScroll; - } - else if (m_hScroll && !m_vScroll) - { - if (getHScrollSliderPos().contains(pt)) - mouseStatus = MouseStatus_HScrollSlider; - else if (getHScrollLeftPos().contains(pt)) - mouseStatus = MouseStatus_HScrollLeft; - else if (getHScrollRightPos().contains(pt)) - mouseStatus = MouseStatus_HScrollRight; - else if (getHScrollPos().contains(pt)) - mouseStatus = MouseStatus_HScroll; - } - else if (!m_hScroll && m_vScroll) - { - if (getVScrollSliderPos().contains(pt)) - mouseStatus = MouseStatus_VScrollSlider; - else if (getVScrollTopPos().contains(pt)) - mouseStatus = MouseStatus_VScrollTop; - else if (getVScrollBottomPos().contains(pt)) - mouseStatus = MouseStatus_VScrollBottom; - else if (getVScrollPos().contains(pt)) - mouseStatus = MouseStatus_VScroll; - } - - return mouseStatus; -} - -QRect HGImgView::getHScrollLeftPos() -{ - assert(m_hScroll); - - return QRect(0, this->height() - m_scrollSize, m_scrollSize, m_scrollSize); -} - -QRect HGImgView::getHScrollRightPos() -{ - assert(m_hScroll); - - if (!m_vScroll) - { - return QRect(this->width() - m_scrollSize, this->height() - m_scrollSize, m_scrollSize, m_scrollSize); - } - - return QRect(this->width() - 2 * m_scrollSize, this->height() - m_scrollSize, m_scrollSize, m_scrollSize); -} - -QRect HGImgView::getHScrollPos() -{ - assert(m_hScroll); - - if (!m_vScroll) - { - return QRect(0, this->height() - m_scrollSize, this->width(), m_scrollSize); - } - - return QRect(0, this->height() - m_scrollSize, this->width() - m_scrollSize, m_scrollSize); -} - -QRect HGImgView::getHScrollSliderPos() -{ - assert(m_hScroll); - - QRect rect; - rect.setY(this->height() - m_scrollSize); - rect.setHeight(m_scrollSize); - if (!m_vScroll) - { - int rollTotalLen = this->width() - 2 * m_scrollSize; - int rollLeft = round((double)rollTotalLen * (-m_showRect.left) / (double)(m_showRect.right - m_showRect.left)); - int rollRight = round((double)rollTotalLen * (-m_showRect.left + this->width()) / (double)(m_showRect.right - m_showRect.left)); - int rollLen = rollRight - rollLeft; - if (rollLen < m_minScrollSliderSize) - { - rollLen = m_minScrollSliderSize; - rollLeft = round((double)(rollTotalLen - m_minScrollSliderSize) * (-m_showRect.left) / (double)(m_showRect.right - m_showRect.left - this->width())); - } - - rect.setX(rollLeft + m_scrollSize); - rect.setWidth(rollLen); - } - else - { - int rollTotalLen = this->width() - 3 * m_scrollSize; - int rollLeft = round((double)rollTotalLen * (-m_showRect.left) / (double)(m_showRect.right - m_showRect.left)); - int rollRight = round((double)rollTotalLen * (-m_showRect.left + this->width() - m_scrollSize) / (double)(m_showRect.right - m_showRect.left)); - int rollLen = rollRight - rollLeft; - if (rollLen < m_minScrollSliderSize) - { - rollLen = m_minScrollSliderSize; - rollLeft = round((double)(rollTotalLen - m_minScrollSliderSize) * (-m_showRect.left) / (double)(m_showRect.right - m_showRect.left - this->width() + m_scrollSize)); - } - - rect.setX(rollLeft + m_scrollSize); - rect.setWidth(rollLen); - } - - return rect; -} - -QRect HGImgView::getVScrollTopPos() -{ - assert(m_vScroll); - - return QRect(this->width() - m_scrollSize, 0, m_scrollSize, m_scrollSize); -} - -QRect HGImgView::getVScrollBottomPos() -{ - assert(m_vScroll); - - if (!m_hScroll) - { - return QRect(this->width() - m_scrollSize, this->height() - m_scrollSize, m_scrollSize, m_scrollSize); - } - - return QRect(this->width() - m_scrollSize, this->height() - 2 * m_scrollSize, m_scrollSize, m_scrollSize); -} - -QRect HGImgView::getVScrollPos() -{ - assert(m_vScroll); - - if (!m_hScroll) - { - return QRect(this->width() - m_scrollSize, 0, m_scrollSize, this->height()); - } - - return QRect(this->width() - m_scrollSize, 0, m_scrollSize, this->height() - m_scrollSize); -} - -QRect HGImgView::getVScrollSliderPos() -{ - assert(m_vScroll); - - QRect rect; - rect.setX(this->width() - m_scrollSize); - rect.setWidth(m_scrollSize); - if (!m_hScroll) - { - int rollTotalLen = this->height() - 2 * m_scrollSize; - int rollTop = round((double)rollTotalLen * (-m_showRect.top) / (double)(m_showRect.bottom - m_showRect.top)); - int rollBottom = round((double)rollTotalLen * (-m_showRect.top + this->height()) / (double)(m_showRect.bottom - m_showRect.top)); - int rollLen = rollBottom - rollTop; - if (rollLen < m_minScrollSliderSize) - { - rollLen = m_minScrollSliderSize; - rollTop = round((double)(rollTotalLen - m_minScrollSliderSize) * (-m_showRect.top) / (double)(m_showRect.bottom - m_showRect.top - this->height())); - } - - rect.setY(rollTop + m_scrollSize); - rect.setHeight(rollLen); - } - else - { - int rollTotalLen = this->height() - 3 * m_scrollSize; - int rollTop = round((double)rollTotalLen * (-m_showRect.top) / (double)(m_showRect.bottom - m_showRect.top)); - int rollBottom = round((double)rollTotalLen * (-m_showRect.top + this->height() - m_scrollSize) / (double)(m_showRect.bottom - m_showRect.top)); - int rollLen = rollBottom - rollTop; - if (rollLen < m_minScrollSliderSize) - { - rollLen = m_minScrollSliderSize; - rollTop = round((double)(rollTotalLen - m_minScrollSliderSize) * (-m_showRect.top) / (double)(m_showRect.bottom - m_showRect.top - this->height() + m_scrollSize)); - } - - rect.setY(rollTop + m_scrollSize); - rect.setHeight(rollLen); - } - - return rect; -} - -QRect HGImgView::getNullScrollPos() -{ - assert(m_hScroll && m_vScroll); - return QRect(this->width() - m_scrollSize, this->height() - m_scrollSize, m_scrollSize, m_scrollSize); -} - -void HGImgView::Show() -{ - repaint(); -} diff --git a/app/scanner/HGImgView.h b/app/scanner/HGImgView.h deleted file mode 100644 index 73f95813..00000000 --- a/app/scanner/HGImgView.h +++ /dev/null @@ -1,146 +0,0 @@ -#ifndef __HGIMGVIEW_H__ -#define __HGIMGVIEW_H__ - -#include "base/HGDef.h" -#include "base/HGBaseErr.h" -#include "base/HGImage.h" -#include - -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__ */ diff --git a/app/scanner/HGUIGlobal.cpp b/app/scanner/HGUIGlobal.cpp deleted file mode 100644 index fd3dbbf1..00000000 --- a/app/scanner/HGUIGlobal.cpp +++ /dev/null @@ -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 -} diff --git a/app/scanner/HGUIGlobal.h b/app/scanner/HGUIGlobal.h deleted file mode 100644 index d1da4d16..00000000 --- a/app/scanner/HGUIGlobal.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef __HGUIGLOBAL_H__ -#define __HGUIGLOBAL_H__ - -#include - -QString getStdFileName(const QString &fileName); - -std::string getStdString(const QString &str); - -#endif /* __HGUIGLOBAL_H__ */ diff --git a/app/scanner/Scanner_resource.qrc b/app/scanner/Scanner_resource.qrc deleted file mode 100644 index 3b8d875b..00000000 --- a/app/scanner/Scanner_resource.qrc +++ /dev/null @@ -1,114 +0,0 @@ - - - etc/qt.conf - - - Scanner_zh_CN.qm - qt_zh_CN.qm - Scanner_zh_EN.qm - - - image_rsc/action/btnEmailScanedImages.png - image_rsc/action/btnFitWindow.png - image_rsc/action/btnFitWindowWidth.png - image_rsc/action/btnHelp.png - image_rsc/action/btnNext.png - image_rsc/action/btnNextPage.png - image_rsc/action/btnOriginalSize.png - image_rsc/action/btnPrevious.png - image_rsc/action/btnPreviousPage.png - image_rsc/action/btnRotateLeft.png - image_rsc/action/btnRotateRight.png - image_rsc/action/btnSaveScanedImages.png - image_rsc/action/btnScan.png - image_rsc/action/btnScannerSetting.png - image_rsc/action/btnZoomIn.png - image_rsc/action/btnZoomOut.png - image_rsc/actions/admin.png - image_rsc/actions/close.png - image_rsc/actions/contrast.png - image_rsc/actions/curve.png - image_rsc/actions/cut.png - image_rsc/actions/fullscreen.png - image_rsc/actions/help.png - image_rsc/actions/nextfile.png - image_rsc/actions/nextpage.png - image_rsc/actions/open.png - image_rsc/actions/previousfile.png - image_rsc/actions/previouspage.png - image_rsc/actions/print.png - image_rsc/actions/redo.png - image_rsc/actions/rotate-anticlockwise.png - image_rsc/actions/rotate-clockwise.png - image_rsc/actions/save.png - image_rsc/actions/saveAs.png - image_rsc/actions/scan.png - image_rsc/actions/settings.png - image_rsc/actions/sortpages.png - image_rsc/actions/undo.png - image_rsc/actions/zoom-fitscreen.png - image_rsc/actions/zoom-fitwidth.png - image_rsc/actions/zoom-in.png - image_rsc/actions/zoom-origin.png - image_rsc/actions/zoom-out.png - image_rsc/adjust/Img_BightnessReduce.png - image_rsc/adjust/Img_BrightnessIncrease.png - image_rsc/adjust/Img_ContrastIncrease.png - image_rsc/adjust/Img_ContrastReduce.png - image_rsc/example/example_arrow.png - image_rsc/example/example_black_after.png - image_rsc/example/example_black_before.png - image_rsc/example/example_crop_after.png - image_rsc/example/example_deskew_after.png - image_rsc/example/example_deskew_before.png - image_rsc/example/example_fillblack_before.png - image_rsc/example/example_fillblack_concave.png - image_rsc/example/example_fillblack_convex.png - image_rsc/example/example_fillcolor_auto.png - image_rsc/example/example_fillcolor_before.png - image_rsc/example/example_fillcolor_default.png - image_rsc/fullscreen/btnNext.png - image_rsc/fullscreen/btnPrevious.png - image_rsc/logo/auge_logo.ico - image_rsc/logo/Hanvon_logo1.ico - image_rsc/logo/Hanvon_logo2.ico - image_rsc/logo/HG_Logo.png - image_rsc/logo/HUAGO-LOGO-for UI.jpg - image_rsc/logo/HUAGO-LOGO-for UI.png - image_rsc/logo/Lanxum_logo.ico - image_rsc/logo/Cumtenn_logo.ico - image_rsc/logo/logo.ico - image_rsc/logo/NoBrand_logo.ico - image_rsc/logo/RightWay_logo.ico - image_rsc/logo/waiting.gif - image_rsc/statusbar/statusBar_admin.png - image_rsc/scroll/bottom_Hot.png - image_rsc/scroll/bottom_Normal.png - image_rsc/scroll/bottom_Push.png - image_rsc/scroll/defItemImage.png - image_rsc/scroll/hScrollImage.png - image_rsc/scroll/hScrollSlider_Hot.png - image_rsc/scroll/hScrollSlider_Normal.png - image_rsc/scroll/hScrollSlider_Push.png - image_rsc/scroll/left_Hot.png - image_rsc/scroll/left_Normal.png - image_rsc/scroll/left_Push.png - image_rsc/scroll/nullScrollImage.png - image_rsc/scroll/right_Hot.png - image_rsc/scroll/right_Normal.png - image_rsc/scroll/right_Push.png - image_rsc/scroll/top_Hot.png - image_rsc/scroll/top_Normal.png - image_rsc/scroll/top_Push.png - image_rsc/scroll/vScrollImage.png - image_rsc/scroll/vScrollSlider_Hot.png - image_rsc/scroll/vScrollSlider_Normal.png - image_rsc/scroll/vScrollSlider_Push.png - image_rsc/action/btnEdit.png - image_rsc/logo/Microtek_logo.ico - image_rsc/logo/uniscan.ico - image_rsc/actions/imageEdit.png - image_rsc/actions/scanInto.png - image_rsc/logo/deli.ico - - diff --git a/app/scanner/Scanner_zh_CN.qm b/app/scanner/Scanner_zh_CN.qm deleted file mode 100644 index 9ac59006..00000000 Binary files a/app/scanner/Scanner_zh_CN.qm and /dev/null differ diff --git a/app/scanner/Scanner_zh_CN.ts b/app/scanner/Scanner_zh_CN.ts deleted file mode 100644 index 70991d52..00000000 --- a/app/scanner/Scanner_zh_CN.ts +++ /dev/null @@ -1,3797 +0,0 @@ - - - - - CutPaperTool - - - 自定义扫描区域 - - - - - 纸张尺寸: - - - - - A4 - - - - - (210*297) - - - - - DPI(像素/英寸): - - - - - 200 - 0×0×0 {200?} - - - - 单位: - - - - - 毫米(mm) - - - - - 英寸(in) - - - - - 像素(px) - - - - - 初始化选择区域 - - - - - x: - - - - - - - - mm - - - - - y: - - - - - w: - - - - - h: - - - - - Dialog_Admin - - - Account sign in - 用户登录 - - - - Account: - 用户: - - - - Administrator - 管理员 - - - - password: - 密码: - - - - Show password - 显示密码 - - - - Sign In - 登录 - - - - Cancel - 取消 - - - - Type password - 输入密码 - - - - Warning - 警告 - - - - Password incorrect. Please try again. - 密码错误,请再次输入 - - - - Dialog_AquireInto - - - Batch scanning - 批量扫描 - - - - configuration scheme management - 配置方案管理 - - - - existing configuration scheme - existing configuration scheme: - 现有配置方案: - - - - delete all configurations - 删除所有配置方案 - - - confgiuration information: - 配置信息: - - - - change name - 重命名配置方案 - - - - delete - 删除配置方案 - - - apply - 应用 - - - - found scheme - 新建配置方案 - - - - Restore Defaults - 恢复默认配置 - - - - Directory - 目录 - - - - ... - - - - - Use subfolder based on current date - 使用当前日期建立子文件夹 - - - - Use subfolder based on blank pages - 按照空白页建立子文件夹 - - - - Use subfolder based on image color type - 按照图片颜色类型建立子文件夹 - - - - File name - 文件名 - - - - File name index - 文件索引 - - - - Start index - 开始索引 - - - - Digit(s) - 数字 - - - - 1 - - - - - 2 - - - - - 3 - - - - - 4 - - - - - 5 - - - - - e.g. 'HGScan001' - 例如 “HGScan001” - - - - Even and odd pages - 偶数和奇数页 - - - - Odd pages - 奇数页 - - - - Even pages - 偶数页 - - - - Format - 格式 - - - - JPG - JPG / 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) - - - - - Compression option - 压缩选项 - - - - Save as multipages (TIFF/PDF/OFD/GIF) - 多页保存(TIFF/PDF/OFD/GIF) - - - - 用户自定义页数 - 用户自定义页数 - - - Save as multipages (TIFF/PDF/OFD) - 多页保存(TIFF/PDF/OFD) - - - - 所有页 - 所有页 - - - defaultCfg - 默认配置 - - - - - default scheme - 默认配置方案 - - - - - - - e.g. '%1%2' - 例如.“%1%2” - - - - ok - 确定 - - - - cancel - 取消 - - - - Browse directory - 文件夹路径 - - - - - tips - 提示 - - - - - The configuration scheme already exists - 配置方案已存在 - - - - Dialog_ClrCache - - - Dialog - 缓存设置 - - - - Cache path: - 缓存路径: - - - - ... - - - - setCachePath - 确认设置 - - - - Cache occupied space: - 缓存占用空间: - - - - - 0 - 0×0×0 {0?} - - - - B - B - - - - (0 Byte) - (0 Byte) - - - - Number of files: - 文件数量: - - - - Clear Cache - 清除缓存 - - - - ok - 确定 - - - - cancel - 取消 - - - Close - 关闭 - - - - Question - 询问 - - - Main window contains temporary files, clear cache would remove all of them. -Continue to clear? - 主窗口中包含临时文件,清除缓存将会移除这些文件。 -继续清除? - - - - Main window contains temporary files, clear cache would remove all of them. - Continue to clear? - 主窗口中包含临时文件,清除缓存将会移除这些文件。 -继续清除? - - - yes - 确定 - - - no - 取消 - - - - - Information - 消息 - - - - No cached file is available - 暂无缓存文件 - - - - Cache clear successfully. - 缓存清除成功。 - - - - Warning - 警告 - - - - Cache clear failed or incompletely clear. - 缓存清除失败或者未清除干净。 - - - - Browse directory - 文件夹路径 - - - - - tips - 提示 - - - - directory can not be empty - 文件目录不能为空 - - - - create cachePath failed: - 创建缓存路径失败: - - - - Dialog_Export - - ok - 确定 - - - cancel - 取消 - - - - Export - 导出 - - - - -Input is not valid. -Page range will be "Chosen Pages". - - 非法输入。 -页面范围将是“所选页面。默认切换“被选页码 - - - - Ocr type: - OCR类型: - - - - Compression Option - 压缩选项 - - - - Page Range - 页码范围 - - - - Chosen Pages - 被选页码 - - - - All Pages - 所有页码 - - - - Nominate Pages(example:1,3,6 or 3-6) - 指定页码(例如:1,3,6 或者3-6) - - - - Page: - 页码 - - - - Save as multipages (TIFF/PDF/OFD/GIF) - Save as multipages (TIFF/PDF/OFD) - 多页保存(TIFF/PDF/OFD/GIF) - - - - - - Input is not valid. -Page range will be 'Chosen Pages'. - 输入无效。 -页码范围将是“被选页码” - - - - English - 英语 - - - - Simplified Chinese - 中文(简体) - - - - Traditional Chinese - 中文(繁体) - - - - Japanese - 日文 - - - - Korean - 韩文 - - - - Dialog_ExportImageFile - - - Dialog - 导出进度 - - - - stop - 停止导出 - - - - export failed: - 导出失败: - - - - tip - 提示 - - - - export succeed - 导出完成 - - - Insufficient access rights - 文件访问权限不足 - - - Ocr processing failed - OCR功能处理失败 - - - ok - 确定 - - - - Dialog_Feedback - - - Dialog - - - - - feedback: - 意见反馈: - - - - contact: - 联系方式: - - - - submit - 提交 - - - - cancel - 取消 - - - - feedback - 意见反馈 - - - - Please leave your valuable comments and suggestions (required field). - 请留下您的意见与建议(必填)。 - - - - Please leave your phone number, QQ or email address (required field). - 请留下您的电话、QQ或者邮箱等联系方式(必填)。 - - - - - - error - 错误 - - - - Comments and suggestions cannot be empty. - 意见与建议不能为空哦 - - - - The contact information column cannot be empty. - 联系方式一栏不能为空哦 - - - - tip - 提示 - - - - submit succeed. - 提交成功 - - - - submit failed. - 提交失败 - - - - Dialog_FullScreen - - - Full Screen - 全屏显示 - - - - Ctrl+Right - - - - - Left - - - - - Right - - - - - Ctrl+Left - - - - - Exit fullscreen - 按ESC退出全屏 - - - - Dialog_ImageEditor - - - Dialog_ImageEditor - 图像编辑 - - - - rect - 矩形 - - - - Rect - 矩形 - - - - ellipse - 椭圆 - - - - Ellipse - 椭圆 - - - - line - 直线 - - - - Line - 直线 - - - - Pen - 画笔 - - - - arrow - 箭头 - - - - Arrow - 箭头 - - - - text - 文字 - - - - Text - 文字 - - - zoomIn - 放大 - - - - 1:1 - 1比1 - - - zoomOut - 缩小 - - - - Color - 彩色 - - - - color - 彩色 - - - - LineWidth - 线宽 - - - - 1 pix - 1 像素 - - - - 3 pix - 3 像素 - - - - 5 pix - 5 像素 - - - - 8 pix - 8 像素 - - - - TextSize - 文字大小 - - - 6 - 6 - - - 7 - 7 - - - 8 - 8 - - - 9 - 9 - - - - 72 - 10 - 72 - - - - 96 - 11 - 96 - - - - 128 - 12 - 128 - - - - 160 - 14 - 160 - - - 16 - 16 - - - 18 - 18 - - - - 20 - 20 - - - 22 - 22 - - - 24 - 24 - - - - 26 - 26 - - - 28 - 28 - - - - 36 - 36 - - - - 48 - 48 - - - - 200 - 200 - - - - zoomin - - - - - Zoomin - 放大 - - - - fit - - - - - Fit - 还原 - - - - 100% - 0×0×0 {100%?} - - - - zoomout - - - - - Zoomout - 缩小 - - - - undo - 撤销 - - - - Undo - 撤销 - - - - Ctrl+Z - - - - - ok - 确定 - - - - Ok - 确定 - - - - cancel - 取消 - - - - Cancel - 取消 - - - - Dialog_ImageInfo - - - Image information - 图像信息 - - - - ok - 确定 - - - - File - 文件 - - - - Image - 图像 - - - - None - - - - - Dialog_ImgProc_Adjust - - - Adjust - 亮度/对比度/伽马 - - - - Show preview - 显示缩略图 - - - - Before - 处理前 - - - - After - 处理后 - - - - Apply to image - 应用到图像 - - - - ok - 确定 - - - - cancel - 取消 - - - - restore default - 恢复默认 - - - - Dialog_ImgProc_AutoCrop - - - - Auto crop - 自动裁剪 - - - - Auto correct skew - 歪斜校正 - - - - Fill black frame type - 背景填充方式 - - - - Convex polygon - 凸多边形 - - - - Concave polygon - 凹多边形 - - - - Auto Color - 自适应文稿底色 - - - - Default Color - 白色 - - - - Advanced parameters - 高级参数设置 - - - - Threshold - 阈值 - - - - Anti background noise - 背景抗噪 - - - - Edge indent - 边缘缩进 - - - - before - 处理前 - - - - after - 处理后 - - - - Image crop - 裁剪/纠偏/消除黑框 - - - - ok - 确定 - - - - cancel - 取消 - - - - restore default - 恢复默认 - - - - Dialog_Input - - - Dialog - - - - - 输入: - - - - - Ok - 确定 - - - - Cancel - 取消 - - - - configuration scheme name change - 配置改名 - - - - tips - 提示 - - - - The content can not be empty - 内容不能为空 - - - new name can not be empty - 新命名不可为空 - - - - Dialog_InsertIndex - - - Insert index selection - 插入所选项 - - - - Insert location - 插入位置 - - - - Before first page - 第一页之前 - - - - Before current page - 当前页之前 - - - - After current page - 当前页之后 - - - - After last page - 最后一页之后 - - - - ok - 确定 - - - - cancel - 取消 - - - - Dialog_LogManager - - - Dialog - 日志导出 - - - - Directory... - 目录... - - - - File Type: - 文件类型: - - - - All(*.*) - 所有文件(*.*) - - - - Image(*.jpg,*.bmp,*.png,*.tif) - 图像文件(*.jpg,*.bmp,*.png,*.tif) - - - - PDF(*.pdf) - PDF(*.pdf) - - - - Text(*.txt) - 文本(*.txt) - - - - Config(*.ini,*.xml) - 配置文件(*.ini,*.xml) - - - - Website(*.html) - 网页(*.html) - - - - HGlog(*.HGLog) - 华高日志(*.HGLog) - - - - Clear - 清空 - - - - Export... - 导出... - - - - Cancel - 取消 - - - - Warning - 警告 - - - - Please select file in the list. - 请选择列表中的文件。 - - - - Choose saving path - 选择保存路径 - - - - - Information - 消息 - - - - Log files export finished. - 日志文件导出完成。 - - - - Question - 询问 - - - - All log files will be cleared. -Continue to clear? - 所有日志文件将被清除。 -继续清空吗? - - - - All log files cleared. - 已清除所有日志文件。 - - - - Dialog_MoveTo - - - move to - 移动到 - - - - target index: - 目标位置: - - - insert pos: - 插入位置: - - - - Dialog_MultiRotate - - - Multiple rotation - 多页旋转 - - - - Rotation - 旋转 - - - - 90° - 旋转90° - - - - 180° - 旋转180° - - - - -90° - 旋转-90° - - - - Pages - 页码 - - - - Current page - 当前页 - - - - Selected pages - 所选页 - - - - All odd pages - 所有奇数页 - - - - All even pages - 所有偶数页 - - - - All pages - 所有页 - - - - Attentions: -This operation will NOT rotate the files that may contain multiple pages, such as .pdf, .tif, etc. - 注意: -此操作不会旋转可能包含多页的文件,例如PDF、TIFF等。 - - - - ok - 确定 - - - - cancel - 取消 - - - - Dialog_MultiRotateImageFile - - - Dialog - 多页旋转进度 - - - - stop - 停止多页旋转 - - - - operation success - 操作成功 - - - - multirotate operation failed: - 多页旋转操作失败: - - - - tip - 提示 - - - ok - 确定 - - - - Dialog_OpenImageIndex - - - Open Page - 跳转至 - - - - pageIndex: - 页数: - - - - ok - 确定 - - - - cancel - 取消 - - - - Dialog_PasswordChange - - - Change password - 用户密码修改 - - - - Old password: - 旧密码: - - - - New password: - 新密码: - - - - Confirm new password: - 确认新密码: - - - - Show password - 显示密码 - - - - Password only allowed to use numbers, English and special characters. -Password length should between 8-20 charactors. - 密码只允许使用数字、英文和特殊字符。 -密码长度应在8-20个字符之间。 - - - - OK - 确定 - - - - Cancel - 取消 - - - - Type old password - 输入旧密码 - - - - Type new password - 输入新密码 - - - - Retype new password - 确认新密码 - - - - - Warning - 警告 - - - - Old password incorrect. -Please try again. - 旧密码错误。请重试。 - - - - New password and confirm password are not matched. -Please make sure the two passwords are the same. - 新密码和确认密码不匹配。 -请确保两个密码相同。 - - - - - - Password only allowed to use numbers, English and special characters. - 新密码只允许使用数字、英文和特殊字符。 - - - - Dialog_SaveAs - - - Save As - 另存为 - - - - Compression Option - 压缩选项 - - - - Use subfolder based on current date - 使用当前日期建立子文件夹 - - - - Ocr type: - OCR类型: - - - - English - 英语 - - - - Simplified Chinese - 中文(简体) - - - - Traditional Chinese - 中文(繁体) - - - - Japanese - 日文 - - - - Korean - 韩文 - - - - Dialog_SaveMessageBox - - - Dialog - 询问 - - - - TextLabel - - - - - Yes - - - - - Yes to All - - - - - No - - - - - save, do not remind again - 保存并不再提醒 - - - - modified, save it? - 图像已被修改,是否保存修改? - - - - Dialog_SaveQuality - - Save Option - 压缩质量设置 - - - ok - 确定 - - - cancel - 取消 - - - - Dialog_WriteSettings - - - Write Settings - 写入设置 - - - - Compression for black&white picture - 黑白图片 - - - - - None - - - - - - LZW - LZW - - - - CCITT G4 - CCITT G4 - - - - Compression for color picture - 彩色图片 - - - - JPEG - JPEG - - - - Quality - 质量 - - - - Lowest - - - - - Best - - - - - Dialog_updateProgress - - - Dialog - 安装包下载中... - - - - stop - 停止 - - - - Dialog_upgrade - - - Dialog - - - - - detect result. versionNum: - - - - - upgrade the latest version - 升级到最新版本 - - - select version - 选择其他版本 - - - Detected installable versions: - 检测到可安装版本: - - - install - 安装 - - - cancel - 取消 - - - - upgrade online - 检查更新 - - - upgrade contents: - 升级内容: - - - bug description: - 错误描述: - - - bug description: - - 错误描述: - - - - - upgrade contents: - - 更新内容: - - - - -bug description: - - -错误描述: - - - - - The current version is the latest! The current version number is : - 当前为最新版本!版本号为: - - - - - Discover the new version : - 发现新版本: - - - - - ,the current version is : - ,当前版本为: - - - tip - 提示 - - - Already in current version - 当前版本已安装! - - - - Dialog_upgradeFirmware - - - Dialog - - - - - gif - - - - - text - 文字 - - - - upgrade - 更新升级 - - - - firmware upgrade in progress, please wait... - 设备固件自动更新升级中,请稍候... - - - - Dialog_wrong_img - - - Dialog - - - - - GraphicsScene - - - SongTi - 宋体 - - - - HGImgThumb - - - - tips - 提示 - - - - unsupported file format - 拖拽仅支持jpg、bmp、png、pnm、tif/tiff、gif、pdf和ofd格式 - - - - file have been loaded - 文件已经加载! - - - - file have been loaded, do you want to move to end? - 文件已经加载,是否将其移动到末尾? - - - - file have been loaded, do you want to move to specified location? - 文件已经加载,是否将其移动到指定位置? - - - - - Question - 提示 - - - - some files have been loaded, do you want to move to end? - 有文件已经加载,是否将其移动到末尾? - - - - some files have been loaded, do you want to move to specified location? - 有文件已经加载,是否将其移动到指定位置? - - - some files have been loaded, do you want to move? - 有图片已经被打开,是否移动这些图片的位置? - - - yes - - - - no - - - - - HGImgView - - tips - 提示 - - - unsupported file format - 拖拽仅支持jpg、bmp、png、tif/tiff、pdf和ofd格式 - - - - MainWindow - - - MainWindow - 华高扫描软件 - - - - menu_file - 文件 - - - - menu_scan - 扫描 - - - - menu_view - 视图 - - - - menu_Auto_Image_Size - menuAuto_Image_Size - 自动图片尺寸 - - - - menu_page - 页面 - - - - menu_multiPages - 多页 - - - - menu_image - 图像 - - - - menuRotate - 旋转 - - - - menu_user - 用户 - - - - menu_info - 信息 - - - - menu_device - 设备 - - - - toolBar - 工具栏 - - - - act_open - 打开... - - - - act_insert - 插入本地文件... - - - - act_save - 保存 - - - - act_saveAs - 另存为... - - - - act_Export - 导出... - - - - act_closeFile - 关闭选中项 - - - - act_closeAll - 关闭所有项 - - - - act_imageInfo - 图像信息 - - - - act_exit - 退出 - - - - act_scannerSettings - 扫描设置... - - - - act_acquire - 扫描 - - - - act_acquireSingle - 扫描单张 - - - - - act_acquireInto - 扫描至... - - - - act_fullscreen - 全屏显示 - - - - act_fitWindowSize - 适应视图框尺寸 - - - - act_fitWindowWidth - 适应视图框宽度 - - - - act_realSize - 真实大小 - - - - act_zoomIn - 放大 - - - - act_zoomOut - 缩小 - - - - act_toolBar - 工具栏 - - - - act_statusBar - 状态栏 - - - - act_thumbnailBar - 缩略图栏 - - - - act_colorInfo - 色彩信息 - - - - act_previous - 上一张 - - - - act_next - 下一张 - - - - act_first - 第一张 - - - - act_last - 最后一张 - - - - act_openPageNum - 跳转至... - - - - act_previousPage - 上一页 - - - - act_nextPage - 下一页 - - - - act_firstPage - 第一页 - - - - act_lastPage - 最后一页 - - - - act_adjust - 亮度/对比度/伽马... - - - - act_90Left - 左旋转90度 - - - - act_90Right - 右旋转90度 - - - - act_180 - 旋转180度 - - - - act_multiRotate - 多页旋转... - - - - act_autoCrop - 裁剪/纠偏/消除黑框... - - - - act_signIn - 登录... - - - - act_passwordChange - 密码修改... - - - - act_signOut - 登出 - - - - act_log - 日志管理... - - - - act_clrCache - 缓存设置... - - - - act_consume - 耗材状态... - - - - act_help - 帮助 - - - - act_about - 关于... - - - - act_insertFromScanner - 从扫描插入... - - - - act_clearRoller - 清除滚轴计数 - - - - act_imageEdit - 图像编辑... - - - - act_sortPages - 书籍排序 - - - - act_autoSave - 自动保存 - - - - act_update - 检查更新... - - - - act_feedback - 意见反馈... - - - - act_device_log - 导出设备日志 - - - - act_driver_log - 导出驱动日志 - - - - act_deleteFile - 删除选中项 - - - - act_enhanceText - 文本增强 - - - - HuaGoScan - 华高扫描软件 - - - - Grid - 多列显示 - - - - Move To... - 移动到... - - - - Insert files - 插入文件 - - - - - - nodevice - 没有发现扫描仪 - - - - - - - - Question - 询问 - - - - modified, save it? - 图像已被修改。 -是否保存修改? - - - - file lost, remove it? - 文件已丢失,是否删除? - - - already connected - 已连接 - - - - disconnected - 已断开连接 - - - %1/%2%3.%4 - %1/%2%3.%4 - - - scan starting... - 开始扫描... - - - scan finished - 扫描完成 - - - - Clear, then start scan - 清空并启动扫描 - - - - Do NOT clear, then start scan - 不清空并启动扫描 - - - - Already exist images in image list. -Do you want to clear? - 图像列表中已存在图像。 -是否清空? - - - Information - 消息 - - - Insufficient disk space - 磁盘空间不足,请删除不需要的文件,以保证有足够的空间 - - - - Open images - 打开图片 - - - - Insert images - 插入图片 - - - info - 信息 - - - save failed - 保存失败 - - - - binary - 黑白 - - - - gray - 256级灰度 - - - - rgb - 24位彩色 - - - - - - - - - - - - - - - Please wake up the device manually - 请手动唤醒设备 - - - - UniScan - 紫光扫描软件 - - - - Scan - 扫描 - - - - - default scheme - 默认配置方案 - - - - thumbnailBar enabled - 显示缩略图栏 - - - - thumbnailBar hidden - 隐藏缩略图栏 - - - - cancel - 取消 - - - - - - save succeed - 保存成功 - - - - - find savePath in thumbnail - 图片名在列表中已存在 - - - - Please select at least one picture before export - 请至少选中一张图片再进行导出 - - - - File name - 文件名 - - - - File path - 文件路径 - - - - File size - 文件大小 - - - - Creation date/time - 创建时间 - - - - Modified date/time - 修改时间 - - - - Accessed date/time - 访问时间 - - - - Format - 格式 - - - - Width - 宽度 - - - - Height - 高度 - - - - depth - 深度 - - - - Color model - 色彩模式 - - - - DPI - 每英寸像素点 - - - - Print size - 打印尺寸 - - - - Frame - - - - - None - - - - - Mono - 黑白 - - - - Gray - 灰度 - - - - Color - 彩色 - - - - Not supported - 不支持 - - - - Warning - - -警告 - - - - Device is Running! -Please finish scanning first. - 设备正在运行! -请先结束扫描。 - - - - cache path folder limit:%1 - 无法访问当前缓存路径:%1 -请尝试在【用户】菜单登录管理员账户,前往【缓存设置】更改缓存路径。 - - - - aquireinto folder limit:%1 - 无法访问当前缓存路径:%1 -请尝试在【扫描到】更改缓存路径。 - - - - Image processing failed - 图像处理失败 - - - - Ocr init failed - OCR初始化错误 - - - - Ocr failed - OCR错误 - - - - File does not exist - 文件不存在 - - - - Failed to load dynamic library - 加载动态库失败 - - - - File data error - 文件数据错误 - - - - Image format processing error - 图像格式处理错误 - - - - Out of memory - 内存不足 - - - - Failed - 错误 - - - - - The language switch is successful and takes effect the next time the software is started! - 语言切换成功,下次启动软件时生效! - - - - Are you sure to delete selected file? - 您确定彻底删除选中项文件? - - - - - - - - - - - - - - - already waked up device - 已唤醒设备 - - - - be ready - 就绪 - - - folder limit - 无法访问当前缓存路径 -请尝试在【用户】菜单登录管理员账户,前往【缓存设置】更改缓存路径 - - - - Insufficient access rights - 文件访问权限不足 - - - export succeed - 导出完成 - - - Ocr processing failed - 图像处理失败 - - - - Are you sure to close - 您确定要断开设备: - - - - ? - 吗? - - - - - close - 关闭 - - - - tip - 提示 - - - - Other versions not available - 未获取到其他版本 - - - - - The device does not support this operation - 设备不支持该操作 - - - - - IO error - IO错误 - - - - - error - 错误 - - - get versionlist failed - 获取版本列表错误 - - - Application is about to close.Make sure all needed files are saved. -Continue to close? - 应用程序即将关闭。请确认所有需要的文件已被保存。 -是否继续关闭? - - - - Sure to sign out administrator account? - 是否确定登出管理员账户? - - - - confirm the operation - 确认操作 - - - - Are you sure to clear the rollor acount? - 你确定要清除滚轴计数吗 - - - Please re-enter the Abount screen to obtain the latest value - 请重新进入关于界面以获取最新值 - - - - - <p>%1: <a href='%2'>%3</a> - - - - - - <p>%1: %2 - - - - - roller number - 滚轴张数 - - - - open scanner - 打开扫描仪 - - - - app name - 华高扫描软件 - - - - - success - 成功 - - - apply setting - 应用配置 - - - success - 成功 - - - failed - 失败 - - - - - failed - 失败 - - - - - - warning - 警告 - - - - - - the disk space in the current path is unsufficient, please select a new path or clear the disk space in time. - 当前路径磁盘空间不足, -请重新选择路径或及时清理磁盘空间。 - - - lost config - 配置丢失 - - - - apply setting - 应用配置 - - - - - - - - - - - - - - - - - - - - - start failed - 启动失败 - - - - HanvonScan - 汉王扫描软件 - - - - LanxumScan - 立思辰扫描软件 - - - - CumtennScan - 沧田扫描软件 - - - - MicrotekScan - Microtek DocWizard EX 扫描软件 - - - - menu_language - 语言 - - - - act_simpCN - 简体中文 - - - - act_English - English - - - - auto save - 自动保存 - - - - when switching pictures, save the edited pictures directly without reminding - 切换图片时,不提醒,直接保存编辑过的图片 - - - - statusBar displayed - 显示状态栏 - - - - statusBar hidden - 隐藏状态栏 - - - - toolBar displayed - 显示工具栏 - - - - toolBar hidden - 隐藏工具栏 - - - - colorInfo enabled - 启用图像信息 - - - - colorInfo disenabled - 关闭图像信息 - - - - enabling automatic saving - 启用自动保存 - - - - cancel auto save - 取消自动保存 - - - - Automatically save the edited the edited iamge when switching pictures. To cancel, uncheck the menu item: image-> automatically save - 切换图片时,自动保存编辑过的图像。若想取消,请取消勾选菜单项:图像->自动保存 - - - yes - 确定 - - - save, do not remind again - 保存,不再提醒 - - - no - 取消 - - - found device - 发现设备 - - - - reconnected - 重新连接 - - - - already connected, but open faild - 已经连接,但打开失败 - - - - - save image failed: - 存图失败: - - - - - - - create savepath failed: - 创建文件夹失败: - - - %1%2%3.%4 - %1%2%3.%4 - - - - - create image doc failed: - 创建图片文件失败: - - - - - - - - - - - - - - - - save image doc failed: - 保存图片文件失败: - - - - start failed! - 启动安装程序失败! - - - - There are pictures that have not been saved. -Are you sure to close? - 有图像未保存,确定关闭? - - - - found device : %1 - 发现设备 : %1 - - - - - - - - - - - - - - - - tips - 提示 - - - - Are you sure to close? - 确定关闭应用软件? - - - - confirm operation - 确认操作 - - - - are you sure to clear the roller count? - 您确定要清除滚轴计数吗 - - - - - - hint - 提示 - - - - - Roller scanned count has been set to 0. - 辊轴计数已置零 - - - - - Roller scanned count reset failed. - 重置滚轴计数失败 - - - - Error - 错误 - - - - Document missing! It would be deleted or renamed. - 文档丢失!文档可能已被删除或被重命名。 - - - HuaGoScan Application - 华高扫描应用程序 - - - 2018-2022 HuaGoScan - 2018-2021 HUAGOSCAN - - - Manufacturer/Developer: Ningbo Huagao Info&Tech co.,ltd. - 制造商/开发商: 宁波华高信息科技有限公司 - - - <br>Company website: <a href='http://www.huagaochina.com/'>www.huagaochina.com</a> - <br>公司网址: <a href='http://www.huagaochina.com/'>www.huagaochina.com</a> - - - <br>Contact: +86 0574 27974866 - <br>联系电话: +86 0574 27974866 - - - <br>Company address: No.655,Xueshi Road,Yinzhou district,Ningbo,Zhejiang,China(PRC) - <br>地址: 浙江省宁波市鄞州区学士路655号 C栋211 - - - Navigation: <a href='https://j.map.baidu.com/7e/1TO'>Visit in Baidu map.</a> - <br>导航地址: <a href='https://j.map.baidu.com/7e/1TO'>百度地图访问</a> - - - About %1 - 关于 %1 - - - <p>%1</p><p>Version: %2<br>CopyRight: &#169; %3</p><p>%4%5%6%7%8%9</p> - <p>%1</p><p>版本: %2<br>版权: &#169; %3</p><p>%4%5%6%7%8%9</p> - - - - - about %1 - 关于 %1 - - - - - <p>Version: %1</p> - <p>版本: %1</p> - <p>版本: %1</p> - - - - - <p>CopyRight: &#169; %1</p> - <p>版权: &#169; %1</p> - <p>版权: &#169; %1</p> - - - <p>%1: <a href='%2'>%3</a></p> - <p>%1: <a href='%2'>%3</a></p> - - - <p>%1: %2</p> - <p>%1: %2</p> - - - - QObject - - error - 错误 - - - - default_setting - 默认设置 - - - - &Save - 保存(&S) - - - - Widget - - - Widget - - - - - zuobiaozhou - 坐标轴 - - - - Widget_Imgproc_Base - - - Form - - - - - Brightness - 亮度 - - - - Contrast - 对比度 - - - - Gamma correction - Gamma校正 - - - - Widget_Imgproc_SideBar - - - Form - - - - - Ok - 确定 - - - - Cancel - 取消 - - - - Restore defaults - 恢复默认值 - - - - Enhance Text - 文本增强 - - - Apply to image - 应用到图像 - - - - Brightness - 亮度 - - - - Gamma correction - Gamma校正 - - - - Contrast - 对比度 - - - - Widget_StatusBar - - - Form - - - - - 0/0 - 0/0 - - - - 0*0*0 - 0×0×0 - - - - X:0, Y:0 - - - - - page - 页码 - - - - size - 分辨率 - - - - mousePos - 坐标 - - - - zoom - 缩放 - - - - cutDialog - - - cutDialog - - - - - device_menu - - - no device - 没有发现扫描仪 - - - - default setting - 默认设置 - - - - dialog_log - - - 日志 - 扫描状态信息 - - - - cancel scan - 取消扫描 - - - - auto scroll - 自动滚动 - - - - export images - 导出图片 - - - - continue scan - 继续扫描 - - - - finish scan - 完成扫描 - - - - (epicycle scanning images %u picture) - (本轮共扫描 %u 幅) - - - fold - 收起 - - - unfold - 展开 - - - - clear - 清空信息 - - - - hg_settingdialog - - set - 设置 - - - configuration management - 配置管理 - - - No configuration selected - 无配置选中 - - - No custom configuration was found - 无配置方案 - - - configuration name: - configuration name: - 配置名称: - - - configuration change name - 配置改名 - - - apply configuration--> - 应用配置--> - - - delete configuration - 删除配置 - - - - existing configuration scheme - 现有配置方案: - - - - change name - 改名 - - - - delete - 删除 - - - - apply - 应用 - - - - delete all configurations - 删除所有配置 - - - - confgiuration information: - 配置信息: - - - - - ok - 确定 - - - - cancel - 取消 - - - - configuration scheme management - 配置方案管理 - - - - regional crop - 区域裁剪 - - - - custom tone curve - 自定义色调曲线 - - - - - - - - Prompt - 提示 - - - - - - - - The funtion is unsupported - 此版本不支持该功能 - - - - Please select to overwrite the original configuration: - 请选择覆盖原来的配置: - - - - ,or add a new configuration - ,或者新增配置 - - - - save the configuration - 保存配置 - - - The Settings you just set are in the original configuration " - The Settings you just set are in the original configuration “ - 您刚才的设置是在原有配置 “ - - - " changed on the basis,Please select overwrite this configuration or add a new one? -Yes: cover " - ” changed on the basis,Please select overwrite this configuration or add a new one? -Yes: cover “ - ” 基础上更改的,请选择是覆盖这个配置,还是增加新的配置? -是: 覆盖 “ - - - " -No: add new configuration - ” -No: add new configuration - -否: 增加新的配置: - - - yes - - - - no - - - - - <h6><b> - <h6><b> - - - - cover original configuration: - 覆盖原来配置: - - - - add new configuration - 新增配置 - - - - rename: - 更名: - - - - - - tips - 提示 - - - - scheme name cannot be empty - 配置名不能为空 - - - - - scheme name: - 配置名: - - - - - already exists - 已存在 - - - - :</b></h6> - :</b></h6> - - - - <p> - <p> - - - - </p> - </p> - - - - configuration scheme name change - 配置改名 - - - - - be sure to delete the configuration - 确认删除配置 - - - - Are you sure you want to delete the configuration " - 您确认要删除配置 - - - - " ? - - - - Are you sure you want to delete the configuration ‘ - 您确认要删除配置 ‘ - - - ’ ? - ’ 吗? - - - - Are you sure you want to delete the configuration? - 您确认要删除所有配置吗? - - - - setPicClrTool - - - 自定义色调曲线 - - - - - 自定义 - 自定 - - - - - 负片(RGB) - - - - - 彩色负片(RGB) - - - - - 较暗(RGB) - - - - - 较亮(RGB) - - - - - RGB - - - - - 灰 - - - - - 红 - - - - - 蓝 - - - - - 绿 - - - - - 初始化 - - - - - 输入: - - - - - 输出: - - - - diff --git a/app/scanner/Scanner_zh_EN.qm b/app/scanner/Scanner_zh_EN.qm deleted file mode 100644 index 1b690d0c..00000000 Binary files a/app/scanner/Scanner_zh_EN.qm and /dev/null differ diff --git a/app/scanner/Scanner_zh_EN.ts b/app/scanner/Scanner_zh_EN.ts deleted file mode 100644 index a08a9550..00000000 --- a/app/scanner/Scanner_zh_EN.ts +++ /dev/null @@ -1,3442 +0,0 @@ - - - - - CutPaperTool - - - 自定义扫描区域 - Custom scan area - - - - 纸张尺寸: - Paper size: - - - - A4 - - - - - (210*297) - - - - - DPI(像素/英寸): - DPI(Primitive / inches): - - - - 200 - - - - - 单位: - Unit: - - - - 毫米(mm) - Millimeter(mm) - - - - 英寸(in) - Inch(in) - - - - 像素(px) - Primitive(px) - - - - 初始化选择区域 - Initialize selected area - - - - x: - - - - - - - - mm - - - - - y: - - - - - w: - - - - - h: - - - - - Dialog_Admin - - - Account sign in - User login - - - - Account: - User: - - - - Administrator - Administrator - - - - password: - Password: - - - - Show password - Show password - - - - Sign In - Login - - - - Cancel - Cancel - - - - Type password - Enter password - - - - Warning - Warning - - - - Password incorrect. Please try again. - Password error; please enter again. - - - - Dialog_AquireInto - - - Batch scanning - Batch scan - - - - configuration scheme management - Configuration plan management - - - - existing configuration scheme - existing configuration scheme: - Existing configuration plan: - - - - delete all configurations - Delete all configurations - - - confgiuration information: - Configuration information: - - - - change name - Rename - - - - delete - Delete - - - apply - Apply - - - - found scheme - Found scheme - - - - Restore Defaults - Restore default configuration - - - - Directory - Table of Contents - - - - ... - - - - - Use subfolder based on current date - Create a subfolder using the current date - - - - Use subfolder based on blank pages - Create subfolders according to blank pages - - - - Use subfolder based on image color type - Create a subfolder according to the image color type - - - - File name - File name - - - - File name index - File index - - - - Start index - Start index - - - - Digit(s) - Number - - - - 1 - - - - - 2 - - - - - 3 - - - - - 4 - - - - - 5 - - - - - e.g. 'HGScan001' - For example HGScan001 - - - - Even and odd pages - Even number and odd number pages - - - - Odd pages - Odd number page - - - - Even pages - Even number page - - - - Format - Format - - - - JPG - JPG / 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) - - - - - Compression option - Compression options - - - - Save as multipages (TIFF/PDF/OFD/GIF) - Save multiple pages(TIFF/PDF/OFD/GIF) - - - - 所有页 - All pages - - - - 用户自定义页数 - User custom pages - - - - - default scheme - Default scheme - - - - - - - e.g. '%1%2' - For example"%1%2" - - - - ok - OK - - - - cancel - Cancel - - - - Browse directory - Folder path - - - - - tips - Prompt - - - - - The configuration scheme already exists - The configuration scheme already exists - - - - Dialog_ClrCache - - - Dialog - Cache settings - - - - Cache path: - Cache path: - - - - ... - - - - - Cache occupied space: - Cache space used: - - - - - 0 - 0×0×0 {0?} - - - - B - B - - - - (0 Byte) - (0 Byte) - - - - Number of files: - Number of files: - - - - Clear Cache - Clear cache - - - - ok - OK - - - - cancel - Cancel - - - - - Information - Information - - - - No cached file is available - Temporarily no cache files - - - - Question - Ask - - - - Main window contains temporary files, clear cache would remove all of them. - Continue to clear? - The main window contains temporary files; clearing the cache will remove these files. -Continue clearing? - - - yes - OK - - - no - Cancel - - - - Cache clear successfully. - Cache cleared successfully. - - - - Warning - Warning - - - - Cache clear failed or incompletely clear. - Failed to clear cache or not cleared. - - - - Browse directory - Folder path - - - - - tips - Prompt - - - - directory can not be empty - File directory cannot be empty - - - - create cachePath failed: - Failed to create cache path: - - - - Dialog_Export - - - Export - Export - - - - Page Range - Page range - - - - Nominate Pages(example:1,3,6 or 3-6) - Specific page number (For example:1,3,6 or 3-6) - - - - Chosen Pages - Selected pages - - - - All Pages - All pages - - - - Page: - Page number: - - - - -Input is not valid. -Page range will be "Chosen Pages". - - Input invalid. -The page range will be “selected pages” - - - - Save as multipages (TIFF/PDF/OFD/GIF) - Save multiple pages(TIFF/PDF/OFD/GIF) - - - - Ocr type: - OCR type: - - - - Compression Option - Compression options - - - ok - OK - - - cancel - Cancel - - - - - - Input is not valid. -Page range will be 'Chosen Pages'. - Input invalid. -The page range will be “selected pages” - - - - English - English - - - - Simplified Chinese - Simplified Chinese - - - - Traditional Chinese - Traditional Chinese - - - - Japanese - Japanese - - - - Korean - Korean - - - - Dialog_ExportImageFile - - - Dialog - Export progress - - - - stop - Stop exporting - - - - export succeed - Export completed - - - - export failed: - Export failed: - - - - tip - Prompt - - - ok - OK - - - - Dialog_Feedback - - - Dialog - Opinions and feedback - - - - feedback: - Opinions and feedback: - - - - contact: - Contact method: - - - - submit - Submit - - - - cancel - Cancel - - - - feedback - Opinions and feedback - - - - Please leave your valuable comments and suggestions (required field). - Please leave your opinions and suggestions (required). - - - - Please leave your phone number, QQ or email address (required field). - Please leave a contact method, such as a phone number or E-mail address (required). - - - - - - error - Error - - - - Comments and suggestions cannot be empty. - Opinions and suggestions cannot be blank - - - - The contact information column cannot be empty. - The contact method field cannot be blank - - - - tip - Prompt - - - - submit succeed. - Submitted successfully. - - - - submit failed. - Submission failed. - - - - Dialog_FullScreen - - - Full Screen - Fullscreen display - - - - Ctrl+Right - - - - - Left - - - - - Right - - - - - Ctrl+Left - - - - - Exit fullscreen - Press ESC to exit full screen - - - - Dialog_ImageEditor - - - Dialog_ImageEditor - Image edit - - - - rect - Rectangle - - - - Rect - Rectangle - - - - ellipse - Oval - - - - Ellipse - Oval - - - - line - Straight line - - - - Line - Straight line - - - - Pen - Brush - - - - arrow - Arrow - - - - Arrow - Arrow - - - - text - Text - - - - Text - Text - - - - Color - Color - - - - color - Color - - - - LineWidth - Line width - - - - 1 pix - 1 Primitive - - - - 3 pix - 3 Primitive - - - - 5 pix - 5 Primitive - - - - 8 pix - 8 Primitive - - - - TextSize - Text size - - - - 20 - - - - - 26 - - - - - 36 - - - - - 48 - - - - - 72 - - - - - 96 - - - - - 128 - - - - - 160 - - - - - 200 - - - - - zoomin - Zoom in - - - - Zoomin - Zoom in - - - - fit - Restore - - - - Fit - Restore - - - - 100% - 0×0×0 {100%?} - - - - 1:1 - 1:1 - - - - zoomout - Zoom out - - - - Zoomout - Zoom out - - - - undo - Revoke - - - - Undo - Revoke - - - - Ctrl+Z - - - - - ok - OK - - - - Ok - OK - - - - cancel - Cancel - - - - Cancel - Cancel - - - - Dialog_ImageInfo - - - Image information - Image information - - - - ok - OK - - - - File - File - - - - Image - Image - - - - None - None - - - - Dialog_ImgProc_Adjust - - - Adjust - Brightness/ contrast/ gamma - - - - Show preview - Show thumbnails - - - - Before - Before processing - - - - After - After processing - - - - Apply to image - Apply to image - - - - ok - OK - - - - cancel - Cancel - - - - restore default - Restore defaults - - - - Dialog_ImgProc_AutoCrop - - - - Auto crop - Auto crop - - - - Auto correct skew - Skew correction - - - - Fill black frame type - Background filling method - - - - Convex polygon - Convex polygon - - - - Concave polygon - Concave polygon - - - - Auto Color - Adaptive document background - - - - Default Color - White - - - - Advanced parameters - Advanced parameter settings - - - - Threshold - Threshold - - - - Anti background noise - Background anti-noise - - - - Edge indent - Edge indent - - - - before - Before processing - - - - after - After processing - - - - Image crop - Crop/ Deskew/ Remove black box - - - - ok - OK - - - - cancel - Cancel - - - - restore default - Restore defaults - - - - Dialog_Input - - - Dialog - - - - - 输入: - Enter: - - - - Ok - OK - - - - Cancel - Cancel - - - - configuration scheme name change - Rename configuration - - - - tips - Prompt - - - - The content can not be empty - The content can not be empty - - - - Dialog_InsertIndex - - - Insert index selection - Insert selected items - - - - Insert location - Insert position - - - - Before first page - Before the first page - - - - Before current page - Before current page - - - - After current page - After current page - - - - After last page - After the last page - - - - ok - OK - - - - cancel - Cancel - - - - Dialog_LogManager - - - Dialog - Log export - - - - Directory... - Table of Contents: - - - - File Type: - File type: - - - - All(*.*) - All files(*.*) - - - - Image(*.jpg,*.bmp,*.png,*.tif) - Image file(*.jpg,*.bmp,*.png,*.tif) - - - - PDF(*.pdf) - PDF(*.pdf) - - - - Text(*.txt) - Text(*.txt) - - - - Config(*.ini,*.xml) - Setting file(*.ini,*.xml) - - - - Website(*.html) - Webpage(*.html) - - - - HGlog(*.HGLog) - HUAGOSCAN log(*.HGLog) - - - - Clear - Clear - - - - Export... - Export... - - - - Cancel - Cancel - - - - Warning - Warning - - - - Please select file in the list. - Please select files in the list. - - - - Choose saving path - Select save path - - - - - Information - Information - - - - Log files export finished. - Log file export completed. - - - - Question - Ask - - - - All log files will be cleared. -Continue to clear? - All log files will be cleared. -Continue clearing? - - - - All log files cleared. - All log files cleared. - - - - Dialog_MoveTo - - - move to - Move to - - - - target index: - Target location: - - - - Dialog_MultiRotate - - - Multiple rotation - Batch rotate - - - - Rotation - Rotate - - - - 90° - Rotate 90° - - - - 180° - Rotate 180° - - - - -90° - Rotate -90° - - - - Pages - Pages - - - - Current page - Current page - - - - Selected pages - Selected page - - - - All odd pages - All odd pages - - - - All even pages - All even pages - - - - All pages - All pages - - - - Attentions: -This operation will NOT rotate the files that may contain multiple pages, such as .pdf, .tif, etc. - Note: -This operation will not rotate files that may include multiple pages. - - - - ok - OK - - - - cancel - Cancel - - - - Dialog_MultiRotateImageFile - - - Dialog - Batch rotate progress - - - - stop - Stop batch rotate - - - - operation success - Operation successful - - - - multirotate operation failed: - Multi-stream rotation operation failed: - - - - tip - Prompt - - - ok - OK - - - - Dialog_OpenImageIndex - - - Open Page - Jump to... - - - - pageIndex: - Page number: - - - - ok - OK - - - - cancel - Cancel - - - - Dialog_PasswordChange - - - Change password - Change user password - - - - Old password: - Old password: - - - - New password: - New password: - - - - Confirm new password: - Confirm new password: - - - - Show password - Show password - - - - Password only allowed to use numbers, English and special characters. -Password length should between 8-20 charactors. - Only numbers, English and special characters are allowed for the password. -The password length should be within characters. - - - - OK - OK - - - - Cancel - Cancel - - - - Type old password - Enter old password - - - - Type new password - Enter new password - - - - Retype new password - Confirm new password - - - - - Warning - Warning - - - - Old password incorrect. -Please try again. - Old password error. Please try again. - - - - New password and confirm password are not matched. -Please make sure the two passwords are the same. - New password and confirm password do not match. - - - - - - Password only allowed to use numbers, English and special characters. - Please make sure the two passwords are the same. - - - - Dialog_SaveAs - - - Save As - Save as - - - - Compression Option - Compression options - - - - Use subfolder based on current date - Create a subfolder using the current date - - - - Ocr type: - OCR type: - - - - English - English - - - - Simplified Chinese - Simplified Chinese - - - - Traditional Chinese - Traditional Chinese - - - - Japanese - Japanese - - - - Korean - Korean - - - - Dialog_SaveMessageBox - - - Dialog - Ask - - - - TextLabel - - - - - Yes - Yes - - - - Yes to All - - - - - No - No - - - - save, do not remind again - Save and do not prompt again - - - - modified, save it? - Image modified, save changes? - - - - Dialog_WriteSettings - - - Write Settings - Write into settings - - - - Compression for black&white picture - Black and white image - - - - - None - None - - - - - LZW - LZW - - - - CCITT G4 - CCITT G4 - - - - Compression for color picture - Colored image - - - - JPEG - JPEG - - - - Quality - Quality - - - - Lowest - Low - - - - Best - High - - - - Dialog_updateProgress - - - Dialog - Downloading installation package... - - - - stop - Stop - - - - Dialog_upgrade - - - Dialog - - - - - detect result. versionNum: - - - - - upgrade the latest version - Update to the latest version - - - - upgrade online - Check for updates - - - - The current version is the latest! The current version number is : - Currently the latest version! The version number is: - - - - - Discover the new version : - New version discovered: - - - - - ,the current version is : - , the current version is: - - - - upgrade contents: - - Update content: - - - - - Dialog_upgradeFirmware - - - Dialog - - - - - gif - - - - - text - - - - - upgrade - Update and upgrade - - - - firmware upgrade in progress, please wait... - Device firmware currently updating; please wait... - - - - Dialog_wrong_img - - - Dialog - - - - - GraphicsScene - - - SongTi - Song - - - - HGImgThumb - - - - tips - Prompt - - - - unsupported file format - Drag and drop only supports jpg, bmp, png, pnm, tif/tiff, gif, pdf and ofd format - - - - file have been loaded - File loaded! - - - - file have been loaded, do you want to move to end? - File loaded; move it to the end? - - - - file have been loaded, do you want to move to specified location? - File loaded; move it to the specified location? - - - - - Question - Ask - - - yes - Yes - - - no - No - - - - some files have been loaded, do you want to move to end? - A file is loaded; move it to the end? - - - - some files have been loaded, do you want to move to specified location? - A file is loaded; move it to the specified location? - - - - MainWindow - - - MainWindow - HUAGOSCAN scanning software - - - - menu_file - File - - - - menu_scan - Scan - - - - menu_view - View - - - - menu_Auto_Image_Size - Automatic image size - - - - menu_page - Page - - - - menu_multiPages - Multiple pages - - - - menu_image - Image - - - - menuRotate - Rotate - - - - menu_user - User - - - - menu_info - Information - - - - menu_device - Device - - - - toolBar - Toolbar - - - - act_open - Open... - - - - act_insert - Insert local file... - - - - act_save - Save - - - - act_saveAs - Save as... - - - - act_Export - Export... - - - - act_closeFile - Close selected item - - - - act_closeAll - Close all items - - - - act_imageInfo - Image information... - - - - act_exit - Exit - - - - act_scannerSettings - Scan settings - - - - act_acquire - Scan - - - - act_acquireSingle - Scan single page - - - - - act_acquireInto - Scan to... - - - - act_fullscreen - Fullscreen display - - - - act_fitWindowSize - Fit view box size - - - - act_fitWindowWidth - Fit view box width - - - - act_realSize - Real size - - - - act_zoomIn - Zoom in - - - - act_zoomOut - Zoom out - - - - act_toolBar - ToolBar - - - - act_statusBar - Status bar - - - - act_thumbnailBar - Thumbnail bar - - - - act_colorInfo - Color information - - - - act_previous - Previous - - - - act_next - Next - - - - act_first - First - - - - act_last - Last - - - - act_openPageNum - Jump to... - - - - act_previousPage - Previous page - - - - act_nextPage - Next page - - - - act_firstPage - First page - - - - act_lastPage - Last page - - - - act_adjust - Brightness/ contrast/ gamma... - - - - act_90Left - Rotate 90 degrees left - - - - act_90Right - Rotate 90 degrees right - - - - act_180 - Rotate 180 degrees - - - - act_multiRotate - Rotate multiple pages... - - - - act_autoCrop - Crop/ Deskew/ Remove black box... - - - - act_signIn - Login... - - - - act_passwordChange - Change password... - - - - act_signOut - Logout - - - - act_log - Log management... - - - - act_clrCache - Cache settings... - - - - act_consume - Consumable status... - - - - act_help - Help - - - - act_about - About... - - - - act_insertFromScanner - Insert from scan... - - - - act_clearRoller - Clear roller count - - - - act_imageEdit - Image edit... - - - - act_sortPages - Book sorting - - - - act_autoSave - Auto save - - - - act_update - Check for updates... - - - - act_feedback - Opinions and feedback... - - - - act_device_log - Export device log... - - - - act_driver_log - Export drive log... - - - - act_deleteFile - Delete selected item - - - - act_enhanceText - Enhance text - - - - HanvonScan - Hanvon scanning software - - - - LanxumScan - LANXUM scanning software - - - - CumtennScan - CUMTENN scanning software - - - - MicrotekScan - Microtek DocWizard EX V1.0 - - - - HuaGoScan - HUAGOSCAN scanning software - - - - menu_language - Language - - - - act_simpCN - 简体中文 - - - - act_English - English - - - - Grid - Multi-column display - - - - Move To... - Move to... - - - - Insert files - Insert file - - - - - - nodevice - No scanner detected - - - - auto save - Auto save - - - - when switching pictures, save the edited pictures directly without reminding - Do not show prompt and save the edited images directly when switching images. - - - - statusBar displayed - Show status bar - - - - statusBar hidden - Hide status bar - - - - toolBar displayed - Show toolbar - - - - toolBar hidden - Hide toolbar - - - - colorInfo enabled - Enable image information - - - - colorInfo disenabled - Disable image information - - - - enabling automatic saving - Enable auto save - - - - cancel auto save - Cancel auto save - - - - Automatically save the edited the edited iamge when switching pictures. To cancel, uncheck the menu item: image-> automatically save - Save edited images automatically when switching images. If you want to cancel, please deselect the menu item: Auto save images. - - - - - - - - Question - Ask - - - - modified, save it? - Image modified, save changes? - - - yes - Yes - - - save, do not remind again - Save, do not prompt again - - - no - No - - - - file lost, remove it? - File lost; delete? - - - found device - Device discovered - - - - found device : %1 - Device discovered: %1 - - - - reconnected - reconnect - - - - already connected, but open faild - connected, but failed to open - - - - disconnected - disconnected - - - - - - the disk space in the current path is unsufficient, please select a new path or clear the disk space in time. - Insufficient disk space for the current path. -Please reselect a path or clear disk space immediately. - - - - - - warning - Warning - - - - - save image failed: - Failed to save image: - - - - - - - create savepath failed: - Failed to create folder: - - - - - create image doc failed: - Failed to create image file: - - - - - - - - - - - - - - - - save image doc failed: - Failed to save image: - - - - binary - Black and white - - - - gray - Grayscale - - - - rgb - Color - - - - - - - - - - - - - - - - - - - - - start failed - Failed to start - - - - UniScan - UNI scanning software - - - - - default scheme - Default scheme - - - - - - - - - - - - - - - Please wake up the device manually - Please wake up the device manually - - - - Scan - Scan - - - - - - - - - - - - - - - already waked up device - Device is awake - - - - thumbnailBar enabled - Show thumbnail bar - - - - thumbnailBar hidden - Hide thumbnail bar - - - - Clear, then start scan - Clear and start scan - - - - Do NOT clear, then start scan - Do not clear and start scan - - - - cancel - Cancel - - - - Already exist images in image list. -Do you want to clear? - Image already exists in the list of images. -Clear? - - - - Open images - Open image - - - - Insert images - Insert image - - - - - - - - - - - - - - - - tips - prompt - - - - - - save succeed - Saved successfully - - - - - find savePath in thumbnail - Image name already exists in the list - - - - Please select at least one picture before export - Please select at least one image and then export - - - - File name - File name - - - - File path - File path - - - - File size - File size - - - - Creation date/time - Creation time - - - - Modified date/time - Modification time - - - - Accessed date/time - Access time - - - - Format - Format - - - - Width - Width - - - - Height - Height - - - - depth - Depth - - - - Color model - Color mode - - - - DPI - Pixels per inch - - - - Print size - Print size - - - - Frame - Frame - - - - None - None - - - - Mono - Black and white - - - - Gray - Gray scale - - - - Color - Color - - - - Not supported - Not supported - - - - Warning - Warning - - - - Device is Running! -Please finish scanning first. - Device is currently running! -Please stop scanning first. - - - - There are pictures that have not been saved. -Are you sure to close? - There are unsaved images; are you sure you want to close? - - - - Are you sure to close? - Are you sure you want to close? - - - - Sure to sign out administrator account? - Are you sure you want to log out of the administrator account? - - - - confirm operation - Confirm operation - - - - are you sure to clear the roller count? - Are you sure you want to clear the roller count? - - - - - - hint - Prompt - - - - - Roller scanned count has been set to 0. - Roller count reset to zero. - - - - - Roller scanned count reset failed. - Failed to reset roller count. - - - - Error - Error - - - - Document missing! It would be deleted or renamed. - File lost! File may be deleted or renamed. - - - - confirm the operation - Confirm operation - - - - Are you sure to clear the rollor acount? - Are you sure you want to clear the roller count? - - - - cache path folder limit:%1 - Unable to access the current path:%1 -Please try to log in to the administrator account in the [User] menu and go to the [Cache settings] to change the cache path. - - - - aquireinto folder limit:%1 - Unable to access the current path:%1 -Please try to change the cache path in [Scan to]. - - - About %1 - About %1 - - - <p>%1</p><p>Version: %2<br>CopyRight: &#169; %3</p><p>%4%5%6%7%8%9</p> - <p>%1</p><p>Version: %2<br>Copyright: &#169; %3</p><p>%4%5%6%7%8%9</p> - - - - - about %1 - About %1 - - - - - <p>Version: %1</p> - <p>Version: %1</p> - - - - - <p>CopyRight: &#169; %1</p> - <p>Copyright: &#169; %1</p> - - - - - <p>%1: <a href='%2'>%3</a> - <p>%1: <a href='%2'>%3</a> - - - - - <p>%1: %2 - <p>%1: %2 - - - - roller number - Number of rollers - - - - open scanner - Open scanner - - - - app name - HUAGOSCAN scanning software - - - - - success - successfully - - - - be ready - Ready - - - - - failed - failed - - - - - error - Error - - - - start failed! - Failed to start! - - - folder limit - Cannot access “My Documents”. -Please go to “Scan to” and change the accessible scan folder and then perform the scan. - - - - Insufficient access rights - Insufficient file access permissions - - - - Image processing failed - Image processing failed - - - - Ocr init failed - OCR initialization error - - - - Ocr failed - OCR failed - - - - File does not exist - File does not exist - - - - Failed to load dynamic library - Failed to load dynamic library - - - - File data error - File data error - - - - Image format processing error - Image format processing error - - - - Out of memory - Insufficient memory - - - - Failed - Failed - - - - apply setting - Apply configuration - - - - Are you sure to close - Are you sure you want to disconnect device: - - - - ? - ? - - - - - close - Close - - - - tip - Prompt - - - - Other versions not available - No other versions obtained - - - - - The device does not support this operation - Device does not support this operation - - - - - IO error - IO error - - - - - The language switch is successful and takes effect the next time the software is started! - The language switch is successful and takes effect the next time the software is started! - - - - Are you sure to delete selected file? - Are you sure to delete the selected file completely? - - - - QObject - - - default_setting - Default setting - - - - &Save - &Save - - - - Widget - - - Widget - - - - - zuobiaozhou - Coordinate axis - - - - Widget_Imgproc_Base - - - Form - - - - - Brightness - Brightness - - - - Contrast - Contrast - - - - Gamma correction - Gamma correction - - - - Widget_Imgproc_SideBar - - - Form - - - - - Ok - OK - - - - Cancel - Cancel - - - - Restore defaults - Restore defaults - - - - Enhance Text - Enhance text - - - Apply to image - Apply to image - - - - Brightness - Brightness - - - - Gamma correction - Gamma correction - - - - Contrast - Contrast - - - - Widget_StatusBar - - - Form - - - - - 0/0 - 0/0 - - - - 0*0*0 - 0×0×0 - - - - X:0, Y:0 - - - - - page - Page - - - - size - Resolution - - - - mousePos - Coordinates - - - - zoom - Zoom - - - - cutDialog - - - cutDialog - - - - - device_menu - - - no device - No scanner detected - - - - default setting - Default settings - - - - dialog_log - - - 日志 - Scan status information - - - - cancel scan - Cancel scan - - - - auto scroll - Auto scroll - - - - clear - Clear information - - - - export images - Export image - - - - continue scan - Continue scanning - - - - finish scan - Scan complete - - - - (epicycle scanning images %u picture) - (A total of %u frames scanned this time) - - - - hg_settingdialog - - - existing configuration scheme - Existing configuration plan: - - - - change name - Rename - - - - delete - Delete - - - - apply - Apply - - - - delete all configurations - Delete all configurations - - - - confgiuration information: - Configuration information: - - - - - ok - OK - - - - cancel - Cancel - - - - configuration scheme management - Configuration plan management - - - - regional crop - Regional crop - - - - custom tone curve - Custom tone curve - - - - - - - - Prompt - Prompt - - - - - - - - The funtion is unsupported - This version does not support this feature. - - - - Please select to overwrite the original configuration: - Please select overwrite original configuration: - - - - ,or add a new configuration - , or add new configuration - - - - save the configuration - Save configuration - - - - cover original configuration: - Overwrite original configuration: - - - - add new configuration - Add new configuration - - - - rename: - Rename: - - - - - - tips - Prompt - - - - scheme name cannot be empty - Configuration name cannot be blank - - - - - scheme name: - Configuration name: - - - - - already exists - already exists - - - - <h6><b> - <h6><b> - - - - :</b></h6> - :</b></h6> - - - - <p> - <p> - - - - </p> - </p> - - - - configuration scheme name change - Rename configuration - - - - - be sure to delete the configuration - Delete configuration - - - - Are you sure you want to delete the configuration " - Are you sure you want to delete configuration - - - - " ? - ? - - - yes - Yes - - - no - No - - - - Are you sure you want to delete the configuration? - Are you sure you want to delete all configurations? - - - - setPicClrTool - - - 自定义色调曲线 - Custom tone curve - - - - 自定义 - Customize - - - - 负片(RGB) - Negative(RGB) - - - - 彩色负片(RGB) - Color negative(RGB) - - - - 较暗(RGB) - Darker(RGB) - - - - 较亮(RGB) - Brighter(RGB) - - - - RGB - RGB - - - - 灰 - Gray - - - - 红 - Red - - - - 蓝 - Blue - - - - 绿 - Green - - - - 初始化 - Initialize - - - - 输入: - Input: - - - - 输出: - OutPut: - - - diff --git a/app/scanner/VersionDll.cpp b/app/scanner/VersionDll.cpp deleted file mode 100644 index 1e11517b..00000000 --- a/app/scanner/VersionDll.cpp +++ /dev/null @@ -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); -} diff --git a/app/scanner/VersionDll.h b/app/scanner/VersionDll.h deleted file mode 100644 index d52bd2a3..00000000 --- a/app/scanner/VersionDll.h +++ /dev/null @@ -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 */ diff --git a/app/scanner/app_cfg.cpp b/app/scanner/app_cfg.cpp deleted file mode 100644 index 10b4d3cd..00000000 --- a/app/scanner/app_cfg.cpp +++ /dev/null @@ -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); -} diff --git a/app/scanner/app_cfg.h b/app/scanner/app_cfg.h deleted file mode 100644 index 0b5d1228..00000000 --- a/app/scanner/app_cfg.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef __APP_CFG_H__ -#define __APP_CFG_H__ - -#include - -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__ */ diff --git a/app/scanner/cfg/cJSON.c b/app/scanner/cfg/cJSON.c deleted file mode 100644 index f3dc5bcd..00000000 --- a/app/scanner/cfg/cJSON.c +++ /dev/null @@ -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 -#include -#include -#include -#include -#include -#include -#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;itype=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;ioffset; - 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;joffset+=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;ibuffer)+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;ichild;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 && ichild=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 && ichild=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 && ichild=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 && ichild=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. */ -} diff --git a/app/scanner/cfg/cJSON.h b/app/scanner/cfg/cJSON.h deleted file mode 100644 index 58b91ef6..00000000 --- a/app/scanner/cfg/cJSON.h +++ /dev/null @@ -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 - -#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 diff --git a/app/scanner/cfg/gb_json.cpp b/app/scanner/cfg/gb_json.cpp deleted file mode 100644 index 6b6e1de0..00000000 --- a/app/scanner/cfg/gb_json.cpp +++ /dev/null @@ -1,1879 +0,0 @@ - -#include "gb_json.h" -#include -#include -#include - -#include "../../sdk/include/huagao/brand.h" - -#if defined(WIN32) || defined(_WIN64) -#define bzero(b, s) memset(b, 0, s) -#endif - - -namespace gb -{ - static std::vector split_with(const char* str, const char* splitor = "/") - { - std::vector ret; - std::string src(str); - size_t pos = src.find(splitor); - - while(pos != std::string::npos) - { - if(pos++) - ret.push_back(src.substr(0, pos - 1)); - src.erase(0, pos + strlen(splitor)); - pos = src.find(splitor); - } - if(src.length()) - ret.push_back(src); - - return ret; - } - static int load_mini_file(const char* file, std::string& cont) - { - FILE* src = fopen(file, "rb"); - if (src) - { - size_t size = 0; - char *buf = NULL; - - fseek(src, 0, SEEK_END); - size = ftell(src); - fseek(src, 0, SEEK_SET); - buf = new char[size + 4]; - memset(buf, 0, size + 4); - fread(buf, 1, size, src); - fclose(src); - cont = std::string(buf, size); - delete[] buf; - - return 0; - } - else - return errno; - } - - refer::refer() : ref_(1) - {} - refer::~refer() - {} - - long refer::add_ref(void) - { -#if defined(WIN32) || defined(_WIN64) - return InterlockedIncrement(&ref_); -#else - return ++ref_; -#endif - } - long refer::release(void) - { -#if defined(WIN32) || defined(_WIN64) - long ref = InterlockedDecrement(&ref_); -#else - long ref = --ref_; -#endif - - if (ref == 0) - delete this; - - return ref; - } - - - json::json(char* json_txt) : obj_(0), cur_child_(0), is_array_(false) - { - memset(&walk_head_, 0, sizeof(walk_head_)); - attach_text(json_txt); - } - json::~json() - { - memset(&walk_head_, 0, sizeof(walk_head_)); - clear(); - } - - std::string json::to_string(cJSON* root, bool formatted) - { - char* txt = formatted ? cJSON_Print(root) : cJSON_PrintUnformatted(root); - std::string ret(txt ? txt : ""); - - if (txt) - free(txt); - - return ret; - } - std::string json::get_value_as_string(cJSON* root, bool integer) - { - std::string ret(""); - - switch (root->type) - { - case cJSON_False: - ret = "false"; - break; - case cJSON_True: - ret = "true"; - break; - case cJSON_NULL: - ret = "null"; - break; - case cJSON_Number: - { - char buf[40]; - if (integer) - sprintf(buf, "%d", root->valueint); - else - sprintf(buf, "%f", root->valuedouble); - ret = buf; - } - break; - case cJSON_String: - if (root->valuestring) - ret = root->valuestring; - break; - default: - ret = json::to_string(root, false); - break; - } - - return ret; - } - void json::free_node_data(cJSON* node) - { - if (node->type == cJSON_String && node->valuestring) - free(node->valuestring); - else if((node->type == cJSON_Object || node->type == cJSON_Array) && node->child) - cJSON_Delete(node->child); - - node->type = cJSON_NULL; - node->valuestring = NULL; - node->child = NULL; - } - cJSON* json::create_element(bool is_array) - { - cJSON* obj = is_array ? cJSON_CreateArray() : cJSON_CreateObject(); - - // bzero(obj, sizeof(*obj)); // cleared in constructor already ! - - return obj; - } - cJSON* json::create_element_with_name(const char* name) - { - cJSON* obj = json::create_element(); - - if(name) - { - obj->string = (char*)malloc(strlen(name) + 4); - bzero(obj->string, strlen(name) + 4); - strcpy(obj->string, name); - } - - return obj; - } - - cJSON* json::find_sibling(cJSON* first, const char* name, cJSON*** prev) - { - cJSON* now = first, **prv = NULL; - while(now) - { - if(now->string && strcmp(now->string, name) == 0) - { - break; - } - prv = &now->next; - now = now->next; - } - if(prev) - *prev = prv; - - return now; - } - cJSON* json::find_child(cJSON *parent, std::vector& path, bool create, cJSON*** addr) - { - if(!parent->child) - { - if(!create) - return NULL; - - parent->child = json::create_element_with_name(path[0].c_str()); - if(path.size() == 1) - { - if(addr) - *addr = &parent->child; - - return parent->child; - } - } - - cJSON** prev = NULL, - *now = find_sibling(parent->child, path[0].c_str(), &prev); - if(!now) - { - if(!create) - return now; - - now = json::create_element_with_name(path[0].c_str()); - if (prev) - { - cJSON* pr = (cJSON*)((DWORD_PTR)prev - (DWORD_PTR)&((cJSON*)0)->next); - pr->next = now; - now->prev = pr; - // *prev = now; - } - else - { - obj_->child = now; - prev = &obj_->child; - } - } - - path.erase(path.begin()); - if(path.empty()) - { - if(addr) - *addr = prev ? prev : &parent->child; - - return now; - } - - return find_child(now, path, create, addr); - } - cJSON* json::find(const char* path, bool create, cJSON*** addr) - { - std::vector tree(split_with(path)); - - if(tree.empty()) - return NULL; - - if(!obj_) - { - if(!create) - return NULL; - - obj_ = json::create_element(); - obj_->child = json::create_element_with_name(tree[0].c_str()); - } - - return find_child(obj_, tree, create, addr); - } - - bool json::attach_text(char* json_txt) - { - clear(); - - obj_ = cJSON_Parse(json_txt); - if(obj_) - is_array_ = obj_->type == cJSON_Array; - - return obj_ != 0; - } - bool json::attach_cjson(cJSON* cjson) - { - clear(); - - if (cjson) - { - std::string txt(json::to_string(cjson, false)); - if (txt.length()) - obj_ = cJSON_Parse(txt.c_str()); - } - if(obj_) - is_array_ = obj_->type == cJSON_Array; - - return obj_ != 0; - } - bool json::create_empty(bool array) - { - clear(); - - obj_ = json::create_element(array); - is_array_ = array; - - return true; - } - void json::clear(void) - { - if (obj_) - { - cJSON_Delete(obj_); - obj_ = 0; - } - } - std::string json::to_string(bool formatted) - { - if (obj_) - return json::to_string(obj_, formatted); - else - return ""; - } - - bool json::get_value(const char* key, bool& val) - { - cJSON* obj = find(key); - - if (!obj) - return false; - - if (obj->type == cJSON_True) - val = true; - else if (obj->type == cJSON_False) - val = false; - else - return false; - - return true; - } - bool json::get_value(const char* key, int& val) - { - cJSON* obj = find(key); - - if (!obj) - return false; - - if (obj->type != cJSON_Number) - return false; - - val = obj->valueint; - - return true; - } - bool json::get_value(const char* key, double& val) - { - cJSON *obj = find(key); - - if (!obj) - return false; - - if (obj->type != cJSON_Number) - return false; - - val = obj->valuedouble; - - return true; - } - bool json::get_value(const char* key, std::string& val) - { - cJSON *obj = find(key); - - if (!obj) - return false; - - if (obj->type != cJSON_String) - return false; - - val = obj->valuestring ? obj->valuestring : ""; - - return true; - } - bool json::get_value(const char* key, json*& val) - { - cJSON *obj = find(key); - - if (!obj) - return false; - - val = new json(); - if (!val->attach_cjson(obj)) - { - val->release(); - - return false; - } - - return true; - } - bool json::get_value_as_string(const char* key, std::string& val, bool integer) - { - cJSON* obj = find(key); - - if (!obj) - return false; - - val = json::get_value_as_string(obj, integer); - - return true; - } - bool json::get_as_array(const char* key, std::vector& val) - { - cJSON *obj = find(key); - - val.clear(); - if (obj && obj->type == cJSON_Array) - { - cJSON *child = obj->child; - while (child) - { - if (child->type == cJSON_Number) - { - char buf[40]; - sprintf(buf, "%d", child->valueint); - val.push_back(buf); - } - else if (child->type == cJSON_String) - val.push_back(child->valuestring ? child->valuestring : ""); - else - { - char *text = cJSON_Print(child); - val.push_back(text); - free(text); - } - - child = child->next; - } - - return true; - } - - return false; - } - - int json::count() - { - if(!obj_ || !obj_->child) - return 0; - - cJSON* child = obj_->child; - int cnt = 0; - - while(child) - { - cnt++; - child = child->next; - } - - return cnt; - } - - - bool json::first_child(std::string& val, std::string* name) - { - cur_child_ = obj_->child; - val = ""; - if (cur_child_) - { - val = json::get_value_as_string(cur_child_); - if (name && cur_child_->string) - *name = cur_child_->string; - - return true; - } - else - { - return false; - } - } - bool json::next_child(std::string& val, std::string* name) - { - if (cur_child_) - cur_child_ = cur_child_->next; - - val = ""; - if (cur_child_) - { - val = json::get_value_as_string(cur_child_); - if (name && cur_child_->string) - *name = cur_child_->string; - - return true; - } - else - { - return false; - } - } - - bool json::set_value(const char* key, bool val) - { - if(!key) - { - if(is_array_) - { - if(!obj_) - obj_ = json::create_element(true); - cJSON_AddItemToArray(obj_, val ? cJSON_CreateTrue() : cJSON_CreateFalse()); - } - - return is_array_; - } - - cJSON* ele = this->find(key, true); - - if (!ele) - return false; - - json::free_node_data(ele); - - if (val) - ele->type = cJSON_True; - else - ele->type = cJSON_False; - - return true; - } - bool json::set_value(const char* key, int val) - { - if(!key) - { - if(is_array_) - { - if(!obj_) - obj_ = json::create_element(true); - cJSON_AddItemToArray(obj_, cJSON_CreateNumber(val)); - } - - return is_array_; - } - - cJSON* ele = this->find(key, true); - - if (!ele) - return false; - - json::free_node_data(ele); - - ele->type = cJSON_Number; - ele->valuedouble = ele->valueint = val; - - return true; - } - bool json::set_value(const char* key, double val) - { - if(!key) - { - if(is_array_) - { - if(!obj_) - obj_ = json::create_element(true); - cJSON_AddItemToArray(obj_, cJSON_CreateNumber(val)); - } - - return is_array_; - } - - cJSON* ele = this->find(key, true); - - if (!ele) - return false; - - json::free_node_data(ele); - - ele->type = cJSON_Number; - ele->valuedouble = val; - - return true; - } - bool json::set_value(const char* key, std::string val) - { - if(!key) - { - if(is_array_) - { - if(!obj_) - obj_ = json::create_element(true); - cJSON_AddItemToArray(obj_, cJSON_CreateString(val.c_str())); - } - - return is_array_; - } - - cJSON* ele = this->find(key, true); - - if (!ele) - return false; - - json::free_node_data(ele); - - ele->type = cJSON_String; - ele->valuestring = (char*)malloc(val.length() + 4); - bzero(ele->valuestring, val.length() + 4); - strcpy(ele->valuestring, val.c_str()); - - return true; - } - bool json::set_value(const char* key, const char* val) - { - return set_value(key, std::string(val)); - } - bool json::set_value(const char* key, json* obj) - { - if(!key) - { - if(is_array_) - { - if(!obj_) - obj_ = json::create_element(true); - if(obj && obj->obj_) - { - cJSON_AddItemToArray(obj_, obj->obj_); - obj->obj_ = NULL; - } - } - - return is_array_; - } - - cJSON** addr = NULL; - cJSON* ele = this->find(key, true, &addr); - - if (!ele) - return false; - -// json::free_node_data(ele); - cJSON_Delete(ele); - *addr = obj->obj_; - ele = obj->obj_; - if(ele->string) - free(ele->string); - ele->string = (char*)malloc(strlen(key) + 4); - bzero(ele->string, strlen(key) + 4); - strcpy(ele->string, key); - obj->obj_ = NULL; - - return true; - } - - bool json::change_key(const char* old_key, const char* new_key) - { - if (!obj_ || !new_key || *new_key == 0 || !old_key || *old_key == 0) - return false; - - cJSON** addr = NULL, - *ele = find(old_key, false, &addr); - - if (!ele) - return false; - - if (strlen(ele->string) < strlen(new_key)) - { - int l = strlen(new_key) + 4; - free(ele->string); - ele->string = (char*)malloc(l); - memset(ele->string, 0, l); - } - strcpy(ele->string, new_key); - - return true; - } - bool json::remove(const char* key) - { - if(!obj_) - return false; - - cJSON **addr = NULL, - *ele = find(key, false, &addr); - - if(ele) - { - bool cur_child = cur_child_ == obj_->child; - - if(addr) - *addr = ele->next; - if (cur_child_ == ele) - { - if (cur_child) - { - walk_head_.next = obj_->child; - cur_child_ = &walk_head_; - } - else - cur_child_ = ele->prev; - } - if (ele->prev) - ele->prev->next = ele->next; - if (ele->next) - ele->next->prev = ele->prev; - ele->prev = NULL; - ele->next = NULL; - cJSON_Delete(ele); - - return true; - } - else - return false; - } -} - - - -namespace gb -{ - static char base64_default_table[] = { "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" }; - - base64::base64() : padding_char_('=') - { - base64_ind_[0] = base64_char_[0] = 0; - - initialize_base64_table(base64_default_table); - } - base64::~base64() - {} - - bool base64::is_valid_base64_table(const char* table) - { - bool valid = false; - - if (table && strlen(table) >= 64) - { - char repeat[4] = { 0 }; - - valid = true; - for (int i = 0; i < 63; ++i) - { - repeat[0] = table[i]; - if (strstr(table + i + 1, repeat)) - { - valid = false; - break; - } - } - } - - return valid; - } - bool base64::initialize_base64_table(const char* table) - { - if (!table || strlen(table) < 64) - { - if (memcmp(base64_default_table, base64_char_, 64) == 0) - { - return !table; - } - - memcpy(base64_char_, base64_default_table, 64); - } - else - { - if (memcmp(base64_char_, table, 64) == 0) - { - return true; - } - else if (!is_valid_base64_table(table)) - return false; - - memcpy(base64_char_, table, 64); - } - base64_char_[64] = base64_char_[65] = 0; - - // initialize base64_index - memset(base64_ind_, 0, sizeof(base64_ind_)); - for (int i = 0; i < 64; ++i) - { - base64_ind_[base64_char_[i]] = i; - } - - // padding char - padding_char_ = '='; - if (base64_ind_[padding_char_]) - { - for (padding_char_ = 0x21; padding_char_ < 0x7e && base64_ind_[padding_char_] && padding_char_ != base64_char_[0]; ++padding_char_); - } - - return padding_char_ < 0x7e; - } - - bool base64::set_base64_table(const char* table) - { - return initialize_base64_table(table ? table : base64_default_table); - } - std::string base64::encode(const char* data, size_t bytes, unsigned int line_bytes, bool need_padding) - { - char* str = (char*)malloc(bytes * 2 + 3); - unsigned char c1 = 0, c2 = 0, c3 = 0; - unsigned long line_len = 0; - unsigned long words = bytes / 3; - int rest = bytes % 3, - pos = 0; - std::string ret(""); - - for (unsigned long i = 0; i < words; ++i) - { - // fetch 3 letters - c1 = *data++; - c2 = *data++; - c3 = *data++; - - // encoding into 4-bytes - str[pos++] = base64_char_[c1 >> 2]; - str[pos++] = base64_char_[((c1 << 4) | (c2 >> 4)) & 0x3f]; - str[pos++] = base64_char_[((c2 << 2) | (c3 >> 6)) & 0x3f]; - str[pos++] = base64_char_[c3 & 0x3f]; - line_len += 4; - - // new line ... - if ((unsigned int)line_len > line_bytes - 4) - { - str[pos++] = '\r'; - str[pos++] = '\n'; - line_len = 0; - } - } - - // rest ... - if (rest == 1) - { - c1 = *data++; - str[pos++] = base64_char_[(c1 & 0xfc) >> 2]; - str[pos++] = base64_char_[((c1 & 0x03) << 4)]; - if (need_padding) - { - str[pos++] = padding_char_; - str[pos++] = padding_char_; - } - } - else if (rest == 2) - { - c1 = *data++; - c2 = *data++; - str[pos++] = base64_char_[(c1 & 0xfc) >> 2]; - str[pos++] = base64_char_[((c1 & 0x03) << 4) | ((c2 & 0xf0) >> 4)]; - str[pos++] = base64_char_[((c2 & 0x0f) << 2)]; - if (need_padding) - { - str[pos++] = padding_char_; - } - } - if (pos > 0) - { - str[pos++] = 0; - ret = std::string(str, pos - 1); - } - free(str); - - return ret; - } - std::string base64::decode(const char* data, size_t bytes) - { - char* str = (char*)malloc(bytes + 1); - int pos = 0, - shifts = 18, - value = 0; - std::string ret(""); - - for (int i = 0; i < (int)bytes; ++i) - { - if (*data != '\r' && *data != '\n') - { - if (*data == padding_char_) - { - break; - } - - value += base64_ind_[*data] << shifts; - if (shifts == 0) - { - shifts = 18; - str[pos++] = (value >> 16) & 0x0ff; - str[pos++] = (value >> 8) & 0x0ff; - str[pos++] = (value >> 0) & 0x0ff; - value = 0; - } - else - { - shifts -= 6; - } - } - data++; - } - - if (shifts == 12 || shifts == 6) - { - str[pos++] = (value >> 16) & 0x0ff; - } - else if (shifts == 0) - { - str[pos++] = (value >> 16) & 0x0ff; - str[pos++] = (value >> 8) & 0x0ff; - } - - if (pos > 0) - { - str[pos++] = 0; - ret = std::string(str, pos - 1); - } - free(str); - - return ret; - } -} - -namespace updater -{ - static std::string hg_model_from_pid(const char* pid) - { - if (strcmp(pid, "7823") == 0) - return "G200"; - - char m[] = { 'G', pid[0], '0', '0', 0}; - - return std::string(m) + " - " + pid; - } - static std::string hv_model_from_pid(const char* pid) - { - std::string m(""); - if (strcmp(pid, "1000") == 0) - m = "HW-1000NS"; - else if (strcmp(pid, "1002") == 0) - m = "HW-1000"; - else if (strcmp(pid, "7000") == 0) - m = "HW-7000NS"; - else if (strcmp(pid, "7002") == 0) - m = "HW-7000"; - else if (strcmp(pid, "7039") == 0) - m = "HW-7000NS"; - else - m = std::string("HW-") + pid; - - return m + " - " + pid; - } - static std::string lsc_model_from_pid(const char* pid) - { - if (strcmp(pid, "8200") == 0) - return "G42S - 8200"; - else - { - char m[] = {'G', pid[1], pid[2], 'S', 0}; - - return std::string(m) + " - " + pid; - } - } - static std::string scanner_chinese_name_2_model(const char* cn) - { - static const char* hg = "\345\215\216\351\253\230", - * hw = "\346\261\211\347\216\213", - * lsc = "\347\253\213\346\200\235\350\276\260", - * smy = "\346\211\253\346\217\217\344\273\252\342\200\224G", - * f = strstr(cn, hg); - std::string model(""); - std::string(* model_from_pid)(const char* pid) = nullptr; - - if (f == cn) - { - model = "HUAGOSCAN "; - model_from_pid = hg_model_from_pid;; - } - else if (strstr(cn, hw) == cn) - { - model = "Hanvon "; - model_from_pid = hv_model_from_pid;; - } - else if (strstr(cn, lsc) == cn) - { - model = "LANXUMSCAN "; - model_from_pid = lsc_model_from_pid;; - } - else - return ""; - - f = strstr(cn, smy); - if (!f) - return ""; - - f += strlen(smy); - model += model_from_pid(f); - - return model; - } - static int update_app_config(const char* scanner_name, const char* jsn_txt, const char* path, gb::scanner_cfg::LPUDF lpfunc) - { - std::string scanner(""), jsn_str(jsn_txt); - std::vector efiles; - - if ((unsigned char)scanner_name[0] > 0x7f) - scanner = scanner_chinese_name_2_model(scanner_name); - else - scanner = scanner_name; - - gb::json* jsn = new gb::json(); - int cur_sel = -1, ret = 0; - gb::scanner_cfg* cfg = nullptr; - if (!jsn->attach_text(&jsn_str[0])) - { - jsn->release(); - return EINVAL; - } - - if (jsn->first_child(jsn_str)) - { - gb::json* child = new gb::json(); - if (child->attach_text(&jsn_str[0])) - { - if (!child->get_value("cur_sel", cur_sel)) - ret = EINVAL; - } - if (ret == 0) - { - cfg = new gb::scanner_cfg(); - int ind = 0; - while (jsn->next_child(jsn_str)) - { - if (!child->attach_text(&jsn_str[0])) - { - ret = EINVAL; - break; - } - - std::string schm_name(""); - if (!child->get_value("scheme", schm_name)) - { - ret = EINVAL; - break; - } - - gb::json* items = nullptr; - if (!child->get_value("opts", items) || !items) - { - ret = EINVAL; - break; - } - - gb::sane_config_schm* schm = new gb::sane_config_schm(); - if (items->first_child(jsn_str)) - { - do - { - std::string name(""), val(""); - gb::json* item = new gb::json(); - if (item->attach_text(&jsn_str[0])) - { - if (item->get_value("name", name) && item->get_value("value", val)) - { - name = lpfunc->title2name(name.c_str(), lpfunc->func_param); - lpfunc->trans_number(name.c_str(), val, lpfunc->func_param); - schm->set_value(name.c_str(), val.c_str(), val.length()); - - val = ""; - item->get_value("extra", val); - if (val.length() && gb::load_mini_file(val.c_str(), val) == 0) - { - schm->set_value(name.c_str(), val.c_str(), val.length(), true); - item->get_value("extra", val); - efiles.push_back(val); - } - } - } - item->release(); - } while (items->next_child(jsn_str)); - } - items->release(); - - cfg->add_scheme(schm, schm_name.c_str()); - schm->release(); - if (ind++ == cur_sel) - cfg->select_scheme(schm_name.c_str()); - } - } - child->release(); - } - jsn->release(); - if (cfg) - { - if (ret == 0) - { - cfg->save((path + scanner + ".cfg").c_str()); - for (auto& v : efiles) - rename(v.c_str(), (v + "_bk").c_str()); - } - cfg->release(); - } - - return ret; - } -} -namespace gb -{ - std::string sane_config_schm::opt_data_appendix_("_data"); - - sane_config_schm::sane_config_schm(scanner_cfg* scanner) : jsn_(NULL), bkp_(NULL), in_setting_(false), scheme_name_("") - , scanner_(scanner) - { - char empty[8] = { "{}" }; - jsn_ = new gb::json(); - jsn_->attach_text(empty); - def_val_ = new gb::json(); - if (scanner_) - scanner_->add_ref(); - } - sane_config_schm::~sane_config_schm() - { - clear(); - def_val_->release(); - if (scanner_) - scanner_->release(); - } - - bool sane_config_schm::hex(unsigned char ch, unsigned char* val) - { - bool ret = true; - - if (ch >= '0' && ch <= '9') - ch -= '0'; - else if (ch >= 'a' && ch <= 'f') - ch = ch - 'a' + 10; - else if (ch >= 'A' && ch <= 'F') - ch = ch - 'A' + 10; - else - ret = false; - - if (ret && val) - { - *val &= 0x0f0; - *val |= ch; - } - - return ret; - } - bool sane_config_schm::hex_char(const char* data, unsigned char* val) - { - unsigned char v = 0; - bool ret = false; - - if (sane_config_schm::hex(*data++, &v)) - { - v <<= 4; - if (sane_config_schm::hex(*data++, &v)) - { - if (val) - *val = v; - - ret = true; - } - } - - return ret; - } - bool sane_config_schm::is_option_data(std::string& name) - { - size_t pos = name.find(sane_config_schm::opt_data_appendix_); - - if (pos != std::string::npos) - { - if (pos + sane_config_schm::opt_data_appendix_.length() == name.length()) - { - name.erase(pos); - - return true; - } - } - - return false; - } - - void sane_config_schm::clear() - { - if (jsn_) - jsn_->release(); - jsn_ = NULL; - if (bkp_) - bkp_->release(); - bkp_ = NULL; - // file_ = ""; - } - std::string sane_config_schm::to_hex_letter(const char* data, size_t bytes) - { - std::string hex(""); - const unsigned char* ptr = (const unsigned char*)data; - char buf[8] = { 0 }; - - for (size_t i = 0; i < bytes; ++i) - { - sprintf(buf, "%02X", ptr[i]); - hex += buf; - } - - return hex; - } - std::string sane_config_schm::from_hex_letter(const char* data, size_t bytes) - { - std::string stream(""); - - bytes /= 2; - for (size_t i = 0; i < bytes; ++i) - { - unsigned char ch = 0; - if (!sane_config_schm::hex_char(data, &ch)) - break; - stream.append(1, ch); - data += 2; - } - - return stream; - } - std::string sane_config_schm::default_value(const char* hex_title) - { - std::string val(""); - - def_val_->get_value(hex_title, val); - - return val; - } - - sane_config_schm* sane_config_schm::copy(void) - { - sane_config_schm *cp = new sane_config_schm(scanner_); - std::string val(jsn_->to_string(false)); - - cp->scheme_name_ = scheme_name_; - cp->file_ = file_; - cp->jsn_->attach_text(&val[0]); - cp->id_name_ = id_name_; - val = def_val_->to_string(false); - cp->def_val_->attach_text(&val[0]); - - return cp; - } - bool sane_config_schm::load_from_file(const char* file) - { - clear(); - - std::string cont(""); - - file_ = file; - if (gb::load_mini_file(file, cont)) - return false; - - return load_from_mem(cont.c_str()); - } - bool sane_config_schm::load_from_mem(const char* mem, bool in_b64) - { - gb::base64 b64; - std::string stream(in_b64 ? b64.decode(mem, strlen(mem)) : mem); - - clear(); - jsn_ = new gb::json(); - if (!jsn_->attach_text(&stream[0])) - { - jsn_->release(); - jsn_ = NULL; - - return false; - } - - return true; - } - bool sane_config_schm::save_to(const char* file) - { - bool ret = false; - std::string encode(to_text_stream()); - - if (!file || *file == 0) - file = file_.c_str(); - - if (encode.length()) - { - FILE* dst = fopen(file, "wb"); - - if (dst) - { - fwrite(encode.c_str(), 1, encode.length(), dst); - fclose(dst); - ret = true; - } - } - - return ret; - } - void sane_config_schm::set_default_value(int sn, const char* name, const char* val, size_t bytes) - { - id_name_[sn] = name; - def_val_->set_value(name, to_hex_letter(val, bytes).c_str()); - } - void sane_config_schm::copy_default_value(sane_config_schm* from) - { - if(from) - { - std::string t(from->def_val_->to_string(false)); - - id_name_ = from->id_name_; - def_val_->attach_text(&t[0]); - } - } - bool sane_config_schm::first_config(std::string& name, std::string& val) - { - bool ret = false; - std::string raw_v(""); - - if (jsn_ && jsn_->first_child(raw_v, &name)) - { - val = sane_config_schm::from_hex_letter(raw_v.c_str(), raw_v.length()); - - ret = true; - } - - return ret; - } - bool sane_config_schm::next_config(std::string& name, std::string& val) - { - bool ret = false; - std::string raw_v(""); - - if (jsn_ && jsn_->next_child(raw_v, &name)) - { - val = sane_config_schm::from_hex_letter(raw_v.c_str(), raw_v.length()); - - ret = true; - } - - return ret; - } - bool sane_config_schm::get_config(const char* name, std::string& val) - { - bool ret = jsn_ ? jsn_->get_value(name, val) : false; - - if(!ret && def_val_) - ret = def_val_->get_value(name, val); - - if(ret) - val = sane_config_schm::from_hex_letter(val.c_str(), val.length()); - - return ret; - } - void sane_config_schm::begin_setting(bool restore) - { - if (bkp_) - bkp_->release(); - bkp_ = jsn_; - in_setting_ = true; - jsn_ = new gb::json(); - if (!restore && bkp_) - { - std::string stream(bkp_->to_string(false)); - if(stream.length()) - jsn_->attach_text(&stream[0]); - } - } - void sane_config_schm::config_changed(const char* name, const char* val, size_t bytes, bool extra) - { - std::string hex_v(to_hex_letter(val, bytes)); - - if (extra) - { - jsn_->set_value((name + sane_config_schm::opt_data_appendix_).c_str(), hex_v.c_str()); - } - else - { - std::string def = default_value(name); - if (hex_v == def) - { - jsn_->remove(name); - jsn_->remove((name + sane_config_schm::opt_data_appendix_).c_str()); - } - else - jsn_->set_value(name, hex_v.c_str()); - } - } - void sane_config_schm::config_changed(int sn, const char* val, size_t bytes, bool extra) - { - std::string name(""); - - if (id_name_.count(sn)) - { - name = id_name_[sn]; - config_changed(name.c_str(), val, bytes, extra); - } - } - void sane_config_schm::remove_config(const char* name) - { - if (jsn_) - jsn_->remove(name); - } - void sane_config_schm::set_value(const char* name, const char* val, size_t bytes, bool extra) - { - std::string hex_v(to_hex_letter(val, bytes)); - - if (extra) - jsn_->set_value((name + sane_config_schm::opt_data_appendix_).c_str(), hex_v.c_str()); - else - jsn_->set_value(name, hex_v.c_str()); - } - bool sane_config_schm::has_changed(int* items) - { - if(items) - *items = jsn_ ? jsn_->count() : 0; - - if(!bkp_) - { - return false; - } - - std::map old; - std::string n(""), v(""); - if(bkp_->first_child(v, &n)) - { - do - { - old[n] = v; - }while(bkp_->next_child(v, &n)); - } - - if(jsn_->first_child(v, &n)) - { - do - { - if(old.count(n) == 0) - return true; - if(old[n]!=v) - return true; - - old.erase(n); - }while(jsn_->next_child(v, &n)); - } - - return old.size() > 0; - } - void sane_config_schm::end_setting(bool cancel) - { - if (in_setting_) - { - if (cancel) - { - jsn_->release(); - jsn_ = bkp_; - bkp_ = NULL; - } - else if (bkp_) - { - bkp_->release(); - bkp_ = NULL; - } - } - in_setting_ = false; - } - int sane_config_schm::id_from_name(const char* name) - { - for (const auto& v : id_name_) - { - if (v.second == name) - return v.first; - } - - return -1; - } - std::string sane_config_schm::to_text_stream(bool b64, bool with_ver) - { - if (jsn_) - { - if(with_ver) - { - char ver[40] = { 0 }; - sprintf(ver, "%u.%u", VERSION_MAIN, VERSION_SUB); - jsn_->set_value("ver", ver); - } - - std::string cont(jsn_->to_string(false)); - if (b64) - { - gb::base64 b64; - - cont = b64.encode(cont.c_str(), cont.length()); - } - - return cont; - } - else - return ""; - } - std::string sane_config_schm::get_version(void) - { - std::string ver(""); - - if (jsn_) - jsn_->get_value("ver", ver); - - return ver; - } - std::string sane_config_schm::get_scheme_name(void) - { - return scheme_name_; - } - void sane_config_schm::set_scheme_name(const char* name) - { - scheme_name_ = name ? name : ""; - } - void sane_config_schm::update(bool(* is_float)(int, void*), void* param, const char* (* t2n)(const char*), std::string* discard) - { - if (!jsn_) - return; - - std::string ver(get_version()), - name(""), - val(""); - int mv = atoi(ver.c_str()), - sv = ver.find("."); - bool changed = false; - char vs[40] = { 0 }; - - if (sv++ != -1) - sv = atoi(ver.c_str() + sv); - - // change title to name ... - if (mv <= 4 && sv < 30) - { - if (jsn_->first_child(val, &name)) - { - changed = true; - do - { - jsn_->change_key(name.c_str(), t2n(sane_config_schm::from_hex_letter(name.c_str(), name.length()).c_str())); - } while (jsn_->next_child(val, &name)); - } - } - - // fix float does not convert to SANE_Fixed bug in eldest version .... (discard them) - if (ver.empty()) - { - if (jsn_->first_child(val, &name)) - { - do - { - int id = id_from_name(name.c_str()); - if (id == -1 || is_float(id, param)) - { - jsn_->remove(name.c_str()); - if (discard) - *discard += name + "\r\n"; - changed = true; - } - } while (jsn_->next_child(val, &name)); - } - } - sprintf(vs, "%u.%u", VERSION_MAIN, VERSION_SUB); - jsn_->set_value("ver", vs); - - if (changed) - save_to(NULL); - } - - - - - /////////////////////////////////////////////////////////////////////////////////// - // scanner_cfg - std::string scanner_cfg::global_name_ = "global"; - std::string scanner_cfg::cur_sel_ = "cur"; - std::string scanner_cfg::default_setting_name_; - - scanner_cfg::scanner_cfg() : path_(""), scanner_name_(""), global_(new json()) - { - default_setting_name_ = QObject::tr("default_setting").toStdString(); - init_version(); - init_select(); - } - scanner_cfg::~scanner_cfg() - { - clear(); - global_->release(); - } - - bool scanner_cfg::update(const char* file, LPUDF func) - { - std::string cont(""), name(""), path(file); - int ret = gb::load_mini_file(file, cont); - base64 b64; - json *jsn = nullptr; - bool ok = true; - - if (ret) - return false; - else if (cont.empty()) - return true; - - cont = b64.decode(cont.c_str(), cont.length()); - jsn = new json(); - if (!jsn->attach_text(&cont[0])) - { - jsn->release(); - return false; - } - - cont = ""; - ret = path.rfind(PATH_SYMBOL[0]); - if (ret++ != std::string::npos) - path.erase(ret); - if (jsn->first_child(cont, &name)) - { - do - { - ok &= updater::update_app_config(name.c_str(), cont.c_str(), path.c_str(), func) == 0; - } while (jsn->next_child(cont, &name)); - } - jsn->release(); - if (ok) - rename(file, (std::string(file) + "_bk").c_str()); - - return true; - } - - void scanner_cfg::clear(void) - { - global_->set_value("ver", ""); - global_->set_value(scanner_cfg::cur_sel_.c_str(), -1); - - for (size_t i = 0; i < schemes_.size(); ++i) - schemes_[i].schm->release(); - schemes_.clear(); - scanner_name_ = ""; - } - void scanner_cfg::init_version(void) - { - char vstr[40] = { 0 }; - - sprintf(vstr, "%u.%u", VERSION_MAIN, VERSION_SUB); - global_->set_value("ver", vstr); - } - void scanner_cfg::init_select(void) - { - global_->set_value(scanner_cfg::cur_sel_.c_str(), -1); - } - void scanner_cfg::walk_sibling_schemes(cJSON* first) - { - if (!first) - return; - - cJSON* next = first->next; - std::string name(first->string ? first->string : ""), - cont(""); - CFGSCHM sch; - - first->next = nullptr; - cont = json::to_string(first, false); - if (name == scanner_cfg::global_name_) - { - global_->attach_text(&cont[0]); - } - else - { - sch.schm = new sane_config_schm(); - if (sch.schm->load_from_mem(cont.c_str(), false)) - { - sch.name = sane_config_schm::from_hex_letter(name.c_str(), name.length()); - sch.schm->set_scheme_name(sch.name.c_str()); - schemes_.push_back(sch); - } - else - sch.schm->release(); - } - - first->next = next; - walk_sibling_schemes(next); - } - - int scanner_cfg::load_file(const char* file) - { - std::string cont(""); - int ret = gb::load_mini_file(file, cont); - - if (ret == 0) - ret = load_mem(cont.c_str()); - - // if (ret == 0 && scanner_name_.empty()) - { - const char* name = strrchr(file, PATH_SYMBOL[0]); - if (name++ == nullptr) - name = file; - else - path_ = std::string(file, name - file); - - scanner_name_ = name; - ret = scanner_name_.rfind('.'); - if (ret != std::string::npos) - scanner_name_.erase(ret); - ret = 0; - } - - return ret; - } - int scanner_cfg::load_mem(const char* mem) - { - base64 b64; - std::string text(b64.decode(mem, strlen(mem))); - cJSON* root = cJSON_Parse(text.c_str()); - - if (!root) - { - FILE* dst = fopen((path_ + "err_cfg.txt").c_str(), "wb"); - fwrite(text.c_str(), 1, text.length(), dst); - fclose(dst); - return EINVAL; - } - - clear(); - walk_sibling_schemes(root->child); - cJSON_Delete(root); - - return 0; - } - int scanner_cfg::save(const char* file) - { - if (!file && path_.empty() && scanner_name_.empty()) - return EINVAL; - - std::string cont("{\"" + scanner_cfg::global_name_ + "\":"), - f(file ? file : path_ + scanner_name_ + ".cfg"), - v(""); - int sel = -1; - - if (!global_->get_value("ver", v) || v.empty()) - init_version(); - if (!global_->get_value(scanner_cfg::cur_sel_.c_str(), sel) || sel >= schemes_.size()) - init_select(); - - cont += global_->to_string(false); - for (auto& v: schemes_) - { - cont += ",\"" + sane_config_schm::to_hex_letter(v.name.c_str(), v.name.length()) + "\":"; - cont += v.schm->to_text_stream(false, false); - } - cont += "}"; - - base64 b64; - FILE* dst = fopen(f.c_str(), "wb"); - - if (!dst) - return errno; - - f = b64.encode(cont.c_str(), cont.length()); - fwrite(f.c_str(), 1, f.length(), dst); - fclose(dst); - - return 0; - } - - void scanner_cfg::get_all_schemes(std::vector& schemes) - { - schemes.push_back(scanner_cfg::default_setting_name_); - for (auto& v : schemes_) - schemes.push_back(v.name); - } - sane_config_schm* scanner_cfg::get_scheme(const char* scheme_name) - { - sane_config_schm* found = nullptr; - - if (scheme_name && *scheme_name) - { - std::vector::iterator it = std::find(schemes_.begin(), schemes_.end(), scheme_name); - if (it != schemes_.end()) - found = it->schm; - } - else - { - int ind = -1; - - global_->get_value(scanner_cfg::cur_sel_.c_str(), ind); - if (ind >= 0 && ind < schemes_.size()) - found = schemes_[ind].schm; - } - - if (found) - found->add_ref(); - - return found; - } - std::string scanner_cfg::get_current_scheme_name(void) - { - int ind = -1; - - global_->get_value(scanner_cfg::cur_sel_.c_str(), ind); - if (ind >= 0 && ind < schemes_.size()) - return schemes_[ind].name; - else - return scanner_cfg::default_setting_name_; - } - bool scanner_cfg::remove_scheme(const char* scheme_name) - { - std::vector::iterator it = std::find(schemes_.begin(), schemes_.end(), scheme_name); - - if (it != schemes_.end()) - { - int id = it - schemes_.begin(), - ind = -1; - - it->schm->release(); - schemes_.erase(it); - global_->get_value(scanner_cfg::cur_sel_.c_str(), ind); - if (ind == id) - global_->set_value(scanner_cfg::cur_sel_.c_str(), -1); - else if (ind > id) - global_->set_value(scanner_cfg::cur_sel_.c_str(), ind - 1); - - return true; - } - - return false; - } - void scanner_cfg::remove_all_schemes(void) - { - for(auto& v: schemes_) - v.schm->release(); - - schemes_.clear(); - } - bool scanner_cfg::select_scheme(const char* scheme_name) - { - std::vector::iterator it = scheme_name ? std::find(schemes_.begin(), schemes_.end(), scheme_name) : schemes_.end(); - - if (it == schemes_.end()) - global_->set_value(scanner_cfg::cur_sel_.c_str(), -1); - else - global_->set_value(scanner_cfg::cur_sel_.c_str(), (int)(it - schemes_.begin())); - - return true; - } - - sane_config_schm* scanner_cfg::copy_scheme(const char* cp_from_name) // for UI setting, call release() if not use anymore - { - if (!cp_from_name) - return nullptr; - else if (scanner_cfg::default_setting_name_ == cp_from_name) - return new sane_config_schm(); - else - { - std::vector::iterator it = std::find(schemes_.begin(), schemes_.end(), cp_from_name); - if (it == schemes_.end()) - return nullptr; - - std::string cont(it->schm->to_text_stream()); - sane_config_schm* schm = new sane_config_schm(); - schm->load_from_mem(cont.c_str()); - - return schm; - } - } - bool scanner_cfg::add_scheme(sane_config_schm* schm, const char* name) - { - CFGSCHM cs; - - cs.name = name ? name : schm->get_scheme_name(); - if(cs.name.empty() || cs.name == scanner_cfg::global_name_) - return false; - - if (std::find(schemes_.begin(), schemes_.end(), cs.name.c_str()) != schemes_.end()) - return false; - - cs.schm = schm; - - schemes_.push_back(cs); - schm->set_scheme_name(cs.name.c_str()); - schm->add_ref(); - - return true; - } - bool scanner_cfg::rename_scheme(const char* from, const char* to) - { - if (to && std::find(schemes_.begin(), schemes_.end(), to) != schemes_.end()) - return false; - - for(auto& v: schemes_) - { - if(v.name == from) - { - v.name = to; - v.schm->set_scheme_name(to); - return true; - } - } - - return false; - } -} diff --git a/app/scanner/cfg/gb_json.h b/app/scanner/cfg/gb_json.h deleted file mode 100644 index ffc79d94..00000000 --- a/app/scanner/cfg/gb_json.h +++ /dev/null @@ -1,233 +0,0 @@ -#pragma once - -#if defined(WIN32) || defined(_WIN64) -#include -#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 -#include -#include -#include - -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& 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& 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 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 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& 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); - }; -}; diff --git a/app/scanner/custom_file_dialog.h b/app/scanner/custom_file_dialog.h deleted file mode 100644 index b1aaed54..00000000 --- a/app/scanner/custom_file_dialog.h +++ /dev/null @@ -1,260 +0,0 @@ -#ifndef CUSTOM_FILE_DIALOG_H -#define CUSTOM_FILE_DIALOG_H - -#include -#include -#include -#include -#include -#include -#include - -#define USE_FILE_DLG_WITHOUT_PROMPT - -template -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(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(obj); - if(grp) - { - printf("Found button-group with %d buttons\n", grp->buttons().size()); - QList btns = grp->buttons(); - for(auto& b : btns) - { - btn = dynamic_cast(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(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(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(obj); - if(l) - { - printf("Found list widget\n"); - } - else { - QListView *v = dynamic_cast(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(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(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(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 diff --git a/app/scanner/cutdialog.cpp b/app/scanner/cutdialog.cpp deleted file mode 100644 index be564c48..00000000 --- a/app/scanner/cutdialog.cpp +++ /dev/null @@ -1,465 +0,0 @@ -#include "cutdialog.h" -#include "ui_cutdialog.h" -#include -#include -#include -#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; -} diff --git a/app/scanner/cutdialog.h b/app/scanner/cutdialog.h deleted file mode 100644 index 2f77ef2a..00000000 --- a/app/scanner/cutdialog.h +++ /dev/null @@ -1,100 +0,0 @@ -#ifndef CUTDIALOG_H -#define CUTDIALOG_H - -#include -#include -#include -#include - -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 diff --git a/app/scanner/cutdialog.ui b/app/scanner/cutdialog.ui deleted file mode 100644 index de03c34e..00000000 --- a/app/scanner/cutdialog.ui +++ /dev/null @@ -1,44 +0,0 @@ - - - cutDialog - - - true - - - - 0 - 0 - 321 - 342 - - - - - 0 - 0 - - - - - 2 - 0 - - - - - 2 - 0 - - - - true - - - cutDialog - - - - - - diff --git a/app/scanner/cutpapertool.cpp b/app/scanner/cutpapertool.cpp deleted file mode 100644 index 88c076ac..00000000 --- a/app/scanner/cutpapertool.cpp +++ /dev/null @@ -1,212 +0,0 @@ -#include "cutpapertool.h" -#include "ui_cutpapertool.h" -#include -#include - -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(); -} diff --git a/app/scanner/cutpapertool.h b/app/scanner/cutpapertool.h deleted file mode 100644 index 14319c14..00000000 --- a/app/scanner/cutpapertool.h +++ /dev/null @@ -1,56 +0,0 @@ -#ifndef CUTPAPERTOOL_H -#define CUTPAPERTOOL_H - -#include -#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 diff --git a/app/scanner/cutpapertool.ui b/app/scanner/cutpapertool.ui deleted file mode 100644 index 0e5178d6..00000000 --- a/app/scanner/cutpapertool.ui +++ /dev/null @@ -1,298 +0,0 @@ - - - CutPaperTool - - - true - - - - 0 - 0 - 439 - 676 - - - - - 0 - 0 - - - - 自定义扫描区域 - - - - - - - - 纸张尺寸: - - - - - - - A4 - - - - - - - (210*297) - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - DPI(像素/英寸): - - - Qt::AlignJustify|Qt::AlignVCenter - - - - - - - 200 - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - 单位: - - - - - - - - 毫米(mm) - - - - - 英寸(in) - - - - - 像素(px) - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - 初始化选择区域 - - - - - - - - - true - - - - - 0 - 0 - 421 - 430 - - - - - - - - 0 - 0 - - - - - - - - - - - - - - x: - - - - - - - - - - mm - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - y: - - - - - - - - - - mm - - - - - - - - - - - w: - - - - - - - - - - mm - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - h: - - - - - - - - - - mm - - - - - - - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - - - cutDialog - QWidget -
cutdialog.h
- 1 -
-
- - -
diff --git a/app/scanner/device_menu.cpp b/app/scanner/device_menu.cpp deleted file mode 100644 index 1259f158..00000000 --- a/app/scanner/device_menu.cpp +++ /dev/null @@ -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 lock(mutex_); - std::vector::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 lock(mutex_); - std::vector::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& dev_names) -{ - std::lock_guard 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 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::iterator it = std::find(menus_.begin(), menus_.end(), QString::fromStdString((s.name))); - POPMENU pm; - std::vector 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); -} diff --git a/app/scanner/device_menu.h b/app/scanner/device_menu.h deleted file mode 100644 index 316f2bcf..00000000 --- a/app/scanner/device_menu.h +++ /dev/null @@ -1,506 +0,0 @@ -#ifndef DEVICE_MENU_H -#define DEVICE_MENU_H - -#include -#include -#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 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(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& 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& 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 actions; - - bool operator==(const QString& menu_title) - { - return menu->title() == menu_title; - } - }POPMENU; - std::vector 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& 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 diff --git a/app/scanner/dialog_admin.cpp b/app/scanner/dialog_admin.cpp deleted file mode 100644 index 83f29d7a..00000000 --- a/app/scanner/dialog_admin.cpp +++ /dev/null @@ -1,51 +0,0 @@ -#include "dialog_admin.h" -#include "ui_dialog_admin.h" -#include - -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()); -} diff --git a/app/scanner/dialog_admin.h b/app/scanner/dialog_admin.h deleted file mode 100644 index 6c65ea22..00000000 --- a/app/scanner/dialog_admin.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef DIALOG_ADMIN_H -#define DIALOG_ADMIN_H - -#include - -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 diff --git a/app/scanner/dialog_admin.ui b/app/scanner/dialog_admin.ui deleted file mode 100644 index 724b8484..00000000 --- a/app/scanner/dialog_admin.ui +++ /dev/null @@ -1,142 +0,0 @@ - - - Dialog_Admin - - - - 0 - 0 - 379 - 119 - - - - - 400 - 130 - - - - Account sign in - - - - - - - - - 54 - 0 - - - - Account: - - - - - - - - 20 - 20 - - - - - - - :/images/statusbar/image_rsc/statusbar/statusBar_admin.png - - - true - - - - - - - Administrator - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - password: - - - - - - - QLineEdit::Password - - - - - - - Show password - - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - false - - - Sign In - - - - - - - Cancel - - - - - - - - - - diff --git a/app/scanner/dialog_aquireinto.cpp b/app/scanner/dialog_aquireinto.cpp deleted file mode 100644 index 62a46ef5..00000000 --- a/app/scanner/dialog_aquireinto.cpp +++ /dev/null @@ -1,530 +0,0 @@ -#include "dialog_aquireinto.h" -#include "ui_dialog_aquireinto.h" -#include "dialog_writesettings.h" -#include -#include -#include -#include -#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 -#include - -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("")); -} diff --git a/app/scanner/dialog_aquireinto.h b/app/scanner/dialog_aquireinto.h deleted file mode 100644 index 6059da1a..00000000 --- a/app/scanner/dialog_aquireinto.h +++ /dev/null @@ -1,90 +0,0 @@ -#ifndef DIALOG_AQUIREINTO_H -#define DIALOG_AQUIREINTO_H - -#include - -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 diff --git a/app/scanner/dialog_aquireinto.ui b/app/scanner/dialog_aquireinto.ui deleted file mode 100644 index 1805a661..00000000 --- a/app/scanner/dialog_aquireinto.ui +++ /dev/null @@ -1,570 +0,0 @@ - - - Dialog_AquireInto - - - - 0 - 0 - 699 - 398 - - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - Batch scanning - - - - - - - 211 - 16777215 - - - - configuration scheme management - - - - - - existing configuration scheme - - - - - - - - 0 - 31 - - - - - 16777215 - 16777215 - - - - - - - - - - - 0 - 31 - - - - found scheme - - - - - - - - 0 - 31 - - - - - 16777215 - 16777215 - - - - change name - - - - - - - - - - - - 0 - 31 - - - - - 16777215 - 16777215 - - - - delete - - - - - - - - 0 - 31 - - - - - 16777215 - 16777215 - - - - delete all configurations - - - - - - - - - - 0 - 31 - - - - Restore Defaults - - - - - - - Qt::Vertical - - - - 17 - 279 - - - - - - - - - - - - - - - - Directory - - - - - - - true - - - - - - - ... - - - - - - - - - Use subfolder based on current date - - - - - - - Use subfolder based on blank pages - - - - - - - Use subfolder based on image color type - - - - - - - - - File name - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - File name index - - - - - - - - Start index - - - - - - - - 0 - 0 - - - - 99999 - - - 1 - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - Digit(s) - - - - - - - 2 - - - - 1 - - - - - 2 - - - - - 3 - - - - - 4 - - - - - 5 - - - - - - - - e.g. 'HGScan001' - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - - Even and odd pages - - - - - Odd pages - - - - - Even pages - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - - - - Format - - - - - - - - JPG - JPG / 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) - - - - - - - - Compression option - - - - - - - - - - - Save as multipages (TIFF/PDF/OFD/GIF) - - - - - - - true - - - 所有页 - - - true - - - - - - - true - - - 用户自定义页数 - - - - - - - true - - - - 0 - 0 - - - - 1 - - - 1000 - - - - - - - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - - - - - - - buttonBox - accepted() - Dialog_AquireInto - accept() - - - 248 - 254 - - - 157 - 274 - - - - - buttonBox - rejected() - Dialog_AquireInto - reject() - - - 316 - 260 - - - 286 - 274 - - - - - diff --git a/app/scanner/dialog_clrcache.cpp b/app/scanner/dialog_clrcache.cpp deleted file mode 100644 index e9b2dc8c..00000000 --- a/app/scanner/dialog_clrcache.cpp +++ /dev/null @@ -1,188 +0,0 @@ -#include "dialog_clrcache.h" -#include "ui_dialog_clrcache.h" -#include -#include -#include -#include -#include -#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(); -} diff --git a/app/scanner/dialog_clrcache.h b/app/scanner/dialog_clrcache.h deleted file mode 100644 index 9b5287fe..00000000 --- a/app/scanner/dialog_clrcache.h +++ /dev/null @@ -1,45 +0,0 @@ -#ifndef DIALOG_CLRCACHE_H -#define DIALOG_CLRCACHE_H - -#include -#include -#include -#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 diff --git a/app/scanner/dialog_clrcache.ui b/app/scanner/dialog_clrcache.ui deleted file mode 100644 index 2cad2115..00000000 --- a/app/scanner/dialog_clrcache.ui +++ /dev/null @@ -1,172 +0,0 @@ - - - Dialog_ClrCache - - - - 0 - 0 - 490 - 159 - - - - - 0 - 159 - - - - - 16777215 - 159 - - - - Dialog - - - - - - - - Cache path: - - - - - - - true - - - - - - - ... - - - - - - - - - - - Cache occupied space: - - - - - - - 0 - - - - - - - B - - - - - - - (0 Byte) - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - Number of files: - - - - - - - 0 - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Clear Cache - - - - - - - ok - - - - - - - cancel - - - - - - - - - - diff --git a/app/scanner/dialog_export.cpp b/app/scanner/dialog_export.cpp deleted file mode 100644 index 5fd8a23a..00000000 --- a/app/scanner/dialog_export.cpp +++ /dev/null @@ -1,654 +0,0 @@ -#include "dialog_export.h" -#include "ui_dialog_export.h" -#include -#include -#include -#include -#include -#include "dialog_writesettings.h" -#include "base/HGBase.h" -#include "HGUIGlobal.h" -#include "app_cfg.h" -#include "ocrPdf.h" -#include - -#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 &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 &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(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::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; -} diff --git a/app/scanner/dialog_export.h b/app/scanner/dialog_export.h deleted file mode 100644 index 752764a4..00000000 --- a/app/scanner/dialog_export.h +++ /dev/null @@ -1,85 +0,0 @@ -#ifndef DIALOG_EXPORT_H -#define DIALOG_EXPORT_H - -#include -#include - -// 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 -#endif -{ - Q_OBJECT - - -public: - explicit Dialog_Export(int total, const std::vector &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 &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 m_supportType; - int m_total; - std::vector m_selectedIndexs; - - QString m_savePath; - QString m_saveName; - QString m_saveExt; - std::vector m_saveIndexs; - int m_suffix; -}; - -#endif // DIALOG_EXPORT_H diff --git a/app/scanner/dialog_export.ui b/app/scanner/dialog_export.ui deleted file mode 100644 index d92bd3bc..00000000 --- a/app/scanner/dialog_export.ui +++ /dev/null @@ -1,202 +0,0 @@ - - - Dialog_Export - - - - 0 - 0 - 650 - 530 - - - - Export - - - - - - - - - - - - - Page Range - - - - - - - - Nominate Pages(example:1,3,6 or 3-6) - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Chosen Pages - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - All Pages - - - - - - - - - - - Page: - - - - - - - - - - true - - - color: rgb(216, 0, 0); - - - -Input is not valid. -Page range will be "Chosen Pages". - - - - true - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - - - - - - Save as multipages (TIFF/PDF/OFD/GIF) - - - - - - - Ocr type: - - - - - - - - 111 - 0 - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Compression Option - - - - - - - - - - - - QFileDialog - QWidget -
qfiledialog.h
- 1 -
-
- - radio_chosenPages - radio_nominatedPages - radio_allPages - lineEdit_nominatePages - check_saveAsMulti - btn_option - - - -
diff --git a/app/scanner/dialog_exportimagefile.cpp b/app/scanner/dialog_exportimagefile.cpp deleted file mode 100644 index 3739aa3e..00000000 --- a/app/scanner/dialog_exportimagefile.cpp +++ /dev/null @@ -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 -#include -#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; -} diff --git a/app/scanner/dialog_exportimagefile.h b/app/scanner/dialog_exportimagefile.h deleted file mode 100644 index cbd3a477..00000000 --- a/app/scanner/dialog_exportimagefile.h +++ /dev/null @@ -1,55 +0,0 @@ -#ifndef DIALOG_EXPORTIMAGEFILE_H -#define DIALOG_EXPORTIMAGEFILE_H - -#include -#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 diff --git a/app/scanner/dialog_exportimagefile.ui b/app/scanner/dialog_exportimagefile.ui deleted file mode 100644 index 9d65fb42..00000000 --- a/app/scanner/dialog_exportimagefile.ui +++ /dev/null @@ -1,78 +0,0 @@ - - - Dialog_ExportImageFile - - - - 0 - 0 - 400 - 300 - - - - Dialog - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - 0 - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - stop - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - diff --git a/app/scanner/dialog_feedback.cpp b/app/scanner/dialog_feedback.cpp deleted file mode 100644 index 103a2ab1..00000000 --- a/app/scanner/dialog_feedback.cpp +++ /dev/null @@ -1,73 +0,0 @@ -#include "dialog_feedback.h" -#include "ui_dialog_feedback.h" -#include - -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(); -} diff --git a/app/scanner/dialog_feedback.h b/app/scanner/dialog_feedback.h deleted file mode 100644 index 2afbf877..00000000 --- a/app/scanner/dialog_feedback.h +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef DIALOG_FEEDBACK_H -#define DIALOG_FEEDBACK_H - -#include -#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 diff --git a/app/scanner/dialog_feedback.ui b/app/scanner/dialog_feedback.ui deleted file mode 100644 index 87fd7085..00000000 --- a/app/scanner/dialog_feedback.ui +++ /dev/null @@ -1,76 +0,0 @@ - - - Dialog_Feedback - - - - 0 - 0 - 488 - 281 - - - - Dialog - - - - - - feedback: - - - - - - - - - - - - contact: - - - - - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - submit - - - - - - - cancel - - - - - - - - - - diff --git a/app/scanner/dialog_fullscreen.cpp b/app/scanner/dialog_fullscreen.cpp deleted file mode 100644 index 3086383f..00000000 --- a/app/scanner/dialog_fullscreen.cpp +++ /dev/null @@ -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 - -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); -} diff --git a/app/scanner/dialog_fullscreen.h b/app/scanner/dialog_fullscreen.h deleted file mode 100644 index 43355ba0..00000000 --- a/app/scanner/dialog_fullscreen.h +++ /dev/null @@ -1,59 +0,0 @@ -#ifndef DIALOG_FULLSCREEN_H -#define DIALOG_FULLSCREEN_H - -#include -#include -#include -#include - -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 diff --git a/app/scanner/dialog_fullscreen.ui b/app/scanner/dialog_fullscreen.ui deleted file mode 100644 index 6a369b4c..00000000 --- a/app/scanner/dialog_fullscreen.ui +++ /dev/null @@ -1,359 +0,0 @@ - - - Dialog_FullScreen - - - - 0 - 0 - 689 - 492 - - - - false - - - Full Screen - - - false - - - background-color: rgb(0, 0, 0); - - - - - - true - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Qt::NoFocus - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - true - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 62 - 1 - - - - - - - - false - - - true - - - Qt::NoFocus - - - - - - - :/images/image_rsc/actions/nextpage.png:/images/image_rsc/actions/nextpage.png - - - - 50 - 50 - - - - Ctrl+Right - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 62 - 1 - - - - - - - - false - - - true - - - Qt::NoFocus - - - - - - - - - - :/images/image_rsc/actions/previousfile.png:/images/image_rsc/actions/previousfile.png - - - - 50 - 50 - - - - Left - - - true - - - - - - - Qt::Horizontal - - - - 40 - 1 - - - - - - - - false - - - true - - - Qt::NoFocus - - - - - - - - - - :/images/image_rsc/actions/nextfile.png:/images/image_rsc/actions/nextfile.png - - - - 50 - 50 - - - - Right - - - true - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 62 - 1 - - - - - - - - Qt::Horizontal - - - - 40 - 1 - - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 62 - 1 - - - - - - - - false - - - true - - - Qt::NoFocus - - - - - - - :/images/image_rsc/actions/previouspage.png:/images/image_rsc/actions/previouspage.png - - - - 50 - 50 - - - - Ctrl+Left - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - - - HGImgView - QWidget -
HGImgView.h
- 1 -
-
- - - - -
diff --git a/app/scanner/dialog_imageeditor.cpp b/app/scanner/dialog_imageeditor.cpp deleted file mode 100644 index 85839699..00000000 --- a/app/scanner/dialog_imageeditor.cpp +++ /dev/null @@ -1,257 +0,0 @@ -#include "dialog_imageeditor.h" -#include "ui_dialog_imageeditor.h" -#include "graphicsscene.h" -#include -#include - -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); -} diff --git a/app/scanner/dialog_imageeditor.h b/app/scanner/dialog_imageeditor.h deleted file mode 100644 index 15bdb708..00000000 --- a/app/scanner/dialog_imageeditor.h +++ /dev/null @@ -1,71 +0,0 @@ -#ifndef DIALOG_IMAGEEDITOR_H -#define DIALOG_IMAGEEDITOR_H - -#include -#include - -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 diff --git a/app/scanner/dialog_imageeditor.ui b/app/scanner/dialog_imageeditor.ui deleted file mode 100644 index 5db93195..00000000 --- a/app/scanner/dialog_imageeditor.ui +++ /dev/null @@ -1,365 +0,0 @@ - - - Dialog_ImageEditor - - - - 0 - 0 - 1378 - 378 - - - - Dialog_ImageEditor - - - - 0 - - - - - - - - - - Qt::NoFocus - - - rect - - - Rect - - - true - - - - - - - Qt::NoFocus - - - ellipse - - - Ellipse - - - true - - - - - - - Qt::NoFocus - - - line - - - Line - - - true - - - - - - - Qt::NoFocus - - - Pen - - - true - - - - - - - Qt::NoFocus - - - arrow - - - Arrow - - - true - - - - - - - Qt::NoFocus - - - text - - - Text - - - true - - - - - - - Color - - - - - - - - 30 - 30 - - - - Qt::NoFocus - - - color - - - - - - - - - - LineWidth - - - - - - - - 1 pix - - - - - 3 pix - - - - - 5 pix - - - - - 8 pix - - - - - - - - TextSize - - - - - - - 0 - - - - 20 - - - - - 26 - - - - - 36 - - - - - 48 - - - - - 72 - - - - - 96 - - - - - 128 - - - - - 160 - - - - - 200 - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Qt::NoFocus - - - zoomin - - - Zoomin - - - - - - - fit - - - Fit - - - - - - - Qt::NoFocus - - - 100% - - - 1:1 - - - - - - - Qt::NoFocus - - - zoomout - - - Zoomout - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Qt::NoFocus - - - undo - - - Undo - - - Ctrl+Z - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - ok - - - Ok - - - - - - - cancel - - - Cancel - - - - - - - - - - - diff --git a/app/scanner/dialog_imageinfo.cpp b/app/scanner/dialog_imageinfo.cpp deleted file mode 100644 index 2b46ef51..00000000 --- a/app/scanner/dialog_imageinfo.cpp +++ /dev/null @@ -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<treeWidget,list); - ui->treeWidget->addTopLevelItem(class1); - list.clear(); - list<treeWidget,list); - ui->treeWidget->addTopLevelItem(class2); - - QList 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; -} diff --git a/app/scanner/dialog_imageinfo.h b/app/scanner/dialog_imageinfo.h deleted file mode 100644 index f8503edb..00000000 --- a/app/scanner/dialog_imageinfo.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef DIALOG_IMAGEINFO_H -#define DIALOG_IMAGEINFO_H - -#include -#include - -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 diff --git a/app/scanner/dialog_imageinfo.ui b/app/scanner/dialog_imageinfo.ui deleted file mode 100644 index 1f4a3144..00000000 --- a/app/scanner/dialog_imageinfo.ui +++ /dev/null @@ -1,85 +0,0 @@ - - - Dialog_ImageInfo - - - - 0 - 0 - 400 - 300 - - - - Image information - - - - - - QAbstractItemView::NoEditTriggers - - - true - - - false - - - true - - - - 1 - - - - - - - - Qt::Horizontal - - - QDialogButtonBox::Ok - - - - - - - - - buttonBox - accepted() - Dialog_ImageInfo - accept() - - - 248 - 254 - - - 157 - 274 - - - - - buttonBox - rejected() - Dialog_ImageInfo - reject() - - - 316 - 260 - - - 286 - 274 - - - - - diff --git a/app/scanner/dialog_imgproc_adjust.cpp b/app/scanner/dialog_imgproc_adjust.cpp deleted file mode 100644 index df1c4f22..00000000 --- a/app/scanner/dialog_imgproc_adjust.cpp +++ /dev/null @@ -1,146 +0,0 @@ -#include "dialog_imgproc_adjust.h" -#include "ui_dialog_imgproc_adjust.h" -#include "imgproc/HGImgProc.h" -#include "app_cfg.h" -#include - -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(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(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)); -} diff --git a/app/scanner/dialog_imgproc_adjust.h b/app/scanner/dialog_imgproc_adjust.h deleted file mode 100644 index ace8fb41..00000000 --- a/app/scanner/dialog_imgproc_adjust.h +++ /dev/null @@ -1,53 +0,0 @@ -#ifndef DIALOG_IMGPROC_ADJUST_H -#define DIALOG_IMGPROC_ADJUST_H - -#include -#include -#include -#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 diff --git a/app/scanner/dialog_imgproc_adjust.ui b/app/scanner/dialog_imgproc_adjust.ui deleted file mode 100644 index 9c7f4753..00000000 --- a/app/scanner/dialog_imgproc_adjust.ui +++ /dev/null @@ -1,169 +0,0 @@ - - - Dialog_ImgProc_Adjust - - - - 0 - 0 - 463 - 543 - - - - Adjust - - - - - - - - Show preview - - - - - - - Qt::Horizontal - - - - - - - - - - - Before - - - - - - - 150 - 100 - - - - - - - - - - - After - - - - - - - 150 - 100 - - - - - - - - - - - - - - - Apply to image - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok|QDialogButtonBox::RestoreDefaults - - - - - - - - HGImgView - QWidget -
HGImgView.h
- 1 -
-
- - - - buttonBox - accepted() - Dialog_ImgProc_Adjust - accept() - - - 248 - 254 - - - 157 - 274 - - - - - buttonBox - rejected() - Dialog_ImgProc_Adjust - reject() - - - 316 - 260 - - - 286 - 274 - - - - -
diff --git a/app/scanner/dialog_imgproc_autocrop.cpp b/app/scanner/dialog_imgproc_autocrop.cpp deleted file mode 100644 index af2bd618..00000000 --- a/app/scanner/dialog_imgproc_autocrop.cpp +++ /dev/null @@ -1,180 +0,0 @@ -#include "dialog_imgproc_autocrop.h" -#include "ui_dialog_imgproc_autocrop.h" -#include -#include -#include -#include -#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; - } -} diff --git a/app/scanner/dialog_imgproc_autocrop.h b/app/scanner/dialog_imgproc_autocrop.h deleted file mode 100644 index 9ecf6127..00000000 --- a/app/scanner/dialog_imgproc_autocrop.h +++ /dev/null @@ -1,58 +0,0 @@ -#ifndef DIALOG_IMGPROC_AUTOCROP_H -#define DIALOG_IMGPROC_AUTOCROP_H - -#include -#include - -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 diff --git a/app/scanner/dialog_imgproc_autocrop.ui b/app/scanner/dialog_imgproc_autocrop.ui deleted file mode 100644 index c799ef50..00000000 --- a/app/scanner/dialog_imgproc_autocrop.ui +++ /dev/null @@ -1,372 +0,0 @@ - - - Dialog_ImgProc_AutoCrop - - - - 0 - 0 - 600 - 408 - - - - - 0 - 0 - - - - - 600 - 420 - - - - Auto crop - - - - - - - - - - Auto crop - - - - - - - Auto correct skew - - - - - - - true - - - Fill black frame type - - - true - - - false - - - - - - Convex polygon - - - true - - - - - - - Concave polygon - - - - - - - Auto Color - - - - - - - Default Color - - - - - - - - - - Advanced parameters - - - true - - - false - - - - - - - - - 16777215 - 16777215 - - - - Threshold - - - - - - - - 16777215 - 16777215 - - - - 255 - - - 40 - - - - - - - - - - - Anti background noise - - - - - - - - 16777215 - 16777215 - - - - 80 - - - 40 - - - - - - - - - - - Edge indent - - - - - - - - 16777215 - 16777215 - - - - 20 - - - 5 - - - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - Qt::Vertical - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - 100 - 100 - - - - - 100 - 100 - - - - before - - - Qt::AlignCenter - - - - - - - - 30 - 30 - - - - - 36 - 36 - - - - - - - :/image_rsc/example/example_arrow.png - - - Qt::AlignCenter - - - - - - - - 100 - 100 - - - - - 100 - 100 - - - - after - - - Qt::AlignCenter - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok|QDialogButtonBox::RestoreDefaults - - - - - - - - - buttonBox - accepted() - Dialog_ImgProc_AutoCrop - accept() - - - 248 - 254 - - - 157 - 274 - - - - - buttonBox - rejected() - Dialog_ImgProc_AutoCrop - reject() - - - 316 - 260 - - - 286 - 274 - - - - - diff --git a/app/scanner/dialog_input.cpp b/app/scanner/dialog_input.cpp deleted file mode 100644 index 1eff99bf..00000000 --- a/app/scanner/dialog_input.cpp +++ /dev/null @@ -1,86 +0,0 @@ -#include "dialog_input.h" -#include "ui_dialog_input.h" -#include -#include - -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(); -} diff --git a/app/scanner/dialog_input.h b/app/scanner/dialog_input.h deleted file mode 100644 index 5f8bc321..00000000 --- a/app/scanner/dialog_input.h +++ /dev/null @@ -1,35 +0,0 @@ -#ifndef DIALOG_INPUT_H -#define DIALOG_INPUT_H - -#include - -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 diff --git a/app/scanner/dialog_input.ui b/app/scanner/dialog_input.ui deleted file mode 100644 index 1508f61c..00000000 --- a/app/scanner/dialog_input.ui +++ /dev/null @@ -1,85 +0,0 @@ - - - Dialog_Input - - - - 0 - 0 - 282 - 82 - - - - Dialog - - - - - - - - -1 - - - 输入: - - - 0 - - - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Ok - - - - - - - Cancel - - - - - - - - - - diff --git a/app/scanner/dialog_insertindex.cpp b/app/scanner/dialog_insertindex.cpp deleted file mode 100644 index c4143d74..00000000 --- a/app/scanner/dialog_insertindex.cpp +++ /dev/null @@ -1,49 +0,0 @@ -#include "dialog_insertindex.h" -#include "ui_dialog_insertindex.h" -#include -#include -#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); -} diff --git a/app/scanner/dialog_insertindex.h b/app/scanner/dialog_insertindex.h deleted file mode 100644 index 2962bfc8..00000000 --- a/app/scanner/dialog_insertindex.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef DIALOG_INSERTINDEX_H -#define DIALOG_INSERTINDEX_H - -#include - -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 diff --git a/app/scanner/dialog_insertindex.ui b/app/scanner/dialog_insertindex.ui deleted file mode 100644 index a146d4a3..00000000 --- a/app/scanner/dialog_insertindex.ui +++ /dev/null @@ -1,104 +0,0 @@ - - - Dialog_InsertIndex - - - - 0 - 0 - 335 - 149 - - - - Insert index selection - - - - - - Insert location - - - - - - Before first page - - - - - - - Before current page - - - - - - - After current page - - - - - - - After last page - - - true - - - - - - - - - - Qt::Vertical - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - - - - buttonBox - accepted() - Dialog_InsertIndex - accept() - - - 248 - 254 - - - 157 - 274 - - - - - buttonBox - rejected() - Dialog_InsertIndex - reject() - - - 316 - 260 - - - 286 - 274 - - - - - diff --git a/app/scanner/dialog_log.cpp b/app/scanner/dialog_log.cpp deleted file mode 100644 index f1c3885d..00000000 --- a/app/scanner/dialog_log.cpp +++ /dev/null @@ -1,179 +0,0 @@ -#include "dialog_log.h" -#include "ui_dialog_log.h" -#include -#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; -} - - diff --git a/app/scanner/dialog_log.h b/app/scanner/dialog_log.h deleted file mode 100644 index ffb936ea..00000000 --- a/app/scanner/dialog_log.h +++ /dev/null @@ -1,69 +0,0 @@ -#ifndef DIALOG_SCANNERLOG_H -#define DIALOG_SCANNERLOG_H - -#include -#include -#include -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 diff --git a/app/scanner/dialog_log.ui b/app/scanner/dialog_log.ui deleted file mode 100644 index d67bc19c..00000000 --- a/app/scanner/dialog_log.ui +++ /dev/null @@ -1,31 +0,0 @@ - - - dialog_log - - - - 0 - 0 - 531 - 161 - - - - 日志 - - - - - - - - - - - - - - - - - diff --git a/app/scanner/dialog_logmanager.cpp b/app/scanner/dialog_logmanager.cpp deleted file mode 100644 index 99102f85..00000000 --- a/app/scanner/dialog_logmanager.cpp +++ /dev/null @@ -1,105 +0,0 @@ -#include "dialog_logmanager.h" -#include "ui_dialog_logmanager.h" -#include "base/HGUtility.h" -#include "base/HGInfo.h" -#include -#include -#include -#include -#include -#include - -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 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)); -} diff --git a/app/scanner/dialog_logmanager.h b/app/scanner/dialog_logmanager.h deleted file mode 100644 index c5972a49..00000000 --- a/app/scanner/dialog_logmanager.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef DIALOG_LOGMANAGER_H -#define DIALOG_LOGMANAGER_H - -#include -#include - -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 diff --git a/app/scanner/dialog_logmanager.ui b/app/scanner/dialog_logmanager.ui deleted file mode 100644 index f6048350..00000000 --- a/app/scanner/dialog_logmanager.ui +++ /dev/null @@ -1,139 +0,0 @@ - - - Dialog_LogManager - - - - 0 - 0 - 487 - 354 - - - - Dialog - - - - - - - - Directory... - - - - - - - true - - - - - - - File Type: - - - - - - - - 100 - 16777215 - - - - - All(*.*) - - - - - Image(*.jpg,*.bmp,*.png,*.tif) - - - - - PDF(*.pdf) - - - - - Text(*.txt) - - - - - Config(*.ini,*.xml) - - - - - Website(*.html) - - - - - HGlog(*.HGLog) - - - - - - - - - - Qt::Horizontal - - - - - - - - - - - - Clear - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Export... - - - - - - - Cancel - - - - - - - - - - diff --git a/app/scanner/dialog_moveto.cpp b/app/scanner/dialog_moveto.cpp deleted file mode 100644 index ebf89251..00000000 --- a/app/scanner/dialog_moveto.cpp +++ /dev/null @@ -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; -} diff --git a/app/scanner/dialog_moveto.h b/app/scanner/dialog_moveto.h deleted file mode 100644 index 09d7b3bc..00000000 --- a/app/scanner/dialog_moveto.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef DIALOG_MOVETO_H -#define DIALOG_MOVETO_H - -#include - -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 diff --git a/app/scanner/dialog_moveto.ui b/app/scanner/dialog_moveto.ui deleted file mode 100644 index cc6b00e1..00000000 --- a/app/scanner/dialog_moveto.ui +++ /dev/null @@ -1,126 +0,0 @@ - - - Dialog_MoveTo - - - - 0 - 0 - 265 - 83 - - - - move to - - - - - - - - target index: - - - - - - - - 0 - 0 - - - - - 100 - 0 - - - - - 100 - 16777215 - - - - 100 - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - - - - buttonBox - accepted() - Dialog_MoveTo - accept() - - - 248 - 254 - - - 157 - 274 - - - - - buttonBox - rejected() - Dialog_MoveTo - reject() - - - 316 - 260 - - - 286 - 274 - - - - - diff --git a/app/scanner/dialog_multirotate.cpp b/app/scanner/dialog_multirotate.cpp deleted file mode 100644 index 3d3cb565..00000000 --- a/app/scanner/dialog_multirotate.cpp +++ /dev/null @@ -1,50 +0,0 @@ -#include "dialog_multirotate.h" -#include "ui_dialog_multirotate.h" -#include -#include - -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; -} - - diff --git a/app/scanner/dialog_multirotate.h b/app/scanner/dialog_multirotate.h deleted file mode 100644 index 9ea574d1..00000000 --- a/app/scanner/dialog_multirotate.h +++ /dev/null @@ -1,35 +0,0 @@ -#ifndef DIALOG_MULTIROTATE_H -#define DIALOG_MULTIROTATE_H - -#include - -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 diff --git a/app/scanner/dialog_multirotate.ui b/app/scanner/dialog_multirotate.ui deleted file mode 100644 index 3501b546..00000000 --- a/app/scanner/dialog_multirotate.ui +++ /dev/null @@ -1,171 +0,0 @@ - - - Dialog_MultiRotate - - - - 0 - 0 - 350 - 250 - - - - - 350 - 250 - - - - - 350 - 250 - - - - Multiple rotation - - - - - - - - Rotation - - - - - - 90° - - - true - - - - - - - 180° - - - - - - - -90° - - - - - - - - - - Pages - - - - - - Current page - - - true - - - - - - - Selected pages - - - - - - - All odd pages - - - - - - - All even pages - - - - - - - All pages - - - - - - - - - - Qt::Vertical - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - - - - Attentions: -This operation will NOT rotate the files that may contain multiple pages, such as .pdf, .tif, etc. - - - true - - - - - - - - - buttonBox - accepted() - Dialog_MultiRotate - accept() - - - 248 - 254 - - - 157 - 274 - - - - - buttonBox - rejected() - Dialog_MultiRotate - reject() - - - 316 - 260 - - - 286 - 274 - - - - - diff --git a/app/scanner/dialog_multirotateimagefile.cpp b/app/scanner/dialog_multirotateimagefile.cpp deleted file mode 100644 index a30569dd..00000000 --- a/app/scanner/dialog_multirotateimagefile.cpp +++ /dev/null @@ -1,158 +0,0 @@ -#include "dialog_multirotateimagefile.h" -#include "ui_dialog_multirotateimagefile.h" -#include "imgfmt/HGImgFmt.h" -#include "HGUIGlobal.h" -#include "mainwindow.h" -#include -#include - -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; -} diff --git a/app/scanner/dialog_multirotateimagefile.h b/app/scanner/dialog_multirotateimagefile.h deleted file mode 100644 index 45023443..00000000 --- a/app/scanner/dialog_multirotateimagefile.h +++ /dev/null @@ -1,49 +0,0 @@ -#ifndef DIALOG_MULTIROTATEIMAGEFILE_H -#define DIALOG_MULTIROTATEIMAGEFILE_H - -#include -#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 diff --git a/app/scanner/dialog_multirotateimagefile.ui b/app/scanner/dialog_multirotateimagefile.ui deleted file mode 100644 index 7cbc30fd..00000000 --- a/app/scanner/dialog_multirotateimagefile.ui +++ /dev/null @@ -1,78 +0,0 @@ - - - Dialog_MultiRotateImageFile - - - - 0 - 0 - 400 - 300 - - - - Dialog - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - 0 - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - stop - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - diff --git a/app/scanner/dialog_openimageindex.cpp b/app/scanner/dialog_openimageindex.cpp deleted file mode 100644 index eaedeeb2..00000000 --- a/app/scanner/dialog_openimageindex.cpp +++ /dev/null @@ -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; -} diff --git a/app/scanner/dialog_openimageindex.h b/app/scanner/dialog_openimageindex.h deleted file mode 100644 index 7d40d09b..00000000 --- a/app/scanner/dialog_openimageindex.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef DIALOG_OPENIMAGEINDEX_H -#define DIALOG_OPENIMAGEINDEX_H - -#include -#include - -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 diff --git a/app/scanner/dialog_openimageindex.ui b/app/scanner/dialog_openimageindex.ui deleted file mode 100644 index d6eebf61..00000000 --- a/app/scanner/dialog_openimageindex.ui +++ /dev/null @@ -1,117 +0,0 @@ - - - Dialog_OpenImageIndex - - - - 0 - 0 - 255 - 84 - - - - Open Page - - - - - - - - pageIndex: - - - - - - - - 0 - 0 - - - - - 121 - 0 - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - Qt::Vertical - - - - 20 - 0 - - - - - - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - - - - buttonBox - accepted() - Dialog_OpenImageIndex - accept() - - - 248 - 254 - - - 157 - 274 - - - - - buttonBox - rejected() - Dialog_OpenImageIndex - reject() - - - 316 - 260 - - - 286 - 274 - - - - - diff --git a/app/scanner/dialog_passwordchange.cpp b/app/scanner/dialog_passwordchange.cpp deleted file mode 100644 index 5165e81a..00000000 --- a/app/scanner/dialog_passwordchange.cpp +++ /dev/null @@ -1,102 +0,0 @@ -#include "dialog_passwordchange.h" -#include "ui_dialog_passwordchange.h" -#include -#include -#include -#include - -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<lineEdit_oldPassword<lineEdit_newPassword<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.")); -} diff --git a/app/scanner/dialog_passwordchange.h b/app/scanner/dialog_passwordchange.h deleted file mode 100644 index 62587325..00000000 --- a/app/scanner/dialog_passwordchange.h +++ /dev/null @@ -1,48 +0,0 @@ -#ifndef DIALOG_PASSWORDCHANGE_H -#define DIALOG_PASSWORDCHANGE_H - -#include - -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 m_lineEditList; - QRegExpValidator *qReg; -}; - -#endif // DIALOG_PASSWORDCHANGE_H diff --git a/app/scanner/dialog_passwordchange.ui b/app/scanner/dialog_passwordchange.ui deleted file mode 100644 index bbb2290a..00000000 --- a/app/scanner/dialog_passwordchange.ui +++ /dev/null @@ -1,157 +0,0 @@ - - - Dialog_PasswordChange - - - - 0 - 0 - 440 - 190 - - - - - 440 - 190 - - - - Change password - - - - - - - - - 130 - 0 - - - - - 130 - 16777215 - - - - Old password: - - - - - - - - - - - - - - - 130 - 0 - - - - - 130 - 16777215 - - - - New password: - - - - - - - - - - - - - - - 130 - 0 - - - - - 130 - 16777215 - - - - Confirm new password: - - - - - - - - - - - - Show password - - - - - - - Password only allowed to use numbers, English and special characters. -Password length should between 8-20 charactors. - - - true - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - false - - - OK - - - - - - - Cancel - - - - - - - - - - diff --git a/app/scanner/dialog_saveas.cpp b/app/scanner/dialog_saveas.cpp deleted file mode 100644 index 79d79882..00000000 --- a/app/scanner/dialog_saveas.cpp +++ /dev/null @@ -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 -#include -#include - -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(); -} diff --git a/app/scanner/dialog_saveas.h b/app/scanner/dialog_saveas.h deleted file mode 100644 index 4dae2287..00000000 --- a/app/scanner/dialog_saveas.h +++ /dev/null @@ -1,39 +0,0 @@ -#ifndef DIALOG_SAVEAS_H -#define DIALOG_SAVEAS_H - -#include - -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 diff --git a/app/scanner/dialog_saveas.ui b/app/scanner/dialog_saveas.ui deleted file mode 100644 index b02c1f83..00000000 --- a/app/scanner/dialog_saveas.ui +++ /dev/null @@ -1,80 +0,0 @@ - - - Dialog_SaveAs - - - - 0 - 0 - 586 - 437 - - - - Save As - - - - - - - - - - - Compression Option - - - - - - - Use subfolder based on current date - - - - - - - Ocr type: - - - - - - - - 101 - 0 - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - QFileDialog - QWidget -
qfiledialog.h
- 1 -
-
- - -
diff --git a/app/scanner/dialog_savemessagebox.cpp b/app/scanner/dialog_savemessagebox.cpp deleted file mode 100644 index 08ff20fb..00000000 --- a/app/scanner/dialog_savemessagebox.cpp +++ /dev/null @@ -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(); -} diff --git a/app/scanner/dialog_savemessagebox.h b/app/scanner/dialog_savemessagebox.h deleted file mode 100644 index 94e7ce75..00000000 --- a/app/scanner/dialog_savemessagebox.h +++ /dev/null @@ -1,39 +0,0 @@ -#ifndef DIALOG_SAVEMESSAGEBOX_H -#define DIALOG_SAVEMESSAGEBOX_H - -#include - -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 diff --git a/app/scanner/dialog_savemessagebox.ui b/app/scanner/dialog_savemessagebox.ui deleted file mode 100644 index 56f5502f..00000000 --- a/app/scanner/dialog_savemessagebox.ui +++ /dev/null @@ -1,109 +0,0 @@ - - - Dialog_SaveMessageBox - - - - 0 - 0 - 387 - 104 - - - - Dialog - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - TextLabel - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Yes - - - - - - - Yes to All - - - - - - - No - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - diff --git a/app/scanner/dialog_updateprogress.cpp b/app/scanner/dialog_updateprogress.cpp deleted file mode 100644 index e2800347..00000000 --- a/app/scanner/dialog_updateprogress.cpp +++ /dev/null @@ -1,88 +0,0 @@ -#include "dialog_updateprogress.h" -#include "ui_dialog_updateprogress.h" -#include "base/HGInfo.h" -#include -#include -#include -#include - -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; -} diff --git a/app/scanner/dialog_updateprogress.h b/app/scanner/dialog_updateprogress.h deleted file mode 100644 index 688c908f..00000000 --- a/app/scanner/dialog_updateprogress.h +++ /dev/null @@ -1,46 +0,0 @@ -#ifndef DIALOG_UPDATEPROGRESS_H -#define DIALOG_UPDATEPROGRESS_H - -#include -#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 diff --git a/app/scanner/dialog_updateprogress.ui b/app/scanner/dialog_updateprogress.ui deleted file mode 100644 index 28a1918f..00000000 --- a/app/scanner/dialog_updateprogress.ui +++ /dev/null @@ -1,65 +0,0 @@ - - - Dialog_updateProgress - - - - 0 - 0 - 500 - 101 - - - - Dialog - - - - - - 24 - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - stop - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - diff --git a/app/scanner/dialog_upgrade.cpp b/app/scanner/dialog_upgrade.cpp deleted file mode 100644 index 05e30b0d..00000000 --- a/app/scanner/dialog_upgrade.cpp +++ /dev/null @@ -1,86 +0,0 @@ -#include "dialog_upgrade.h" -#include "ui_dialog_upgrade.h" -#include "base/HGUtility.h" -#include -#include -#include -#include - -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(); -} diff --git a/app/scanner/dialog_upgrade.h b/app/scanner/dialog_upgrade.h deleted file mode 100644 index af3703e3..00000000 --- a/app/scanner/dialog_upgrade.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef DIALOG_UPGRADE_H -#define DIALOG_UPGRADE_H - -#include -#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 diff --git a/app/scanner/dialog_upgrade.ui b/app/scanner/dialog_upgrade.ui deleted file mode 100644 index 6fd22c7a..00000000 --- a/app/scanner/dialog_upgrade.ui +++ /dev/null @@ -1,65 +0,0 @@ - - - Dialog_upgrade - - - - 0 - 0 - 431 - 253 - - - - Dialog - - - - - - detect result. versionNum: - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - upgrade the latest version - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - diff --git a/app/scanner/dialog_upgradefirmware.cpp b/app/scanner/dialog_upgradefirmware.cpp deleted file mode 100644 index 3517d7dd..00000000 --- a/app/scanner/dialog_upgradefirmware.cpp +++ /dev/null @@ -1,62 +0,0 @@ -#include "dialog_upgradefirmware.h" -#include "ui_dialog_upgradefirmware.h" -#include - -Dialog_upgradeFirmware::Dialog_upgradeFirmware(SANE_Handle handle, const std::string &upgradePath, QWidget *parent) : - QDialog(parent) - , m_handle(handle) - , m_upgradePath(upgradePath) - , m_status(SANE_STATUS_INVAL) - , ui(new Ui::Dialog_upgradeFirmware) -{ - ui->setupUi(this); - - setWindowTitle(tr("upgrade")); - setWindowFlags(Qt::Dialog | Qt::FramelessWindowHint); - - ui->label_text->setText(tr("firmware upgrade in progress, please wait...")); - - QMovie *movie = new QMovie(":images/image_rsc/logo/waiting.gif"); - ui->label_gif->setMovie(movie); - movie->setCacheMode(QMovie::CacheAll); - movie->setScaledSize(QSize(ui->label_gif->width(), ui->label_gif->height())); - movie->start(); - ui->label_gif->show(); - - connect(this, SIGNAL(finish()), this, SLOT(on_finish()), Qt::QueuedConnection); - - HGBase_OpenThread(ThreadFunc, this, &m_thread); -} - -Dialog_upgradeFirmware::~Dialog_upgradeFirmware() -{ - if (nullptr != m_thread) - { - HGBase_CloseThread(m_thread); - m_thread = nullptr; - } - - delete ui; -} - -void HGAPI Dialog_upgradeFirmware::ThreadFunc(HGThread thread, HGPointer param) -{ - (void)thread; - Dialog_upgradeFirmware *p = (Dialog_upgradeFirmware *)param; - - SANE_Status rc = sane_io_control(p->m_handle, IO_CTRL_CODE_SET_FIRMWARE_UPGRADE, (void*)p->m_upgradePath.c_str(), NULL); - p->m_status = rc; - - emit p->finish(); -} - -SANE_Status Dialog_upgradeFirmware::getUpgradeStatus() -{ - return m_status; -} - -void Dialog_upgradeFirmware::on_finish() -{ - accept(); -} - diff --git a/app/scanner/dialog_upgradefirmware.h b/app/scanner/dialog_upgradefirmware.h deleted file mode 100644 index fd1afa7b..00000000 --- a/app/scanner/dialog_upgradefirmware.h +++ /dev/null @@ -1,43 +0,0 @@ -#ifndef DIALOG_UPGRADEFIRMWARE_H -#define DIALOG_UPGRADEFIRMWARE_H - -#include -#include "base/HGThread.h" -#include "sane/sane_ex.h" - -namespace Ui { -class Dialog_upgradeFirmware; -} - -class Dialog_upgradeFirmware : public QDialog -{ - Q_OBJECT - -public: - explicit Dialog_upgradeFirmware(SANE_Handle handle, const std::string &upgradePath, QWidget *parent = nullptr); - ~Dialog_upgradeFirmware(); - -private: - static void HGAPI ThreadFunc(HGThread thread, HGPointer param); - -public: - SANE_Status getUpgradeStatus(); - -signals: - void finish(); - -private slots: - void on_finish(); - -private: - SANE_Handle m_handle; - std::string m_upgradePath; - SANE_Status m_status; - - HGThread m_thread; - -private: - Ui::Dialog_upgradeFirmware *ui; -}; - -#endif // DIALOG_UPGRADEFIRMWARE_H diff --git a/app/scanner/dialog_upgradefirmware.ui b/app/scanner/dialog_upgradefirmware.ui deleted file mode 100644 index df195eaa..00000000 --- a/app/scanner/dialog_upgradefirmware.ui +++ /dev/null @@ -1,127 +0,0 @@ - - - Dialog_upgradeFirmware - - - - 0 - 0 - 435 - 125 - - - - Dialog - - - - - - Qt::Vertical - - - - 20 - 19 - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 40 - 60 - - - - gif - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - text - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - Qt::Vertical - - - - 20 - 20 - - - - - - - - - diff --git a/app/scanner/dialog_writesettings.cpp b/app/scanner/dialog_writesettings.cpp deleted file mode 100644 index 59fba5e4..00000000 --- a/app/scanner/dialog_writesettings.cpp +++ /dev/null @@ -1,64 +0,0 @@ -#include "dialog_writesettings.h" -#include "ui_dialog_writesettings.h" -#include "app_cfg.h" - -Dialog_WriteSettings::Dialog_WriteSettings(int suffix_type, QWidget *parent) : - QDialog(parent), - ui(new Ui::Dialog_WriteSettings) -{ - ui->setupUi(this); - //set visible - bool jpg_enable = (suffix_type == 0 || suffix_type == 7 || suffix_type == 8); - bool tif_enable = (suffix_type == 6); - ui->lab_tif_bw->setVisible(tif_enable); - ui->cbox_tif_bw->setVisible(tif_enable); - ui->lab_tif_color->setVisible(tif_enable); - ui->cbox_tif_color->setVisible(tif_enable); - ui->lab_spin_tif_jpgQuality->setVisible(tif_enable); - ui->spin_tif_quality->setVisible(tif_enable); - ui->lab_slider_jpg_low->setVisible(jpg_enable); - ui->lab_slider_jpg_high->setVisible(jpg_enable); - ui->slider_jpg_quality->setVisible(jpg_enable); - ui->lab_spin_jpgQuality->setVisible(jpg_enable); - ui->spin_jpg_quality->setVisible(jpg_enable); - //set value - - ui->slider_jpg_quality->setValue(getCfgValue("saveParam", "jpegQuality", 80)); - ui->spin_jpg_quality->setValue(getCfgValue("saveParam", "jpegQuality", 80)); - ui->cbox_tif_bw->setCurrentIndex(getCfgValue("saveParam", "tiffCompBW", 1)); - ui->cbox_tif_color->setCurrentIndex(getCfgValue("saveParam", "tiffCompClr", 1)); - ui->spin_tif_quality->setValue(getCfgValue("saveParam", "tiffQuality", 80)); - //set enable - ui->spin_tif_quality->setEnabled(ui->cbox_tif_color->currentIndex()==2); - - ui->spin_jpg_quality->setMinimumWidth(160); - ui->spin_tif_quality->setMinimumWidth(160); -} - -Dialog_WriteSettings::~Dialog_WriteSettings() -{ - delete ui; -} - -void Dialog_WriteSettings::on_cbox_tif_color_currentIndexChanged(int index) -{ - ui->spin_tif_quality->setEnabled(index == 2); -} - -void Dialog_WriteSettings::on_slider_jpg_quality_valueChanged(int value) -{ - ui->spin_jpg_quality->setValue(value); -} - -void Dialog_WriteSettings::on_spin_jpg_quality_valueChanged(int arg1) -{ - ui->slider_jpg_quality->setValue(arg1); -} - -void Dialog_WriteSettings::on_buttonBox_accepted() -{ - saveCfgValue("saveParam", "jpegQuality", ui->spin_jpg_quality->value()); - saveCfgValue("saveParam", "tiffCompBW", ui->cbox_tif_bw->currentIndex()); - saveCfgValue("saveParam", "tiffCompClr", ui->cbox_tif_color->currentIndex()); - saveCfgValue("saveParam", "tiffQuality", ui->spin_tif_quality->value()); -} diff --git a/app/scanner/dialog_writesettings.h b/app/scanner/dialog_writesettings.h deleted file mode 100644 index b5cc171b..00000000 --- a/app/scanner/dialog_writesettings.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef DIALOG_WRITESETTINGS_H -#define DIALOG_WRITESETTINGS_H - -#include - -class QSettings; -namespace Ui { -class Dialog_WriteSettings; -} - -class Dialog_WriteSettings : public QDialog -{ - Q_OBJECT - -public: - explicit Dialog_WriteSettings(int suffix_type, QWidget *parent = nullptr); - ~Dialog_WriteSettings(); - -private slots: - void on_cbox_tif_color_currentIndexChanged(int index); - - void on_slider_jpg_quality_valueChanged(int value); - - void on_spin_jpg_quality_valueChanged(int arg1); - - void on_buttonBox_accepted(); - -private: - Ui::Dialog_WriteSettings *ui; -}; - -#endif // DIALOG_WRITESETTINGS_H diff --git a/app/scanner/dialog_writesettings.ui b/app/scanner/dialog_writesettings.ui deleted file mode 100644 index dbbe55bc..00000000 --- a/app/scanner/dialog_writesettings.ui +++ /dev/null @@ -1,335 +0,0 @@ - - - Dialog_WriteSettings - - - - 0 - 0 - 454 - 178 - - - - Write Settings - - - - - - - - - 115 - 0 - - - - Compression for black&white picture - - - true - - - - - - - - 80 - 0 - - - - - None - - - - - LZW - - - - - CCITT G4 - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - - 115 - 0 - - - - Compression for color picture - - - true - - - - - - - - 80 - 0 - - - - - None - - - - - LZW - - - - - JPEG - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - 2 - - - - - - - - - - - - - - Quality - - - - - - - - - - - - - Lowest - - - - - - - Qt::LeftToRight - - - Best - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - - 100 - - - 80 - - - Qt::Horizontal - - - false - - - QSlider::TicksAbove - - - 10 - - - - - - - - - - - - - - - - - - - 0 - 0 - - - - 100 - - - 80 - - - - - - - - - - - - - - - - - - - 0 - 0 - - - - 100 - - - 80 - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - - - - buttonBox - accepted() - Dialog_WriteSettings - accept() - - - 248 - 254 - - - 157 - 274 - - - - - buttonBox - rejected() - Dialog_WriteSettings - reject() - - - 316 - 260 - - - 286 - 274 - - - - - diff --git a/app/scanner/dialog_wrong_img.cpp b/app/scanner/dialog_wrong_img.cpp deleted file mode 100644 index 2b205ca4..00000000 --- a/app/scanner/dialog_wrong_img.cpp +++ /dev/null @@ -1,74 +0,0 @@ -#include "dialog_wrong_img.h" -#include "ui_dialog_wrong_img.h" -#include "sane/sane_ex.h" -#include "imgfmt/HGImgFmt.h" - -dialog_wrong_img::dialog_wrong_img(QWidget *parent, QString img_file, int index, int statu) - : QDialog(parent) - , ui(new Ui::Dialog_wrong_img) - , save_(false), img_file_(img_file), index_(index), statu_(statu) -{ - ui->setupUi(this); - // connect(pbtn_stop, SIGNAL(clicked(bool)), this, SLOT(on_pbtn_stop_clicked())); - if(statu == SANE_Image_Statu_Double) // 双张图片,请确认是否要保留 - setWindowTitle(QString::fromStdString("\345\217\214\345\274\240\345\233\276\347\211\207\357\274\214\350\257\267\347\241\256\350\256\244\346\230\257\345\220\246\350\246\201\344\277\235\347\225\231")); - else if(statu == SANE_Image_Statu_Jammed) // 卡纸图片,请确认是否要保留 - setWindowTitle(QString::fromStdString("\345\215\241\347\272\270\345\233\276\347\211\207\357\274\214\350\257\267\347\241\256\350\256\244\346\230\257\345\220\246\350\246\201\344\277\235\347\225\231")); - else { - // 异常(%d)图片,请确认是否要保留 - char msg[256] = {0}; - sprintf(msg, "\345\274\202\345\270\270\357\274\210%d\357\274\211\345\233\276\347\211\207\357\274\214\350\257\267\347\241\256\350\256\244\346\230\257\345\220\246\350\246\201\344\277\235\347\225\231", statu); - setWindowTitle(QString::fromStdString(msg)); - } - - view_ = new HGImgView(this); - - view_->setFixedSize(300, 200); - - HGImage img = nullptr; - HGImgFmtReader imgFmtReader = nullptr; - HGImgFmt_OpenImageReader(img_file.toStdString().c_str(), 0, &imgFmtReader); - if (nullptr != imgFmtReader) - { - HGImgFmt_LoadImageFromReader(imgFmtReader, (HGUInt)0, nullptr, 0, HGBASE_IMGORIGIN_TOP, &img); - HGImgFmt_CloseImageReader(imgFmtReader); - view_->addImage(img); - HGBase_DestroyImage(img); - } -} - -dialog_wrong_img::~dialog_wrong_img() -{ - delete ui; -} - -QString dialog_wrong_img::image_file(void) -{ - return img_file_; -} -int dialog_wrong_img::index(void) -{ - return index_; -} -int dialog_wrong_img::increase_index(void) -{ - return ++index_; -} - -void dialog_wrong_img::closeEvent(QCloseEvent *event) -{ - emit handle_wrong_img(this, save_); -} - - -void dialog_wrong_img::on_buttonBox_accepted() -{ - save_ = true; - close(); -} - -void dialog_wrong_img::on_buttonBox_rejected() -{ - save_ = false; - close(); -} diff --git a/app/scanner/dialog_wrong_img.h b/app/scanner/dialog_wrong_img.h deleted file mode 100644 index acbcc065..00000000 --- a/app/scanner/dialog_wrong_img.h +++ /dev/null @@ -1,45 +0,0 @@ -#ifndef DIALOG_WRONG_IMG_H -#define DIALOG_WRONG_IMG_H - -#include -#include -#include "HGImgView.h" - -namespace Ui { -class Dialog_wrong_img; -} - -class dialog_wrong_img : public QDialog -{ - Q_OBJECT - bool save_; - QString img_file_; - int index_; - int statu_; - HGImgView *view_; - - -public: - explicit dialog_wrong_img(QWidget *parent, QString img_file, int index, int statu); - ~dialog_wrong_img(); - - QString image_file(void); - int index(void); - int increase_index(void); - -signals: - void handle_wrong_img(dialog_wrong_img* dlg, bool save); - -private slots: - void on_buttonBox_accepted(); - - void on_buttonBox_rejected(); - -private: - void closeEvent(QCloseEvent *event); - -private: - Ui::Dialog_wrong_img *ui; -}; - -#endif // DIALOG_WRONG_IMG_H diff --git a/app/scanner/dialog_wrong_img.ui b/app/scanner/dialog_wrong_img.ui deleted file mode 100644 index 717718e0..00000000 --- a/app/scanner/dialog_wrong_img.ui +++ /dev/null @@ -1,74 +0,0 @@ - - - Dialog_wrong_img - - - - 0 - 0 - 320 - 240 - - - - - 0 - 0 - - - - Dialog - - - - - 10 - 200 - 301 - 32 - - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - - buttonBox - accepted() - Dialog_wrong_img - accept() - - - 248 - 254 - - - 157 - 274 - - - - - buttonBox - rejected() - Dialog_wrong_img - reject() - - - 316 - 260 - - - 286 - 274 - - - - - diff --git a/app/scanner/etc/qt.conf b/app/scanner/etc/qt.conf deleted file mode 100644 index 2620cdc2..00000000 --- a/app/scanner/etc/qt.conf +++ /dev/null @@ -1,2 +0,0 @@ -[Platforms] -WindowsArguments = dpiawareness=0 \ No newline at end of file diff --git a/app/scanner/gaosixy.cpp b/app/scanner/gaosixy.cpp deleted file mode 100644 index 15de754a..00000000 --- a/app/scanner/gaosixy.cpp +++ /dev/null @@ -1,54 +0,0 @@ -#include "gaosixy.h" -#include -#include -#include - -GaoSiXY::GaoSiXY() -{ -} - -void GaoSiXY::solve(double**a,int n,double *recv) -{ - int m = 0; - int i,j; - - for(j = 0; j < n; j++){ - double max = 0; - double imax = 0; - for(i = j; i < n; i++){ - if(imax < fabs(a[i][j])){ - imax = fabs(a[i][j]); - max = a[i][j];//得到各行中所在列最大元素 - m = i; - } - } - if(fabs(a[j][j]) != max) { - double b = 0; - for(int k = j;k < n + 1; k++){ - b = a[j][k]; - a[j][k] = a[m][k]; - a[m][k] = b; } - } - for(int r = j;r < n + 1;r++){ - a[j][r] = a[j][r] / max;//让该行的所在列除以所在列的第一个元素,目的是让首元素为1 - } - for(i = j + 1;i < n; i++){ - double c = a[i][j]; - if(c == 0) continue; - for(int s = j;s < n + 1;s++){ - //double tempdata = a[i][s]; - a[i][s] = a[i][s] - a[j][s] * c;//前后行数相减,使下一行或者上一行的首元素为0 - } - } - } - for(i = n - 2; i >= 0; i--){ - for(j = i + 1;j < n; j++){ - a[i][n] = a[i][n] - a[j][n] * a[i][j]; - } - } - - for(int k = 0; k < n; k++){ - recv[k] = a[k][n]; - } - -} diff --git a/app/scanner/gaosixy.h b/app/scanner/gaosixy.h deleted file mode 100644 index 4b446756..00000000 --- a/app/scanner/gaosixy.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef GAOSIXY_H -#define GAOSIXY_H - -#include -#include - -class GaoSiXY -{ -public: - GaoSiXY(); - void solve(double **a,int n,double *recv);//用于计算曲线方程 - -private: - -}; - -#endif // GAOSIXY_H diff --git a/app/scanner/graphicsscene.cpp b/app/scanner/graphicsscene.cpp deleted file mode 100644 index b38d8939..00000000 --- a/app/scanner/graphicsscene.cpp +++ /dev/null @@ -1,348 +0,0 @@ -#include "graphicsscene.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -GraphicsTextEdit::GraphicsTextEdit(QWidget* parent) - : QTextEdit(parent) -{ - viewport()->setWindowFlags(Qt::FramelessWindowHint); - //viewport()->setAttribute(Qt::WA_TranslucentBackground); - setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - - setContextMenuPolicy(Qt::ContextMenuPolicy::NoContextMenu); - connect(this, SIGNAL(textChanged()), this, SLOT(on_textChanged())); - - setStyleSheet("QTextEdit{background-color: transparent; border: 3px solid red;}"); - //setWindowOpacity(0.3); - //setMouseTracking(true); -} - -GraphicsTextEdit::~GraphicsTextEdit() -{ -} - -void GraphicsTextEdit::setDefeaultColor(const QColor& color) -{ - m_defeaultColor = color; - setTextColor(m_defeaultColor); -} - -#define BORDER_WIDTH 20 -void GraphicsTextEdit::on_textChanged() -{ - QFontMetrics fm(font()); - - QSize currentSize = this->size(); - QStringList lineText = document()->toPlainText().split("\n", QString::SkipEmptyParts); - - int idealWidth = 0; - for (const QString& str : lineText) - { - int width = fm.width(str); - if (width > idealWidth) - idealWidth = width; - } - int idelHeight = document()->lineCount() * fm.lineSpacing(); - - if (width() < idealWidth + BORDER_WIDTH) - currentSize.setWidth(idealWidth + BORDER_WIDTH); - if (height() < idelHeight + BORDER_WIDTH * 2) - currentSize.setHeight(idelHeight + BORDER_WIDTH * 2); - - if (currentSize != this->size()) - resize(currentSize); - - if (toPlainText().isEmpty()) - setTextColor(m_defeaultColor); -} - -GraphicsScene::GraphicsScene(QObject* parent) - : QGraphicsScene(parent) - , m_status(Normal) - , m_activeItem(nullptr) - , m_btn_pressed(0) - , m_pen(QColor(255, 0, 0, 255)) - , m_brush(QColor(255, 255, 255, 255)) - , m_font(tr("SongTi")) - , m_edit(nullptr) -{ -} - -GraphicsScene::~GraphicsScene() -{ -} - -void GraphicsScene::setColor(const QColor& color) -{ - m_pen.setColor(color); - m_brush.setColor(color); - if (m_edit != nullptr) - m_edit->setDefeaultColor(color); -} - -void GraphicsScene::setTextSize(int size) -{ - m_font.setPointSize(size); -} - -void GraphicsScene::setLineWidth(int width) -{ - m_pen.setWidth(width); -} - -void GraphicsScene::setItemFlag(int flag) -{ - if (m_status == CreateText) - { - if (m_activeItem != nullptr) - { - QString text = m_edit->document()->toPlainText(); - QFont font = m_edit->font(); - removeItem(m_activeItem); - QGraphicsTextItem* item = addText(text, font); - item->setPos(m_edit->mapToParent(QPoint())); - item->setDefaultTextColor(m_pen.color()); - delete m_edit; - m_edit = nullptr; - m_activeItem = nullptr; - } - } - - if (m_activeItem != nullptr) - { - if (typeid(*m_activeItem) == typeid(QGraphicsProxyWidget)) - removeItem(m_activeItem); - - m_activeItem = nullptr; - m_status = Normal; - } - - switch (flag) - { - case Rect: - m_status = CreateRect; - break; - case Ellipse: - m_status = CreateEllipse; - break; - case Line: - m_status = CreateLine; - break; - case Text: - m_status = CreateText; - break; - case Arrow: - m_status = CreateArrow; - break; - case Pen: - m_status = CreatePen; - break; - default: - m_status = Normal; - break; - } -} - -void GraphicsScene::unDo() -{ - m_activeItem = nullptr; - - QList items = this->items(); - if (items.count() < 2) - return; - - removeItem(items.first()); -} - -#define PI acos(-1) - -QPointF rotate(const QPointF& center, const QPointF& p, float angle) -{ - float angle_ = angle; - float x = (p.x() - center.x()) * cos(angle_) - (p.y() - center.y()) * sin(angle_) + center.x(); - float y = (p.y() - center.y()) * cos(angle_) + (p.x() - center.x()) * sin(angle_) + center.y(); - - return QPointF(x, y); -} - -float lineLength(const QPointF& p1, const QPointF& p2) -{ - return sqrt(pow(p1.x() - p2.x(), 2) + pow(p1.y() - p2.y(), 2)); -} - -QPainterPath GraphicsScene::createArrowPath(const QPointF& p1, const QPointF& p2) -{ - float angle; - if (p2.x() == p1.x()) - if (p2.y() > p1.y()) - angle = PI / 2; - else - angle = -PI / 2; - else - if (p2.x() < p1.x() && std::abs(p1.y() - p2.y()) < 0.000001) - angle = PI; - else - { - angle = atan((p2.y() - p1.y()) / (p2.x() - p1.x())); - if (p2.y() < p1.y() && p2.x() < p1.x()) - angle -= PI; - if (p2.y() > p1.y() && p2.x() < p1.x()) - angle += PI; - } - - float length = lineLength(p1, p2); - QPointF p_1 = rotate(p1, QPointF(p1.x() + length - 25, p1.y() + 15), angle); - QPointF p_2 = rotate(p1, QPointF(p1.x() + length - 25, p1.y() - 15), angle); - QPointF p_1_half = rotate(p1, QPointF(p1.x() + length - 22, p1.y() + 10), angle); - QPointF p_2_half = rotate(p1, QPointF(p1.x() + length - 22, p1.y() - 10), angle); - - QPainterPath path; - path.moveTo(p2); - path.lineTo(p_2); - path.lineTo(p_2_half); - path.lineTo(p1); - path.lineTo(p_1_half); - path.lineTo(p_1); - path.lineTo(p2); - - return path; -} - -void GraphicsScene::mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent) -{ - if (m_activeItem == nullptr) - return; - - if (!sceneRect().contains(mouseEvent->scenePos())) - return; - - if (m_status == CreateRect) - { - QGraphicsRectItem* item = reinterpret_cast(m_activeItem); - QPointF pos = mouseEvent->scenePos(); - float left = qMin(pos.x(), m_startPoint.x()); - float top = qMin(pos.y(), m_startPoint.y()); - float right = qMax(pos.x(), m_startPoint.x()); - float bottom = qMax(pos.y(), m_startPoint.y()); - item->setRect(QRectF(QPointF(left, top), QPointF(right, bottom))); - } - else if (m_status == CreateEllipse) - { - QGraphicsEllipseItem* item = reinterpret_cast(m_activeItem); - QPointF pos = mouseEvent->scenePos(); - float left = qMin(pos.x(), m_startPoint.x()); - float top = qMin(pos.y(), m_startPoint.y()); - float right = qMax(pos.x(), m_startPoint.x()); - float bottom = qMax(pos.y(), m_startPoint.y()); - item->setRect(QRectF(QPointF(left, top), QPointF(right, bottom))); - } - else if (m_status == CreateLine) - { - QGraphicsLineItem* item = reinterpret_cast(m_activeItem); - item->setLine(QLineF(m_startPoint, mouseEvent->scenePos())); - } - else if (m_status == CreateArrow) - { - QGraphicsPathItem* item = reinterpret_cast(m_activeItem); - item->setPath(createArrowPath(m_startPoint, mouseEvent->scenePos())); - } - else if (m_status == CreatePen) - { - QGraphicsPathItem* item = reinterpret_cast(m_activeItem); - QPainterPath path = item->path(); - path.lineTo(mouseEvent->scenePos()); - item->setPath(path); - } -} - -void GraphicsScene::mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent) -{ - if (mouseEvent->button() == Qt::MouseButton::LeftButton) - m_btn_pressed = 1; - else if (mouseEvent->button() == Qt::MouseButton::RightButton) - m_btn_pressed = 2; - - if (m_status == CreateRect) - { - m_activeItem = addRect(QRectF(mouseEvent->scenePos(), QSize(1, 1)), QPen(m_brush.color()), m_brush); - m_startPoint = mouseEvent->scenePos(); - } - else if (m_status == CreateEllipse) - { - m_activeItem = addEllipse(QRectF(mouseEvent->scenePos(), QSize(1, 1)), m_pen, QBrush()); - m_startPoint = mouseEvent->scenePos(); - } - else if (m_status == CreateLine) - { - m_activeItem = addLine(QLineF(mouseEvent->scenePos(), mouseEvent->scenePos()), m_pen); - m_startPoint = mouseEvent->scenePos(); - } - else if (m_status == CreateArrow) - { - m_startPoint = mouseEvent->scenePos(); - m_activeItem = addPath(createArrowPath(m_startPoint, mouseEvent->scenePos()), m_pen, QBrush(m_pen.color())); - } - else if (m_status == CreatePen) - { - m_startPoint = mouseEvent->scenePos(); - QPainterPath path(m_startPoint); - path.lineTo(m_startPoint + QPointF(1, 1)); - m_activeItem = addPath(path, m_pen, QBrush()); - } -} - -void GraphicsScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent) -{ - if (mouseEvent->button() == Qt::MouseButton::RightButton) - { - QGraphicsScene::mouseReleaseEvent(mouseEvent); - return; - } - - m_btn_pressed = 0; - if (m_activeItem != nullptr) - if (typeid(*m_activeItem) != typeid(QGraphicsProxyWidget)) - m_activeItem = nullptr; - - if (m_status == CreateText) - { - if (m_activeItem != nullptr) - { - QRectF r(m_edit->mapToParent(QPoint()), m_edit->size()); - if (r.contains(mouseEvent->scenePos())) - { - QGraphicsScene::mouseReleaseEvent(mouseEvent); - return; - } - QString text = m_edit->document()->toPlainText(); - QFont font = m_edit->font(); - removeItem(m_activeItem); - QGraphicsTextItem* item = addText(text, font); - item->setPos(m_edit->mapToParent(QPoint())); - item->setDefaultTextColor(m_pen.color()); - delete m_edit; - m_edit = nullptr; - m_activeItem = nullptr; - } - else - { - m_edit = new GraphicsTextEdit(); - m_edit->setDefeaultColor(m_pen.color()); - m_edit->setFont(m_font); - QGraphicsProxyWidget* widget = addWidget(m_edit, Qt::FramelessWindowHint); - widget->setPos(mouseEvent->scenePos()); - m_activeItem = widget; - m_edit->setFocus(); - } - - } -} diff --git a/app/scanner/graphicsscene.h b/app/scanner/graphicsscene.h deleted file mode 100644 index af501275..00000000 --- a/app/scanner/graphicsscene.h +++ /dev/null @@ -1,83 +0,0 @@ -#ifndef GRAPHICSSCENE_H -#define GRAPHICSSCENE_H - -#include -#include - -#include - -class GraphicsTextEdit : public QTextEdit -{ - Q_OBJECT -public: - GraphicsTextEdit(QWidget* parent = nullptr); - - ~GraphicsTextEdit(); - - void setDefeaultColor(const QColor& color); - -private slots: - void on_textChanged(); -private: - QColor m_defeaultColor; -}; - -class GraphicsScene : public QGraphicsScene -{ - Q_OBJECT -public: - enum STATUS - { - Normal = 0, - CreateRect, - CreateEllipse, - CreateLine, - CreateText, - CreateArrow, - CreatePen, - Erase - }; - - enum - { - None, - Rect, - Ellipse, - Line, - Text, - Arrow, - Pen - }; -public: - GraphicsScene(QObject* parent = nullptr); - - ~GraphicsScene(); - - void setColor(const QColor& color); - - void setTextSize(int size); - - void setLineWidth(int width); - - void setItemFlag(int flag); - - void unDo(); -private: - QPainterPath createArrowPath(const QPointF& p1, const QPointF& p2); - -protected: - virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent); - virtual void mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent); - virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent); -private: - STATUS m_status; - QGraphicsItem* m_activeItem; - int m_btn_pressed; - QPointF m_startPoint; - QPen m_pen; - QBrush m_brush; - QFont m_font; - GraphicsTextEdit* m_edit; -}; - -#endif // GRAPHICSSCENE_H diff --git a/app/scanner/hg_settingdialog.cpp b/app/scanner/hg_settingdialog.cpp deleted file mode 100644 index f4572823..00000000 --- a/app/scanner/hg_settingdialog.cpp +++ /dev/null @@ -1,2020 +0,0 @@ -#include "hg_settingdialog.h" - -#include -#include -#include "cutpapertool.h" -#include "setpicclrtool.h" -#include "base/HGDef.h" -#include "HGString.h" -#include "sane/sane_option_definitions.h" -#include "lang/app_language.h" -#include "dialog_input.h" -#include -#include "device_menu.h" - -std::string hg_settingdialog::property_combox_data_type_ = "combox_value_type"; - -hg_settingdialog::hg_settingdialog(void *handle, QWidget *parent - , dev_que* dev) - : QDialog(parent) - , dev_que_(dev), save_(false) - , btn_cut_area_(nullptr), btn_gamma_(nullptr), clicked_gamma_(false) - , custom_area_lable_(nullptr), comb_(nullptr) -{ - std::string n(dev->opened_scanner_name()); - for(int i = 0; i < dev->scanners(); ++i) - { - SCANNER s = dev->get_at(i); - if(s.name == n) - { - cur_cfg_ = s.cfg; - break; - } - } - cur_scheme_ = cur_cfg_->get_scheme(); - if(!cur_scheme_) - cur_scheme_ = new gb::sane_config_schm(); - cur_scheme_->begin_setting(); - - m_dpiId = -1; - m_dpiValue = 200; - m_paperSizeId = -1; - m_paperSizeValue.clear(); - m_cutLeftId = -1; - m_cutTopId = -1; - m_cutRightId = -1; - m_cutBottomId = -1; - m_cutWidth = 210; - m_cutHeight = 297; - m_cutLeftValue = 0; - m_cutTopValue = 0; - m_cutRightValue = 210; - m_cutBottomValue = 297; - - m_colorModeId = -1; - m_colorModeValue.clear(); - memset(&m_gammaData, 0, sizeof(m_gammaData)); - for(int i = 0; i < sizeof(m_gammaData.table) / sizeof(m_gammaData.table[0]); ++i) - m_gammaData.table[i] = i & 0x0ff; - - m_handle = handle; - initUi(); - on_current_scheme_changed(); - getAppVersion(); -} - -hg_settingdialog::~hg_settingdialog() -{ - cur_scheme_->release(); - cur_cfg_->release(); -} - -void hg_settingdialog::initUi() -{ - updateOpt(); - createUI(); - -#if defined(OEM_ZHONGJING) - setWindowTitle("Microtek DocWizard EX TWAIN"); -#else - setWindowTitle(QString::fromStdString(dev_que_->opened_scanner_name())); -#endif - - setWindowFlags(Qt::Dialog | Qt::WindowCloseButtonHint); - resize(740, height()); -} - -void hg_settingdialog::updateOpt() -{ - bool first = true; - - m_list_defaultOptions.clear(); - - SANE_Int dev_options = 0; - sane_control_option(m_handle, 0, SANE_ACTION_GET_VALUE, &dev_options, nullptr); - for (int i = 1, j= dev_options; i < j; i++) - { - const SANE_Option_Descriptor* opt = sane_get_option_descriptor(m_handle, i); - SANE_Int method = 0; - if (opt == nullptr) - { - m_list_defaultOptions.append(QPair(opt, QVariant(0))); - } - else - { - if(opt->type == SANE_TYPE_INT) - { - SANE_Int init = 0; - - sane_control_option(m_handle, i, SANE_ACTION_GET_VALUE, &init, &method); - m_list_defaultOptions.append(QPair(opt, QVariant(init))); - - if(first) - { - unsigned int n = i; - sane_io_control(m_handle, IO_CTRL_CODE_GET_DEFAULT_VALUE, &init, &n); - cur_scheme_->set_default_value(i, opt->name, (char*)&init, sizeof(init)); - } - } - else if(opt->type == SANE_TYPE_FIXED) - { - SANE_Fixed init = 0; - - sane_control_option(m_handle, i, SANE_ACTION_GET_VALUE, &init, &method); - m_list_defaultOptions.append(QPair(opt, QVariant(init))); - - if(first) - { - unsigned int n = i; - sane_io_control(m_handle, IO_CTRL_CODE_GET_DEFAULT_VALUE, &init, &n); - cur_scheme_->set_default_value(i, opt->name, (char*)&init, sizeof(init)); - } - } - else if(opt->type == SANE_TYPE_BOOL) - { - SANE_Bool init = 0; - - sane_control_option(m_handle, i, SANE_ACTION_GET_VALUE, &init, &method); - m_list_defaultOptions.append(QPair(opt, QVariant(init))); - - if(first) - { - unsigned int n = i; - sane_io_control(m_handle, IO_CTRL_CODE_GET_DEFAULT_VALUE, &init, &n); - cur_scheme_->set_default_value(i, opt->name, (char*)&init, sizeof(init)); - } - } - else if(opt->type == SANE_TYPE_STRING) - { - char *init = (char*)malloc(opt->size * 2 + 4); - - sane_control_option(m_handle, i, SANE_ACTION_GET_VALUE, init, &method); - m_list_defaultOptions.append(QPair(opt, QVariant(QString::fromStdString(init)))); - - if(first) - { - unsigned int n = i; - int err = sane_io_control(m_handle, IO_CTRL_CODE_GET_DEFAULT_VALUE, init, &n); - (void)err; - std::string langCN(to_default_language(init, nullptr)); - cur_scheme_->set_default_value(i, opt->name, &langCN[0], langCN.length()); - } - free(init); - } - else - { - m_list_defaultOptions.append(QPair(opt, QVariant(0))); - } - } - } -} - -QString hg_settingdialog::find_current_scheme_menu(int *scheme_id) -{ - QString text(comb_->currentText()); - - if(scheme_id) - { - if(comb_->currentIndex() >= 0 && comb_->currentIndex() < comb_->count()) - *scheme_id = comb_->currentIndex(); - else { - *scheme_id = -1; - } - } - - return text; -} -void hg_settingdialog::create_scheme_management_ui(QVBoxLayout* layout) -{ - QLabel *title = new QLabel(this); - bool enabled = false; - QHBoxLayout *hbox = new QHBoxLayout(); - int width = 180; - std::vector schemes; - std::string cur_schm(cur_cfg_->get_current_scheme_name()); - - cur_cfg_->get_all_schemes(schemes); - comb_ = new QComboBox(this); - layout->addSpacing(30); - for(int i = 1; i < (int)schemes.size(); ++i) - { - comb_->addItem(QString::fromStdString(schemes[i])); - if(cur_schm == schemes[i]) - { - enabled = true; - comb_->setCurrentText(QString::fromStdString(schemes[i])); - } - } - - if(!enabled) - comb_->setCurrentIndex(-1); - - title->setFixedWidth(width); - comb_->setFixedWidth(width); - - title->setText(tr("existing configuration scheme")); - layout->addWidget(title); - layout->addWidget(comb_); - - rename_ = new QPushButton(this); - rename_->setText(tr("change name")); - rename_->setEnabled(enabled); - rename_->setFixedWidth(width/3); - hbox->addWidget(rename_); - connect(rename_, SIGNAL(clicked(bool)), this, SLOT(slot_pushButton_scheme_management())); - - del_this_ = new QPushButton(this); - del_this_->setText(tr("delete")); - del_this_->setEnabled(enabled); - del_this_->setFixedWidth(width / 3); - hbox->addWidget(del_this_); - connect(del_this_, SIGNAL(clicked(bool)), this, SLOT(slot_pushButton_scheme_management())); - - apply_ = new QPushButton(this); - apply_->setText(tr("apply")); - apply_->setEnabled(enabled); - apply_->setFixedWidth(width / 3); - hbox->addWidget(apply_); - connect(apply_, SIGNAL(clicked(bool)), this, SLOT(slot_pushButton_scheme_management())); - hbox->setSizeConstraint(QLayout::SetFixedSize); - - layout->addLayout(hbox); - layout->addSpacing(10); - - del_all_ = new QPushButton(this); - del_all_->setText(tr("delete all configurations")); - del_all_->setEnabled(enabled); - del_all_->setFixedWidth(width); - layout->addWidget(del_all_); - connect(del_all_, SIGNAL(clicked(bool)), this, SLOT(slot_pushButton_scheme_management())); - - layout->addStretch(); - - title = new QLabel(this); - title->setText(tr("confgiuration information:")); - layout->addWidget(title); - - sketch_ = new QTextEdit(this); - sketch_->setReadOnly(true); - sketch_->setFixedSize(width, 200); - layout->addWidget(sketch_); - - connect(comb_, SIGNAL(currentTextChanged(const QString)), this, SLOT(on_current_scheme_changed())); - on_current_scheme_changed(); -} -void hg_settingdialog::createUI() -{ - QTabWidget *tabWidgetCreation = new QTabWidget(this); - - QPushButton *buttonOk = new QPushButton(this); - buttonOk->setText(tr("ok")); - QPushButton *buttonCancel = new QPushButton(this); - buttonCancel->setText(tr("cancel")); - QHBoxLayout *hlayoutOkAndCancel = new QHBoxLayout; - hlayoutOkAndCancel->addStretch(); - hlayoutOkAndCancel->addWidget(buttonOk); - hlayoutOkAndCancel->addWidget(buttonCancel); - QWidget *widgetOkAndCancel = new QWidget(); - widgetOkAndCancel->setLayout(hlayoutOkAndCancel); - connect(buttonOk, SIGNAL(clicked(bool)), this, SLOT(slot_buttonOkClicked())); - connect(buttonCancel, SIGNAL(clicked(bool)), this, SLOT(slot_buttonCancelClicked())); - - - QHBoxLayout *h = new QHBoxLayout(); - QVBoxLayout *v1 = new QVBoxLayout(), - *v2 = new QVBoxLayout(); - create_scheme_management_ui(v1); - v2->addWidget(tabWidgetCreation); - - QGroupBox *grp = new QGroupBox(tr("configuration scheme management"), this); - grp->setLayout(v1); - grp->setFixedSize(195, 500); - - h->addWidget(grp); - h->addLayout(v2); - - QVBoxLayout* mainVerticalLayout = new QVBoxLayout(this); - mainVerticalLayout->addLayout(h); -// mainVerticalLayout->addWidget(tabWidgetCreation); - mainVerticalLayout->addWidget(widgetOkAndCancel); - this->setLayout(mainVerticalLayout); - - QScrollArea* scrollArea = new QScrollArea; - scrollArea->setWidgetResizable(true); - scrollArea->setAlignment(Qt::AlignCenter); - QFormLayout* layout = new QFormLayout; - - QWidget* widget = new QWidget; - widget->setLayout(layout); - - bool isBegin = true; - std::string cur_val(""); - for (int i = 0; i < m_list_defaultOptions.size(); i++) - { - const SANE_Option_Descriptor* opt = reinterpret_cast(m_list_defaultOptions.at(i).first); - int ind = -1; - - if(opt == nullptr) continue; - h = nullptr; - cur_scheme_->get_config(opt->name, cur_val); - switch (opt->type) - { - case SANE_TYPE_BOOL: - { - QCheckBox *checkBoxCreation = new QCheckBox; - - if (strcmp(opt->name, SANE_STD_OPT_NAME_CUSTOM_AREA) == 0) - { - QWidget* widget_cbtn_pbtn = new QWidget; - widget_cbtn_pbtn->setMaximumWidth(200); - - QLabel *label = new QLabel; - label->setText(QString::fromStdString(opt->title) + QString(" : ")); - - btn_cut_area_ = new QPushButton; - btn_cut_area_->setText(tr("regional crop")); - btn_cut_area_->setFixedWidth(150); - - QHBoxLayout *hLayout = new QHBoxLayout; - hLayout->addWidget(checkBoxCreation); - hLayout->addWidget(btn_cut_area_); - widget_cbtn_pbtn->setLayout(hLayout); - - custom_area_lable_ = label; - - reinterpret_cast(widget->layout())->addRow(label, widget_cbtn_pbtn); - - connect(btn_cut_area_, SIGNAL(clicked(bool)), this, SLOT(slot_cutButtonClicked())); - } - else if (strcmp(opt->name, SANE_STD_OPT_NAME_IS_CUSTOM_GAMMA) == 0) - { - QWidget* widget_cbtn_pbtn = new QWidget(scrollArea); - widget_cbtn_pbtn->setMaximumWidth(200); - btn_gamma_ = new QPushButton(widget_cbtn_pbtn); - btn_gamma_->setText(tr("custom tone curve")); - btn_gamma_->setFixedWidth(150); - - QHBoxLayout *hLayout = new QHBoxLayout; - hLayout->addWidget(checkBoxCreation); - hLayout->addWidget(btn_gamma_); - widget_cbtn_pbtn->setLayout(hLayout); - - reinterpret_cast(widget->layout())->addRow(opt->title + QString(" : "), widget_cbtn_pbtn); - connect(btn_gamma_, SIGNAL(clicked(bool)), this, SLOT(slot_gammaButtonClicked())); - } - else - reinterpret_cast(widget->layout())->addRow(opt->title + QString(" : "), checkBoxCreation); - - checkBoxCreation->setToolTip(opt->desc); - int id = i + 1; - bool enable = *(bool*)&cur_val[0]; - checkBoxCreation->setProperty("controls_id", id); - checkBoxCreation->setChecked(enable); - if (strcmp(opt->name, SANE_STD_OPT_NAME_CUSTOM_AREA) == 0) - btn_cut_area_->setEnabled(enable); - else if (strcmp(opt->name, SANE_STD_OPT_NAME_IS_CUSTOM_GAMMA) == 0) - btn_gamma_->setEnabled(enable); - connect(checkBoxCreation, SIGNAL(stateChanged(int)), this, SLOT(slot_checkedClicked())); - m_list_widgets.append(checkBoxCreation); - - m_list_getOpt.append(QPair(id, opt)); - break; - } - - case SANE_TYPE_INT: - { - switch(opt->constraint_type) - { - case SANE_CONSTRAINT_NONE: - { - QSpinBox* spinBox = new QSpinBox(scrollArea); - spinBox->setMinimumWidth(150); - spinBox->setToolTip(opt->desc); - spinBox->setRange(1, 1000); - int id = i + 1; - spinBox->setProperty("controls_id", id); - - QHBoxLayout* hLayout = new QHBoxLayout; - hLayout->addWidget(spinBox); - hLayout->addStretch(); - reinterpret_cast(widget->layout())->addRow(opt->title + QString(" : "), spinBox); - - m_list_widgets.append(spinBox); - m_list_getOpt.append(QPair(id, opt)); - - spinBox->setValue(*(int*)&cur_val[0]); - connect(spinBox, SIGNAL(valueChanged(int)), this, SLOT(slot_spinBoxClicked(int))); - break; - } - - case SANE_CONSTRAINT_RANGE: - { - QWidget* widget_slider_spin = new QWidget(scrollArea); - widget_slider_spin->setMinimumWidth(300); - - QSlider* sliderCreation = new QSlider(widget_slider_spin); - sliderCreation->setOrientation(Qt::Horizontal); - sliderCreation->setMinimumWidth(120); - sliderCreation->setRange(opt->constraint.range->min, opt->constraint.range->max); - sliderCreation->setToolTip(opt->desc); - sliderCreation->setProperty("controls_id", i+1); - sliderCreation->setValue(m_list_defaultOptions.at(i).second.toInt()); - - QSpinBox* spinBox = new QSpinBox(widget_slider_spin); - spinBox->setMinimumWidth(150); - spinBox->setToolTip(opt->desc); - spinBox->setRange(opt->constraint.range->min, opt->constraint.range->max); - - spinBox->setSingleStep(1); - spinBox->setValue(m_list_defaultOptions.at(i).second.toInt()); - int id = i + 1; - spinBox->setProperty("controls_id", id); - m_list_sliderSpinbox.append(QPair(sliderCreation, spinBox)); - - QHBoxLayout* hLayout = new QHBoxLayout; - hLayout->addWidget(sliderCreation); - hLayout->addWidget(spinBox); -// hLayout->addStretch(); - widget_slider_spin->setLayout(hLayout); - reinterpret_cast(widget->layout())->addRow(opt->title + QString(" : "), widget_slider_spin); - - m_list_widgets.append(sliderCreation); - m_list_widgets.append(spinBox); - m_list_getOpt.append(QPair(id, opt)); - - int cur = *(int*)&cur_val[0]; - spinBox->setValue(cur); - sliderCreation->setValue(cur); - - connect(spinBox, SIGNAL(valueChanged(int)), this, SLOT(slot_spinBoxClicked(int))); - connect(sliderCreation, SIGNAL(valueChanged(int)), this, SLOT(slot_sliderClicked(int))); - - break; - } - - case SANE_CONSTRAINT_WORD_LIST: - { - QComboBox* comboBoxCreation = new QComboBox(scrollArea); - comboBoxCreation->setToolTip(opt->desc); - int id = i + 1; - comboBoxCreation->setProperty("controls_id", id); - reinterpret_cast(widget->layout())->addRow(opt->title + QString(" : "), comboBoxCreation); - - auto p_str = opt->constraint.word_list; - char buf[20]; - for(SANE_Int i = 0; i < p_str[0]; ++i) - { - sprintf(buf, "%d", p_str[i + 1]); - comboBoxCreation->addItem(QString::fromStdString(buf)); - } - sprintf(buf, "%d", m_list_defaultOptions.at(i).second.toInt()); - comboBoxCreation->setProperty(hg_settingdialog::property_combox_data_type_.c_str(), COMBO_VAL_INT); - m_list_widgets.append(comboBoxCreation); - m_list_getOpt.append(QPair(id, opt)); - - char nstr[40] = {0}; - sprintf(nstr, "%d", *(int*)&cur_val[0]); - comboBoxCreation->setCurrentText(QString::fromStdString(nstr)); - connect(comboBoxCreation, SIGNAL(currentTextChanged(const QString)), this, SLOT(slot_string_list_comboBoxClicked())); - break; - } - - case SANE_CONSTRAINT_STRING_LIST: - break; - } - break; - } - - case SANE_TYPE_FIXED: - { - QWidget* widget_slider_spin = new QWidget(scrollArea); - widget_slider_spin->setMinimumWidth(300); - QSlider* sliderCreation = new QSlider(widget_slider_spin); - sliderCreation->setOrientation(Qt::Horizontal); - sliderCreation->setMinimumWidth(120); - sliderCreation->setToolTip(opt->desc); - int id = i + 1; - sliderCreation->setProperty("controls_id", id); - sliderCreation->setRange(SANE_UNFIX(opt->constraint.range->min) * 100, SANE_UNFIX(opt->constraint.range->max) * 100); - sliderCreation->setValue(SANE_UNFIX(m_list_defaultOptions.at(i).second.toDouble()) * 100); - - QDoubleSpinBox* spinBox = new QDoubleSpinBox(widget_slider_spin); - spinBox->setMinimumWidth(150); - spinBox->setToolTip(opt->desc); - spinBox->setDecimals(2); - spinBox->setSingleStep(0.01); - spinBox->setRange(SANE_UNFIX(opt->constraint.range->min), SANE_UNFIX(opt->constraint.range->max)); - spinBox->setValue(sliderCreation->value() * spinBox->singleStep()); - spinBox->setProperty("controls_id", id); - - m_list_sliderSpinbox.append(QPair(sliderCreation, spinBox)); - - QHBoxLayout* hLayout = new QHBoxLayout; - hLayout->addWidget(sliderCreation); - hLayout->addWidget(spinBox); -// hLayout->addStretch(); - widget_slider_spin->setLayout(hLayout); - reinterpret_cast(widget->layout())->addRow(opt->title + QString(" : "), widget_slider_spin); - - m_list_widgets.append(sliderCreation); - m_list_widgets.append(spinBox); - - m_list_getOpt.append(QPair(id, opt)); -// iniRead(md5(opt->title), id, sliderCreation); -// iniRead(md5(opt->title), id, spinBox); - - float v = SANE_UNFIX(*(SANE_Fixed*)&cur_val[0]); - sliderCreation->setValue(v * 100); - spinBox->setValue(sliderCreation->value() * spinBox->singleStep()); - connect(spinBox, SIGNAL(valueChanged(double)), this, SLOT(slot_doubleSpinboxClicked(double))); - connect(sliderCreation, SIGNAL(valueChanged(int)), this, SLOT(slot_sliderClicked(int))); - break; - } - - case SANE_TYPE_STRING: - { - switch(opt->constraint_type) - { - case SANE_CONSTRAINT_NONE: - { - QLineEdit *lineEdit = new QLineEdit(scrollArea); - lineEdit->setToolTip(opt->desc); - int id = i + 1; - lineEdit->setProperty("controls_id", id); - reinterpret_cast(widget->layout())->addRow(opt->title + QString(" : "), lineEdit); - - m_list_widgets.append(lineEdit); - m_list_getOpt.append(QPair(id, opt)); -// iniRead(md5(opt->title), id, lineEdit); - - lineEdit->setText(QString::fromStdString(cur_val)); - connect(lineEdit, SIGNAL(textChanged(const QString&)), this, SLOT(slot_lineEditInput())); - break; - } - - case SANE_CONSTRAINT_RANGE: - break; - case SANE_CONSTRAINT_WORD_LIST: - break; - - case SANE_CONSTRAINT_STRING_LIST: - { - QComboBox* comboBoxCreation = new QComboBox(scrollArea); - comboBoxCreation->setToolTip(opt->desc); - int id = i + 1; - comboBoxCreation->setProperty("controls_id", id); - reinterpret_cast(widget->layout())->addRow(opt->title + QString(" : "), comboBoxCreation); - - auto p_str = opt->constraint.string_list; - QStringList stringList; - while(*p_str) - { - stringList.append(*p_str); - p_str++; - } - - if(stringList.isEmpty() != true) - { - for(int i = 0; i < (stringList.size()); i++) - comboBoxCreation->addItem(stringList.at(i)); - } - comboBoxCreation->setCurrentText(m_list_defaultOptions.at(i).second.toString()); - comboBoxCreation->setProperty(hg_settingdialog::property_combox_data_type_.c_str(), COMBO_VAL_STRING); - //printf("Option %02d default value is: %s\n", i + 1, m_list_defaultOptions.at(i).second.toString().data()); - - m_list_widgets.append(comboBoxCreation); - - m_list_getOpt.append(QPair(id, opt)); -// iniRead(md5(opt->title), id, comboBoxCreation); - - comboBoxCreation->setCurrentText(QString::fromStdString(cur_val)); - connect(comboBoxCreation, SIGNAL(currentTextChanged(const QString)), this, SLOT(slot_string_list_comboBoxClicked())); - break; - } - } - break; - } - - case SANE_TYPE_BUTTON: - { - QPushButton* pushButton = new QPushButton(this); - pushButton->setText(opt->title); - pushButton->setToolTip(opt->desc); - int id = i + 1; - pushButton->setProperty("controls_id", id); - hlayoutOkAndCancel->insertWidget(0, pushButton, 0, Qt::AlignRight); - - connect(pushButton, SIGNAL(clicked(bool)), this, SLOT(slot_pushButtonClicked())); - break; - } - - case SANE_TYPE_GROUP: - { - if (isBegin) - { - scrollArea->setWindowTitle(opt->title); - isBegin = false; - }else{ - scrollArea->setWidget(widget); - tabWidgetCreation->addTab(scrollArea, scrollArea->windowTitle()); - scrollArea = new QScrollArea; - scrollArea->setWidgetResizable(true); - scrollArea->setWindowTitle(opt->title); - layout = new QFormLayout; - widget = new QWidget; - widget->setLayout(layout); - } - - m_list_widgets.append(nullptr); - break; - } - } //switch(opt->type) - -// if (Utf8ToStdString(opt->title) == "分辨率") - if (strcmp(opt->name, SANE_STD_OPT_NAME_RESOLUTION) == 0) - { - m_dpiId = i + 1; - m_dpiValue = m_list_defaultOptions.at(i).second.toInt(); - } -// else if (Utf8ToStdString(opt->title) == "纸张尺寸") - else if (strcmp(opt->name, SANE_STD_OPT_NAME_PAPER) == 0) - { - m_paperSizeId = i + 1; - m_paperSizeValue = m_list_defaultOptions.at(i).second.toString(); - } - - if (0 == strcmp(opt->name, SANE_STD_OPT_NAME_CUSTOM_AREA_LEFT)) - { - m_cutLeftId = i + 1; - m_cutLeftValue = SANE_UNFIX(m_list_defaultOptions.at(i).second.toInt()); - if (opt->constraint_type == SANE_CONSTRAINT_RANGE) - m_cutWidth = SANE_UNFIX(opt->constraint.range->max); - } - else if (0 == strcmp(opt->name, SANE_STD_OPT_NAME_CUSTOM_AREA_TOP)) - { - m_cutTopId = i + 1; - m_cutTopValue = SANE_UNFIX(m_list_defaultOptions.at(i).second.toInt()); - if (opt->constraint_type == SANE_CONSTRAINT_RANGE) - m_cutHeight = SANE_UNFIX(opt->constraint.range->max); - } - else if (0 == strcmp(opt->name, SANE_STD_OPT_NAME_CUSTOM_AREA_RIGHT)) - { - m_cutRightId = i + 1; - m_cutRightValue = SANE_UNFIX(m_list_defaultOptions.at(i).second.toInt()); - } - else if (0 == strcmp(opt->name, SANE_STD_OPT_NAME_CUSTOM_AREA_BOTTOM)) - { - m_cutBottomId = i + 1; - m_cutBottomValue = SANE_UNFIX(m_list_defaultOptions.at(i).second.toInt()); - } - -// else if (Utf8ToStdString(opt->title) == "颜色模式") - if (strcmp(opt->name, SANE_STD_OPT_NAME_COLOR_MODE) == 0) - { - m_colorModeId = i + 1; - m_colorModeValue = m_list_defaultOptions.at(i).second.toString(); - } -// else if (Utf8ToStdString(opt->title) == "伽玛" || Utf8ToStdString(opt->title) == "伽玛值") - - } //for - - updateUIStatus(); - - scrollArea->setWidget(widget); - tabWidgetCreation->addTab(scrollArea, scrollArea->windowTitle()); -} - -void hg_settingdialog::refresh_control_value(int op_id) -{ - QVector ctrls = find_control(op_id); - - if(ctrls.empty()) - return; - - const SANE_Option_Descriptor* opt = (const SANE_Option_Descriptor*)m_list_defaultOptions.at(op_id - 1).first; - if(opt->type == SANE_TYPE_BOOL) - { - for(size_t i = 0; i < (size_t)ctrls.size(); ++i) - { - QCheckBox* cb = qobject_cast(ctrls[i]); - if(cb) - { - disconnect(cb, SIGNAL(stateChanged(int)), this, SLOT(slot_checkedClicked())); - cb->setChecked(m_list_defaultOptions.at(op_id - 1).second.toBool()); - connect(cb, SIGNAL(stateChanged(int)), this, SLOT(slot_checkedClicked())); - break; - } - } - } - else if(opt->type == SANE_TYPE_INT) - { - for(size_t i = 0; i < (size_t)ctrls.size(); ++i) - { - QComboBox* comb = qobject_cast(ctrls[i]); - if(comb) - { - char buf[40] = {0}; - sprintf(buf, "%d", m_list_defaultOptions.at(op_id - 1).second.toInt()); - comb->disconnect(comb, SIGNAL(currentTextChanged(const QString)), this, SLOT(slot_string_list_comboBoxClicked())); - comb->setCurrentText(QString::fromStdString(buf)); - connect(comb, SIGNAL(currentTextChanged(const QString)), this, SLOT(slot_string_list_comboBoxClicked())); - } - else - { - QSlider* slider = qobject_cast(ctrls[i]); - if(slider) - { - disconnect(slider, SIGNAL(valueChanged(int)), this, SLOT(slot_sliderClicked(int))); - slider->setValue(m_list_defaultOptions.at(op_id - 1).second.toInt()); - connect(slider, SIGNAL(valueChanged(int)), this, SLOT(slot_sliderClicked(int))); - } - else - { - QSpinBox* spin = qobject_cast(ctrls[i]); - if(spin) - { - disconnect(spin, SIGNAL(valueChanged(int)), this, SLOT(slot_spinBoxClicked(int))); - spin->setValue(m_list_defaultOptions.at(op_id - 1).second.toInt()); - connect(spin, SIGNAL(valueChanged(int)), this, SLOT(slot_spinBoxClicked(int))); - } - } - } - } - } - else if(opt->type == SANE_TYPE_FIXED) - { - double val = SANE_UNFIX(m_list_defaultOptions.at(op_id - 1).second.toInt()); - QSlider *slider = NULL; - QDoubleSpinBox* spin = NULL; - for(size_t i = 0; i < (size_t)ctrls.size(); ++i) - { - QComboBox* comb = qobject_cast(ctrls[i]); - if(comb) - { - char buf[40] = {0}; - sprintf(buf, "%f", val); - comb->disconnect(comb, SIGNAL(currentTextChanged(const QString)), this, SLOT(slot_string_list_comboBoxClicked())); - comb->setCurrentText(QString::fromStdString(buf)); - connect(comb, SIGNAL(currentTextChanged(const QString)), this, SLOT(slot_string_list_comboBoxClicked())); - } - else if(!slider) - { - slider = qobject_cast(ctrls[i]); - if(slider) - disconnect(slider, SIGNAL(valueChanged(int)), this, SLOT(slot_sliderClicked(int))); - } - else if(!spin) - { - spin = qobject_cast(ctrls[i]); - if(spin) - disconnect(spin, SIGNAL(valueChanged(double)), this, SLOT(slot_spinBoxClicked(double))); - } - } - if(slider) - slider->setValue(val * 100); - if(spin) - spin->setValue(val); - if(slider) - connect(slider, SIGNAL(valueChanged(int)), this, SLOT(slot_sliderClicked(int))); - if(spin) - connect(spin, SIGNAL(valueChanged(double)), this, SLOT(slot_spinBoxClicked(double))); - } - else if(opt->type == SANE_TYPE_STRING) - { - for(size_t i = 0; i < (size_t)ctrls.size(); ++i) - { - QComboBox* comb = qobject_cast(ctrls[i]); - if(comb) - { - disconnect(comb, SIGNAL(currentTextChanged(const QString)), this, SLOT(slot_string_list_comboBoxClicked())); - comb->setCurrentText(m_list_defaultOptions.at(op_id - 1).second.toString()); - // comb->setProperty(hg_settingdialog::property_combox_data_type_.c_str(), COMBO_VAL_STRING); - connect(comb, SIGNAL(currentTextChanged(const QString)), this, SLOT(slot_string_list_comboBoxClicked())); - } - else - { - QLineEdit* edit = qobject_cast(ctrls[i]); - if(edit) - { - disconnect(edit, SIGNAL(textChanged(const QString&)), this, SLOT(slot_lineEditInput())); - edit->setText(m_list_defaultOptions.at(op_id - 1).second.toString()); - connect(edit, SIGNAL(textChanged(const QString&)), this, SLOT(slot_lineEditInput())); - } - } - } - } -} -QVector hg_settingdialog::find_control(int opt_num) -{ - QVector list_w; - for(int i = 0; i< m_list_widgets.size(); i++) - { - if (m_list_widgets.at(i) == nullptr) continue; - QWidget* w = m_list_widgets.at(i); - int id = w->property("controls_id").toInt(); - if(opt_num == id) - list_w.append(w); - } - return list_w; -} - -void hg_settingdialog::updateUIStatus() -{ - updateOpt(); - - SANE_Int dev_options = 0; - sane_control_option(m_handle, 0, SANE_ACTION_GET_VALUE, &dev_options, nullptr); - for(int id = 1, optons = dev_options; id < optons; id++) - { - QVector list_widgets = find_control(id); - if (list_widgets.empty()) continue; - QWidget* widget = list_widgets.first(); - if (widget == nullptr) continue; - QWidget* parentWidget = widget->parentWidget(); - - while (parentWidget->layout() && - typeid(*(parentWidget->layout())) != typeid(QFormLayout)) - { - widget = parentWidget; - parentWidget = widget->parentWidget(); - } - - QFormLayout* layout = reinterpret_cast(parentWidget->layout()); - const SANE_Option_Descriptor* opt = reinterpret_cast(m_list_defaultOptions.at(id - 1).first); - bool hide = (opt->cap & SANE_CAP_INACTIVE) == SANE_CAP_INACTIVE; - QWidget* w_label = layout ? layout->labelForField(widget) : nullptr; - - if( strcmp(opt->name, SANE_STD_OPT_NAME_CUSTOM_AREA_LEFT) == 0 || - strcmp(opt->name, SANE_STD_OPT_NAME_CUSTOM_AREA_TOP) == 0 || - strcmp(opt->name, SANE_STD_OPT_NAME_CUSTOM_AREA_RIGHT) == 0 || - strcmp(opt->name, SANE_STD_OPT_NAME_CUSTOM_AREA_BOTTOM) == 0 ) - hide = true; - - refresh_control_value(id); - if(w_label) - hide ? w_label->hide() : w_label->show(); - widget->setVisible(!hide); - if(strcmp(opt->name, SANE_STD_OPT_NAME_CUSTOM_AREA) == 0) - { - if(hide) - { - custom_area_lable_->hide(); - btn_cut_area_->hide(); - } - else - { - custom_area_lable_->show(); - btn_cut_area_->show(); - } - } - } -} - -void hg_settingdialog::slot_checkedClicked() -{ - QCheckBox *checkBox = qobject_cast(sender()); - SANE_Int id = checkBox->property("controls_id").toInt(); - SANE_Bool checkBoxcurrentState = checkBox->isChecked(); - - const SANE_Option_Descriptor* opt = nullptr; - for(int i = 0; i < m_list_getOpt.size(); i++) - if (m_list_getOpt.at(i).first == id) - { - opt = reinterpret_cast(m_list_getOpt.at(i).second); - break; - } - - m_list_IdValueTitle.append(QPair, QString>(QPair(id, checkBoxcurrentState), md5(opt->title))); - - SANE_Int method = 0; - SANE_Status ret = sane_control_option(m_handle, id, SANE_ACTION_SET_VALUE, &checkBoxcurrentState, &method); - if (ret == SANE_STATUS_UNSUPPORTED) - { - SANE_Bool value = false; - ret = sane_control_option(m_handle, id, SANE_ACTION_GET_VALUE, &value, &method); - checkBox->setCheckState(value ? Qt::Checked : Qt::Unchecked); - QMessageBox::information(this, tr("Prompt"), tr("The funtion is unsupported")); - return; - } - - if((method & SANE_INFO_RELOAD_OPTIONS) == SANE_INFO_RELOAD_OPTIONS) - updateUIStatus(); - else if(method & SANE_INFO_INEXACT) - checkBox->setCheckState(checkBoxcurrentState ? Qt::CheckState::Checked : Qt::CheckState::Unchecked); - - if(strcmp(opt->name, SANE_STD_OPT_NAME_CUSTOM_AREA) == 0) - btn_cut_area_->setEnabled(checkBoxcurrentState); - else if (strcmp(opt->name, SANE_STD_OPT_NAME_IS_CUSTOM_GAMMA) == 0) - btn_gamma_->setEnabled(checkBoxcurrentState); - cur_scheme_->config_changed(id, (char*)&checkBoxcurrentState, sizeof(checkBoxcurrentState)); -} - -void hg_settingdialog::slot_string_list_comboBoxClicked() -{ - QComboBox *comboBox = qobject_cast(sender()); - SANE_Int id = comboBox->property("controls_id").toInt(); - std::string comboBoxcurrentItem(comboBox->currentText().toUtf8()); - int type = comboBox->property(hg_settingdialog::property_combox_data_type_.c_str()).toInt(); - - if (id == m_dpiId) - { - m_dpiValue = atoi(comboBoxcurrentItem.c_str()); - qDebug("dpi=%d", m_dpiValue); - } - else if (id == m_paperSizeId) - { - m_paperSizeValue = comboBoxcurrentItem.c_str(); - qDebug("paperSize=%s", comboBoxcurrentItem.c_str()); - } - else if (id == m_colorModeId) - { - m_colorModeValue = comboBoxcurrentItem.c_str(); - qDebug("colorMode=%s", comboBoxcurrentItem.c_str()); - } - - const SANE_Option_Descriptor* opt = nullptr; - for(int i = 0; i < m_list_getOpt.size(); i++) - if (m_list_getOpt.at(i).first == id) - { - opt = reinterpret_cast(m_list_getOpt.at(i).second); - break; - } - - m_list_IdValueTitle.append(QPair, QString>(QPair(id, &comboBoxcurrentItem.at(0)), md5(opt->title))); - - SANE_Int method = 0; - SANE_String buf = (SANE_String)malloc(opt->size * 2 + 4); - if(type == COMBO_VAL_INT) - *((SANE_Int*)buf) = atoi(comboBoxcurrentItem.c_str()); - else if(type == COMBO_VAL_FLOAT) - *((SANE_Fixed*)buf) = SANE_FIX(atof(comboBoxcurrentItem.c_str())); - else - strcpy(buf, comboBoxcurrentItem.c_str()); - SANE_Status ret = sane_control_option(m_handle, id, SANE_ACTION_SET_VALUE, buf, &method); - if (ret == SANE_STATUS_UNSUPPORTED) - { - char* value = (char*)malloc(opt->size * 2 + 4); - ret = sane_control_option(m_handle, id, SANE_ACTION_GET_VALUE, value, &method); - if (value != nullptr) - comboBox->setCurrentText(QString::fromStdString(value)); - free(value); - - QMessageBox::information(this, tr("Prompt"), tr("The funtion is unsupported")); - return; - } - - if((method & SANE_INFO_RELOAD_OPTIONS) == SANE_INFO_RELOAD_OPTIONS) - updateUIStatus(); - else if(method & SANE_INFO_INEXACT) - comboBox->setCurrentText(QString::fromStdString(buf)); - - if(type == COMBO_VAL_INT) - cur_scheme_->config_changed(id, buf, sizeof(SANE_Int)); - else if(type == COMBO_VAL_FLOAT) - cur_scheme_->config_changed(id, buf, sizeof(SANE_Fixed)); - else - { - std::string langCN(to_default_language(buf, nullptr)); - cur_scheme_->config_changed(id, &langCN[0], langCN.length()); - } - free(buf); -} - -void hg_settingdialog::slot_pushButtonClicked() -{ - QPushButton *pushButton = qobject_cast(sender()); - SANE_Int id = pushButton->property("controls_id").toInt(), - after = 0; - - // restore to default setting ? - SANE_Status ret = sane_control_option(m_handle, id, SANE_ACTION_SET_VALUE, NULL, &after); - if (ret == SANE_STATUS_UNSUPPORTED) - { - QMessageBox::information(this, tr("Prompt"), tr("The funtion is unsupported")); - return; - } - - if((after & SANE_INFO_RELOAD_OPTIONS) == SANE_INFO_RELOAD_OPTIONS) - updateUIStatus(); - - const SANE_Option_Descriptor* opt = sane_get_option_descriptor(m_handle, id); - if(opt && strcmp(opt->name, SANE_STD_OPT_NAME_RESTORE) == 0) - { - restore_2_default_settings(); - } -} - -void hg_settingdialog::slot_cutButtonClicked() -{ - //int width = 0.03937 * m_cutWidth * m_dpiValue; - //int height = 0.03937 * m_cutHeight * m_dpiValue; - qreal left = 0.03937 * m_cutLeftValue * m_dpiValue; - qreal top = 0.03937 * m_cutTopValue * m_dpiValue; - qreal right = 0.03937 * m_cutRightValue * m_dpiValue; - qreal bottom = 0.03937 * m_cutBottomValue * m_dpiValue; - - CutPaperTool dlg(m_dpiValue, m_paperSizeValue, 300, 0, this); - QRectF rc(left, top, right - left, bottom - top); - dlg.setCutRectPixel(rc); - if (dlg.exec()) - { - QRectF rcRet = dlg.getCutRectPixel(); - - m_cutLeftValue = rcRet.left() / (0.03937 * m_dpiValue); - m_cutTopValue = rcRet.top() / (0.03937 * m_dpiValue); - m_cutRightValue = rcRet.right() / (0.03937 * m_dpiValue); - m_cutBottomValue = rcRet.bottom() / (0.03937 * m_dpiValue); - - SANE_Int info; - SANE_Word value = SANE_FIX(m_cutLeftValue); - sane_control_option(m_handle, m_cutLeftId, SANE_ACTION_SET_VALUE, &value, &info); - cur_scheme_->config_changed(m_cutLeftId, (char*)&value, sizeof(value)); - value = SANE_FIX(m_cutTopValue); - sane_control_option(m_handle, m_cutTopId, SANE_ACTION_SET_VALUE, &value, &info); - cur_scheme_->config_changed(m_cutTopId, (char*)&value, sizeof(value)); - value = SANE_FIX(m_cutRightValue); - sane_control_option(m_handle, m_cutRightId, SANE_ACTION_SET_VALUE, &value, &info); - cur_scheme_->config_changed(m_cutRightId, (char*)&value, sizeof(value)); - value = SANE_FIX(m_cutBottomValue); - sane_control_option(m_handle, m_cutBottomId, SANE_ACTION_SET_VALUE, &value, &info); - cur_scheme_->config_changed(m_cutBottomId, (char*)&value, sizeof(value)); - } -} - -void hg_settingdialog::slot_gammaButtonClicked() -{ - setPicClrTool dlg(this); - - int colorMode; // 0-彩色, 1-灰度 - if (m_colorModeValue.toStdString() == OPTION_VALUE_YSMS_256JHD - || m_colorModeValue.toStdString() == OPTION_VALUE_YSMS_HB) - { - colorMode = 1; - - QList keyTable; - for (int i = 0; i < m_gammaData.pt_count; ++i) - { - QPoint pt(m_gammaData.keypoint[i].x, m_gammaData.keypoint[i].y); - keyTable.append(pt); - } - - if (!keyTable.empty()) - { - dlg.setGrayKeyTable(keyTable); - } - } - else - { - colorMode = 0; - - QList keyTable; - for (int i = 0; i < m_gammaData.pt_count; ++i) - { - QPoint pt(m_gammaData.keypoint[i].x, m_gammaData.keypoint[i].y); - keyTable.append(pt); - } - - QList rKeyTable; - for (int i = 0; i < m_gammaData.pt_count_r; ++i) - { - QPoint pt(m_gammaData.keypoint_r[i].x, m_gammaData.keypoint_r[i].y); - rKeyTable.append(pt); - } - - QList gKeyTable; - for (int i = 0; i < m_gammaData.pt_count_g; ++i) - { - QPoint pt(m_gammaData.keypoint_g[i].x, m_gammaData.keypoint_g[i].y); - gKeyTable.append(pt); - } - - QList bKeyTable; - for (int i = 0; i < m_gammaData.pt_count_b; ++i) - { - QPoint pt(m_gammaData.keypoint_b[i].x, m_gammaData.keypoint_b[i].y); - bKeyTable.append(pt); - } - - QVector> keyTableList; - if (!keyTable.empty() && !rKeyTable.empty() && !gKeyTable.empty() && !bKeyTable.empty()) - { - keyTableList.append(keyTable); - keyTableList.append(rKeyTable); - keyTableList.append(gKeyTable); - keyTableList.append(bKeyTable); - dlg.setRGBKeyTable(keyTableList); - } - } - - dlg.setColorMode(colorMode); - if (dlg.exec()) - { - memset(&m_gammaData, 0, sizeof(m_gammaData)); - clicked_gamma_ = true; - - if (1 == colorMode) - { - QList keyTable = dlg.getGrayKeyTable(); - - m_gammaData.pt_count = HGMIN(4, keyTable.size()); - int i = 0; - for (QPoint pt : keyTable) - { - if (i >= 4) - break; - - m_gammaData.keypoint[i].x = pt.x(); - m_gammaData.keypoint[i].y = pt.y(); - ++i; - } - - uchar data[256]; - dlg.getGrayTable(data, 256); - for (int i = 0; i < 256; ++i) - { - m_gammaData.table[i] = data[i]; - } - } - else - { - QVector> keyTableList = dlg.getRGBKeyTable(); - - m_gammaData.pt_count = HGMIN(4, keyTableList[0].size()); - int i = 0; - for (QPoint pt : keyTableList[0]) - { - if (i >= 4) - break; - - m_gammaData.keypoint[i].x = pt.x(); - m_gammaData.keypoint[i].y = pt.y(); - ++i; - } - - m_gammaData.pt_count_r = HGMIN(4, keyTableList[1].size()); - i = 0; - for (QPoint pt : keyTableList[1]) - { - if (i >= 4) - break; - - m_gammaData.keypoint_r[i].x = pt.x(); - m_gammaData.keypoint_r[i].y = pt.y(); - ++i; - } - - m_gammaData.pt_count_g = HGMIN(4, keyTableList[2].size()); - i = 0; - for (QPoint pt : keyTableList[2]) - { - if (i >= 4) - break; - - m_gammaData.keypoint_g[i].x = pt.x(); - m_gammaData.keypoint_g[i].y = pt.y(); - ++i; - } - - m_gammaData.pt_count_b = HGMIN(4, keyTableList[3].size()); - i = 0; - for (QPoint pt : keyTableList[3]) - { - if (i >= 4) - break; - - m_gammaData.keypoint_b[i].x = pt.x(); - m_gammaData.keypoint_b[i].y = pt.y(); - ++i; - } - - uchar data[256 * 3]; - dlg.getRGBTable(data, 256 * 3); - for (int i = 0; i < 256; ++i) - { - m_gammaData.table[i] = data[i * 3 + 2]; - m_gammaData.table[i + 256] = data[i * 3 + 1]; - m_gammaData.table[i + 512] = data[i * 3 + 0]; - } - } - - unsigned int len = sizeof(SANE_Gamma); - sane_io_control(m_handle, IO_CTRL_CODE_SET_CUSTOM_GAMMA, &m_gammaData, &len); - cur_scheme_->config_changed(SANE_STD_OPT_NAME_IS_CUSTOM_GAMMA, (char*)&m_gammaData, sizeof(m_gammaData), true); - } -} - -void hg_settingdialog::slot_word_list_comboBoxClicked(int value) -{ - QComboBox *comboBox = qobject_cast(sender()); - SANE_Int id = comboBox->property("controls_id").toInt(); - SANE_Int temp = value; - - const SANE_Option_Descriptor* opt = nullptr; - for(int i = 0; i < m_list_getOpt.size(); i++) - if (m_list_getOpt.at(i).first == id) - { - opt = reinterpret_cast(m_list_getOpt.at(i).second); - break; - } - m_list_IdValueTitle.append(QPair, QString>(QPair(id, temp), md5(opt->title))); - - - SANE_Int method = 0; - SANE_Status ret = sane_control_option(m_handle, id, SANE_ACTION_SET_VALUE, &temp, &method); - if (ret == SANE_STATUS_UNSUPPORTED) - { - char* value = (char*)malloc(opt->size * 2 + 4); - ret = sane_control_option(m_handle, id, SANE_ACTION_GET_VALUE, value, &method); - if (value != nullptr) - comboBox->setCurrentText(QString::fromStdString(value)); - free(value); - - QMessageBox::information(this, tr("Prompt"), tr("The funtion is unsupported")); - return; - } - if((method & SANE_INFO_RELOAD_OPTIONS) == SANE_INFO_RELOAD_OPTIONS) - updateUIStatus(); - else if(method & SANE_INFO_INEXACT) - { - char buf[20]; - sprintf(buf, "%d", temp); - comboBox->setCurrentText(QString::fromStdString(buf)); - } - cur_scheme_->config_changed(id, (char*)&temp, sizeof(temp)); -} - -void hg_settingdialog::slot_sliderClicked(int value) -{ - QSlider *slider = qobject_cast(sender()); - SANE_Int id = slider->property("controls_id").toInt(); - - const SANE_Option_Descriptor* opt = nullptr; - for(int i = 0; i < m_list_getOpt.size(); i++) - if (m_list_getOpt.at(i).first == id) - { - opt = reinterpret_cast(m_list_getOpt.at(i).second); - break; - } - - QAbstractSpinBox* spin = nullptr; - for(int i = 0; i < m_list_sliderSpinbox.size(); i++) - if (m_list_sliderSpinbox.at(i).first == slider) - { - spin = reinterpret_cast(m_list_sliderSpinbox.at(i).second); - break; - } - - if (spin != nullptr) - { - SANE_Int val = value, method = 0; - bool db_val = false; - if (typeid(*spin) == typeid(QSpinBox)) - { - QSpinBox* spin_ = reinterpret_cast(spin); - spin_->setValue(value); - - m_list_IdValueTitle.append(QPair, QString>(QPair(id, val), md5(opt->title))); - } - else - { - QDoubleSpinBox* spin_ = reinterpret_cast(spin); - double temp = value * spin_->singleStep(); - if(temp != spin_->value()) - spin_->setValue(temp); - - val = SANE_FIX(temp); - db_val = true; - - m_list_IdValueTitle.append(QPair, QString>(QPair(id, temp), md5(opt->title))); - } - SANE_Status ret = sane_control_option(m_handle, id, SANE_ACTION_SET_VALUE, &val, &method); - if (ret == SANE_STATUS_UNSUPPORTED) - { - if (!db_val) - { - SANE_Int value = 0; - ret = sane_control_option(m_handle, id, SANE_ACTION_GET_VALUE, &value, &method); - slider->setValue(value); - } - else - { - SANE_Fixed value = 0; - ret = sane_control_option(m_handle, id, SANE_ACTION_GET_VALUE, &value, &method); - slider->setValue(value); - } - - QMessageBox::information(this, tr("Prompt"), tr("The funtion is unsupported")); - return; - } - if((method & SANE_INFO_RELOAD_OPTIONS) == SANE_INFO_RELOAD_OPTIONS) - updateUIStatus(); - else if(method & SANE_INFO_INEXACT) - { - if(db_val) - { - QDoubleSpinBox* spin_ = reinterpret_cast(spin); - double v = SANE_UNFIX(val); - spin_->setValue(v); - slider->setValue(spin_->value() / spin_->singleStep()); - } - else { - QSpinBox* spin_ = reinterpret_cast(spin); - spin_->setValue(val); - slider->setValue(spin_->value() / spin_->singleStep()); - } - } - cur_scheme_->config_changed(id, (char*)&val, sizeof(val)); - } -} - -void hg_settingdialog::slot_doubleSpinboxClicked(double value) -{ - QDoubleSpinBox* spinBox = qobject_cast(sender()); - QAbstractSlider* slider = nullptr; - int id = spinBox->property("controls_id").toInt(); - for (int i = 0; i < m_list_sliderSpinbox.size(); i++) - if (m_list_sliderSpinbox.at(i).second == spinBox) - { - slider = reinterpret_cast(m_list_sliderSpinbox.at(i).first); - break; - } - if(slider != nullptr) - { - int temp = static_cast(value / spinBox->singleStep() + 0.5); - QSlider* slider_ = reinterpret_cast(slider); - if (slider_->value() != temp) - slider_->setValue(temp); - } -} - -void hg_settingdialog::slot_spinBoxClicked(int value) -{ - QSpinBox* spinBox = qobject_cast(sender()); - int id = spinBox->property("controls_id").toInt(); - - const SANE_Option_Descriptor* opt = nullptr; - for(int i = 0; i < m_list_getOpt.size(); i++) - if (m_list_getOpt.at(i).first == id) - { - opt = reinterpret_cast(m_list_getOpt.at(i).second); - break; - } - - QAbstractSlider* slider = nullptr; - for (int i = 0; i < m_list_sliderSpinbox.size(); i++) - if (m_list_sliderSpinbox.at(i).second == spinBox) - { - slider = reinterpret_cast(m_list_sliderSpinbox.at(i).first); - break; - } - if(slider == nullptr) - { - SANE_Int temp = value; - - m_list_IdValueTitle.append(QPair, QString>(QPair(id, temp), md5(opt->title))); - - SANE_Int method = 0; - sane_control_option(m_handle, id, SANE_ACTION_SET_VALUE, &temp, &method); - if((method & SANE_INFO_RELOAD_OPTIONS) == SANE_INFO_RELOAD_OPTIONS) - updateUIStatus(); - else if(value != temp) - { - disconnect(spinBox, SIGNAL(valueChanged(int)), this, SLOT(slot_spinBoxClicked(int))); - spinBox->setValue(temp); - connect(spinBox, SIGNAL(valueChanged(int)), this, SLOT(slot_spinBoxClicked(int))); - } - cur_scheme_->config_changed(id, (char*)&temp, sizeof(temp)); - }else - { - QSlider* slider_ = reinterpret_cast(slider); - slider_->setValue(spinBox->value()); - } -} - -void hg_settingdialog::slot_lineEditInput() -{ - QLineEdit* lineEdit = qobject_cast(sender()); - int id = lineEdit->property("controls_id").toInt(); - std::string lineEditCurrentText(lineEdit->text().toUtf8()); - - const SANE_Option_Descriptor* opt = nullptr; - for(int i = 0; i < m_list_getOpt.size(); i++) - if (m_list_getOpt.at(i).first == id) - { - opt = reinterpret_cast(m_list_getOpt.at(i).second); - break; - } - - m_list_IdValueTitle.append(QPair, QString>(QPair(id, &lineEditCurrentText.at(0)), md5(opt->title))); - - SANE_Int method = 0; - void *buf = NULL; - SANE_Int nv = 0; - if(opt->type == SANE_TYPE_INT) - { - nv = atoi(lineEditCurrentText.c_str()); - buf = &nv; - } - else if(opt->type == SANE_TYPE_FIXED) - { - nv = SANE_FIX(atof(lineEditCurrentText.c_str())); - buf = &nv; - } - else - { - buf = malloc(opt->size * 2 + 4); - strcpy((char*)buf, lineEditCurrentText.c_str()); - } - sane_control_option(m_handle, id, SANE_ACTION_SET_VALUE, buf, &method); - if((method & SANE_INFO_RELOAD_OPTIONS) == SANE_INFO_RELOAD_OPTIONS) - updateUIStatus(); - else if(method & SANE_INFO_INEXACT) - { - char mem[20], *v = mem; - if(opt->type == SANE_TYPE_INT) - sprintf(mem, "%d", nv); - else if(opt->type == SANE_TYPE_FIXED) - sprintf(mem, "%f", SANE_UNFIX(nv)); - else - v = (char*)buf; - lineEdit->setText(QString::fromStdString(v)); - } - - if(opt->type == SANE_TYPE_INT || opt->type == SANE_TYPE_FIXED) - { - cur_scheme_->config_changed(id, (char*)buf, sizeof(SANE_Int)); - } - else - { - std::string langCN(to_default_language((char*)buf, nullptr)); - cur_scheme_->config_changed(id, &langCN[0], langCN.length()); - free(buf); - } -} - -void hg_settingdialog::slot_buttonOkClicked() -{ - save_ = true; - close(); -} - -void hg_settingdialog::slot_buttonCancelClicked() -{ - close(); -} - -void hg_settingdialog::keyPressEvent(QKeyEvent *e) -{ - if (e->key() == Qt::Key_Escape) { - e->ignore(); - } - else { - QDialog::keyPressEvent(e); - } -} - -int hg_settingdialog::get_changed_items(void) -{ - return changed_count_; -} - -void hg_settingdialog::iniWrite(QString title, int id, QVariant value) -{ - (void)title; - (void)id; - (void)value; -// m_qstrFileName = QCoreApplication::applicationDirPath() + "/config.ini"; -// m_configIniWrite = new QSettings(m_qstrFileName, QSettings::IniFormat); -// m_configIniWrite->setIniCodec(QTextCodec::codecForName("UTF-8")); -// m_configIniWrite->setValue(title + "/id", id); -// m_configIniWrite->setValue(title + "/value", value); - -// delete m_configIniWrite; -// m_configIniWrite = nullptr; -} - -void hg_settingdialog::iniRead(QString title, int id, QWidget *w) -{ - (void)title; - (void)id; - (void)w; -// m_configIniRead = new QSettings("config.ini", QSettings::IniFormat); -// m_configIniRead->setIniCodec(QTextCodec::codecForName("UTF-8")); -// int id_ini = m_configIniRead->value(title + "/id").toInt(); -// QVariant value = m_configIniRead->value(title + "/value"); - -// if(id_ini == id) -// { -// if(typeid(*w) == typeid(QCheckBox)) -// reinterpret_cast(w)->setChecked(value.toBool()); - -// else if(typeid(*w) == typeid(QSlider)) -// reinterpret_cast(w)->setValue(value.toInt()); - -// else if(typeid(*w) == typeid(QSpinBox)) -// reinterpret_cast(w)->setValue(value.toInt()); - -// else if(typeid(*w) == typeid(QDoubleSpinBox)) -// reinterpret_cast(w)->setValue(value.toDouble()); - -// else if(typeid(*w) == typeid(QComboBox)) -// reinterpret_cast(w)->setCurrentText(value.toString()); -// } - -// delete m_configIniRead; -// m_configIniRead = nullptr; -} - -//生成UTF-8编码的MD5值 -QString hg_settingdialog::md5(QString key) -{ - QCryptographicHash md5(QCryptographicHash::Md5); - md5.addData(key.toUtf8()); - return QString(md5.result().toHex()); -} -const void* hg_settingdialog::find_option_description(int id) -{ - for(int i = 0; i < m_list_getOpt.size(); i++) - { - if (m_list_getOpt.at(i).first == id) - return reinterpret_cast(m_list_getOpt.at(i).second); - } - - return nullptr; -} -const void* hg_settingdialog::find_option_description(const std::string& title, int* id) -{ - for(int i = 0; i < m_list_getOpt.size(); i++) - { - std::string t((reinterpret_cast(m_list_getOpt.at(i).second))->name); - - if (title == t) - { - if(id) - *id = m_list_getOpt.at(i).first; - return reinterpret_cast(m_list_getOpt.at(i).second); - } - } - - return nullptr; -} - - -void hg_settingdialog::closeEvent(QCloseEvent* e) -{ - if(e->type() == QEvent::Close) // consider as cancel ... - { - if(save_) - save_scheme(); - else - cancel_setting(); - } - - e->accept(); -} - -bool hg_settingdialog::createMsgBoxUi(bool add, std::string &name) -{ - QString text(tr("Please select to overwrite the original configuration:")); - text += QString::fromStdString(name); - text += tr(",or add a new configuration"); - - QDialog *dlg = new QDialog(this); - dlg->setWindowTitle(tr("save the configuration")); - QLabel *label_question = new QLabel; - label_question->setText(text); - - QRadioButton *radioButtonCover = new QRadioButton; - radioButtonCover->setText(tr("cover original configuration:") + QString::fromStdString(name)); - radioButtonCover->setChecked(true); - add = false; - QRadioButton *radioButtonNew = new QRadioButton; - radioButtonNew->setText(tr("add new configuration")); - - QHBoxLayout *hLayoutName = new QHBoxLayout; - QLabel *label_name = new QLabel; - label_name->setText(tr("rename:")); - m_lineEdit_name = new QLineEdit; - std::string name2; - m_lineEdit_name->setText(QString::fromStdString(getCurUiShemeName(name2))); - - QSpacerItem *spacer1 = new QSpacerItem(20, 20, QSizePolicy::Expanding); - hLayoutName->addWidget(label_name); - hLayoutName->addWidget(m_lineEdit_name); - hLayoutName->addSpacerItem(spacer1); - label_name->setVisible(false); - m_lineEdit_name->setVisible(false); - - bool cover = true; - connect(radioButtonCover, &QRadioButton::clicked, this, [=, &add, &cover](){ - cover = true; - add = false; - label_name->setVisible(false); - m_lineEdit_name->setVisible(false); - }); - connect(radioButtonNew, &QRadioButton::clicked, this, [=, &add, &cover](){ - cover = false; - add = true; - label_name->setVisible(true); - m_lineEdit_name->setVisible(true); - - m_lineEdit_name->setFocus(); - QTimer::singleShot(0, m_lineEdit_name, &QLineEdit::selectAll); - }); - - QSpacerItem *spacer2 = new QSpacerItem(20, 20, QSizePolicy::Expanding); - QPushButton *pbtnOk = new QPushButton; - pbtnOk->setText(tr("ok")); - connect(pbtnOk, &QPushButton::clicked, this, [=, &name, &cover](){ - - QString text = m_lineEdit_name->text(); - static QRegularExpression re("\\s"); - text.remove(re);//Remove space - - name = text.toStdString(); - - if(name.empty()) - { - QMessageBox::information(this, tr("tips"), tr("scheme name cannot be empty")); - m_lineEdit_name->setText(QString::fromStdString(getCurUiShemeName(name))); - return; - } - - if (!cover) - { - std::vector now; - cur_cfg_->get_all_schemes(now); - for(auto& v: now) - { - if(v == name) - { - - QMessageBox::information(this, tr("tips"), tr("scheme name: ") + QString::fromStdString(name) + tr(" already exists")); - m_lineEdit_name->setText(QString::fromStdString(getCurUiShemeName(name))); - return; - } - } - } - - dlg->close(); - }); - - QHBoxLayout *hLayout_pbtnOk = new QHBoxLayout; - hLayout_pbtnOk->addSpacerItem(spacer2); - hLayout_pbtnOk->addWidget(pbtnOk); - - QVBoxLayout *vLayout = new QVBoxLayout; - vLayout->addWidget(label_question); - vLayout->addWidget(radioButtonCover); - vLayout->addWidget(radioButtonNew); - vLayout->addLayout(hLayoutName); - vLayout->addLayout(hLayout_pbtnOk); - dlg->setLayout(vLayout); - - dlg->exec(); - - return add; -} - -std::string hg_settingdialog::getCurUiShemeName(std::string name) -{ - std::string k(""), val(""); - int id = 0; - const SANE_Option_Descriptor* opt = nullptr; - - if (cur_scheme_->first_config(k, val)) - { - int count = 0; - do - { - id = cur_scheme_->id_from_name(k.c_str()); - opt = id == -1 ? nullptr : sane_get_option_descriptor(m_handle, id); - if (opt) - { - if (count++) - name += " + "; - - if (opt->type == SANE_TYPE_STRING) - name += from_default_language(val.c_str(), nullptr); - else - { - name += opt->title; - if (opt->type == SANE_TYPE_BOOL) - { - name += std::string("("); - if (*(SANE_Bool*)&val[0] == SANE_TRUE) - name += "true)"; - else - name += "false)"; - } - else if (opt->type == SANE_TYPE_INT) - { - char buf[128] = { 0 }; - sprintf(buf, "(%d)", *(int*)&val[0]); - name += buf; - } - else if (opt->type == SANE_TYPE_FIXED) - { - char buf[128] = { 0 }; - sprintf(buf, "(%.4f)", SANE_UNFIX(*(SANE_Fixed*)&val[0])); - name += buf; - } - } - } - } while (count < 3 && cur_scheme_->next_config(k, val)); - } - return name; -} - -void hg_settingdialog::save_scheme(void) -{ - std::string name(cur_scheme_->get_scheme_name()); - - bool add = name.empty(); - - if(add) - { - name = getCurUiShemeName(name); - } - else - { - int items = 0; - add = cur_scheme_->has_changed(&items); - if(add) - { - if(items == 0) // while shemes is default - { - cur_cfg_->select_scheme(nullptr); - return; - } - else - add = createMsgBoxUi(add, name); - } - } - if(add) - { - if(name.empty() && cur_scheme_->get_scheme_name().empty()) - { - cur_scheme_->end_setting(true); - return; - } - - gb::sane_config_schm* cp = cur_scheme_->copy(); - - cur_scheme_->end_setting(true); - cur_scheme_->release(); - cur_scheme_ = cp; - - size_t pos = name.rfind('-'); - int ind = 0; - char append[20] = {0}; - - if(pos != std::string::npos) - { - ind = atoi(name.c_str() + pos + 1); - if(ind > 0) - { - name.erase(pos); - sprintf(append, "-%d", ++ind); - } - } - while(!cur_cfg_->add_scheme(cur_scheme_, (name + append).c_str())) - { - sprintf(append, "-%d", ++ind); - } - } - else - { - cur_scheme_->end_setting(false); - } - - cur_cfg_->select_scheme(cur_scheme_->get_scheme_name().c_str()); - - cur_cfg_->save(); -} -void hg_settingdialog::cancel_setting(void) -{ - // restore changed value ... - cur_scheme_->end_setting(true); - dev_que::apply_scheme(m_handle, cur_scheme_); -} - -void hg_settingdialog::getAppVersion() -{ - SANE_About *about = nullptr; - unsigned int len = 0; - std::string versionNum; - if (sane_io_control(m_handle, IO_CTRL_CODE_ABOUT_INFO, about, &len) == SANE_STATUS_NO_MEM) - { - about = (SANE_About*)malloc(len + 128); - if (about) - { - memset(about, 0, len + 128); - if (sane_io_control(m_handle, IO_CTRL_CODE_ABOUT_INFO, about, &len) == SANE_STATUS_GOOD) - { - versionNum = about->version; - } - } - } -} -void hg_settingdialog::apply_current_scheme(void) -{ - dev_que::apply_scheme(m_handle, cur_scheme_); -} -std::string sane_val_to_string(const char* val, SANE_Value_Type type) -{ - char buf[128] = {0}; - std::string ret(""); - - switch(type) - { - case SANE_TYPE_BOOL: - ret = *(SANE_Bool*)val == SANE_TRUE ? "true" : "false"; - break; - case SANE_TYPE_INT: - sprintf(buf, "%d", *(int*)val); - ret = buf; - break; - case SANE_TYPE_FIXED: - sprintf(buf, "%.4f", SANE_UNFIX(*(SANE_Fixed*)val)); - ret = buf; - break; - default: - ret = val; - break; - } - - return ret; -} -void hg_settingdialog::on_current_scheme_changed() -{ - QString scheme(comb_->currentText()); - bool enabled = false; - gb::sane_config_schm *schm = cur_cfg_->get_scheme(scheme.toStdString().c_str()); - - if(schm) - enabled = true; - - rename_->setEnabled(enabled); - apply_->setEnabled(enabled); - del_this_->setEnabled(enabled); - del_all_->setEnabled(enabled); - memset(&m_gammaData, 0, sizeof(m_gammaData)); - for(int i = 0; i < sizeof(m_gammaData.table) / sizeof(m_gammaData.table[0]); ++i) - m_gammaData.table[i] = i & 0x0ff; - - QString info(tr("")); - std::string name(""), val(""); - if(schm && schm->first_config(name, val)) - { - do - { - QString title; - SANE_Value_Type type = SANE_TYPE_STRING; - for (int ii = 0; ii < m_list_defaultOptions.size(); ii++) - { - const SANE_Option_Descriptor* opt = reinterpret_cast(m_list_defaultOptions.at(ii).first); - if(strcmp(opt->name, name.c_str()) == 0) - { - title = QString::fromStdString(opt->title); - type = opt->type; - if(type == SANE_TYPE_STRING) - val = from_default_language(val.c_str(), nullptr); - break; - } - } - - if(title.length()) - { - info += tr("
") + title + tr(":
"); - info += tr("

") + QString::fromStdString(sane_val_to_string(val.c_str(), type)) + tr("

"); - } - else { - if(val.length() == sizeof(SANE_Gamma)) - memcpy(&m_gammaData, val.c_str(), sizeof(SANE_Gamma)); - } - }while(schm->next_config(name, val)); - } - if(schm) - schm->release(); - - sketch_->setHtml(info); -} -void hg_settingdialog::slot_pushButton_scheme_management(void) -{ - QPushButton* btn = qobject_cast(sender()); - - if(btn == rename_) - { - int id = 0; - QString text(find_current_scheme_menu(&id)); - if(!text.isEmpty() && id >= 0) - { - Dialog_Input dlg; - - dlg.init_value(text); - dlg.setWindowTitle(tr("configuration scheme name change")); - if(dlg.exec() && text != dlg.get_inputting_value()) - { - std::vector now; - std::string str = dlg.get_inputting_value().toStdString(); - - cur_cfg_->get_all_schemes(now); - for(auto& v: now) - { - if(v == str) - { - QMessageBox::information(this, tr("tips"), tr("scheme name: ") + QString::fromStdString(str) + tr(" already exists")); - return; - } - } - disconnect(comb_, SIGNAL(currentTextChanged(const QString)), this, SLOT(on_current_scheme_changed())); - comb_->removeItem(id); - comb_->insertItem(id, QString::fromStdString(str)); - comb_->setCurrentIndex(id); - connect(comb_, SIGNAL(currentTextChanged(const QString)), this, SLOT(on_current_scheme_changed())); - - cur_cfg_->rename_scheme(text.toStdString().c_str(), str.c_str()); - cur_cfg_->save(); - changed_count_++; - } - } - } - else if(btn == apply_) - { - QString text(find_current_scheme_menu()); - gb::sane_config_schm *cur = nullptr; - - cur_cfg_->select_scheme(text.toStdString().c_str()); - cur = cur_cfg_->get_scheme(); - if(!cur) - cur = new gb::sane_config_schm(); - cur->copy_default_value(cur_scheme_); - cur_scheme_->end_setting(true); - cur_scheme_->release(); - cur_scheme_ = cur; - cur_scheme_->begin_setting(); - - apply_current_scheme(); - updateUIStatus(); - changed_count_++; - } - else if(btn == del_this_) - { - int id = -1; - QString text(find_current_scheme_menu(&id)); - - if(text.isEmpty()) - return; - - QMessageBox msg(QMessageBox::Question, tr("be sure to delete the configuration"), - tr("Are you sure you want to delete the configuration \"") + text + tr("\" ?"), QMessageBox::Yes | QMessageBox::No, this); - msg.exec(); - if (msg.clickedButton() != msg.button(QMessageBox::Yes)) - return; - - gb::sane_config_schm *sch = cur_cfg_->get_scheme(text.toStdString().c_str()); - cur_cfg_->remove_scheme(text.toStdString().c_str()); - comb_->removeItem(id); - sch->release(); - if(sch == cur_scheme_) - { - restore_2_default_settings(); - updateUIStatus(); - } - - on_current_scheme_changed(); - changed_count_++; - cur_cfg_->save(); - } - else if(btn == del_all_) - { - QMessageBox msg(QMessageBox::Question, tr("be sure to delete the configuration"), - tr("Are you sure you want to delete the configuration?"), QMessageBox::Yes | QMessageBox::No, this); - msg.exec(); - if (msg.clickedButton() != msg.button(QMessageBox::Yes)) - return; - - restore_2_default_settings(); - updateUIStatus(); - comb_->clear(); - changed_count_++; - cur_cfg_->remove_all_schemes(); - cur_cfg_->save(); - } -} -void hg_settingdialog::restore_2_default_settings(void) -{ - cur_scheme_->end_setting(true); - cur_cfg_->select_scheme(nullptr); - dev_que_->apply_scheme(nullptr); - cur_cfg_->save(); - - gb::sane_config_schm *s = new gb::sane_config_schm(); - s->copy_default_value(cur_scheme_); - cur_scheme_->release(); - cur_scheme_ = s; - cur_scheme_->begin_setting(); - - on_current_scheme_changed(); -} diff --git a/app/scanner/hg_settingdialog.h b/app/scanner/hg_settingdialog.h deleted file mode 100644 index 72f71ad3..00000000 --- a/app/scanner/hg_settingdialog.h +++ /dev/null @@ -1,141 +0,0 @@ -#ifndef HG_SETTING_DIALOG_H -#define HG_SETTING_DIALOG_H - -#include -#include -#include -#include "sane/sane_ex.h" -#include "cfg/gb_json.h" -#include "device_menu.h" - -class hg_settingdialog : public QDialog -{ - Q_OBJECT - - int changed_count_; - bool save_; - bool clicked_gamma_; - dev_que *dev_que_; - gb::scanner_cfg *cur_cfg_; - gb::sane_config_schm *cur_scheme_; - - void refresh_control_value(int op_id); - void on_select_scheme(bool apply_to_dev = true); - QString gen_gamma_file_path(void); - - QMenu *top_menu_; - QLineEdit *edit_name_; - QPushButton *rename_; - QPushButton *apply_; - QPushButton *del_this_; - QPushButton *del_all_; - QLabel *custom_area_lable_; - QPushButton *btn_cut_area_; - QPushButton *btn_gamma_; - QTextEdit *sketch_; - QLineEdit *m_lineEdit_name; - void create_scheme_management_ui(QVBoxLayout* layout); - QString find_current_scheme_menu(int *scheme_id = nullptr); - - static std::string property_combox_data_type_; - enum _cbox_type - { - COMBO_VAL_STRING = 0, - COMBO_VAL_INT, - COMBO_VAL_FLOAT, - }; - -public: - explicit hg_settingdialog(void *handle, QWidget *parent = nullptr, - dev_que* dev = nullptr); - ~hg_settingdialog(); - -public: - void initUi(); - void updateOpt(); - void createUI(); - void updateUIStatus(); - QVector find_control(int opt_num); - void keyPressEvent(QKeyEvent *e); - int get_changed_items(void); - -private: - void *m_handle; - -private: - QString m_qstrFileName; - QSettings *m_configIniWrite; - QSettings *m_configIniRead; - -private: - void iniWrite(QString title, int id, QVariant value); - void iniRead(QString title, int id, QWidget *w); - QString md5(QString key); - const void* find_option_description(int id); // return const SANE_Option_Descriptor* pointer - const void* find_option_description(const std::string& title, int* id); // return const SANE_Option_Descriptor* pointer - - virtual void closeEvent(QCloseEvent* e); - bool createMsgBoxUi(bool add, std::string &name); - std::string getCurUiShemeName(std::string name); - void save_scheme(void); - void cancel_setting(void); - void getAppVersion(); - void apply_current_scheme(void); - -private: - QVector, QString>> m_list_IdValueTitle; - QVector> m_list_defaultOptions; // default values of device - QVector> m_list_sliderSpinbox; - QVector> m_list_getOpt; - QVector m_list_deviceNames; - QVector m_list_widgets; - -private slots: - void slot_checkedClicked(); - void slot_sliderClicked(int value); - void slot_spinBoxClicked(int value); - void slot_doubleSpinboxClicked(double value); - void slot_string_list_comboBoxClicked(); - void slot_pushButtonClicked(); - void slot_cutButtonClicked(); - void slot_gammaButtonClicked(); - void slot_word_list_comboBoxClicked(int value); - void slot_lineEditInput(); - void slot_buttonOkClicked(); - void slot_buttonCancelClicked(); - void slot_pushButton_scheme_management(void); - void on_current_scheme_changed(void); - void restore_2_default_settings(void); - -private: - int m_dpiId; - int m_dpiValue; - int m_paperSizeId; - QString m_paperSizeValue; - int m_cutLeftId; - int m_cutTopId; - int m_cutRightId; - int m_cutBottomId; - double m_cutWidth; // 单位是毫米 - double m_cutHeight; // 单位是毫米 - double m_cutLeftValue; // 单位是毫米 - double m_cutTopValue; // 单位是毫米 - double m_cutRightValue; // 单位是毫米 - double m_cutBottomValue; // 单位是毫米 - - int m_colorModeId; - QString m_colorModeValue; - SANE_Gamma m_gammaData; - QComboBox *comb_; -}; - -#endif // HG_SETTING_DIALOG_H - - - - - - - - - diff --git a/app/scanner/image_rsc/action/btnEdit.png b/app/scanner/image_rsc/action/btnEdit.png deleted file mode 100644 index d0314e98..00000000 Binary files a/app/scanner/image_rsc/action/btnEdit.png and /dev/null differ diff --git a/app/scanner/image_rsc/action/btnEmailScanedImages.png b/app/scanner/image_rsc/action/btnEmailScanedImages.png deleted file mode 100644 index 04f7aeb6..00000000 Binary files a/app/scanner/image_rsc/action/btnEmailScanedImages.png and /dev/null differ diff --git a/app/scanner/image_rsc/action/btnFitWindow.png b/app/scanner/image_rsc/action/btnFitWindow.png deleted file mode 100644 index a91665a7..00000000 Binary files a/app/scanner/image_rsc/action/btnFitWindow.png and /dev/null differ diff --git a/app/scanner/image_rsc/action/btnFitWindowWidth.png b/app/scanner/image_rsc/action/btnFitWindowWidth.png deleted file mode 100644 index 31117721..00000000 Binary files a/app/scanner/image_rsc/action/btnFitWindowWidth.png and /dev/null differ diff --git a/app/scanner/image_rsc/action/btnHelp.png b/app/scanner/image_rsc/action/btnHelp.png deleted file mode 100644 index a66bcfcd..00000000 Binary files a/app/scanner/image_rsc/action/btnHelp.png and /dev/null differ diff --git a/app/scanner/image_rsc/action/btnNext.png b/app/scanner/image_rsc/action/btnNext.png deleted file mode 100644 index 3cedec2b..00000000 Binary files a/app/scanner/image_rsc/action/btnNext.png and /dev/null differ diff --git a/app/scanner/image_rsc/action/btnNextPage.png b/app/scanner/image_rsc/action/btnNextPage.png deleted file mode 100644 index e559cad2..00000000 Binary files a/app/scanner/image_rsc/action/btnNextPage.png and /dev/null differ diff --git a/app/scanner/image_rsc/action/btnOriginalSize.png b/app/scanner/image_rsc/action/btnOriginalSize.png deleted file mode 100644 index 8fa672f0..00000000 Binary files a/app/scanner/image_rsc/action/btnOriginalSize.png and /dev/null differ diff --git a/app/scanner/image_rsc/action/btnPrevious.png b/app/scanner/image_rsc/action/btnPrevious.png deleted file mode 100644 index 2f7030bd..00000000 Binary files a/app/scanner/image_rsc/action/btnPrevious.png and /dev/null differ diff --git a/app/scanner/image_rsc/action/btnPreviousPage.png b/app/scanner/image_rsc/action/btnPreviousPage.png deleted file mode 100644 index cfc19941..00000000 Binary files a/app/scanner/image_rsc/action/btnPreviousPage.png and /dev/null differ diff --git a/app/scanner/image_rsc/action/btnRotateLeft.png b/app/scanner/image_rsc/action/btnRotateLeft.png deleted file mode 100644 index 6fa489eb..00000000 Binary files a/app/scanner/image_rsc/action/btnRotateLeft.png and /dev/null differ diff --git a/app/scanner/image_rsc/action/btnRotateRight.png b/app/scanner/image_rsc/action/btnRotateRight.png deleted file mode 100644 index 8bdd0bc7..00000000 Binary files a/app/scanner/image_rsc/action/btnRotateRight.png and /dev/null differ diff --git a/app/scanner/image_rsc/action/btnSaveScanedImages.png b/app/scanner/image_rsc/action/btnSaveScanedImages.png deleted file mode 100644 index ca603ce1..00000000 Binary files a/app/scanner/image_rsc/action/btnSaveScanedImages.png and /dev/null differ diff --git a/app/scanner/image_rsc/action/btnScan.png b/app/scanner/image_rsc/action/btnScan.png deleted file mode 100644 index faba07e9..00000000 Binary files a/app/scanner/image_rsc/action/btnScan.png and /dev/null differ diff --git a/app/scanner/image_rsc/action/btnScannerSetting.png b/app/scanner/image_rsc/action/btnScannerSetting.png deleted file mode 100644 index 5fc71bf0..00000000 Binary files a/app/scanner/image_rsc/action/btnScannerSetting.png and /dev/null differ diff --git a/app/scanner/image_rsc/action/btnZoomIn.png b/app/scanner/image_rsc/action/btnZoomIn.png deleted file mode 100644 index 0e202afa..00000000 Binary files a/app/scanner/image_rsc/action/btnZoomIn.png and /dev/null differ diff --git a/app/scanner/image_rsc/action/btnZoomOut.png b/app/scanner/image_rsc/action/btnZoomOut.png deleted file mode 100644 index 28d94b7f..00000000 Binary files a/app/scanner/image_rsc/action/btnZoomOut.png and /dev/null differ diff --git a/app/scanner/image_rsc/actions/admin.png b/app/scanner/image_rsc/actions/admin.png deleted file mode 100644 index 77cb98bb..00000000 Binary files a/app/scanner/image_rsc/actions/admin.png and /dev/null differ diff --git a/app/scanner/image_rsc/actions/close.png b/app/scanner/image_rsc/actions/close.png deleted file mode 100644 index 27bc667f..00000000 Binary files a/app/scanner/image_rsc/actions/close.png and /dev/null differ diff --git a/app/scanner/image_rsc/actions/contrast.png b/app/scanner/image_rsc/actions/contrast.png deleted file mode 100644 index b6473e09..00000000 Binary files a/app/scanner/image_rsc/actions/contrast.png and /dev/null differ diff --git a/app/scanner/image_rsc/actions/curve.png b/app/scanner/image_rsc/actions/curve.png deleted file mode 100644 index 15a0dd33..00000000 Binary files a/app/scanner/image_rsc/actions/curve.png and /dev/null differ diff --git a/app/scanner/image_rsc/actions/cut.png b/app/scanner/image_rsc/actions/cut.png deleted file mode 100644 index bebd13d8..00000000 Binary files a/app/scanner/image_rsc/actions/cut.png and /dev/null differ diff --git a/app/scanner/image_rsc/actions/fullscreen.png b/app/scanner/image_rsc/actions/fullscreen.png deleted file mode 100644 index df41e0a7..00000000 Binary files a/app/scanner/image_rsc/actions/fullscreen.png and /dev/null differ diff --git a/app/scanner/image_rsc/actions/help.png b/app/scanner/image_rsc/actions/help.png deleted file mode 100644 index 0ac9bc12..00000000 Binary files a/app/scanner/image_rsc/actions/help.png and /dev/null differ diff --git a/app/scanner/image_rsc/actions/imageEdit.png b/app/scanner/image_rsc/actions/imageEdit.png deleted file mode 100644 index 8a1f5b96..00000000 Binary files a/app/scanner/image_rsc/actions/imageEdit.png and /dev/null differ diff --git a/app/scanner/image_rsc/actions/nextfile.png b/app/scanner/image_rsc/actions/nextfile.png deleted file mode 100644 index c260b10d..00000000 Binary files a/app/scanner/image_rsc/actions/nextfile.png and /dev/null differ diff --git a/app/scanner/image_rsc/actions/nextpage.png b/app/scanner/image_rsc/actions/nextpage.png deleted file mode 100644 index 6f1bcfca..00000000 Binary files a/app/scanner/image_rsc/actions/nextpage.png and /dev/null differ diff --git a/app/scanner/image_rsc/actions/open.png b/app/scanner/image_rsc/actions/open.png deleted file mode 100644 index 4269a967..00000000 Binary files a/app/scanner/image_rsc/actions/open.png and /dev/null differ diff --git a/app/scanner/image_rsc/actions/previousfile.png b/app/scanner/image_rsc/actions/previousfile.png deleted file mode 100644 index d5d24197..00000000 Binary files a/app/scanner/image_rsc/actions/previousfile.png and /dev/null differ diff --git a/app/scanner/image_rsc/actions/previouspage.png b/app/scanner/image_rsc/actions/previouspage.png deleted file mode 100644 index 9b34d804..00000000 Binary files a/app/scanner/image_rsc/actions/previouspage.png and /dev/null differ diff --git a/app/scanner/image_rsc/actions/print.png b/app/scanner/image_rsc/actions/print.png deleted file mode 100644 index 3e36a381..00000000 Binary files a/app/scanner/image_rsc/actions/print.png and /dev/null differ diff --git a/app/scanner/image_rsc/actions/redo.png b/app/scanner/image_rsc/actions/redo.png deleted file mode 100644 index 7f9d14a6..00000000 Binary files a/app/scanner/image_rsc/actions/redo.png and /dev/null differ diff --git a/app/scanner/image_rsc/actions/rotate-anticlockwise.png b/app/scanner/image_rsc/actions/rotate-anticlockwise.png deleted file mode 100644 index fcb6a038..00000000 Binary files a/app/scanner/image_rsc/actions/rotate-anticlockwise.png and /dev/null differ diff --git a/app/scanner/image_rsc/actions/rotate-clockwise.png b/app/scanner/image_rsc/actions/rotate-clockwise.png deleted file mode 100644 index bdeaa9b2..00000000 Binary files a/app/scanner/image_rsc/actions/rotate-clockwise.png and /dev/null differ diff --git a/app/scanner/image_rsc/actions/save.png b/app/scanner/image_rsc/actions/save.png deleted file mode 100644 index 494fa3fb..00000000 Binary files a/app/scanner/image_rsc/actions/save.png and /dev/null differ diff --git a/app/scanner/image_rsc/actions/saveAs.png b/app/scanner/image_rsc/actions/saveAs.png deleted file mode 100644 index ef9e3a57..00000000 Binary files a/app/scanner/image_rsc/actions/saveAs.png and /dev/null differ diff --git a/app/scanner/image_rsc/actions/scan.png b/app/scanner/image_rsc/actions/scan.png deleted file mode 100644 index 69d1782c..00000000 Binary files a/app/scanner/image_rsc/actions/scan.png and /dev/null differ diff --git a/app/scanner/image_rsc/actions/scanInto.png b/app/scanner/image_rsc/actions/scanInto.png deleted file mode 100644 index 58cabfc1..00000000 Binary files a/app/scanner/image_rsc/actions/scanInto.png and /dev/null differ diff --git a/app/scanner/image_rsc/actions/settings.png b/app/scanner/image_rsc/actions/settings.png deleted file mode 100644 index affb00a1..00000000 Binary files a/app/scanner/image_rsc/actions/settings.png and /dev/null differ diff --git a/app/scanner/image_rsc/actions/sortpages.png b/app/scanner/image_rsc/actions/sortpages.png deleted file mode 100644 index d1f563be..00000000 Binary files a/app/scanner/image_rsc/actions/sortpages.png and /dev/null differ diff --git a/app/scanner/image_rsc/actions/undo.png b/app/scanner/image_rsc/actions/undo.png deleted file mode 100644 index 81993d34..00000000 Binary files a/app/scanner/image_rsc/actions/undo.png and /dev/null differ diff --git a/app/scanner/image_rsc/actions/zoom-fitscreen.png b/app/scanner/image_rsc/actions/zoom-fitscreen.png deleted file mode 100644 index 12be6942..00000000 Binary files a/app/scanner/image_rsc/actions/zoom-fitscreen.png and /dev/null differ diff --git a/app/scanner/image_rsc/actions/zoom-fitwidth.png b/app/scanner/image_rsc/actions/zoom-fitwidth.png deleted file mode 100644 index aae9d492..00000000 Binary files a/app/scanner/image_rsc/actions/zoom-fitwidth.png and /dev/null differ diff --git a/app/scanner/image_rsc/actions/zoom-in.png b/app/scanner/image_rsc/actions/zoom-in.png deleted file mode 100644 index 6cfbbd3d..00000000 Binary files a/app/scanner/image_rsc/actions/zoom-in.png and /dev/null differ diff --git a/app/scanner/image_rsc/actions/zoom-origin.png b/app/scanner/image_rsc/actions/zoom-origin.png deleted file mode 100644 index aa2775f1..00000000 Binary files a/app/scanner/image_rsc/actions/zoom-origin.png and /dev/null differ diff --git a/app/scanner/image_rsc/actions/zoom-out.png b/app/scanner/image_rsc/actions/zoom-out.png deleted file mode 100644 index 6f6065ad..00000000 Binary files a/app/scanner/image_rsc/actions/zoom-out.png and /dev/null differ diff --git a/app/scanner/image_rsc/adjust/Img_BightnessReduce.png b/app/scanner/image_rsc/adjust/Img_BightnessReduce.png deleted file mode 100644 index 2fefbcde..00000000 Binary files a/app/scanner/image_rsc/adjust/Img_BightnessReduce.png and /dev/null differ diff --git a/app/scanner/image_rsc/adjust/Img_BrightnessIncrease.png b/app/scanner/image_rsc/adjust/Img_BrightnessIncrease.png deleted file mode 100644 index c7d31370..00000000 Binary files a/app/scanner/image_rsc/adjust/Img_BrightnessIncrease.png and /dev/null differ diff --git a/app/scanner/image_rsc/adjust/Img_ContrastIncrease.png b/app/scanner/image_rsc/adjust/Img_ContrastIncrease.png deleted file mode 100644 index 64dccf97..00000000 Binary files a/app/scanner/image_rsc/adjust/Img_ContrastIncrease.png and /dev/null differ diff --git a/app/scanner/image_rsc/adjust/Img_ContrastReduce.png b/app/scanner/image_rsc/adjust/Img_ContrastReduce.png deleted file mode 100644 index cc3c056d..00000000 Binary files a/app/scanner/image_rsc/adjust/Img_ContrastReduce.png and /dev/null differ diff --git a/app/scanner/image_rsc/example/example_arrow.png b/app/scanner/image_rsc/example/example_arrow.png deleted file mode 100644 index d12c3f38..00000000 Binary files a/app/scanner/image_rsc/example/example_arrow.png and /dev/null differ diff --git a/app/scanner/image_rsc/example/example_black_after.png b/app/scanner/image_rsc/example/example_black_after.png deleted file mode 100644 index 0bd02bc8..00000000 Binary files a/app/scanner/image_rsc/example/example_black_after.png and /dev/null differ diff --git a/app/scanner/image_rsc/example/example_black_before.png b/app/scanner/image_rsc/example/example_black_before.png deleted file mode 100644 index df7f9b1e..00000000 Binary files a/app/scanner/image_rsc/example/example_black_before.png and /dev/null differ diff --git a/app/scanner/image_rsc/example/example_crop_after.png b/app/scanner/image_rsc/example/example_crop_after.png deleted file mode 100644 index 2ca1d687..00000000 Binary files a/app/scanner/image_rsc/example/example_crop_after.png and /dev/null differ diff --git a/app/scanner/image_rsc/example/example_deskew_after.png b/app/scanner/image_rsc/example/example_deskew_after.png deleted file mode 100644 index 7c4f2537..00000000 Binary files a/app/scanner/image_rsc/example/example_deskew_after.png and /dev/null differ diff --git a/app/scanner/image_rsc/example/example_deskew_before.png b/app/scanner/image_rsc/example/example_deskew_before.png deleted file mode 100644 index b3a05216..00000000 Binary files a/app/scanner/image_rsc/example/example_deskew_before.png and /dev/null differ diff --git a/app/scanner/image_rsc/example/example_fillblack_before.png b/app/scanner/image_rsc/example/example_fillblack_before.png deleted file mode 100644 index 6e54cf30..00000000 Binary files a/app/scanner/image_rsc/example/example_fillblack_before.png and /dev/null differ diff --git a/app/scanner/image_rsc/example/example_fillblack_concave.png b/app/scanner/image_rsc/example/example_fillblack_concave.png deleted file mode 100644 index 4b885022..00000000 Binary files a/app/scanner/image_rsc/example/example_fillblack_concave.png and /dev/null differ diff --git a/app/scanner/image_rsc/example/example_fillblack_convex.png b/app/scanner/image_rsc/example/example_fillblack_convex.png deleted file mode 100644 index d98d1e27..00000000 Binary files a/app/scanner/image_rsc/example/example_fillblack_convex.png and /dev/null differ diff --git a/app/scanner/image_rsc/example/example_fillcolor_auto.png b/app/scanner/image_rsc/example/example_fillcolor_auto.png deleted file mode 100644 index 077f7f19..00000000 Binary files a/app/scanner/image_rsc/example/example_fillcolor_auto.png and /dev/null differ diff --git a/app/scanner/image_rsc/example/example_fillcolor_before.png b/app/scanner/image_rsc/example/example_fillcolor_before.png deleted file mode 100644 index 576059bb..00000000 Binary files a/app/scanner/image_rsc/example/example_fillcolor_before.png and /dev/null differ diff --git a/app/scanner/image_rsc/example/example_fillcolor_default.png b/app/scanner/image_rsc/example/example_fillcolor_default.png deleted file mode 100644 index 275fb5ef..00000000 Binary files a/app/scanner/image_rsc/example/example_fillcolor_default.png and /dev/null differ diff --git a/app/scanner/image_rsc/fullscreen/btnNext.png b/app/scanner/image_rsc/fullscreen/btnNext.png deleted file mode 100644 index 3cedec2b..00000000 Binary files a/app/scanner/image_rsc/fullscreen/btnNext.png and /dev/null differ diff --git a/app/scanner/image_rsc/fullscreen/btnPrevious.png b/app/scanner/image_rsc/fullscreen/btnPrevious.png deleted file mode 100644 index 2f7030bd..00000000 Binary files a/app/scanner/image_rsc/fullscreen/btnPrevious.png and /dev/null differ diff --git a/app/scanner/image_rsc/logo/Cumtenn_logo.ico b/app/scanner/image_rsc/logo/Cumtenn_logo.ico deleted file mode 100644 index 62100d5b..00000000 Binary files a/app/scanner/image_rsc/logo/Cumtenn_logo.ico and /dev/null differ diff --git a/app/scanner/image_rsc/logo/HG_Logo.png b/app/scanner/image_rsc/logo/HG_Logo.png deleted file mode 100644 index 4c2f5189..00000000 Binary files a/app/scanner/image_rsc/logo/HG_Logo.png and /dev/null differ diff --git a/app/scanner/image_rsc/logo/HUAGO-LOGO-for UI.jpg b/app/scanner/image_rsc/logo/HUAGO-LOGO-for UI.jpg deleted file mode 100644 index ede0c4a4..00000000 Binary files a/app/scanner/image_rsc/logo/HUAGO-LOGO-for UI.jpg and /dev/null differ diff --git a/app/scanner/image_rsc/logo/HUAGO-LOGO-for UI.png b/app/scanner/image_rsc/logo/HUAGO-LOGO-for UI.png deleted file mode 100644 index 99b0730d..00000000 Binary files a/app/scanner/image_rsc/logo/HUAGO-LOGO-for UI.png and /dev/null differ diff --git a/app/scanner/image_rsc/logo/Hanvon_logo1.ico b/app/scanner/image_rsc/logo/Hanvon_logo1.ico deleted file mode 100644 index cf47eb31..00000000 Binary files a/app/scanner/image_rsc/logo/Hanvon_logo1.ico and /dev/null differ diff --git a/app/scanner/image_rsc/logo/Hanvon_logo2.ico b/app/scanner/image_rsc/logo/Hanvon_logo2.ico deleted file mode 100644 index 637c35e6..00000000 Binary files a/app/scanner/image_rsc/logo/Hanvon_logo2.ico and /dev/null differ diff --git a/app/scanner/image_rsc/logo/Lanxum_logo.ico b/app/scanner/image_rsc/logo/Lanxum_logo.ico deleted file mode 100644 index 3f04624b..00000000 Binary files a/app/scanner/image_rsc/logo/Lanxum_logo.ico and /dev/null differ diff --git a/app/scanner/image_rsc/logo/Microtek_logo.ico b/app/scanner/image_rsc/logo/Microtek_logo.ico deleted file mode 100644 index 46c1adf8..00000000 Binary files a/app/scanner/image_rsc/logo/Microtek_logo.ico and /dev/null differ diff --git a/app/scanner/image_rsc/logo/NoBrand_logo.ico b/app/scanner/image_rsc/logo/NoBrand_logo.ico deleted file mode 100644 index 569a7ac5..00000000 Binary files a/app/scanner/image_rsc/logo/NoBrand_logo.ico and /dev/null differ diff --git a/app/scanner/image_rsc/logo/RightWay_logo.ico b/app/scanner/image_rsc/logo/RightWay_logo.ico deleted file mode 100644 index 8692896a..00000000 Binary files a/app/scanner/image_rsc/logo/RightWay_logo.ico and /dev/null differ diff --git a/app/scanner/image_rsc/logo/auge_logo.ico b/app/scanner/image_rsc/logo/auge_logo.ico deleted file mode 100644 index bdbc6191..00000000 Binary files a/app/scanner/image_rsc/logo/auge_logo.ico and /dev/null differ diff --git a/app/scanner/image_rsc/logo/deli.ico b/app/scanner/image_rsc/logo/deli.ico deleted file mode 100644 index 7fc788e4..00000000 Binary files a/app/scanner/image_rsc/logo/deli.ico and /dev/null differ diff --git a/app/scanner/image_rsc/logo/logo.ico b/app/scanner/image_rsc/logo/logo.ico deleted file mode 100644 index bb062276..00000000 Binary files a/app/scanner/image_rsc/logo/logo.ico and /dev/null differ diff --git a/app/scanner/image_rsc/logo/uniscan.ico b/app/scanner/image_rsc/logo/uniscan.ico deleted file mode 100644 index 0ef56bae..00000000 Binary files a/app/scanner/image_rsc/logo/uniscan.ico and /dev/null differ diff --git a/app/scanner/image_rsc/logo/waiting.gif b/app/scanner/image_rsc/logo/waiting.gif deleted file mode 100644 index 915c1984..00000000 Binary files a/app/scanner/image_rsc/logo/waiting.gif and /dev/null differ diff --git a/app/scanner/image_rsc/scroll/bottom_Hot.png b/app/scanner/image_rsc/scroll/bottom_Hot.png deleted file mode 100644 index 5b0b800c..00000000 Binary files a/app/scanner/image_rsc/scroll/bottom_Hot.png and /dev/null differ diff --git a/app/scanner/image_rsc/scroll/bottom_Normal.png b/app/scanner/image_rsc/scroll/bottom_Normal.png deleted file mode 100644 index cba9d6ee..00000000 Binary files a/app/scanner/image_rsc/scroll/bottom_Normal.png and /dev/null differ diff --git a/app/scanner/image_rsc/scroll/bottom_Push.png b/app/scanner/image_rsc/scroll/bottom_Push.png deleted file mode 100644 index ef2d626c..00000000 Binary files a/app/scanner/image_rsc/scroll/bottom_Push.png and /dev/null differ diff --git a/app/scanner/image_rsc/scroll/defItemImage.png b/app/scanner/image_rsc/scroll/defItemImage.png deleted file mode 100644 index 55b8217a..00000000 Binary files a/app/scanner/image_rsc/scroll/defItemImage.png and /dev/null differ diff --git a/app/scanner/image_rsc/scroll/hScrollImage.png b/app/scanner/image_rsc/scroll/hScrollImage.png deleted file mode 100644 index 2f118c80..00000000 Binary files a/app/scanner/image_rsc/scroll/hScrollImage.png and /dev/null differ diff --git a/app/scanner/image_rsc/scroll/hScrollSlider_Hot.png b/app/scanner/image_rsc/scroll/hScrollSlider_Hot.png deleted file mode 100644 index d63df0f7..00000000 Binary files a/app/scanner/image_rsc/scroll/hScrollSlider_Hot.png and /dev/null differ diff --git a/app/scanner/image_rsc/scroll/hScrollSlider_Normal.png b/app/scanner/image_rsc/scroll/hScrollSlider_Normal.png deleted file mode 100644 index f75c4048..00000000 Binary files a/app/scanner/image_rsc/scroll/hScrollSlider_Normal.png and /dev/null differ diff --git a/app/scanner/image_rsc/scroll/hScrollSlider_Push.png b/app/scanner/image_rsc/scroll/hScrollSlider_Push.png deleted file mode 100644 index 85208280..00000000 Binary files a/app/scanner/image_rsc/scroll/hScrollSlider_Push.png and /dev/null differ diff --git a/app/scanner/image_rsc/scroll/left_Hot.png b/app/scanner/image_rsc/scroll/left_Hot.png deleted file mode 100644 index caef5565..00000000 Binary files a/app/scanner/image_rsc/scroll/left_Hot.png and /dev/null differ diff --git a/app/scanner/image_rsc/scroll/left_Normal.png b/app/scanner/image_rsc/scroll/left_Normal.png deleted file mode 100644 index cba9d6ee..00000000 Binary files a/app/scanner/image_rsc/scroll/left_Normal.png and /dev/null differ diff --git a/app/scanner/image_rsc/scroll/left_Push.png b/app/scanner/image_rsc/scroll/left_Push.png deleted file mode 100644 index dccdb752..00000000 Binary files a/app/scanner/image_rsc/scroll/left_Push.png and /dev/null differ diff --git a/app/scanner/image_rsc/scroll/nullScrollImage.png b/app/scanner/image_rsc/scroll/nullScrollImage.png deleted file mode 100644 index 2f118c80..00000000 Binary files a/app/scanner/image_rsc/scroll/nullScrollImage.png and /dev/null differ diff --git a/app/scanner/image_rsc/scroll/right_Hot.png b/app/scanner/image_rsc/scroll/right_Hot.png deleted file mode 100644 index 3255c518..00000000 Binary files a/app/scanner/image_rsc/scroll/right_Hot.png and /dev/null differ diff --git a/app/scanner/image_rsc/scroll/right_Normal.png b/app/scanner/image_rsc/scroll/right_Normal.png deleted file mode 100644 index cba9d6ee..00000000 Binary files a/app/scanner/image_rsc/scroll/right_Normal.png and /dev/null differ diff --git a/app/scanner/image_rsc/scroll/right_Push.png b/app/scanner/image_rsc/scroll/right_Push.png deleted file mode 100644 index 79e64029..00000000 Binary files a/app/scanner/image_rsc/scroll/right_Push.png and /dev/null differ diff --git a/app/scanner/image_rsc/scroll/top_Hot.png b/app/scanner/image_rsc/scroll/top_Hot.png deleted file mode 100644 index 1da747bf..00000000 Binary files a/app/scanner/image_rsc/scroll/top_Hot.png and /dev/null differ diff --git a/app/scanner/image_rsc/scroll/top_Normal.png b/app/scanner/image_rsc/scroll/top_Normal.png deleted file mode 100644 index cba9d6ee..00000000 Binary files a/app/scanner/image_rsc/scroll/top_Normal.png and /dev/null differ diff --git a/app/scanner/image_rsc/scroll/top_Push.png b/app/scanner/image_rsc/scroll/top_Push.png deleted file mode 100644 index 5ae58ed3..00000000 Binary files a/app/scanner/image_rsc/scroll/top_Push.png and /dev/null differ diff --git a/app/scanner/image_rsc/scroll/vScrollImage.png b/app/scanner/image_rsc/scroll/vScrollImage.png deleted file mode 100644 index 705fafdc..00000000 Binary files a/app/scanner/image_rsc/scroll/vScrollImage.png and /dev/null differ diff --git a/app/scanner/image_rsc/scroll/vScrollSlider_Hot.png b/app/scanner/image_rsc/scroll/vScrollSlider_Hot.png deleted file mode 100644 index bb724b92..00000000 Binary files a/app/scanner/image_rsc/scroll/vScrollSlider_Hot.png and /dev/null differ diff --git a/app/scanner/image_rsc/scroll/vScrollSlider_Normal.png b/app/scanner/image_rsc/scroll/vScrollSlider_Normal.png deleted file mode 100644 index 83cb4010..00000000 Binary files a/app/scanner/image_rsc/scroll/vScrollSlider_Normal.png and /dev/null differ diff --git a/app/scanner/image_rsc/scroll/vScrollSlider_Push.png b/app/scanner/image_rsc/scroll/vScrollSlider_Push.png deleted file mode 100644 index 406915e1..00000000 Binary files a/app/scanner/image_rsc/scroll/vScrollSlider_Push.png and /dev/null differ diff --git a/app/scanner/image_rsc/statusbar/statusBar_admin.png b/app/scanner/image_rsc/statusbar/statusBar_admin.png deleted file mode 100644 index 75d2fc58..00000000 Binary files a/app/scanner/image_rsc/statusbar/statusBar_admin.png and /dev/null differ diff --git a/app/scanner/main.cpp b/app/scanner/main.cpp deleted file mode 100644 index a95d2699..00000000 --- a/app/scanner/main.cpp +++ /dev/null @@ -1,58 +0,0 @@ -#include "mainwindow.h" - -#include -#include -#include -#include "app_cfg.h" -#include "lang/app_language.h" - -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - - lang_initialize(nullptr); - - QString appLang = getCfgValue("global", "language", QString("chinese")); - for (int i = 1; i < argc; i++) - { - char* z = argv[i]; - - if (z == strstr(z, "-language=")) - appLang = z + strlen("-language="); - } - - if (appLang != "english") - { - appLang = "chinese"; - } - - saveCfgValue("global", "language", appLang); - - QString translator_qt_name = ":translation/qt_zh_CN.qm"; - QString translator_scanner_name = ":translation/Scanner_zh_CN.qm"; - - QTranslator translator_qt; - int cp = 936; - if (appLang == "english") - { - translator_scanner_name = ":translation/Scanner_zh_EN.qm"; - cp = 20127; - } - else if (appLang == "chinese") - { - if (translator_qt.load(translator_qt_name)) - a.installTranslator(&translator_qt); - } - - QTranslator translator_scanner; - if (translator_scanner.load(translator_scanner_name)) - a.installTranslator(&translator_scanner); - - lang_set_code_page(cp); - - MainWindow w(appLang); - QScreen *screen = QGuiApplication::primaryScreen(); - w.move((screen->size().width() - w.width()) / 2, (screen->size().height() - w.height()) / 2); - w.show(); - return a.exec(); -} diff --git a/app/scanner/mainwindow.cpp b/app/scanner/mainwindow.cpp deleted file mode 100644 index aa60f381..00000000 --- a/app/scanner/mainwindow.cpp +++ /dev/null @@ -1,4709 +0,0 @@ -#include "mainwindow.h" -#include "ui_mainwindow.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include "widget_statusbar.h" -#include "dialog_log.h" -#include "dialog_openimageindex.h" -#include "dialog_saveas.h" -#include "dialog_export.h" -#include "dialog_exportimagefile.h" -#include "dialog_imageinfo.h" -#include "dialog_fullscreen.h" -#include "dialog_imgproc_adjust.h" -#include "dialog_multirotate.h" -#include "dialog_multirotateimagefile.h" -#include "dialog_imgproc_autocrop.h" -#include "dialog_admin.h" -#include "dialog_passwordchange.h" -#include "dialog_insertindex.h" -#include "dialog_aquireinto.h" -#include "dialog_logmanager.h" -#include "dialog_clrcache.h" -#include "dialog_moveto.h" -#include "dialog_imageeditor.h" -#include "dialog_updateprogress.h" -#include "dialog_upgrade.h" -#include "dialog_feedback.h" -#include "dialog_upgradefirmware.h" -#include "dialog_savemessagebox.h" -#include "hg_settingdialog.h" -#include "base/HGInfo.h" -#include "huagao/hgscanner_error.h" -#include "imgfmt/HGPdf.h" -#include "imgfmt/HGTiff.h" -#include "imgfmt/HGImgFmt.h" -#include "imgproc/HGImgProc.h" -#include "imgproc/HGOCR.h" -#include "base/HGUtility.h" -#include "base/HGCrash.h" -#include "HGUIGlobal.h" -#include "HGString.h" -#include "app_cfg.h" -#include -#include "dialog_wrong_img.h" -#include "../../code_device/hgdriver/hgdev/char_const.h" -#include "lang/app_language.h" -#include "ocrPdf.h" - -#define PASSWORD_KEY 4 -#define MY_URL_SCHEME "inscanner" - -MainWindow::MainWindow(const QString& appLang, QWidget *parent) - : QMainWindow(parent) - , ui(new Ui::MainWindow) - , m_currLang(appLang) - , m_versionDll(nullptr) - , m_admin_loggedIn(false) - , m_dpi(200) - , m_currFilePath("") - , m_currIndex(-1) - , m_multiPageCount(0) - , m_multiIndex(-1) - , m_modify(false) - , m_singleScan(false) - , m_scanType(0) - , m_scanInsertPos(-1) - , m_saveType(0) - , m_scanFileName("") - , m_scanImgFmtWriter(nullptr) - , m_isScanning(false) - , auto_save_changes_(false) - , save_from_changed_(false) - , m_closeTip(true) - , m_currScanCount(0) - , m_devSerialNum("") - , m_devVersionNum("") - , m_currDeviceName("") - , m_devPid("") - , m_cacheDirNotify(false) - , m_AquirePathNotify(false) - , m_bSideflag(false) - , m_bSideEditing(false) -{ - ui->setupUi(this); - - m_versionDll = new VersionDll; - HGBase_RegisterCrashFunc(CrashFunc, this); - - HGChar logFilePath[512]; - HGBase_GetLogFilePath(logFilePath, 512); - deleteOverdueLogFile(QString::fromStdString(getStdString(logFilePath))); - - HGChar cfgFilePath[512]; - HGBase_GetConfigPath(cfgFilePath, 512); - deleteUpgradePkg(QString::fromStdString(getStdString(cfgFilePath))); - -#if defined(OEM_HANWANG) - this->setWindowIcon(QIcon(":images/image_rsc/logo/Hanvon_logo1.ico")); - this->setWindowTitle(tr("HanvonScan")); - m_oemName = HGVERSION_OEMNAME_HANVON; -#elif defined(OEM_LISICHENG) - this->setWindowIcon(QIcon(":images/image_rsc/logo/Lanxum_logo.ico")); - this->setWindowTitle(tr("LanxumScan")); - m_oemName = HGVERSION_OEMNAME_LANXUM; -#elif defined(OEM_CANGTIAN) - this->setWindowIcon(QIcon(":images/image_rsc/logo/Cumtenn_logo.ico")); - this->setWindowTitle(tr("CumtennScan")); - m_oemName = HGVERSION_OEMNAME_CUMTENN; -#elif defined(OEM_ZHONGJING) - this->setWindowIcon(QIcon(":images/image_rsc/logo/Microtek_logo.ico")); - this->setWindowTitle(tr("MicrotekScan")); - m_oemName = HGVERSION_OEMNAME_MICROTEK; -#elif defined(OEM_ZIGUANG) - this->setWindowIcon(QIcon(":images/image_rsc/logo/uniscan.ico")); - this->setWindowTitle(tr("UniScan")); - m_oemName = HGVERSION_OEMNAME_UNIS; -#elif defined(OEM_HUAGO_NEU) - this->setWindowIcon(QIcon(":images/image_rsc/logo/RightWay_logo.ico")); - this->setWindowTitle(tr("Scan")); - m_oemName = HGVERSION_OEMNAME_HUAGO_NEU; -#elif defined(OEM_DELI) - this->setWindowIcon(QIcon(":images/image_rsc/logo/deli.ico")); - this->setWindowTitle(tr("DeliScan")); - m_oemName = HGVERSION_OEMNAME_DELI; -#else - this->setWindowIcon(QIcon(":images/image_rsc/logo/logo.ico")); - this->setWindowTitle(tr("HuaGoScan")); - m_oemName = HGVERSION_OEMNAME_HUAGO; -#endif - - this->setAutoFillBackground(true); - this->setPalette(QPalette(QColor(230, 230, 230))); - - QDesktopWidget *desktopWidget = QApplication::desktop(); - QRect screenRect = desktopWidget->screenGeometry(this); - if(screenRect.width() > 1200 && screenRect.height() > 900) - { - resize(950, 720); - } - - ui->actionact_update->setVisible(false); - ui->act_feedback->setVisible(false); - -#if !defined(OEM_HANWANG) && !defined(OEM_LISICHENG) && !defined(OEM_CANGTIAN) && !defined(OEM_ZHONGJING) && !defined(OEM_ZIGUANG) && !defined(OEM_NEUTRAL) && !defined(OEM_DELI) - if (m_versionDll->IsValid()) - { - ui->actionact_update->setVisible(true); - ui->act_feedback->setVisible(true); - m_versionDll->PostUserOpenInfo(HGVERSION_APPNAME_SCANNER, m_oemName); - } -#endif - - HGChar cfgpath[512] = {0}; - QString old; - HGBase_GetConfigPath(cfgpath, _countof(cfgpath) - 1); - HGBase_CreateDir(cfgpath); - dev_que_.set_root_dir(cfgpath); - old = QString::fromStdString(cfgpath) + PATH_SYMBOL + "scanner.schm"; - if(QFile::exists(old)) - dev_que::update_old_cfg(old.toStdString().c_str()); - - ui->toolBar->addAction(ui->act_scannerSettings); - ui->toolBar->addAction(ui->act_acquire); - m_act_acquireInto2 = new QAction(QIcon(":/images/image_rsc/actions/scanInto.png"), tr("act_acquireInto"), this); - connect(m_act_acquireInto2, SIGNAL(triggered()), this, SLOT(on_AcquireInto2())); - ui->toolBar->addAction(m_act_acquireInto2); - ui->toolBar->addSeparator(); - - initAcquireIntoComboBox(); - - ui->toolBar->addAction(ui->act_fitWindowWidth); - ui->toolBar->addAction(ui->act_fitWindowSize); - ui->toolBar->addAction(ui->act_zoomIn); - ui->toolBar->addAction(ui->act_zoomOut); - ui->toolBar->addAction(ui->act_realSize); - ui->toolBar->addSeparator(); - ui->toolBar->addAction(ui->act_90Left); - ui->toolBar->addAction(ui->act_90Right); - ui->toolBar->addAction(ui->act_imageEdit); - ui->toolBar->addSeparator(); - ui->toolBar->addAction(ui->act_previous); - ui->toolBar->addAction(ui->act_next); - ui->toolBar->addAction(ui->act_previousPage); - ui->toolBar->addAction(ui->act_nextPage); - ui->toolBar->addAction(ui->act_sortPages); - ui->toolBar->addSeparator(); - ui->toolBar->addAction(ui->act_help); - -#if defined (OEM_ZHONGJING) - m_menu_language = new QMenu(tr("menu_language")); - m_act_simpCN = new QAction(tr("act_simpCN"),nullptr); - m_act_English = new QAction(tr("act_English"),nullptr); - m_act_simpCN->setCheckable(true); - m_act_English->setCheckable(true); - ui->menu_info->addMenu(m_menu_language); - m_menu_language->addAction(m_act_simpCN); - m_menu_language->addAction(m_act_English); - - if (m_currLang == "english") - { - m_act_simpCN->setChecked(false); - m_act_English->setChecked(true); - } - else - { - m_act_simpCN->setChecked(true); - m_act_English->setChecked(false); - } - - connect(m_act_simpCN, SIGNAL(triggered()), this, SLOT(on_act_simpCN_triggered())); - connect(m_act_English, SIGNAL(triggered()), this, SLOT(on_act_English_triggered())); -#endif - - m_view = new HGImgView(ui->centralwidget); - ui->verticalLayout->addWidget(m_view); - ui->centralwidget->setMinimumWidth(160); - - m_thumb = new HGImgThumb(ui->dockWidget); - ui->dockWidget->setMinimumWidth(200); - resizeDocks({ui->dockWidget}, {200}, Qt::Horizontal); - ui->dockWidget->setWidget(m_thumb); - ui->dockWidget->setTitleBarWidget(new QWidget()); - ui->dockWidget->titleBarWidget()->setVisible(false); - - QRegExp rx("[0-9,-]+$"); - m_multiPageLineEdit = new HGLineEdit(this); - m_multiPageLineEdit->setValidator(new QRegExpValidator(rx, this)); - m_multiPageLineEdit->setFixedWidth(100); - m_multiPageLineEdit->setAlignment(Qt::AlignHCenter); - ui->toolBar->insertWidget(ui->act_nextPage, m_multiPageLineEdit); - ui->toolBar->setStyleSheet("QToolBar::item{border: 0px}"); - - m_wndStatusBar = new Widget_StatusBar(ui->act_zoomIn, ui->act_zoomOut, ui->statusBar); - ui->statusBar->addWidget(m_wndStatusBar, 1); - m_wndStatusBar->setStyleSheet("QStatusBar::item{border: 0px}"); - ui->statusBar->setSizeGripEnabled(false); - - m_dialogLog = new dialog_log(this); - - connect(m_view, SIGNAL(scaleChanged(double)), this, SLOT(on_viewerScale(double))); - connect(m_view, SIGNAL(mousePos(int, int)), this, SLOT(on_viewerMousePos(int, int))); - connect(m_view, SIGNAL(drop(const QObject*, const QStringList &)), this, SLOT(on_viewerDrop(const QObject*, const QStringList &))); - connect(m_view, SIGNAL(doubleClicked()), this, SLOT(on_viewerDblClick())); - connect(m_thumb, SIGNAL(itemCountChanged(int)), this, SLOT(on_itemCountChanged(int))); - connect(m_thumb, SIGNAL(itemSelectingChanged()), this, SLOT(on_itemSelectingChanged())); - connect(m_thumb, SIGNAL(currItemChanged(int)), this, SLOT(on_currItemChanged(int))); - connect(m_thumb, SIGNAL(itemDoubleClicked(int)), this, SLOT(on_itemDoubleClicked(int))); - connect(m_thumb, SIGNAL(contextMenuEvent(int)), this, SLOT(on_thumbContextMenu(int))); - connect(m_thumb, SIGNAL(drop(const QObject*, const QStringList &, int)), this, SLOT(on_thumbDrop(const QObject*, const QStringList &, int))); - - connect(m_multiPageLineEdit, SIGNAL(editingFinished()), this, SLOT(on_multiPageLineEditFinished())); - - m_view->enableScroll(true); - m_view->setScrollSize(16); - m_view->setMinScrollSliderSize(20); - - QImage defItemImage(":images/image_rsc/scroll/defItemImage.png"); - m_thumb->setDefItemImage(&defItemImage); - m_thumb->setType(HGImgThumb::ThumbType_Vert); - m_thumb->setItemSize(120); - m_thumb->setScrollSize(16); - m_thumb->setMinScrollSliderSize(20); - m_thumb->setItemTextHeight(0); - - QImage nullScrollImage(":images/image_rsc/scroll/nullScrollImage.png"); - m_view->setNullScrollImage(&nullScrollImage); - m_thumb->setNullScrollImage(&nullScrollImage); - - QImage hScrollImage(":images/image_rsc/scroll/hScrollImage.png"); - m_thumb->setHScrollImage(&hScrollImage, nullptr); - m_view->setHScrollImage(&hScrollImage, nullptr); - QImage vScrollImage(":images/image_rsc/scroll/vScrollImage.png"); - m_thumb->setVScrollImage(&vScrollImage, nullptr); - m_view->setVScrollImage(&vScrollImage, nullptr); - - QImage leftNormalImg(":images/image_rsc/scroll/left_Normal.png"); - QImage leftHotImg(":images/image_rsc/scroll/left_Hot.png"); - QImage leftPushImg(":images/image_rsc/scroll/left_Push.png"); - m_thumb->setHScrollLeftImage(&leftNormalImg, &leftHotImg, &leftPushImg); - m_view->setHScrollLeftImage(&leftNormalImg, &leftHotImg, &leftPushImg); - - QImage rightNormalImg(":images/image_rsc/scroll/right_Normal.png"); - QImage rightHotImg(":images/image_rsc/scroll/right_Hot.png"); - QImage rightPushImg(":images/image_rsc/scroll/right_Push.png"); - m_thumb->setHScrollRightImage(&rightNormalImg, &rightHotImg, &rightPushImg); - m_view->setHScrollRightImage(&rightNormalImg, &rightHotImg, &rightPushImg); - - QImage topNormalImg(":images/image_rsc/scroll/top_Normal.png"); - QImage topHotImg(":images/image_rsc/scroll/top_Hot.png"); - QImage topPushImg(":images/image_rsc/scroll/top_Push.png"); - m_thumb->setVScrollTopImage(&topNormalImg, &topHotImg, &topPushImg); - m_view->setVScrollTopImage(&topNormalImg, &topHotImg, &topPushImg); - - QImage bottomNormalImg(":images/image_rsc/scroll/bottom_Normal.png"); - QImage bottomHotImg(":images/image_rsc/scroll/bottom_Hot.png"); - QImage bottomPushImg(":images/image_rsc/scroll/bottom_Push.png"); - m_thumb->setVScrollBottomImage(&bottomNormalImg, &bottomHotImg, &bottomPushImg); - m_view->setVScrollBottomImage(&bottomNormalImg, &bottomHotImg, &bottomPushImg); - - HGRect hSliderStretchRect = { 4, 0, 196, 16 }; - QImage hScrollSliderNormalImage(":images/image_rsc/scroll/hScrollSlider_Normal.png"); - QImage hScrollSliderHotImage(":images/image_rsc/scroll/hScrollSlider_Hot.png"); - QImage hScrollSliderPushImage(":images/image_rsc/scroll/hScrollSlider_Push.png"); - m_thumb->setHScrollSliderImage(&hScrollSliderNormalImage, &hSliderStretchRect, - &hScrollSliderHotImage, &hSliderStretchRect, &hScrollSliderPushImage, &hSliderStretchRect); - m_view->setHScrollSliderImage(&hScrollSliderNormalImage, &hSliderStretchRect, - &hScrollSliderHotImage, &hSliderStretchRect, &hScrollSliderPushImage, &hSliderStretchRect); - - HGRect vSliderStretchRect = { 0, 4, 16, 196 }; - QImage vScrollSliderNormalImage(":images/image_rsc/scroll/vScrollSlider_Normal.png"); - QImage vScrollSliderHotImage(":images/image_rsc/scroll/vScrollSlider_Hot.png"); - QImage vScrollSliderPushImage(":images/image_rsc/scroll/vScrollSlider_Push.png"); - m_thumb->setVScrollSliderImage(&vScrollSliderNormalImage, &vSliderStretchRect, - &vScrollSliderHotImage, &vSliderStretchRect, &vScrollSliderPushImage, &vSliderStretchRect); - m_view->setVScrollSliderImage(&vScrollSliderNormalImage, &vSliderStretchRect, - &vScrollSliderHotImage, &vSliderStretchRect, &vScrollSliderPushImage, &vSliderStretchRect); - - m_act_thumbGrid = new QAction(tr("Grid"), this); - m_act_thumbGrid->setCheckable(true); - m_act_thumbGrid->setChecked(false); - connect(m_act_thumbGrid, SIGNAL(triggered(bool)), this, SLOT(on_act_thumbGrid_triggered(bool))); - - m_moveToAction = new QAction(tr("Move To..."), this); - connect(m_moveToAction, SIGNAL(triggered()), this, SLOT(on_act_moveTo_triggered())); - - m_thumbMenu = new QMenu(this); - m_menu_imageInsert = new QMenu(tr("Insert files"), m_thumbMenu); - - m_thumbMenu->addAction(ui->act_deleteFile); - m_thumbMenu->addAction(ui->act_closeFile); - m_thumbMenu->addAction(ui->act_closeAll); - m_thumbMenu->addAction(ui->act_Export); - m_thumbMenu->addSeparator(); - m_thumbMenu->addAction(m_moveToAction); - m_thumbMenu->addAction(m_menu_imageInsert->menuAction()); - m_thumbMenu->addSeparator(); - m_thumbMenu->addAction(m_act_thumbGrid); - m_menu_imageInsert->addAction(ui->act_insert); - m_menu_imageInsert->addAction(ui->act_insertFromScanner); - - ui->act_consume->setVisible(false); - - connect(this, SIGNAL(sane_dev_arrive(QString, bool)), this, SLOT(on_sane_dev_arrive(QString, bool)), Qt::QueuedConnection); - connect(this, SIGNAL(sane_dev_remove(QString)), this, SLOT(on_sane_dev_remove(QString)), Qt::QueuedConnection); - connect(this, SIGNAL(pre_new_image(void*)), this, SLOT(on_pre_new_image(void*)), Qt::BlockingQueuedConnection); - connect(this, SIGNAL(post_new_image(unsigned int, int)), this, SLOT(on_post_new_image(unsigned int, int)), Qt::BlockingQueuedConnection); - connect(this, SIGNAL(scan_working(QString)), this, SLOT(on_scan_working(QString)), Qt::QueuedConnection); - connect(this, SIGNAL(scan_finish(QString, int)), this, SLOT(on_scan_finish(QString, int)), Qt::QueuedConnection); - connect(this, SIGNAL(sane_dev_error(QString)), this, SLOT(on_sane_dev_error(QString)), Qt::QueuedConnection); - connect(this, SIGNAL(sane_dev_readyStatus(QString)), this, SLOT(on_sane_dev_readyStatus(QString)), Qt::QueuedConnection); - connect(m_dialogLog, SIGNAL(continueScan()), this, SLOT(on_continueScan())); - connect(m_dialogLog, SIGNAL(stopScan()), this, SLOT(on_stopScan())); - connect(m_dialogLog, SIGNAL(exportScanned()), this, SLOT(on_export_scanned_image())); - connect(m_wndStatusBar, SIGNAL(statusInfoDblClick()), this, SLOT(on_statusInfoDblClick())); - - m_wndStatusBar->setDeviceStatusInfo(tr("nodevice"), false); - m_dialogLog->addLog(tr("nodevice"), false); - HGBase_WriteInfo(HGBASE_INFOTYPE_DESC, "%s", getStdString(tr("nodevice")).c_str()); - connect(ui->menu_device, SIGNAL(scanOptionsChanged(const QString&, const QString&, bool)), this, SLOT(on_scanOptions_changed(const QString&, const QString&, bool))); - - QString password = getCfgValue("login", "password", QString("")); - if (password.isEmpty()) - #if defined(OEM_HANWANG) - m_password = "hanvonscan"; - #elif defined(OEM_LISICHENG) - m_password = "lanxum"; - #elif defined(OEM_CANGTIAN) - m_password = "cumtenn"; - #elif defined(OEM_ZHONGJING) - m_password = "microtek"; - #elif defined(OEM_ZIGUANG) - m_password = "uniscan"; - #elif defined(OEM_NEUTRAL) - m_password = "scan"; - #elif defined(OEM_DELI) - m_password = "deliscan"; - #else - m_password = "huagoscan"; - #endif - else - m_password = passwordDecrypt(password); - - m_dlgFullScreen = nullptr; - m_dialogLog->updateStatus(!dev_que_.opened_scanner_name().empty() && 0 != m_scanType, m_isScanning); - ui->act_autoSave->setChecked(getCfgValue("save", "autoSave", false)); - -#if defined(OEM_LISICHENG) - ui->act_autoSave->setChecked(true); -#endif - - auto_save_changes_ = ui->act_autoSave->isChecked(); - ui->act_autoSave->setText(tr("auto save")); - ui->act_autoSave->setToolTip(tr("when switching pictures, save the edited pictures directly without reminding")); - - auto_save_info_.index = 0; - ui->act_device_log->setEnabled(false); - ui->act_driver_log->setEnabled(false); - - m_pbtn_push = new QPushButton(this); - m_pbtn_push->setVisible(false); - m_pbtn_push->setText("<<"); - m_pbtn_push->setGeometry(0, 0, 25, 50); - m_widget_sideBar = new Widget_Imgproc_SideBar(this); - - connect(m_pbtn_push, SIGNAL(clicked()), this, SLOT(on_m_pbtn_push_clicked())); - connect(m_widget_sideBar, SIGNAL(applyToImage(HGImage,int,int,double,bool)), this, SLOT(on_dialog_sideBar_applyToImage(HGImage,int,int,double,bool))); - connect(m_widget_sideBar, SIGNAL(finish(bool)), this, SLOT(on_dialog_sideBar_finish(bool))); - - updateSideBar(); - updateActionStatus(); - - SANE_Int v = 0; - sane_init_ex(&v, sane_ex_callback, this); -} - -MainWindow::~MainWindow() -{ - if (nullptr != m_dlgFullScreen) - { - delete m_dlgFullScreen; - m_dlgFullScreen = nullptr; - } - - if (nullptr != dev_que_.handle()) - { - dev_que_.close_scanner(); - m_versionDll->PostDeviceCloseInfo(m_currDeviceName.toStdString().c_str(), m_devSerialNum.toStdString().c_str(), "", m_devVersionNum.toStdString().c_str()); - } - - sane_exit(); - - delete m_versionDll; - m_versionDll = nullptr; - - for(auto& v : wrong_imgs_) - { - v->hide(); - delete v; - } - delete ui; -} - -void MainWindow::exitFullScreen() -{ - assert(nullptr != m_dlgFullScreen); - this->show(); - delete m_dlgFullScreen; - m_dlgFullScreen = nullptr; -} - -HGResult MainWindow::saveImage(HGImage image, const HGImgFmtSaveInfo* info, bool ocr, int ocrLanguageType, const HGChar *fileName) -{ - if (!ocr) - { - return HGImgFmt_SaveImage(image, 0, info, fileName); - } - - HGResult ret = HGBASE_ERR_FAIL; - -#if 0 - HGChar tmpFileName[256]; - HGBase_GetTmpFileName("bmp", tmpFileName, 256); - ret = HGImgFmt_SaveImage(image, 0, info, tmpFileName); - bool result = createOcrPdf(tmpFileName, fileName, ocrLanguageType); - QFile::remove(tmpFileName); - return (result) ? HGBASE_ERR_OK : HGIMGPROC_ERR_OCR; -#else - // 韫囩晫鏆恑nfo - HGOCRMgr ocrMgr = nullptr; - ret = HGImgProc_CreateOCRMgr(0, &ocrMgr); - if (HGBASE_ERR_OK == ret) - { - ret = HGImgProc_ImageOCRToFile(ocrMgr, image, 0, fileName); - HGImgProc_DestroyOCRMgr(ocrMgr); - } - - return ret; -#endif -} - -void MainWindow::on_act_90Left_triggered() -{ - if (HGBASE_ERR_OK == m_view->rotateLeft()) - { - m_modify = true; - updateStatusBarPixelInfo(); - updateActionStatus(); - - if (auto_save_changes_) - { - on_act_save_triggered(); - } - } -} - -void MainWindow::on_act_90Right_triggered() -{ - if (HGBASE_ERR_OK == m_view->rotateRight()) - { - m_modify = true; - updateStatusBarPixelInfo(); - updateActionStatus(); - - if (auto_save_changes_) - { - on_act_save_triggered(); - } - } -} - -void MainWindow::on_act_180_triggered() -{ - if (HGBASE_ERR_OK == m_view->rotate180()) - { - m_modify = true; - updateStatusBarPixelInfo(); - updateActionStatus(); - - if (auto_save_changes_) - { - on_act_save_triggered(); - } - } -} - -void MainWindow::on_act_fitWindowSize_triggered() -{ - m_view->fitWndSize(); -} - -void MainWindow::on_act_fitWindowWidth_triggered() -{ - m_view->fitWndWidth(); -} - -void MainWindow::on_act_realSize_triggered() -{ - m_view->realSize(); -} - -void MainWindow::on_act_zoomIn_triggered() -{ - m_view->zoomIn(nullptr); -} - -void MainWindow::on_act_zoomOut_triggered() -{ - m_view->zoomOut(nullptr); -} - -void MainWindow::on_act_statusBar_triggered(bool checked) -{ - ui->statusBar->setVisible(checked); - if(checked) - { - m_wndStatusBar->setDeviceStatusInfo(tr("statusBar displayed"), false); - } - else - { - m_wndStatusBar->setDeviceStatusInfo(tr("statusBar hidden"), false); - } -} - -void MainWindow::on_act_toolBar_triggered(bool checked) -{ - ui->toolBar->setVisible(checked); - if(checked) - { - m_wndStatusBar->setDeviceStatusInfo(tr("toolBar displayed"), false); - } - else - { - m_wndStatusBar->setDeviceStatusInfo(tr("toolBar hidden"), false); - } -} - -void MainWindow::on_act_colorInfo_triggered(bool checked) -{ - m_view->showColorInfo(checked); - if(checked) - { - m_wndStatusBar->setDeviceStatusInfo(tr("colorInfo enabled"), false); - } - else - { - m_wndStatusBar->setDeviceStatusInfo(tr("colorInfo disenabled"), false); - } -} - -void MainWindow::on_act_fullscreen_triggered() -{ - assert(nullptr == m_dlgFullScreen); - - int count = 0; - m_thumb->getItemCount(&count); - if (0 == count || -1 == m_currIndex || -1 == m_multiIndex) - { - return; - } - - QStringList fileNames; - for (int i = 0; i < count; ++i) - { - QString fileName; - m_thumb->getItemFileName(i, fileName); - fileNames.append(fileName); - } - - m_dlgFullScreen = new Dialog_FullScreen(this, fileNames, m_currIndex, m_multiIndex); - m_dlgFullScreen->show(); - this->hide(); -} - -void MainWindow::on_act_autoSave_triggered() -{ - auto_save_changes_ = ui->act_autoSave->isChecked(); - if(auto_save_changes_) - { - m_wndStatusBar->setDeviceStatusInfo(tr("enabling automatic saving"), false); - } - else - { - m_wndStatusBar->setDeviceStatusInfo(tr("cancel auto save"), false); - } - saveCfgValue("save", "autoSave", auto_save_changes_); -} - -void MainWindow::on_AcquireInto2() -{ - if (!dev_que_.is_online() || m_isScanning) - { - return; - } - - int count = 0; - m_thumb->getItemCount(&count); - if (count != 0) - { - int result = startScanMessageBox(this); - if (cancelScan == result) - return; - } - - Dialog_AquireInto dlg(this); - if (1) - { - m_singleScan = false; - m_scanType = 2; - m_aquireIntoSaveParam = dlg.getSaveParam(); - m_aquireIntoInBlank = true; - m_aquireIntoBatchStartIndex = 0; - m_aquireIntoPageIndex = 0; - m_aquireIntoMultiPageCount = 0; - - QDateTime dateTime = QDateTime::currentDateTime(); - if (m_aquireIntoSaveParam.m_isUseSubfolderByTime) - { - m_aquireIntoSaveParam.m_savePath = getStdFileName(m_aquireIntoSaveParam.m_savePath + dateTime.toString("yyyy-MM-dd") + "/"); - } - -// m_aquireIntoSaveParam.m_savePath = getStdFileName(m_aquireIntoSaveParam.m_savePath + dateTime.toString("yyyyMMddhhmmss") + "/"); - - - if(!isLimitAccessFolder(2)) - { - return; - } - - startSaveMessageBox(this); - - m_dpi = getDpi(); - SANE_Status ret = sane_start(dev_que_.handle()); - if (ret != SANE_STATUS_GOOD) - { - m_dialogLog->updateStatus(dev_que_.is_online() && 0 != m_scanType, m_isScanning); - m_wndStatusBar->setDeviceStatusInfo(tr("start failed"), true); - m_dialogLog->addLog(tr("start failed") + "(" + QString(sane_err_desc(ret)) + ")", true); - HGBase_WriteInfo(HGBASE_INFOTYPE_ERROR, "%s", getStdString(tr("start failed")).c_str()); - - if(ret == SCANNER_ERR_DEVICE_SLEEPING) - { - ui->menu_scan->setEnabled(false); - ui->act_acquire->setEnabled(false); - ui->act_scannerSettings->setEnabled(false); - m_dialogLog->updateStatus(false, false); - m_dialogLog->show(); - - if (m_devVersionNum < "G4393B1001" - && ("439" == m_devPid || "9220" == m_devPid || "8529" == m_devPid)) - { - m_dialogLog->addLog(tr("Please wake up the device manually"), true); - m_wndStatusBar->setDeviceStatusInfo(tr("Please wake up the device manually"), true); - } - else - { - QTime curTimer = QTime::currentTime().addMSecs(10000); - while (QTime::currentTime() < curTimer) - { - QCoreApplication::processEvents(QEventLoop::AllEvents, 100); - } - - m_dialogLog->addLog(tr("already waked up device"), false); - m_wndStatusBar->setDeviceStatusInfo(tr("already waked up device"), false); - } - - ui->menu_scan->setEnabled(true); - ui->act_acquire->setEnabled(true); - ui->act_scannerSettings->setEnabled(true); - m_dialogLog->updateStatus(true, false); - } - } - else - { - m_isScanning = true; - m_thumb->setAcceptDrops(false); - m_dialogLog->updateStatus(dev_que_.is_online() && 0 != m_scanType, m_isScanning); - updateActionStatus(); - } - - m_dialogLog->show(); - } -} - -void MainWindow::on_reloadAcquireIntoCfg() -{ - disconnect(m_cbtn_acquireIntoCfg, SIGNAL(currentTextChanged(QString)), this, SLOT(on_m_acquireIntoCfg_changed(QString))); - m_cbtn_acquireIntoCfg->clear(); - m_cbtn_acquireIntoCfg->addItem(tr("default scheme")); - connect(m_cbtn_acquireIntoCfg, SIGNAL(currentTextChanged(QString)), this, SLOT(on_m_acquireIntoCfg_changed(QString))); - QString allCfgName = getCfgValue("aquire", "cfgNameList", QString("")); - QStringList allCfgNameList = allCfgName.split(","); - if (!allCfgNameList.contains(QString(""))) - { - m_cbtn_acquireIntoCfg->addItems(allCfgNameList); - m_cbtn_acquireIntoCfg->setCurrentText(getCfgValue("aquire", "currentKeyName", QString("aquire"))); - } - else - { - allCfgNameList.removeOne(QString("")); - m_cbtn_acquireIntoCfg->setCurrentIndex(0); - } -} - -void MainWindow::on_m_acquireIntoCfg_changed(QString schemeName) -{ - QString selectedCfgName = m_cbtn_acquireIntoCfg->currentText(); - Dialog_AquireInto dlg; - dlg.setConfig(selectedCfgName); -} - -void MainWindow::on_itemCountChanged(int count) -{ - m_wndStatusBar->setPageInfo(count, m_currIndex); - updateActionStatus(); -} - -void MainWindow::on_itemSelectingChanged() -{ - updateActionStatus(); -} - -void MainWindow::on_currItemChanged(int index) -{ - HGImage img = nullptr; - m_view->getImage(&img); - if (nullptr != img && m_modify && -1 != m_currIndex && m_multiPageCount == 1) - { - assert(!m_currFilePath.isEmpty()); - - QString newCurrFilePath; - if (-1 != index) - m_thumb->getItemFileName(index, newCurrFilePath); - - if (m_currFilePath != newCurrFilePath) - { - bool save = false; - if(auto_save_changes_) - { - QString info(tr("Automatically save the edited the edited iamge when switching pictures. To cancel, uncheck the menu item: image-> automatically save")); - m_wndStatusBar->setDeviceStatusInfo(info, false); - save = true; - } - else - { - Dialog_SaveMessageBox dlg(this); - if (dlg.exec()) - { - if (dlg.m_result == dlg.result_Yes) - { - save = true; - } - else if (dlg.m_result == dlg.result_YesToAll) - { - save = true; - auto_save_changes_ = true; - ui->act_autoSave->setChecked(true); - } - else if (dlg.m_result == dlg.result_No) - { - m_modify = false; - } - } - } - - if(save) - { - save_from_changed_ = true; - on_act_save_triggered(); - save_from_changed_ = false; - } - } - } - - if (-1 != index) - { - QString oldCurrFilePath = m_currFilePath; - m_currIndex = index; - m_thumb->getItemFileName(m_currIndex, m_currFilePath); - assert(!m_currFilePath.isEmpty()); - - if (oldCurrFilePath != m_currFilePath) - { - m_multiPageCount = getMultiPageCount(); - m_multiIndex = 0; - - HGImage img2 = createImage(); - if (nullptr != img2) - { - m_view->addImage(img2); - m_widget_sideBar->setImage(img2); - m_widget_sideBar->enableUI(false); - m_bSideEditing = false; - HGBase_DestroyImage(img2); - m_modify = false; - } - else - { - m_view->clearImage(); - m_wndStatusBar->setMousePosInfo(0, 0); - m_modify = false; - - QFileInfo info(m_currFilePath); - if (!info.isFile()) - { - QMessageBox msg(QMessageBox::Question, tr("Question"), - tr("file lost, remove it?"), - QMessageBox::Yes | QMessageBox::No, this); - msg.exec(); - if (msg.clickedButton() == msg.button(QMessageBox::Yes)) - { - m_thumb->removeItem(index, HGImgThumb::ThumbRemoveFlag_NULL); - } - } - } - } - } - else - { - m_currFilePath.clear(); - m_currIndex = -1; - m_multiPageCount = 0; - m_multiIndex = -1; - - m_view->clearImage(); - m_wndStatusBar->setMousePosInfo(0, 0); - m_modify = false; - } - - int count = 0; - m_thumb->getItemCount(&count); - m_wndStatusBar->setPageInfo(count, m_currIndex); - updateStatusBarPixelInfo(); - updateActionStatus(); -} - -void MainWindow::on_itemDoubleClicked(int index) -{ - (void)index; -} - -void MainWindow::on_thumbContextMenu(int index) -{ - qDebug("thumbnail menu index=%d", index); - - m_thumbMenu->show(); - m_thumbMenu->popup(QCursor::pos()); - qDebug("show menu"); -} - -void MainWindow::on_viewerScale(double scale) -{ - m_wndStatusBar->setScale(scale); -} - -void MainWindow::on_viewerMousePos(int x, int y) -{ - m_wndStatusBar->setMousePosInfo(x, y); -} - -void MainWindow::on_thumbDrop(const QObject *source, const QStringList &fileNames, int pos) -{ - if (source != m_thumb) - m_thumb->insertItems(fileNames, pos); - else - m_thumb->moveItems(fileNames, pos); -} - -void MainWindow::on_viewerDrop(const QObject *source, const QStringList &fileNames) -{ - if (source != m_thumb) - m_thumb->addItems(fileNames); -} - -void MainWindow::on_viewerDblClick() -{ - on_act_open_triggered(); -} - -void MainWindow::on_act_moveTo_triggered() -{ - int count = 0; - m_thumb->getItemCount(&count); - - Dialog_MoveTo dlg(count, (-1 != m_currIndex) ? m_currIndex : 0, this); - if (dlg.exec()) - { - QStringList fileNames; - for (int i = 0; i < count; ++i) - { - bool selected = false; - m_thumb->itemIsSelect(i, &selected); - if (selected) - { - QString fileName; - m_thumb->getItemFileName(i, fileName); - fileNames.append(fileName); - } - } - - int index = dlg.getMoveToIndex(); - m_thumb->moveItemsTo(fileNames, index); - } -} - -void MainWindow::on_act_thumbGrid_triggered(bool checked) -{ - if (checked) - { - m_thumb->setType(HGImgThumb::ThumbType_Grid); - resizeDocks({ui->dockWidget}, {300}, Qt::Horizontal); - } - - else - { - m_thumb->setType(HGImgThumb::ThumbType_Vert); - resizeDocks({ui->dockWidget}, {200}, Qt::Horizontal); - } - -} - -void MainWindow::on_dialog_adjust_applyToImage(HGImage img) -{ - m_view->addImage(img); - updateStatusBarPixelInfo(); -} - -void MainWindow::on_dialog_multirotate_refreshImgFile(const QString &fileName) -{ - m_thumb->refreshItem(fileName); -} - -void MainWindow::on_multiPageLineEditFinished() -{ - if (-1 != m_currIndex && m_multiPageCount > 0) - { - int multiIndex = m_multiPageLineEdit->text().toInt() - 1; - if (multiIndex >= 0 && multiIndex < m_multiPageCount) - { - m_multiIndex = multiIndex; - - HGImage img = createImage(); - if (nullptr != img) - { - m_view->addImage(img); - m_widget_sideBar->setImage(img); - m_widget_sideBar->enableUI(false); - m_bSideEditing = false; - HGBase_DestroyImage(img); - m_modify = false; - } - else - { - m_view->clearImage(); - m_wndStatusBar->setMousePosInfo(0, 0); - m_modify = false; - } - - updateStatusBarPixelInfo(); - } - - updateActionStatus(); - } -} - -void MainWindow::on_clearCache() -{ - std::vector removeItems; - - int count = 0; - m_thumb->getItemCount(&count); - for (int i = 0; i < count; ++i) - { - QString fileName; - m_thumb->getItemFileName(i, fileName); - if (0 == fileName.indexOf(Dialog_ClrCache::getCachePath())) - { - removeItems.push_back(i); - } - } - - m_thumb->removeItems(removeItems, HGImgThumb::ThumbRemoveFlag_NULL); -} - -void MainWindow::on_sane_dev_arrive(QString devName, bool opened) -{ - bool reconnected = false; - std::vector now; - std::string stdn(devName.toStdString()); - - dev_que_.get_scanners(now); - if(std::find(now.begin(), now.end(), stdn) == now.end()) - { - // initializing the device configuration ... - dev_que_.add_scanner(stdn.c_str()); - - // statu info ... - QString info = tr("found device : %1").arg(devName); - m_wndStatusBar->setDeviceStatusInfo(info, false); - m_dialogLog->addLog(info, false); - HGBase_WriteInfo(HGBASE_INFOTYPE_DESC, "%s", getStdString(info).c_str()); - } - else - { - // re-connected statu ... - QString info(devName); - if(!opened && devName.toStdString() != dev_que_.opened_scanner_name()) - opened = true; - if(opened) - info += tr(" reconnected"); - else - info += tr("already connected, but open faild"); - m_wndStatusBar->setDeviceStatusInfo(info, !opened); - m_dialogLog->addLog(info, !opened); - HGBase_WriteInfo(!opened ? HGBASE_INFOTYPE_ERROR : HGBASE_INFOTYPE_DESC, "%s", getStdString(info).c_str()); - reconnected = true; - dev_que_.set_online(true, stdn.c_str()); - } - - // enable the device menu item ... - ui->menu_device->connectedDevice(devName); - - // open it if no device has been opened ... - if (dev_que_.opened_scanner_name().empty()) - { - //dev_que_.open_scanner(stdn.c_str()); - open_scanner(devName, ""); - } - - ui->menu_device->deviceMenuUpdate(&dev_que_); - - m_dialogLog->updateStatus(!dev_que_.opened_scanner_name().empty() && 0 != m_scanType, m_isScanning); - updateActionStatus(); -} - -void MainWindow::on_sane_dev_remove(QString devName) -{ - // statu info ... - QString info(devName + tr(" disconnected")); - - m_wndStatusBar->setDeviceStatusInfo(info, true); - m_dialogLog->addLog(info, true); - HGBase_WriteInfo(HGBASE_INFOTYPE_ERROR, "%s", getStdString(info).c_str()); - - // enable the device menu item ... - ui->menu_device->disconnectedDevice(devName); - - // set openning device offline ... - dev_que_.set_online(false, devName.toStdString().c_str()); - - m_dialogLog->updateStatus(dev_que_.is_online() && 0 != m_scanType, m_isScanning); - updateActionStatus(); -} - -void MainWindow::on_sane_dev_error(QString errorInfo) -{ - //Error codes operate in slot function: on_scan_finish(QString finishInfo, int err). - - m_wndStatusBar->setDeviceStatusInfo(errorInfo, true); - m_dialogLog->addLog(errorInfo, true); - HGBase_WriteInfo(HGBASE_INFOTYPE_ERROR, "%s", getStdString(errorInfo).c_str()); -} - -void MainWindow::on_sane_dev_readyStatus(QString promptInfo) -{ - if (STATU_DESC_SCANNER_ERR_DEVICE_DEVS_BOOTING == promptInfo) - { - m_wndStatusBar->setDeviceStatusInfo(promptInfo, true); - m_dialogLog->addLog(promptInfo, true); - //Enable ui... - } - else if (STATU_DESC_SCANNER_ERR_DEVICE_DEVS_START_SUCCES == promptInfo) - { - m_devSerialNum = getDevSerialNum(); - m_devVersionNum = getDevFwVersionNum(); - m_devPid = getDevPid(); - - if (!m_currDeviceName.isEmpty()) - m_versionDll->PostDeviceOpenInfo(m_currDeviceName.toStdString().c_str(), m_devSerialNum.toStdString().c_str(), "", m_devVersionNum.toStdString().c_str()); - - m_wndStatusBar->setDeviceStatusInfo(promptInfo, true); - m_dialogLog->addLog(promptInfo, true); - } -} - -void MainWindow::on_pre_new_image(void *img) -{ - m_saveType = 0; - - HGImage image = (HGImage)img; - HGBase_SetImageDpi(image, m_dpi, m_dpi); - - if (1 == m_scanType) - { - if (m_cacheDirNotify) - { - return; - } - else - { - if (!judgeDiskSpace(Dialog_ClrCache::getCachePath(), false)) - { - m_cacheDirNotify = true; - on_stopScan(); - - QString info = tr("the disk space in the current path is unsufficient, please select a new path or clear the disk space in time."); - m_wndStatusBar->setDeviceStatusInfo(info, true); - m_dialogLog->addLog(info, true); - HGBase_WriteInfo(HGBASE_INFOTYPE_ERROR, "disk space is unsufficient!"); - QMessageBox::warning(this, tr("warning"), info); - return; - } - } - - m_scanFileName = getCacheFileName(image); - m_saveType = 1; - return; - } - else if (2 == m_scanType) - { - if (m_AquirePathNotify) - { - return; - } - else - { - if (!judgeDiskSpace(m_aquireIntoSaveParam.m_savePath, false)) - { - m_AquirePathNotify = true; - on_stopScan(); - - QString info = tr("the disk space in the current path is unsufficient, please select a new path or clear the disk space in time."); - m_wndStatusBar->setDeviceStatusInfo(info, true); - m_dialogLog->addLog(info, true); - HGBase_WriteInfo(HGBASE_INFOTYPE_ERROR, "disk space is unsufficient!"); - QMessageBox::warning(this, tr("warning"), info); - return; - } - } - - ++m_aquireIntoPageIndex; - if ((1 == m_aquireIntoSaveParam.m_fileNameOddEventType && 1 != m_aquireIntoPageIndex % 2) - || (2 == m_aquireIntoSaveParam.m_fileNameOddEventType && 0 != m_aquireIntoPageIndex % 2)) - { - return; - } - - if (m_aquireIntoSaveParam.m_isSaveAsMultiPage) - { - if (1 == m_aquireIntoSaveParam.m_multiPagesType && m_aquireIntoMultiPageCount == m_aquireIntoSaveParam.m_customMultiPages) - { - if (nullptr != m_scanImgFmtWriter) - { - HGImgFmt_CloseImageWriter(m_scanImgFmtWriter); - m_scanImgFmtWriter = nullptr; - m_thumb->addItem(m_scanFileName); - m_scanFileName.clear(); - ++m_aquireIntoSaveParam.m_fileNameStartIndex; - m_aquireIntoMultiPageCount = 0; - } - } - - if (nullptr == m_scanImgFmtWriter) - { - assert(m_scanFileName.isEmpty()); - HGResult ret = HGBase_CreateDir(getStdString(m_aquireIntoSaveParam.m_savePath).c_str()); - if (ret != HGBASE_ERR_OK) - { - m_dialogLog->addLog(tr("create savepath failed: ") + getLogInfo(ret), true); - m_wndStatusBar->setDeviceStatusInfo(tr("create savepath failed: ") + getLogInfo(ret), true); - } - - QString scanFileName; - while (1) - { - scanFileName = m_aquireIntoSaveParam.m_savePath + m_aquireIntoSaveParam.m_fileNamePrefix + QString("%1.%2") - .arg(m_aquireIntoSaveParam.m_fileNameStartIndex, m_aquireIntoSaveParam.m_fileNameDigits, 10, QLatin1Char('0')) - .arg(m_aquireIntoSaveParam.m_fileNameExt); - QFileInfo fileInfo(scanFileName); - if (fileInfo.isFile()) - { - ++m_aquireIntoSaveParam.m_fileNameStartIndex; - } - else - { - break; - } - } - - ret = HGImgFmt_OpenImageWriter(getStdString(getStdFileName(scanFileName)).c_str(), 0, &m_scanImgFmtWriter); - if(ret != HGBASE_ERR_OK) - { - m_dialogLog->addLog(tr("create image doc failed: ") + getLogInfo(ret), true); - m_wndStatusBar->setDeviceStatusInfo(tr("create image doc failed: ") + getLogInfo(ret), true); - } - - if (nullptr != m_scanImgFmtWriter) - m_scanFileName = scanFileName; - } - - if (nullptr != m_scanImgFmtWriter) - { - m_saveType = 2; - } - } - else - { - assert(nullptr == m_scanImgFmtWriter); - - QString savePath = m_aquireIntoSaveParam.m_savePath; - if (m_aquireIntoSaveParam.m_isUseSubfolderByBlankPages) - { - HGBool isBlank = HGFALSE; - HGImgProc_ImageBlankCheck(image, nullptr, &isBlank); - if (isBlank) - { - m_aquireIntoInBlank = true; - } - else - { - if (m_aquireIntoInBlank) - { - ++m_aquireIntoBatchStartIndex; - } - - m_aquireIntoInBlank = false; - } - - char batchDir[20]; - sprintf(batchDir, "batch%d", m_aquireIntoBatchStartIndex); - savePath = getStdFileName(savePath + batchDir + "/"); - } - - if (m_aquireIntoSaveParam.m_isUseSubfolderByColor) - { - QString colorModeName; - HGImageInfo imgInfo; - HGBase_GetImageInfo(image, &imgInfo); - if (HGBASE_IMGTYPE_BINARY == imgInfo.type) - colorModeName = tr("binary"); - else if (HGBASE_IMGTYPE_GRAY == imgInfo.type) - colorModeName = tr("gray"); - else - colorModeName = tr("rgb"); - - savePath = getStdFileName(savePath + colorModeName + "/"); - } - - HGResult ret = HGBase_CreateDir(getStdString(savePath).c_str()); - if(ret != HGBASE_ERR_OK) - { - m_dialogLog->addLog(tr("create savepath failed: ") + getLogInfo(ret), true); - m_wndStatusBar->setDeviceStatusInfo(tr("create savepath failed: ") + getLogInfo(ret), true); - } - - while (1) - { - m_scanFileName = savePath + m_aquireIntoSaveParam.m_fileNamePrefix + QString("%1.%2") - .arg(m_aquireIntoSaveParam.m_fileNameStartIndex, m_aquireIntoSaveParam.m_fileNameDigits, 10, QLatin1Char('0')) - .arg(m_aquireIntoSaveParam.m_fileNameExt); - QFileInfo fileInfo(m_scanFileName); - if (fileInfo.isFile()) - { - ++m_aquireIntoSaveParam.m_fileNameStartIndex; - } - else - { - break; - } - } - - m_saveType = 3; - } - } -} - -void MainWindow::on_post_new_image(unsigned int ret, int statu) -{ - if (1 == m_scanType && 1 == m_saveType) - { - if (ret == HGBASE_ERR_OK) - { - if(statu != SANE_Image_Statu_OK) - { - int ind = 0; - if(m_scanInsertPos == -1) - m_thumb->getItemCount(&ind); - else - ind = m_scanInsertPos; - - dialog_wrong_img *wi = new dialog_wrong_img(this, m_scanFileName, ind, statu); - connect(wi, SIGNAL(handle_wrong_img(dialog_wrong_img*, bool)), this, SLOT(on_wrong_image_decide(dialog_wrong_img*, bool))); - wrong_imgs_.push_back(wi); - wi->show(); - } - else if (-1 == m_scanInsertPos) - { - m_thumb->addItem(m_scanFileName); - } - else - { - m_thumb->insertItem(m_scanFileName, m_scanInsertPos); - ++m_scanInsertPos; - } - } - else - { - m_dialogLog->addLog(tr("save image failed: ") + getLogInfo(ret), true); - m_wndStatusBar->setDeviceStatusInfo(tr("save image failed: ") + getLogInfo(ret), true); - } - } - else if (2 == m_scanType) - { - if (m_aquireIntoSaveParam.m_isSaveAsMultiPage && 2 == m_saveType) - { - if (ret != HGBASE_ERR_OK) - { - m_dialogLog->addLog(tr("save image doc failed: ") + getLogInfo(ret), true); - m_wndStatusBar->setDeviceStatusInfo(tr("save image doc failed: ") + getLogInfo(ret), true); - } - - ++m_aquireIntoMultiPageCount; - } - else if (3 == m_saveType) - { - if (ret == HGBASE_ERR_OK) - { - m_thumb->addItem(m_scanFileName); - ++m_aquireIntoSaveParam.m_fileNameStartIndex; - } - else - { - m_dialogLog->addLog(tr("save image doc failed: ") + getLogInfo(ret), true); - m_wndStatusBar->setDeviceStatusInfo(tr("save image doc failed: ") + getLogInfo(ret), true); - } - } - } - - m_currScanCount++; - if(statu == SANE_Image_Statu_OK) - m_dialogLog->image_received_from_scanner(); -} - -void MainWindow::on_scan_working(QString workingInfo) -{ - m_wndStatusBar->setDeviceStatusInfo(workingInfo, false); - m_dialogLog->addLog(workingInfo, false, LOG_EVENT_SCAN_BEGINNING); - HGBase_WriteInfo(HGBASE_INFOTYPE_DESC, "%s", getStdString(workingInfo).c_str()); -} - -void MainWindow::on_scan_finish(QString finishInfo, int err) -{ - if (0 == m_scanType) - { - if (nullptr != m_scanImgFmtWriter) - { - HGImgFmt_CloseImageWriter(m_scanImgFmtWriter); - m_scanImgFmtWriter = nullptr; - m_thumb->addItem(m_scanFileName); - m_scanFileName.clear(); - ++m_aquireIntoSaveParam.m_fileNameStartIndex; - } - } - - if(err == SCANNER_ERR_DEVICE_PAPER_JAMMED) - { - m_versionDll->PostDevicePaperJamInfo(m_currDeviceName.toStdString().c_str(), - m_devSerialNum.toStdString().c_str(), "", m_devVersionNum.toStdString().c_str()); - } - - m_versionDll->PostDeviceScanCountInfo(m_currDeviceName.toStdString().c_str(), m_devSerialNum.toStdString().c_str(), "", m_devVersionNum.toStdString().c_str(), m_currScanCount); - m_currScanCount = 0; - m_isScanning = false; - m_thumb->setAcceptDrops(true); - m_dialogLog->updateStatus(dev_que_.is_online() && 0 != m_scanType, m_isScanning); - updateActionStatus(); - m_wndStatusBar->setDeviceStatusInfo(finishInfo, (err != SANE_STATUS_GOOD)); - m_dialogLog->addLog(finishInfo, (err != SANE_STATUS_GOOD), LOG_EVENT_SCAN_STOPPED); - HGBase_WriteInfo((err != SANE_STATUS_GOOD) ? HGBASE_INFOTYPE_ERROR : HGBASE_INFOTYPE_DESC, - "%s", getStdString(finishInfo).c_str()); - - m_cacheDirNotify = false; - m_AquirePathNotify = false; -} - -void MainWindow::on_export_scanned_image(void) -{ - m_dialogLog->hide(); - on_act_Export_triggered(); -} - -void MainWindow::on_continueScan() -{ - if (1 == m_scanType) - { - if(!isLimitAccessFolder(1)) - { - return; - } - } - else if (2 == m_scanType) - { - if(!isLimitAccessFolder(2)) - { - return; - } - } - - if (!dev_que_.is_online() || m_isScanning || 0 == m_scanType) - { - return; - } - - startSaveMessageBox(m_dialogLog); - - SANE_Status ret; - - m_dpi = getDpi(); - if (m_singleScan) - ret = sane_io_control(dev_que_.handle(), IO_CTRL_CODE_TEST_SINGLE, nullptr, nullptr); - else - ret = sane_start(dev_que_.handle()); - if (ret != SANE_STATUS_GOOD) - { - m_wndStatusBar->setDeviceStatusInfo(tr("start failed"), true); - m_dialogLog->addLog(tr("start failed") + "(" + QString(sane_err_desc(ret)) + ")", true); - HGBase_WriteInfo(HGBASE_INFOTYPE_ERROR, "%s", getStdString(tr("start failed")).c_str()); - - if(ret == SCANNER_ERR_DEVICE_SLEEPING) - { - ui->menu_scan->setEnabled(false); - ui->act_acquire->setEnabled(false); - ui->act_scannerSettings->setEnabled(false); - m_dialogLog->updateStatus(false, false); - m_dialogLog->show(); - - if (m_devVersionNum < "G4393B1001" - && ("439" == m_devPid || "9220" == m_devPid || "8529" == m_devPid)) - { - m_dialogLog->addLog(tr("Please wake up the device manually"), true); - m_wndStatusBar->setDeviceStatusInfo(tr("Please wake up the device manually"), true); - } - else - { - QTime curTimer = QTime::currentTime().addMSecs(10000); - while (QTime::currentTime() < curTimer) - { - QCoreApplication::processEvents(QEventLoop::AllEvents, 100); - } - - m_dialogLog->addLog(tr("already waked up device"), false); - m_wndStatusBar->setDeviceStatusInfo(tr("already waked up device"), false); - } - - ui->menu_scan->setEnabled(true); - ui->act_acquire->setEnabled(true); - ui->act_scannerSettings->setEnabled(true); - m_dialogLog->updateStatus(true, false); - } - } - else - { - m_isScanning = true; - m_thumb->setAcceptDrops(false); - m_dialogLog->updateStatus(dev_que_.is_online() && 0 != m_scanType, m_isScanning); - updateActionStatus(); - } - - m_dialogLog->show(); -} - -void MainWindow::on_stopScan() -{ - m_dialogLog->updateStatus(dev_que_.is_online(), m_isScanning); - - if (!m_isScanning) - { - if (nullptr != m_scanImgFmtWriter) - { - HGImgFmt_CloseImageWriter(m_scanImgFmtWriter); - m_scanImgFmtWriter = nullptr; - m_thumb->addItem(m_scanFileName); - m_scanFileName.clear(); - ++m_aquireIntoSaveParam.m_fileNameStartIndex; - } - } - else - { - if (dev_que_.is_online()) - { - sane_cancel(dev_que_.handle()); - } - } -} - -void MainWindow::on_statusInfoDblClick() -{ - m_dialogLog->show(); -} -void MainWindow::on_wrong_image_decide(dialog_wrong_img* dlg, bool save) -{ - int i = 0; - - for(; i < wrong_imgs_.size(); ++i) - { - if(wrong_imgs_[i] == dlg) - { - wrong_imgs_.erase(wrong_imgs_.begin() + i); - break; - } - } - - if(save) - { - // save the image ... - for(; i < wrong_imgs_.size(); ++i) - wrong_imgs_[i]->increase_index(); - - m_thumb->insertItem(dlg->image_file(), dlg->index()); - if (-1 != m_scanInsertPos) - { - ++m_scanInsertPos; - } - m_dialogLog->image_received_from_scanner(); - } - else { - remove(dlg->image_file().toStdString().c_str()); - } - - delete dlg; -} - -void MainWindow::on_m_pbtn_push_clicked() -{ - int mainWndWidth = this->rect().width(); - int mainWndHeight = this->rect().height(); - int sideBarWidth = m_widget_sideBar->width(); - int sideBarHeight = m_widget_sideBar->height(); - - if(!m_bSideflag) - { - m_propertyAnimation->setStartValue(QRect(mainWndWidth, mainWndHeight/2 - sideBarHeight/2, sideBarWidth, sideBarHeight)); - m_propertyAnimation->setEndValue(QRect(mainWndWidth - sideBarWidth, mainWndHeight/2 - sideBarHeight/2, sideBarWidth, sideBarHeight)); - m_propertyAnimation->start(); - m_propertyAnimation2->setStartValue(QRect(mainWndWidth - m_pbtn_push->width(), mainWndHeight/2 - m_pbtn_push->height()/2, m_pbtn_push->width(), m_pbtn_push->height())); - m_propertyAnimation2->setEndValue(QRect(mainWndWidth - m_pbtn_push->width() - sideBarWidth, mainWndHeight/2 - m_pbtn_push->height()/2, m_pbtn_push->width(), m_pbtn_push->height())); - m_propertyAnimation2->start(); - m_pbtn_push->setText(">>"); - m_bSideflag = !m_bSideflag; - } - else - { - m_propertyAnimation->setStartValue(QRect(mainWndWidth - sideBarWidth, mainWndHeight/2 - sideBarHeight/2,sideBarWidth, sideBarHeight)); - m_propertyAnimation->setEndValue(QRect(mainWndWidth, mainWndHeight/2 - sideBarHeight/2, sideBarWidth, sideBarHeight)); - m_propertyAnimation->start(); - m_propertyAnimation2->setStartValue(QRect(mainWndWidth - m_pbtn_push->width() - sideBarWidth, mainWndHeight/2 - m_pbtn_push->height()/2, m_pbtn_push->width(), m_pbtn_push->height())); - m_propertyAnimation2->setEndValue(QRect(mainWndWidth - m_pbtn_push->width(), mainWndHeight/2 - m_pbtn_push->height()/2, m_pbtn_push->width(), m_pbtn_push->height())); - m_propertyAnimation2->start(); - m_pbtn_push->setText("<<"); - m_bSideflag = !m_bSideflag; - } - - updateActionStatus(); -} - -void MainWindow::on_dialog_sideBar_applyToImage(HGImage img, int brightness, int contrast, double gamma, bool enhanceText) -{ - assert(nullptr != img); - - HGImage destImg = nullptr; - HGBase_CloneImage(img, 0, 0, &destImg); - if (nullptr != destImg) - { - HGImgProc_ImageAdjustColors(destImg, destImg, brightness, contrast, (HGFloat)gamma); - if (enhanceText) - HGImgProc_ImageBinarization(destImg, destImg, HGIMGPROC_THRESHTYPE_ADAPTIVE_MEAN, 120, 51, 41); - - m_view->addImage(destImg); - m_widget_sideBar->enableUI(m_multiPageCount == 1); - m_bSideEditing = true; - HGBase_DestroyImage(destImg); - updateActionStatus(); - updateStatusBarPixelInfo(); - } -} - -void MainWindow::on_dialog_sideBar_finish(bool ok) -{ - m_modify = ok; - m_bSideEditing = false; - updateActionStatus(); - emit m_pbtn_push->clicked(); -} - -void MainWindow::on_act_thumbnailBar_triggered(bool checked) -{ - ui->dockWidget->setVisible(checked); - if(checked) - { - m_wndStatusBar->setDeviceStatusInfo(tr("thumbnailBar enabled"), false); - } - else - { - m_wndStatusBar->setDeviceStatusInfo(tr("thumbnailBar hidden"), false); - } -} - -void MainWindow::on_act_previous_triggered() -{ - int count = 0; - m_thumb->getItemCount(&count); - if (count > 0 && (-1 == m_currIndex || m_currIndex > 0)) - { - if (-1 == m_currIndex) - m_thumb->setCurrItem(0); - else - m_thumb->setCurrItem(m_currIndex - 1); - } -} - -void MainWindow::on_act_next_triggered() -{ - int count = 0; - m_thumb->getItemCount(&count); - if (count > 0 && (-1 == m_currIndex || m_currIndex < count - 1)) - { - if (-1 == m_currIndex) - m_thumb->setCurrItem(0); - else - m_thumb->setCurrItem(m_currIndex + 1); - } -} - -void MainWindow::on_act_first_triggered() -{ - int count = 0; - m_thumb->getItemCount(&count); - if (count > 0 && 0 != m_currIndex) - { - m_thumb->setCurrItem(0); - } -} - -void MainWindow::on_act_last_triggered() -{ - int count = 0; - m_thumb->getItemCount(&count); - if (count > 0 && count - 1 != m_currIndex) - { - m_thumb->setCurrItem(count - 1); - } -} - -HGUInt MainWindow::getDpi() -{ - HGUInt dpi = 200; - SANE_Int num_dev_options = 0; - sane_control_option(dev_que_.handle(), 0, SANE_ACTION_GET_VALUE, &num_dev_options, nullptr); - for (int i = 1; i < num_dev_options; ++i) - { - const SANE_Option_Descriptor* desp = sane_get_option_descriptor(dev_que_.handle(), i); - if (nullptr == desp) - continue; - - if (SANE_TYPE_INT == desp->type) - { - SANE_Int value = 0; - sane_control_option(dev_que_.handle(), i, SANE_ACTION_GET_VALUE, &value, nullptr); - if (0 == strcmp(desp->name, SANE_STD_OPT_NAME_RESOLUTION)) - { - dpi = (HGUInt)value; - } - } - } - - return dpi; -} - -QString MainWindow::getCacheFileName(HGImage img) -{ - assert(nullptr != img); - - HGImageInfo imgInfo; - HGBase_GetImageInfo(img, &imgInfo); - - QString cachePath = Dialog_ClrCache::getCachePath(); - HGBase_CreateDir(getStdString(cachePath).c_str()); - - char uuid[256] = {0}; - HGBase_GetUuid(uuid, 256); - QString suffix = (HGBASE_IMGTYPE_BINARY == imgInfo.type) ? ".bmp" : ".jpg"; - QString fileName = getStdFileName(cachePath + uuid + suffix); - return fileName; -} - -HGImage MainWindow::createImage() -{ - qDebug("createImage"); - - assert(-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); - } - - return img; -} - -int MainWindow::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); - } - - qDebug("pageCount=%d", count); - return count; -} - -void MainWindow::updateStatusBarPixelInfo() -{ - HGImage img = nullptr; - m_view->getImage(&img); - if (nullptr == img) - { - m_wndStatusBar->setPixelInfo(0, 0, 0); - } - else - { - HGImageInfo imgInfo; - HGBase_GetImageInfo(img, &imgInfo); - int bpp = 0; - if (HGBASE_IMGTYPE_BINARY == imgInfo.type) - bpp = 1; - else if (HGBASE_IMGTYPE_GRAY == imgInfo.type) - bpp = 8; - else if (HGBASE_IMGTYPE_BGR == imgInfo.type || HGBASE_IMGTYPE_RGB == imgInfo.type) - bpp = 24; - else - bpp = 32; - m_wndStatusBar->setPixelInfo((int)imgInfo.width, (int)imgInfo.height, bpp); - } -} - -void MainWindow::updateActionStatus() -{ - HGImage img = nullptr; - m_view->getImage(&img); - int count = 0; - m_thumb->getItemCount(&count); - std::vector selectIndexs; - for (int i = 0; i < count; ++i) - { - bool select = false; - m_thumb->itemIsSelect(i, &select); - if (select) - selectIndexs.push_back(i); - } - - ui->act_open->setEnabled(!dev_que_.is_online() || !m_isScanning); - ui->act_insert->setEnabled(!dev_que_.is_online() || !m_isScanning); - ui->act_save->setEnabled(nullptr != img && -1 != m_currIndex && m_multiPageCount == 1 - && (!dev_que_.is_online() || !m_isScanning)); - ui->act_saveAs->setEnabled(nullptr != img); - ui->act_Export->setEnabled(0 != count && (!dev_que_.is_online() || !m_isScanning)); - ui->act_deleteFile->setEnabled(!selectIndexs.empty() && (!dev_que_.is_online() || !m_isScanning)); - ui->act_closeFile->setEnabled(!selectIndexs.empty() && (!dev_que_.is_online() || !m_isScanning)); - ui->act_closeAll->setEnabled(0 != count && (!dev_que_.is_online() || !m_isScanning)); - ui->act_imageInfo->setEnabled(-1 != m_currIndex && (!dev_que_.is_online() || !m_isScanning)); - ui->menu_multiPages->setEnabled(m_multiPageCount > 1 && (!dev_que_.is_online() || !m_isScanning)); - ui->act_previous->setEnabled(count > 0 && (-1 == m_currIndex || m_currIndex > 0) - && (!dev_que_.is_online() || !m_isScanning)); - ui->act_next->setEnabled(count > 0 && (-1 == m_currIndex || m_currIndex < count - 1) - && (!dev_que_.is_online() || !m_isScanning)); - ui->act_first->setEnabled(count > 0 && 0 != m_currIndex && (!dev_que_.is_online() || !m_isScanning)); - ui->act_last->setEnabled(count > 0 && count - 1 != m_currIndex && (!dev_que_.is_online() || !m_isScanning)); - ui->act_openPageNum->setEnabled(count > 0 && (!dev_que_.is_online() || !m_isScanning)); - ui->act_previousPage->setEnabled(-1 != m_currIndex && m_multiPageCount > 0 && m_multiIndex > 0 - && (!dev_que_.is_online() || !m_isScanning)); - ui->act_nextPage->setEnabled(-1 != m_currIndex && m_multiPageCount > 0 && -1 != m_multiIndex && m_multiIndex < m_multiPageCount - 1 - && (!dev_que_.is_online() || !m_isScanning)); - ui->act_firstPage->setEnabled(-1 != m_currIndex && m_multiPageCount > 0 && 0 != m_multiIndex - && (!dev_que_.is_online() || !m_isScanning)); - ui->act_lastPage->setEnabled(-1 != m_currIndex && m_multiPageCount > 0 && m_multiIndex != m_multiPageCount - 1 - && (!dev_que_.is_online() || !m_isScanning)); - m_multiPageLineEdit->setText(QString("%1/%2").arg(m_multiIndex + 1).arg(m_multiPageCount)); - ui->toolBar->actions().at(18)->setVisible(-1 != m_currIndex && m_multiPageCount > 1 && -1 != m_multiIndex - && (!dev_que_.is_online() || !m_isScanning)); - ui->act_sortPages->setEnabled(0 != count && (!dev_que_.is_online() || !m_isScanning)); - - ui->act_imageEdit->setEnabled(nullptr != img); - ui->act_zoomIn->setEnabled(nullptr != img); - ui->act_zoomOut->setEnabled(nullptr != img); - ui->act_fullscreen->setEnabled(count > 0 && -1 != m_currIndex && -1 != m_multiIndex - && (!dev_que_.is_online() || !m_isScanning)); - ui->act_fitWindowSize->setEnabled(nullptr != img); - ui->act_fitWindowWidth->setEnabled(nullptr != img); - ui->act_realSize->setEnabled(nullptr != img); - ui->act_90Left->setEnabled(nullptr != img); - ui->act_90Right->setEnabled(nullptr != img); - ui->act_180->setEnabled(nullptr != img); - ui->menu_Auto_Image_Size->setEnabled(nullptr != img); - ui->act_multiRotate->setEnabled(0 != count && (!dev_que_.is_online() || !m_isScanning)); - ui->menu_Rotate->setEnabled((0 != count || nullptr != img) && (!dev_que_.is_online() || !m_isScanning)); - ui->act_autoCrop->setEnabled(nullptr != img); - - ui->act_signIn->setEnabled(!m_admin_loggedIn); - ui->act_passwordChange->setEnabled(m_admin_loggedIn); - ui->act_signOut->setEnabled(m_admin_loggedIn); - ui->act_log->setEnabled(m_admin_loggedIn); - ui->act_clrCache->setEnabled(m_admin_loggedIn); - ui->act_consume->setEnabled(m_admin_loggedIn); - ui->act_clearRoller->setEnabled(m_admin_loggedIn); - - ui->act_acquireInto->setEnabled(dev_que_.is_online() && !m_isScanning); - m_act_acquireInto2->setEnabled(dev_que_.is_online() && !m_isScanning); - ui->act_acquireSingle->setEnabled(dev_que_.is_online() && !m_isScanning); - ui->act_acquire->setEnabled(dev_que_.is_online() && !m_isScanning); - ui->act_scannerSettings->setEnabled(dev_que_.is_online() && !m_isScanning); - ui->act_insertFromScanner->setEnabled(dev_que_.is_online() && !m_isScanning); - ui->menu_scan->setEnabled(dev_que_.is_online() && !m_isScanning); - ui->menu_device->setEnabled(!dev_que_.is_online() || !m_isScanning); - ui->act_device_log->setEnabled(m_admin_loggedIn && !m_isScanning && dev_que_.is_online()); - ui->act_driver_log->setEnabled(m_admin_loggedIn); - if(m_dialogLog != nullptr) - m_dialogLog->pbtn_export->setEnabled(ui->act_Export->isEnabled()); - - m_moveToAction->setEnabled(!selectIndexs.empty() && (!dev_que_.is_online() || !m_isScanning)); - - if (m_pbtn_push != nullptr && m_widget_sideBar!= nullptr) - { - m_pbtn_push->setVisible(nullptr != img); - m_widget_sideBar->setVisible(nullptr != img); - } - m_cbtn_acquireIntoCfg->setEnabled(dev_que_.is_online() && !m_isScanning); - - ui->act_adjust->setEnabled(!m_bSideEditing && nullptr != img); -} - -void MainWindow::startSaveMessageBox(QWidget* parent) -{ - HGImage img = nullptr; - m_view->getImage(&img); - if (nullptr != img && m_modify && -1 != m_currIndex && m_multiPageCount == 1) - { - QMessageBox msg(QMessageBox::Question, tr("Question"), - tr("modified, save it?"), - QMessageBox::Yes | QMessageBox::No, parent); - msg.exec(); - if (msg.clickedButton() != msg.button(QMessageBox::Yes)) - { - m_modify = false; - updateActionStatus(); - } - else - { - on_act_save_triggered(); - } - } -} - -askIfClear MainWindow::startScanMessageBox(QWidget *parent) -{ - QMessageBox box(parent); - QPushButton* clearBtn = box.addButton(tr("Clear, then start scan"), QMessageBox::ActionRole); - box.addButton(tr("Do NOT clear, then start scan"), QMessageBox::ActionRole); - QPushButton* cancelBtn = box.addButton(QMessageBox::Cancel); - cancelBtn->setText(tr("cancel")); - box.setWindowTitle(tr("Question")); - box.setText(tr("Already exist images in image list.\nDo you want to clear?")); - box.exec(); - if (box.clickedButton() == cancelBtn) - return cancelScan; - else if (box.clickedButton() == clearBtn) - { - on_act_closeAll_triggered(); - return clearAndScan; - } - return notClearAndScan; -} - -QString MainWindow::passwordEncrypt(const QString& password) -{ - QString p = password; - int num = PASSWORD_KEY - p.length() % PASSWORD_KEY; - for (int i = 0; i < num; i++) - p.append("+"); - int rows = p.length() / 4; - QString transcode; - for (int i = 0; i < PASSWORD_KEY; i++) - for (int j = 0; j < rows; j++) - transcode.append(p[i + j * PASSWORD_KEY]); - - return transcode; -} - -QString MainWindow::passwordDecrypt(const QString& transcode) -{ - QString t = transcode; - int cols = t.length() / 4; - QString password; - for (int i = 0; i < cols; i++) - for (int j = 0; j < PASSWORD_KEY; j++) - password.append(t[i + j * cols]); - password.remove("+"); - return password; -} - -void MainWindow::on_act_openPageNum_triggered() -{ - int count = 0; - m_thumb->getItemCount(&count); - if (0 == count) - { - return; - } - - Dialog_OpenImageIndex dlg(count, (-1 == m_currIndex) ? 0 : m_currIndex, this); - if (dlg.exec()) - { - int index = dlg.getIndex(); - m_thumb->setCurrItem(index); - } -} - -void MainWindow::on_act_previousPage_triggered() -{ - if (-1 != m_currIndex && m_multiPageCount > 0 && m_multiIndex > 0) - { - --m_multiIndex; - - HGImage img = createImage(); - if (nullptr != img) - { - m_view->addImage(img); - m_widget_sideBar->setImage(img); - m_widget_sideBar->enableUI(false); - m_bSideEditing = false; - HGBase_DestroyImage(img); - m_modify = false; - } - else - { - m_view->clearImage(); - m_wndStatusBar->setMousePosInfo(0, 0); - m_modify = false; - } - - updateStatusBarPixelInfo(); - updateActionStatus(); - } -} - -void MainWindow::on_act_nextPage_triggered() -{ - if (-1 != m_currIndex && m_multiPageCount > 0 && -1 != m_multiIndex && m_multiIndex < m_multiPageCount - 1) - { - ++m_multiIndex; - - HGImage img = createImage(); - if (nullptr != img) - { - m_view->addImage(img); - m_widget_sideBar->setImage(img); - m_widget_sideBar->enableUI(false); - m_bSideEditing = false; - HGBase_DestroyImage(img); - m_modify = false; - } - else - { - m_view->clearImage(); - m_wndStatusBar->setMousePosInfo(0, 0); - m_modify = false; - } - - updateStatusBarPixelInfo(); - updateActionStatus(); - } -} - -void MainWindow::on_act_firstPage_triggered() -{ - if (-1 != m_currIndex && m_multiPageCount > 0 && 0 != m_multiIndex) - { - m_multiIndex = 0; - - HGImage img = createImage(); - if (nullptr != img) - { - m_view->addImage(img); - m_widget_sideBar->setImage(img); - m_widget_sideBar->enableUI(false); - m_bSideEditing = false; - HGBase_DestroyImage(img); - m_modify = false; - } - else - { - m_view->clearImage(); - m_wndStatusBar->setMousePosInfo(0, 0); - m_modify = false; - } - - updateStatusBarPixelInfo(); - updateActionStatus(); - } -} - -void MainWindow::on_act_lastPage_triggered() -{ - if (-1 != m_currIndex && m_multiPageCount > 0 && m_multiIndex != m_multiPageCount - 1) - { - m_multiIndex = m_multiPageCount - 1; - - HGImage img = createImage(); - if (nullptr != img) - { - m_view->addImage(img); - m_widget_sideBar->setImage(img); - m_widget_sideBar->enableUI(false); - m_bSideEditing = false; - HGBase_DestroyImage(img); - m_modify = false; - } - else - { - m_view->clearImage(); - m_wndStatusBar->setMousePosInfo(0, 0); - m_modify = false; - } - - updateStatusBarPixelInfo(); - updateActionStatus(); - } -} - -void MainWindow::on_act_adjust_triggered() -{ - HGImage img = nullptr; - m_view->getImage(&img); - if (nullptr == img) - { - return; - } - - HGUInt xDpi = 0; - HGUInt yDpi = 0; - HGBase_GetImageDpi(img, &xDpi, &yDpi); - - Dialog_ImgProc_Adjust dlg(img, this); - connect(&dlg, SIGNAL(applyToImage(HGImage)), this, SLOT(on_dialog_adjust_applyToImage(HGImage))); - - HGImage image = NULL; - if (dlg.exec()) - { - image = dlg.getAfterImage(); - HGBase_SetImageDpi(image, xDpi, yDpi); - m_view->addImage(image); - m_widget_sideBar->setImage(image); - m_widget_sideBar->enableUI(false); - m_bSideEditing = false; - m_modify = true; - } - else - { - image = dlg.getBeforeImage(); - HGBase_SetImageDpi(image, xDpi, yDpi); - m_view->addImage(image); - m_widget_sideBar->setImage(image); - m_widget_sideBar->enableUI(false); - m_bSideEditing = false; - } - - updateStatusBarPixelInfo(); - updateActionStatus(); - - if (auto_save_changes_) - { - on_act_save_triggered(); - } - - disconnect(&dlg, SIGNAL(applyToImage(HGImage)), this, SLOT(on_dialog_adjust_applyToImage(HGImage))); -} - -void MainWindow::on_act_open_triggered() -{ - if (m_isScanning) - { - return; - } - - QStringList fileNames = QFileDialog::getOpenFileNames(nullptr, tr("Open images"), "", "(*.jpg *.jpeg *.png *.bmp *.ppm *.pgm *.pbm *.pdf *.tif *.tiff *.ofd *.gif)"); - m_thumb->addItems(fileNames); -} - -void MainWindow::on_act_insert_triggered() -{ - if (m_isScanning) - { - return; - } - - QStringList fileNames = QFileDialog::getOpenFileNames(nullptr, tr("Insert images"), "", "(*.jpg *.jpeg *.png *.bmp *.ppm *.pgm *.pbm *.pdf *.tif *.tiff *.ofd *.gif)"); - if (-1 != m_currIndex) - m_thumb->insertItems(fileNames, m_currIndex); - else - m_thumb->addItems(fileNames); -} - -void MainWindow::on_act_closeFile_triggered() -{ - if (m_isScanning) - { - return; - } - - std::vector selectIndexs; - int count = 0; - m_thumb->getItemCount(&count); - for (int i = 0; i < count; ++i) - { - bool select = false; - m_thumb->itemIsSelect(i, &select); - if (select) - selectIndexs.push_back(i); - } - - if (selectIndexs.empty()) - { - return; - } - - if (-1 != m_currIndex) - { - bool select = false; - m_thumb->itemIsSelect(m_currIndex, &select); - if (select) - { - startSaveMessageBox(this); - } - } - - m_thumb->removeItems(selectIndexs, HGImgThumb::ThumbRemoveFlag_NULL); -} - -void MainWindow::on_act_closeAll_triggered() -{ - if (m_isScanning) - { - return; - } - - int count = 0; - auto_save_info_.index = 0; - auto_save_info_.path = ""; - m_thumb->getItemCount(&count); - if (0 == count) - { - return; - } - - for(auto& v : wrong_imgs_) - { - v->hide(); - remove(v->image_file().toStdString().c_str()); - delete v; - } - wrong_imgs_.clear(); - - startSaveMessageBox(this); - - m_thumb->removeAllItems(HGImgThumb::ThumbRemoveFlag_NULL); -} - -void MainWindow::on_act_exit_triggered() -{ - close(); -} - -void MainWindow::on_act_save_triggered() -{ - HGResult ret = HGBASE_ERR_FAIL; - HGImage img = nullptr; - m_view->getImage(&img); - if (nullptr == img || -1 == m_currIndex || 1 != m_multiPageCount) - { - return; - } - - assert(!m_currFilePath.isEmpty()); - if (0 == m_currFilePath.indexOf(Dialog_ClrCache::getCachePath())) - { - QString savePath; - if (!auto_save_changes_) - savePath = auto_save_info_.path; - else - savePath = m_currFilePath; - - int jpegQuality = auto_save_info_.jpegQuality; - int tiffCompressionBW = auto_save_info_.tiffCompressionBW; - int tiffCompression = auto_save_info_.tiffCompression; - int tiffQuality = auto_save_info_.tiffQuality; - bool isOcr = auto_save_info_.isOcr; - int ocrLanguageType = 0; - bool find = false; - int count = 0; - - if(!auto_save_changes_ || auto_save_info_.path.isEmpty() || !judgeDiskSpace(savePath)) - { - Dialog_SaveAs dlg(this); - if(savePath.length()) - { - int pos = savePath.lastIndexOf('/'); - if(pos > 0) - dlg.set_current_directory(savePath.left(pos)); - } - - if (!auto_save_changes_) - { - if (!dlg.exec()) - { - return; - } - } - else - savePath = m_currFilePath; - - if (!judgeDiskSpace(savePath)) - { - m_dialogLog->updateStatus(dev_que_.is_online() && 0 != m_scanType, m_isScanning); - return; - } - - if (!auto_save_changes_) - { - savePath = auto_save_info_.path = dlg.getSavePath(); - } - - isOcr = auto_save_info_.isOcr = dlg.isOcr(); - jpegQuality = auto_save_info_.jpegQuality = dlg.getJpegQuality(); - tiffQuality = auto_save_info_.tiffQuality = dlg.getTiffQuality(); - tiffCompression = auto_save_info_.tiffCompression = dlg.getTiffCompression(); - tiffCompressionBW = auto_save_info_.tiffCompressionBW = dlg.getTiffCompressionBW(); - ocrLanguageType = dlg.getOcrLanguageType(); - } - if(auto_save_changes_ && save_from_changed_) - { - // appendix ... - int pos = savePath.lastIndexOf('.'); - char index[20] = {0}; - if (!auto_save_changes_) - { - sprintf(index, "_%03u", ++auto_save_info_.index); - } - - savePath.insert(pos, QString::fromStdString(index)); - m_thumb->notify_mouse_leave(); - } - - m_thumb->getItemCount(&count); - for (int i = 0; i < count; ++i) - { - QString fileName; - m_thumb->getItemFileName(i, fileName); - assert(!fileName.isEmpty()); - - if (!auto_save_changes_) - { - if (fileName == savePath) - { - find = true; - break; - } - } - - } - - if (!find) - { - HGImgFmtSaveInfo saveInfo; - saveInfo.jpegQuality = (HGUInt)jpegQuality; - saveInfo.tiffCompression = HGIMGFMT_TIFFCOMP_NONE; - saveInfo.tiffJpegQuality = (HGUInt)tiffQuality; - - HGImageInfo imgInfo; - HGBase_GetImageInfo(img, &imgInfo); - if (HGBASE_IMGTYPE_BINARY == imgInfo.type) - { - if (1 == tiffCompressionBW) - saveInfo.tiffCompression = HGIMGFMT_TIFFCOMP_LZW; - else if (2 == tiffCompressionBW) - saveInfo.tiffCompression = HGIMGFMT_TIFFCOMP_CCITTFAX4; - } - else - { - if (1 == tiffCompression) - saveInfo.tiffCompression = HGIMGFMT_TIFFCOMP_LZW; - else if (2 == tiffCompression) - saveInfo.tiffCompression = HGIMGFMT_TIFFCOMP_JPEG; - } - - ret = saveImage(img, &saveInfo, isOcr, ocrLanguageType, getStdString(savePath).c_str()); - if (HGBASE_ERR_OK == ret) - { - if (auto_save_changes_) - { - m_thumb->refreshItem(m_currIndex); - } - else - m_thumb->updateItem(m_currIndex, savePath); - - m_currFilePath = savePath; - m_modify = false; - if(!auto_save_changes_) - { - QMessageBox::information(this, tr("tips"), tr("save succeed")); - } - } - else - { - QMessageBox::critical(this, tr("tips"), tr("save image doc failed: ") + getLogInfo(ret)); - m_dialogLog->addLog(tr("save image doc failed: ") + getLogInfo(ret), true); - m_wndStatusBar->setDeviceStatusInfo(tr("save image doc failed: ") + getLogInfo(ret), true); - } - } - else - { - QMessageBox::information(this, tr("tips"), tr("find savePath in thumbnail")); - } - - return; - } - - HGUInt fmtType = 0; - HGImgFmt_GetImgFmtTypeFromFileName(getStdString(m_currFilePath).c_str(), &fmtType); - if (HGIMGFMT_TYPE_TIFF == fmtType) - { - HGUInt compression = HGIMGFMT_TIFFCOMP_LZW; - - HGTiffReader tiffReader = nullptr; - HGImgFmt_OpenTiffReader(getStdString(m_currFilePath).c_str(), &tiffReader); - if (nullptr != tiffReader) - { - HGTiffLoadInfo tiffInfo; - HGImgFmt_LoadImageFromTiffReader(tiffReader, 0, &tiffInfo, 0, 0, nullptr); - compression = tiffInfo.compression; - HGImgFmt_CloseTiffReader(tiffReader); - } - - HGUInt xDpi, yDpi; - HGBase_GetImageDpi(img, &xDpi, &yDpi); - HGTiffSaveInfo tiffInfo; - tiffInfo.compression = compression; - tiffInfo.jpegQuality = 80; - tiffInfo.resolutionUnit = HGIMGFMT_TIFFRESUNIT_INCH; - tiffInfo.xResolution = xDpi; - tiffInfo.yResolution = yDpi; - - HGTiffWriter tiffWriter = nullptr; - ret = HGImgFmt_OpenTiffWriter(getStdString(m_currFilePath).c_str(), &tiffWriter); - if (HGBASE_ERR_OK == ret) - { - ret = HGImgFmt_SaveImageToTiffWriter(tiffWriter, img, &tiffInfo); - HGImgFmt_CloseTiffWriter(tiffWriter); - } - } - else - { - ret = HGImgFmt_SaveImage(img, 0, nullptr, getStdString(m_currFilePath).c_str()); - } - - if (HGBASE_ERR_OK == ret) - { - if(auto_save_changes_ && save_from_changed_) - m_thumb->notify_mouse_leave(); - m_thumb->refreshItem(m_currFilePath); - m_modify = false; - updateActionStatus(); - if(!auto_save_changes_) - { - QMessageBox::information(this, tr("tips"), tr("save succeed")); - } - } - else - { - QMessageBox::critical(this, tr("tips"), tr("save image doc failed: ") + getLogInfo(ret)); - m_dialogLog->addLog(tr("save image doc failed: ") + getLogInfo(ret), true); - m_wndStatusBar->setDeviceStatusInfo(tr("save image doc failed: ") + getLogInfo(ret), true); - } -} - -void MainWindow::on_act_saveAs_triggered() -{ - HGImage img = nullptr; - m_view->getImage(&img); - if (nullptr == img) - { - return; - } - - Dialog_SaveAs dlg(this); - if (dlg.exec()) - { - QString savePath = dlg.getSavePath(); - - if(!judgeDiskSpace(savePath)) - { - m_dialogLog->updateStatus(dev_que_.is_online() && 0 != m_scanType, m_isScanning); - return; - } - - bool find = false; - int count = 0; - m_thumb->getItemCount(&count); - for (int i = 0; i < count; ++i) - { - QString fileName; - m_thumb->getItemFileName(i, fileName); - assert(!fileName.isEmpty()); - - if (fileName == savePath) - { - find = true; - break; - } - } - - if (!find) - { - int jpegQuality = dlg.getJpegQuality(); - int tiffCompressionBW = dlg.getTiffCompressionBW(); - int tiffCompression = dlg.getTiffCompression(); - int tiffQuality = dlg.getTiffQuality(); - bool isOcr = dlg.isOcr(); - int ocrLanguageType = dlg.getOcrLanguageType(); - - HGImgFmtSaveInfo saveInfo; - saveInfo.jpegQuality = (HGUInt)jpegQuality; - saveInfo.tiffCompression = HGIMGFMT_TIFFCOMP_NONE; - saveInfo.tiffJpegQuality = (HGUInt)tiffQuality; - - HGImageInfo imgInfo; - HGBase_GetImageInfo(img, &imgInfo); - if (HGBASE_IMGTYPE_BINARY == imgInfo.type) - { - if (1 == tiffCompressionBW) - saveInfo.tiffCompression = HGIMGFMT_TIFFCOMP_LZW; - else if (2 == tiffCompressionBW) - saveInfo.tiffCompression = HGIMGFMT_TIFFCOMP_CCITTFAX4; - } - else - { - if (1 == tiffCompression) - saveInfo.tiffCompression = HGIMGFMT_TIFFCOMP_LZW; - else if (2 == tiffCompression) - saveInfo.tiffCompression = HGIMGFMT_TIFFCOMP_JPEG; - } - - HGResult ret = saveImage(img, &saveInfo, isOcr, ocrLanguageType, getStdString(savePath).c_str()); - if (HGBASE_ERR_OK == ret) - { - if(!auto_save_changes_) - { - QMessageBox::information(this, tr("tips"), tr("save succeed")); - } - } - else - { - QMessageBox::critical(this, tr("tips"), tr("save image doc failed: ") + getLogInfo(ret)); - m_dialogLog->addLog(tr("save image doc failed: ") + getLogInfo(ret), true); - m_wndStatusBar->setDeviceStatusInfo(tr("save image doc failed: ") + getLogInfo(ret), true); - } - } - else - { - QMessageBox::information(this, tr("tips"), tr("find savePath in thumbnail")); - } - } -} - -void MainWindow::on_act_Export_triggered() -{ - int count = 0; - m_thumb->getItemCount(&count); - if (0 == count) - { - return; - } - - std::vector selectIndexs; - for (int i = 0; i < count; ++i) - { - bool select = false; - m_thumb->itemIsSelect(i, &select); - if (select) - selectIndexs.push_back(i); - } - if (selectIndexs.size() == 0) - { - QMessageBox::information(this, tr("tips"), tr("Please select at least one picture before export")); - return; - } - - Dialog_Export dlg(count, selectIndexs, this); - if (dlg.exec()) - { - QStringList srcFiles; - - std::vector saveIndexs; - dlg.getSaveIndexs(saveIndexs); - for (size_t i = 0; i < saveIndexs.size(); ++i) - { - QString fileName; - m_thumb->getItemFileName(saveIndexs[i], fileName); - srcFiles.append(fileName); - - if(!judgeDiskSpace(fileName)) - { - m_dialogLog->updateStatus(dev_que_.is_online() && 0 != m_scanType, m_isScanning); - return; - } - } - - if (!srcFiles.isEmpty()) - { - QString savePath = dlg.getSavePath(); - QString saveName = dlg.getSaveName(); - QString saveExt = dlg.getSaveExt(); - bool isSaveAsMulti = dlg.isSaveAsMultiPage(); - int jpegQuality = dlg.getJpegQuality(); - int tiffCompressionBW = dlg.getTiffCompressionBW(); - int tiffCompression = dlg.getTiffCompression(); - int tiffQuality = dlg.getTiffQuality(); - bool isOcr = dlg.isOcr(); - int ocrLanguageType = dlg.getOcrLanguageType(); - - Dialog_ExportImageFile dlgExport(savePath, saveName, saveExt, isSaveAsMulti, jpegQuality, - tiffCompressionBW, tiffCompression, tiffQuality, isOcr, ocrLanguageType, srcFiles, this); - dlgExport.exec(); - } - } -} - -void MainWindow::on_act_imageInfo_triggered() -{ - if (-1 == m_currIndex) - { - return; - } - - assert(!m_currFilePath.isEmpty()); - QFileInfo info(m_currFilePath); - - HGImage image = NULL; - m_view->getImage(&image); - if (nullptr == image) - { - return; - } - - HGImageInfo imgInfo; - HGBase_GetImageInfo(image, &imgInfo); - - HGUInt xDpi, yDpi; - HGBase_GetImageDpi(image, &xDpi, &yDpi); - - QStringList fileKeys; - fileKeys << tr("File name") << tr("File path") << tr("File size") << tr("Creation date/time") << tr("Modified date/time") << tr("Accessed date/time"); - - QStringList fileValues; - fileValues.append(info.completeBaseName());//add Filename - fileValues.append(info.absoluteFilePath());//add Filepath - qint64 size_B = info.size(); - QDateTime c_date = info.created(); - QString createTime = c_date.toString("yyyy-MM-dd hh:mm:ss"); - fileValues.append(createTime);//add File created time - QDateTime m_date = info.lastModified(); - QString modifiedTime = m_date.toString("yyyy-MM-dd hh:mm:ss"); - fileValues.append(modifiedTime);//add File modified time - QDateTime r_date = info.lastRead(); - QString accessTime = r_date.toString("yyyy-MM-dd hh:mm:ss"); - fileValues.append(accessTime);//add File access time - - double s = size_B; - int unit = 0; - while (true) - { - if (s > 1024.0) - { - s /= 1024.0; - unit += 1; - } - else - break; - } - QString unitstring = unit == 3 ? "GB" : (unit == 2 ? "MB" : (unit == 1 ? "KB" : "B")); - QString sstring = QString::number(s, 'f', 2); - QString Bstring = QString::number(size_B); - 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; - } - fileValues.insert(2, sstring + " " + unitstring + " (" + Bstring + ")");//add Filesize - - QStringList imageKeys; - imageKeys << tr("Format") << tr("Width") << tr("Height") << tr("depth") << tr("Color model") << tr("DPI") << tr("Print size") << tr("Frame"); - QStringList imageValues; - imageValues.append(info.suffix());//add image format - imageValues.append(QString::number(imgInfo.width));//add image width - imageValues.append(QString::number(imgInfo.height));//add image height - - int depth = 1; - if (HGBASE_IMGTYPE_GRAY == imgInfo.type) - depth = 8; - else if (HGBASE_IMGTYPE_BGR == imgInfo.type || HGBASE_IMGTYPE_RGB == imgInfo.type) - depth = 24; - else if (HGBASE_IMGTYPE_BGRA == imgInfo.type || HGBASE_IMGTYPE_RGBA == imgInfo.type) - depth = 32; - imageValues.append(QString::number(depth));//add image depth - imageValues.append(depth == 0 ? tr("None") : (depth == 1 ? tr("Mono") : (depth == 8 ? tr("Gray") : tr("Color"))));//add image color - - HGUInt imgFmtType = 0; - HGImgFmt_GetImgFmtType(m_currFilePath.toLocal8Bit().toStdString().c_str(), &imgFmtType); - if (HGIMGFMT_TYPE_PDF == imgFmtType || HGIMGFMT_TYPE_GIF == imgFmtType - || HGIMGFMT_TYPE_PNM == imgFmtType) - { - QString info = tr("Not supported"); - imageValues.append(info); - imageValues.append(info); - } - else - { - QString dpi = QString::number(xDpi) + " x " + QString::number(yDpi); - imageValues.append(dpi);//add image dpi - - double cm_x = (0 == xDpi) ? 0 : 2.54 * imgInfo.width / xDpi; - double cm_y = (0 == yDpi) ? 0 : 2.54 * imgInfo.height / yDpi; - QString cm_printsize = QString::number(cm_x, 'f', 2) + " x " + QString::number(cm_y, 'f', 2) + " cm"; - double inch_x = cm_x / 2.54; - double inch_y = cm_y / 2.54; - QString inch_printsize = QString::number(inch_x, 'f', 2) + " x " + QString::number(inch_y, 'f', 2) + " inches"; - imageValues.append(cm_printsize + ", " + inch_printsize);//add image print size - } - imageValues.append(QString::number(m_multiIndex)); - - Dialog_ImageInfo d(fileKeys, fileValues, imageKeys, imageValues, this); - d.exec(); -} - -void MainWindow::closeEvent(QCloseEvent *e) -{ - if (m_isScanning) - { - m_closeTip = true; - QMessageBox::warning(this, tr("Warning"), tr("Device is Running!\nPlease finish scanning first.")); - e->ignore(); - return; - } - - bool cache_saved = true; - int count = 0; - m_thumb->getItemCount(&count); - for (int i = 0; i < count; ++i) - { - QString fileName; - m_thumb->getItemFileName(i, fileName); - if (0 == fileName.indexOf(Dialog_ClrCache::getCachePath())) - { - cache_saved = false; - break; - } - } - - if(m_closeTip) - { - if (!cache_saved || m_modify) - { - QMessageBox msg(QMessageBox::Question, tr("Question"), - tr("There are pictures that have not been saved.\nAre you sure to close?"), - QMessageBox::Yes | QMessageBox::No, this); - msg.exec(); - if (msg.clickedButton() != msg.button(QMessageBox::Yes)) - { - e->ignore(); - return; - } - } - else - { - QMessageBox msg(QMessageBox::Question, tr("tips"), - tr("Are you sure to close?"), - QMessageBox::Yes | QMessageBox::No, this); - msg.exec(); - if (msg.clickedButton() != msg.button(QMessageBox::Yes)) - { - e->ignore(); - return; - } - } - } - - QString cachePath = Dialog_ClrCache::getCachePath(); - QDir dir = QDir(cachePath); - if (dir.exists() && (cachePath.endsWith("Cache/") || cachePath.endsWith("Cache\\"))) - dir.removeRecursively(); - - m_versionDll->PostUserCloseInfo(HGVERSION_APPNAME_SCANNER, m_oemName); -} - -void MainWindow::resizeEvent(QResizeEvent *e) -{ - (void)e; - - if (m_bSideflag) - { - int mainWndWidth = this->rect().width(); - int mainWndHeight = this->rect().height(); - int sideBarWidth = m_widget_sideBar->width(); - int sideBarHeight = m_widget_sideBar->height(); - - m_widget_sideBar->move(mainWndWidth - sideBarWidth, mainWndHeight/2 - sideBarHeight/2); - m_pbtn_push->move(mainWndWidth - m_pbtn_push->width() - sideBarWidth, mainWndHeight/2 - m_pbtn_push->height()/2); - } - else - { - updateSideBar(); - } -} - -int MainWindow::sane_ex_callback(SANE_Handle hdev, int code, void *data, unsigned int* len, void *param) -{ - (void)hdev; - (void)len; - MainWindow *p = (MainWindow *)param; - switch (code) - { - case SANE_EVENT_DEVICE_ARRIVED: - { - SANE_Device_Ex* sane_dev = (SANE_Device_Ex*)data; - emit p->sane_dev_arrive(sane_dev->name, sane_dev->openned == SANE_TRUE); - } - break; - case SANE_EVENT_DEVICE_LEFT: - { - SANE_Device* sane_dev = (SANE_Device*)data; - emit p->sane_dev_remove(sane_dev->name); - } - break; - case SANE_EVENT_STATUS: - { - QString promptInfo((char*)data); - emit p->sane_dev_readyStatus(promptInfo); - } - break; - case SANE_EVENT_ERROR: - { - QString errorInfo((char*)data); - emit p->sane_dev_error(errorInfo); - } - break; - case SANE_EVENT_WORKING: - { - QString workingInfo((char*)data); - emit p->scan_working(workingInfo); - } - break; - case SANE_EVENT_IMAGE_OK: - { - SANE_Image *sane_img = (SANE_Image *)data; - - HGUInt imgType = 0; - if (sane_img->header.format == SANE_FRAME_GRAY) - { - if (1 == sane_img->header.depth) - imgType = HGBASE_IMGTYPE_BINARY; - else if (8 == sane_img->header.depth) - imgType = HGBASE_IMGTYPE_GRAY; - } - else if (sane_img->header.format == SANE_FRAME_RGB) - { - imgType = HGBASE_IMGTYPE_RGB; - } - - HGByte *imgData = sane_img->data; - HGImageInfo imgInfo = {(HGUInt)sane_img->header.pixels_per_line, (HGUInt)sane_img->header.lines, - imgType, (HGUInt)sane_img->header.bytes_per_line, HGBASE_IMGORIGIN_TOP}; - - HGImage img = nullptr; - HGBase_CreateImageWithData(imgData, &imgInfo, &img); - if (nullptr != img) - { - emit p->pre_new_image(img); - - HGResult ret = HGBASE_ERR_FAIL; - if (1 == p->m_saveType) - { - HGImgFmtSaveInfo info; - info.jpegQuality = 100; - info.tiffCompression = HGIMGFMT_TIFFCOMP_LZW; - info.tiffJpegQuality = 0; - ret = HGImgFmt_SaveImage(img, 0, &info, getStdString(p->m_scanFileName).c_str()); - } - else if (2 == p->m_saveType) - { - HGImgFmtSaveInfo saveInfo; - saveInfo.jpegQuality = (HGUInt)p->m_aquireIntoSaveParam.m_jpegQuality; - saveInfo.tiffCompression = HGIMGFMT_TIFFCOMP_NONE; - saveInfo.tiffJpegQuality = (HGUInt)p->m_aquireIntoSaveParam.m_tiffQuality; - - HGImageInfo imgInfo; - HGBase_GetImageInfo(img, &imgInfo); - if (HGBASE_IMGTYPE_BINARY == imgInfo.type) - { - if (1 == p->m_aquireIntoSaveParam.m_tiffCompressionBW) - saveInfo.tiffCompression = HGIMGFMT_TIFFCOMP_LZW; - else if (2 == p->m_aquireIntoSaveParam.m_tiffCompressionBW) - saveInfo.tiffCompression = HGIMGFMT_TIFFCOMP_CCITTFAX4; - } - else - { - if (1 == p->m_aquireIntoSaveParam.m_tiffCompression) - saveInfo.tiffCompression = HGIMGFMT_TIFFCOMP_LZW; - else if (2 == p->m_aquireIntoSaveParam.m_tiffCompression) - saveInfo.tiffCompression = HGIMGFMT_TIFFCOMP_JPEG; - } - - ret = HGImgFmt_SaveImageToWriter(p->m_scanImgFmtWriter, img, &saveInfo); - } - else if (3 == p->m_saveType) - { - HGImgFmtSaveInfo saveInfo; - saveInfo.jpegQuality = (HGUInt)p->m_aquireIntoSaveParam.m_jpegQuality; - saveInfo.tiffCompression = HGIMGFMT_TIFFCOMP_NONE; - saveInfo.tiffJpegQuality = (HGUInt)p->m_aquireIntoSaveParam.m_tiffQuality; - - HGImageInfo imgInfo; - HGBase_GetImageInfo(img, &imgInfo); - if (HGBASE_IMGTYPE_BINARY == imgInfo.type) - { - if (1 == p->m_aquireIntoSaveParam.m_tiffCompressionBW) - saveInfo.tiffCompression = HGIMGFMT_TIFFCOMP_LZW; - else if (2 == p->m_aquireIntoSaveParam.m_tiffCompressionBW) - saveInfo.tiffCompression = HGIMGFMT_TIFFCOMP_CCITTFAX4; - } - else - { - if (1 == p->m_aquireIntoSaveParam.m_tiffCompression) - saveInfo.tiffCompression = HGIMGFMT_TIFFCOMP_LZW; - else if (2 == p->m_aquireIntoSaveParam.m_tiffCompression) - saveInfo.tiffCompression = HGIMGFMT_TIFFCOMP_JPEG; - } - - ret = saveImage(img, &saveInfo, p->m_aquireIntoSaveParam.m_isOcr, 0, getStdString(p->m_scanFileName).c_str()); - } - - emit p->post_new_image(ret, sane_img->flag.statu); - HGBase_DestroyImage(img); - } - } - break; - case SANE_EVENT_SCAN_FINISHED: - { - int err = len ? (int)(*len) : 0; - QString finishInfo((char*)data); - emit p->scan_finish(finishInfo, err); - } - break; - } - - return 0; -} - -void HGAPI MainWindow::CrashFunc(HGPointer crashAddr, HGPointer param) -{ - MainWindow *p = (MainWindow *)param; - - - HGChar crashName[256]; - HGBase_GetLogFilePath(crashName, 256); - strcat(crashName, "crash.dmp"); - if (HGBASE_ERR_OK == HGBase_MakeCrashFile(crashName)) - { - HGChar excpStr[64]; -#ifdef HG_64BIT - sprintf(excpStr, "0x%016p", crashAddr); -#else - sprintf(excpStr, "0x%08p", crashAddr); -#endif - - p->m_versionDll->PostCrashInfo(HGVERSION_APPNAME_SCANNER, p->m_oemName, "crash", crashName, excpStr); - } -} - -void MainWindow::on_act_multiRotate_triggered() -{ - int count = 0; - m_thumb->getItemCount(&count); - if (0 == count) - { - return; - } - - Dialog_MultiRotate dlg(this); - if (dlg.exec()) - { - int rotateType = dlg.getRotateType(); - int rotatePageType = dlg.getRotatePageType(); - - QStringList fileList; - switch (rotatePageType) - { - case 0: - { - if (-1 != m_currIndex) - { - assert(!m_currFilePath.isEmpty()); - fileList.append(m_currFilePath); - } - } - break; - case 1: - { - for (int i = 0; i < count; ++i) - { - bool selected = false; - m_thumb->itemIsSelect(i, &selected); - if (selected) - { - QString fileName; - m_thumb->getItemFileName(i, fileName); - fileList.append(fileName); - } - } - } - break; - case 2: - { - for (int i = 0; i < count; ++i) - { - if ((i + 1) % 2 != 0) - { - QString fileName; - m_thumb->getItemFileName(i, fileName); - fileList.append(fileName); - } - } - } - break; - case 3: - { - for (int i = 0; i < count; ++i) - { - if ((i + 1) % 2 == 0) - { - QString fileName; - m_thumb->getItemFileName(i, fileName); - fileList.append(fileName); - } - } - } - break; - case 4: - { - for (int i = 0; i < count; ++i) - { - QString fileName; - m_thumb->getItemFileName(i, fileName); - fileList.append(fileName); - } - } - break; - } - - if (!fileList.isEmpty()) - { - Dialog_MultiRotateImageFile processDlg(fileList, rotateType, this); - connect(&processDlg, SIGNAL(refreshImageFile(const QString &)), this, SLOT(on_dialog_multirotate_refreshImgFile(const QString &))); - processDlg.exec(); - disconnect(&processDlg, SIGNAL(refreshImageFile(const QString &)), this, SLOT(on_dialog_multirotate_refreshImgFile(const QString &))); - } - } -} - -void MainWindow::on_act_autoCrop_triggered() -{ - HGImage img = nullptr; - m_view->getImage(&img); - if (nullptr == img) - { - return; - } - - HGUInt xDpi = 0; - HGUInt yDpi = 0; - HGBase_GetImageDpi(img, &xDpi, &yDpi); - - Dialog_ImgProc_AutoCrop dlg(this); - if (dlg.exec()) - { - bool isCrop = dlg.isCrop(); - bool isDeskew = dlg.isDeskew(); - bool isFillBlank = dlg.isFillBlank(); - bool isConvex = dlg.isConvex(); - bool isAutoColor = dlg.isAutoColor(); - bool isUseAdvParam = dlg.isUseAdvancedParam(); - int threshold = dlg.getThreshold(); - int noise = dlg.getNoise(); - int indent = dlg.getIndent(); - - HGImgAutoCropParam autoCropParam; - autoCropParam.normalCrop = HGFALSE; - autoCropParam.dispersion = HGTRUE; - - if (isFillBlank) - { - autoCropParam.convex = (HGBool)isConvex; - autoCropParam.fillColor = (HGBool)isAutoColor; - } - else - { - autoCropParam.convex = HGTRUE; - autoCropParam.fillColor = HGFALSE; - } - - if (isUseAdvParam) - { - autoCropParam.threshold = threshold; - autoCropParam.noise = noise; - autoCropParam.indent = indent; - } - else - { - autoCropParam.threshold = 40.0; - autoCropParam.noise = 8; - autoCropParam.indent = 5; - } - - if (isCrop || isDeskew || isFillBlank) - { - HGImageInfo imgInfo; - HGBase_GetImageInfo(img, &imgInfo); - - HGImage destImage = nullptr; - HGUInt destWidth = imgInfo.width; - HGUInt destHeight = imgInfo.height; - - HGImgProc_ImageAutoCrop(img, (HGBool)isCrop, (HGBool)isDeskew, (HGBool)isFillBlank, &autoCropParam, destWidth, destHeight, - imgInfo.type, HGBASE_IMGORIGIN_TOP, &destImage); - if (nullptr != destImage) - { - HGBase_SetImageDpi(destImage, xDpi, yDpi); - m_view->addImage(destImage); - m_widget_sideBar->setImage(destImage); - m_widget_sideBar->enableUI(false); - m_bSideEditing = false; - HGBase_DestroyImage(destImage); - m_modify = true; - - updateStatusBarPixelInfo(); - updateActionStatus(); - - if (auto_save_changes_) - { - on_act_save_triggered(); - } - } - } - } -} - -void MainWindow::on_act_signIn_triggered() -{ - if (m_admin_loggedIn) - { - return; - } - - Dialog_Admin dlg(m_password, this); - m_admin_loggedIn = dlg.exec(); - updateActionStatus(); - if (m_admin_loggedIn) - m_versionDll->PostUserLoginInfo(HGVERSION_APPNAME_SCANNER, m_oemName); -} - -void MainWindow::on_act_passwordChange_triggered() -{ - if (!m_admin_loggedIn) - { - return; - } - - Dialog_PasswordChange dlg(m_password, this); - if (dlg.exec()) - { - m_password = dlg.getNewPassword(); - saveCfgValue("login", "password", passwordEncrypt(m_password)); - } -} - -void MainWindow::on_act_signOut_triggered() -{ - if (!m_admin_loggedIn) - { - return; - } - - QMessageBox msg(QMessageBox::Question, tr("Question"), - tr("Sure to sign out administrator account?"), QMessageBox::Yes | QMessageBox::No); - msg.exec(); - if(msg.clickedButton() == msg.button(QMessageBox::Yes)) - { - m_admin_loggedIn = false; - updateActionStatus(); - m_versionDll->PostUserLogoutInfo(HGVERSION_APPNAME_SCANNER, m_oemName); - } -} - -void MainWindow::on_act_log_triggered() -{ - if (!m_admin_loggedIn) - { - return; - } - - Dialog_LogManager d(this); - d.setWindowFlags(Qt::Dialog | Qt::WindowCloseButtonHint); - d.exec(); -} - -void MainWindow::on_act_clrCache_triggered() -{ - if (!m_admin_loggedIn) - { - return; - } - - Dialog_ClrCache dlg(this); - dlg.setWindowFlags(Qt::Dialog | Qt::WindowCloseButtonHint); - connect(&dlg, SIGNAL(clearCache()), this, SLOT(on_clearCache())); - dlg.exec(); - disconnect(&dlg, SIGNAL(clearCache()), this, SLOT(on_clearCache())); -} - -void MainWindow::on_act_consume_triggered() -{ - if (!m_admin_loggedIn) - { - return; - } -} - -void MainWindow::on_act_clearRoller_triggered() -{ - if (!m_admin_loggedIn) - { - return; - } - - QMessageBox msg(QMessageBox::Question, tr("confirm operation"), - tr("are you sure to clear the roller count?"), - QMessageBox::Yes | QMessageBox::No, this); - msg.exec(); - if(msg.clickedButton() != msg.button(QMessageBox::Yes)) - return; - - unsigned int count = 0; - int ret = sane_io_control(dev_que_.handle(), IO_CTRL_CODE_SET_CLEAR_ROLLER_COUNT, nullptr, &count); - - if(ret == SANE_STATUS_GOOD) - { - QMessageBox::information(this, tr("hint"), tr("Roller scanned count has been set to 0.")); - m_versionDll->PostDeviceClearRollerInfo(m_currDeviceName.toStdString().c_str(), m_devSerialNum.toStdString().c_str(), "", m_devVersionNum.toStdString().c_str()); - } - else - QMessageBox::information(this, tr("hint"), tr("Roller scanned count reset failed.")); -} - -void MainWindow::on_act_help_triggered() -{ - QString filename; -#if defined(HG_CMP_MSC) - #if defined(OEM_HANWANG) - filename = QApplication::applicationDirPath() + "/HanvonScan_App_Help_manual.pdf"; - #elif defined(OEM_LISICHENG) - filename = QApplication::applicationDirPath() + "/LanxumScan_App_Help_manual.pdf"; - #elif defined(OEM_CANGTIAN) - filename = QApplication::applicationDirPath() + "/CumtennScan_App_Help_manual.pdf"; - #elif defined(OEM_ZHONGJING) - filename = QApplication::applicationDirPath() + "/MicrotekScan_App_Help_manual.pdf"; - if (m_currLang == "english") - filename = QApplication::applicationDirPath() + "/MicrotekScan_App_Help_manual_EN.pdf"; - #elif defined(OEM_ZIGUANG) - filename = QApplication::applicationDirPath() + "/UniScan_App_Help_manual.pdf"; - #elif defined(OEM_NEUTRAL) - filename = QApplication::applicationDirPath() + "/HGScan_App_Help_manual.pdf"; - #elif defined(OEM_DELI) - filename = QApplication::applicationDirPath() + "/DeliScan_App_Help_manual.pdf"; - #else - filename = QApplication::applicationDirPath() + "/HuaGoScan_App_Help_manual.pdf"; - #endif -#else - std::string osName; - FILE *file = popen("cat /etc/issue | cut -d\' \' -f1", "r"); - if (NULL != file) - { - char data[1024] = {0}; - if (NULL != fgets(data, 1024, file)) - osName = data; - pclose(file); - } - - printf("osName=%s\n", osName.c_str()); - if (osName.find("UnionTech") != std::string::npos) - { -#if defined(OEM_HANWANG) - filename = QApplication::applicationDirPath() + "/../../entries/help/HanvonScan_App_Help_manual.pdf"; -#elif defined(OEM_LISICHENG) - filename = QApplication::applicationDirPath() + "/../../entries/help/LanxumScan_App_Help_manual.pdf"; -#elif defined(OEM_CANGTIAN) - filename = QApplication::applicationDirPath() + "/../../entries/help/CumtennScan_App_Help_manual.pdf"; -#elif defined(OEM_ZHONGJING) - filename = QApplication::applicationDirPath() + "/../../entries/help/MicrotekScan_App_Help_manual.pdf"; - if (m_currLang == "english") - filename = QApplication::applicationDirPath() + "/../../entries/help/MicrotekScan_App_Help_manual_EN.pdf"; -#elif defined(OEM_ZIGUANG) - filename = QApplication::applicationDirPath() + "/../../entries/help/UniScan_App_Help_manual.pdf"; -#elif defined(OEM_NEUTRAL) - filename = QApplication::applicationDirPath() + "/../../entries/help/HGScan_App_Help_manual.pdf"; -#elif defined(OEM_DELI) - filename = QApplication::applicationDirPath() + "/../../entries/help/DeliScan_App_Help_manual.pdf"; -#else - filename = QApplication::applicationDirPath() + "/../../entries/help/HuaGoScan_App_Help_manual.pdf"; -#endif - } - else - { -#if defined(OEM_HANWANG) - filename = QApplication::applicationDirPath() + "/../doc/HanvonScan_App_Help_manual.pdf"; -#elif defined(OEM_LISICHENG) - filename = QApplication::applicationDirPath() + "/../doc/LanxumScan_App_Help_manual.pdf"; -#elif defined(OEM_CANGTIAN) - filename = QApplication::applicationDirPath() + "/../doc/CumtennScan_App_Help_manual.pdf"; -#elif defined(OEM_ZHONGJING) - filename = QApplication::applicationDirPath() + "/../doc/MicrotekScan_App_Help_manual.pdf"; - if (m_currLang == "english") - filename = QApplication::applicationDirPath() + "/../doc/MicrotekScan_App_Help_manual_EN.pdf"; -#elif defined(OEM_ZIGUANG) - filename = QApplication::applicationDirPath() + "/../doc/UniScan_App_Help_manual.pdf"; -#elif defined(OEM_NEUTRAL) - filename = QApplication::applicationDirPath() + "/../doc/HGScan_App_Help_manual.pdf"; -#elif defined(OEM_DELI) - filename = QApplication::applicationDirPath() + "/../doc/DeliScan_App_Help_manual.pdf"; -#else - filename = QApplication::applicationDirPath() + "/../doc/HuaGoScan_App_Help_manual.pdf"; -#endif - } -#endif - - QFileInfo info(filename); - if (!info.exists()) - QMessageBox::warning(this, tr("Error"), tr("Document missing! It would be deleted or renamed.")); - else - QDesktopServices::openUrl(QUrl::fromLocalFile(filename)); -} - -void MainWindow::my_url_handler(const QUrl& url) -{ - std::string to(url.url().toStdString()); - - if(to.find("://clear-roller") != std::string::npos) - { - QMessageBox msg(QMessageBox::Question, tr("confirm the operation"), - tr("Are you sure to clear the rollor acount?"), - QMessageBox::Yes | QMessageBox::No, this); - msg.exec(); - if(msg.clickedButton() == msg.button(QMessageBox::Yes)) - { - unsigned int count = 0; - int ret = sane_io_control(dev_que_.handle(), IO_CTRL_CODE_SET_CLEAR_ROLLER_COUNT, nullptr, &count); - - QString info; - if(ret == SANE_STATUS_GOOD) - { - info = tr("Roller scanned count has been set to 0."); - - // +鐠囩兘鍣搁弬鎷岀箻閸忋儱鍙ф禍搴f櫕闂堫澀浜掗懢宄板絿閺堚偓閺傛澘鈧? info += tr("Please re-enter the Abount screen to obtain the latest value"); - } - else - info = tr("Roller scanned count reset failed."); - - QMessageBox::information(this, tr("hint"), info); - } - } -} -void MainWindow::on_act_about_triggered() -{ - SANE_About *about = nullptr; - unsigned int len = 0; - QString title; - QString content; - std::list info; - QDesktopServices::setUrlHandler(MY_URL_SCHEME, this, "my_url_handler"); - if (sane_io_control(dev_que_.handle(), IO_CTRL_CODE_ABOUT_INFO, about, &len) == SANE_STATUS_NO_MEM) - { - about = (SANE_About*)malloc(len + 128); - if (about) - { - memset(about, 0, len + 128); - if (sane_io_control(dev_que_.handle(), IO_CTRL_CODE_ABOUT_INFO, about, &len) == SANE_STATUS_GOOD) - { -#if defined(OEM_ZHONGJING) - title = tr("about %1").arg(QString::fromStdString(about->title)); - info.push_back(tr("

Version: %1

").arg(QString::fromStdString(about->version))); - for (int i = 0; about->appendix[i].key; ++i) - { - if(about->appendix[i].url) - info.push_back(tr("

%1: %3").arg(about->appendix[i].key).arg(about->appendix[i].url).arg(about->appendix[i].content) + "

"); - else - info.push_back(tr("

%1: %2").arg(about->appendix[i].key).arg(about->appendix[i].content) + "

"); - } - info.push_back(tr("

CopyRight: © %1

").arg(QString::fromStdString(about->copyright))); - - const char* cmp[] = { - BRAND_TITLE_DEVICE_MODEL, - about->version, - BRAND_TITLE_FIRM_VERSION, - BRAND_TITLE_SERIAL_NUM, - BRAND_TITLE_ROLLER_COUNT, - BRAND_TITLE_HISTORY_COUNT, - BRAND_TITLE_IP, - BRAND_TITE_MANUFACTOR, - BRAND_COMPANY_ADDRESS, - BRAND_TITLE_TEL, - BRAND_TITLE_URL, - BRAND_TITLE_GPS, - about->copyright - }; - for (int i = 0; i < sizeof(cmp) / sizeof(const char *); ++i) - { - std::list::iterator iter = info.begin(); - while (iter != info.end()) - { - if (iter->contains(from_default_language(cmp[i], nullptr))) - { - content += *iter; - info.erase(iter); - break; - } - else - { - ++iter; - } - } - } - - std::list::iterator iter = info.begin(); - while (iter != info.end()) - { - content += *iter; - ++iter; - } -#else - title = tr("about %1").arg(QString::fromStdString(about->title)); - content = tr("

Version: %1

").arg(QString::fromStdString(about->version)); - content += tr("

CopyRight: © %1

").arg(QString::fromStdString(about->copyright)); - for (int i = 0; about->appendix[i].key; ++i) - { - if(about->appendix[i].url) - content += tr("

%1: %3").arg(about->appendix[i].key).arg(about->appendix[i].url).arg(about->appendix[i].content); - else - content += tr("

%1: %2").arg(about->appendix[i].key).arg(about->appendix[i].content); - if(m_admin_loggedIn - && strcmp(about->appendix[i].key, tr("roller number").toLatin1().data()) == 0 - && atoi(about->appendix[i].content) > 0) - { - char url[128] = {0}; - sprintf(url, "        \346\270\205\351\231\244", MY_URL_SCHEME); - content += QString::fromStdString(url); - } - content += "

"; - } -#endif - } - free(about); - } - } - - QMessageBox::about(this, title, content); - QDesktopServices::unsetUrlHandler(MY_URL_SCHEME); -} - -void MainWindow::on_act_scannerSettings_triggered() -{ - if (!dev_que_.is_online() || m_isScanning) - { - return; - } - - hg_settingdialog dlg(dev_que_.handle(), this, &dev_que_); - dlg.exec(); - ui->menu_device->deviceMenuUpdate(&dev_que_); -} - -void MainWindow::on_act_acquire_triggered() -{ - if(!isLimitAccessFolder(1)) - { - return; - } - - if (!dev_que_.is_online() || m_isScanning) - { - return; - } - - int count = 0; - m_thumb->getItemCount(&count); - if (count != 0) - { - int result = startScanMessageBox(this); - if (cancelScan == result) - return; - } - - m_singleScan = false; - m_scanType = 1; - m_scanInsertPos = -1; - - startSaveMessageBox(this); - - m_dpi = getDpi(); - SANE_Status ret = sane_start(dev_que_.handle()); - if (ret != SANE_STATUS_GOOD) - { - m_dialogLog->updateStatus(dev_que_.is_online() && 0 != m_scanType, m_isScanning); - m_wndStatusBar->setDeviceStatusInfo(tr("start failed"), true); - m_dialogLog->addLog(tr("start failed") + "(" + QString(sane_err_desc(ret)) + ")", true); - HGBase_WriteInfo(HGBASE_INFOTYPE_ERROR, "%s", getStdString(tr("start failed")).c_str()); - - if(ret == SCANNER_ERR_DEVICE_SLEEPING) - { - ui->menu_scan->setEnabled(false); - ui->act_acquire->setEnabled(false); - ui->act_scannerSettings->setEnabled(false); - m_dialogLog->updateStatus(false, false); - m_dialogLog->show(); - - if (m_devVersionNum < "G4393B1001" - && ("439" == m_devPid || "9220" == m_devPid || "8529" == m_devPid || "7039" == m_devPid))//Previous versions of this firmware number and 439 device can only be manually awakened. - { - m_dialogLog->addLog(tr("Please wake up the device manually"), true); - m_wndStatusBar->setDeviceStatusInfo(tr("Please wake up the device manually"), true); - } - else - { - QTime curTimer = QTime::currentTime().addMSecs(10000); - while (QTime::currentTime() < curTimer) - { - QCoreApplication::processEvents(QEventLoop::AllEvents, 100); - } - - m_dialogLog->addLog(tr("already waked up device"), false); - m_wndStatusBar->setDeviceStatusInfo(tr("already waked up device"), false); - } - - ui->menu_scan->setEnabled(true); - ui->act_acquire->setEnabled(true); - ui->act_scannerSettings->setEnabled(true); - m_dialogLog->updateStatus(true, false); - } - } - else - { - m_isScanning = true; - m_thumb->setAcceptDrops(false); - m_dialogLog->updateStatus(dev_que_.is_online() && 0 != m_scanType, m_isScanning); - updateActionStatus(); - } - - m_dialogLog->show(); -} - -void MainWindow::on_act_acquireSingle_triggered() -{ - if(!isLimitAccessFolder(1)) - { - return; - } - - if (!dev_que_.is_online() || m_isScanning) - { - return; - } - - int count = 0; - m_thumb->getItemCount(&count); - if (count != 0) - { - int result = startScanMessageBox(this); - if (cancelScan == result) - return; - } - - m_singleScan = true; - m_scanType = 1; - m_scanInsertPos = -1; - - startSaveMessageBox(this); - - m_dpi = getDpi(); - SANE_Status ret = sane_io_control(dev_que_.handle(), IO_CTRL_CODE_TEST_SINGLE, nullptr, nullptr); - if (ret != SANE_STATUS_GOOD) - { - m_dialogLog->updateStatus(dev_que_.is_online() && 0 != m_scanType, m_isScanning); - m_wndStatusBar->setDeviceStatusInfo(tr("start failed"), true); - m_dialogLog->addLog(tr("start failed") + "(" + QString(sane_err_desc(ret)) + ")", true); - HGBase_WriteInfo(HGBASE_INFOTYPE_ERROR, "%s", getStdString(tr("start failed")).c_str()); - - if(ret == SCANNER_ERR_DEVICE_SLEEPING) - { - ui->menu_scan->setEnabled(false); - ui->act_acquire->setEnabled(false); - ui->act_scannerSettings->setEnabled(false); - m_dialogLog->updateStatus(false, false); - m_dialogLog->show(); - - if (m_devVersionNum < "G4393B1001" - && ("439" == m_devPid || "9220" == m_devPid || "8529" == m_devPid)) - { - m_dialogLog->addLog(tr("Please wake up the device manually"), true); - m_wndStatusBar->setDeviceStatusInfo(tr("Please wake up the device manually"), true); - } - else - { - QTime curTimer = QTime::currentTime().addMSecs(10000); - while (QTime::currentTime() < curTimer) - { - QCoreApplication::processEvents(QEventLoop::AllEvents, 100); - } - - m_dialogLog->addLog(tr("already waked up device"), false); - m_wndStatusBar->setDeviceStatusInfo(tr("already waked up device"), false); - } - - ui->menu_scan->setEnabled(true); - ui->act_acquire->setEnabled(true); - ui->act_scannerSettings->setEnabled(true); - m_dialogLog->updateStatus(true, false); - } - } - else - { - m_isScanning = true; - m_thumb->setAcceptDrops(false); - m_dialogLog->updateStatus(dev_que_.is_online() && 0 != m_scanType, m_isScanning); - updateActionStatus(); - } - - m_dialogLog->show(); -} - -void MainWindow::on_act_acquireInto_triggered() -{ - if (!dev_que_.is_online() || m_isScanning) - { - return; - } - - int count = 0; - m_thumb->getItemCount(&count); - if (count != 0) - { - int result = startScanMessageBox(this); - if (cancelScan == result) - return; - } - - Dialog_AquireInto dlg(this); - - connect(&dlg, SIGNAL(reloadAcquireIntoCfg()), this, SLOT(on_reloadAcquireIntoCfg())); - - if (dlg.exec()) - { - m_singleScan = false; - m_scanType = 2; - m_aquireIntoSaveParam = dlg.getSaveParam(); - m_aquireIntoInBlank = true; - m_aquireIntoBatchStartIndex = 0; - m_aquireIntoPageIndex = 0; - m_aquireIntoMultiPageCount = 0; - - QDateTime dateTime = QDateTime::currentDateTime(); - if (m_aquireIntoSaveParam.m_isUseSubfolderByTime) - { - m_aquireIntoSaveParam.m_savePath = getStdFileName(m_aquireIntoSaveParam.m_savePath + dateTime.toString("yyyy-MM-dd") + "/"); - } - -// m_aquireIntoSaveParam.m_savePath = getStdFileName(m_aquireIntoSaveParam.m_savePath + dateTime.toString("yyyyMMddhhmmss") + "/"); - - - if(!isLimitAccessFolder(2)) - { - return; - } - - startSaveMessageBox(this); - - m_dpi = getDpi(); - SANE_Status ret = sane_start(dev_que_.handle()); - if (ret != SANE_STATUS_GOOD) - { - m_dialogLog->updateStatus(dev_que_.is_online() && 0 != m_scanType, m_isScanning); - m_wndStatusBar->setDeviceStatusInfo(tr("start failed"), true); - m_dialogLog->addLog(tr("start failed") + "(" + QString(sane_err_desc(ret)) + ")", true); - HGBase_WriteInfo(HGBASE_INFOTYPE_ERROR, "%s", getStdString(tr("start failed")).c_str()); - - if(ret == SCANNER_ERR_DEVICE_SLEEPING) - { - ui->menu_scan->setEnabled(false); - ui->act_acquire->setEnabled(false); - ui->act_scannerSettings->setEnabled(false); - m_dialogLog->updateStatus(false, false); - m_dialogLog->show(); - - if (m_devVersionNum < "G4393B1001" - && ("439" == m_devPid || "9220" == m_devPid || "8529" == m_devPid)) - { - m_dialogLog->addLog(tr("Please wake up the device manually"), true); - m_wndStatusBar->setDeviceStatusInfo(tr("Please wake up the device manually"), true); - } - else - { - QTime curTimer = QTime::currentTime().addMSecs(10000); - while (QTime::currentTime() < curTimer) - { - QCoreApplication::processEvents(QEventLoop::AllEvents, 100); - } - - m_dialogLog->addLog(tr("already waked up device"), false); - m_wndStatusBar->setDeviceStatusInfo(tr("already waked up device"), false); - } - - ui->menu_scan->setEnabled(true); - ui->act_acquire->setEnabled(true); - ui->act_scannerSettings->setEnabled(true); - m_dialogLog->updateStatus(true, false); - } - } - else - { - m_isScanning = true; - m_thumb->setAcceptDrops(false); - m_dialogLog->updateStatus(dev_que_.is_online() && 0 != m_scanType, m_isScanning); - updateActionStatus(); - } - - m_dialogLog->show(); - } -} - -void MainWindow::on_act_insertFromScanner_triggered() -{ - if(!isLimitAccessFolder(1)) - { - return; - } - - if (!dev_que_.is_online() || m_isScanning) - { - return; - } - - Dialog_InsertIndex dlg(this); - if (dlg.exec()) - { - m_singleScan = false; - m_scanType = 1; - m_scanInsertPos = -1; - - int count = 0; - m_thumb->getItemCount(&count); - switch (dlg.selectedLocation()) - { - case 0: - m_scanInsertPos = 0; - break; - case 1: - if (-1 != m_currIndex) - m_scanInsertPos = m_currIndex; - break; - case 2: - if (-1 != m_currIndex) - m_scanInsertPos = m_currIndex + 1; - break; - case 3: - m_scanInsertPos = count; - break; - } - - startSaveMessageBox(this); - - m_dpi = getDpi(); - SANE_Status ret = sane_start(dev_que_.handle()); - if (ret != SANE_STATUS_GOOD) - { - m_dialogLog->updateStatus(dev_que_.is_online() && 0 != m_scanType, m_isScanning); - m_wndStatusBar->setDeviceStatusInfo(tr("start failed"), true); - m_dialogLog->addLog(tr("start failed") + "(" + QString(sane_err_desc(ret)) + ")", true); - HGBase_WriteInfo(HGBASE_INFOTYPE_ERROR, "%s", getStdString(tr("start failed")).c_str()); - - if(ret == SCANNER_ERR_DEVICE_SLEEPING) - { - ui->menu_scan->setEnabled(false); - ui->act_acquire->setEnabled(false); - ui->act_scannerSettings->setEnabled(false); - m_dialogLog->updateStatus(false, false); - m_dialogLog->show(); - - if (m_devVersionNum < "G4393B1001" - && ("439" == m_devPid || "9220" == m_devPid || "8529" == m_devPid)) - { - m_dialogLog->addLog(tr("Please wake up the device manually"), true); - m_wndStatusBar->setDeviceStatusInfo(tr("Please wake up the device manually"), true); - } - else - { - QTime curTimer = QTime::currentTime().addMSecs(10000); - while (QTime::currentTime() < curTimer) - { - QCoreApplication::processEvents(QEventLoop::AllEvents, 100); - } - - m_dialogLog->addLog(tr("already waked up device"), false); - m_wndStatusBar->setDeviceStatusInfo(tr("already waked up device"), false); - } - - ui->menu_scan->setEnabled(true); - ui->act_acquire->setEnabled(true); - ui->act_scannerSettings->setEnabled(true); - m_dialogLog->updateStatus(true, false); - } - } - else - { - m_isScanning = true; - m_thumb->setAcceptDrops(false); - m_dialogLog->updateStatus(dev_que_.is_online() && 0 != m_scanType, m_isScanning); - updateActionStatus(); - } - - m_dialogLog->show(); - } -} - - -void MainWindow::on_act_imageEdit_triggered() -{ - HGImage img = nullptr; - m_view->getImage(&img); - if (nullptr == img) - { - return; - } - - HGUInt xDpi = 0; - HGUInt yDpi = 0; - HGBase_GetImageDpi(img, &xDpi, &yDpi); - - HGImageInfo info; - HGBase_GetImageInfo(img, &info); - - QImage::Format fmt = QImage::Format_Invalid; - if (info.type == HGBASE_IMGTYPE_BINARY) - fmt = QImage::Format_Mono; - else if (info.type == HGBASE_IMGTYPE_GRAY) - fmt = QImage::Format_Grayscale8; - else if (info.type == HGBASE_IMGTYPE_RGB) - fmt = QImage::Format_RGB888; - else if (info.type == HGBASE_IMGTYPE_RGBA) - fmt = QImage::Format_RGBA8888; - if (QImage::Format_Invalid == fmt) - { - return; - } - - HGByte *data = nullptr; - HGBase_GetImageData(img, &data); - QImage image(data, (int)info.width, (int)info.height, (int)info.widthStep, fmt); - if (image.isNull()) - { - return; - } - - Dialog_ImageEditor dlg(this); - dlg.setImage(image); - if (dlg.exec()) - { - QImage image = dlg.exportImage(); - if (!image.isNull()) - { - info.width = (HGUInt)image.width(); - info.height = (HGUInt)image.height(); - info.type = 0; - if (QImage::Format_Mono == image.format()) - info.type = HGBASE_IMGTYPE_BINARY; - else if (QImage::Format_Grayscale8 == image.format()) - info.type = HGBASE_IMGTYPE_GRAY; - else if (QImage::Format_RGB888 == image.format()) - info.type = HGBASE_IMGTYPE_RGB; - else if (QImage::Format_RGBA8888 == image.format()) - info.type = HGBASE_IMGTYPE_RGBA; - info.widthStep = (HGUInt)image.bytesPerLine(); - info.origin = HGBASE_IMGORIGIN_TOP; - - HGImage img = nullptr; - HGBase_CreateImageWithData((HGByte *)image.bits(), &info, &img); - if (nullptr != img) - { - HGBase_SetImageDpi(img, xDpi, yDpi); - m_view->addImage(img); - m_widget_sideBar->setImage(img); - m_widget_sideBar->enableUI(false); - m_bSideEditing = false; - HGBase_DestroyImage(img); - m_modify = true; - - updateStatusBarPixelInfo(); - updateActionStatus(); - - if (auto_save_changes_) - { - on_act_save_triggered(); - } - } - } - } -} - -bool MainWindow::open_scanner(const QString& name, const QString& scheme) -{ - bool ret = dev_que_.open_scanner(name.toStdString().c_str(), scheme.toStdString().c_str()) == SANE_STATUS_GOOD; - QString info(tr("open scanner ") + " " + name + " "); - - if(ret) - { - m_currDeviceName = name; - info += tr("success"); - m_wndStatusBar->setDeviceStatusInfo(info, false); - m_dialogLog->addLog(info, false); - HGBase_WriteInfo(HGBASE_INFOTYPE_DESC, "%s", getStdString(info).c_str()); - - m_wndStatusBar->setDeviceStatusInfo(tr("be ready"), false); - } - else - { - info += tr("failed"); - m_wndStatusBar->setDeviceStatusInfo(info, true); - m_dialogLog->addLog(info, true); - HGBase_WriteInfo(HGBASE_INFOTYPE_ERROR, "%s", getStdString(info).c_str()); - } - - m_dialogLog->updateStatus(dev_que_.is_online() && 0 != m_scanType, m_isScanning); - updateActionStatus(); - return ret; -} - -bool MainWindow::judgeDiskSpace(QString currentPath, bool showDlg) -{ - QStorageInfo storage = QStorageInfo::root(); - storage.refresh(); - storage.device(); - storage.setPath(currentPath); - - qint64 available_size = 0; - available_size = storage.bytesAvailable()/1024/1024; - if(available_size < 64) - { - if (showDlg) - { - QString info = tr("the disk space in the current path is unsufficient, please select a new path or clear the disk space in time."); - m_wndStatusBar->setDeviceStatusInfo(info, true); - m_dialogLog->addLog(info, true); - HGBase_WriteInfo(HGBASE_INFOTYPE_ERROR, "disk space is unsufficient!"); - QMessageBox::warning(this, tr("warning"), info); - } - - return false; - } - return true; -} - -void MainWindow::upgradeApp(QString pkgPath) -{ - HGChar moduleName[256]; - HGBase_GetModuleName(nullptr, moduleName, 256); - HGChar curPath2[256]; - HGBase_GetFilePath(moduleName, curPath2, 256); - QString curPath(curPath2); - HGChar tmpPath2[256]; - HGBase_GetTmpPath(tmpPath2, 256); - QString tmpPath(tmpPath2); - -#if defined(HG_CMP_MSC) -// #if defined(OEM_HANWANG) -// QFile::remove(tmpPath + "HwUpgradeApp.exe"); -// QFile::copy(curPath + "HwUpgradeApp.exe", tmpPath + "HwUpgradeApp.exe"); -// QFile::remove(tmpPath + "HwBase.dll"); -// QFile::copy(curPath + "HwBase.dll", tmpPath + "HwBase.dll"); -// QFile::remove(tmpPath + "HwVersion.dll"); -// QFile::copy(curPath + "HwVersion.dll", tmpPath + "HwVersion.dll"); -// #elif defined(OEM_LISICHENG) -// QFile::remove(tmpPath + "LscUpgradeApp.exe"); -// QFile::copy(curPath + "LscUpgradeApp.exe", tmpPath + "LscUpgradeApp.exe"); -// QFile::remove(tmpPath + "LscBase.dll"); -// QFile::copy(curPath + "LscBase.dll", tmpPath + "LscBase.dll"); -// QFile::remove(tmpPath + "LscVersion.dll"); -// QFile::copy(curPath + "LscVersion.dll", tmpPath + "LscVersion.dll"); -// #elif defined(OEM_CANGTIAN) -// QFile::remove(tmpPath + "CtsUpgradeApp.exe"); -// QFile::copy(curPath + "CtsUpgradeApp.exe", tmpPath + "CtsUpgradeApp.exe"); -// QFile::remove(tmpPath + "CtsBase.dll"); -// QFile::copy(curPath + "CtsBase.dll", tmpPath + "CtsBase.dll"); -// QFile::remove(tmpPath + "CtsVersion.dll"); -// QFile::copy(curPath + "CtsVersion.dll", tmpPath + "CtsVersion.dll"); -// #elif defined(OEM_ZHONGJING) -// QFile::remove(tmpPath + "ZJUpgradeApp.exe"); -// QFile::copy(curPath + "ZJUpgradeApp.exe", tmpPath + "ZJUpgradeApp.exe"); -// QFile::remove(tmpPath + "ZJBase.dll"); -// QFile::copy(curPath + "ZJBase.dll", tmpPath + "ZJBase.dll"); -// QFile::remove(tmpPath + "ZJVersion.dll"); -// QFile::copy(curPath + "ZJVersion.dll", tmpPath + "ZJVersion.dll"); -// #elif defined(OEM_ZIGUANG) -// QFile::remove(tmpPath + "ZGUpgradeApp.exe"); -// QFile::copy(curPath + "ZGUpgradeApp.exe", tmpPath + "ZGUpgradeApp.exe"); -// QFile::remove(tmpPath + "ZGBase.dll"); -// QFile::copy(curPath + "ZGBase.dll", tmpPath + "ZGBase.dll"); -// QFile::remove(tmpPath + "ZGVersion.dll"); -// QFile::copy(curPath + "ZGVersion.dll", tmpPath + "ZGVersion.dll"); -// #elif defined(OEM_DELI) -// QFile::remove(tmpPath + "DLUpgradeApp.exe"); -// QFile::copy(curPath + "DLUpgradeApp.exe", tmpPath + "DLUpgradeApp.exe"); -// QFile::remove(tmpPath + "DLBase.dll"); -// QFile::copy(curPath + "DLBase.dll", tmpPath + "DLBase.dll"); -// QFile::remove(tmpPath + "DLVersion.dll"); -// QFile::copy(curPath + "DLVersion.dll", tmpPath + "DLVersion.dll"); -// #else - QFile::remove(tmpPath + "HGUpgradeApp.exe"); - QFile::copy(curPath + "HGUpgradeApp.exe", tmpPath + "HGUpgradeApp.exe"); - QFile::remove(tmpPath + "HGBase.dll"); - QFile::copy(curPath + "HGBase.dll", tmpPath + "HGBase.dll"); - QFile::remove(tmpPath + "HGVersion.dll"); - QFile::copy(curPath + "HGVersion.dll", tmpPath + "HGVersion.dll"); -// #endif - - QFile::remove(tmpPath + "msvcp140.dll"); - QFile::copy(curPath + "msvcp140.dll", tmpPath + "msvcp140.dll"); - QFile::remove(tmpPath + "Qt5Core.dll"); - QFile::copy(curPath + "Qt5Core.dll", tmpPath + "Qt5Core.dll"); - QFile::remove(tmpPath + "Qt5Gui.dll"); - QFile::copy(curPath + "Qt5Gui.dll", tmpPath + "Qt5Gui.dll"); - QFile::remove(tmpPath + "Qt5Widgets.dll"); - QFile::copy(curPath + "Qt5Widgets.dll", tmpPath + "Qt5Widgets.dll"); - QFile::remove(tmpPath + "vcruntime140.dll"); - QFile::copy(curPath + "vcruntime140.dll", tmpPath + "vcruntime140.dll"); - QFile::remove(tmpPath + "concrt140.dll"); - QFile::copy(curPath + "concrt140.dll", tmpPath + "concrt140.dll"); - QFile::remove(tmpPath + "vcruntime140_1.dll"); - QFile::copy(curPath + "vcruntime140_1.dll", tmpPath + "vcruntime140_1.dll"); - QDir dir; - dir.mkdir(tmpPath + "platforms"); - QFile::remove(tmpPath + "platforms/qwindows.dll"); - QFile::copy(curPath + "platforms/qwindows.dll", tmpPath + "platforms/qwindows.dll"); - dir.mkdir(tmpPath + "imageformats"); - QFile::remove(tmpPath + "imageformats/qgif.dll"); - QFile::copy(curPath + "imageformats/qgif.dll", tmpPath + "imageformats/qgif.dll"); -#else -// #if defined(OEM_HANWANG) -// QFile::remove(tmpPath + "HwUpgradeApp"); -// QFile::copy(curPath + "HwUpgradeApp", tmpPath + "HwUpgradeApp"); -// QFile::remove(tmpPath + "libHwBase.so"); -// QFile::copy(curPath + "libHwBase.so", tmpPath + "libHwBase.so"); -// QFile::remove(tmpPath + "libHwVersion.so"); -// QFile::copy(curPath + "libHwVersion.so", tmpPath + "libHwVersion.so"); -// #elif defined(OEM_LISICHENG) -// QFile::remove(tmpPath + "LscUpgradeApp"); -// QFile::copy(curPath + "LscUpgradeApp", tmpPath + "LscUpgradeApp"); -// QFile::remove(tmpPath + "libLscBase.so"); -// QFile::copy(curPath + "libLscBase.so", tmpPath + "libLscBase.so"); -// QFile::remove(tmpPath + "libLscVersion.so"); -// QFile::copy(curPath + "libLscVersion.so", tmpPath + "libLscVersion.so"); -// #elif defined(OEM_CANGTIAN) -// QFile::remove(tmpPath + "CtsUpgradeApp"); -// QFile::copy(curPath + "CtsUpgradeApp", tmpPath + "CtsUpgradeApp"); -// QFile::remove(tmpPath + "libCtsBase.so"); -// QFile::copy(curPath + "libCtsBase.so", tmpPath + "libCtsBase.so"); -// QFile::remove(tmpPath + "libCtsVersion.so"); -// QFile::copy(curPath + "libCtsVersion.so", tmpPath + "libCtsVersion.so"); -// #elif defined(OEM_ZHONGJING) -// QFile::remove(tmpPath + "ZjUpgradeApp"); -// QFile::copy(curPath + "ZjUpgradeApp", tmpPath + "ZjUpgradeApp"); -// QFile::remove(tmpPath + "libZjBase.so"); -// QFile::copy(curPath + "libZjBase.so", tmpPath + "libZjBase.so"); -// QFile::remove(tmpPath + "libZjVersion.so"); -// QFile::copy(curPath + "libZjVersion.so", tmpPath + "libZjVersion.so"); -// #elif defined(OEM_ZIGUANG) -// QFile::remove(tmpPath + "ZgUpgradeApp"); -// QFile::copy(curPath + "ZgUpgradeApp", tmpPath + "ZgUpgradeApp"); -// QFile::remove(tmpPath + "libZgBase.so"); -// QFile::copy(curPath + "libZgBase.so", tmpPath + "libZgBase.so"); -// QFile::remove(tmpPath + "libZgVersion.so"); -// QFile::copy(curPath + "libZgVersion.so", tmpPath + "libZgVersion.so"); -// #elif defined(OEM_DELI) -// QFile::remove(tmpPath + "DlUpgradeApp"); -// QFile::copy(curPath + "DlUpgradeApp", tmpPath + "DlUpgradeApp"); -// QFile::remove(tmpPath + "libDlBase.so"); -// QFile::copy(curPath + "libDlBase.so", tmpPath + "libDlBase.so"); -// QFile::remove(tmpPath + "libDlVersion.so"); -// QFile::copy(curPath + "libDlVersion.so", tmpPath + "libDlVersion.so"); -// #else - QFile::remove(tmpPath + "HGUpgradeApp"); - QFile::copy(curPath + "HGUpgradeApp", tmpPath + "HGUpgradeApp"); - //QFile::remove(tmpPath + "libHGBase.so"); - //QFile::copy(curPath + "libHGBase.so", tmpPath + "libHGBase.so"); - //QFile::remove(tmpPath + "libHGVersion.so"); - //QFile::copy(curPath + "libHGVersion.so", tmpPath + "libHGVersion.so"); -// #endif -#endif - - QProcess proc; - bool isSuccessdStart = false; - - QStringList argList; - argList.push_back(QString("-appName=%1").arg(HGVERSION_APPNAME_SCANNER)); - argList.push_back(QString("-oemName=%1").arg(m_oemName)); - argList.push_back(QString("-pkgpath=%1").arg(pkgPath.toStdString().c_str())); - argList.push_back(QString("-type=%1").arg("upgrade")); - argList.push_back(QString("-language=%1").arg(m_currLang.toStdString().c_str())); - -#if defined(HG_CMP_MSC) -// #if defined(OEM_HANWANG) -// isSuccessdStart = proc.startDetached(tmpPath + "HwUpgradeApp.exe", argList); -// #elif defined(OEM_LISICHENG) -// isSuccessdStart = proc.startDetached(tmpPath + "LscUpgradeApp.exe", argList); -// #elif defined(OEM_CANGTIAN) -// isSuccessdStart = proc.startDetached(tmpPath + "CtsUpgradeApp.exe", argList); -// #elif defined(OEM_ZHONGJING) -// isSuccessdStart = proc.startDetached(tmpPath + "ZJUpgradeApp.exe", argList); -// #elif defined(OEM_ZIGUANG) -// isSuccessdStart = proc.startDetached(tmpPath + "ZGUpgradeApp.exe", argList); -// #elif defined(OEM_DELI) -// isSuccessdStart = proc.startDetached(tmpPath + "DLUpgradeApp.exe", argList); -// #else - isSuccessdStart = proc.startDetached(tmpPath + "HGUpgradeApp.exe", argList); -// #endif -#else -// #if defined(OEM_HANWANG) -// isSuccessdStart = proc.startDetached(tmpPath + "HwUpgradeApp", argList); -// #elif defined(OEM_LISICHENG) -// isSuccessdStart = proc.startDetached(tmpPath + "LscUpgradeApp", argList); -// #elif defined(OEM_CANGTIAN) -// isSuccessdStart = proc.startDetached(tmpPath + "CtsUpgradeApp", argList); -// #elif defined(OEM_ZHONGJING) -// isSuccessdStart = proc.startDetached(tmpPath + "ZjUpgradeApp", argList); -// #elif defined(OEM_ZIGUANG) -// isSuccessdStart = proc.startDetached(tmpPath + "ZgUpgradeApp", argList); -// #else - isSuccessdStart = proc.startDetached(tmpPath + "HGUpgradeApp", argList); -// #endif -#endif - - if (isSuccessdStart) - { - m_closeTip = false; - close(); - } - else - { - QMessageBox msg(QMessageBox::Critical, tr("error"), - tr("start failed!"), - QMessageBox::Ok, this); - msg.exec(); - } -} - -bool MainWindow::isLimitAccessFolder(int type) -{ - QString cachePath = Dialog_ClrCache::getCachePath(); - QString aquireIntoPath = m_aquireIntoSaveParam.m_savePath; - QString filePath; - - HGChar uuid[512]; - HGBase_GetUuid(uuid, 512); - - if (1 == type) - { - filePath = cachePath + uuid; - } - else if (2 == type) - { - filePath = aquireIntoPath + uuid; - } - - HGResult ret = HGBase_CreateDir(getStdString(filePath).c_str()); - if (ret != HGBASE_ERR_OK) - { - QString info; - if (1 == type) - { - info = tr("cache path folder limit:%1").arg(cachePath); - } - else if (2 == type) - { - info = tr("aquireinto folder limit:%1").arg(aquireIntoPath); - } - - QMessageBox::critical(this, tr("error"), info); - m_dialogLog->addLog(info, true); - m_wndStatusBar->setDeviceStatusInfo(info, true); - return false; - } - else - { - HGBase_DeleteDir(getStdString(filePath).c_str()); - } - return true; -} - -QString MainWindow::GetDevType(const QString& fwVersion, bool &canLock) -{ - canLock = false; - - QString devType; - if (fwVersion.length() == 10) - { - QString dev = fwVersion.left(2); - if (fwVersion.mid(2, 2) == "40" || fwVersion.mid(2, 2) == "50" - || fwVersion.mid(2, 2) == "60" || fwVersion.mid(2, 2) == "70") - { - // 3288 - QString ver = fwVersion.mid(2, 2); - QString date = fwVersion.mid(4, 6); - } - else - { - // 3399 - QString ver = fwVersion.mid(2, 3); - QString date = fwVersion.mid(5, 5); - if ((dev == "G1" || dev == "G2") && ver == "393") - { - if (date >= "A1220" && date <= "A1230") - { - devType = dev + ver + "/" + "A1220-A1230"; - if (date >= "A1224") - { - canLock = true; - } - } - else if (date >= "B0326" && date <= "B0334") - { - devType = dev + ver + "/" + "B0326-B0334"; - if (date >= "B0333") - { - canLock = true; - } - } - else if (date >= "B0429") - { - devType = dev + ver + "/" + "B0429-"; - if (date >= "B1031" || date == "B0500") - { - canLock = true; - } - } - } - else if (dev == "G4" && ver == "393") - { - devType = dev + ver + "/"; - if (date >= "B1108") - { - canLock = true; - } - } - } - } - - return devType; -} - -QString MainWindow::getLogInfo(HGResult ret) -{ - QString str; - if (HGBASE_ERR_ACCESSDENIED == ret) - { - str = tr("Insufficient access rights"); - } - else if (HGIMGPROC_ERR_FAIL == ret) - { - str = tr("Image processing failed"); - } - else if (HGIMGPROC_ERR_OCRINIT == ret) - { - str = tr("Ocr init failed"); - } - else if (HGIMGPROC_ERR_OCR == ret) - { - str = tr("Ocr failed"); - } - else if (HGBASE_ERR_FILENOTEXIST == ret) - { - str = tr("File does not exist"); - } - else if (HGBASE_ERR_LOADLIBRARY == ret) - { - str = tr("Failed to load dynamic library"); - } - else if (HGBASE_ERR_FILEERROR == ret) - { - str = tr("File data error"); - } - else if (HGIMGFMT_ERR_FAIL == ret) - { - str = tr("Image format processing error"); - } - else if (HGBASE_ERR_OUTOFMEMORY == ret) - { - str = tr("Out of memory"); - } - else - { - str = tr("Failed"); - } - - return str; -} - -void MainWindow::deleteOverdueLogFile(const QString& logFilePath) -{ - QDir dir(logFilePath); - if(!dir.exists()) - { - return; - } - dir.setFilter(QDir::Files | QDir::NoSymLinks); - QFileInfoList list = dir.entryInfoList(); - - int count = list.count(); - if(count <= 0) - { - return; - } - - for(int i=0; i < count; i++) - { - QFileInfo info = list.at(i); - QString suffix = info.suffix(); - if(suffix == "log") - { - QDateTime nowTime = QDateTime::currentDateTime(); - QDateTime createTime = info.created(); - int days = createTime.daysTo(nowTime); - if (days > 14) - { - HGBase_DeleteFile(info.absoluteFilePath().toStdString().c_str()); - } - } - } -} - -void MainWindow::deleteUpgradePkg(const QString &cfgFilePath) -{ - QDir dir(cfgFilePath); - if(!dir.exists()) - { - return; - } - dir.setFilter(QDir::Files | QDir::NoSymLinks); - QFileInfoList list = dir.entryInfoList(); - - int count = list.count(); - if(count <= 0) - { - return; - } - - for(int i=0; i < count; i++) - { - QFileInfo info = list.at(i); - QString suffix = info.suffix(); - if(suffix == "exe") - { - HGBase_DeleteFile(info.absoluteFilePath().toStdString().c_str()); - } - } -} - -QString MainWindow::getDevPid() -{ - VIDPID vidpid; - int vidpid_val; - unsigned int len = sizeof(int); - sane_io_control(dev_que_.handle(), IO_CTRL_CODE_GET_VIDPID, &vidpid_val, &len); - vidpid.Value = vidpid_val; - int vid = vidpid.VID; - int pid = vidpid.PID; - char buf[10]; - char buf2[10]; - sprintf(buf, "%x", vid); - sprintf(buf2, "%x", pid); - return QString::fromStdString(buf2); -} - -QString MainWindow::getDevSerialNum() -{ - std::string serialNum; - unsigned int serialNumLen = 0; - if(SANE_STATUS_NO_MEM == sane_io_control(dev_que_.handle(), IO_CTRL_CODE_GET_SERIAL, nullptr, &serialNumLen) - && serialNumLen) - { - serialNum.resize(serialNumLen); - sane_io_control(dev_que_.handle(), IO_CTRL_CODE_GET_SERIAL, &serialNum[0], &serialNumLen); - } - return QString::fromStdString(serialNum.c_str()); -} - -QString MainWindow::getDevFwVersionNum() -{ - std::string versionNum; - unsigned int versionNumLen = 0; - if(SANE_STATUS_NO_MEM == sane_io_control(dev_que_.handle(), IO_CTRL_CODE_GET_HARDWARE_VERSION, nullptr, &versionNumLen) - && versionNumLen) - { - versionNum.resize(versionNumLen); - sane_io_control(dev_que_.handle(), IO_CTRL_CODE_GET_HARDWARE_VERSION, &versionNum[0], &versionNumLen); - } - return QString::fromStdString(versionNum.c_str()); -} - -void MainWindow::initAcquireIntoComboBox() -{ - m_cbtn_acquireIntoCfg = new QComboBox; - - m_cbtn_acquireIntoCfg->setFixedWidth(150); - ui->toolBar->addWidget(m_cbtn_acquireIntoCfg); - m_cbtn_acquireIntoCfg->addItem(tr("default scheme")); - QString allCfgName = getCfgValue("aquire", "cfgNameList", QString("")); - QStringList allCfgNameList = allCfgName.split(","); - if (!allCfgNameList.contains(QString(""))) - { - m_cbtn_acquireIntoCfg->addItems(allCfgNameList); - m_cbtn_acquireIntoCfg->setCurrentText(getCfgValue("aquire", "currentKeyName", QString("aquire"))); - } - else - { - allCfgNameList.removeOne(QString("")); - m_cbtn_acquireIntoCfg->setCurrentIndex(0); - } - - connect(m_cbtn_acquireIntoCfg, SIGNAL(currentTextChanged(QString)), this, SLOT(on_m_acquireIntoCfg_changed(QString))); -} - -void MainWindow::updateSideBar() -{ - int mainWndWidth = this->rect().width(); - int mainWndHeight = this->rect().height(); - int sideBarHeight = m_widget_sideBar->height(); - - m_widget_sideBar->move(mainWndWidth, mainWndHeight/2 - sideBarHeight/2); - m_pbtn_push->move(mainWndWidth - m_pbtn_push->width(), mainWndHeight/2 - m_pbtn_push->height()/2); - - m_propertyAnimation = new QPropertyAnimation(m_widget_sideBar, "geometry"); - m_propertyAnimation->setEasingCurve(QEasingCurve::InOutSine); - m_propertyAnimation->setDuration(600); - m_propertyAnimation2 = new QPropertyAnimation(m_pbtn_push, "geometry"); - m_propertyAnimation2->setEasingCurve(QEasingCurve::InOutSine); - m_propertyAnimation2->setDuration(600); -} - -void MainWindow::on_scanOptions_changed(const QString &device, const QString &option, bool checked_now) -{ - QString title(tr("app name")); - if(checked_now) - { - std::string curdev(dev_que_.opened_scanner_name()); - int ret = 0; - if(curdev != device.toStdString()) - { - //ret = dev_que_.open_scanner(device.toStdString().c_str(), option.toStdString().c_str()); - open_scanner(device, option); - return; - } - else { - ret = dev_que_.apply_scheme(option.toStdString().c_str()); - } - - QString info(tr("apply setting") + " '" + option + "' "); - if(ret == 0) - { - info += tr("success"); - } - else - { - ui->menu_device->setOptionChecked(device, option, false); - info += tr("failed"); - } - - m_wndStatusBar->setDeviceStatusInfo(info, ret != 0); - m_dialogLog->addLog(info, ret != 0); - HGBase_WriteInfo(ret != 0 ? HGBASE_INFOTYPE_ERROR : HGBASE_INFOTYPE_DESC, "%s", getStdString(info).c_str()); - title = device + "(" + option + ")"; - } - else - { - QMessageBox msg(QMessageBox::Question, title, - tr("Are you sure to close ") + device + tr(" ?"), - QMessageBox::Yes | QMessageBox::No, this); - msg.exec(); - if(msg.clickedButton() == msg.button(QMessageBox::Yes)) - { - dev_que_.close_scanner(); - m_versionDll->PostDeviceCloseInfo(device.toStdString().c_str(), m_devSerialNum.toStdString().c_str(), "", m_devVersionNum.toStdString().c_str()); - - m_dialogLog->addLog(tr("close ") + device, false); - m_wndStatusBar->setDeviceStatusInfo(tr("close ") + device, false); - } - else { - ui->menu_device->setOptionChecked(device, option, true); - return; - } - } - - m_dialogLog->updateStatus(dev_que_.is_online() && 0 != m_scanType, m_isScanning); - updateActionStatus(); - // setWindowTitle(title); -} - -void MainWindow::on_act_sortPages_triggered() -{ - if (dev_que_.is_online() && m_isScanning) - { - return; - } - - m_thumb->bookSort(); -} - -void MainWindow::on_actionact_update_triggered() -{ - HGVersionInfo *versionInfo = NULL; - HGUInt versionCount = 0; - HGResult ret = m_versionDll->GetVersionList(HGVERSION_APPNAME_SCANNER, m_oemName, &versionInfo, &versionCount); - if (ret != HGBASE_ERR_OK) - { - HGBase_WriteInfo(HGBASE_INFOTYPE_ERROR, "GetVersionList:%u", ret); - } - if(versionCount > 0) - { - Dialog_upgrade dlg(m_versionDll, versionInfo, this); - if (dlg.exec()) - { - QString url, md5; - - QString versionNum = dlg.getVersionNum(); - for (HGUInt i = 0; i < versionCount; ++i) - { - if (versionNum == versionInfo[i].version) - { - url = versionInfo[i].url; - md5 = versionInfo[i].md5; - break; - } - } - - assert(!url.isEmpty() && !md5.isEmpty()); - - HGChar suffix[64]; - HGBase_GetFileSuffix(url.toStdString().c_str(), suffix, 64); - - HGChar savePath[512]; - HGBase_GetConfigPath(savePath, 512); - HGBase_CreateDir(savePath); - - HGChar fileName[128]; - sprintf(fileName, "%s.%s", versionNum.toStdString().c_str(), suffix); - strcat(savePath, fileName); - - QFile saveFile(savePath); - saveFile.open(QFile::ReadOnly); - QByteArray fileMsg = saveFile.readAll(); - saveFile.close(); - QString md5_2 = QCryptographicHash::hash(fileMsg , QCryptographicHash::Md5).toHex(); - - QFile f(savePath); - if(!f.exists() || md5 != md5_2) - { - Dialog_updateProgress dlg(m_versionDll, url, savePath, this); - if (dlg.exec()) - { - QFile saveFile(savePath); - saveFile.open(QFile::ReadOnly); - QByteArray fileMsg = saveFile.readAll(); - saveFile.close(); - QString md5_2 = QCryptographicHash::hash(fileMsg , QCryptographicHash::Md5).toHex(); - - if (md5 == md5_2) - { - upgradeApp(savePath); - } - } - } - else - { - upgradeApp(savePath); - } - } - } - else - { - QMessageBox::information(this, tr("tip"), tr("Other versions not available")); - } - m_versionDll->ReleaseVersionList(versionInfo, versionCount); -} - -void MainWindow::on_act_feedback_triggered() -{ - Dialog_Feedback dlg(m_versionDll, this); - dlg.exec(); -} - -void MainWindow::on_act_driver_log_triggered() -{ - char log_file_path[260] = {0}; - unsigned int type = SANE_LogFileType::LOG_FILE_DRIVER; - SANE_Status statu = sane_io_control(dev_que_.handle(), IO_CTRL_CODE_GET_LOG_FILE, log_file_path, &type); - if(statu == SANE_STATUS_GOOD) - { - if(log_file_path[0]) - QDesktopServices::openUrl(QUrl::fromLocalFile(log_file_path)); - } - else { - if(statu == SANE_STATUS_UNSUPPORTED) // 鐠佹儳顦稉宥嗘暜閹镐浇顕氶幙宥勭稊 - QMessageBox::information(this, windowTitle(), tr("The device does not support this operation")); - else - QMessageBox::information(this, windowTitle(), tr("IO error")); // IO闁挎瑨顕? - } -} - -void MainWindow::on_act_device_log_triggered() -{ - char log_file_path[260] = {0}; - unsigned int type = SANE_LogFileType::LOG_FILE_DEVICE; - SANE_Status statu = sane_io_control(dev_que_.handle(), IO_CTRL_CODE_GET_LOG_FILE, log_file_path, &type); - if(statu == SANE_STATUS_GOOD) - { - if(log_file_path[0]) - QDesktopServices::openUrl(QUrl::fromLocalFile(log_file_path)); - } - else { - if(statu == SANE_STATUS_UNSUPPORTED) - QMessageBox::information(this, windowTitle(), tr("The device does not support this operation")); - else - QMessageBox::information(this, windowTitle(), tr("IO error")); - } - -} - -void MainWindow::on_act_simpCN_triggered() -{ - m_act_simpCN->setChecked(true); - m_act_English->setChecked(false); - - if (m_currLang == "chinese") - { - return; - } - - m_currLang = "chinese"; - saveCfgValue("global", "language", m_currLang); - - QMessageBox msg(QMessageBox::Information, tr("tips"), - tr("The language switch is successful and takes effect the next time the software is started!"), - QMessageBox::Ok, this); - msg.exec(); -} - -void MainWindow::on_act_English_triggered() -{ - m_act_simpCN->setChecked(false); - m_act_English->setChecked(true); - - if (m_currLang == "english") - { - return; - } - - m_currLang = "english"; - saveCfgValue("global", "language", m_currLang); - - QMessageBox msg(QMessageBox::Information, tr("tips"), - tr("The language switch is successful and takes effect the next time the software is started!"), - QMessageBox::Ok, this); - msg.exec(); -} - -void MainWindow::on_act_deleteFile_triggered() -{ - if (m_isScanning) - { - return; - } - - std::vector selectIndexs; - int count = 0; - m_thumb->getItemCount(&count); - for (int i = 0; i < count; ++i) - { - bool select = false; - m_thumb->itemIsSelect(i, &select); - if (select) - selectIndexs.push_back(i); - } - - if (selectIndexs.empty()) - { - return; - } - - if (-1 != m_currIndex) - { - bool select = false; - m_thumb->itemIsSelect(m_currIndex, &select); - if (select) - { - startSaveMessageBox(this); - } - } - - QMessageBox msg(QMessageBox::Question, tr("tips"), tr("Are you sure to delete selected file?"), - QMessageBox::Yes | QMessageBox::No, this); - msg.exec(); - if (msg.clickedButton() == msg.button(QMessageBox::Yes)) - { - m_thumb->removeItems(selectIndexs, HGImgThumb::ThumbRemoveFlag_Delete); - } -} diff --git a/app/scanner/mainwindow.h b/app/scanner/mainwindow.h deleted file mode 100644 index 17730ac1..00000000 --- a/app/scanner/mainwindow.h +++ /dev/null @@ -1,356 +0,0 @@ -#ifndef MAINWINDOW_H -#define MAINWINDOW_H - -#include -#include -#include -#include -#include -#include -#include "HGImgView.h" -#include "HGImgThumb.h" -#include "sane/sane_ex.h" -#include "dialog_aquireinto.h" -#include "widget_imgproc_base.h" -#include "widget_imgproc_sidebar.h" -#include "imgfmt/HGImgFmt.h" -#include "VersionDll.h" -#include "device_menu.h" -#include "sane_device.h" - -QT_BEGIN_NAMESPACE -namespace Ui { class MainWindow; } -QT_END_NAMESPACE - -class HGLineEdit : public QLineEdit -{ - Q_OBJECT -public: - HGLineEdit(QWidget* parent) - : QLineEdit(parent) - { - - } - -protected: - void focusInEvent(QFocusEvent* e) - { - (void)e; - QString text = this->text(); - QStringList list = text.split("/"); - text = list.first(); - this->setText(text); - this->selectAll(); - - QLineEdit::focusInEvent(e); - } -}; - -enum askIfClear -{ - cancelScan = 0, - clearAndScan, - notClearAndScan -}; - -//class dialog_wrong_img; - -class MainWindow : public QMainWindow -{ - Q_OBJECT - std::vector wrong_imgs_; - -public: - MainWindow(const QString& appLang, QWidget *parent = nullptr); - virtual ~MainWindow() override; - - void exitFullScreen(); - static HGResult saveImage(HGImage image, const HGImgFmtSaveInfo* info, bool ocr, int ocrLanguageType, const HGChar *fileName); - static QString getLogInfo(HGResult ret); - -private slots: - void on_act_90Left_triggered(); - - void on_act_90Right_triggered(); - - void on_act_180_triggered(); - - void on_act_fitWindowSize_triggered(); - - void on_act_fitWindowWidth_triggered(); - - void on_act_realSize_triggered(); - - void on_act_zoomIn_triggered(); - - void on_act_zoomOut_triggered(); - - void on_act_statusBar_triggered(bool checked); - - void on_act_toolBar_triggered(bool checked); - - void on_act_colorInfo_triggered(bool checked); - - void on_act_fullscreen_triggered(); - - void on_act_autoSave_triggered(); - -signals: - void sane_dev_arrive(QString devName, bool opened); - void sane_dev_remove(QString devName); - void sane_dev_error(QString errorInfo); - void sane_dev_readyStatus(QString promptInfo); - void pre_new_image(void *img); - void post_new_image(unsigned int ret, int statu); - void scan_working(QString workingInfo); - void scan_finish(QString finishInfo, int err); - -private slots: - void on_AcquireInto2(); - void on_reloadAcquireIntoCfg(); - void on_m_acquireIntoCfg_changed(QString schemeName); - void on_itemCountChanged(int count); - void on_itemSelectingChanged(); - void on_currItemChanged(int index); - void on_itemDoubleClicked(int index); - void on_thumbContextMenu(int index); - void on_viewerScale(double scale); - void on_viewerMousePos(int x, int y); - void on_thumbDrop(const QObject *source, const QStringList &fileNames, int pos); - void on_viewerDrop(const QObject *source, const QStringList &fileNames); - void on_viewerDblClick(); - void on_act_moveTo_triggered(); - void on_act_thumbGrid_triggered(bool checked); - void on_dialog_adjust_applyToImage(HGImage img); - void on_dialog_multirotate_refreshImgFile(const QString &fileName); - void on_multiPageLineEditFinished(); - void on_clearCache(); - void on_sane_dev_arrive(QString devName, bool opened); - void on_sane_dev_remove(QString devName); - void on_sane_dev_error(QString errorInfo); - void on_sane_dev_readyStatus(QString promptInfo); - void on_pre_new_image(void *img); - void on_post_new_image(unsigned int ret, int statu); - void on_scan_working(QString workingInfo); - void on_scan_finish(QString finishInfo, int err); - void on_export_scanned_image(void); - void on_continueScan(); - void on_stopScan(); - void on_statusInfoDblClick(); - void on_wrong_image_decide(dialog_wrong_img* dlg, bool save); - void on_m_pbtn_push_clicked(); - void on_dialog_sideBar_applyToImage(HGImage img, int brightness, int contrast, double gamma, bool enhanceText); - void on_dialog_sideBar_finish(bool ok); - - void on_act_thumbnailBar_triggered(bool checked); - - void on_act_previous_triggered(); - - void on_act_next_triggered(); - - void on_act_first_triggered(); - - void on_act_last_triggered(); - - void on_act_openPageNum_triggered(); - - void on_act_previousPage_triggered(); - - void on_act_nextPage_triggered(); - - void on_act_firstPage_triggered(); - - void on_act_lastPage_triggered(); - - void on_act_adjust_triggered(); - - void on_act_open_triggered(); - - void on_act_insert_triggered(); - - void on_act_closeFile_triggered(); - - void on_act_closeAll_triggered(); - - void on_act_exit_triggered(); - - void on_act_save_triggered(); - - void on_act_saveAs_triggered(); - - void on_act_Export_triggered(); - - void on_act_imageInfo_triggered(); - - void on_act_multiRotate_triggered(); - - void on_act_autoCrop_triggered(); - - void on_act_signIn_triggered(); - - void on_act_passwordChange_triggered(); - - void on_act_signOut_triggered(); - - void on_act_log_triggered(); - - void on_act_clrCache_triggered(); - - void on_act_consume_triggered(); - - void on_act_clearRoller_triggered(); - - void on_act_help_triggered(); - - void on_act_about_triggered(); - - void on_act_scannerSettings_triggered(); - - void on_act_acquire_triggered(); - - void on_act_acquireSingle_triggered(); - - void on_act_acquireInto_triggered(); - - void on_act_insertFromScanner_triggered(); - - void on_act_imageEdit_triggered(); - - void on_scanOptions_changed(const QString &device, const QString &option, bool checked_now); - - void on_act_sortPages_triggered(); - - void on_actionact_update_triggered(); - - void on_act_feedback_triggered(); - - void on_act_driver_log_triggered(); - - void on_act_device_log_triggered(); - - void on_act_simpCN_triggered(); - - void on_act_English_triggered(); - - void on_act_deleteFile_triggered(); - -public slots: - void my_url_handler(const QUrl& url); - -protected: - virtual void closeEvent(QCloseEvent *e) override; - virtual void resizeEvent(QResizeEvent *e) override; - -private: - static int sane_ex_callback(SANE_Handle hdev, int code, void *data, unsigned int* len, void *param); - static void HGAPI CrashFunc(HGPointer crashAddr, HGPointer param); - - HGUInt getDpi(); - QString getCacheFileName(HGImage img); - HGImage createImage(); - int getMultiPageCount(); - void updateStatusBarPixelInfo(); - void updateActionStatus(); - void startSaveMessageBox(QWidget* parent); - askIfClear startScanMessageBox(QWidget* parent); - QString passwordEncrypt(const QString& password); - QString passwordDecrypt(const QString& transcode); - bool open_scanner(const QString& name, const QString& scheme); - bool judgeDiskSpace(QString currentPath, bool showDlg = true); - void upgradeApp(QString pkgPath); - bool isLimitAccessFolder(int type); //type:1-aquire,2-aquireInto - static QString GetDevType(const QString& fwVersion, bool &canLock); - void deleteOverdueLogFile(const QString& logFilePath); - void deleteUpgradePkg(const QString& cfgFilePath); - QString getDevPid(); - QString getDevSerialNum(); - QString getDevFwVersionNum(); - void initAcquireIntoComboBox(); - void updateSideBar(); - -private: - Ui::MainWindow *ui; - QAction *m_act_acquireInto2; - QComboBox *m_cbtn_acquireIntoCfg; - QString m_currLang; - VersionDll *m_versionDll; - QString m_password; - bool m_admin_loggedIn; - HGImgView *m_view; - HGImgThumb *m_thumb; - QMenu *m_thumbMenu; - QMenu* m_menu_imageInsert; - QAction *m_moveToAction; - QAction* m_act_thumbGrid; - QListWidget* m_listwidget; - QMenu *m_menu_language; - QAction *m_act_simpCN; - QAction *m_act_English; - QPushButton *m_pbtn_push; - Widget_Imgproc_SideBar *m_widget_sideBar; - QPropertyAnimation *m_propertyAnimation; - QPropertyAnimation *m_propertyAnimation2; - - dev_que dev_que_; - - bool auto_save_changes_; - bool save_from_changed_; - typedef struct _save_opt - { - QString path; - int index; - int jpegQuality; - int tiffCompressionBW; - int tiffCompression; - int tiffQuality; - bool isOcr; - }SAVEOPT; - SAVEOPT auto_save_info_; - - union VIDPID - { - struct - { - unsigned short VID; - unsigned short PID; - }; - unsigned int Value; - }; - - HGUInt m_dpi; - QString m_currFilePath; - int m_currIndex; - int m_multiPageCount; - int m_multiIndex; - bool m_modify; // m_view上面的图像是否改变 - bool m_singleScan; // 是否单张扫描 - int m_scanType; // 1-扫描到缓存目录,2-扫描到本地目录 - int m_scanInsertPos; // 扫描插入位置,-1表示插入到最后 - int m_saveType; - QString m_scanFileName; - HGImgFmtWriter m_scanImgFmtWriter; - AquireIntoSaveParam m_aquireIntoSaveParam; - bool m_aquireIntoInBlank; - int m_aquireIntoBatchStartIndex; - int m_aquireIntoPageIndex; - int m_aquireIntoMultiPageCount; - bool m_isScanning; - bool m_closeTip; - int m_currScanCount; - QString m_devSerialNum; - QString m_devVersionNum; - QString m_currDeviceName; - QString m_devPid; - const char* m_oemName; - bool m_cacheDirNotify; - bool m_AquirePathNotify; - bool m_bSideflag; - bool m_bSideEditing; - - class HGLineEdit* m_multiPageLineEdit; - class Widget_StatusBar *m_wndStatusBar; - class dialog_log *m_dialogLog; - class Dialog_AquireInto *m_dialogAcquireinto; - class Dialog_FullScreen *m_dlgFullScreen; -}; -#endif // MAINWINDOW_H diff --git a/app/scanner/mainwindow.ui b/app/scanner/mainwindow.ui deleted file mode 100644 index 30aa63f4..00000000 --- a/app/scanner/mainwindow.ui +++ /dev/null @@ -1,645 +0,0 @@ - - - MainWindow - - - - 0 - 0 - 800 - 600 - - - - Qt::NoContextMenu - - - MainWindow - - - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - - 0 - 0 - 800 - 22 - - - - - menu_file - - - true - - - - - - - - - - - - - - - - - - - - - menu_scan - - - - - - - - - - - - menu_view - - - - menu_Auto_Image_Size - - - - - - - - - - - - - - - - - - - - menu_page - - - - menu_multiPages - - - - - - - - - - - - - - - - - - menu_image - - - - menuRotate - - - - - - - - - - - - - - menu_user - - - - - - - - - - - - - - - - - menu_info - - - - - - - - - - menu_device - - - - - - - - - - - - - - - toolBar - - - TopToolBarArea - - - false - - - - - QDockWidget::NoDockWidgetFeatures - - - 1 - - - - - 0 - 0 - - - - - - - - :/images/image_rsc/actions/open.png:/images/image_rsc/actions/open.png - - - act_open - - - - - act_insert - - - - - - :/images/image_rsc/actions/save.png:/images/image_rsc/actions/save.png - - - act_save - - - - - - :/images/image_rsc/actions/saveAs.png:/images/image_rsc/actions/saveAs.png - - - act_saveAs - - - - - act_Export - - - - - - :/images/image_rsc/actions/close.png:/images/image_rsc/actions/close.png - - - act_closeFile - - - - - - :/images/image_rsc/actions/close.png:/images/image_rsc/actions/close.png - - - act_closeAll - - - - - act_imageInfo - - - - - act_exit - - - - - - :/images/image_rsc/actions/settings.png:/images/image_rsc/actions/settings.png - - - act_scannerSettings - - - - - - :/images/image_rsc/actions/scan.png:/images/image_rsc/actions/scan.png - - - act_acquire - - - - - act_acquireSingle - - - - - - :/images/image_rsc/actions/scanInto.png:/images/image_rsc/actions/scanInto.png - - - act_acquireInto - - - - - - :/images/image_rsc/actions/fullscreen.png:/images/image_rsc/actions/fullscreen.png - - - act_fullscreen - - - - - - :/images/image_rsc/actions/zoom-fitscreen.png:/images/image_rsc/actions/zoom-fitscreen.png - - - act_fitWindowSize - - - - - - :/images/image_rsc/actions/zoom-fitwidth.png:/images/image_rsc/actions/zoom-fitwidth.png - - - act_fitWindowWidth - - - - - - :/images/image_rsc/actions/zoom-origin.png:/images/image_rsc/actions/zoom-origin.png - - - act_realSize - - - - - - :/images/image_rsc/actions/zoom-in.png:/images/image_rsc/actions/zoom-in.png - - - act_zoomIn - - - - - - :/images/image_rsc/actions/zoom-out.png:/images/image_rsc/actions/zoom-out.png - - - act_zoomOut - - - - - true - - - true - - - act_toolBar - - - - - true - - - true - - - act_statusBar - - - - - true - - - true - - - act_thumbnailBar - - - - - true - - - act_colorInfo - - - - - - :/images/image_rsc/actions/previousfile.png:/images/image_rsc/actions/previousfile.png - - - act_previous - - - - - - :/images/image_rsc/actions/nextfile.png:/images/image_rsc/actions/nextfile.png - - - act_next - - - - - act_first - - - - - act_last - - - - - act_openPageNum - - - - - - :/images/image_rsc/actions/previouspage.png:/images/image_rsc/actions/previouspage.png - - - act_previousPage - - - - - - :/images/image_rsc/actions/nextpage.png:/images/image_rsc/actions/nextpage.png - - - act_nextPage - - - - - act_firstPage - - - - - act_lastPage - - - - - - :/images/image_rsc/actions/contrast.png:/images/image_rsc/actions/contrast.png - - - act_adjust - - - - - - :/images/image_rsc/actions/rotate-anticlockwise.png:/images/image_rsc/actions/rotate-anticlockwise.png - - - act_90Left - - - - - - :/images/image_rsc/actions/rotate-clockwise.png:/images/image_rsc/actions/rotate-clockwise.png - - - act_90Right - - - - - act_180 - - - - - act_multiRotate - - - - - - :/images/image_rsc/actions/cut.png:/images/image_rsc/actions/cut.png - - - act_autoCrop - - - - - - :/images/image_rsc/actions/admin.png:/images/image_rsc/actions/admin.png - - - act_signIn - - - - - act_passwordChange - - - - - act_signOut - - - - - act_log - - - - - act_clrCache - - - - - act_consume - - - - - - :/images/image_rsc/action/btnHelp.png:/images/image_rsc/action/btnHelp.png - - - act_help - - - - - act_about - - - - - act_insertFromScanner - - - - - act_clearRoller - - - - - - :/images/image_rsc/actions/imageEdit.png:/images/image_rsc/actions/imageEdit.png - - - act_imageEdit - - - - - - :/images/image_rsc/actions/sortpages.png:/images/image_rsc/actions/sortpages.png - - - act_sortPages - - - - - true - - - act_autoSave - - - - - act_update - - - - - true - - - act_feedback - - - - - act_device_log - - - - - act_driver_log - - - - - - :/images/image_rsc/actions/close.png:/images/image_rsc/actions/close.png - - - act_deleteFile - - - - - act_enhanceText - - - - - - device_menu - QMenu -
device_menu.h
-
-
- - - - -
diff --git a/app/scanner/ocrPdf.cpp b/app/scanner/ocrPdf.cpp deleted file mode 100644 index ffd511c8..00000000 --- a/app/scanner/ocrPdf.cpp +++ /dev/null @@ -1,148 +0,0 @@ -#include -#include "base/HGBase.h" -#ifdef HG_CMP_MSC -#include -#endif -#include -#include "base/HGUtility.h" - -std::string getOcrPath() -{ - std::string ocrPath; -#ifdef HG_CMP_MSC - HKEY hKey = NULL; -#ifdef _WIN64 - RegOpenKeyExA(HKEY_LOCAL_MACHINE, "SOFTWARE\\WOW6432Node\\Microtek\\Microtek OCR Engine V1", 0, KEY_QUERY_VALUE, &hKey); -#else - RegOpenKeyExA(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microtek\\Microtek OCR Engine V1", 0, KEY_QUERY_VALUE, &hKey); -#endif - if (NULL != hKey) - { - CHAR szData[MAX_PATH] = { 0 }; - DWORD cbData = MAX_PATH; - if (ERROR_SUCCESS == RegQueryValueExA(hKey, "InstallPath_Fast", NULL, NULL, (LPBYTE)szData, &cbData)) - { - ocrPath = szData; - } - - RegCloseKey(hKey); - } -#endif - return ocrPath; -} - -bool createOcrPdf(const std::string &imgPath, const std::string &dstFile, int languageType) -{ -#ifdef HG_CMP_MSC - std::string ocrPath = getOcrPath(); - if (ocrPath.empty()) - return false; - - DWORD len1 = GetEnvironmentVariableA("Path", NULL, 0); - char* env1 = (char *)malloc((size_t)len1 + 256); - if (NULL != env1) - { - memset(env1, 0, (size_t)len1 + 256); - GetEnvironmentVariableA("Path", env1, len1 + 256); - std::string ss(env1); - if (ss.find(ocrPath) == std::string::npos) - { - strcat(env1, ";"); - strcat(env1, ocrPath.c_str()); - SetEnvironmentVariableA("Path", env1); - } - - free(env1); - } - - char env2[256] = {0}; - strcat(env2, ocrPath.c_str()); - strcat(env2, "\\"); - strcat(env2, "tessdata_f"); - SetEnvironmentVariableA("TESSDATA_PREFIX", env2); - - - DeleteFileA(dstFile.c_str()); - - - const int MY_PIPE_BUFFER_SIZE = 1024; - //初始化管道 - HANDLE hPipeRead = NULL; - HANDLE hPipeWrite = NULL; - SECURITY_ATTRIBUTES saOutPipe; - ::ZeroMemory(&saOutPipe, sizeof(saOutPipe)); - saOutPipe.nLength = sizeof(SECURITY_ATTRIBUTES); - saOutPipe.lpSecurityDescriptor = NULL; - saOutPipe.bInheritHandle = TRUE; - CreatePipe(&hPipeRead, &hPipeWrite, &saOutPipe, MY_PIPE_BUFFER_SIZE); - - - PROCESS_INFORMATION ProcessInfo; - ::ZeroMemory(&ProcessInfo, sizeof(ProcessInfo)); - STARTUPINFOA StartupInfo; - ZeroMemory(&StartupInfo, sizeof(StartupInfo)); - StartupInfo.cb = sizeof(StartupInfo); - StartupInfo.dwFlags = STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW; - StartupInfo.hStdOutput = hPipeWrite; - StartupInfo.hStdError = hPipeWrite; - StartupInfo.wShowWindow = SW_HIDE; - - HGChar prefix[256]; - HGBase_GetFilePrefix(dstFile.c_str(), prefix, 256); - - bool ret = false; - char cmd[1024] = {0}; - - if (0 == languageType) - { - sprintf(cmd, "tesseract.exe \"%s\" \"%s\" -l %s --psm %d --oem %d %s", imgPath.c_str(), prefix, "eng", 3, 3, "pdf"); - } - else if (1 == languageType) - { - sprintf(cmd, "tesseract.exe \"%s\" \"%s\" -l %s --psm %d --oem %d %s", imgPath.c_str(), prefix, "chi_sim", 3, 3, "pdf"); - } - else if (2 == languageType) - { - sprintf(cmd, "tesseract.exe \"%s\" \"%s\" -l %s --psm %d --oem %d %s", imgPath.c_str(), prefix, "chi_tra", 3, 3, "pdf"); - } - else if (3 == languageType) - { - sprintf(cmd, "tesseract.exe \"%s\" \"%s\" -l %s --psm %d --oem %d %s", imgPath.c_str(), prefix, "jpn", 3, 3, "pdf"); - } - else if (4 == languageType) - { - sprintf(cmd, "tesseract.exe \"%s\" \"%s\" -l %s --psm %d --oem %d %s", imgPath.c_str(), prefix, "kor", 3, 3, "pdf"); - } - - BOOL b = CreateProcessA(NULL, cmd, NULL, NULL, TRUE, CREATE_NO_WINDOW, NULL, NULL, &StartupInfo, &ProcessInfo); - if (b) - { - WaitForSingleObject(ProcessInfo.hProcess, INFINITE); - DWORD exitCode; - GetExitCodeProcess(ProcessInfo.hProcess, &exitCode); - if (0 == exitCode) - ret = true; - - DWORD dwReadLen = 0; - DWORD dwStdLen = 0; - if (PeekNamedPipe(hPipeRead, NULL, 0, NULL, &dwReadLen, NULL) && dwReadLen > 0) - { - char szPipeOut[MY_PIPE_BUFFER_SIZE]; - ::ZeroMemory(szPipeOut, sizeof(szPipeOut)); - if (ReadFile(hPipeRead, szPipeOut, dwReadLen, &dwStdLen, NULL)) - { - - } - } - - CloseHandle(ProcessInfo.hProcess); - CloseHandle(ProcessInfo.hThread); - } - - CloseHandle(hPipeRead); - CloseHandle(hPipeWrite); - return ret; -#else - return false; -#endif -} diff --git a/app/scanner/ocrPdf.h b/app/scanner/ocrPdf.h deleted file mode 100644 index e500ee45..00000000 --- a/app/scanner/ocrPdf.h +++ /dev/null @@ -1,9 +0,0 @@ -#ifndef __OCRPDF_H__ -#define __OCRPDF_H__ - -#include - -std::string getOcrPath(); -bool createOcrPdf(const std::string &imgPath, const std::string &dstFile, int languageType);//languageType is the index of the comboBox on export and save_as ui. - -#endif /* __OCRPDF_H__ */ diff --git a/app/scanner/qt_zh_CN.qm b/app/scanner/qt_zh_CN.qm deleted file mode 100644 index e8d65305..00000000 Binary files a/app/scanner/qt_zh_CN.qm and /dev/null differ diff --git a/app/scanner/qt_zh_CN.ts b/app/scanner/qt_zh_CN.ts deleted file mode 100644 index f6a25d21..00000000 --- a/app/scanner/qt_zh_CN.ts +++ /dev/null @@ -1,8077 +0,0 @@ - - - - - MAC_APPLICATION_MENU - - - Services - 服务 - - - - Hide %1 - 隐藏%1 - - - - Hide Others - 隐藏其他 - - - - Show All - 全部显示 - - - - Preferences... - 偏好设置… - - - - Quit %1 - 退出 %1 - - - - About %1 - 关于 %1 - - - - AudioOutput - - - <html>The audio playback device <b>%1</b> does not work.<br/>Falling back to <b>%2</b>.</html> - <html>音频回放设备 <b>%1</b> 没有工作。<br/>回滚到 <b>%2</b>。</html> - - - - <html>Switching to the audio playback device <b>%1</b><br/>which just became available and has higher preference.</html> - <html>切换到音频回放设备 <b>%1</b>,<br/>它刚刚变为可用并且具有更高的优先级。</html> - - - - Revert back to device '%1' - 恢复到设备“%1” - - - - CloseButton - - - Close Tab - 关闭标签页 - - - - Phonon:: - - - Notifications - 通知 - - - - Music - 音乐 - - - - Video - 视频 - - - - Communication - 通讯 - - - - Games - 游戏 - - - - Accessibility - 无障碍环境 - - - - Phonon::Gstreamer::Backend - - - Warning: You do not seem to have the package gstreamer0.10-plugins-good installed. - Some video features have been disabled. - 警告:看起来,您没有安装 gstreamer0.10-plugins-good 包。 - 一些视频特性已经被关闭。 - - - - Warning: You do not seem to have the base GStreamer plugins installed. - All audio and video support has been disabled - 警告:看起来,您没有安装基础的 GStreamer 插件。 - 所有的音频和视频支持都已经被关闭。 - - - - Phonon::Gstreamer::MediaObject - - - Cannot start playback. - -Check your Gstreamer installation and make sure you -have libgstreamer-plugins-base installed. - 不能开始回放。 - -请检查您的 Gstreamer 安装并且确认您 -已经安装 libgstreamer-plugins-base。 - - - - A required codec is missing. You need to install the following codec(s) to play this content: %0 - 缺少一个需要的解码器。您需要安装如下解码器来播放这个内容:%0 - - - - - - - - - - - Could not open media source. - 不能打开媒体源。 - - - - Invalid source type. - 无效的源类型。 - - - - Could not locate media source. - 不能定位媒体源。 - - - - Could not open audio device. The device is already in use. - 不能打开音频设备。这个设备正在被使用。 - - - - Could not decode media source. - 不能解码媒体源。 - - - - Phonon::VolumeSlider - - - - Volume: %1% - 音量:%1% - - - - - - Use this slider to adjust the volume. The leftmost position is 0%, the rightmost is %1% - 请使用这个滑块调节音量。最左为%0,最右为%1% - - - - Q3Accel - - - %1, %2 not defined - %1,%2未定义 - - - - Ambiguous %1 not handled - 不明确的%1没有被处理 - - - - Q3DataTable - - - True - - - - - False - - - - - Insert - 插入 - - - - Update - 更新 - - - - Delete - 删除 - - - - Q3FileDialog - - - Copy or Move a File - 复制或者移动一个文件 - - - - Read: %1 - 读取:%1 - - - - - Write: %1 - 写入:%1 - - - - - Cancel - 取消 - - - - - - - All Files (*) - 所有文件 (*) - - - - Name - 名称 - - - - Size - 大小 - - - - Type - 类型 - - - - Date - 日期 - - - - Attributes - 属性 - - - - - &OK - 确定(&O) - - - - Look &in: - 查找范围(&I): - - - - - - File &name: - 文件名称(&N): - - - - File &type: - 文件类型(&T): - - - - Back - 后退 - - - - One directory up - 向上一级 - - - - Create New Folder - 创建新文件夹 - - - - List View - 列表视图 - - - - Detail View - 详细视图 - - - - Preview File Info - 预览文件信息 - - - - Preview File Contents - 预览文件内容 - - - - Read-write - 读写 - - - - Read-only - 只读 - - - - Write-only - 只写 - - - - Inaccessible - 不可访问的 - - - - Symlink to File - 文件的系统链接 - - - - Symlink to Directory - 目录的系统链接 - - - - Symlink to Special - 特殊的系统链接 - - - - File - 文件 - - - - Dir - 目录 - - - - Special - 特殊 - - - - - - Open - 打开 - - - - - Save As - 另存为 - - - - - - &Open - 打开(&O) - - - - - &Save - 保存(&S) - - - - &Rename - 重命名(&R) - - - - &Delete - 删除(&D) - - - - R&eload - 重新载入(&E) - - - - Sort by &Name - 按名称排列(&N) - - - - Sort by &Size - 按大小排列(&S) - - - - Sort by &Date - 按日期排列(&D) - - - - &Unsorted - 未排列的(&U) - - - - Sort - 排列 - - - - Show &hidden files - 显示隐藏文件(&H) - - - - the file - 文件 - - - - the directory - 目录 - - - - the symlink - 系统链接 - - - - Delete %1 - 删除%1 - - - - <qt>Are you sure you wish to delete %1 "%2"?</qt> - <qt>你确认你想删除%1,“%2”?</qt> - - - - &Yes - 是(&Y) - - - - &No - 否(&N) - - - - New Folder 1 - 新建文件夹1 - - - - New Folder - 新建文件夹 - - - - New Folder %1 - 新建文件夹%1 - - - - Find Directory - 查找目录 - - - - - Directories - 目录 - - - - Directory: - 目录: - - - - - Error - 错误 - - - - %1 -File not found. -Check path and filename. - 文件%1 -未找到。 -请检查路径和文件名。 - - - - - All Files (*.*) - 所有文件 (*.*) - - - - Open - 打开 - - - - Select a Directory - 选择一个目录 - - - - Q3LocalFs - - - - Could not read directory -%1 - 不能读取目录 -%1 - - - - Could not create directory -%1 - 不能创建目录 -%1 - - - - Could not remove file or directory -%1 - 不能移除文件或者目录 -%1 - - - - Could not rename -%1 -to -%2 - 不能把 -%1 -重命名为 -%2 - - - - Could not open -%1 - 不能打开 -%1 - - - - Could not write -%1 - 不能写入 -%1 - - - - Q3MainWindow - - - Line up - 排列 - - - - Customize... - 自定义... - - - - Q3NetworkProtocol - - - Operation stopped by the user - 操作被用户停止 - - - - Q3ProgressDialog - - - - Cancel - 取消 - - - - Q3TabDialog - - - - OK - 确认 - - - - Apply - 应用 - - - - Help - 帮助 - - - - Defaults - 默认 - - - - Cancel - 取消 - - - - Q3TextEdit - - - &Undo - 撤消(&U) - - - - &Redo - 恢复(&R) - - - - Cu&t - 剪切(&T) - - - - &Copy - 复制(&C) - - - - &Paste - 粘贴(&P) - - - - Clear - 清空 - - - - - Select All - 选择全部 - - - - Q3TitleBar - - - System - 系统 - - - - Restore up - 向上恢复 - - - - Minimize - 最小化 - - - - Restore down - 向下恢复 - - - - Maximize - 最大化 - - - - Close - 关闭 - - - - Contains commands to manipulate the window - 包含操作窗口的命令。 - - - - Puts a minimized back to normal - 把一个最小化窗口恢复为普通状态 - - - - Moves the window out of the way - 把窗口移到外面 - - - - Puts a maximized window back to normal - 把一个最大化窗口恢复为普通状态 - - - - Makes the window full screen - 窗口全屏化 - - - - Closes the window - 关闭窗口 - - - - Displays the name of the window and contains controls to manipulate it - 显示窗口名称并且包含维护它的控件 - - - - Q3ToolBar - - - More... - 更多... - - - - Q3UrlOperator - - - - - The protocol `%1' is not supported - 协议“%1”不被支持 - - - - The protocol `%1' does not support listing directories - 协议“%1”不支持列出目录 - - - - The protocol `%1' does not support creating new directories - 协议“%1”不支持创建新目录 - - - - The protocol `%1' does not support removing files or directories - 协议“%1”不支持移除文件或者目录 - - - - The protocol `%1' does not support renaming files or directories - 协议“%1”不支持重命名文件或者目录 - - - - The protocol `%1' does not support getting files - 协议“%1”不支持获取文件 - - - - The protocol `%1' does not support putting files - 协议“%1”不支持上传文件 - - - - - The protocol `%1' does not support copying or moving files or directories - 协议“%1”不支持复制或者移动文件或者目录 - - - - - (unknown) - (未知的) - - - - Q3Wizard - - - &Cancel - 取消(&C) - - - - < &Back - < 上一步(&B) - - - - &Next > - 下一步(&N) > - - - - &Finish - 完成(&F) - - - - &Help - 帮助(&H) - - - - QAbstractSocket - - - - - - Host not found - 主机未找到 - - - - - - Connection refused - 连接被拒绝 - - - - Connection timed out - 连接超时 - - - - - - Operation on socket is not supported - Socket操作不被支持 - - - - Socket operation timed out - 套接字操作超时 - - - - Socket is not connected - 套接字没有被连接 - - - - Network unreachable - 网络不能访问 - - - - QAbstractSpinBox - - - &Step up - 增加(&S) - - - - Step &down - 减少(&D) - - - - &Select All - 选择全部(&S) - - - - QApplication - - - Activate - 激活 - - - - Executable '%1' requires Qt %2, found Qt %3. - 执行“%1”需要Qt %2,只找到了Qt %3。 - - - - Incompatible Qt Library Error - 不兼容的Qt错误 - - - - Activates the program's main window - 激活这个程序的主窗口 - - - - QAxSelect - - - Select ActiveX Control - 选择ActiveX控件 - - - - OK - 确定 - - - - &Cancel - 取消(&C) - - - - COM &Object: - COM对象(&O): - - - - QCheckBox - - - Uncheck - 取消选中 - - - - Check - 选中 - - - - Toggle - 切换 - - - - QColorDialog - - - Hu&e: - 色调(&E): - - - - &Sat: - 饱和度(&S): - - - - &Val: - 亮度(&V): - - - - &Red: - 红色(&R): - - - - &Green: - 绿色(&G): - - - - Bl&ue: - 蓝色(&U): - - - - A&lpha channel: - Alpha通道(&A): - - - - Select Color - 选择颜色 - - - - &Basic colors - 基本颜色(&B) - - - - &Custom colors - 自定义颜色(&C) - - - - &Add to Custom Colors - 添加到自定义颜色(&A) - - - Select color - 选择颜色 - - - &Pick Screen Color - 拾取屏幕颜色(&P) - - - Cursor at %1, %2 -Press ESC to cancel - 光标位置 %1, %2 -按ESC键取消 - - - &HTML: - 颜色值(&H): - - - - QComboBox - - - - Open - 打开 - - - - False - - - - - True - - - - - Close - 关闭 - - - - QCoreApplication - - %1: permission denied - QSystemSemaphore - %1:权限被拒绝 - - - %1: already exists - QSystemSemaphore - %1:已经存在 - - - %1: doesn't exists - QSystemSemaphore - %1:不存在 - - - %1: out of resources - QSystemSemaphore - %1:资源耗尽了 - - - %1: unknown error %2 - QSystemSemaphore - %1:未知错误 %2 - - - - %1: key is empty - QSystemSemaphore - %1:键是空的 - - - - %1: unable to make key - QSystemSemaphore - %1:不能制造键 - - - - %1: ftok failed - QSystemSemaphore - %1:ftok 失败 - - - - QDB2Driver - - - Unable to connect - 不能连接 - - - - Unable to commit transaction - 不能提交事务 - - - - Unable to rollback transaction - 不能回滚事务 - - - - Unable to set autocommit - 不能设置自动提交 - - - - QDB2Result - - - - Unable to execute statement - 不能执行语句 - - - - Unable to prepare statement - 不能准备语句 - - - - Unable to bind variable - 不能帮定变量 - - - - Unable to fetch record %1 - 不能获取记录%1 - - - - Unable to fetch next - 不能获取下一个 - - - - Unable to fetch first - 不能获取第一个 - - - - QDateTimeEdit - - - AM - AM - - - - am - am - - - - PM - PM - - - - pm - pm - - - - QDial - - - QDial - QDial - - - - SpeedoMeter - SpeedoMeter - - - - SliderHandle - SliderHandle - - - - QDialog - - - What's This? - 这是什么? - - - - Done - 完成 - - - - QDialogButtonBox - - - - - OK - 确定 - - - - Save - 保存 - - - - &Save - 保存(&S) - - - - Open - 打开 - - - - Cancel - 取消 - - - - &Cancel - 取消(&C) - - - - Close - 关闭 - - - - &Close - 关闭(&C) - - - - Apply - 应用 - - - - Reset - 重置 - - - - Help - 帮助 - - - - Don't Save - 不保存 - - - - Discard - 抛弃 - - - - &Yes - 是(&Y) - - - - Yes to &All - 全部是(&A) - - - - &No - 否(&N) - - - - N&o to All - 全部否(&O) - - - - Save All - 保存全部 - - - - Abort - 放弃 - - - - Retry - 重试 - - - - Ignore - 忽略 - - - - Restore Defaults - 恢复默认 - - - - Close without Saving - 不保存关闭 - - - - &OK - 确定(&O) - - - - QDirModel - - - Name - 名称 - - - - Size - 大小 - - - - Kind - Match OS X Finder - 类型 - - - - Type - All other platforms - 类型 - - - - Date Modified - 日期被修改 - - - - QDockWidget - - - Close - 关闭 - - - - Dock - 锚接 - - - - Float - 浮动 - - - - QDoubleSpinBox - - - More - 更多 - - - - Less - 更少 - - - - QErrorMessage - - - Debug Message: - 调试消息: - - - - Warning: - 警告: - - - - Fatal Error: - 致命错误: - - - - &Show this message again - 再次显示这个消息(&S) - - - - &OK - 确定(&O) - - - - QFile - - - - Destination file exists - 目标文件已存在 - - - - Cannot remove source file - - - - - Cannot open %1 for input - 无法输入 %1 - - - - Cannot open for output - 无法输出 - - - - Failure to write block - 写块失败 - - - - Cannot create %1 for output - 无法创建 %1 - - - - QFileDialog - - - - All Files (*) - 所有文件 (*) - - - - Directories - 目录 - - - - - - - &Open - 打开(&O) - - - - - &Save - 保存(&S) - - - - &Cancel - 取消(&S) - - - - Cancel - 取消 - - - - Open - 打开 - - - - %1 already exists. -Do you want to replace it? - %1已经存在。 -你想要替换它么? - - - - %1 -File not found. -Please verify the correct file name was given. - 文件%1 -没有找到。 -请核实已给定正确文件名。 - - - - My Computer - 我的计算机 - - - - &Rename - 重命名(&R) - - - - &Delete - 删除(&D) - - - - Show &hidden files - 显示隐藏文件(&H) - - - - - Back - 后退 - - - - - Parent Directory - 父目录 - - - - - List View - 列表视图 - - - - - Detail View - 详细视图 - - - - - Files of type: - 文件类型: - - - - - Directory: - 目录: - - - - - %1 -Directory not found. -Please verify the correct directory name was given. - 目录%1 -没有找到。 -请核实已给定正确目录名。 - - - - '%1' is write protected. -Do you want to delete it anyway? - “%1“是写保护的。 -你还是想删除它么? - - - - Are sure you want to delete '%1'? - 你确认你想删除“%1“? - - - - Could not delete directory. - 不能删除目录。 - - - - Recent Places - 最近的地方 - - - - Save As - 另存为 - - - - Drive - 驱动器 - - - - - File - 文件 - - - - Unknown - 未知的 - - - - Find Directory - 查找目录 - - - - Show - 显示 - - - - - Forward - 前进 - - - - New Folder - 新建文件夹 - - - - &New Folder - 新建文件夹(&N) - - - - - &Choose - 选择(&C) - - - - Remove - 移除 - - - - - File &name: - 文件名称(&N): - - - - - Look in: - 查看: - - - - - Create New Folder - 创建新文件夹 - - - - All Files (*.*) - 所有文件 (*.*) - - - - QFileSystemModel - - - %1 TB - %1 TB - - - - %1 GB - %1 GB - - - - %1 MB - %1 MB - - - - %1 KB - %1千字节 - - - - %1 bytes - %1字节 - - - - Invalid filename - 无效文件名 - - - - <b>The name "%1" can not be used.</b><p>Try using another name, with fewer characters or no punctuations marks. - <b>名称“%1“不能被使用。</b><p>请使用另外一个包含更少字符或者不含有标点符号的名称。 - - - - Name - 名称 - - - - Size - 大小 - - - - Kind - Match OS X Finder - 类型 - - - - Type - All other platforms - 类型 - - - - Date Modified - 日期被修改 - - - - My Computer - 我的计算机 - - - - Computer - 计算机 - - - - QFontDatabase - - - - Normal - 普通 - - - - - - Bold - 粗体 - - - - - Demi Bold - 半粗体 - - - - - - Black - 黑体 - - - - Demi - 半体 - - - - - Light - 轻体 - - - - - Italic - 意大利体 - - - - - Oblique - 斜体 - - - - Any - 任意 - - - - Latin - 拉丁文 - - - - Greek - 希腊文 - - - - Cyrillic - 西里尔文 - - - - Armenian - 亚美尼亚文 - - - - Hebrew - 希伯来文 - - - - Arabic - 阿拉伯文 - - - - Syriac - 叙利亚文 - - - - Thaana - 马尔代夫文 - - - - Devanagari - 梵文 - - - - Bengali - 孟加拉文 - - - - Gurmukhi - 旁遮普文 - - - - Gujarati - 古吉拉特文 - - - - Oriya - 奥里雅文 - - - - Tamil - 泰米尔文 - - - - Telugu - 泰卢固文 - - - - Kannada - 埃纳德文 - - - - Malayalam - 马拉亚拉姆文 - - - - Sinhala - 僧伽罗文 - - - - Thai - 泰国文 - - - - Lao - 老挝文 - - - - Tibetan - 藏文 - - - - Myanmar - 缅甸文 - - - - Georgian - 格鲁吉亚文 - - - - Khmer - 谷美尔文 - - - - Simplified Chinese - 简体中文 - - - - Traditional Chinese - 繁体中文 - - - - Japanese - 日文 - - - - Korean - 韩文 - - - - Vietnamese - 越南文 - - - - Symbol - 符号 - - - - Ogham - 欧甘文 - - - - Runic - 古北欧文 - - - - QFontDialog - - - &Font - 字体(&F) - - - - Font st&yle - 字体风格(&Y) - - - - &Size - 大小(&S) - - - - Effects - 效果 - - - - Stri&keout - 删除线(&K) - - - - &Underline - 下划线(&U) - - - - Sample - 实例 - - - - Wr&iting System - 书写系统(&I) - - - - - Select Font - 选择字体 - - - - QFtp - - - - Not connected - 没有连接 - - - - - Host %1 not found - 主机%1没有找到 - - - - - Connection refused to host %1 - 连接被主机 %1 拒绝 - - - - Connection timed out to host %1 - 主机%1连接超时 - - - - - - Connected to host %1 - 连接到主机%1了 - - - - - Connection refused for data connection - 因为数据连接而被拒绝连接 - - - - - - - Unknown error - 未知的错误 - - - - - Connecting to host failed: -%1 - 连接主机失败: -%1 - - - - - Login failed: -%1 - 登录失败: -%1 - - - - - Listing directory failed: -%1 - 列出目录失败: -%1 - - - - - Changing directory failed: -%1 - 改变目录失败: -%1 - - - - - Downloading file failed: -%1 - 下载文件失败: -%1 - - - - - Uploading file failed: -%1 - 上传文件失败: -%1 - - - - - Removing file failed: -%1 - 移除文件失败: -%1 - - - - - Creating directory failed: -%1 - 创建目录失败: -%1 - - - - - Removing directory failed: -%1 - 移除目录失败: -%1 - - - - - - Connection closed - 连接关闭了 - - - - Host %1 found - 主机%1找到了 - - - - Connection to %1 closed - 到%1的连接关闭了 - - - - Host found - 主机找到了 - - - - Connected to host - 连接到主机了 - - - - QGuiApplication - - - QT_LAYOUT_DIRECTION - Translate this string to the string 'LTR' in left-to-right languages or to 'RTL' in right-to-left languages (such as Hebrew and Arabic) to get proper widget layout. - LTR - - - - QHostInfo - - - Unknown error - 未知的错误 - - - - QHostInfoAgent - - - - - - - - - - Host not found - 主机未找到 - - - - - - - Unknown address type - 未知的地址类型 - - - - - - Unknown error - 未知的错误 - - - - QHttp - - - - - - Unknown error - 未知的错误 - - - - - Request aborted - 请求被放弃了 - - - - - No server set to connect to - 没有设置要连接的服务器 - - - - - Wrong content length - 错误的内容长度 - - - - - Server closed connection unexpectedly - 服务器异常地关闭了连接 - - - - Unknown authentication method - - - - - Error writing response to device - 向设备中进行写回复时发生错误 - - - - - Connection refused - 连接被拒绝 - - - - - - Host %1 not found - 主机%1没有找到 - - - - - - - HTTP request failed - HTTP请求失败 - - - - - Invalid HTTP response header - 无效的HTTP响应头 - - - - - - - Invalid HTTP chunked body - 无效的HTTP臃肿体 - - - - Host %1 found - 主机%1找到了 - - - - Connected to host %1 - 连接到%1主机了 - - - - Connection to %1 closed - 到%1的连接关闭了 - - - - Host found - 主机找到了 - - - - Connected to host - 连接到主机了 - - - - - Connection closed - 连接关闭了 - - - - Proxy authentication required - 代理需要认证 - - - - Authentication required - 需要认证 - - - - Connection refused (or timed out) - 连接被拒绝(或者超时) - - - - Proxy requires authentication - 代理需要验证 - - - - Host requires authentication - 主机需要验证 - - - - Data corrupted - 数据错误 - - - - Unknown protocol specified - 所指定的协议是未知的 - - - - SSL handshake failed - SSL 握手失败 - - - - HTTPS connection requested but SSL support not compiled in - HTTPS 连接需要 SSL,但它没有被编译进来 - - - - QHttpSocketEngine - - - Did not receive HTTP response from proxy - 未收到代理的HTTP响应 - - - - Error parsing authentication request from proxy - 解析代理的认证请求出错 - - - - Authentication required - 需要认证 - - - - Proxy denied connection - 代理拒绝连接 - - - - Error communicating with HTTP proxy - 和HTTP代理通讯时发生错误 - - - - Proxy server not found - 未找到代理服务器 - - - - Proxy connection refused - 代理连接被拒绝 - - - - Proxy server connection timed out - 代理服务器连接超时 - - - - Proxy connection closed prematurely - 代理连接过早关闭 - - - - QIBaseDriver - - - Error opening database - 打开数据库错误 - - - - Could not start transaction - 不能开始事务 - - - - Unable to commit transaction - 不能提交事务 - - - - Unable to rollback transaction - 不能回滚事务 - - - - QIBaseResult - - - Unable to create BLOB - 不能创建BLOB - - - - Unable to write BLOB - 不能写入BLOB - - - - Unable to open BLOB - 不能打开BLOB - - - - Unable to read BLOB - 不能读取BLOB - - - - - Could not find array - 不能找到数组 - - - - Could not get array data - 不能得到数组数据 - - - - Could not get query info - 不能得到查询信息 - - - - Could not start transaction - 不能开始事务 - - - - Unable to commit transaction - 不能提交事务 - - - - Could not allocate statement - 不能分配语句 - - - - Could not prepare statement - 不能准备语句 - - - - - Could not describe input statement - 不能描述输入语句 - - - - Could not describe statement - 不能描述语句 - - - - Unable to close statement - 不能关闭语句 - - - - Unable to execute query - 不能执行查询 - - - - Could not fetch next item - 不能获取下一项 - - - - Could not get statement info - 不能得到语句信息 - - - - QIODevice - - - Permission denied - 权限被拒绝 - - - - Too many open files - 太多打开的文件 - - - - No such file or directory - 没有这个文件或者目录 - - - - No space left on device - 设备上没有空间了 - - - - Unknown error - 未知的错误 - - - - QInputContext - - - XIM - XIM - - - - XIM input method - XIM输入法 - - - - Windows input method - Windows输入法 - - - - Mac OS X input method - Mac OS X输入法 - - - - QInputDialog - - - Enter a value: - 输入一个值: - - - - QLibrary - - QLibrary::load_sys: Cannot load %1 (%2) - QLibrary::load_sys: 不能载入%1 (%2) - - - QLibrary::unload_sys: Cannot unload %1 (%2) - QLibrary::unload_sys:不能卸载%1 (%2) - - - QLibrary::resolve_sys: Symbol "%1" undefined in %2 (%3) - QLibrary::resolve_sys: 符号“%1”在%2(%3)没有被定义 - - - - Could not mmap '%1': %2 - 不能映射”%1“:%2 - - - - Plugin verification data mismatch in '%1' - “%1“中的插件验证数据不匹配 - - - - Could not unmap '%1': %2 - 不能取消映射“%1“:%2 - - - - The plugin '%1' uses incompatible Qt library. (%2.%3.%4) [%5] - 插件“%1”使用了不兼容的Qt库。(%2.%3.%4) [%5] - - - - The plugin '%1' uses incompatible Qt library. Expected build key "%2", got "%3" - 插件“%1“使用了不兼容的Qt库。期待的构建键是“%2“,得到的却是”%3“ - - - - Unknown error - 未知的错误 - - - - - The shared library was not found. - 共享库没有被找到。 - - - - The file '%1' is not a valid Qt plugin. - 文件“%1“不是有效的Qt插件。 - - - - The plugin '%1' uses incompatible Qt library. (Cannot mix debug and release libraries.) - 插件“%1“使用了不兼容的Qt库。(不能混合使用库的调试版本和发布版本。) - - - - - Cannot load library %1: %2 - 无法加载库%1:%2 - - - - - Cannot unload library %1: %2 - 无法卸载库%1:%2 - - - - - Cannot resolve symbol "%1" in %2: %3 - 无法解析%2中的符号“%1”:%3 - - - - QLineEdit - - - &Undo - 撤消(&U) - - - - &Redo - 恢复(&R) - - - - Cu&t - 剪切(&T) - - - - &Copy - 复制(&C) - - - - &Paste - 粘贴(&P) - - - - Delete - 删除 - - - - Select All - 选择全部 - - - - QLocalServer - - - - %1: Name error - %1: 名称错误 - - - - %1: Permission denied - %1:权限被拒绝 - - - - %1: Address in use - %1:地址正在被使用 - - - - - %1: Unknown error %2 - %1:未知错误 %2 - - - - QLocalSocket - - - - %1: Connection refused - %1:连接被拒绝 - - - - - %1: Remote closed - %1:远程已关闭 - - - - - - - %1: Invalid name - %1:无效名称 - - - - - %1: Socket access error - %1:套接字访问错误 - - - - - %1: Socket resource error - %1:套接字资源错误 - - - - - %1: Socket operation timed out - %1:套接字操作超时 - - - - - %1: Datagram too large - %1:数据报太大 - - - - - - %1: Connection error - %1:连接错误 - - - - - %1: The socket operation is not supported - %1:套接字操作不被支持 - - - - %1: Unknown error - %1:未知错误 - - - - - %1: Unknown error %2 - %1:未知错误 %2 - - - - QMYSQLDriver - - - Unable to open database ' - 不能打开数据库 - - - - Unable to connect - 不能连接 - - - - Unable to begin transaction - 不能开始事务 - - - - Unable to commit transaction - 不能提交事务 - - - - Unable to rollback transaction - 不能回滚事务 - - - - QMYSQLResult - - - Unable to fetch data - 不能获取数据 - - - - Unable to execute query - 不能执行查询 - - - - Unable to store result - 不能存储结果 - - - - - Unable to prepare statement - 不能准备语句 - - - - Unable to reset statement - 不能重置语句 - - - - Unable to bind value - 不能绑定值 - - - - Unable to execute statement - 不能执行语句 - - - - - Unable to bind outvalues - 不能绑定外值 - - - - Unable to store statement results - 不能存储语句结果 - - - - Unable to execute next query - 不能执行下一个查询 - - - - Unable to store next result - 不能存储下一个结果 - - - - QMdiArea - - - (Untitled) - (未命名的) - - - - QMdiSubWindow - - - %1 - [%2] - %1 - [%2] - - - - Close - 关闭 - - - - Minimize - 最小化 - - - - Restore Down - 向下恢复 - - - - &Restore - 恢复(&R) - - - - &Move - 移动(&M) - - - - &Size - 大小(&S) - - - - Mi&nimize - 最小化(&N) - - - - Ma&ximize - 最大化(&X) - - - - Stay on &Top - 总在最前(&T) - - - - &Close - 关闭(&C) - - - - - [%1] - - [%1] - - - - Maximize - 最大化 - - - - Unshade - 取消遮蔽 - - - - Shade - 遮蔽 - - - - Restore - 恢复 - - - - Help - 帮助 - - - - Menu - 菜单 - - - - QMenu - - - - Close - 关闭 - - - - - Open - 打开 - - - - - - Execute - 执行 - - - - QMenuBar - - About - 关于 - - - Config - 配置 - - - Preference - 首选项 - - - Options - 选项 - - - Setting - 设置 - - - Setup - 安装 - - - Quit - 退出 - - - Exit - 退出 - - - About %1 - 关于%1 - - - About Qt - 关于Qt - - - Preferences - 首选项 - - - Quit %1 - 退出%1 - - - - QMessageBox - - - Help - 帮助 - - - - - - - OK - 确定 - - - - About Qt - 关于Qt - - - <p>This program uses Qt version %1.</p> - <p>这个程序使用的是Qt %1版。</p> - - - - Show Details... - 显示细节…… - - - - Hide Details... - 隐藏细节…… - - - - <h3>About Qt</h3><p>This program uses Qt version %1.</p><p>Qt is a C++ toolkit for cross-platform application development.</p><p>Qt provides single-source portability across MS&nbsp;Windows, Mac&nbsp;OS&nbsp;X, Linux, and all major commercial Unix variants. Qt is also available for embedded devices as Qt for Embedded Linux and Qt for Windows CE.</p><p>Qt is available under three different licensing options designed to accommodate the needs of our various users.</p>Qt licensed under our commercial license agreement is appropriate for development of proprietary/commercial software where you do not want to share any source code with third parties or otherwise cannot comply with the terms of the GNU LGPL version 2.1 or GNU GPL version 3.0.</p><p>Qt licensed under the GNU LGPL version 2.1 is appropriate for the development of Qt applications (proprietary or open source) provided you can comply with the terms and conditions of the GNU LGPL version 2.1.</p><p>Qt licensed under the GNU General Public License version 3.0 is appropriate for the development of Qt applications where you wish to use such applications in combination with software subject to the terms of the GNU GPL version 3.0 or where you are otherwise willing to comply with the terms of the GNU GPL version 3.0.</p><p>Please see <a href="http://qt.nokia.com/products/licensing">qt.nokia.com/products/licensing</a> for an overview of Qt licensing.</p><p>Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).</p><p>Qt is a Nokia product. See <a href="http://qt.nokia.com/">qt.nokia.com</a> for more information.</p> - - - - <h3>About Qt</h3>%1<p>Qt is a C++ toolkit for cross-platform application development.</p><p>Qt provides single-source portability across MS&nbsp;Windows, Mac&nbsp;OS&nbsp;X, Linux, and all major commercial Unix variants. Qt is also available for embedded devices as Qt for Embedded Linux and Qt for Windows CE.</p><p>Qt is a Nokia product. See <a href="http://qt.nokia.com/">qt.nokiae.com</a> for more information.</p> - <h3>关于Qt</h3>%1<p>Qt是一个用于跨平台应用程序开发的C++工具包。</p><p>对于MS&nbsp;Windows、Mac&nbsp;OS&nbsp;X、Linux和所有主流商业Unix,Qt提供了单一源程序的可移植性。Qt也有用于嵌入式Linux和Windows CE的版本。</p><p>Qt是Nokia的产品。有关更多信息,请参考<a href="http://qt.nokia.com/">qt.nokia.com</a>。</p> - - - <p>This program uses Qt Open Source Edition version %1.</p><p>Qt Open Source Edition is intended for the development of Open Source applications. You need a commercial Qt license for development of proprietary (closed source) applications.</p><p>Please see <a href="http://qt.nokia.com/company/model/">qt.nokia.com/company/model/</a> for an overview of Qt licensing.</p> - <p>这个程序使用了Qt %1开源版本。</p><p>Qt开源版本只用于开源应用程序的开发。如果要开发私有(闭源)软件,你需要一个商业的Qt协议。</p><p>有关Qt协议的概览,请参考<a href="http://qt.nokia.com/company/model/">qt.nokia.com/company/model/</a>。</p> - - - <h3>About Qt</h3>%1<p>Qt is a C++ toolkit for cross-platform application development.</p><p>Qt provides single-source portability across MS&nbsp;Windows, Mac&nbsp;OS&nbsp;X, Linux, and all major commercial Unix variants. Qt is also available for embedded devices as Qt Embedded.</p><p>Qt is a Trolltech product. See <a href="http://qt.nokia.com/">qt.nokia.com</a> for more information.</p> - <h3>关于Qt</h3>%1<p>Qt是一个用于跨平台应用程序开发的C++工具包。</p><p>对于MS&nbsp;Windows、Mac&nbsp;OS&nbsp;X、Linux和所有主流商业Unix,Qt提供了单一源程序的可移植性。Qt对于嵌入式平台也是可用的,在嵌入式平台上它被称为Qt Embedded。</p><p>Qt是Trolltech的产品。有关更多信息,请参考<a href="http://qt.nokia.com/">qt.nokia.com</a>。</p> - - - - QMultiInputContext - - - Select IM - 选择输入法 - - - - QMultiInputContextPlugin - - - Multiple input method switcher - 多输入法切换器 - - - - Multiple input method switcher that uses the context menu of the text widgets - 使用文本窗口部件上下文菜单的多输入法切换器 - - - - QNativeSocketEngine - - - The remote host closed the connection - 远端主机关闭了这个连接 - - - - Network operation timed out - 网络操作超时 - - - - Out of resources - 资源耗尽了 - - - - Unsupported socket operation - 不被支持的套接字操作 - - - - Protocol type not supported - 协议类型不被支持 - - - - Invalid socket descriptor - 无效的套接字描述符 - - - - Network unreachable - 网络不能访问 - - - - Permission denied - 权限被拒绝 - - - - Connection timed out - 连接超时 - - - - Connection refused - 连接被拒绝 - - - - The bound address is already in use - 要启用的地址已经被使用 - - - - The address is not available - 这个地址不可用 - - - - The address is protected - 这个地址被保护了 - - - - Unable to send a message - 不能发送一个消息 - - - - Unable to receive a message - 不能接收一个消息 - - - - Unable to write - 不能写入 - - - - Network error - 网络错误 - - - - Another socket is already listening on the same port - 另一个套接字已经正在监听同一端口 - - - - Unable to initialize non-blocking socket - 不能初始化非阻塞套接字 - - - - Unable to initialize broadcast socket - 不能初始化广播套接字 - - - - Attempt to use IPv6 socket on a platform with no IPv6 support - 试图在不支持IPv6支持的平台上使用IPv6套接字 - - - - Host unreachable - 主机不能访问 - - - - Datagram was too large to send - 不能发送过大的数据报 - - - - Operation on non-socket - 对非套接字操作 - - - - Unknown error - 未知的错误 - - - - The proxy type is invalid for this operation - 对于这个操作代理类型是无效的。 - - - - QNetworkAccessCacheBackend - - - Error opening %1 - 打开%1发生错误 - - - - QNetworkAccessFileBackend - - - Request for opening non-local file %1 - 正在打开非本地文件 %1 的请求 - - - - Error opening %1: %2 - 打开 %1 错误:%2 - - - - Write error writing to %1: %2 - 写入 %1 错误:%2 - - - - Cannot open %1: Path is a directory - 无法打开 %1:路径是一个目录 - - - - Read error reading from %1: %2 - 读取 %1 错误:%2 - - - - QNetworkAccessFtpBackend - - - No suitable proxy found - 未找到合适的代理 - - - - Cannot open %1: is a directory - 无法读取 %1:是一个目录 - - - - Logging in to %1 failed: authentication required - 登入 %1 失败:需要验证 - - - - Error while downloading %1: %2 - 下载 %1 时错误:%2 - - - - Error while uploading %1: %2 - 上载 %1 时错误:%2 - - - - QNetworkAccessHttpBackend - - - No suitable proxy found - 未找到合适的代理 - - - - QNetworkReply - - - Error downloading %1 - server replied: %2 - 下载 %1 错误 - 服务器回复:%2 - - - - Protocol "%1" is unknown - 协议“%1”是未知的 - - - - QNetworkReplyImpl - - - - Operation canceled - 操作被取消 - - - - QOCIDriver - - - Unable to logon - 不能登录 - - - - Unable to initialize - QOCIDriver - 不能初始化 - - - - Unable to begin transaction - 不能开始事务 - - - - Unable to commit transaction - 不能提交事务 - - - - Unable to rollback transaction - 不能回滚事务 - - - - QOCIResult - - - - - Unable to bind column for batch execute - 不能绑定批处理执行的列 - - - - Unable to execute batch statement - 不能执行批处理语句 - - - - Unable to goto next - 不能进入下一个 - - - - Unable to alloc statement - 不能分配语句 - - - - Unable to prepare statement - 不能准备语句 - - - - Unable to bind value - 不能绑定值 - - - Unable to execute select statement - 不能执行选择语句 - - - - Unable to execute statement - 不能执行语句 - - - - QODBCDriver - - - Unable to connect - 不能连接 - - - - Unable to connect - Driver doesn't support all needed functionality - 不能连接—驱动程序不支持所有功能 - - - - Unable to disable autocommit - 不能禁止自动提交 - - - - Unable to commit transaction - 不能提交事务 - - - - Unable to rollback transaction - 不能回滚事务 - - - - Unable to enable autocommit - 不能打开自动提交 - - - - QODBCResult - - - - QODBCResult::reset: Unable to set 'SQL_CURSOR_STATIC' as statement attribute. Please check your ODBC driver configuration - QODBCResult::reset: 不能把“SQL_CURSOR_STATIC”设置为语句属性。请检查你的ODBC驱动程序设置。 - - - - - Unable to execute statement - 不能执行语句 - - - - Unable to fetch next - 不能获取下一个 - - - - Unable to prepare statement - 不能准备语句 - - - - Unable to bind variable - 不能帮定变量 - - - - - - Unable to fetch last - 不能获取最后一个 - - - - Unable to fetch - 不能获取 - - - - Unable to fetch first - 不能获取第一个 - - - - Unable to fetch previous - 不能获取上一个 - - - - QObject - - - Home - - - - - Operation not supported on %1 - 在 %1 上不被支持的操作 - - - - Invalid URI: %1 - 无效的 URI:%1 - - - - Write error writing to %1: %2 - 写入 %1 错误:%2 - - - - Read error reading from %1: %2 - 读取 %1 错误:%2 - - - - Socket error on %1: %2 - %1 上的套接字错误:%2 - - - - Remote host closed the connection prematurely on %1 - 远程主机过早地关闭了在 %1 上的这个连接 - - - - Protocol error: packet of size 0 received - 协议错误:收到了大小为 0 的包 - - - - - No host name given - 未指定主机名 - - - - QPPDOptionsModel - - - Name - 名称 - - - - Value - - - - - QPSQLDriver - - - Unable to connect - 不能连接 - - - - Could not begin transaction - 不能开始事务 - - - - Could not commit transaction - 不能提交事务 - - - - Could not rollback transaction - 不能回滚事务 - - - - Unable to subscribe - 不能订阅 - - - - Unable to unsubscribe - 不能取消订阅 - - - - QPSQLResult - - - Unable to create query - 不能创建查询 - - - - Unable to prepare statement - 不能准备语句 - - - - QPageSetupWidget - - - Centimeters (cm) - 厘米 (cm) - - - - Millimeters (mm) - 毫米 (mm) - - - - Inches (in) - 英寸 (in) - - - - Points (pt) - 点 (pt) - - - - Form - 窗体 - - - - Paper - 纸张 - - - - Page size: - 纸张大小: - - - - Width: - 宽度: - - - - Height: - 高度: - - - - Paper source: - 纸张源: - - - - Orientation - 方向 - - - - Portrait - 纵向 - - - - Landscape - 横向 - - - - Reverse landscape - 反向横向 - - - - Reverse portrait - 反向纵向 - - - - Margins - 边距 - - - - top margin - 上边距 - - - - left margin - 左边距 - - - - right margin - 右边距 - - - - bottom margin - 下边距 - - - - QPluginLoader - - - Unknown error - 未知的错误 - - - - The plugin was not loaded. - 插件没有被载入。 - - - - QPrintDialog - - - locally connected - 本地已经连接的 - - - - - Aliases: %1 - 别名:%1 - - - - - unknown - 未知的 - - - - Print all - 打印全部 - - - - Print selection - 打印选择 - - - - Print range - 打印范围 - - - - A0 (841 x 1189 mm) - A0 (841 x 1189 毫米) - - - - A1 (594 x 841 mm) - A1 (594 x 841 毫米) - - - - A2 (420 x 594 mm) - A2 (420 x 594 毫米) - - - - A3 (297 x 420 mm) - A3 (297 x 420 毫米) - - - - A4 (210 x 297 mm, 8.26 x 11.7 inches) - A4 (210 x 297 毫米,8.26 x 11.7 英寸) - - - - A5 (148 x 210 mm) - A5 (148 x 210 毫米) - - - - A6 (105 x 148 mm) - A6 (105 x 148 毫米) - - - - A7 (74 x 105 mm) - A7 (74 x 105 毫米) - - - - A8 (52 x 74 mm) - A8 (52 x 74 毫米) - - - - A9 (37 x 52 mm) - A9 (37 x 52 毫米) - - - - B0 (1000 x 1414 mm) - B0 (1000 x 1414 毫米) - - - - B1 (707 x 1000 mm) - B1 (707 x 1000 毫米) - - - - B2 (500 x 707 mm) - B2 (500 x 707 毫米) - - - - B3 (353 x 500 mm) - B3 (353 x 500 毫米) - - - - B4 (250 x 353 mm) - B4 (250 x 353 毫米) - - - - B5 (176 x 250 mm, 6.93 x 9.84 inches) - B5 (176 x 250 毫米,6.93 x 9.84 英寸) - - - - B6 (125 x 176 mm) - B6 (125 x 176 毫米) - - - - B7 (88 x 125 mm) - B7 (88 x 125 毫米) - - - - B8 (62 x 88 mm) - B8 (62 x 88 毫米) - - - - B9 (44 x 62 mm) - B9 (44 x 62 毫米) - - - - B10 (31 x 44 mm) - B10 (31 x 44 毫米) - - - - C5E (163 x 229 mm) - C5E (163 x 229 毫米) - - - - DLE (110 x 220 mm) - DLE (110 x 220 毫米) - - - - Executive (7.5 x 10 inches, 191 x 254 mm) - Executive (7.5 x 10 英寸,191 x 254 毫米) - - - - Folio (210 x 330 mm) - Folio (210 x 330 毫米) - - - - Ledger (432 x 279 mm) - Ledger (432 x 279 毫米) - - - - Legal (8.5 x 14 inches, 216 x 356 mm) - Legal (8.5 x 14 英寸,216 x 356 毫米) - - - - Letter (8.5 x 11 inches, 216 x 279 mm) - Letter (8.5 x 11 英寸,216 x 279 毫米) - - - - Tabloid (279 x 432 mm) - Tabloid (279 x 432 毫米) - - - - US Common #10 Envelope (105 x 241 mm) - 美国普通10号信封 (105 x 241 毫米) - - - - OK - 确定 - - - - - - Print - 打印 - - - - Print To File ... - 打印到文件…… - - - - File %1 is not writable. -Please choose a different file name. - 文件%1不可写。 -请选择一个不同的文件名。 - - - - %1 already exists. -Do you want to overwrite it? - %1已经存在。 -你想覆盖它么? - - - - File exists - 文件存在 - - - - <qt>Do you want to overwrite it?</qt> - <qt>你想覆盖它么?</qt> - - - - %1 is a directory. -Please choose a different file name. - %1是目录。 -请选择一个不同的文件名。 - - - - The 'From' value cannot be greater than the 'To' value. - “从”的数值不能大于“到”的数值。 - - - - A0 - A0 - - - - A1 - A1 - - - - A2 - A2 - - - - A3 - A3 - - - - A4 - A4 - - - - A5 - A5 - - - - A6 - A6 - - - - A7 - A7 - - - - A8 - A8 - - - - A9 - A9 - - - - B0 - B0 - - - - B1 - B1 - - - - B2 - B2 - - - - B3 - B3 - - - - B4 - B4 - - - - B5 - B5 - - - - B6 - B6 - - - - B7 - B7 - - - - B8 - B8 - - - - B9 - B9 - - - - B10 - B10 - - - - C5E - C5E - - - - DLE - DLE - - - - Executive - 决策文书 - - - - Folio - 对开纸 - - - - Ledger - 帐页 - - - - Legal - 法律文书 - - - - Letter - 信纸 - - - - Tabloid - 小型报纸 - - - - US Common #10 Envelope - 美国普通10号信封 - - - - Custom - 自定义 - - - - - &Options >> - 选项(&O) >> - - - - &Print - 打印(&P) - - - - &Options << - 选项(&O) << - - - - Print to File (PDF) - 打印到文件(PDF) - - - - Print to File (Postscript) - 打印到文件(Postscript) - - - - Local file - 本地文件 - - - - Write %1 file - 写入 %1 文件 - - - - QPrintPreviewDialog - - - - Page Setup - 页面设置 - - - - %1% - %1% - - - - Print Preview - 打印预览 - - - - Next page - 下一页 - - - - Previous page - 上一页 - - - - First page - 第一页 - - - - Last page - 最后一页 - - - - Fit width - 适应宽度 - - - - Fit page - 适应页面 - - - - Zoom in - 放大 - - - - Zoom out - 缩小 - - - - Portrait - 纵向 - - - - Landscape - 横向 - - - - Show single page - 显示单页 - - - - Show facing pages - 显示当前页 - - - - Show overview of all pages - 显示所有页的概览 - - - - Print - 打印 - - - - Page setup - 打印设置 - - - - Close - 关闭 - - - - Export to PDF - 导出为PDF - - - - Export to PostScript - 导出为PostScript - - - - QPrintPropertiesWidget - - - Form - 窗体 - - - - Page - - - - - Advanced - 高级 - - - - QPrintSettingsOutput - - - Form - 窗体 - - - - Copies - 拷贝 - - - - Print range - 打印范围 - - - - Print all - 打印全部 - - - - Pages from - 页数从 - - - - to - - - - - Selection - 选择 - - - - Output Settings - 输出设置 - - - - Copies: - 备份: - - - - Collate - 校对 - - - - Reverse - 反向 - - - - Options - 选项 - - - - Color Mode - 彩色模式 - - - - Color - 彩色 - - - - Grayscale - 灰度 - - - - Duplex Printing - 两部分打印 - - - - None - - - - - Long side - 长侧 - - - - Short side - 短侧 - - - - QPrintWidget - - - Form - 窗体 - - - - Printer - 打印机 - - - - &Name: - 名称(&N): - - - - P&roperties - 属性(&R) - - - - Location: - 位置: - - - - Preview - 预览 - - - - Type: - 类型: - - - - Output &file: - 输出文件(&F): - - - - ... - ... - - - - QProcess - - - - Could not open input redirection for reading - 无法打开用于读取的输入重定向 - - - - - Could not open output redirection for writing - 无法打开用于写入的输出重定向 - - - - Resource error (fork failure): %1 - 资源错误(fork失败):%1 - - - - - - - - - - - - Process operation timed out - 进程处理超时 - - - - - - - Error reading from process - 从进程中读取时发生错误 - - - - - - Error writing to process - 向进程写入时发生错误 - - - - Process crashed - 进程已崩溃 - - - - No program defined - - - - - Process failed to start - 启动进程失败 - - - - QProgressDialog - - - Cancel - 撤消 - - - - QPushButton - - - Open - 打开 - - - - QRadioButton - - - Check - 选中 - - - - QRegExp - - - no error occurred - 没有错误发生 - - - - disabled feature used - 使用了失效的特效 - - - - bad char class syntax - 错误的字符类语法 - - - - bad lookahead syntax - 错误的预测语法 - - - - bad repetition syntax - 错误的重复语法 - - - - invalid octal value - 无效的八进制数值 - - - - missing left delim - 找不到左分隔符 - - - - unexpected end - 意外的终止 - - - - met internal limit - 遇到内部限制 - - - - QSQLite2Driver - - - Error to open database - 打开数据库错误 - - - - Unable to begin transaction - 不能开始事务 - - - - Unable to commit transaction - 不能提交事务 - - - - Unable to rollback Transaction - 不能回滚事务 - - - - QSQLite2Result - - - Unable to fetch results - 不能获取结果 - - - - Unable to execute statement - 不能执行语句 - - - - QSQLiteDriver - - - Error opening database - 打开数据库错误 - - - - Error closing database - 关闭数据库错误 - - - - Unable to begin transaction - 不能开始事务 - - - - Unable to commit transaction - 不能提交事务 - - - - Unable to rollback transaction - 不能回滚事务 - - - - QSQLiteResult - - - - - Unable to fetch row - 不能获取行 - - - - Unable to execute statement - 不能执行语句 - - - - Unable to reset statement - 不能重置语句 - - - - Unable to bind parameters - 不能绑定参数 - - - - Parameter count mismatch - 参数数量不匹配 - - - - No query - 没有查询 - - - - QScrollBar - - - Scroll here - 滚动到这里 - - - - Left edge - 左边缘 - - - - Top - 顶部 - - - - Right edge - 右边缘 - - - - Bottom - 底部 - - - - Page left - 左一页 - - - - - Page up - 上一页 - - - - Page right - 右一页 - - - - - Page down - 下一页 - - - - Scroll left - 向左滚动 - - - - Scroll up - 向上滚动 - - - - Scroll right - 向右滚动 - - - - Scroll down - 向下滚动 - - - - Line up - 向上排列 - - - - Position - 位置 - - - - Line down - 向下排列 - - - - QSharedMemory - - - %1: unable to set key on lock - %1:无法设置锁定的键 - - - - %1: create size is less then 0 - %1:创建的大小小于 0 - - - - - %1: unable to lock - %1:无法锁定 - - - - %1: unable to unlock - %1:无法取消锁定 - - - - - %1: permission denied - %1:权限被拒绝 - - - - - %1: already exists - %1:已经存在 - - - - - %1: doesn't exists - %1:不存在 - - - - - %1: out of resources - %1:资源耗尽了 - - - - - %1: unknown error %2 - %1:未知错误 %2 - - - - %1: key is empty - %1:键是空的 - - - - %1: unix key file doesn't exists - %1:Unix 键文件不存在 - - - - %1: ftok failed - %1:ftok 失败 - - - - - %1: unable to make key - %1:不能制造键 - - - - %1: system-imposed size restrictions - %1:系统预设大小限制 - - - - %1: not attached - %1:没有附加 - - - - %1: invalid size - %1:无效大小 - - - - %1: key error - %1: 键错误 - - - - %1: size query failed - %1:大小查询失败 - - - - QShortcut - - - Space - 空格 - - - - Esc - Esc - - - - Tab - Tab - - - - Backtab - Backtab - - - - Backspace - Backspace - - - - Return - Return - - - - Enter - Enter - - - - Ins - Ins - - - - Del - Del - - - - Pause - Pause - - - - Print - Print - - - - SysReq - SysReq - - - - Home - Home - - - - End - End - - - - Left - Left - - - - Up - Up - - - - Right - Right - - - - Down - Down - - - - PgUp - PgUp - - - - PgDown - PgDown - - - - CapsLock - CapsLock - - - - NumLock - NumLock - - - - ScrollLock - ScrollLock - - - - Menu - Menu - - - - Help - Help - - - - Back - 后退 - - - - Forward - 前进 - - - - Stop - 停止 - - - - Refresh - 刷新 - - - - Volume Down - 调小音量 - - - - Volume Mute - 静音 - - - - Volume Up - 调大音量 - - - - Bass Boost - 低音增强 - - - - Bass Up - 调大低音 - - - - Bass Down - 调小低音 - - - - Treble Up - 调大高音 - - - - Treble Down - 调小高音 - - - - Media Play - 多媒体播放 - - - - Media Stop - 多媒体停止 - - - - Media Previous - 上一个多媒体 - - - - Media Next - 下一个多媒体 - - - - Media Record - 多媒体记录 - - - - Favorites - 最喜爱的 - - - - Search - 搜索 - - - - Standby - 等待 - - - - Open URL - 打开URL - - - - Launch Mail - 启动邮件 - - - - Launch Media - 启动多媒体 - - - - Launch (0) - 启动 (0) - - - - Launch (1) - 启动 (1) - - - - Launch (2) - 启动 (2) - - - - Launch (3) - 启动 (3) - - - - Launch (4) - 启动 (4) - - - - Launch (5) - 启动 (5) - - - - Launch (6) - 启动 (6) - - - - Launch (7) - 启动 (7) - - - - Launch (8) - 启动 (8) - - - - Launch (9) - 启动 (9) - - - - Launch (A) - 启动 (A) - - - - Launch (B) - 启动 (B) - - - - Launch (C) - 启动 (C) - - - - Launch (D) - 启动 (D) - - - - Launch (E) - 启动 (E) - - - - Launch (F) - 启动 (F) - - - - Print Screen - Print Screen - - - - Page Up - Page Up - - - - Page Down - Page Down - - - - Caps Lock - Caps Lock - - - - Num Lock - Num Lock - - - - Number Lock - Number Lock - - - - Scroll Lock - Scroll Lock - - - - Insert - Insert - - - - Delete - Delete - - - - Escape - Escape - - - - System Request - System Request - - - - Select - 选择 - - - - Yes - - - - - No - - - - - Context1 - 上下文1 - - - - Context2 - 上下文2 - - - - Context3 - 上下文3 - - - - Context4 - 上下文4 - - - - Call - 呼叫 - - - - Hangup - 挂起 - - - - Flip - 翻转 - - - - - Ctrl - Ctrl - - - - - Shift - Shift - - - - - Alt - Alt - - - - - Meta - Meta - - - - + - + - - - - F%1 - F%1 - - - - Home Page - 主页 - - - - QSlider - - - Page left - 左一页 - - - - Page up - 上一页 - - - - Position - 位置 - - - - Page right - 右一页 - - - - Page down - 下一页 - - - - QSocks5SocketEngine - - - Connection to proxy refused - 代理拒绝连接 - - - - Connection to proxy closed prematurely - 代理连接过早关闭 - - - - Proxy host not found - 代理主机未找到 - - - - Connection to proxy timed out - 代理连接超时 - - - - Proxy authentication failed - 代理认证失败 - - - - Proxy authentication failed: %1 - 代理认证失败: %1 - - - - SOCKS version 5 protocol error - SOCKS版本5协议错误 - - - - General SOCKSv5 server failure - 常规服务器失败 - - - - Connection not allowed by SOCKSv5 server - 连接不被SOCKSv5服务器允许 - - - - TTL expired - TTL已过期 - - - - SOCKSv5 command not supported - 不支持的SOCKSv5命令 - - - - Address type not supported - 不支持的地址类型 - - - - Unknown SOCKSv5 proxy error code 0x%1 - 未知SOCKSv5代理,错误代码 0x%1 - - - Socks5 timeout error connecting to socks server - 连接到套接字服务器的时候,Socks5超时错误 - - - - Network operation timed out - 网络操作超时 - - - - QSpinBox - - - More - 更多 - - - - Less - 更少 - - - - QSql - - - Delete - 删除 - - - - Delete this record? - 删除这条记录? - - - - - - Yes - - - - - - - No - - - - - Insert - 插入 - - - - Update - 更新 - - - - Save edits? - 保存编辑? - - - - Cancel - 取消 - - - - Confirm - 确认 - - - - Cancel your edits? - 取消您的编辑? - - - - QSslSocket - - - Unable to write data: %1 - 不能写入数据:%1 - - - - Error while reading: %1 - 读取时错误:%1 - - - - Error during SSL handshake: %1 - SSL握手错误:%1 - - - - Error creating SSL context (%1) - 创建SSL上下文错误(%1) - - - - Invalid or empty cipher list (%1) - 无效或者空白的密码列表(%1) - - - - Error creating SSL session, %1 - 创建SSL会话错误,%1 - - - - Error creating SSL session: %1 - 创建SSL会话错误:%1 - - - - Cannot provide a certificate with no key, %1 - 不能提供没有键的证书,%1 - - - - Error loading local certificate, %1 - 不能载入本地证书,%1 - - - - Error loading private key, %1 - 不能载入私有键,%1 - - - - Private key does not certificate public key, %1 - 私有键不能验证公有键,%1 - - - - QSystemSemaphore - - - - %1: out of resources - %1:资源耗尽了 - - - - - %1: permission denied - %1:权限被拒绝 - - - - %1: already exists - %1:已经存在 - - - - %1: does not exist - %1:不存在 - - - - - %1: unknown error %2 - %1:未知错误 %2 - - - - QTDSDriver - - - Unable to open connection - 不能打开连接 - - - - Unable to use database - 不能使用数据库 - - - - QTabBar - - - Scroll Left - 向左滚动 - - - - Scroll Right - 向右滚动 - - - - QTcpServer - - - Operation on socket is not supported - socket操作不被支持 - - - - QTextControl - - - &Undo - 撤消(&U) - - - - &Redo - 恢复(&R) - - - - Cu&t - 剪切(&T) - - - - &Copy - 复制(&C) - - - - Copy &Link Location - 复制链接位置(&L) - - - - &Paste - 粘贴(&P) - - - - Delete - 删除 - - - - Select All - 选择全部 - - - - QToolButton - - - - Press - 按下 - - - - - Open - 打开 - - - - QUdpSocket - - - This platform does not support IPv6 - 这个平台不支持IPv6 - - - - QUndoGroup - - - Undo - 撤销 - - - - Redo - 恢复 - - - - QUndoModel - - - <empty> - <空白> - - - - QUndoStack - - - Undo - 撤销 - - - - Redo - 恢复 - - - - QUnicodeControlCharacterMenu - - - LRM Left-to-right mark - LRM 从左到右标记 - - - - RLM Right-to-left mark - RLM 从右向左标记 - - - - ZWJ Zero width joiner - ZWJ 零宽度连接器 - - - - ZWNJ Zero width non-joiner - ZWNJ 零宽度非连接器 - - - - ZWSP Zero width space - ZWSP 零宽度空格 - - - - LRE Start of left-to-right embedding - LRE 开始从左到右嵌入 - - - - RLE Start of right-to-left embedding - RLE 开始从右向左嵌入 - - - - LRO Start of left-to-right override - LRO 开始从左向右覆盖 - - - - RLO Start of right-to-left override - RLO 开始从右向左覆盖 - - - - PDF Pop directional formatting - PDF 弹出方向格式 - - - - Insert Unicode control character - 插入Unicode控制字符 - - - - QWebFrame - - - Request cancelled - 请求被取消了 - - - - Request blocked - 请求被阻塞了 - - - - Cannot show URL - 无法显示 URL - - - - Frame load interruped by policy change - 因为策略调整打断了桢的加载 - - - - Cannot show mimetype - 无法显示 MIMETYPE - - - - File does not exist - 文件不存在 - - - - QWebPage - - - Bad HTTP request - 错误的 HTTP 请求 - - - - Submit - default label for Submit buttons in forms on web pages - 提交 - - - - Submit - Submit (input element) alt text for <input> elements with no alt, title, or value - 提交 - - - - Reset - default label for Reset buttons in forms on web pages - 重置 - - - - This is a searchable index. Enter search keywords: - text that appears at the start of nearly-obsolete web pages in the form of a 'searchable index' - 这是一个可以搜索的索引。请输入要搜索的关键字: - - - - Choose File - title for file button used in HTML forms - 选择文件 - - - - No file selected - text to display in file button used in HTML forms when no file is selected - 没有文件被选择 - - - - Open in New Window - Open in New Window context menu item - 在新窗口中打开 - - - - Save Link... - Download Linked File context menu item - 保存链接... - - - - Copy Link - Copy Link context menu item - 复制链接 - - - - Open Image - Open Image in New Window context menu item - 打开图片 - - - - Save Image - Download Image context menu item - 保存图片 - - - - Copy Image - Copy Link context menu item - 复制图片 - - - - Open Frame - Open Frame in New Window context menu item - 打开框架 - - - - Copy - Copy context menu item - 复制 - - - - Go Back - Back context menu item - 后退 - - - - Go Forward - Forward context menu item - 前进 - - - - Stop - Stop context menu item - 停止 - - - - Reload - Reload context menu item - 重新载入 - - - - Cut - Cut context menu item - 剪切 - - - - Paste - Paste context menu item - 粘贴 - - - - No Guesses Found - No Guesses Found context menu item - 没有找到猜测 - - - - Ignore - Ignore Spelling context menu item - 忽略 - - - - Add To Dictionary - Learn Spelling context menu item - 添加到字典 - - - - Search The Web - Search The Web context menu item - 搜索网页 - - - - Look Up In Dictionary - Look Up in Dictionary context menu item - 在字典中查找 - - - - Open Link - Open Link context menu item - 打开链接 - - - - Ignore - Ignore Grammar context menu item - 忽略 - - - - Spelling - Spelling and Grammar context sub-menu item - 拼写 - - - - Show Spelling and Grammar - menu item title - 显示拼写和语法 - - - - Hide Spelling and Grammar - menu item title - 隐藏拼写和语法 - - - - Check Spelling - Check spelling context menu item - 检查拼写 - - - - Check Spelling While Typing - Check spelling while typing context menu item - 在输入时检查拼写 - - - - Check Grammar With Spelling - Check grammar with spelling context menu item - 检查语法和拼写 - - - - Fonts - Font context sub-menu item - 字体 - - - - Bold - Bold context menu item - 粗体 - - - - Italic - Italic context menu item - 意大利体 - - - - Underline - Underline context menu item - 下划线 - - - - Outline - Outline context menu item - 轮廓 - - - - Direction - Writing direction context sub-menu item - 方向 - - - - Text Direction - Text direction context sub-menu item - 文本方向 - - - - Default - Default writing direction context menu item - 默认 - - - - LTR - Left to Right context menu item - LTR - - - - RTL - Right to Left context menu item - RTL - - - - Inspect - Inspect Element context menu item - 检查 - - - - No recent searches - Label for only item in menu that appears when clicking on the search field image, when no searches have been performed - 没有最近的搜索 - - - - Recent searches - label for first item in the menu that appears when clicking on the search field image, used as embedded menu title - 最近的搜索 - - - - Clear recent searches - menu item in Recent Searches menu that empties menu's contents - 清除最近的搜索 - - - - Unknown - Unknown filesize FTP directory listing item - 未知的 - - - - %1 (%2x%3 pixels) - Title string for images - %1 (%2x%3 像素) - - - - Web Inspector - %2 - 网页检查员 - %2 - - - - Scroll here - 滚动到这里 - - - - Left edge - 左边缘 - - - - Top - 顶部 - - - - Right edge - 右边缘 - - - - Bottom - 底部 - - - - Page left - 左一页 - - - - Page up - 上一页 - - - - Page right - 右一页 - - - - Page down - 下一页 - - - - Scroll left - 向左滚动 - - - - Scroll up - 向上滚动 - - - - Scroll right - 向右滚动 - - - - Scroll down - 向下滚动 - - - - %n file(s) - number of chosen file - - %n 个文件 - - - - - JavaScript Alert - %1 - JavaScript警告 - %1 - - - - JavaScript Confirm - %1 - JavaScript确认 - %1 - - - - JavaScript Prompt - %1 - JavaScript提示 - %1 - - - - Move the cursor to the next character - 移动光标到下一个字符 - - - - Move the cursor to the previous character - 移动光标到上一个字符 - - - - Move the cursor to the next word - 移动光标到下一个单词 - - - - Move the cursor to the previous word - 移动光标到上一个单词 - - - - Move the cursor to the next line - 移动光标到下一行 - - - - Move the cursor to the previous line - 移动光标到上一行 - - - - Move the cursor to the start of the line - 移动光标到行首 - - - - Move the cursor to the end of the line - 移动光标到行尾 - - - - Move the cursor to the start of the block - 移动光标到块首 - - - - Move the cursor to the end of the block - 移动光标到块尾 - - - - Move the cursor to the start of the document - 移动光标到文件开头 - - - - Move the cursor to the end of the document - 移动光标到文件末尾 - - - - Select all - - - - - Select to the next character - 选中到下一个字符 - - - - Select to the previous character - 选中到上一个字符 - - - - Select to the next word - 选中到下一个单词 - - - - Select to the previous word - 选中到上一个单词 - - - - Select to the next line - 选中到下一行 - - - - Select to the previous line - 选中到上一行 - - - - Select to the start of the line - 选中到行首 - - - - Select to the end of the line - 选中到行尾 - - - - Select to the start of the block - 选中到块首 - - - - Select to the end of the block - 选中到块尾 - - - - Select to the start of the document - 选中到文件首 - - - - Select to the end of the document - 选中到文件尾 - - - - Delete to the start of the word - 删除到单词首 - - - - Delete to the end of the word - 删除到单词尾 - - - - Insert a new paragraph - - - - - Insert a new line - - - - - QWhatsThisAction - - - What's This? - 这是什么? - - - - QWidget - - - * - * - - - - QWizard - - - Go Back - 返回 - - - - Continue - 继续 - - - - Commit - 提交 - - - - Done - 完成 - - - Quit - 退出 - - - - Help - 帮助 - - - - < &Back - < 上一步(&B) - - - - &Finish - 完成(&F) - - - - Cancel - 取消 - - - - &Help - 帮助(&H) - - - - &Next - 下一步(&N) - - - - &Next > - 下一步(&N) > - - - - QWorkspace - - - &Restore - 恢复(&R) - - - - &Move - 移动(&M) - - - - &Size - 大小(&S) - - - - Mi&nimize - 最小化(&N) - - - - Ma&ximize - 最大化(&X) - - - - &Close - 关闭(&C) - - - - Stay on &Top - 总在最前(&T) - - - - - Sh&ade - 卷起(&A) - - - - - %1 - [%2] - %1 - [%2] - - - - Minimize - 最小化 - - - - Restore Down - 恢复 - - - - Close - 关闭 - - - - &Unshade - 展开(&U) - - - - QXml - - - no error occurred - 没有错误发生 - - - - error triggered by consumer - 由消费者出发的错误 - - - - unexpected end of file - 意外的文件终止 - - - - more than one document type definition - 多于一个的文档类型定义 - - - - error occurred while parsing element - 在解析元素的时候发生错误 - - - - tag mismatch - 标记不匹配 - - - - error occurred while parsing content - 在解析内容的时候发生错误 - - - - unexpected character - 意外的字符 - - - - invalid name for processing instruction - 无效的处理指令名称 - - - - version expected while reading the XML declaration - 在读取XML声明的时候,版本被期待 - - - - wrong value for standalone declaration - 错误的独立声明的值 - - - - encoding declaration or standalone declaration expected while reading the XML declaration - 在读取XML声明的时候,编码声明或者独立声明被期待 - - - - standalone declaration expected while reading the XML declaration - 在读取XML声明的时候,独立声明被期待 - - - - error occurred while parsing document type definition - 在解析文档类型定义的时候发生错误 - - - - letter is expected - 字符被期待 - - - - error occurred while parsing comment - 在解析注释的时候发生错误 - - - - error occurred while parsing reference - 在解析参考的时候发生错误 - - - - internal general entity reference not allowed in DTD - 在DTD中不允许使用内部解析的通用实体参考 - - - - external parsed general entity reference not allowed in attribute value - 在属性值中不允许使用外部解析的通用实体参考 - - - - external parsed general entity reference not allowed in DTD - 在DTD中不允许使用外部解析的通用实体参考 - - - - unparsed entity reference in wrong context - 没有解析的错误上下文中的实体参考 - - - - recursive entities - 嵌套实体 - - - - error in the text declaration of an external entity - 在一个外部实体的文本声明里有错误 - - - - QXmlStream - - - - Extra content at end of document. - 文档末尾有额外内容。 - - - - Invalid entity value. - 无效的实体值。 - - - - Invalid XML character. - 无效的XML字符。 - - - - Sequence ']]>' not allowed in content. - 内容中不允许有“]]>“序列。 - - - - Namespace prefix '%1' not declared - 命名空间的”%1“前缀没有被声明 - - - - Attribute redefined. - 属性重复定义。 - - - - Unexpected character '%1' in public id literal. - 在公有标识文本中有意外的字符”%1“。 - - - - Invalid XML version string. - 无效的XML版本字符串。 - - - - Unsupported XML version. - 不被支持的XML版本。 - - - - %1 is an invalid encoding name. - %1是无效的编码名称。 - - - - Encoding %1 is unsupported - 编码%1不被支持。 - - - - Standalone accepts only yes or no. - 独立运行只允许是或者否。 - - - - Invalid attribute in XML declaration. - 在XML声明中无效的属性。 - - - - Premature end of document. - 文档过早的结束。 - - - - Invalid document. - 无效的文档。 - - - - Expected - 期待的 - - - - , but got ' - ,但是得到的是“ - - - - Unexpected ' - 意外的“ - - - - Expected character data. - 期待的字符数据。 - - - - Recursive entity detected. - 检测到嵌套实体。 - - - - Start tag expected. - 开始期待的标记。 - - - - XML declaration not at start of document. - XML声明没有在文档的开始位置。 - - - - NDATA in parameter entity declaration. - 在参数实体声明中有NDATA。 - - - - %1 is an invalid processing instruction name. - %1 是无效的处理指令名称。 - - - - Invalid processing instruction name. - 无效的处理指令名称。 - - - - - - - Illegal namespace declaration. - 非法的命名空间声明。 - - - - Invalid XML name. - 无效的XML名称。 - - - - Opening and ending tag mismatch. - 开始标记和结束标记不匹配。 - - - - Reference to unparsed entity '%1'. - 未解析实体“%1“的引用。 - - - - - - Entity '%1' not declared. - 实体”%1“没有被声明。 - - - - Reference to external entity '%1' in attribute value. - 在属性值中的外部实体“%1”的引用。 - - - - Invalid character reference. - 无效的字符引用。 - - - - - Encountered incorrectly encoded content. - 遇到不正确的编码内容。 - - - - The standalone pseudo attribute must appear after the encoding. - 独立运行伪属性必须出现在编码之后。 - - - - %1 is an invalid PUBLIC identifier. - %1是一个无效的公有(PUBLIC)标识符。 - - - - QtXmlPatterns - - - An %1-attribute with value %2 has already been declared. - 带有值 %2 的 %1 属性已经声明过了。 - - - - An %1-attribute must have a valid %2 as value, which %3 isn't. - 一个 %1 属性必须带有一个有效的 %2 作为值,但 %3 却不是。 - - - - Network timeout. - 网络超时。 - - - - Element %1 can't be serialized because it appears outside the document element. - 元素 %1 不能被串行化,因为它出现在文档元素之外。 - - - Attribute element %1 can't be serialized because it appears at the top level. - 属性元素 %1 不能被串行化,因为它出现在最顶层。 - - - - Year %1 is invalid because it begins with %2. - %1 年是无效的,因为应该从 %2 开始。 - - - - Day %1 is outside the range %2..%3. - %1 日是在 %2...%3 范围之外的。 - - - - Month %1 is outside the range %2..%3. - %1 月是在 %2...%3 范围之外的。 - - - - Overflow: Can't represent date %1. - 溢出:无法呈现数据 %1。 - - - - Day %1 is invalid for month %2. - %1 日对于 %2 月是无效的。 - - - - Time 24:%1:%2.%3 is invalid. Hour is 24, but minutes, seconds, and milliseconds are not all 0; - 时间 24:%1:%2.%3 是无效的。小时是 24,但是分钟、秒和毫秒不全为 0; - - - - Time %1:%2:%3.%4 is invalid. - 时间 %1:%2:%3.%4 是无效的。 - - - - Overflow: Date can't be represented. - 溢出:数据无法被呈现。 - - - - - At least one component must be present. - 至少有一个组件被呈现。 - - - - At least one time component must appear after the %1-delimiter. - 至少一个时间组件必须出现在这个 %1 界限之后。 - - - - No operand in an integer division, %1, can be %2. - 在整数除法中没有操作数,%1,可以是 %2。 - - - - The first operand in an integer division, %1, cannot be infinity (%2). - 除法中的第一个操作数,%1,不能是无穷(%2)。 - - - - The second operand in a division, %1, cannot be zero (%2). - 除法中的第二个操作数,%1,不能是零(%2)。 - - - - %1 is not a valid value of type %2. - %1 不是类型为 %2 的有效值。 - - - - When casting to %1 from %2, the source value cannot be %3. - 当从 %2 抛出到 %1 时,源值不能是 %3。 - - - - Integer division (%1) by zero (%2) is undefined. - 整数除法(%1)除零(%2)是未定义的。 - - - - Division (%1) by zero (%2) is undefined. - 除法(%1)除零(%2)是未定义的。 - - - - Modulus division (%1) by zero (%2) is undefined. - 求模除法(%1)除零(%2)是未定义的。 - - - - - Dividing a value of type %1 by %2 (not-a-number) is not allowed. - 一个类型为 %1 的值除以 %2(不是一个数值)是不允许的。 - - - - Dividing a value of type %1 by %2 or %3 (plus or minus zero) is not allowed. - 一个类型为 %1 的值除以 %2 或者 %3(正负零)是不允许的。 - - - - Multiplication of a value of type %1 by %2 or %3 (plus or minus infinity) is not allowed. - 一个类型为 %1 的值乘以 %2 或者 %3(正负无穷)是不允许的。 - - - - A value of type %1 cannot have an Effective Boolean Value. - 一个类型为 %1 的值不能是一个有效的布尔值(Effective Boolean Value)。 - - - - Effective Boolean Value cannot be calculated for a sequence containing two or more atomic values. - 有效的布尔值(Effective Boolean Value)不能被用于计算一个包含两个或者更多原子值的序列。 - - - - Value %1 of type %2 exceeds maximum (%3). - 类型为 %2 的值 %1 超过了最大值(%3)。 - - - - Value %1 of type %2 is below minimum (%3). - 类型为 %2 的值 %1 超过了最小值(%3)。 - - - - A value of type %1 must contain an even number of digits. The value %2 does not. - 类型为 %1 的值必须包含偶数个数字。值 %2 不是这样的。 - - - - %1 is not valid as a value of type %2. - %1 不是类型为 %2 的有效值。 - - - - Operator %1 cannot be used on type %2. - 操作符 %1 不能被用于类型 %2。 - - - - Operator %1 cannot be used on atomic values of type %2 and %3. - 操作符 %1 不能被用于类型为 %2 和 %3 的原子值。 - - - - The namespace URI in the name for a computed attribute cannot be %1. - 一个被计算的属性的名称中的命名空间 URI 不能是 %1。 - - - - The name for a computed attribute cannot have the namespace URI %1 with the local name %2. - 一个被计算的属性的名称不能使用带有本地名称 %2 的命名空间 URI %1。 - - - - Type error in cast, expected %1, received %2. - 抛出类型错误,期望的是 %1,收到的是 %2。 - - - - When casting to %1 or types derived from it, the source value must be of the same type, or it must be a string literal. Type %2 is not allowed. - 当抛出到 %1 或者它的派生类时,源类型必须是同一类型,或者它必须是一个字符串类型。类型 %2 是不被允许的。 - - - - No casting is possible with %1 as the target type. - 无法以 %1 为目标类型进行抛出。 - - - - It is not possible to cast from %1 to %2. - 无法从 %1 抛出到 %2。 - - - - Casting to %1 is not possible because it is an abstract type, and can therefore never be instantiated. - 无法抛出到 %1,因为它是一个抽象类型,并且因此无法被实例化。 - - - - It's not possible to cast the value %1 of type %2 to %3 - 无法从类型为 %2 的值 %1 抛出到 %3 - - - - Failure when casting from %1 to %2: %3 - 从 %2 抛出到 %1 失败:%3 - - - - A comment cannot contain %1 - 注释不能包含 %1 - - - - A comment cannot end with a %1. - 注释不能以 %1 结尾。 - - - - No comparisons can be done involving the type %1. - 对于类型 %1 不能进行比较。 - - - - Operator %1 is not available between atomic values of type %2 and %3. - 在类型 %2 和 %3 的原子值之间,操作符 %1 是不可用的。 - - - - An attribute node cannot be a child of a document node. Therefore, the attribute %1 is out of place. - 一个属性节点不能是一个文档节点的子节点。因此,这个属性 %1 所在位置是不合适的。 - - - - A library module cannot be evaluated directly. It must be imported from a main module. - 一个库模块不能被直接评估。它必须从一个主模块中导入。 - - - - No template by name %1 exists. - 没有名为 %1 的模板存在。 - - - - A value of type %1 cannot be a predicate. A predicate must have either a numeric type or an Effective Boolean Value type. - 类型为 %1 的值不能被判断。一个判断必须是数值类型或者一个有效的布尔值(Effective Boolean Value)类型。 - - - - A positional predicate must evaluate to a single numeric value. - 一个定位判断必须评估一个单一数值。 - - - - The target name in a processing instruction cannot be %1 in any combination of upper and lower case. Therefore, is %2 invalid. - 一个处理指令中的目标名称不能是任何大小写混合的 %1。因此,%2 是无效的。 - - - - %1 is not a valid target name in a processing instruction. It must be a %2 value, e.g. %3. - %1 不是处理指令的有效目标名称。它必须是值 %2,例如 %3。 - - - - The last step in a path must contain either nodes or atomic values. It cannot be a mixture between the two. - 一个路径中的最后一步必须包含节点或者原子值。它不能是两者的一个组合。 - - - - The data of a processing instruction cannot contain the string %1 - 处理指令的数据不能包含字符串 %1 - - - - No namespace binding exists for the prefix %1 - 对于前缀 %1,没有存在绑定的命名空间。 - - - - No namespace binding exists for the prefix %1 in %2 - 对于 %2 中的前缀 %1,没有存在绑定的命名空间。 - - - - - %1 is an invalid %2 - %1 是一个无效的 %2。 - - - - %1 takes at most %n argument(s). %2 is therefore invalid. - - %1 最多可以有 %n 个参数。因此 %2 是无效的。 - - - - - %1 requires at least %n argument(s). %2 is therefore invalid. - - %1 需要至少 %n 个参数。因此 %2 是无效的。 - - - - - The first argument to %1 cannot be of type %2. It must be a numeric type, xs:yearMonthDuration or xs:dayTimeDuration. - %1 的第一个参数不能是类型 %2 的。它必须是数字类型的,xs:yearMonthDuration 或者 xs:dayTimeDuration。 - - - - The first argument to %1 cannot be of type %2. It must be of type %3, %4, or %5. - %1 的第一个参数不能是类型 %2 的。它必须是类型 %3、%4 或者 %5 的。 - - - - The second argument to %1 cannot be of type %2. It must be of type %3, %4, or %5. - %1 的第二个参数不能是类型 %2 的。它必须是类型 %3、%4 或者 %5 的。 - - - - %1 is not a valid XML 1.0 character. - %1 不是一个有效的 XML 1.0 字符。 - - - - The first argument to %1 cannot be of type %2. - %1 的第一个参数不能是类型 %2 的。 - - - - If both values have zone offsets, they must have the same zone offset. %1 and %2 are not the same. - 如果两个值都有区偏移(zone offset),它们必须拥有相同的区偏移。%1 和 %2 的区偏移是不同的。 - - - - %1 was called. - %1 被调用了。 - - - - %1 must be followed by %2 or %3, not at the end of the replacement string. - %1 必须被 %2 或者 %3 跟随,不能在替换字符串的末尾。 - - - - In the replacement string, %1 must be followed by at least one digit when not escaped. - 在这个替换字符串中,%1 在没有被转义的时候必须被至少一个数字跟随。 - - - - In the replacement string, %1 can only be used to escape itself or %2, not %3 - 在这个替换字符串中,%1 只能被用于转义它本身或者 %2,而不是 %3 - - - - %1 matches newline characters - %1 匹配了换行符 - - - - %1 and %2 match the start and end of a line. - %1 和 %2 匹配了一行的头和尾。 - - - - Matches are case insensitive - 匹配是大小写不敏感的 - - - - Whitespace characters are removed, except when they appear in character classes - 空白字符被移除了,除非当它们出现在字符类中 - - - - %1 is an invalid regular expression pattern: %2 - %1 是正则表达式中的一个无效模式:%2 - - - - %1 is an invalid flag for regular expressions. Valid flags are: - %1 是正则表达式中的一个无效标记。有效标记为: - - - - If the first argument is the empty sequence or a zero-length string (no namespace), a prefix cannot be specified. Prefix %1 was specified. - 如果第一个参数是空序列或者零长度字符串(无命名空间),那么就不能指定前缀。前缀 %1 被指定了。 - - - - It will not be possible to retrieve %1. - 将不能获取 %1。 - - - - The root node of the second argument to function %1 must be a document node. %2 is not a document node. - 函数 %1 的第二个参数的根节点必须是一个文档节点。%2 不是一个文档节点。 - - - - The default collection is undefined - 默认收集(collection)是未定义的 - - - - %1 cannot be retrieved - 无法获取 %1 - - - - The normalization form %1 is unsupported. The supported forms are %2, %3, %4, and %5, and none, i.e. the empty string (no normalization). - 不支持正规化(normalization)表单 %1。被支持的表单是 %2、%3、%4 和 %5,以及无,例如空字符串(无正规化)。 - - - - A zone offset must be in the range %1..%2 inclusive. %3 is out of range. - 区偏移(zone offset)必须在 %1...%2 范围之内。%3 是在范围之外的。 - - - - %1 is not a whole number of minutes. - %1 不是分钟的整数。 - - - - Required cardinality is %1; got cardinality %2. - 所需要的表间关系是 %1;得到的表间关系却是 %2。 - - - - The item %1 did not match the required type %2. - 项 %1 和所需的类型 %2 不匹配。 - - - - - %1 is an unknown schema type. - %1 是一个未知的方案类型。 - - - - Only one %1 declaration can occur in the query prolog. - 只有一个 %1 的声明可以出现在查询序言中。 - - - - The initialization of variable %1 depends on itself - 变量 %1 的初始化依赖于它本身 - - - - No variable by name %1 exists - 没有名称为 %1 的变量存在。 - - - - The variable %1 is unused - 变量 %1 没有被使用 - - - - Version %1 is not supported. The supported XQuery version is 1.0. - 不支持版本 %1。被支持的 XQuery 版本是 1.0。 - - - - The encoding %1 is invalid. It must contain Latin characters only, must not contain whitespace, and must match the regular expression %2. - 编码方式 %1 是无效的。它必须只包含拉丁字符,必须不包含空白符号,并且必须和正则表达式 %2 匹配。 - - - - No function with signature %1 is available - 没有签名为 %1 的可用函数。 - - - - - A default namespace declaration must occur before function, variable, and option declarations. - 默认命名空间声明必须出现在函数、变量和选项声明之前。 - - - - Namespace declarations must occur before function, variable, and option declarations. - 命名空间声明必须出现在函数、变量和选项声明之前。 - - - - Module imports must occur before function, variable, and option declarations. - 模块导入不能出现在函数、变量和选项声明之前。 - - - - It is not possible to redeclare prefix %1. - 不能重复声明前缀 %1。 - - - Only the prefix %1 can be declared to bind the namespace %2. By default, it is already bound to the prefix %1. - 至于前缀 %1 可以被声明为和命名空间 %2 绑定。默认情况下,它已经被绑定到前缀 %1。 - - - - Prefix %1 is already declared in the prolog. - 前缀 %1 在序言中已经声明过了。 - - - - The name of an option must have a prefix. There is no default namespace for options. - 一个选项的名称必须带有前缀。对于选项没有默认命名空间。 - - - - The Schema Import feature is not supported, and therefore %1 declarations cannot occur. - 不支持方案导入(Schema Import)特性,并且因此 %1 声明不能出现。 - - - - The target namespace of a %1 cannot be empty. - %1 的目标命名空间不能为空。 - - - - The module import feature is not supported - 不支持模块导入特性 - - - A variable by name %1 has already been declared in the prolog. - 名称为 %1 的变量已经在序言中声明过了。 - - - - No value is available for the external variable by name %1. - 名称为 %1 的外部变量并没有可用的值。 - - - The namespace for a user defined function cannot be empty(try the predefined prefix %1 which exists for cases like this) - 用户定义的函数的命名空间不能为空(请试试预定义的前缀 %1,它就是用于这种情况的)。 - - - - A construct was encountered which only is allowed in XQuery. - 遇到了一个只允许在XQuery中出现的构造。 - - - - A template by name %1 has already been declared. - 模板%1已被声明 - - - - The keyword %1 cannot occur with any other mode name. - 任何其他模式名称不能出现关键字%1。 - - - - The value of attribute %1 must of type %2, which %3 isn't. - 属性%1的值必须是类型%2,但%3不是。 - - - - The prefix %1 can not be bound. By default, it is already bound to the namespace %2. - 前缀%1不能被绑定。默认的,它已被绑定到名字空间%2。 - - - - A variable by name %1 has already been declared. - 变量%1已被声明。 - - - - A stylesheet function must have a prefixed name. - 样式表函数必须有一个前缀名。 - - - - The namespace for a user defined function cannot be empty (try the predefined prefix %1 which exists for cases like this) - 用户定义函数的名字空间不能为空(试用为这种情况而存在的预定义前缀%1) - - - - The namespace %1 is reserved; therefore user defined functions may not use it. Try the predefined prefix %2, which exists for these cases. - 命名空间 %1 是保留的;因此用户定义的函数不能使用它。请试试预定义的前缀 %2,它就是用于这种情况的。 - - - - The namespace of a user defined function in a library module must be equivalent to the module namespace. In other words, it should be %1 instead of %2 - 用户在一个库模块中定义的函数的命名空间必须和这个模块的命名空间一致。也就是说,它应该是 %1,而不是 %2 - - - - A function already exists with the signature %1. - 一个带有签名 %1 的函数已经存在。 - - - - No external functions are supported. All supported functions can be used directly, without first declaring them as external - 不支持外部函数。所有支持的函数必须可以被直接使用,不能把它们声明为外部的 - - - - An argument by name %1 has already been declared. Every argument name must be unique. - 名称为 %1 的参数已经被声明了。每个参数名称必须唯一。 - - - - When function %1 is used for matching inside a pattern, the argument must be a variable reference or a string literal. - 当函数%1被用于样式匹配时,参数必须是变量参考或者字符串。 - - - - In an XSL-T pattern, the first argument to function %1 must be a string literal, when used for matching. - 在XSL-T样式中,函数%1的第一个参数必须是字符串,以便用于匹配。 - - - - In an XSL-T pattern, the first argument to function %1 must be a literal or a variable reference, when used for matching. - 在XSL-T样式中,函数%1的第一个参数必须是文字或者变量参考,以便用于匹配。 - - - - In an XSL-T pattern, function %1 cannot have a third argument. - 在XSL-T样式中,函数%1不能有第三个参数。 - - - - In an XSL-T pattern, only function %1 and %2, not %3, can be used for matching. - 在XSL-T样式中,只用函数%1和%2可以用于匹配,%3不可以。 - - - - In an XSL-T pattern, axis %1 cannot be used, only axis %2 or %3 can. - 在XSL-T仰视中,不能使用%1轴,只能使用%2轴或者%3轴。 - - - - %1 is an invalid template mode name. - %1不是一个合法的模板模式名称。 - - - - The name of a variable bound in a for-expression must be different from the positional variable. Hence, the two variables named %1 collide. - 一个在 for 表达式中绑定的变量的名称必须和这个定位变量不同。因此,这两个名称为 %1 的变量冲突。 - - - - The Schema Validation Feature is not supported. Hence, %1-expressions may not be used. - 不支持方案验证特性(Schema Validation Feature)。因此,也许不能使用 %1 表达式。 - - - - None of the pragma expressions are supported. Therefore, a fallback expression must be present - 不支持任何编译指示表达式(pragma expression)。因此,必须呈现一个回调表达式(fallback expression)。 - - - - Each name of a template parameter must be unique; %1 is duplicated. - 每一个模板参数的名称都必须是唯一的;%2是重复的。 - - - - The %1-axis is unsupported in XQuery - 这个 %1 轴在 XQuery 中是不被支持的。 - - - - %1 is not a valid name for a processing-instruction. - %1不是一个处理指令的合法名称。 - - - - %1 is not a valid numeric literal. - %1 不是一个有效的数字语义。 - - - - No function by name %1 is available. - 没有名称为 %1 的可用函数。 - - - - The namespace URI cannot be the empty string when binding to a prefix, %1. - 当这个命名空间 URI 被绑定到一个前缀 %1 时,它不能是空字符串。 - - - - %1 is an invalid namespace URI. - %1 是一个无效的命名空间 URI。 - - - - It is not possible to bind to the prefix %1 - 无法绑定到这个前缀 %1。 - - - - Namespace %1 can only be bound to %2 (and it is, in either case, pre-declared). - 命名空间 %1 只能和 %2 绑定(并且如果是这种情况,需要提前声明)。 - - - - Prefix %1 can only be bound to %2 (and it is, in either case, pre-declared). - 前缀 %1 只能和 %2 绑定(并且如果是这种情况,需要提前声明)。 - - - - Two namespace declaration attributes have the same name: %1. - 两个命名空间声明属性使用了相同的名称:%1。 - - - - The namespace URI must be a constant and cannot use enclosed expressions. - 命名空间 URI 必须是一个常量并且不能使用封闭的表达式。 - - - - An attribute by name %1 has already appeared on this element. - 一个名称为 %1 的属性已经出现在这个元素中了。 - - - - A direct element constructor is not well-formed. %1 is ended with %2. - 一个直接元素构造器没有很好地形成。%1 后面跟着 %2。 - - - - The name %1 does not refer to any schema type. - 名称 %1 没有指向任何方案类型。 - - - - %1 is an complex type. Casting to complex types is not possible. However, casting to atomic types such as %2 works. - %1 是一个复杂类型。无法抛出到复杂类型。因此,抛出到例如 %2 这样的原子类型是可以的。 - - - - %1 is not an atomic type. Casting is only possible to atomic types. - %1 不是原子类型。只能抛出到原子类型。 - - - %1 is not a valid name for a processing-instruction. Therefore this name test will never match. - %1 不是处理指令的有效名称。因此这个名称测试永远不会匹配。 - - - - - %1 is not in the in-scope attribute declarations. Note that the schema import feature is not supported. - %1 不是范围内属性声明。注意方案导入特性是不被支持的。 - - - - The name of an extension expression must be in a namespace. - 一个扩展表达式的名称必须在一个命名空间中。 - - - - empty - 空白 - - - - zero or one - 零或者一 - - - - exactly one - 确切地一 - - - - one or more - 一或者更多 - - - - zero or more - 零或者更多 - - - - Required type is %1, but %2 was found. - 需要的类型是 %1,但是找到的是 %2。 - - - - Promoting %1 to %2 may cause loss of precision. - 把 %1 升级为 %2 会导致精度的损失。 - - - - The focus is undefined. - 焦点未定义。 - - - - It's not possible to add attributes after any other kind of node. - 不能在任何其它类型节点后添加属性。 - - - - An attribute by name %1 has already been created. - 一个名称为 %1 的属性已经被创建。 - - - - Only the Unicode Codepoint Collation is supported(%1). %2 is unsupported. - 只支持 Unicode 代码点校验(Unicode Codepoint Collation)(%1)。%2 是不被支持的。 - - - - Attribute %1 can't be serialized because it appears at the top level. - 属性 %1 不能被串行化,因为它出现在最顶层。 - - - - %1 is an unsupported encoding. - %1 是不被支持的编码。 - - - - %1 contains octets which are disallowed in the requested encoding %2. - %1包含了在请求编码%2中不允许的八进位值。 - - - - The codepoint %1, occurring in %2 using encoding %3, is an invalid XML character. - 在使用编码%3的%2中出现的代码点%1不是一个有效的XML字符。 - - - - Ambiguous rule match. - 含糊规则匹配。 - - - In a namespace constructor, the value for a namespace value cannot be an empty string. - 在一个命名空间构造中,命名空间的值不能为空字符串。 - - - - In a namespace constructor, the value for a namespace cannot be an empty string. - - - - - The prefix must be a valid %1, which %2 is not. - 前缀必须是有效的%1,而%2不是。 - - - - The prefix %1 cannot be bound. - 前缀%1不能被绑定。 - - - - Only the prefix %1 can be bound to %2 and vice versa. - 只有前缀%1可以绑定到%2,反之也一样 - - - - Circularity detected - 检测到环 - - - - The parameter %1 is required, but no corresponding %2 is supplied. - 需要参数%1,但是没有提供对应的%2。 - - - - The parameter %1 is passed, but no corresponding %2 exists. - 参数%1已传递,但没有相应的%2存在。 - - - - The URI cannot have a fragment - URI不能有片段 - - - - Element %1 is not allowed at this location. - 元素%1不能在这个位置。 - - - - Text nodes are not allowed at this location. - 文本节点不能在这个位置。 - - - - Parse error: %1 - 解析错误:%1 - - - - The value of the XSL-T version attribute must be a value of type %1, which %2 isn't. - XSL-T版本属性的值必须是%1类型的值,而%2不是。 - - - - Running an XSL-T 1.0 stylesheet with a 2.0 processor. - 在XSL-T 2.0处理器中运行一个1.0的样式表。 - - - - Unknown XSL-T attribute %1. - 未知的XSL-T属性%1。 - - - - Attribute %1 and %2 are mutually exclusive. - 属性%1和%2彼此互斥。 - - - - In a simplified stylesheet module, attribute %1 must be present. - 在一个简化样式表模块中,属性%1必须存在。 - - - - If element %1 has no attribute %2, it cannot have attribute %3 or %4. - 如果元素%1没有属性%2,那么它也不能有属性%3或者%4。 - - - - Element %1 must have at least one of the attributes %2 or %3. - 元素%1必须至少有属性%2或者%3其中一个。 - - - - At least one mode must be specified in the %1-attribute on element %2. - 在元素%2的%1属性中至少要指定一个模式。 - - - - Attribute %1 cannot appear on the element %2. Only the standard attributes can appear. - 属性%1不能出现在元素%2上。只有标准属性可以出现。 - - - - Attribute %1 cannot appear on the element %2. Only %3 is allowed, and the standard attributes. - 属性%1不能出现在元素%2上。只有%3和标准属性是允许的。 - - - - Attribute %1 cannot appear on the element %2. Allowed is %3, %4, and the standard attributes. - 属性%1不能出现在元素%2上。只有%3、%4和标准属性是允许的。 - - - - Attribute %1 cannot appear on the element %2. Allowed is %3, and the standard attributes. - 属性%1不能出现在元素%2上。只有%3和标准属性是允许的。 - - - - XSL-T attributes on XSL-T elements must be in the null namespace, not in the XSL-T namespace which %1 is. - XSL-T元素中的XSL-T属性必须放在空(null)命名空间中,而不是在XSL-T命名空间中,%1却是这个样子。 - - - - The attribute %1 must appear on element %2. - 属性%1必须出现在元素%2中。 - - - - The element with local name %1 does not exist in XSL-T. - 有本地名称%1的元素在XSL-T中不存在。 - - - - Element %1 must come last. - 元素%1必须最后出现。 - - - - At least one %1-element must occur before %2. - 至少一个元素%1要出现在%2之前。 - - - - Only one %1-element can appear. - 只能出现一个元素%1。 - - - - At least one %1-element must occur inside %2. - 至少一个元素%1要出现在%2之内。 - - - - When attribute %1 is present on %2, a sequence constructor cannot be used. - 当属性%1出现在%2中时,不能使用顺序构造。 - - - - Element %1 must have either a %2-attribute or a sequence constructor. - 元素%1必须有在一个%2属性或者顺序构造。 - - - - When a parameter is required, a default value cannot be supplied through a %1-attribute or a sequence constructor. - 当需要参数时,不能通过属性%1或者顺序构造提供默认值。 - - - - Element %1 cannot have children. - 元素%1不能有子元素。 - - - - Element %1 cannot have a sequence constructor. - 元素%1不能有顺序构造。 - - - - - The attribute %1 cannot appear on %2, when it is a child of %3. - 属性%1不能出现在%2中,因为它是%3的子元素。 - - - - A parameter in a function cannot be declared to be a tunnel. - 函数内的参数不能被声明为通道(tunnel)。 - - - - This processor is not Schema-aware and therefore %1 cannot be used. - 这个处理器不能感知Schema,因此%1不能被使用。 - - - - Top level stylesheet elements must be in a non-null namespace, which %1 isn't. - 顶级样式表元素必须是在非空命名空间中的,而%1不是。 - - - - The value for attribute %1 on element %2 must either be %3 or %4, not %5. - 元素%2中属性%1的值必须是%3或者%4,而不是%5。 - - - - Attribute %1 cannot have the value %2. - 属性%1的值不能是%2。 - - - - The attribute %1 can only appear on the first %2 element. - 属性%1只能出现在前%2个元素中。 - - - - At least one %1 element must appear as child of %2. - %2必须至少又一个子元素%1。 - - - - VolumeSlider - - - Muted - 已静音 - - - - - Volume: %1% - 音量:%1% - - - - WebCore::PlatformScrollbar - - Scroll here - 滚动到这里 - - - Left edge - 左边缘 - - - Top - 顶部 - - - Right edge - 右边缘 - - - Bottom - 底部 - - - Page left - 左一页 - - - Page up - 上一页 - - - Page right - 右一页 - - - Page down - 下一页 - - - Scroll left - 向左滚动 - - - Scroll up - 向上滚动 - - - Scroll right - 向右滚动 - - - Scroll down - 向下滚动 - - - - QPlatformTheme - - OK - 确定 - - - &OK - 确定(&O) - - - Cancel - 取消 - - - &Cancel - 取消(&C) - - - Yes - - - - &Yes - 是(&Y) - - - No - - - - &No - 否(&N) - - - Yes to All - 应用到所有 - - - Yes to &All - 应用到所有(&A) - - - - QGnomeTheme - - OK - 确定 - - - &OK - 确定(&O) - - - Cancel - 取消 - - - &Cancel - 取消(&C) - - - Yes - - - - &Yes - 是(&Y) - - - No - - - - &No - 否(&N) - - - Yes to All - 应用到所有 - - - Yes to &All - 应用到所有(&A) - - - diff --git a/app/scanner/sane_device.cpp b/app/scanner/sane_device.cpp deleted file mode 100644 index c47dd61d..00000000 --- a/app/scanner/sane_device.cpp +++ /dev/null @@ -1,65 +0,0 @@ -#include "sane_device.h" - - -sane_dev::sane_dev() : hdev_(nullptr), offline_(true), name_(""), cfg_name_("") -{} -sane_dev::~sane_dev() -{ - close(); -} - -bool sane_dev::apply(gb::sane_config_schm* schm) -{ - SANE_Int count = 0, - afterdo = 0; - bool ret = false; - - return ret; -} - -std::string sane_dev::name(void) -{ - return name_; -} -std::string sane_dev::current_configuration_name(void) -{ - return cfg_name_; -} -bool sane_dev::is_online(void) -{ - return !offline_; -} -SANE_Handle sane_dev::handle(void) -{ - return hdev_; -} - -bool sane_dev::open(const std::string& name) -{ - if(name_ == name) - return true; - - close(); - - SANE_Status statu = sane_open(name.c_str(), &hdev_); - if(statu == SANE_STATUS_GOOD) - { - } - - return statu == SANE_STATUS_GOOD; -} -void sane_dev::set_online(bool online) -{ - offline_ = !online; -} -void sane_dev::close(void) -{ - if(hdev_) - { - sane_close(hdev_); - hdev_ = nullptr; - } - offline_ = true; - name_ = ""; - cfg_name_ = ""; -} diff --git a/app/scanner/sane_device.h b/app/scanner/sane_device.h deleted file mode 100644 index f6071060..00000000 --- a/app/scanner/sane_device.h +++ /dev/null @@ -1,38 +0,0 @@ -#pragma once - -#include -#include "sane/sane_ex.h" -#include "cfg/gb_json.h" - - - -class sane_dev -{ - SANE_Handle hdev_; - bool offline_; - std::string name_; - std::string cfg_name_; - - enum act_result - { - ACT_RESULT_NO_NEED = 0, - ACT_RESULT_FAILED, - ACT_RESULT_SUCCESS, - }; - - bool apply(gb::sane_config_schm* schm); - -public: - sane_dev(); - ~sane_dev(); - -public: - std::string name(void); - std::string current_configuration_name(void); - bool is_online(void); - SANE_Handle handle(void); - - bool open(const std::string& name); - void set_online(bool online); - void close(void); -}; diff --git a/app/scanner/setpicclrtool.cpp b/app/scanner/setpicclrtool.cpp deleted file mode 100644 index 3ebedd56..00000000 --- a/app/scanner/setpicclrtool.cpp +++ /dev/null @@ -1,316 +0,0 @@ -#include "setpicclrtool.h" -#include "ui_setpicclrtool.h" -#include "widget.h" -#include -#include - -setPicClrTool::setPicClrTool(QWidget *parent) : - QDialog(parent), - ui(new Ui::setPicClrTool) -{ - ui->setupUi(this); - setWindowFlags(Qt::Dialog | Qt::WindowCloseButtonHint); - setMouseTracking(true); - ui->inputEdt->setEnabled(false); - ui->outputEdt->setEnabled(false); - ui->inputEdt->setValidator(new QIntValidator(0, 255, this)); - ui->outputEdt->setValidator(new QIntValidator(0, 255, this)); - ui->widget->setFocus(Qt::MouseFocusReason); - connect(ui->widget,SIGNAL(mouseCoordSig(QPoint)),this,SLOT(mouseCoordSlot(QPoint))); - connect(ui->widget,SIGNAL(dragPointChecked(bool)),this,SLOT(lineEditEnable(bool))); - connect(ui->widget,SIGNAL(lineChangeSig()),this,SLOT(lineChangeSlot())); -} - -setPicClrTool::~setPicClrTool() -{ - delete ui; -} - -void setPicClrTool::getGrayTable(uchar *table, size_t length) -{ - QVector gray = getGrayALLPoint(); - for (size_t i = 0; i < length; i++) - table[i] = static_cast(gray[static_cast(i)]); -} - -void setPicClrTool::getRGBTable(uchar *table, size_t length) -{ - if (length != 768) - throw "length is not 768."; - - QVector rgb = getRgbALLPoint(); - QVector red = getRedALLPoint(); - QVector green = getGreenALLPoint(); - QVector blue = getBlueALLPoint(); - - - for (size_t i = 0; i < 256; i++) - { - //if (i == 255) - // int a = 0; - //table member order is B\G\R - table[i * 3 + 0] = static_cast(blue[rgb[static_cast(i)]]); - table[i * 3 + 1] = static_cast(green[rgb[static_cast(i)]]); - table[i * 3 + 2] = static_cast(red[rgb[static_cast(i)]]); - } -} - -//void setPicClrTool::setGrayTable(const uchar *table, size_t length) -//{ -// QVector gray; -// for (size_t i = 0; i < length; i++) -// gray[static_cast(i)] = int(table[i]); -// //ui->widget->setGrayALLPoint(gray); -//} - -//void setPicClrTool::setRGBTable(const uchar *table, size_t length) -//{ -// QVector rgb; -// QVector red; -// QVector green; -// QVector blue; -// for(int i = 0; i < 256; i++){ -// rgb.append(i); -// } -// for (size_t i = 0; i < length; i++){ -// red.append(int(table[i * 3 + 0])); -// green.append(int(table[i * 3 + 1])); -// blue.append(int(table[i * 3 + 2])); -// } - -//} - -void setPicClrTool::setColorMode(int colorMode) -{ - QVariant v(6); - if(colorMode == 0) - { - ui->colorSetCmb->setItemData(1,v,Qt::UserRole - 1); - } - else - { - ui->comboBox->setItemData(2,v,Qt::UserRole - 1); - ui->colorSetCmb->setItemData(0,v,Qt::UserRole - 1); - ui->colorSetCmb->setItemData(2,v,Qt::UserRole - 1); - ui->colorSetCmb->setItemData(3,v,Qt::UserRole - 1); - ui->colorSetCmb->setItemData(4,v,Qt::UserRole - 1); - ui->colorSetCmb->setCurrentIndex(1); - } -} - -QVector > setPicClrTool::getRGBKeyTable() -{ - QVector> plv; - plv.append(getRgbKeyPoint()); - plv.append(getRedKeyPoint()); - plv.append(getGreenKeyPoint()); - plv.append(getBlueKeyPoint()); - return plv; -} - -void setPicClrTool::setRGBKeyTable(QVector > &plv) -{ - setRgbKeyPoint(plv[0]); - setRedKeyPoint(plv[1]); - setGreenKeyPoint(plv[2]); - setBlueKeyPoint(plv[3]); -} - -QList setPicClrTool::getGrayKeyTable() -{ - return getGrayKeyPoint(); -} - -void setPicClrTool::setGrayKeyTable(QList &plv) -{ - setGrayKeyPoint(plv); -} - -QVector setPicClrTool::getRgbALLPoint() -{ - return ui->widget->getRgbALLPoint(); -} - -QList setPicClrTool::getRgbKeyPoint() const -{ - qDebug() << "setRgb" << ui->widget->getRgbKeyPoint(); - return ui->widget->getRgbKeyPoint(); -} - -void setPicClrTool::setRgbKeyPoint(const QList &pVec) -{ - qDebug() << "setRgb" << pVec; - ui->widget->setRgbKeyPoint(pVec); -} - -QList setPicClrTool::getRedKeyPoint() const -{ - return ui->widget->getRedKeyPoint(); -} - -void setPicClrTool::setRedKeyPoint(const QList &pVec) -{ - ui->widget->setRedKeyPoint(pVec); -} - -QList setPicClrTool::getBlueKeyPoint() const -{ - return ui->widget->getBlueKeyPoint(); -} - -void setPicClrTool::setBlueKeyPoint(const QList &pVec) -{ - ui->widget->setBlueKeyPoint(pVec); -} - -QList setPicClrTool::getGreenKeyPoint() const -{ - return ui->widget->getGreenKeyPoint(); -} - -void setPicClrTool::setGreenKeyPoint(const QList &pVec) -{ - ui->widget->setGreenKeyPoint(pVec); -} - -QList setPicClrTool::getGrayKeyPoint() const -{ - return ui->widget->getGrayKeyPoint(); -} - -void setPicClrTool::setGrayKeyPoint(const QList &pVec) -{ - ui->widget->setGrayKeyPoint(pVec); -} - -QVector setPicClrTool::getRedALLPoint() -{ - return ui->widget->getRedALLPoint(); -} - -QVector setPicClrTool::getBlueALLPoint() -{ - return ui->widget->getBlueALLPoint(); -} - -QVector setPicClrTool::getGreenALLPoint() -{ - return ui->widget->getGreenALLPoint(); -} - -QVector setPicClrTool::getGrayALLPoint() -{ - return ui->widget->getGrayALLPoint(); -} - -void setPicClrTool::mouseCoordSlot(QPoint pos) -{ - ui->inputEdt->setText(QString::number(pos.x())); - ui->outputEdt->setText(QString::number(pos.y())); -} - -void setPicClrTool::lineEditEnable(bool a) -{ - ui->inputEdt->setEnabled(a); - ui->outputEdt->setEnabled(a); -} - -void setPicClrTool::lineChangeSlot() -{ - ui->comboBox->setCurrentIndex(0); -} - -void setPicClrTool::on_colorSetCmb_currentIndexChanged(int index) -{ - (void)index; - /* switch(index){ - case RED: - ui->widget->updateCurLinePnt(RED); - break; - case GREEN: - ui->widget->updateCurLinePnt(GREEN); - break; - case BLUE: - ui->widget->updateCurLinePnt(BLUE); - break; - case RGB: - ui->widget->updateCurLinePnt(RGB); - break; - case GRAY: - ui->widget->updateCurLinePnt(GRAY); - break; - }*/ -} - -void setPicClrTool::on_comboBox_currentIndexChanged(int index) -{ - if(index == 0){ - ui->widget->initAllLstPnt(); - ui->widget->updateCurLinePnt(ui->colorSetCmb->currentIndex()); - return ; - } - ui->widget->initAllLstPnt(); - if(index == 1){ - rgbLine.clear(); - rgbLine.append(QPoint(0,255)); - rgbLine.append(QPoint(255,0)); - ui->widget->setLstPnt_RGB(rgbLine); - }else if(index == 2){ - redLine.clear(); - redLine.append(QPoint(33,255)); - redLine.append(QPoint(185,0)); - redLine.append(QPoint(119,127)); - greenLine.clear(); - greenLine.append(QPoint(28,255)); - greenLine.append(QPoint(132,0)); - greenLine.append(QPoint(77,127)); - blueLine.clear(); - blueLine.append(QPoint(25,255)); - blueLine.append(QPoint(108,0)); - blueLine.append(QPoint(60,127)); - ui->widget->setLstPnt_RED(redLine); - ui->widget->setLstPnt_GREEN(greenLine); - ui->widget->setLstPnt_BLUE(blueLine); - }else if(index == 4){ - rgbLine.clear(); - rgbLine.append(QPoint(0,0)); - rgbLine.append(QPoint(255,255)); - rgbLine.append(QPoint(103,125)); - ui->widget->setLstPnt_RGB(rgbLine); - }else if(index == 3){ - rgbLine.clear(); - rgbLine.append(QPoint(0,0)); - rgbLine.append(QPoint(255,255)); - rgbLine.append(QPoint(130,101)); - ui->widget->setLstPnt_RGB(rgbLine); - } - ui->widget->updateCurLinePnt(ui->colorSetCmb->currentIndex()); -} - -void setPicClrTool::on_inputEdt_textChanged(const QString &arg1) -{ - ui->widget->setXCoorVal(arg1.toInt()); -} - -void setPicClrTool::on_outputEdt_textChanged(const QString &arg1) -{ - ui->widget->setYCoorVal(arg1.toInt()); -} - -void setPicClrTool::on_pushButton_clicked() -{ - ui->widget->initSelectColLine(ui->colorSetCmb->currentIndex()); -} - -void setPicClrTool::on_buttonBox_accepted() -{ - //close(); - accept(); -} - -void setPicClrTool::on_buttonBox_rejected() -{ - ui->widget->initAllLstPnt(); - //close(); - reject(); -} diff --git a/app/scanner/setpicclrtool.h b/app/scanner/setpicclrtool.h deleted file mode 100644 index 59c4c25b..00000000 --- a/app/scanner/setpicclrtool.h +++ /dev/null @@ -1,82 +0,0 @@ -#ifndef SETPICCLRTOOL_H -#define SETPICCLRTOOL_H - -//#include "colorlinesetdef.h" -#include - -namespace Ui { -class setPicClrTool; -} - -class setPicClrTool : public QDialog -{ - Q_OBJECT - -public: - explicit setPicClrTool(QWidget *parent = nullptr); - ~setPicClrTool(); - - void getGrayTable(uchar* table, size_t length = 256); - - void getRGBTable(uchar* table, size_t length = 768); - -// void setGrayTable(const uchar* table, size_t length = 256); - -// void setRGBTable(const uchar* table, size_t length = 768); - - void setColorMode(int colorMode); - - QVector> getRGBKeyTable(); - void setRGBKeyTable(QVector>& plv); - QList getGrayKeyTable(); - void setGrayKeyTable(QList &plv); - - -private: - QVector getRgbALLPoint(); - QVector getRedALLPoint(); - QVector getBlueALLPoint(); - QVector getGreenALLPoint(); - QVector getGrayALLPoint(); - - QList getRgbKeyPoint()const; - void setRgbKeyPoint(const QList& pVec); - QList getRedKeyPoint()const; - void setRedKeyPoint(const QList& pVec); - QList getBlueKeyPoint()const; - void setBlueKeyPoint(const QList& pVec); - QList getGreenKeyPoint()const; - void setGreenKeyPoint(const QList& pVec); - QList getGrayKeyPoint()const; - void setGrayKeyPoint(const QList& pVec); - -private slots: - void mouseCoordSlot(QPoint);//set QLineEdit value by QPoint setting - void lineEditEnable(bool);//set 2 LineEdit enable status - void lineChangeSlot(); - - void on_colorSetCmb_currentIndexChanged(int index); - - void on_comboBox_currentIndexChanged(int index); - - void on_inputEdt_textChanged(const QString &arg1); - - void on_outputEdt_textChanged(const QString &arg1); - - void on_pushButton_clicked(); - - void on_buttonBox_accepted(); - - void on_buttonBox_rejected(); - -private: - Ui::setPicClrTool *ui; - QList linePoint; - QList greenLine; - QList redLine; - QList blueLine; - QList rgbLine; - QList grayLine; -}; - -#endif // SETPICCLRTOOL_H diff --git a/app/scanner/setpicclrtool.ui b/app/scanner/setpicclrtool.ui deleted file mode 100644 index 5ba412a6..00000000 --- a/app/scanner/setpicclrtool.ui +++ /dev/null @@ -1,167 +0,0 @@ - - - setPicClrTool - - - - 0 - 0 - 259 - 341 - - - - 自定义色调曲线 - - - - - - - - - 自定义 - - - - - 负片(RGB) - - - - - 彩色负片(RGB) - - - - - 较暗(RGB) - - - - - 较亮(RGB) - - - - - - - - - - - - false - - - - RGB - - - - - - - - - - - - - - - - - - - - 绿 - - - - - - - - 初始化 - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - true - - - Qt::StrongFocus - - - - - - - - - 输入: - - - - - - - true - - - - - - - 输出: - - - - - - - true - - - - - - - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - - - Widget - QWidget -
widget.h
- 1 -
-
- - -
diff --git a/app/scanner/widget.cpp b/app/scanner/widget.cpp deleted file mode 100644 index 71c943bf..00000000 --- a/app/scanner/widget.cpp +++ /dev/null @@ -1,855 +0,0 @@ -#include "widget.h" -#include "ui_widget.h" -#include "gaosixy.h" -#include -#include -#include -#include -using namespace std; - - -enum COLOR_TPYE -{ - RGB, - GRAY, - RED, - BLUE, - GREEN -}; - -Widget::Widget(QWidget *parent) : - QWidget(parent), - ui(new Ui::Widget) -{ - ui->setupUi(this); - setWindowTitle(tr("zuobiaozhou")); //设置标题栏标题 - //resize(300,300); //设置窗口初始大小 - //ui->table->setWindowFlags(Qt::WindowStaysOnTopHint); - initAllLstPnt(); - initInterface(); -} - -Widget::~Widget() -{ - delete ui; -} - -void Widget::setLstPnt_RGB(const QList &plst) -{ - rgbLine = QList(plst); -} - -QList Widget::getLstPnt_RGB() const -{ - return rgbLine; -} - -void Widget::setLstPnt_RED(const QList &plst) -{ - redLine = QList(plst); -} - -void Widget::setLstPnt_BLUE(const QList &plst) -{ - blueLine = QList(plst); -} - -QList Widget::getLstPnt_BLUE() const -{ - return blueLine; -} - -void Widget::setLstPnt_GREEN(const QList &plst) -{ - greenLine = QList(plst); -} - -QList Widget::getLstPnt_GREEN() const -{ - return greenLine; -} - -void Widget::setLstPnt_GRAY(const QList &plst) -{ - grayLine = QList(plst); -} - -QList Widget::getLstPnt_GRAY() const -{ - return grayLine; -} - -QVector Widget::getRgbALLPoint() -{ - return rgbALLPoint; -} - -QList Widget::getRgbKeyPoint() const -{ - return rgbLine; -} - -void Widget::setRgbKeyPoint(const QList &pLst) -{ - if(pLst.size() > 4) return; - rgbLine = QList(pLst); - pointLst.clear(); - pointLst = QList(rgbLine); - drawLineFromPoint(rgbLine, RGB); - update(); -} - -QVector Widget::getRedALLPoint() -{ - return redALLPoint; -} - -QList Widget::getRedKeyPoint() const -{ - return redLine; -} - -void Widget::setRedKeyPoint(const QList &pLst) -{ - if(pLst.size() > 4) return; - redLine = QList(pLst); - drawLineFromPoint(redLine, RED); - update(); -} - -QVector Widget::getBlueALLPoint() -{ - return blueALLPoint; -} - -QList Widget::getBlueKeyPoint() const -{ - return blueLine; -} - -void Widget::setBlueKeyPoint(const QList &pLst) -{ - if(pLst.size() > 4) return; - blueLine = QList(pLst); - drawLineFromPoint(blueLine, BLUE); - update(); -} - -QVector Widget::getGreenALLPoint() -{ - return greenALLPoint; -} - -QList Widget::getGreenKeyPoint() const -{ - return greenLine; -} - -void Widget::setGreenKeyPoint(const QList &pLst) -{ - if(pLst.size() > 4) return; - greenLine = QList(pLst); - drawLineFromPoint(greenLine, GREEN); - update(); -} - -QVector Widget::getGrayALLPoint() -{ - return grayALLPoint; -} - -QList Widget::getGrayKeyPoint() const -{ - return grayLine; -} - -void Widget::setGrayKeyPoint(const QList &pLst) -{ - if(pLst.size() > 4) return; - grayLine = QList(pLst); - pointLst.clear(); - pointLst = QList(grayLine); - drawLineFromPoint(grayLine, GRAY); - update(); -} - -void Widget::initAllLstPnt() -{ - pointLst.clear(); - pointLst.append(QPoint(0,0)); - pointLst.append(QPoint(255,255)); - redLine.clear(); - redLine.append(QPoint(0,0)); - redLine.append(QPoint(255,255)); - blueLine.clear(); - blueLine.append(QPoint(0,0)); - blueLine.append(QPoint(255,255)); - greenLine.clear(); - greenLine.append(QPoint(0,0)); - greenLine.append(QPoint(255,255)); - rgbLine.clear(); - rgbLine.append(QPoint(0,0)); - rgbLine.append(QPoint(255,255)); - grayLine.clear(); - grayLine.append(QPoint(0,0)); - grayLine.append(QPoint(255,255)); - drawLineFromPoint(redLine, RED); - drawLineFromPoint(rgbLine, RGB); - drawLineFromPoint(greenLine, GREEN); - drawLineFromPoint(blueLine, BLUE); - drawLineFromPoint(grayLine, GRAY); -} - -void Widget::initInterface() -{ - color = Qt::gray; - selectCol = RGB; - leftMouseMv = false; - newPoint = false; - clickLine = false; - dragPoint = -1; - setMouseTracking(true); - ui->widget_2->setStyleSheet("QWidget{background-color:qlineargradient(" - "spread:pad, x1:0, y1:0, x2:1, y2:0, " - "stop:0 rgba(0, 0, 0, 255), stop:1 rgba(255, 255, 255, 255))}"); - ui->widget->setStyleSheet("QWidget{background-color:qlineargradient(" - "spread:pad, x1:0, y1:1, x2:0, y2:0, " - "stop:0 rgba(0, 0, 0, 255), stop:1 rgba(255, 255, 255, 255))}"); -} - -void Widget::paintEvent(QPaintEvent *) -{ - QPainter painter(this); - painter.setRenderHint(QPainter::Antialiasing,true); //开启抗锯齿 - painter.translate(ui->widget->width(),ui->widget->height()); //坐标系统平移变换,把原点平移 - painter.scale(ui->table->width() / 258.0,ui->table->height() / 258.0); //坐标系统比例变换,使绘制的图形随窗口的放大而放大 - painter.scale(1,-1); - - drawCoordinate(painter); - drawBackColorBySlc(painter); - drawCoorScale(painter); - drawCurveByColor(painter); - drawAllPoint(painter); - - if(dragPoint < 0){ - setMouseTracking(true); - emit dragPointChecked(false); - } - painter.end(); -} - -void Widget::mousePressEvent(QMouseEvent *event) -{ - int x = (event->x() - ui->widget->width())*258/ui->table->width(); - int y = (height() - event->y()-ui->widget_2->height())*258/ui->table->height(); - //qDebug() << x << y; - if(event->button() == Qt::LeftButton){ - newPoint = false; - dragPoint = -1; - clickLine = false; - for(int i = 0; i < linePoint.size();i++){ - int px = linePoint.at(i).x(); - int py = linePoint.at(i).y(); - if(qAbs(x-px) <= 6 && qAbs(y-py) <= 6) - { - newPoint = true; - for(int j = 0; j < pointLst.size(); j++){ - int lx = pointLst.at(j).x(); - int ly = pointLst.at(j).y(); - if(qAbs(x-lx) <= 6 && qAbs(y-ly) <= 6){ - dragPoint = j; - clickLine = true; - leftMouseMv = true; - newPoint = false; - emit dragPointChecked(true); - setMouseTracking(false); - update(); - break; - } - } - if(newPoint && pointLst.size() < 4 && x > pointLst.at(0).x() && x < pointLst.at(1).x()){ - pointLst.append(QPoint(x,y)); - dragPoint = pointLst.size()-1; - leftMouseMv = true; - clickLine = true; - emit dragPointChecked(true); - setMouseTracking(false); - update(); - } - } - } - } - else if(event->button() == Qt::RightButton){ - for(int j = 0; j < pointLst.size(); j++){ - int lx = pointLst.at(j).x(); - int ly = pointLst.at(j).y(); - if(qAbs(x-lx) <= 7 && qAbs(y-ly) <= 5){ - if(j > 1) - pointLst.removeAt(j); - if(j == dragPoint){ - dragPoint = -1; - emit dragPointChecked(false); - }else if(j > dragPoint){ - dragPoint = dragPoint; - }else { - dragPoint = dragPoint-1; - } - update(); - break; - } - } - } - if(!clickLine){ - dragPoint = -1; - emit dragPointChecked(false); - setMouseTracking(true); - update(); - } - emit mouseCoordSig(QPoint(x,y)); -} - -void Widget::mouseMoveEvent(QMouseEvent *event) -{ - int x = (event->x() - ui->widget->width())*258/ui->table->width(); - int y = (height() - event->y()-ui->widget_2->height())*258/ui->table->height(); - if(x < 0) x = 0; - if(y < 0) y = 0; - if(x >= 255) x = 255; - if(y >= 255) y = 255; - //qDebug() << x << y; - if(leftMouseMv && dragPoint >= 0) - { - if(pointLst[dragPoint] != pointLst.at(0) && pointLst[dragPoint] != pointLst.at(1)){ - if(x <= pointLst.at(0).x()) x = pointLst.at(0).x() + 1; - if(x >= pointLst.at(1).x()) x = pointLst.at(1).x() - 1; - - if(pointLst.size() == 4){ - if(dragPoint == 2){ - if(pointLst[2].x() > pointLst[3].x() && x <= pointLst[3].x()) - x = pointLst[3].x() + 1; - if(pointLst[2].x() < pointLst[3].x() && x >= pointLst[3].x()) - x = pointLst[3].x() - 1; - } - else if(dragPoint == 3){ - if(pointLst[2].x() < pointLst[3].x() && x <= pointLst[2].x()) - x = pointLst[2].x() + 1; - if(pointLst[2].x() > pointLst[3].x() && x >= pointLst[2].x()) - x = pointLst[2].x() - 1; - } - } - } - else if(pointLst[dragPoint] == pointLst.at(0)){ - int min = 999; - for(int i = 1; i < pointLst.size(); i++){ - if(min > pointLst[i].x()) min = pointLst[i].x(); - } - if(x >= min) x = min-1; - } - else if(pointLst[dragPoint] == pointLst.at(1)){ - if(pointLst.size() > 2){ - int max = 0; - for(int i = 2; i < pointLst.size(); i++){ - if(max < pointLst[i].x()) max = pointLst[i].x(); - } - if(x <= max) x = max+1; - } - else if(pointLst.size() <= 2) - if(x <= pointLst.at(0).x()) x = pointLst.at(0).x()+1; - } - pointLst[dragPoint].setX(x); - pointLst[dragPoint].setY(y); - emit lineChangeSig(); - update(); - } - emit mouseCoordSig(QPoint(x,y)); -} - -void Widget::mouseReleaseEvent(QMouseEvent *) -{ - leftMouseMv = false; -} - -void Widget::enterEvent(QEvent *) -{ - setFocus(Qt::MouseFocusReason); -} - -void Widget::leaveEvent(QEvent *) -{ - if(dragPoint < 0) - emit mouseLeaveSig(); -} - -void Widget::setHist_RGB(const QVector &hist) -{ - rgbBackColor = QVector(hist); -} - -QVector Widget::getHist_RED() const -{ - return redBackColor; -} - -void Widget::setHist_RED(const QVector &hist) -{ - redBackColor = QVector(hist); -} - -QVector Widget::getHist_RGB() const -{ - return rgbBackColor; -} - -void Widget::setHist_GREEN(const QVector &hist) -{ - greenBackColor = QVector(hist); -} - -QVector Widget::getHist_GREEN() const -{ - return greenBackColor; -} - -void Widget::setHist_BLUE(const QVector &hist) -{ - blueBackColor = QVector(hist); -} - -QVector Widget::getHist_BLUE() const -{ - return blueBackColor; -} - -void Widget::setHist_GRAY(const QVector &hist) -{ - grayBackColor = QVector(hist); -} - -QVector Widget::getHist_GRAY() const -{ - return grayBackColor; -} - -void Widget::drawCoordinate(QPainter &painter) -{ - painter.setBrush(QColor(79,79,79)); - painter.drawRect(0, 0, 260, 260); - painter.drawLine(-2000,0,2000,0); - painter.drawLine(0,1500,0,-1500); -} - -void Widget::drawBackgroudColor(QPainter &painter,QVector &curCol) -{ - painter.setPen(QPen(color,1)); - painter.setBrush(color); - int max = 0; - for(int i = 0; i < curCol.size(); i++) - { - if(curCol.at(i) > max) - { - max = curCol.at(i); - } - } - for(int i = 0; i < curCol.size(); i++) - { - painter.drawRect(i, 0, 1, curCol.at(i)*255/max); - } - -} - -void Widget::drawBackColorBySlc(QPainter &painter) -{ - switch(selectCol){ - case RGB: - drawBackgroudColor(painter,rgbBackColor); - break; - case GREEN: - drawBackgroudColor(painter,greenBackColor); - break; - case BLUE: - drawBackgroudColor(painter,blueBackColor); - break; - case RED: - drawBackgroudColor(painter,redBackColor); - break; - case GRAY: - drawBackgroudColor(painter,grayBackColor); - break; - } -} - -void Widget::drawCoorScale(QPainter &painter) -{ - painter.setPen(QPen(Qt::gray,1)); - for(int i = 0; i < 260 ; i+=50) - { - if(i%50 == 0 && i >=50) - { - QVector dashes; - qreal space = 3; - dashes << 5 << space << 5 < &plst, const int& col) -{ - double **a; - int len = plst.size(); - a = new double *[len]; - for(int i = 0; i < len; i++){ - a[i] = new double[len+1]; - } - /*******通过pointLst的所有点给二维数组赋值生成行列式*******/ - for(int i = 0; i < len; i++){ - for(int j = 0;j < len + 1; j++){ - if(j < len) - a[i][j] = caculateAllMi(plst.at(i).x(),len-j-1); - if(j == len) - a[i][j] = plst.at(i).y(); - } - } - - /*******调用高斯消元法计算曲线方程的系数值********/ - GaoSiXY gaoSi; - double *result = new double[len] ; - gaoSi.solve(a,len,result); - - /********保存曲线方程 x 的系数(a,b,c,d....)********/ - QList xiNum; - for(int i = 0; i < len; i++){ - xiNum.append(*(result+i)); - } - - linePoint.clear(); - linePoints.clear(); - for(int i = 0; i < 256; i++){ - int x = i; - double yVal = 0; - for(int j = 0; j < len; j++){ - yVal += xiNum.at(j)*caculateAllMi(x,len-j-1); - } - int y = (int)yVal; - if(y > 255) y = 255; - if(y < 0) y = 0; - if(x < plst.at(0).x()) y = plst.at(0).y(); - if(x > plst.at(1).x()) y = plst.at(1).y(); - allLinePoints[x] = y; - linePoints.append(y); - linePoint.append(QPoint(x,y)); - } - - - if(col == RED){ - redALLPoint.clear(); - for(int i = 0; i < linePoint.size(); i++) - redALLPoint.append(linePoint.at(i).y()); - } - if(col == GREEN){ - greenALLPoint.clear(); - for(int i = 0; i < linePoint.size(); i++) - greenALLPoint.append(linePoint.at(i).y()); - } - if(col == BLUE){ - blueALLPoint.clear(); - for(int i = 0; i < linePoint.size(); i++) - blueALLPoint.append(linePoint.at(i).y()); - } - if(col == GRAY){ - grayALLPoint.clear(); - for(int i = 0; i < linePoint.size(); i++) - grayALLPoint.append(linePoint.at(i).y()); - } - if(col == RGB){ - rgbALLPoint.clear(); - for(int i = 0; i < linePoint.size(); i++) - { - rgbALLPoint.append(linePoint.at(i).y()); - } - } - - - for(int i = 0;i < len; i++){ - delete[] a[i]; - } - delete []a; -} - -void Widget::drawAllPoint(QPainter &painter) -{ - if(pointLst.size() > 0) - { - painter.setPen(QPen(Qt::white,1)); - painter.setBrush(Qt::white); - for(int i = 0; i < pointLst.size(); i++){ - painter.drawEllipse(pointLst.at(i),3,3); - } - if(dragPoint >= 0){ - painter.setPen(QPen(QColor(0, 245, 255),2)); - painter.drawEllipse(pointLst[dragPoint],4,4); - } - } - - if(selectCol == GREEN){ - greenLine.clear(); - greenLine = QList(pointLst); - } - else if(selectCol == RED){ - redLine.clear(); - redLine = QList(pointLst); - }else if(selectCol == BLUE){ - blueLine.clear(); - blueLine = QList(pointLst); - }else if(selectCol == RGB){ - rgbLine.clear(); - rgbLine = QList(pointLst); - }else if(selectCol == GRAY){ - grayLine.clear(); - grayLine = QList(pointLst); - } -} - -void Widget::drawCurveByColor(QPainter &painter) -{ - qDebug() << selectCol; - switch (selectCol) { - case RGB: - painter.setPen(QPen(Qt::white,1)); - drawLineFromPoint(rgbLine, RGB); - drawLineByVector(painter,rgbALLPoint); - if(redLine.size()>2 || redLine.at(0)!= QPoint(0,0) || redLine.at(1)!= QPoint(255,255)){ - painter.setPen(QPen(Qt::red,1)); - drawLineFromPoint(redLine,RED); - drawLineByVector(painter,redALLPoint); - } - if(blueLine.size()>2 || blueLine.at(0)!= QPoint(0,0) || blueLine.at(1)!= QPoint(255,255)){ - painter.setPen(QPen(Qt::blue,1)); - drawLineFromPoint(blueLine, BLUE); - drawLineByVector(painter,blueALLPoint); - } - if(greenLine.size()>2 || greenLine.at(0)!= QPoint(0,0) || greenLine.at(1)!= QPoint(255,255)){ - painter.setPen(QPen(Qt::green,1)); - drawLineFromPoint(greenLine, BLUE); - drawLineByVector(painter,greenALLPoint); - } - break; - case RED: - painter.setPen(QPen(Qt::red,1)); - drawLineFromPoint(redLine,RED); - drawLineByVector(painter,redALLPoint); - break; - case BLUE: - painter.setPen(QPen(Qt::blue,1)); - drawLineFromPoint(blueLine, BLUE); - drawLineByVector(painter,blueALLPoint); - break; - case GREEN: - painter.setPen(QPen(Qt::green,1)); - drawLineFromPoint(greenLine, GREEN); - drawLineByVector(painter,greenALLPoint); - break; - case GRAY: - painter.setPen(QPen(Qt::white,1)); - drawLineFromPoint(grayLine, GRAY); - drawLineByVector(painter,grayALLPoint); - break; - default: - break; - } - drawLineFromPoint(pointLst, -1); -} - -void Widget::drawLineByVector(QPainter &painter,QVector &pVec) -{ - for(int i = 0; i < pVec.size()-1; i++){ - painter.drawLine(QPoint(i,pVec.at(i)),QPoint(i+1,pVec.at(i+1))); - } - update(); -} - -int Widget::caculateAllMi(int num, int n) -{ - int val = 1; - if(n == 0) return 1; - for(int i = 0; i < n; i++){ - val *= num; - } - return val; -} - -void Widget::getCurLineLUT(uchar *table, size_t length) -{ - for(size_t i = 0; i < length; i++) - { - table[i] = allLinePoints[i]; - } -} - -QVector Widget::getCurLinePntVec() -{ - return linePoints; -} - -void Widget::updateCurLinePnt(const int& colType) -{ - dragPoint = -1; - selectCol = colType; - if(selectCol == GREEN){ - color = QColor(202, 255, 112); - pointLst.clear(); - pointLst = QList(greenLine); - ui->widget_2->setStyleSheet("QWidget{background-color:qlineargradient(" - "spread:pad, x1:0, y1:0, x2:1, y2:0, " - "stop:0 rgba(0, 0, 0, 255), stop:1 rgba(0, 255, 0, 255))}"); - ui->widget->setStyleSheet("QWidget{background-color:qlineargradient(" - "spread:pad, x1:0, y1:1, x2:0, y2:0, " - "stop:0 rgba(0, 0, 0, 255), stop:1 rgba(0, 255, 0, 255))}"); - }else if(selectCol == BLUE){ - color = QColor(131, 111, 255); - pointLst.clear(); - pointLst = QList(blueLine); - ui->widget_2->setStyleSheet("QWidget{background-color:qlineargradient(" - "spread:pad, x1:0, y1:0, x2:1, y2:0, " - "stop:0 rgba(0, 0, 0, 255), stop:1 rgba(0, 0, 255, 255))}"); - ui->widget->setStyleSheet("QWidget{background-color:qlineargradient(" - "spread:pad, x1:0, y1:1, x2:0, y2:0, " - "stop:0 rgba(0, 0, 0, 255), stop:1 rgba(0, 0, 255, 255))}"); - }else if(selectCol == RED){ - color = QColor(255, 160, 122); - pointLst.clear(); - pointLst = QList(redLine); - ui->widget_2->setStyleSheet("QWidget{background-color:qlineargradient(" - "spread:pad, x1:0, y1:0, x2:1, y2:0, " - "stop:0 rgba(0, 0, 0, 255), stop:1 rgba(255, 0, 0, 255))}"); - ui->widget->setStyleSheet("QWidget{background-color:qlineargradient(" - "spread:pad, x1:0, y1:1, x2:0, y2:0, " - "stop:0 rgba(0, 0, 0, 255), stop:1 rgba(255, 0, 0, 255))}"); - }else if(selectCol == GRAY){ - color = Qt::gray; - pointLst.clear(); - pointLst = QList(grayLine); - ui->widget_2->setStyleSheet("QWidget{background-color:qlineargradient(" - "spread:pad, x1:0, y1:0, x2:1, y2:0, " - "stop:0 rgba(0, 0, 0, 255), stop:1 rgba(255, 255, 255, 255))}"); - ui->widget->setStyleSheet("QWidget{background-color:qlineargradient(" - "spread:pad, x1:0, y1:1, x2:0, y2:0, " - "stop:0 rgba(0, 0, 0, 255), stop:1 rgba(255, 255, 255, 255))}"); - }else if(selectCol == RGB){ - color = Qt::gray; - pointLst.clear(); - pointLst = QList(rgbLine); - ui->widget_2->setStyleSheet("QWidget{background-color:qlineargradient(" - "spread:pad, x1:0, y1:0, x2:1, y2:0, " - "stop:0 rgba(0, 0, 0, 255), stop:1 rgba(255, 255, 255, 255))}"); - ui->widget->setStyleSheet("QWidget{background-color:qlineargradient(" - "spread:pad, x1:0, y1:1, x2:0, y2:0, " - "stop:0 rgba(0, 0, 0, 255), stop:1 rgba(255, 255, 255, 255))}"); - } - update(); -} - -void Widget::setXCoorVal(const int &xVal) -{ - if(dragPoint >= 0){ - int x = xVal; - if(pointLst[dragPoint] != pointLst.at(0) && pointLst[dragPoint] != pointLst.at(1)){ - if(pointLst.size() == 3 && x > pointLst.at(0).x() && x < pointLst.at(1).x()) - pointLst[dragPoint].setX(x); - - if(pointLst.size() == 4){ - if(dragPoint == 2){ - if(pointLst[2].x() > pointLst[3].x() && x > pointLst[3].x() && x < pointLst[1].x()) - pointLst[dragPoint].setX(x); - if(pointLst[2].x() < pointLst[3].x() && x < pointLst[3].x() && x > pointLst[0].x()) - pointLst[dragPoint].setX(x); - } - else if(dragPoint == 3){ - if(pointLst[2].x() < pointLst[3].x() && x > pointLst[2].x() && x < pointLst[1].x()) - pointLst[dragPoint].setX(x); - if(pointLst[2].x() > pointLst[3].x() && x < pointLst[2].x() && x > pointLst[0].x()) - pointLst[dragPoint].setX(x); - } - } - } - else if(pointLst[dragPoint] == pointLst.at(0)){ - int min = 999; - for(int i = 1; i < pointLst.size(); i++){ - if(min > pointLst[i].x()) min = pointLst[i].x(); - } - if(x < min) pointLst[dragPoint].setX(x); - } - else if(pointLst[dragPoint] == pointLst.at(1)){ - if(pointLst.size() > 2){ - int max = 0; - for(int i = 2; i < pointLst.size(); i++){ - if(max < pointLst[i].x()) max = pointLst[i].x(); - } - if(x > max) pointLst[dragPoint].setX(x); - } - else if(pointLst.size() <= 2) - if(x > pointLst.at(0).x()) pointLst[dragPoint].setX(x); - } - update(); - } -} - -void Widget::setYCoorVal(const int &yVal) -{ - if(dragPoint >= 0){ - pointLst[dragPoint].setY(yVal); - update(); - } -} - -void Widget::initSelectColLine(const int& colType) -{ - pointLst.clear(); - pointLst.append(QPoint(0,0)); - pointLst.append(QPoint(255,255)); - switch(colType){ - case RED: - redLine.clear(); - redLine.append(QPoint(0,0)); - redLine.append(QPoint(255,255)); - break; - case BLUE: - blueLine.clear(); - blueLine.append(QPoint(0,0)); - blueLine.append(QPoint(255,255)); - break; - case GREEN: - greenLine.clear(); - greenLine.append(QPoint(0,0)); - greenLine.append(QPoint(255,255)); - break; - case GRAY: - grayLine.clear(); - grayLine.append(QPoint(0,0)); - grayLine.append(QPoint(255,255)); - break; - case RGB: - initAllLstPnt(); - break; - } - dragPoint = -1; - leftMouseMv = false; - newPoint = false; - clickLine = false; - setMouseTracking(true); - qDebug() << "init"; - updateCurLinePnt(colType); -} - -void Widget::SetAllLinePnt(QVector &all) -{ - allLinePntSet = QVector(all); -} - diff --git a/app/scanner/widget.h b/app/scanner/widget.h deleted file mode 100644 index 0ff62115..00000000 --- a/app/scanner/widget.h +++ /dev/null @@ -1,132 +0,0 @@ -#ifndef WIDGET_H -#define WIDGET_H - -#include -#include -//#include "colorlinesetdef.h" - -namespace Ui { -class Widget; -} -// -//enum COLOR_TPYE -//{ -// RGB, -// GRAY, -// RED, -// BLUE, -// GREEN -//}; - -class Widget : public QWidget -{ - Q_OBJECT - -public: - explicit Widget(QWidget *parent = nullptr); - ~Widget(); - void initAllLstPnt(); //初始化所有颜色曲线 - void setLstPnt_RGB(const QList& plst); //设置生成RGB曲线的关键点(<=4) - QList getLstPnt_RGB()const; //获取生成RGB曲线的关键点 - void setLstPnt_RED(const QList& plst); - QList getLstPnt_RED()const; - void setLstPnt_BLUE(const QList& plst); - QList getLstPnt_BLUE()const; - void setLstPnt_GREEN(const QList& plst); - QList getLstPnt_GREEN()const; - void setLstPnt_GRAY(const QList& plst); - QList getLstPnt_GRAY()const; - - QVector getRgbALLPoint(); - QList getRgbKeyPoint()const; - void setRgbKeyPoint(const QList& pVec); - QVector getRedALLPoint(); - QList getRedKeyPoint()const; - void setRedKeyPoint(const QList& pVec); - QVector getBlueALLPoint(); - QList getBlueKeyPoint()const; - void setBlueKeyPoint(const QList& pVec); - QVector getGreenALLPoint(); - QList getGreenKeyPoint()const; - void setGreenKeyPoint(const QList& pVec); - QVector getGrayALLPoint(); - QList getGrayKeyPoint()const; - void setGrayKeyPoint(const QList& pVec); - - void setHist_RGB(const QVector& hist);//设置RGB的背景直方图 - QVector getHist_RGB()const;//获取RGB的背景直方图 - void setHist_RED(const QVector& hist); - QVector getHist_RED()const; - void setHist_BLUE(const QVector& hist); - QVector getHist_BLUE()const; - void setHist_GREEN(const QVector& hist); - QVector getHist_GREEN()const; - void setHist_GRAY(const QVector& hist); - QVector getHist_GRAY()const; - - void getCurLineLUT(uchar* table, size_t length = 256);//获取当前曲线上的所有点并存入table - QVector getCurLinePntVec();//获取当前曲线上的所有点 - void setXCoorVal(const int &xVal);//设置被选中的点的X坐标 - void setYCoorVal(const int &yVal);//设置被选中的点的Y坐标 - void updateCurLinePnt(const int& colType);//根据当前所选颜色(colType)重绘界面 - void initSelectColLine(const int& colType);//初始化当前所选颜色(colType)界面的曲线 - void SetAllLinePnt(QVector& all);//设置自定义曲线的所有点 - -signals: - void dragPointChecked(bool);//曲线上的点被选中的信号 - void mouseLeaveSig();//鼠标离开控件的信号 - void mouseCoordSig(QPoint pos);//鼠标的坐标信号 - void lineChangeSig(); - -private: - void initInterface();//初始化界面 - void paintEvent(QPaintEvent *); - void mousePressEvent(QMouseEvent*); - void mouseMoveEvent(QMouseEvent*); - void mouseReleaseEvent(QMouseEvent*); - void enterEvent(QEvent*); - void leaveEvent(QEvent*); - void drawCoordinate(QPainter&);//画直角坐标 - void drawBackgroudColor(QPainter&,QVector&);//画背景直方图 - void drawBackColorBySlc(QPainter&);//画不同的背景直方图 - void drawCoorScale(QPainter&);//画虚线刻度 - void drawLineFromPoint(QList &plst, const int &col);//根据多点求出曲线方程,并画出曲线 - void drawAllPoint(QPainter&);//画出生成曲线的关键点 - void drawCurveByColor(QPainter&);//画不同的颜色曲线 - void drawLineByVector(QPainter&,QVector&);//将数组的所有点连接绘制曲线 - int caculateAllMi(int num,int n);//计算num的n次方的值 - -private: - Ui::Widget *ui; - QVector rgbBackColor; - QVector redBackColor; - QVector blueBackColor; - QVector greenBackColor; - QVector grayBackColor; - QVector rgbALLPoint; - QVector redALLPoint; - QVector blueALLPoint; - QVector greenALLPoint; - QVector grayALLPoint; - QVector allLinePntSet; - QVector linePoints; - - //QList points; - QList pointLst; - QList linePoint; - QList greenLine; - QList redLine; - QList blueLine; - QList rgbLine; - QList grayLine; - QColor color; - - unsigned char allLinePoints[256]; - bool leftMouseMv; - bool newPoint; - bool clickLine; - int dragPoint; - int selectCol; -}; - -#endif // WIDGET_H diff --git a/app/scanner/widget.ui b/app/scanner/widget.ui deleted file mode 100644 index aaf5af1c..00000000 --- a/app/scanner/widget.ui +++ /dev/null @@ -1,91 +0,0 @@ - - - Widget - - - - 0 - 0 - 556 - 484 - - - - Widget - - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - 0 - 0 - - - - - 0 - 0 - - - - true - - - Qt::WheelFocus - - - QWidget{background-color:qlineargradient(spread:pad, x1:0, y1:1, x2:0, y2:0, stop:0 rgba(0, 0, 0, 255), stop:1 rgba(255, 255, 255, 255))} - - - - - - - - 0 - 20 - - - - true - - - Qt::NoFocus - - - - - - - - 0 - 0 - - - - QWidget{background-color:qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0, stop:0 rgba(0, 0, 0, 255), stop:1 rgba(255, 255, 255, 255))} - - - - - - - - - diff --git a/app/scanner/widget_imgproc_base.cpp b/app/scanner/widget_imgproc_base.cpp deleted file mode 100644 index 6a5723f0..00000000 --- a/app/scanner/widget_imgproc_base.cpp +++ /dev/null @@ -1,63 +0,0 @@ -#include "widget_imgproc_base.h" -#include "ui_widget_imgproc_base.h" - -Widget_Imgproc_Base::Widget_Imgproc_Base(QWidget *parent) : - QWidget(parent), - ui(new Ui::Widget_Imgproc_Base) -{ - ui->setupUi(this); - connect(ui->slider_brightness, SIGNAL(valueChanged(int)), ui->spin_brightness, SLOT(setValue(int))); - connect(ui->slider_contrast, SIGNAL(valueChanged(int)), ui->spin_contrast, SLOT(setValue(int))); -} - -Widget_Imgproc_Base::~Widget_Imgproc_Base() -{ - qDebug("~Widget_Imgproc_Base"); - - delete ui; -} - -void Widget_Imgproc_Base::setBrightness(int brightness) -{ - ui->spin_brightness->setValue(brightness); -} - -void Widget_Imgproc_Base::setContrast(int contrast) -{ - ui->spin_contrast->setValue(contrast); -} - -void Widget_Imgproc_Base::setGamma(double gamma) -{ - ui->dspin_gamma->setValue(gamma); -} - -void Widget_Imgproc_Base::setDefault() -{ - ui->spin_brightness->setValue(0); - ui->spin_contrast->setValue(0); - ui->dspin_gamma->setValue(1.0); -} - -void Widget_Imgproc_Base::on_spin_brightness_valueChanged(int arg1) -{ - ui->slider_brightness->setValue(arg1); - emit brightness_change(arg1); -} - -void Widget_Imgproc_Base::on_spin_contrast_valueChanged(int arg1) -{ - ui->slider_contrast->setValue(arg1); - emit contrast_change(arg1); -} - -void Widget_Imgproc_Base::on_slider_gamma_valueChanged(int value) -{ - ui->dspin_gamma->setValue(static_cast(value / 100.0)); -} - -void Widget_Imgproc_Base::on_dspin_gamma_valueChanged(double arg1) -{ - ui->slider_gamma->setValue(static_cast(arg1 * 100)); - emit gamma_change(arg1); -} diff --git a/app/scanner/widget_imgproc_base.h b/app/scanner/widget_imgproc_base.h deleted file mode 100644 index f26c46dd..00000000 --- a/app/scanner/widget_imgproc_base.h +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef WIDGET_IMGPROC_BASE_H -#define WIDGET_IMGPROC_BASE_H - -#include - -namespace Ui { -class Widget_Imgproc_Base; -} - -class Widget_Imgproc_Base : public QWidget -{ - Q_OBJECT - -public: - explicit Widget_Imgproc_Base(QWidget *parent = nullptr); - ~Widget_Imgproc_Base(); - - void setBrightness(int brightness); - void setContrast(int contrast); - void setGamma(double gamma); - void setDefault(); - -signals: - void brightness_change(int); - void contrast_change(int); - void gamma_change(double); - -private slots: - void on_spin_brightness_valueChanged(int arg1); - void on_spin_contrast_valueChanged(int arg1); - void on_slider_gamma_valueChanged(int position); - void on_dspin_gamma_valueChanged(double arg1); - -private: - Ui::Widget_Imgproc_Base *ui; -}; - -#endif // WIDGET_IMGPROC_BASE_H diff --git a/app/scanner/widget_imgproc_base.ui b/app/scanner/widget_imgproc_base.ui deleted file mode 100644 index 82d77601..00000000 --- a/app/scanner/widget_imgproc_base.ui +++ /dev/null @@ -1,186 +0,0 @@ - - - Widget_Imgproc_Base - - - - 0 - 0 - 489 - 284 - - - - Form - - - - - - Brightness - - - - - - -255 - - - 255 - - - 0 - - - Qt::Horizontal - - - QSlider::TicksAbove - - - 32 - - - - - - - - 150 - 0 - - - - -255 - - - 255 - - - 0 - - - 10 - - - - - - - - - - Contrast - - - - - - -127 - - - 127 - - - 0 - - - Qt::Horizontal - - - false - - - false - - - QSlider::TicksAbove - - - 16 - - - - - - - - 150 - 0 - - - - -127 - - - 127 - - - 0 - - - 10 - - - - - - - - - - Gamma correction - - - - - - 1 - - - 500 - - - 100 - - - Qt::Horizontal - - - QSlider::TicksAbove - - - 25 - - - - - - - - 150 - 0 - - - - 0.010000000000000 - - - 5.000000000000000 - - - 0.010000000000000 - - - 1.000000000000000 - - - - - - - - - - - diff --git a/app/scanner/widget_imgproc_sidebar.cpp b/app/scanner/widget_imgproc_sidebar.cpp deleted file mode 100644 index cae27b6e..00000000 --- a/app/scanner/widget_imgproc_sidebar.cpp +++ /dev/null @@ -1,100 +0,0 @@ -#include "widget_imgproc_sidebar.h" -#include "ui_widget_imgproc_sidebar.h" -#include -#include -#include "app_cfg.h" - -Widget_Imgproc_SideBar::Widget_Imgproc_SideBar(QWidget *parent) : - QWidget(parent), - ui(new Ui::Widget_Imgproc_SideBar) - , m_curImage(NULL) -{ - ui->setupUi(this); - ui->pbtn_ok->setEnabled(false); - - connect(ui->slider_brightness, SIGNAL(valueChanged(int)), ui->spin_brightness, SLOT(setValue(int))); - connect(ui->slider_contrast, SIGNAL(valueChanged(int)), ui->spin_contrast, SLOT(setValue(int))); -} - -Widget_Imgproc_SideBar::~Widget_Imgproc_SideBar() -{ - if (m_curImage != nullptr) - { - HGBase_DestroyImage(m_curImage); - } - delete ui; -} - -void Widget_Imgproc_SideBar::setImage(HGImage image) -{ - HGBase_DestroyImage(m_curImage); - HGBase_CloneImage(image, 0, 0, &m_curImage); - on_pbtn_restoreDefault_clicked(); -} - -void Widget_Imgproc_SideBar::enableUI(bool enable) -{ - ui->pbtn_ok->setEnabled(enable); -} - -void Widget_Imgproc_SideBar::paintEvent(QPaintEvent *e) -{ - (void)e; - QPainter p(this); - p.fillRect(0, 0, this->width(), this->height(), qRgb(240, 240, 240)); - p.setPen(QColor("gray")); - p.drawRect(0, 0, width() -1, height() -1); -} - -void Widget_Imgproc_SideBar::on_spin_brightness_valueChanged(int arg1) -{ - ui->slider_brightness->setValue(arg1); - emit applyToImage(m_curImage, ui->spin_brightness->value(), ui->spin_contrast->value(), - ui->dspin_gamma->value(), ui->checkBox_enhanceText->isChecked()); -} - -void Widget_Imgproc_SideBar::on_spin_contrast_valueChanged(int arg1) -{ - ui->slider_contrast->setValue(arg1); - emit applyToImage(m_curImage, ui->spin_brightness->value(), ui->spin_contrast->value(), - ui->dspin_gamma->value(), ui->checkBox_enhanceText->isChecked()); -} - -void Widget_Imgproc_SideBar::on_dspin_gamma_valueChanged(double arg1) -{ - ui->slider_gamma->setValue(static_cast(arg1 * 100)); - emit applyToImage(m_curImage, ui->spin_brightness->value(), ui->spin_contrast->value(), - ui->dspin_gamma->value(), ui->checkBox_enhanceText->isChecked()); -} - -void Widget_Imgproc_SideBar::on_slider_gamma_valueChanged(int value) -{ - ui->dspin_gamma->setValue(static_cast(value / 100.0)); - emit applyToImage(m_curImage, ui->spin_brightness->value(), ui->spin_contrast->value(), - ui->dspin_gamma->value(), ui->checkBox_enhanceText->isChecked()); -} - -void Widget_Imgproc_SideBar::on_pbtn_restoreDefault_clicked() -{ - ui->spin_brightness->setValue(0); - ui->spin_contrast->setValue(0); - ui->dspin_gamma->setValue(1.0); - ui->checkBox_enhanceText->setChecked(false); -} - -void Widget_Imgproc_SideBar::on_pbtn_ok_clicked() -{ - emit finish(true); -} - -void Widget_Imgproc_SideBar::on_pbtn_cancel_clicked() -{ - on_pbtn_restoreDefault_clicked(); - emit finish(false); -} - -void Widget_Imgproc_SideBar::on_checkBox_enhanceText_toggled(bool checked) -{ - emit applyToImage(m_curImage, ui->spin_brightness->value(), ui->spin_contrast->value(), - ui->dspin_gamma->value(), ui->checkBox_enhanceText->isChecked()); -} diff --git a/app/scanner/widget_imgproc_sidebar.h b/app/scanner/widget_imgproc_sidebar.h deleted file mode 100644 index 2936c206..00000000 --- a/app/scanner/widget_imgproc_sidebar.h +++ /dev/null @@ -1,52 +0,0 @@ -#ifndef WIDGET_IMGPROC_SIDEBAR_H -#define WIDGET_IMGPROC_SIDEBAR_H - -#include -#include "imgproc/HGImgProc.h" - -namespace Ui { -class Widget_Imgproc_SideBar; -} - -class Widget_Imgproc_SideBar : public QWidget -{ - Q_OBJECT - -public: - explicit Widget_Imgproc_SideBar(QWidget *parent = nullptr); - ~Widget_Imgproc_SideBar(); - - void setImage(HGImage image); - void enableUI(bool enable); - -protected: - void paintEvent(QPaintEvent *e) override; - -signals: - void applyToImage(HGImage img, int brightness, int contrast, double gamma, bool enhanceText); - void finish(bool ok); - -private slots: - void on_spin_brightness_valueChanged(int arg1); - - void on_spin_contrast_valueChanged(int arg1); - - void on_dspin_gamma_valueChanged(double arg1); - - void on_slider_gamma_valueChanged(int value); - - void on_pbtn_restoreDefault_clicked(); - - void on_pbtn_ok_clicked(); - - void on_pbtn_cancel_clicked(); - - void on_checkBox_enhanceText_toggled(bool checked); - -private: - Ui::Widget_Imgproc_SideBar *ui; - - HGImage m_curImage; -}; - -#endif // WIDGET_IMGPROC_SIDEBAR_H diff --git a/app/scanner/widget_imgproc_sidebar.ui b/app/scanner/widget_imgproc_sidebar.ui deleted file mode 100644 index a3ef4767..00000000 --- a/app/scanner/widget_imgproc_sidebar.ui +++ /dev/null @@ -1,348 +0,0 @@ - - - Widget_Imgproc_SideBar - - - - 0 - 0 - 220 - 376 - - - - Form - - - - - 60 - 340 - 75 - 23 - - - - Ok - - - - - - 140 - 340 - 75 - 23 - - - - Cancel - - - - - - 10 - 250 - 143 - 22 - - - - - - - Enhance Text - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - 10 - 10 - 201 - 71 - - - - Brightness - - - - - 10 - 35 - 121 - 27 - - - - - 121 - 27 - - - - -255 - - - 255 - - - 0 - - - false - - - Qt::Horizontal - - - QSlider::TicksAbove - - - 32 - - - - - - 140 - 40 - 51 - 20 - - - - - 0 - 0 - - - - - 51 - 20 - - - - -255 - - - 255 - - - 0 - - - 10 - - - - - - - 10 - 170 - 201 - 71 - - - - Gamma correction - - - - - 10 - 35 - 121 - 27 - - - - - 121 - 27 - - - - 1 - - - 500 - - - 100 - - - false - - - Qt::Horizontal - - - QSlider::TicksAbove - - - 25 - - - - - - 140 - 40 - 51 - 20 - - - - - 0 - 0 - - - - - 51 - 20 - - - - 0.010000000000000 - - - 5.000000000000000 - - - 0.010000000000000 - - - 1.000000000000000 - - - - - - - 10 - 90 - 201 - 71 - - - - Contrast - - - - - 10 - 34 - 121 - 27 - - - - - 121 - 27 - - - - -127 - - - 127 - - - 0 - - - false - - - Qt::Horizontal - - - false - - - false - - - QSlider::TicksAbove - - - 16 - - - - - - 140 - 40 - 51 - 20 - - - - - 0 - 0 - - - - - 51 - 20 - - - - -127 - - - 127 - - - 0 - - - 10 - - - - - - - 10 - 290 - 104 - 23 - - - - Restore defaults - - - - - - diff --git a/app/scanner/widget_statusbar.cpp b/app/scanner/widget_statusbar.cpp deleted file mode 100644 index 002bb7f3..00000000 --- a/app/scanner/widget_statusbar.cpp +++ /dev/null @@ -1,89 +0,0 @@ -#include "widget_statusbar.h" -#include "ui_widget_statusbar.h" -#include - -Widget_StatusBar::Widget_StatusBar(QAction *zoomIn, QAction *zoomOut, QWidget *parent) : - QWidget(parent), - ui(new Ui::Widget_StatusBar) -{ - ui->setupUi(this); - - ui->lbl_devSts->installEventFilter(this); - - QToolBar *toolBar = new QToolBar(this); - toolBar->setFixedHeight(20); - - m_lbl_scale = new QLabel("0%", toolBar); - m_lbl_scale->setFixedWidth(40); - m_lbl_scale->setAlignment(Qt::AlignHCenter); - - toolBar->addAction(zoomIn); - toolBar->addWidget(m_lbl_scale); - toolBar->addAction(zoomOut); - reinterpret_cast(this->layout())->addWidget(toolBar, 0, Qt::AlignRight); - - ui->lbl_page->setText(tr("page")); - ui->lbl_size->setText(tr("size")); - ui->lbl_mousePos->setText(tr("mousePos")); - m_lbl_scale->setText(tr("zoom")); -} - -Widget_StatusBar::~Widget_StatusBar() -{ - qDebug("~Widget_StatusBar"); - - delete ui; -} - -void Widget_StatusBar::setPageInfo(int total, int page) -{ - ui->lbl_page->setText(QString("%1/%2").arg(page + 1).arg(total)); -} - -void Widget_StatusBar::setPixelInfo(int width, int height, int bpp) -{ - ui->lbl_size->setText(QString("%1*%2*%3").arg(width).arg(height).arg(bpp)); -} - -void Widget_StatusBar::setMousePosInfo(int x, int y) -{ - ui->lbl_mousePos->setText(QString("X:%1, Y:%2").arg(x).arg(y)); -} - -void Widget_StatusBar::setScale(double scale) -{ - m_lbl_scale->setText(QString("%1%").arg((int)(scale * 100.0))); -} - -void Widget_StatusBar::setDeviceStatusInfo(const QString &info, bool err) -{ - ui->lbl_devSts->setText(info); - - if (err) - { - QPalette pe; - pe.setColor(QPalette::WindowText, Qt::red); - ui->lbl_devSts->setPalette(pe); - } - else - { - QPalette pe; - pe.setColor(QPalette::WindowText, Qt::black); - ui->lbl_devSts->setPalette(pe); - } -} - -bool Widget_StatusBar::eventFilter(QObject* obj, QEvent* event) -{ - if (obj == ui->lbl_devSts) - { - if (event->type() == QEvent::MouseButtonDblClick) - { - emit statusInfoDblClick(); - return true; - } - - } - - return false; -} diff --git a/app/scanner/widget_statusbar.h b/app/scanner/widget_statusbar.h deleted file mode 100644 index cc6550df..00000000 --- a/app/scanner/widget_statusbar.h +++ /dev/null @@ -1,37 +0,0 @@ -#ifndef WIDGET_STATUSBAR_H -#define WIDGET_STATUSBAR_H - -#include -#include - -namespace Ui { -class Widget_StatusBar; -} - -class Widget_StatusBar : public QWidget -{ - Q_OBJECT - -public: - explicit Widget_StatusBar(QAction *zoomIn, QAction *zoomOut, QWidget *parent = nullptr); - ~Widget_StatusBar(); - - void setPageInfo(int total, int page); - void setPixelInfo(int width, int height, int bpp); - void setMousePosInfo(int x, int y); - void setScale(double scale); - void setDeviceStatusInfo(const QString &info, bool err); - -signals: - void statusInfoDblClick(); - -private: - virtual bool eventFilter(QObject* obj, QEvent* event) override; - -private: - Ui::Widget_StatusBar *ui; - - QLabel* m_lbl_scale; -}; - -#endif // WIDGET_STATUSBAR_H diff --git a/app/scanner/widget_statusbar.ui b/app/scanner/widget_statusbar.ui deleted file mode 100644 index ae9de805..00000000 --- a/app/scanner/widget_statusbar.ui +++ /dev/null @@ -1,111 +0,0 @@ - - - Widget_StatusBar - - - - 0 - 0 - 603 - 50 - - - - Form - - - - 5 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - QFrame::VLine - - - QFrame::Sunken - - - - - - - 0/0 - - - - - - - Qt::Vertical - - - - - - - 0*0*0 - - - - - - - Qt::Vertical - - - - - - - X:0, Y:0 - - - - - - - QFrame::VLine - - - QFrame::Sunken - - - - - - - - diff --git a/build2/qt/HGScanner/HGScanner.pro b/build2/qt/HGScanner/HGScanner.pro deleted file mode 100644 index 4d715c75..00000000 --- a/build2/qt/HGScanner/HGScanner.pro +++ /dev/null @@ -1,339 +0,0 @@ -QT += core gui - -greaterThan(QT_MAJOR_VERSION, 4): QT += widgets - -TEMPLATE = app -DEFINES += UNTITLED_LIBRARY - -CONFIG += c++11 - -# The following define makes your compiler emit warnings if you use -# any Qt feature that has been marked deprecated (the exact warnings -# depend on your compiler). Please consult the documentation of the -# deprecated API in order to know how to port your code away from it. -DEFINES += QT_DEPRECATED_WARNINGS -DEFINES += QT_NO_VERSION_TAGGING - -# You can also make your code fail to compile if it uses deprecated APIs. -# In order to do so, uncomment the following line. -# You can also select to disable deprecated APIs only up to a certain version of Qt. -#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 - -include($$PWD/../HGOEM.pri) - -if (contains(DEFINES, OEM_HANWANG)) { - RC_ICONS = ../../../app/scanner/image_rsc/logo/Hanvon_logo1.ico - TARGET = HanvonScan -} else { - if (contains(DEFINES, OEM_LISICHENG)) { - RC_ICONS = ../../../app/scanner/image_rsc/logo/Lanxum_logo.ico - TARGET = LanxumScan - } else { - if (contains(DEFINES, OEM_CANGTIAN)) { - RC_ICONS = ../../../app/scanner/image_rsc/logo/Cumtenn_logo.ico - TARGET = CumtennScan - } else { - if (contains(DEFINES, OEM_ZHONGJING)) { - RC_ICONS = ../../../app/scanner/image_rsc/logo/Microtek_logo.ico - TARGET = MicrotekScan - } else { - if (contains(DEFINES, OEM_ZIGUANG)) { - RC_ICONS = ../../../app/scanner/image_rsc/logo/uniscan.ico - TARGET = UniScan - } else { - if (contains(DEFINES, OEM_NEUTRAL)) { - RC_ICONS = ../../../app/scanner/image_rsc/logo/NoBrand_logo.ico - TARGET = NeuScan - } else { - if (contains(DEFINES, OEM_DELI)) { - RC_ICONS = ../../../app/scanner/image_rsc/logo/deli.ico - TARGET = "DELI SCAN" - } else { - RC_ICONS = ../../../app/scanner/image_rsc/logo/logo.ico - TARGET = HuaGoScan - } - } - } - } - } - } -} - -CONFIG(debug, debug|release) { - MY_CONFIGURE = Debug -} -CONFIG(release, debug|release) { - MY_CONFIGURE = Release -} - -win32 { - - MY_OS = windows - - contains(QT_ARCH, i386) { - MY_ARCH = x86 - } - contains(QT_ARCH, x86_64) { - MY_ARCH = x64 - } - - CONFIG(release, debug|release) { - QMAKE_LFLAGS_RELEASE += /MAP - QMAKE_CFLAGS_RELEASE += /Zi - QMAKE_LFLAGS_RELEASE += /debug /opt:ref - } - - LIBS += -lgdi32 -lgdiplus -ldbghelp -luser32 -ladvapi32 - LIBS += -L$$PWD/../../build/$${MY_OS}/$${OEM_NAME}/$${MY_ARCH}/$${MY_CONFIGURE} -l$${OEM_PREFIX}Base -l$${OEM_PREFIX}ImgFmt \ - -l$${OEM_PREFIX}ImgProc - LIBS += -L$$PWD/../../../../sdk/lib/win/$${MY_ARCH}/OEM/$${OEM_NAME} -lsane -llang - - # sane.dll - LIBS += -L$$PWD/../../../../release/win/$${MY_ARCH}/OEM/$${OEM_NAME} -} - -unix { - - DISTRIBUTION = $$system(cat /etc/issue | cut -d\' \' -f1) - contains(DISTRIBUTION, UnionTech) { - MY_OS = uos - } else { - MY_OS = kylin - } - - contains(QT_ARCH, x86_64) { - MY_ARCH = amd64 - MY_ARCH2 = x86_64 - } - contains(QT_ARCH, arm64) { - MY_ARCH = aarch64 - MY_ARCH2 = aarch64 - } - contains(QT_ARCH, mips64) { - MY_ARCH = mips64 - MY_ARCH2 = mips64 - } - contains(QT_ARCH, loongarch64) { - MY_ARCH = loongarch64 - MY_ARCH2 = loongarch64 - } - contains(QT_ARCH, sw_64) { - MY_ARCH = sw_64 - MY_ARCH2 = sw_64 - } - - CONFIG += unversioned_libname unversioned_soname - QMAKE_CXXFLAGS += -fvisibility=hidden - # QMAKE_LFLAGS += -static-libstdc++ -static-libgcc - QMAKE_LFLAGS += -Wl,-rpath,\'\$\$ORIGIN\' -Wl,--exclude-libs,ALL - QMAKE_LFLAGS += -z defs -B direct - - LIBS += -lpthread -ldl - LIBS += -L$$PWD/../../build/$${MY_OS}/$${OEM_NAME}/$${MY_ARCH}/$${MY_CONFIGURE} -l$${OEM_PREFIX2}Base -l$${OEM_PREFIX2}ImgFmt \ - -l$${OEM_PREFIX2}ImgProc - LIBS += -L$$PWD/../../../../release/$${MY_OS}/$${MY_ARCH2} -lsane-$${OEM_PREFIX3}sane -llang -} - -INCLUDEPATH += $$PWD/../../../app/scanner -INCLUDEPATH += $$PWD/../../../modules -INCLUDEPATH += $$PWD/../../../utility -INCLUDEPATH += $$PWD/../../../../sdk/include - -DESTDIR = $$PWD/../../build/$${MY_OS}/$${OEM_NAME}/$${MY_ARCH}/$${MY_CONFIGURE} -UI_DIR = $$PWD/../../temp/$${MY_OS}/$${OEM_NAME}/$${MY_ARCH}/$${MY_CONFIGURE}/$${TARGET} -MOC_DIR = $$PWD/../../temp/$${MY_OS}/$${OEM_NAME}/$${MY_ARCH}/$${MY_CONFIGURE}/$${TARGET} -OBJECTS_DIR = $$PWD/../../temp/$${MY_OS}/$${OEM_NAME}/$${MY_ARCH}/$${MY_CONFIGURE}/$${TARGET} -RCC_DIR = $$PWD/../../temp/$${MY_OS}/$${OEM_NAME}/$${MY_ARCH}/$${MY_CONFIGURE}/$${TARGET} - -message(MY_OS: $$MY_OS) -message(MY_ARCH: $$MY_ARCH) -message(OEM_PREFIX: $$OEM_PREFIX) -message(OEM_PREFIX2: $$OEM_PREFIX2) -message(OEM_NAME: $$OEM_NAME) -message(MY_CONFIGURE: $$MY_CONFIGURE) -message(TARGET: $$TARGET) -message(DESTDIR: $$DESTDIR) -message(UI_DIR: $$UI_DIR) -message(MOC_DIR: $$MOC_DIR) -message(OBJECTS_DIR: $$OBJECTS_DIR) -message(RCC_DIR: $$RCC_DIR) - -win32 { - - CONFIG(release, debug|release) { - DESTEXE_PATH = $${PWD}/../../../../release/win/$${MY_ARCH}/$${MY_CONFIGURE}/ - DESTEXE_PATH = $$replace(DESTEXE_PATH, /, \\) - message(DESTEXE_PATH: $$DESTEXE_PATH) - - SRCEXE_FILE = $${DESTDIR}/$${TARGET}.exe - SRCEXE_FILE = $$replace(SRCEXE_FILE, /, \\) - message(SRCEXE_FILE: $$SRCEXE_FILE) - SRCPDB_FILE = $${DESTDIR}/$${TARGET}.pdb - SRCPDB_FILE = $$replace(SRCPDB_FILE, /, \\) - message(SRCPDB_FILE: $$SRCPDB_FILE) - - QMAKE_POST_LINK += xcopy /y \"$$SRCEXE_FILE\" $$DESTEXE_PATH && xcopy /y \"$$SRCPDB_FILE\" $$DESTEXE_PATH - } -} - -unix { - - CONFIG(release, debug|release) { - DESTEXE_PATH = $$PWD/../../../../release/$${MY_OS}/$${MY_ARCH2}/ - message(DESTEXE_PATH: $$DESTEXE_PATH) - - SRCEXE_FILE = $${DESTDIR}/$${TARGET} - message(SRCEXE_FILE: $$SRCEXE_FILE) - - QMAKE_POST_LINK += cp $$SRCEXE_FILE $$DESTEXE_PATH - } -} - -SOURCES += \ - ../../../app/scanner/HGImgThumb.cpp \ - ../../../app/scanner/HGImgView.cpp \ - ../../../app/scanner/HGUIGlobal.cpp \ - ../../../app/scanner/VersionDll.cpp \ - ../../../app/scanner/app_cfg.cpp \ - ../../../app/scanner/cfg/cJSON.c \ - ../../../app/scanner/cfg/gb_json.cpp \ - ../../../app/scanner/cutdialog.cpp \ - ../../../app/scanner/cutpapertool.cpp \ - ../../../app/scanner/device_menu.cpp \ - ../../../app/scanner/dialog_admin.cpp \ - ../../../app/scanner/dialog_aquireinto.cpp \ - ../../../app/scanner/dialog_clrcache.cpp \ - ../../../app/scanner/dialog_export.cpp \ - ../../../app/scanner/dialog_exportimagefile.cpp \ - ../../../app/scanner/dialog_feedback.cpp \ - ../../../app/scanner/dialog_fullscreen.cpp \ - ../../../app/scanner/dialog_imageeditor.cpp \ - ../../../app/scanner/dialog_imageinfo.cpp \ - ../../../app/scanner/dialog_imgproc_adjust.cpp \ - ../../../app/scanner/dialog_imgproc_autocrop.cpp \ - ../../../app/scanner/dialog_input.cpp \ - ../../../app/scanner/dialog_insertindex.cpp \ - ../../../app/scanner/dialog_log.cpp \ - ../../../app/scanner/dialog_logmanager.cpp \ - ../../../app/scanner/dialog_moveto.cpp \ - ../../../app/scanner/dialog_multirotate.cpp \ - ../../../app/scanner/dialog_multirotateimagefile.cpp \ - ../../../app/scanner/dialog_openimageindex.cpp \ - ../../../app/scanner/dialog_passwordchange.cpp \ - ../../../app/scanner/dialog_saveas.cpp \ - ../../../app/scanner/dialog_savemessagebox.cpp \ - ../../../app/scanner/dialog_updateprogress.cpp \ - ../../../app/scanner/dialog_upgrade.cpp \ - ../../../app/scanner/dialog_upgradefirmware.cpp \ - ../../../app/scanner/dialog_writesettings.cpp \ - ../../../app/scanner/dialog_wrong_img.cpp \ - ../../../app/scanner/gaosixy.cpp \ - ../../../app/scanner/graphicsscene.cpp \ - ../../../app/scanner/hg_settingdialog.cpp \ - ../../../app/scanner/main.cpp \ - ../../../app/scanner/mainwindow.cpp \ - ../../../app/scanner/ocrPdf.cpp \ - ../../../app/scanner/sane_device.cpp \ - ../../../app/scanner/setpicclrtool.cpp \ - ../../../app/scanner/widget.cpp \ - ../../../app/scanner/widget_imgproc_base.cpp \ - ../../../app/scanner/widget_statusbar.cpp \ - ../../../app/scanner/widget_imgproc_sidebar.cpp \ - ../../../utility/HGString.cpp - -HEADERS += \ - ../../../app/scanner/HGImgThumb.h \ - ../../../app/scanner/HGImgView.h \ - ../../../app/scanner/HGUIGlobal.h \ - ../../../app/scanner/VersionDll.h \ - ../../../app/scanner/app_cfg.h \ - ../../../app/scanner/cfg/cJSON.h \ - ../../../app/scanner/cfg/gb_json.h \ - ../../../app/scanner/custom_file_dialog.h \ - ../../../app/scanner/cutdialog.h \ - ../../../app/scanner/cutpapertool.h \ - ../../../app/scanner/device_menu.h \ - ../../../app/scanner/dialog_admin.h \ - ../../../app/scanner/dialog_aquireinto.h \ - ../../../app/scanner/dialog_clrcache.h \ - ../../../app/scanner/dialog_export.h \ - ../../../app/scanner/dialog_exportimagefile.h \ - ../../../app/scanner/dialog_feedback.h \ - ../../../app/scanner/dialog_fullscreen.h \ - ../../../app/scanner/dialog_imageeditor.h \ - ../../../app/scanner/dialog_imageinfo.h \ - ../../../app/scanner/dialog_imgproc_adjust.h \ - ../../../app/scanner/dialog_imgproc_autocrop.h \ - ../../../app/scanner/dialog_input.h \ - ../../../app/scanner/dialog_insertindex.h \ - ../../../app/scanner/dialog_log.h \ - ../../../app/scanner/dialog_logmanager.h \ - ../../../app/scanner/dialog_moveto.h \ - ../../../app/scanner/dialog_multirotate.h \ - ../../../app/scanner/dialog_multirotateimagefile.h \ - ../../../app/scanner/dialog_openimageindex.h \ - ../../../app/scanner/dialog_passwordchange.h \ - ../../../app/scanner/dialog_saveas.h \ - ../../../app/scanner/dialog_savemessagebox.h \ - ../../../app/scanner/dialog_updateprogress.h \ - ../../../app/scanner/dialog_upgrade.h \ - ../../../app/scanner/dialog_upgradefirmware.h \ - ../../../app/scanner/dialog_writesettings.h \ - ../../../app/scanner/dialog_wrong_img.h \ - ../../../app/scanner/gaosixy.h \ - ../../../app/scanner/graphicsscene.h \ - ../../../app/scanner/hg_settingdialog.h \ - ../../../app/scanner/mainwindow.h \ - ../../../app/scanner/ocrPdf.h \ - ../../../app/scanner/sane_device.h \ - ../../../app/scanner/setpicclrtool.h \ - ../../../app/scanner/widget.h \ - ../../../app/scanner/widget_imgproc_base.h \ - ../../../app/scanner/widget_statusbar.h \ - ../../../app/scanner/widget_imgproc_sidebar.h \ - ../../../utility/HGString.h - -FORMS += \ - ../../../app/scanner/cutdialog.ui \ - ../../../app/scanner/cutpapertool.ui \ - ../../../app/scanner/dialog_admin.ui \ - ../../../app/scanner/dialog_aquireinto.ui \ - ../../../app/scanner/dialog_clrcache.ui \ - ../../../app/scanner/dialog_export.ui \ - ../../../app/scanner/dialog_exportimagefile.ui \ - ../../../app/scanner/dialog_feedback.ui \ - ../../../app/scanner/dialog_fullscreen.ui \ - ../../../app/scanner/dialog_imageeditor.ui \ - ../../../app/scanner/dialog_imageinfo.ui \ - ../../../app/scanner/dialog_imgproc_adjust.ui \ - ../../../app/scanner/dialog_imgproc_autocrop.ui \ - ../../../app/scanner/dialog_input.ui \ - ../../../app/scanner/dialog_insertindex.ui \ - ../../../app/scanner/dialog_log.ui \ - ../../../app/scanner/dialog_logmanager.ui \ - ../../../app/scanner/dialog_moveto.ui \ - ../../../app/scanner/dialog_multirotate.ui \ - ../../../app/scanner/dialog_multirotateimagefile.ui \ - ../../../app/scanner/dialog_openimageindex.ui \ - ../../../app/scanner/dialog_passwordchange.ui \ - ../../../app/scanner/dialog_saveas.ui \ - ../../../app/scanner/dialog_savemessagebox.ui \ - ../../../app/scanner/dialog_updateprogress.ui \ - ../../../app/scanner/dialog_upgrade.ui \ - ../../../app/scanner/dialog_upgradefirmware.ui \ - ../../../app/scanner/dialog_writesettings.ui \ - ../../../app/scanner/dialog_wrong_img.ui \ - ../../../app/scanner/mainwindow.ui \ - ../../../app/scanner/setpicclrtool.ui \ - ../../../app/scanner/widget.ui \ - ../../../app/scanner/widget_imgproc_base.ui \ - ../../../app/scanner/widget_statusbar.ui \ - ../../../app/scanner/widget_imgproc_sidebar.ui - -RESOURCES += \ - ../../../app/scanner/Scanner_resource.qrc - -TRANSLATIONS += \ - ../../../app/scanner/Scanner_zh_CN.ts \ - ../../../app/scanner/Scanner_zh_EN.ts \ - ../../../app/scanner/qt_zh_CN.ts