Merge branch 'master' of http://192.168.100.140:8099/sane/code_app
This commit is contained in:
commit
609655ae5c
|
@ -0,0 +1,248 @@
|
|||
#ifndef CUSTOM_FILE_DIALOG_H
|
||||
#define CUSTOM_FILE_DIALOG_H
|
||||
|
||||
#include <QFileDialog>
|
||||
#include <QLineEdit>
|
||||
#include <QPushButton>
|
||||
#include <QListWidget>
|
||||
#include <QLayout>
|
||||
#include <QButtonGroup>
|
||||
#include <string>
|
||||
|
||||
#define USE_FILE_DLG_WITHOUT_PROMPT
|
||||
|
||||
template<class T>
|
||||
class custom_file_dlg
|
||||
{
|
||||
QLineEdit* edit_;
|
||||
QLineEdit* new_;
|
||||
QPushButton *save_;
|
||||
QFileDialog *fdlg_;
|
||||
QListView *list_;
|
||||
|
||||
enum find_cls
|
||||
{
|
||||
FIND_BUTTON = 1,
|
||||
FIND_LINE_EDIT,
|
||||
FIND_LIST,
|
||||
};
|
||||
typedef struct _find_ctrl
|
||||
{
|
||||
int cls;
|
||||
std::string title;
|
||||
QObject *found;
|
||||
}FINDCTRL, *LPFINDCTRL;
|
||||
|
||||
static bool find_ctrls(QObject* obj, LPFINDCTRL ret)
|
||||
{
|
||||
if(ret->cls == FIND_BUTTON)
|
||||
{
|
||||
QPushButton* btn = dynamic_cast<QPushButton*>(obj);
|
||||
if(btn)
|
||||
{
|
||||
std::string t(btn->text().toStdString());
|
||||
if(ret->title.empty() || t == ret->title) // "\344\277\235\345\255\230(&S)")
|
||||
{
|
||||
ret->found = obj;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
QButtonGroup* grp = dynamic_cast<QButtonGroup*>(obj);
|
||||
if(grp)
|
||||
{
|
||||
printf("Found button-group with %d buttons\n", grp->buttons().size());
|
||||
QList<QAbstractButton*> btns = grp->buttons();
|
||||
for(auto& b : btns)
|
||||
{
|
||||
btn = dynamic_cast<QPushButton*>(b);
|
||||
if(btn)
|
||||
{
|
||||
std::string t(btn->text().toStdString());
|
||||
if(ret->title.empty() || t == ret->title) // "\344\277\235\345\255\230(&S)")
|
||||
{
|
||||
ret->found = obj;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(ret->cls == FIND_LINE_EDIT)
|
||||
{
|
||||
QLineEdit* edit = dynamic_cast<QLineEdit*>(obj);
|
||||
if(edit)
|
||||
{
|
||||
std::string t(edit->text().toStdString());
|
||||
if(ret->title.empty() || t == ret->title) // "\344\277\235\345\255\230(&S)")
|
||||
{
|
||||
ret->found = obj;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(ret->cls == FIND_LIST)
|
||||
{
|
||||
QListView *v = dynamic_cast<QListView*>(obj);
|
||||
if(v)
|
||||
{
|
||||
std::string t(v->objectName().toStdString());
|
||||
if(ret->title.empty() && ret->title.empty()) // || t == ret->title)
|
||||
{
|
||||
ret->found = obj;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
QListWidget *l = dynamic_cast<QListWidget*>(obj);
|
||||
if(l)
|
||||
{
|
||||
printf("Found list widget\n");
|
||||
}
|
||||
else {
|
||||
QListView *v = dynamic_cast<QListView*>(obj);
|
||||
if(v)
|
||||
printf("Found list view: %s\n", v->objectName().toStdString().c_str());
|
||||
}
|
||||
QObjectList objs(obj->children());
|
||||
for(auto& o : objs)
|
||||
{
|
||||
if(find_ctrls(o, ret))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
QPushButton* save_button(void){return save_;}
|
||||
QLineEdit* input_edit(bool org){return org ? edit_ : new_;}
|
||||
QListView* file_list(void){return list_;}
|
||||
void replace_input(QLineEdit* from, QLineEdit* tobe)
|
||||
{
|
||||
fdlg_->layout()->replaceWidget(from, tobe);
|
||||
from->hide();
|
||||
tobe->show();
|
||||
}
|
||||
|
||||
protected slots:
|
||||
virtual void on_file_dialog_textChanged(const QString &path) = 0;
|
||||
virtual void on_file_dialog_returnPressed() = 0;
|
||||
|
||||
protected:
|
||||
custom_file_dlg() : edit_(nullptr), new_(nullptr), save_(nullptr), fdlg_(nullptr), list_(nullptr)
|
||||
{
|
||||
}
|
||||
~custom_file_dlg()
|
||||
{
|
||||
}
|
||||
|
||||
public:
|
||||
static QLineEdit* find_input_box(QFileDialog* host)
|
||||
{
|
||||
FINDCTRL fc;
|
||||
QObjectList objs(host->children());
|
||||
|
||||
fc.cls = FIND_LINE_EDIT;
|
||||
fc.found = nullptr;
|
||||
for(auto& o : objs)
|
||||
{
|
||||
if(custom_file_dlg::find_ctrls(o, &fc))
|
||||
break;
|
||||
}
|
||||
|
||||
return dynamic_cast<QLineEdit*>(fc.found);
|
||||
}
|
||||
static QPushButton* find_button(QFileDialog* host, const char* title)
|
||||
{
|
||||
FINDCTRL fc;
|
||||
QObjectList objs(host->children());
|
||||
|
||||
fc.cls = FIND_BUTTON;
|
||||
fc.title = (title && *title) ? title : "";
|
||||
fc.found = nullptr;
|
||||
for(auto& o : objs)
|
||||
{
|
||||
if(custom_file_dlg::find_ctrls(o, &fc))
|
||||
break;
|
||||
}
|
||||
|
||||
return dynamic_cast<QPushButton*>(fc.found);
|
||||
}
|
||||
static QListView* find_list(QFileDialog* host, const char* title)
|
||||
{
|
||||
FINDCTRL fc;
|
||||
QObjectList objs(host->children());
|
||||
|
||||
fc.cls = FIND_LIST;
|
||||
fc.title = (title && *title) ? title : "";
|
||||
fc.found = nullptr;
|
||||
for(auto& o : objs)
|
||||
{
|
||||
if(custom_file_dlg::find_ctrls(o, &fc))
|
||||
break;
|
||||
}
|
||||
|
||||
return dynamic_cast<QListView*>(fc.found);
|
||||
}
|
||||
|
||||
|
||||
protected:
|
||||
bool init_custom_file_dlg(QFileDialog* fdlg)
|
||||
{
|
||||
new_ = new QLineEdit(((T*)this));
|
||||
fdlg_ = fdlg;
|
||||
edit_ = custom_file_dlg::find_input_box(fdlg);
|
||||
save_ = custom_file_dlg::find_button(fdlg, "\344\277\235\345\255\230(&S)");
|
||||
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_)
|
||||
{
|
||||
list_->clearSelection();
|
||||
edit_->setText(text);
|
||||
edit_->setSelection(0, text.length());
|
||||
}
|
||||
|
||||
if(save_)
|
||||
save_->setEnabled(!text.isEmpty());
|
||||
}
|
||||
void on_file_name_press_return(void)
|
||||
{
|
||||
emit save_->clicked();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
#endif // CUSTOM_FILE_DIALOG_H
|
|
@ -35,6 +35,10 @@ Dialog_Export::Dialog_Export(int total, const std::vector<int> &selectedIndexs,
|
|||
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);
|
||||
|
@ -237,6 +241,19 @@ void Dialog_Export::on_lineEdit_nominatePages_textChanged(const QString& arg1)
|
|||
ui->lab_warning->setText(tr("Input is not valid.\nPage range will be 'Chosen Pages'."));
|
||||
}
|
||||
|
||||
#ifdef USE_FILE_DLG_WITHOUT_PROMPT
|
||||
void Dialog_Export::on_file_dialog_textChanged(const QString &path)
|
||||
{
|
||||
QLineEdit* edit = dynamic_cast<QLineEdit*>(sender());
|
||||
|
||||
on_file_name_changed(edit, path);
|
||||
}
|
||||
void Dialog_Export::on_file_dialog_returnPressed()
|
||||
{
|
||||
on_file_name_press_return();
|
||||
}
|
||||
#endif
|
||||
|
||||
bool Dialog_Export::isNominatedPagesLegal(const QString& page)
|
||||
{
|
||||
if (page.isEmpty())
|
||||
|
|
|
@ -3,14 +3,22 @@
|
|||
|
||||
#include <QDialog>
|
||||
|
||||
// u can ONLY comment following line if u want to use filedialog as system present !
|
||||
#include "custom_file_dialog.h"
|
||||
|
||||
namespace Ui {
|
||||
class Dialog_Export;
|
||||
}
|
||||
|
||||
|
||||
class Dialog_Export : public QDialog
|
||||
#ifdef USE_FILE_DLG_WITHOUT_PROMPT
|
||||
, public custom_file_dlg<Dialog_Export>
|
||||
#endif
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
||||
public:
|
||||
explicit Dialog_Export(int total, const std::vector<int> &selectedIndexs, QWidget *parent = nullptr);
|
||||
~Dialog_Export();
|
||||
|
@ -33,6 +41,11 @@ private slots:
|
|||
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();
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>546</width>
|
||||
<height>414</height>
|
||||
<width>650</width>
|
||||
<height>530</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
|
@ -17,30 +17,6 @@
|
|||
<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>
|
||||
|
@ -50,25 +26,55 @@
|
|||
</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>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
<item>
|
||||
<widget class="QRadioButton" name="radio_nominatedPages">
|
||||
<property name="text">
|
||||
<string>Nominate Pages(example:1,3,6 or 3-6)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="radio_chosenPages">
|
||||
<property name="text">
|
||||
<string>Chosen Pages</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_4">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="radio_allPages">
|
||||
<property name="text">
|
||||
<string>All Pages</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2" stretch="0,0,1,0">
|
||||
|
@ -91,8 +97,10 @@
|
|||
<string notr="true">color: rgb(216, 0, 0);</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Input is not valid.
|
||||
Page range will be "Chosen Pages".</string>
|
||||
<string>
|
||||
Input is not valid.
|
||||
Page range will be "Chosen Pages".
|
||||
</string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
|
@ -114,28 +122,60 @@ Page range will be "Chosen Pages".</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>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="check_saveAsMulti">
|
||||
<property name="text">
|
||||
<string>Save as multipages (TIFF/PDF/OFD)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="btn_option">
|
||||
<property name="text">
|
||||
<string>Compression Option</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>QFileDialog</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>qfiledialog.h</header>
|
||||
<header location="global">qfiledialog.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<tabstops>
|
||||
<tabstop>radio_chosenPages</tabstop>
|
||||
<tabstop>radio_nominatedPages</tabstop>
|
||||
<tabstop>radio_allPages</tabstop>
|
||||
<tabstop>lineEdit_nominatePages</tabstop>
|
||||
<tabstop>check_saveAsMulti</tabstop>
|
||||
<tabstop>btn_option</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
|
|
@ -20,7 +20,7 @@ RC_ICONS = ../../app/scanner/image_rsc/logo/logo.ico
|
|||
# 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
|
||||
|
||||
TARGET = HGScanner
|
||||
TARGET = HuaGoScan
|
||||
|
||||
win32 {
|
||||
DEFINES += _CRT_SECURE_NO_WARNINGS
|
||||
|
@ -202,7 +202,8 @@ HEADERS += \
|
|||
../../app/scanner/HGImgView.h \
|
||||
../../app/scanner/HGUIGlobal.h \
|
||||
../../utility/HGString.h \
|
||||
../../app/scanner/dialog_input.h
|
||||
../../app/scanner/dialog_input.h \
|
||||
../../app/scanner/custom_file_dialog.h
|
||||
|
||||
FORMS += \
|
||||
../../app/scanner/cutdialog.ui \
|
||||
|
|
4
build.sh
4
build.sh
|
@ -81,7 +81,7 @@ if [ "${1}" == "hw" ]; then
|
|||
sed -i "s/OEM_HUAGAO/OEM_HANWANG/g" HGScannerTmp.pro
|
||||
sed -i "s/hgsane/hwsane/g" HGScannerTmp.pro
|
||||
sed -i "s/hgdriver/hwdriver/g" HGScannerTmp.pro
|
||||
sed -i "s/HGScanner/HwScanner/g" HGScannerTmp.pro
|
||||
sed -i "s/HuaGoScan/HanvonScan/g" HGScannerTmp.pro
|
||||
sed -i "s/HGBase/HwBase/g" HGScannerTmp.pro
|
||||
sed -i "s/HGImgFmt/HwImgFmt/g" HGScannerTmp.pro
|
||||
sed -i "s/HGImgProc/HwImgProc/g" HGScannerTmp.pro
|
||||
|
@ -90,7 +90,7 @@ elif [ "${1}" == "lsc" ]; then
|
|||
sed -i "s/OEM_HUAGAO/OEM_LISICHENG/g" HGScannerTmp.pro
|
||||
sed -i "s/hgsane/lscsane/g" HGScannerTmp.pro
|
||||
sed -i "s/hgdriver/lscdriver/g" HGScannerTmp.pro
|
||||
sed -i "s/HGScanner/LscScanner/g" HGScannerTmp.pro
|
||||
sed -i "s/HuaGoScan/LanxumScan/g" HGScannerTmp.pro
|
||||
sed -i "s/HGBase/LscBase/g" HGScannerTmp.pro
|
||||
sed -i "s/HGImgFmt/LscImgFmt/g" HGScannerTmp.pro
|
||||
sed -i "s/HGImgProc/LscImgProc/g" HGScannerTmp.pro
|
||||
|
|
Loading…
Reference in New Issue