HGGitLab

Commit 6f54d508 authored by luoliangyi's avatar luoliangyi

1)缩略图控件功能微调

2)ofd保存按照长宽比正确设置物理尺寸
3)Scanner增加导出和另存为功能
parent 5b91f336
......@@ -50,17 +50,29 @@ unix {
INCLUDEPATH += $$PWD/../../../release/include/
SOURCES += \
dialog_export.cpp \
dialog_openimageindex.cpp \
dialog_saveas.cpp \
dialog_savequality.cpp \
main.cpp \
mainwindow.cpp \
../../../ui/HGImgView.cpp \
../../../ui/HGImgThumb.cpp
HEADERS += \
dialog_export.h \
dialog_openimageindex.h \
dialog_saveas.h \
dialog_savequality.h \
mainwindow.h \
../../../ui/HGImgView.hpp \
../../../ui/HGImgThumb.hpp
FORMS += \
dialog_export.ui \
dialog_openimageindex.ui \
dialog_saveas.ui \
dialog_savequality.ui \
mainwindow.ui \
TRANSLATIONS += \
......
This diff is collapsed.
#ifndef DIALOG_EXPORT_H
#define DIALOG_EXPORT_H
#include <QDialog>
#include <QRegExpValidator>
namespace Ui {
class Dialog_Export;
}
class Dialog_Export : public QDialog
{
Q_OBJECT
public:
explicit Dialog_Export(int total, const std::vector<int> &selectedIndexs, QWidget *parent = nullptr);
~Dialog_Export();
QString getSavePath();
int getSaveQuality();
void getSaveIndexs(std::vector<int> &indexs);
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);
private:
bool isNominatedPagesLegal(const QString& page);
void makeSaveIndexs();
private:
Ui::Dialog_Export *ui;
int m_total;
std::vector<int> m_selectedIndexs;
QRegExpValidator *m_qReg;
QString m_savePath;
int m_saveQuality;
std::vector<int> m_saveIndexs;
int m_suffix;
};
#endif // DIALOG_EXPORT_H
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Dialog_Export</class>
<widget class="QDialog" name="Dialog_Export">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>546</width>
<height>414</height>
</rect>
</property>
<property name="windowTitle">
<string>Export</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2" stretch="1,0,0">
<item>
<widget class="QFileDialog" name="fileDialog" native="true"/>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QPushButton" name="btn_option">
<property name="text">
<string>Compression Option</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QGroupBox" name="gbox_pageRange">
<property name="title">
<string>Page Range</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QRadioButton" name="radio_chosenPages">
<property name="text">
<string>Chosen Pages</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radio_allPages">
<property name="text">
<string>All Pages</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radio_nominatedPages">
<property name="text">
<string>Nominate Pages(example:1,3,6 or 3-6)</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2" stretch="0,0,1,0">
<item>
<widget class="QLabel" name="lab_nominatePages">
<property name="text">
<string>Page:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_nominatePages"/>
</item>
<item>
<widget class="QLabel" name="lab_warning">
<property name="enabled">
<bool>true</bool>
</property>
<property name="styleSheet">
<string notr="true">color: rgb(216, 0, 0);</string>
</property>
<property name="text">
<string>Input is not valid.
Page range will be &quot;Chosen Pages&quot;.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>QFileDialog</class>
<extends>QWidget</extends>
<header>qfiledialog.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>
#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);
ui->spinBox->setMinimum(1);
ui->spinBox->setMaximum(total);
ui->spinBox->setValue(currentIndex + 1);
}
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;
}
#ifndef DIALOG_OPENIMAGEINDEX_H
#define DIALOG_OPENIMAGEINDEX_H
#include <QDialog>
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
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Dialog_OpenImageIndex</class>
<widget class="QDialog" name="Dialog_OpenImageIndex">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>226</width>
<height>102</height>
</rect>
</property>
<property name="windowTitle">
<string>Open Page</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>pageIndex:</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="spinBox"/>
</item>
</layout>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>Dialog_OpenImageIndex</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>Dialog_OpenImageIndex</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>
#include "dialog_saveas.h"
#include "ui_dialog_saveas.h"
#include "dialog_savequality.h"
Dialog_SaveAs::Dialog_SaveAs(QWidget *parent) :
QDialog(parent)
, ui(new Ui::Dialog_SaveAs)
, m_saveQuality(0)
, m_suffix(0)
{
ui->setupUi(this);
ui->fileDialog->setAcceptMode(QFileDialog::AcceptSave);
ui->fileDialog->setWindowFlags(ui->fileDialog->windowFlags() & ~Qt::Dialog);
ui->fileDialog->setOption(QFileDialog::DontUseNativeDialog, true);
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)");
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&)));
}
Dialog_SaveAs::~Dialog_SaveAs()
{
delete ui;
}
QString Dialog_SaveAs::getSavePath()
{
return m_savePath;
}
int Dialog_SaveAs::getSaveQuality()
{
return m_saveQuality;
}
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 = ".tif";
break;
case 4:
extName = ".pdf";
break;
case 5:
extName = ".ofd";
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);
pos = name.lastIndexOf('.');
if (-1 != pos)
name = name.left(pos);
m_savePath = path + name + extName;
qDebug("%s", m_savePath.toStdString().c_str());
}
accept();
}
void Dialog_SaveAs::on_filterSelected(const QString& filterName)
{
m_suffix = ui->fileDialog->nameFilters().indexOf(filterName);
}
void Dialog_SaveAs::on_btn_option_clicked()
{
Dialog_SaveQuality dlg(m_saveQuality, this);
if (dlg.exec())
{
m_saveQuality = dlg.getSaveQuality();
}
}
#ifndef DIALOG_SAVEAS_H
#define DIALOG_SAVEAS_H
#include <QDialog>
namespace Ui {
class Dialog_SaveAs;
}
class Dialog_SaveAs : public QDialog
{
Q_OBJECT
public:
explicit Dialog_SaveAs(QWidget *parent = nullptr);
~Dialog_SaveAs();
QString getSavePath();
int getSaveQuality();
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_saveQuality;
int m_suffix;
};
#endif // DIALOG_SAVEAS_H
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Dialog_SaveAs</class>
<widget class="QDialog" name="Dialog_SaveAs">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>586</width>
<height>437</height>
</rect>
</property>
<property name="windowTitle">
<string>Save As</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QFileDialog" name="fileDialog" native="true"/>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QPushButton" name="btn_option">
<property name="text">
<string>Compression Option</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>QFileDialog</class>
<extends>QWidget</extends>
<header>qfiledialog.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>
#include "dialog_savequality.h"
#include "ui_dialog_savequality.h"
Dialog_SaveQuality::Dialog_SaveQuality(int quality, QWidget *parent) :
QDialog(parent),
ui(new Ui::Dialog_SaveQuality)
{
ui->setupUi(this);
ui->spinBox->setValue(quality);
}
Dialog_SaveQuality::~Dialog_SaveQuality()
{
delete ui;
}
int Dialog_SaveQuality::getSaveQuality()
{
return ui->spinBox->value();
}
void Dialog_SaveQuality::on_horizontalSlider_valueChanged(int value)
{
ui->spinBox->setValue(value);
}
void Dialog_SaveQuality::on_spinBox_valueChanged(int arg1)
{
ui->horizontalSlider->setValue(arg1);
}
#ifndef DIALOG_SAVEQUALITY_H
#define DIALOG_SAVEQUALITY_H
#include <QDialog>
namespace Ui {
class Dialog_SaveQuality;
}
class Dialog_SaveQuality : public QDialog
{
Q_OBJECT
public:
explicit Dialog_SaveQuality(int quality, QWidget *parent = nullptr);
~Dialog_SaveQuality();
int getSaveQuality();
private slots:
void on_horizontalSlider_valueChanged(int value);
void on_spinBox_valueChanged(int arg1);
private:
Ui::Dialog_SaveQuality *ui;
};
#endif // DIALOG_SAVEQUALITY_H
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Dialog_SaveQuality</class>
<widget class="QDialog" name="Dialog_SaveQuality">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>397</width>
<height>252</height>
</rect>
</property>
<property name="windowTitle">
<string>Save Option</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QSlider" name="horizontalSlider">
<property name="maximum">
<number>100</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="spinBox">
<property name="maximum">
<number>100</number>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>Dialog_SaveQuality</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>Dialog_SaveQuality</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>
This diff is collapsed.
......@@ -79,6 +79,14 @@ private slots:
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();
private:
HGImage createImage();
int getMultiPageCount();
......@@ -90,5 +98,6 @@ private:
int m_currIndex;
int m_multiIndex;
bool m_modify; // m_view上面的图像是否改变
};
#endif // MAINWINDOW_H
......@@ -11,6 +11,12 @@
#include "framework.h"
#include "../../../base/HGBase.h"
#include "../../../imgfmt/HGJpeg.h"
#include "../../../imgfmt/HGBmp.h"
#include "../../../imgfmt/HGPng.h"
#include "../../../imgfmt/HGTiff.h"
#include "../../../imgfmt/HGPdf.h"
#include "../../../imgfmt/HGOfd.h"
#include "../../../imgfmt/HGImgFmt.h"
#include "../../../twain_user/HGTwain.h"
#include "../../../imgproc/HGImgProc.h"
......
......@@ -2,7 +2,8 @@
#include "../base/HGInc.h"
#include "../base/HGUtility.h"
#define A4page_page_PhysicalBox "0.000000 0.000000 197.273333 139.022667"
#define A4page_page_PhysicalBox_Width 210.000000
#define A4page_page_PhysicalBox_Height 297.000000
HGOfdReaderImpl::HGOfdReaderImpl()
{
......@@ -485,7 +486,12 @@ HGResult HGOfdImageWriterImpl::SaveJpegImage(HGImage image, const HGJpegSaveInfo
return HGBASE_ERR_FAIL;
}
AddContentXmlFile(m_curImgIndex);
HGImageInfo imgInfo;
HGBase_GetImageInfo(image, &imgInfo);
HGFloat physicalWidth = 25.4f * (HGFloat)imgInfo.width / 96.0f;
HGFloat physicalHeight = 25.4f * (HGFloat)imgInfo.height / 96.0f;
AddContentXmlFile(m_curImgIndex, physicalWidth, physicalHeight);
++m_curImgIndex;
return HGBASE_ERR_OK;
}
......@@ -570,7 +576,10 @@ bool HGOfdImageWriterImpl::AddDocXml()
commonData->InsertEndChild(documentRes);
tinyxml2::XMLElement* physicalBox = xmlDoc.NewElement("ofd:PhysicalBox");
physicalBox->SetText(A4page_page_PhysicalBox);
char physicalBoxText[512];
sprintf(physicalBoxText, "0.000000 0.000000 %f %f", A4page_page_PhysicalBox_Width,
A4page_page_PhysicalBox_Height);
physicalBox->SetText(physicalBoxText);
pageArea->InsertEndChild(physicalBox);
tinyxml2::XMLElement* pages = xmlDoc.NewElement("ofd:Pages");
......@@ -696,7 +705,7 @@ bool HGOfdImageWriterImpl::AddJpegImageFile(HGImage image, const HGJpegSaveInfo*
return true;
}
bool HGOfdImageWriterImpl::AddContentXmlFile(HGUInt index)
bool HGOfdImageWriterImpl::AddContentXmlFile(HGUInt index, HGFloat physicalWidth, HGFloat physicalHeight)
{
HGChar dir[128];
sprintf(dir, "Doc_0/Pages/Page_%u", index);
......@@ -712,7 +721,9 @@ bool HGOfdImageWriterImpl::AddContentXmlFile(HGUInt index)
root->InsertEndChild(area);
tinyxml2::XMLElement* physicalBox = xmlDoc.NewElement("ofd:PhysicalBox");
physicalBox->SetText(A4page_page_PhysicalBox);
char physicalBoxText[512];
sprintf(physicalBoxText, "0.000000 0.000000 %f %f", physicalWidth, physicalHeight);
physicalBox->SetText(physicalBoxText);
area->InsertEndChild(physicalBox);
tinyxml2::XMLElement* content = xmlDoc.NewElement("ofd:Content");
......@@ -729,11 +740,15 @@ bool HGOfdImageWriterImpl::AddContentXmlFile(HGUInt index)
HGChar imgObjectId[24];
sprintf(imgObjectId, "%u", index * 10 + 4);
imgObject->SetAttribute("ID", imgObjectId);
imgObject->SetAttribute("Boundary", "0.000000 0.000000 197.273333 139.022667");
char boundaryText[512];
sprintf(boundaryText, "0.000000 0.000000 %f %f", physicalWidth, physicalHeight);
imgObject->SetAttribute("Boundary", boundaryText);
HGChar imgObjectResId[24];
sprintf(imgObjectResId, "%u", index * 10 + 2);
imgObject->SetAttribute("ResourceID", imgObjectResId);
imgObject->SetAttribute("CTM", "197.273333 0 0 139.022667 0 0");
char ctmText[512];
sprintf(ctmText, "%f 0 0 %f 0 0", physicalWidth, physicalHeight);
imgObject->SetAttribute("CTM", ctmText);
layer->InsertEndChild(imgObject);
HGChar name[128];
......
......@@ -50,7 +50,7 @@ private:
bool AddPublicResXml();
bool AddXmlFile(tinyxml2::XMLDocument &xmlDoc, const HGChar *name);
bool AddJpegImageFile(HGImage image, const HGJpegSaveInfo* info, HGUInt quality, const HGChar* name);
bool AddContentXmlFile(HGUInt index);
bool AddContentXmlFile(HGUInt index, HGFloat physicalWidth, HGFloat physicalHeight);
private:
zip* m_zip;
......
......@@ -135,6 +135,25 @@ HGResult HGAPI HGImgFmt_OpenPdfReader(const HGChar* fileName, HGPdfReader* reade
return HGBASE_ERR_INVALIDARG;
}
HGBool isPdfFile = HGFALSE;
FILE* file = fopen(fileName, "r");
if (NULL != file)
{
HGByte data[4];
size_t len = fread(data, 1, 4, file);
if (4 == len && 0 == memcmp(data, "%PDF", 4))
{
isPdfFile = HGTRUE;
}
fclose(file);
}
if (!isPdfFile)
{
return HGBASE_ERR_FAIL;
}
fz_context* pContext = fz_new_context(NULL, NULL, FZ_STORE_DEFAULT);
if (NULL == pContext)
{
......@@ -213,11 +232,13 @@ HGResult HGAPI HGImgFmt_GetPdfPageInfo(HGPdfReader reader, HGUInt page, HGPdfPag
{
fzpage = fz_load_page(pdfReaderImpl->m_pContext, pdfReaderImpl->m_pDoc, (int)page);
pdf_page* page = pdf_page_from_fz_page(pdfReaderImpl->m_pContext, fzpage);
fz_rect pdfRect = pdf_bound_page(pdfReaderImpl->m_pContext, page);
info->width = pdfRect.x1;
info->height = pdfRect.y1;
ret = HGBASE_ERR_OK;
if (NULL != page)
{
fz_rect pdfRect = pdf_bound_page(pdfReaderImpl->m_pContext, page);
info->width = ceil(pdfRect.x1);
info->height = ceil(pdfRect.y1);
ret = HGBASE_ERR_OK;
}
}
fz_catch(pdfReaderImpl->m_pContext)
{
......
......@@ -43,6 +43,7 @@ HGImgThumb::HGImgThumb(QWidget* parent)
m_mouseOn = false;
m_curItemIndex = -1;
m_hotItemIndex = -1;
m_pushItemIndex = -1;
m_signItemIndex = -1;
m_stopThread = false;
HGBase_OpenThread(ThreadFunc, this, &m_thread);
......@@ -1726,6 +1727,7 @@ void HGImgThumb::mousePressEvent(QMouseEvent *e)
emitCurItemChange = true;
}
m_pushItemIndex = index;
m_signItemIndex = index;
}
}
......@@ -1734,7 +1736,17 @@ void HGImgThumb::mousePressEvent(QMouseEvent *e)
{
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)
{
......@@ -1782,6 +1794,8 @@ void HGImgThumb::mousePressEvent(QMouseEvent *e)
m_curItemIndex = index;
emitCurItemChange = true;
}
m_pushItemIndex = index;
}
}
else
......@@ -1804,6 +1818,7 @@ void HGImgThumb::mousePressEvent(QMouseEvent *e)
emitCurItemChange = true;
}
m_pushItemIndex = index;
m_signItemIndex = index;
}
}
......@@ -2051,12 +2066,6 @@ void HGImgThumb::mouseMoveEvent(QMouseEvent* e)
m_frontItems[i]->selected = false;
}
if (-1 != m_curItemIndex)
{
m_curItemIndex = -1;
emitCurItemChange = true;
}
// 开始框选
m_frameSelection = true;
m_frameSelectionRect.left = HGMIN(m_frameSelectionStartX, e->pos().x() - round(m_thumbRect.left));
......@@ -2085,6 +2094,8 @@ void HGImgThumb::mouseReleaseEvent(QMouseEvent *e)
m_insertPtValid = false;
m_draging = false;
m_pushItemIndex = -1;
m_operateStartX = -1;
m_operateStartY = -1;
m_operate = 0;
......@@ -2119,12 +2130,6 @@ void HGImgThumb::mouseReleaseEvent(QMouseEvent *e)
emitItemSelectingChanged = true;
m_frontItems[i]->selected = false;
}
if (-1 != m_curItemIndex)
{
m_curItemIndex = -1;
emitCurrItemChanged = true;
}
}
}
}
......@@ -2137,22 +2142,10 @@ void HGImgThumb::mouseReleaseEvent(QMouseEvent *e)
if (m_frontItems[oldHitItemIndex]->selected)
{
m_frontItems[oldHitItemIndex]->selected = false;
if (oldHitItemIndex == m_curItemIndex)
{
m_curItemIndex = -1;
emitCurrItemChanged = true;
}
}
else
{
m_frontItems[oldHitItemIndex]->selected = true;
if (oldHitItemIndex != m_curItemIndex)
{
m_curItemIndex = oldHitItemIndex;
emitCurrItemChanged = true;
}
}
emitItemSelectingChanged = true;
......@@ -2172,12 +2165,6 @@ void HGImgThumb::mouseReleaseEvent(QMouseEvent *e)
emitItemSelectingChanged = true;
m_frontItems[i]->selected = false;
}
if (-1 != m_curItemIndex)
{
m_curItemIndex = -1;
emitCurrItemChanged = true;
}
}
else
{
......@@ -2347,19 +2334,26 @@ void HGImgThumb::paintEvent(QPaintEvent* e)
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, 196));
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, 196), 3);
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));
......
......@@ -218,6 +218,7 @@ private:
bool m_mouseOn;
int m_curItemIndex;
int m_hotItemIndex;
int m_pushItemIndex;
int m_signItemIndex;
bool m_stopThread;
HGThread m_thread;
......
......@@ -1375,7 +1375,7 @@ void HGImgView::mouseMoveEvent(QMouseEvent* e)
if (xImg >= 0 && xImg < (int)info.width && yImg >= 0 && yImg < (int)info.height)
{
qDebug("mousePos, x=%d, y=%d", xImg, yImg);
//qDebug("mousePos, x=%d, y=%d", xImg, yImg);
emit mousePos(xImg, yImg);
if (m_showColorInfo)
......@@ -1387,7 +1387,7 @@ void HGImgView::mouseMoveEvent(QMouseEvent* e)
HGByte r = pixel[0];
HGByte g = pixel[1];
HGByte b = pixel[2];
qDebug("colorInfo, r=%d, g=%d, b=%d", r, g, b);
//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)",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment