HGGitLab

Commit 87a9ccf6 authored by luoliangyi's avatar luoliangyi

整理app目录

parent 78b85655
......@@ -4,6 +4,6 @@
/third_party
/app
/build
/build-qt
/release
\ No newline at end of file
<RCC>
<qresource prefix="/translation">
<file>Scanner_zh_CN.qm</file>
<file>qt_zh_CN.qm</file>
</qresource>
<qresource prefix="/images">
<file>image_rsc/action/btnEmailScanedImages.png</file>
<file>image_rsc/action/btnFitWindow.png</file>
<file>image_rsc/action/btnFitWindowWidth.png</file>
<file>image_rsc/action/btnHelp.png</file>
<file>image_rsc/action/btnNext.png</file>
<file>image_rsc/action/btnNextPage.png</file>
<file>image_rsc/action/btnOriginalSize.png</file>
<file>image_rsc/action/btnPrevious.png</file>
<file>image_rsc/action/btnPreviousPage.png</file>
<file>image_rsc/action/btnRotateLeft.png</file>
<file>image_rsc/action/btnRotateRight.png</file>
<file>image_rsc/action/btnSaveScanedImages.png</file>
<file>image_rsc/action/btnScan.png</file>
<file>image_rsc/action/btnScannerSetting.png</file>
<file>image_rsc/action/btnZoomIn.png</file>
<file>image_rsc/action/btnZoomOut.png</file>
<file>image_rsc/actions/admin.png</file>
<file>image_rsc/actions/close.png</file>
<file>image_rsc/actions/contrast.png</file>
<file>image_rsc/actions/curve.png</file>
<file>image_rsc/actions/cut.png</file>
<file>image_rsc/actions/fullscreen.png</file>
<file>image_rsc/actions/help.png</file>
<file>image_rsc/actions/nextfile.png</file>
<file>image_rsc/actions/nextpage.png</file>
<file>image_rsc/actions/open.png</file>
<file>image_rsc/actions/previousfile.png</file>
<file>image_rsc/actions/previouspage.png</file>
<file>image_rsc/actions/print.png</file>
<file>image_rsc/actions/redo.png</file>
<file>image_rsc/actions/rotate-anticlockwise.png</file>
<file>image_rsc/actions/rotate-clockwise.png</file>
<file>image_rsc/actions/save.png</file>
<file>image_rsc/actions/saveAs.png</file>
<file>image_rsc/actions/scan.png</file>
<file>image_rsc/actions/settings.png</file>
<file>image_rsc/actions/sortpages.png</file>
<file>image_rsc/actions/undo.png</file>
<file>image_rsc/actions/zoom-fitscreen.png</file>
<file>image_rsc/actions/zoom-fitwidth.png</file>
<file>image_rsc/actions/zoom-in.png</file>
<file>image_rsc/actions/zoom-origin.png</file>
<file>image_rsc/actions/zoom-out.png</file>
<file>image_rsc/adjust/Img_BightnessReduce.png</file>
<file>image_rsc/adjust/Img_BrightnessIncrease.png</file>
<file>image_rsc/adjust/Img_ContrastIncrease.png</file>
<file>image_rsc/adjust/Img_ContrastReduce.png</file>
<file>image_rsc/example/example_arrow.png</file>
<file>image_rsc/example/example_black_after.png</file>
<file>image_rsc/example/example_black_before.png</file>
<file>image_rsc/example/example_crop_after.png</file>
<file>image_rsc/example/example_deskew_after.png</file>
<file>image_rsc/example/example_deskew_before.png</file>
<file>image_rsc/example/example_fillblack_before.png</file>
<file>image_rsc/example/example_fillblack_concave.png</file>
<file>image_rsc/example/example_fillblack_convex.png</file>
<file>image_rsc/example/example_fillcolor_auto.png</file>
<file>image_rsc/example/example_fillcolor_before.png</file>
<file>image_rsc/example/example_fillcolor_default.png</file>
<file>image_rsc/fullscreen/btnNext.png</file>
<file>image_rsc/fullscreen/btnPrevious.png</file>
<file>image_rsc/fullscreen/labQuitHint.png</file>
<file>image_rsc/logo/auge_logo.ico</file>
<file>image_rsc/logo/Hanvon_logo1.ico</file>
<file>image_rsc/logo/Hanvon_logo2.ico</file>
<file>image_rsc/logo/HG_Logo.png</file>
<file>image_rsc/logo/HUAGO-LOGO-for UI.jpg</file>
<file>image_rsc/logo/HUAGO-LOGO-for UI.png</file>
<file>image_rsc/logo/Lanxum_logo.ico</file>
<file>image_rsc/logo/logo.ico</file>
<file>image_rsc/logo/NoBrand_logo.ico</file>
<file>image_rsc/logo/RightWay_logo.ico</file>
<file>image_rsc/logo/waiting.gif</file>
<file>image_rsc/statusbar/statusBar_admin.png</file>
<file>image_rsc/scroll/bottom_Hot.png</file>
<file>image_rsc/scroll/bottom_Normal.png</file>
<file>image_rsc/scroll/bottom_Push.png</file>
<file>image_rsc/scroll/defItemImage.png</file>
<file>image_rsc/scroll/hScrollImage.png</file>
<file>image_rsc/scroll/hScrollSlider_Hot.png</file>
<file>image_rsc/scroll/hScrollSlider_Normal.png</file>
<file>image_rsc/scroll/hScrollSlider_Push.png</file>
<file>image_rsc/scroll/left_Hot.png</file>
<file>image_rsc/scroll/left_Normal.png</file>
<file>image_rsc/scroll/left_Push.png</file>
<file>image_rsc/scroll/nullScrollImage.png</file>
<file>image_rsc/scroll/right_Hot.png</file>
<file>image_rsc/scroll/right_Normal.png</file>
<file>image_rsc/scroll/right_Push.png</file>
<file>image_rsc/scroll/top_Hot.png</file>
<file>image_rsc/scroll/top_Normal.png</file>
<file>image_rsc/scroll/top_Push.png</file>
<file>image_rsc/scroll/vScrollImage.png</file>
<file>image_rsc/scroll/vScrollSlider_Hot.png</file>
<file>image_rsc/scroll/vScrollSlider_Normal.png</file>
<file>image_rsc/scroll/vScrollSlider_Push.png</file>
</qresource>
</RCC>
This diff is collapsed.
#include "dialog_admin.h"
#include "ui_dialog_admin.h"
#include <QMessageBox>
Dialog_Admin::Dialog_Admin(const QString& password, QWidget *parent)
: QDialog(parent)
, ui(new Ui::Dialog_Admin)
{
ui->setupUi(this);
ui->lineEdit->setPlaceholderText(tr("Type password"));
ui->lineEdit->setEchoMode(QLineEdit::Password);
ui->lineEdit->setMaxLength(20);
m_password = password;
}
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());
}
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Dialog_Admin</class>
<widget class="QDialog" name="Dialog_Admin">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>379</width>
<height>119</height>
</rect>
</property>
<property name="maximumSize">
<size>
<width>400</width>
<height>130</height>
</size>
</property>
<property name="windowTitle">
<string>Account sign in</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="lab_account">
<property name="minimumSize">
<size>
<width>54</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Account:</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lab_adminIcon">
<property name="maximumSize">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap>:/images/statusbar/image_rsc/statusbar/statusBar_admin.png</pixmap>
</property>
<property name="scaledContents">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lab_accountName">
<property name="text">
<string>Administrator</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout" stretch="0,1,0">
<item>
<widget class="QLabel" name="lab_password">
<property name="text">
<string>password:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit">
<property name="echoMode">
<enum>QLineEdit::Password</enum>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="cbtn_showPassword">
<property name="text">
<string>Show password</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="btn_signIn">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Sign In</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btn_cancel">
<property name="text">
<string>Cancel</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
#include "dialog_aquireinto.h"
#include "ui_dialog_aquireinto.h"
#include "dialog_savequality.h"
#include "global.h"
#include <QFileDialog>
#include <QDateTime>
#include <QRegExpValidator>
#include <QStandardPaths>
Dialog_AquireInto::Dialog_AquireInto(QWidget* parent) :
QDialog(parent),
ui(new Ui::Dialog_AquireInto),
m_saveQuality(0)
{
ui->setupUi(this);
QRegExp rx("[^\\\\/:*?\"<>|]+$");
ui->lineEdit_fileName->setValidator(new QRegExpValidator(rx, this));
QString filePath = APP_AQUIREINTO_PATH;
ui->lineEdit_directory->setText(filePath);
ui->cbtn_subFolder->setChecked(false);
ui->cbtn_subFolderByBlank->setChecked(false);
ui->cbtn_subFolderByColor->setChecked(false);
ui->lineEdit_fileName->setText("HGScan");
ui->spin_index->setValue(1);
ui->cbox_digit->setCurrentIndex(2);
ui->cbox_evenOdd->setCurrentIndex(0);
ui->cbox_format->setCurrentIndex(0);
ui->cbtn_multiFile->setChecked(false);
ui->radio_multiAll->setChecked(true);
ui->spinBox_multiPages->setValue(1);
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->cbtn_multiFile->setEnabled(ui->cbox_format->currentIndex() > 2);
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"));
//Temporarily hide some functions
ui->cbtn_subFolderByBlank->setEnabled(false);
ui->cbtn_subFolderByColor->setEnabled(false);
ui->cbox_evenOdd->setEnabled(false);
ui->radio_multiCustom->setEnabled(false);
ui->spinBox_multiPages->setEnabled(false);
}
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_saveQuality = m_saveQuality;
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 = "tif";
break;
case 4:
format = "pdf";
break;
case 5:
format = "ofd";
break;
default:
break;
}
param.m_fileNameExt = format;
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::on_btn_directory_clicked()
{
QString save_dir = QFileDialog::getExistingDirectory(this, tr("Browse directory"), "");
if (!save_dir.isEmpty())
ui->lineEdit_directory->setText(save_dir);
}
void Dialog_AquireInto::on_btn_option_clicked()
{
Dialog_SaveQuality dlg(m_saveQuality, this);
if (dlg.exec())
{
m_saveQuality = dlg.getSaveQuality();
}
}
void Dialog_AquireInto::on_cbox_format_currentIndexChanged(int index)
{
ui->cbtn_multiFile->setEnabled(index > 2);
if (index < 3)
ui->cbtn_multiFile->setChecked(false);
}
void Dialog_AquireInto::on_lineEdit_directory_textChanged(const QString& arg1)
{
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(!arg1.isEmpty());
}
void Dialog_AquireInto::on_buttonBox_accepted()
{
// 保存到配置文件
}
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')));
}
#ifndef DIALOG_AQUIREINTO_H
#define DIALOG_AQUIREINTO_H
#include <QDialog>
class QRegExpValidator;
namespace Ui {
class Dialog_AquireInto;
}
class AquireIntoSaveParam
{
public:
QString m_savePath;
bool m_isUseSubfolderByTime;
bool m_isUseSubfolderByBlankPages;
bool m_isUseSubfolderByColor;
int m_saveQuality;
QString m_fileNamePrefix;
int m_fileNameStartIndex;
int m_fileNameDigits;
int m_fileNameOddEventType;
QString m_fileNameExt;
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();
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);
private:
Ui::Dialog_AquireInto* ui;
int m_saveQuality;
};
#endif // DIALOG_AQUIREINTO_H
This diff is collapsed.
#include "dialog_clrcache.h"
#include "ui_dialog_clrcache.h"
#include "global.h"
#include <QMessageBox>
#include <QDir>
#include <QFileInfo>
#include <QKeyEvent>
Dialog_ClrCache::Dialog_ClrCache(QWidget *parent) :
QDialog(parent),
ui(new Ui::Dialog_ClrCache)
{
ui->setupUi(this);
ui->lineEdit->setText(APP_CACHE_PATH);
setInformation(APP_CACHE_PATH);
}
Dialog_ClrCache::~Dialog_ClrCache()
{
delete ui;
}
void Dialog_ClrCache::on_btn_clr_clicked()
{
QFileInfo file(APP_CACHE_PATH);
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.setButtonText(QMessageBox::Yes, tr("yes"));
msg.setButtonText(QMessageBox::No, tr("no"));
msg.exec();
if (msg.clickedButton() != msg.button(QMessageBox::Yes))
{
return;
}
bool ret = clrCache(APP_CACHE_PATH);
if (ret)
{
emit clearCache();
QMessageBox::information(this, tr("Information"), tr("Cache clear successfully."));
Global::writeSyslog(user_level_messages, Informational, "User try to clear cache and succeed.");
}
else
{
QMessageBox::warning(this, tr("Warning"), tr("Cache clear failed or incompletely clear."));
Global::writeSyslog(user_level_messages, Informational, "User try to clear cache, but failed or incompletely clear.");
}
setInformation(APP_CACHE_PATH);
}
void Dialog_ClrCache::on_btn_close_clicked()
{
close();
}
bool Dialog_ClrCache::clrCache(const QString &path)
{
QDir dir = QDir(path);
bool isSuccessful = dir.removeRecursively();
dir.mkpath(APP_CACHE_PATH);
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));
}
#ifndef DIALOG_CLRCACHE_H
#define DIALOG_CLRCACHE_H
#include <QDialog>
#include <QButtonGroup>
#include <QPushButton>
namespace Ui {
class Dialog_ClrCache;
}
class Dialog_ClrCache : public QDialog
{
Q_OBJECT
public:
explicit Dialog_ClrCache(QWidget *parent = nullptr);
~Dialog_ClrCache();
signals:
void clearCache();
private slots:
void on_btn_clr_clicked();
void on_btn_close_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;
};
#endif // DIALOG_CLRCACHE_H
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Dialog_ClrCache</class>
<widget class="QDialog" name="Dialog_ClrCache">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>490</width>
<height>159</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>159</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>159</height>
</size>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Cache path:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Cache occupied space:</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lab_size">
<property name="text">
<string>0</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lab_unit">
<property name="text">
<string>B</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lab_sizeByB">
<property name="text">
<string>(0 Byte)</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string>Number of files:</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lab_num">
<property name="text">
<string>0</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="btn_clr">
<property name="text">
<string>Clear Cache</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btn_close">
<property name="text">
<string>Close</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
This diff is collapsed.
#ifndef DIALOG_EXPORT_H
#define DIALOG_EXPORT_H
#include <QDialog>
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;
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_exportimagefile.h"
#include "ui_dialog_exportimagefile.h"
#include "imgfmt/HGImgFmt.h"
#include "HGUIGlobal.h"
Dialog_ExportImageFile::Dialog_ExportImageFile(const QString &destFile, int saveQuality, const QStringList &srcFiles, QWidget *parent) :
QDialog(parent)
, ui(new Ui::Dialog_ExportImageFile)
, m_destFile(destFile)
, m_saveQuality(saveQuality)
, 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()), this, SLOT(on_finish()), 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 Dialog_ExportImageFile::ThreadFunc(HGThread thread, HGPointer param)
{
(void)thread;
Dialog_ExportImageFile *p = (Dialog_ExportImageFile *)param;
HGImgFmtWriter imgFmtWriter = nullptr;
HGImgFmt_OpenImageWriter(getStdString(p->m_destFile).c_str(), 0, &imgFmtWriter);
if (nullptr != imgFmtWriter)
{
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)
{
HGImgFmt_SaveImageToWriter(imgFmtWriter, img, nullptr, (HGUInt)p->m_saveQuality);
HGBase_DestroyImage(img);
}
}
HGImgFmt_CloseImageReader(imgFmtReader);
}
}
HGImgFmt_CloseImageWriter(imgFmtWriter);
}
emit p->finish();
}
void Dialog_ExportImageFile::on_updateProgress(int value)
{
ui->progressBar->setValue(value);
}
void Dialog_ExportImageFile::on_finish()
{
close();
}
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;
}
#ifndef DIALOG_EXPORTIMAGEFILE_H
#define DIALOG_EXPORTIMAGEFILE_H
#include <QDialog>
#include "base/HGThread.h"
namespace Ui {
class Dialog_ExportImageFile;
}
class Dialog_ExportImageFile : public QDialog
{
Q_OBJECT
public:
explicit Dialog_ExportImageFile(const QString &destFile, int saveQuality, const QStringList &srcFiles, QWidget *parent = nullptr);
~Dialog_ExportImageFile();
private:
static void 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_ExportImageFile *ui;
QString m_destFile;
int m_saveQuality;
QStringList m_srcFiles;
bool m_stopThread;
HGThread m_thread;
};
#endif // DIALOG_EXPORTIMAGEFILE_H
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Dialog_ExportImageFile</class>
<widget class="QDialog" name="Dialog_ExportImageFile">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QProgressBar" name="progressBar">
<property name="value">
<number>0</number>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="pushButton">
<property name="text">
<string>stop</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
#include "dialog_fullscreen.h"
#include "ui_dialog_fullscreen.h"
#include "mainwindow.h"
#include "imgfmt/HGPdf.h"
#include "imgfmt/HGImgFmt.h"
#include "HGUIGlobal.h"
Dialog_FullScreen::Dialog_FullScreen(class MainWindow *mainWidget, const QStringList &fileNames, int currIndex, int multiIndex)
: QDialog(nullptr)
, ui(new Ui::Dialog_FullScreen)
, m_mainWidget(mainWidget)
, m_fileNames(fileNames)
, m_currFilePath("")
, m_currIndex(currIndex)
, m_multiPageCount(0)
, m_multiIndex(multiIndex)
, m_pa_contrlWidget(new QPropertyAnimation(&m_effect_contrlWidget, "opacity", this))
, m_pa_text(new QPropertyAnimation(&m_effect_exit, "opacity", this))
{
ui->setupUi(this);
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;
HGPdfReader pdfReader = nullptr;
HGImgFmt_OpenPdfReader(getStdString(m_currFilePath).c_str(), &pdfReader);
if (nullptr != pdfReader)
{
HGPdfPageInfo pageInfo = {0, 0};
if (HGBASE_ERR_OK == HGImgFmt_GetPdfPageInfo(pdfReader, (HGUInt)m_multiIndex, &pageInfo))
{
float scale = 1.0f;
if (pageInfo.width < 1600)
scale = 1600.0f / pageInfo.width;
HGImgFmt_LoadImageFromPdfReader(pdfReader, (HGUInt)m_multiIndex, scale, scale, HGBASE_IMGTYPE_RGB, HGBASE_IMGORIGIN_TOP, &img);
}
HGImgFmt_ClosePdfReader(pdfReader);
}
else
{
HGImgFmtReader imgFmtReader = nullptr;
HGImgFmt_OpenImageReader(getStdString(m_currFilePath).c_str(), 0, &imgFmtReader);
if (nullptr != imgFmtReader)
{
HGImgFmt_LoadImageFromReader(imgFmtReader, (HGUInt)m_multiIndex, nullptr, HGBASE_IMGTYPE_RGB, 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);
}
#ifndef DIALOG_FULLSCREEN_H
#define DIALOG_FULLSCREEN_H
#include <QDialog>
#include <QTimer>
#include <QGraphicsOpacityEffect>
#include <QPropertyAnimation>
namespace Ui {
class Dialog_FullScreen;
}
class Dialog_FullScreen : public QDialog
{
Q_OBJECT
public:
explicit Dialog_FullScreen(class MainWindow *mainWidget, const QStringList &fileNames, int currIndex, int multiIndex);
~Dialog_FullScreen();
private slots:
void on_btn_exit_clicked();
void on_btn_prePage_clicked();
void on_btn_nextPage_clicked();
void on_btn_pre_clicked();
void on_btn_next_clicked();
void on_hide();
void on_escape();
void on_mousePos(int x, int y);
private:
void setBtnOpacity(qreal opacity);
void setBtnEnable(); //根据当前图像序号刷新按钮可见情况
void showImage();
int getMultiPageCount();
private:
Ui::Dialog_FullScreen *ui;
class MainWindow *m_mainWidget;
QStringList m_fileNames;
QString m_currFilePath;
int m_currIndex;
int m_multiPageCount;
int m_multiIndex;
QTimer m_timer_hide;
QGraphicsOpacityEffect m_effect_contrlWidget;
QGraphicsOpacityEffect m_effect_exit;
QPropertyAnimation* m_pa_contrlWidget;
QPropertyAnimation* m_pa_text;
};
#endif // DIALOG_FULLSCREEN_H
This diff is collapsed.
#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);
ui->treeWidget->header()->resizeSections(QHeaderView::ResizeToContents);
ui->treeWidget->setColumnCount(2);
ui->treeWidget->setColumnWidth(0,180);
ui->treeWidget->setAlternatingRowColors(true);
ui->buttonBox->button(QDialogButtonBox::Ok)->setText(tr("ok"));
//set primery directory
QStringList list;
list<<tr("File");
QTreeWidgetItem *class1 = new QTreeWidgetItem(ui->treeWidget,list);
ui->treeWidget->addTopLevelItem(class1);
list.clear();
list<<tr("Image");
QTreeWidgetItem *class2 = new QTreeWidgetItem(ui->treeWidget,list);
ui->treeWidget->addTopLevelItem(class2);
QList<QTreeWidgetItem*> list_class;
//set class1 secondary directory
m_file_values = makeList(m_file_keys, m_file_values);
for(int i=0;i< m_file_keys.size();i++)
{
QStringList list_string;
list_string<< m_file_keys[i]<< m_file_values[i];
QTreeWidgetItem *class1_child = new QTreeWidgetItem(class1, list_string);
list_class.append(class1_child);
}
class1->addChildren(list_class);
//set class2 secondary directory
list_class.clear();
m_image_values = makeList(m_image_keys, m_image_values);
for(int i=0;i< m_image_keys.size();i++)
{
QStringList list_string;
list_string<< m_image_keys[i]<< m_image_values[i];
QTreeWidgetItem *class2_child = new QTreeWidgetItem(class2, list_string);
list_class.append(class2_child);
}
class2->addChildren(list_class);
ui->treeWidget->expandAll();
}
Dialog_ImageInfo::~Dialog_ImageInfo()
{
delete ui;
}
QStringList Dialog_ImageInfo::makeList(const QStringList& keys, QStringList values)
{
if (keys.size() < values.size())
return values.mid(0, keys.size());
else if (keys.size() > values.size())
{
for (int i = 0; i < keys.size() - values.size(); i++)
values.append(tr("None"));
}
return values;
}
#ifndef DIALOG_IMAGEINFO_H
#define DIALOG_IMAGEINFO_H
#include <QDialog>
#include <QPushButton>
namespace Ui {
class Dialog_ImageInfo;
}
class Dialog_ImageInfo : public QDialog
{
Q_OBJECT
public:
explicit Dialog_ImageInfo(const QStringList& file_keys, const QStringList& file_values,
const QStringList& image_keys, const QStringList& image_values, QWidget *parent = nullptr);
~Dialog_ImageInfo();
private:
QStringList makeList(const QStringList& keys, QStringList values);
private:
Ui::Dialog_ImageInfo *ui;
QStringList m_file_keys, m_file_values, m_image_keys, m_image_values;
};
#endif // DIALOG_IMAGEINFO_H
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Dialog_ImageInfo</class>
<widget class="QDialog" name="Dialog_ImageInfo">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Image information</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QTreeWidget" name="treeWidget">
<property name="editTriggers">
<set>QAbstractItemView::NoEditTriggers</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
<attribute name="headerVisible">
<bool>false</bool>
</attribute>
<attribute name="headerStretchLastSection">
<bool>true</bool>
</attribute>
<column>
<property name="text">
<string notr="true">1</string>
</property>
</column>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>Dialog_ImageInfo</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>Dialog_ImageInfo</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>
#include "dialog_imgproc_adjust.h"
#include "ui_dialog_imgproc_adjust.h"
#include "imgproc/HGImgProc.h"
Dialog_ImgProc_Adjust::Dialog_ImgProc_Adjust(HGImage img, QWidget *parent) :
QDialog(parent),
ui(new Ui::Dialog_ImgProc_Adjust)
{
ui->setupUi(this);
ui->view_before->addImage(img);
ui->view_after->addImage(img);
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"));
m_base_widget = new Widget_Imgproc_Base(this);
reinterpret_cast<QVBoxLayout*>(this->layout())->insertWidget(2, m_base_widget);
connect(m_base_widget, SIGNAL(brightness_change(int)), this, SLOT(on_brightness_change(int)));
connect(m_base_widget, SIGNAL(contrast_change(int)), this, SLOT(on_contrast_change(int)));
connect(m_base_widget, SIGNAL(gamma_change(double)), this, SLOT(on_gamma_change(double)));
m_brightness = 0;
m_contrast = 0;
m_gamma = 1.0;
}
Dialog_ImgProc_Adjust::~Dialog_ImgProc_Adjust()
{
delete ui;
}
HGImage Dialog_ImgProc_Adjust::getBeforeImage()
{
HGImage img = nullptr;
ui->view_before->getImage(&img);
return img;
}
HGImage Dialog_ImgProc_Adjust::getAfterImage()
{
HGImage img = nullptr;
ui->view_after->getImage(&img);
return img;
}
void Dialog_ImgProc_Adjust::on_brightness_change(int value)
{
m_brightness = value;
process();
}
void Dialog_ImgProc_Adjust::on_contrast_change(int value)
{
m_contrast = value;
process();
}
void Dialog_ImgProc_Adjust::on_gamma_change(double value)
{
m_gamma = value;
process();
}
void Dialog_ImgProc_Adjust::on_cbtn_preview_toggled(bool checked)
{
reinterpret_cast<QVBoxLayout*>(this->layout())->setStretch(1, checked ? 1 : 0);
ui->gbox_before->setVisible(checked);
ui->gbox_after->setVisible(checked);
}
void Dialog_ImgProc_Adjust::on_cbtn_applyImg_toggled(bool checked)
{
HGImage img = nullptr;
if (checked)
ui->view_after->getImage(&img);
else
ui->view_before->getImage(&img);
assert(nullptr != img);
emit applyToImage(img);
}
void Dialog_ImgProc_Adjust::on_buttonBox_clicked(QAbstractButton *button)
{
if (ui->buttonBox->standardButton(button) == QDialogButtonBox::RestoreDefaults)
{
m_base_widget->setDefault();
m_brightness = 0;
m_contrast = 0;
m_gamma = 1.0;
process();
}
}
void Dialog_ImgProc_Adjust::process()
{
HGImage img = nullptr;
ui->view_before->getImage(&img);
assert(nullptr != img);
HGImageInfo imgInfo;
HGBase_GetImageInfo(img, &imgInfo);
HGImage destImg = nullptr;
HGBase_CreateImage(imgInfo.width, imgInfo.height, imgInfo.type, imgInfo.origin, &destImg);
if (nullptr != destImg)
{
HGImgProc_ImageAdjustColors(img, destImg, m_brightness, m_contrast, (HGFloat)m_gamma);
ui->view_after->addImage(destImg);
HGBase_DestroyImage(destImg);
if (ui->cbtn_applyImg->isChecked())
{
HGImage emitImg = nullptr;
ui->view_after->getImage(&emitImg);
assert(nullptr != emitImg);
emit applyToImage(emitImg);
}
}
}
#ifndef DIALOG_IMGPROC_ADJUST_H
#define DIALOG_IMGPROC_ADJUST_H
#include <QDialog>
#include <QAbstractButton>
#include <QPushButton>
#include "widget_imgproc_base.h"
#include "base/HGImage.h"
namespace Ui {
class Dialog_ImgProc_Adjust;
}
class Dialog_ImgProc_Adjust : public QDialog
{
Q_OBJECT
public:
explicit Dialog_ImgProc_Adjust(HGImage img, QWidget *parent = nullptr);
~Dialog_ImgProc_Adjust();
HGImage getBeforeImage();
HGImage getAfterImage();
signals:
void applyToImage(HGImage img);
private slots:
void on_brightness_change(int value);
void on_contrast_change(int value);
void on_gamma_change(double value);
void on_cbtn_preview_toggled(bool checked);
void on_cbtn_applyImg_toggled(bool checked);
void on_buttonBox_clicked(QAbstractButton *button);
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
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Dialog_ImgProc_Adjust</class>
<widget class="QDialog" name="Dialog_ImgProc_Adjust">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>463</width>
<height>543</height>
</rect>
</property>
<property name="windowTitle">
<string>Adjust</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout" stretch="0,0,0,0,0">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4" stretch="0,1">
<item>
<widget class="QCheckBox" name="cbtn_preview">
<property name="text">
<string>Show preview</string>
</property>
</widget>
</item>
<item>
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QGroupBox" name="gbox_before">
<property name="title">
<string>Before</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="HGImgView" name="view_before" native="true">
<property name="minimumSize">
<size>
<width>150</width>
<height>100</height>
</size>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="gbox_after">
<property name="title">
<string>After</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="HGImgView" name="view_after" native="true">
<property name="minimumSize">
<size>
<width>150</width>
<height>100</height>
</size>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_8">
<item>
<widget class="QCheckBox" name="cbtn_applyImg">
<property name="text">
<string>Apply to image</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok|QDialogButtonBox::RestoreDefaults</set>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>HGImgView</class>
<extends>QWidget</extends>
<header location="global">HGImgView.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>Dialog_ImgProc_Adjust</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>Dialog_ImgProc_Adjust</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
#include "dialog_insertindex.h"
#include "ui_dialog_insertindex.h"
#include <QButtonGroup>
#include <QPushButton>
Dialog_InsertIndex::Dialog_InsertIndex(QWidget *parent) :
QDialog(parent),
ui(new Ui::Dialog_InsertIndex),
button_group(new QButtonGroup),
m_index(afterLast)
{
ui->setupUi(this);
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)));
}
Dialog_InsertIndex::~Dialog_InsertIndex()
{
delete button_group;
delete ui;
}
void Dialog_InsertIndex::on_rbtn_clicked(int id)
{
m_index = id;
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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