HGGitLab

Commit aaf5aea2 authored by luoliangyi's avatar luoliangyi

解决导出时不能多张导出的问题

parent bfca5cb4
This diff is collapsed.
......@@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>443</width>
<width>442</width>
<height>360</height>
</rect>
</property>
......
......@@ -43,6 +43,8 @@ Dialog_Export::Dialog_Export(int total, const std::vector<int> &selectedIndexs,
m_saveQuality = getCfgValue("export", "quality", 0);
m_suffix = getCfgValue("export", "suffix", 0);
ui->fileDialog->selectNameFilter(ui->fileDialog->nameFilters().at(m_suffix));
ui->check_saveAsMulti->setEnabled(m_suffix > 2);
ui->check_saveAsMulti->setChecked(getCfgValue("export", "saveAsMulti", false));
int exportType = getCfgValue("export", "exportType", 0);
if (0 == exportType)
......@@ -79,11 +81,26 @@ QString Dialog_Export::getSavePath()
return m_savePath;
}
QString Dialog_Export::getSaveName()
{
return m_saveName;
}
QString Dialog_Export::getSaveExt()
{
return m_saveExt;
}
int Dialog_Export::getSaveQuality()
{
return m_saveQuality;
}
bool Dialog_Export::isSaveAsMultiPage()
{
return ui->check_saveAsMulti->isChecked();
}
void Dialog_Export::getSaveIndexs(std::vector<int> &indexs)
{
indexs = m_saveIndexs;
......@@ -126,7 +143,9 @@ void Dialog_Export::on_dialog_accepted()
if (-1 != pos)
name = name.left(pos);
m_savePath = getStdFileName(path + name + extName);
m_savePath = getStdFileName(path);
m_saveName = name;
m_saveExt = extName;
}
makeSaveIndexs();
......@@ -142,6 +161,7 @@ void Dialog_Export::on_dialog_accepted()
else if (ui->radio_nominatedPages->isChecked())
exportType = 2;
saveCfgValue("export", "exportType", exportType);
saveCfgValue("export", "saveAsMulti", ui->check_saveAsMulti->isChecked());
accept();
}
......@@ -149,6 +169,9 @@ void Dialog_Export::on_dialog_accepted()
void Dialog_Export::on_filterSelected(const QString& filterName)
{
m_suffix = ui->fileDialog->nameFilters().indexOf(filterName);
ui->check_saveAsMulti->setEnabled(m_suffix > 2);
if (m_suffix <= 2)
ui->check_saveAsMulti->setChecked(false);
}
void Dialog_Export::on_btn_option_clicked()
......
......@@ -16,7 +16,10 @@ public:
~Dialog_Export();
QString getSavePath();
QString getSaveName();
QString getSaveExt();
int getSaveQuality();
bool isSaveAsMultiPage();
void getSaveIndexs(std::vector<int> &indexs);
private slots:
......@@ -36,6 +39,8 @@ private:
std::vector<int> m_selectedIndexs;
QString m_savePath;
QString m_saveName;
QString m_saveExt;
int m_saveQuality;
std::vector<int> m_saveIndexs;
int m_suffix;
......
......@@ -114,6 +114,13 @@ Page range will be &quot;Chosen Pages&quot;.</string>
</item>
</layout>
</item>
<item>
<widget class="QCheckBox" name="check_saveAsMulti">
<property name="text">
<string>Save as multipages (TIFF/PDF/OFD)</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
......
......@@ -3,10 +3,14 @@
#include "imgfmt/HGImgFmt.h"
#include "HGUIGlobal.h"
Dialog_ExportImageFile::Dialog_ExportImageFile(const QString &destFile, int saveQuality, const QStringList &srcFiles, QWidget *parent) :
QDialog(parent)
Dialog_ExportImageFile::Dialog_ExportImageFile(const QString &destPath, const QString &destName, const QString &destExt,
bool isSaveAsMulti, int saveQuality, const QStringList &srcFiles, QWidget *parent)
: QDialog(parent)
, ui(new Ui::Dialog_ExportImageFile)
, m_destFile(destFile)
, m_destPath(destPath)
, m_destName(destName)
, m_destExt(destExt)
, m_isSaveAsMulti(isSaveAsMulti)
, m_saveQuality(saveQuality)
, m_srcFiles(srcFiles)
{
......@@ -39,8 +43,12 @@ void Dialog_ExportImageFile::ThreadFunc(HGThread thread, HGPointer param)
(void)thread;
Dialog_ExportImageFile *p = (Dialog_ExportImageFile *)param;
if (p->m_isSaveAsMulti)
{
QString fileName = p->m_destPath + p->m_destName + p->m_destExt;
HGImgFmtWriter imgFmtWriter = nullptr;
HGImgFmt_OpenImageWriter(getStdString(p->m_destFile).c_str(), 0, &imgFmtWriter);
HGImgFmt_OpenImageWriter(getStdString(fileName).c_str(), 0, &imgFmtWriter);
if (nullptr != imgFmtWriter)
{
for (int i = 0; i < p->m_srcFiles.size(); ++i)
......@@ -80,6 +88,52 @@ void Dialog_ExportImageFile::ThreadFunc(HGThread thread, HGPointer param)
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;
HGImgFmt_OpenImageReader(getStdString(p->m_srcFiles[i]).c_str(), 0, &imgFmtReader);
if (nullptr != imgFmtReader)
{
HGUInt count = 0;
HGImgFmt_GetImagePageCount(imgFmtReader, &count);
for (HGUInt j = 0; j < count; ++j)
{
if (p->m_stopThread)
{
break;
}
HGImage img = nullptr;
HGImgFmt_LoadImageFromReader(imgFmtReader, j, nullptr, HGBASE_IMGTYPE_RGB, HGBASE_IMGORIGIN_TOP, &img);
if (nullptr != img)
{
char fileName[512];
sprintf(fileName, "%s%03d", getStdString(p->m_destName).c_str(), index);
++index;
QString saveFileName = p->m_destPath + QString(StdStringToUtf8(fileName).c_str()) + p->m_destExt;
HGImgFmt_SaveImage(img, 0, nullptr, (HGUInt)p->m_saveQuality, getStdString(saveFileName).c_str());
HGBase_DestroyImage(img);
}
}
HGImgFmt_CloseImageReader(imgFmtReader);
}
}
}
emit p->finish();
}
......
......@@ -13,7 +13,8 @@ class Dialog_ExportImageFile : public QDialog
Q_OBJECT
public:
explicit Dialog_ExportImageFile(const QString &destFile, int saveQuality, const QStringList &srcFiles, QWidget *parent = nullptr);
explicit Dialog_ExportImageFile(const QString &destPath, const QString &destName, const QString &destExt,
bool isSaveAsMulti, int saveQuality, const QStringList &srcFiles, QWidget *parent = nullptr);
~Dialog_ExportImageFile();
private:
......@@ -34,7 +35,10 @@ protected:
private:
Ui::Dialog_ExportImageFile *ui;
QString m_destFile;
QString m_destPath;
QString m_destName;
QString m_destExt;
bool m_isSaveAsMulti;
int m_saveQuality;
QStringList m_srcFiles;
......
......@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>252</width>
<height>149</height>
<width>262</width>
<height>97</height>
</rect>
</property>
<property name="windowTitle">
......@@ -16,8 +16,8 @@
<widget class="QDialogButtonBox" name="buttonBox">
<property name="geometry">
<rect>
<x>70</x>
<y>100</y>
<x>80</x>
<y>50</y>
<width>171</width>
<height>32</height>
</rect>
......@@ -29,13 +29,13 @@
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
<widget class="QWidget" name="">
<widget class="QWidget" name="layoutWidget">
<property name="geometry">
<rect>
<x>10</x>
<y>50</y>
<x>20</x>
<y>20</y>
<width>231</width>
<height>21</height>
<height>22</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
......@@ -47,7 +47,14 @@
</widget>
</item>
<item>
<widget class="QSpinBox" name="spinBox"/>
<widget class="QSpinBox" name="spinBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
</layout>
</widget>
......
......@@ -7,8 +7,6 @@ Dialog_SaveQuality::Dialog_SaveQuality(int quality, QWidget *parent) :
ui(new Ui::Dialog_SaveQuality)
{
ui->setupUi(this);
ui->spinBox->setFixedWidth(180);
ui->spinBox->setValue(quality);
ui->buttonBox->button(QDialogButtonBox::Ok)->setText(tr("ok"));
......
......@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>397</width>
<height>252</height>
<width>326</width>
<height>105</height>
</rect>
</property>
<property name="windowTitle">
......@@ -18,6 +18,12 @@
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QSlider" name="horizontalSlider">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximum">
<number>100</number>
</property>
......@@ -28,6 +34,12 @@
</item>
<item>
<widget class="QSpinBox" name="spinBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximum">
<number>100</number>
</property>
......
......@@ -1572,24 +1572,6 @@ void MainWindow::on_act_Export_triggered()
Dialog_Export dlg(count, selectIndexs, this);
if (dlg.exec())
{
QString savePath = dlg.getSavePath();
bool find = false;
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)
{
QStringList srcFiles;
......@@ -1604,16 +1586,16 @@ void MainWindow::on_act_Export_triggered()
if (!srcFiles.isEmpty())
{
QString savePath = dlg.getSavePath();
QString saveName = dlg.getSaveName();
QString saveExt = dlg.getSaveExt();
bool isSaveAsMulti = dlg.isSaveAsMultiPage();
int saveQuality = dlg.getSaveQuality();
Dialog_ExportImageFile dlgExport(savePath, saveQuality, srcFiles, this);
Dialog_ExportImageFile dlgExport(savePath, saveName, saveExt, isSaveAsMulti, saveQuality, srcFiles, this);
dlgExport.exec();
}
}
else
{
QMessageBox::information(this, tr("info"), tr("find savePath in thumbnail"));
}
}
}
void MainWindow::on_act_imageInfo_triggered()
......
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