HGGitLab
Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
app
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
CI / CD Analytics
Repository Analytics
Value Stream Analytics
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
luoliangyi
app
Commits
de7bd5d0
Commit
de7bd5d0
authored
Apr 26, 2022
by
luoliangyi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
将扫描目录和缓存目录标准化
parent
e33eb8c7
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
124 additions
and
97 deletions
+124
-97
app/scanner/dialog_aquireinto.cpp
app/scanner/dialog_aquireinto.cpp
+14
-3
app/scanner/dialog_clrcache.cpp
app/scanner/dialog_clrcache.cpp
+18
-8
app/scanner/dialog_clrcache.h
app/scanner/dialog_clrcache.h
+3
-0
app/scanner/global.cpp
app/scanner/global.cpp
+0
-1
app/scanner/global.h
app/scanner/global.h
+0
-9
app/scanner/mainwindow.cpp
app/scanner/mainwindow.cpp
+26
-74
app/scanner/mainwindow.h
app/scanner/mainwindow.h
+1
-0
build-qt/windows/HGSolution/HGScanner.pro
build-qt/windows/HGSolution/HGScanner.pro
+0
-2
ui/HGUIGlobal.cpp
ui/HGUIGlobal.cpp
+56
-0
ui/HGUIGlobal.h
ui/HGUIGlobal.h
+6
-0
No files found.
app/scanner/dialog_aquireinto.cpp
View file @
de7bd5d0
#
include
"dialog_aquireinto.h"
#
include
"dialog_aquireinto.h"
#include "ui_dialog_aquireinto.h"
#include "ui_dialog_aquireinto.h"
#include "dialog_savequality.h"
#include "dialog_savequality.h"
#include "global.h"
#include <QFileDialog>
#include <QFileDialog>
#include <QDateTime>
#include <QDateTime>
#include <QRegExpValidator>
#include <QRegExpValidator>
#include <QStandardPaths>
#include <QStandardPaths>
#include "base/HGDef.h"
#include "base/HGInc.h"
#include "base/HGUtility.h"
#include "HGUIGlobal.h"
Dialog_AquireInto
::
Dialog_AquireInto
(
QWidget
*
parent
)
:
Dialog_AquireInto
::
Dialog_AquireInto
(
QWidget
*
parent
)
:
QDialog
(
parent
),
QDialog
(
parent
),
...
@@ -17,7 +20,11 @@ Dialog_AquireInto::Dialog_AquireInto(QWidget* parent) :
...
@@ -17,7 +20,11 @@ Dialog_AquireInto::Dialog_AquireInto(QWidget* parent) :
QRegExp
rx
(
"[^
\\\\
/:*?
\"
<>|]+$"
);
QRegExp
rx
(
"[^
\\\\
/:*?
\"
<>|]+$"
);
ui
->
lineEdit_fileName
->
setValidator
(
new
QRegExpValidator
(
rx
,
this
));
ui
->
lineEdit_fileName
->
setValidator
(
new
QRegExpValidator
(
rx
,
this
));
QString
filePath
=
APP_AQUIREINTO_PATH
;
HGChar
aquireIntoPath
[
512
];
HGBase_GetDocumentsPath
(
aquireIntoPath
,
512
);
strcat
(
aquireIntoPath
,
"Huago/ScannerApp/AquireInto/"
);
QString
filePath
=
getStdFileName
(
StdStringToUtf8
(
aquireIntoPath
).
c_str
());
ui
->
lineEdit_directory
->
setText
(
filePath
);
ui
->
lineEdit_directory
->
setText
(
filePath
);
ui
->
cbtn_subFolder
->
setChecked
(
false
);
ui
->
cbtn_subFolder
->
setChecked
(
false
);
ui
->
cbtn_subFolderByBlank
->
setChecked
(
false
);
ui
->
cbtn_subFolderByBlank
->
setChecked
(
false
);
...
@@ -102,7 +109,11 @@ void Dialog_AquireInto::on_btn_directory_clicked()
...
@@ -102,7 +109,11 @@ void Dialog_AquireInto::on_btn_directory_clicked()
{
{
QString
save_dir
=
QFileDialog
::
getExistingDirectory
(
this
,
tr
(
"Browse directory"
),
""
);
QString
save_dir
=
QFileDialog
::
getExistingDirectory
(
this
,
tr
(
"Browse directory"
),
""
);
if
(
!
save_dir
.
isEmpty
())
if
(
!
save_dir
.
isEmpty
())
ui
->
lineEdit_directory
->
setText
(
save_dir
);
{
if
(
save_dir
[
save_dir
.
size
()
-
1
]
!=
'/'
)
save_dir
+=
"/"
;
ui
->
lineEdit_directory
->
setText
(
getStdFileName
(
save_dir
));
}
}
}
void
Dialog_AquireInto
::
on_btn_option_clicked
()
void
Dialog_AquireInto
::
on_btn_option_clicked
()
...
...
app/scanner/dialog_clrcache.cpp
View file @
de7bd5d0
#include "dialog_clrcache.h"
#include "dialog_clrcache.h"
#include "ui_dialog_clrcache.h"
#include "ui_dialog_clrcache.h"
#include "global.h"
#include <QMessageBox>
#include <QMessageBox>
#include <QDir>
#include <QDir>
#include <QFileInfo>
#include <QFileInfo>
#include <QKeyEvent>
#include <QKeyEvent>
#include "base/HGUtility.h"
#include "HGUIGlobal.h"
Dialog_ClrCache
::
Dialog_ClrCache
(
QWidget
*
parent
)
:
Dialog_ClrCache
::
Dialog_ClrCache
(
QWidget
*
parent
)
:
QDialog
(
parent
),
QDialog
(
parent
),
ui
(
new
Ui
::
Dialog_ClrCache
)
ui
(
new
Ui
::
Dialog_ClrCache
)
{
{
ui
->
setupUi
(
this
);
ui
->
setupUi
(
this
);
ui
->
lineEdit
->
setText
(
APP_CACHE_PATH
);
m_cachePath
=
getCachePath
();
setInformation
(
APP_CACHE_PATH
);
ui
->
lineEdit
->
setText
(
m_cachePath
);
setInformation
(
m_cachePath
);
}
}
Dialog_ClrCache
::~
Dialog_ClrCache
()
Dialog_ClrCache
::~
Dialog_ClrCache
()
...
@@ -21,9 +22,18 @@ Dialog_ClrCache::~Dialog_ClrCache()
...
@@ -21,9 +22,18 @@ Dialog_ClrCache::~Dialog_ClrCache()
delete
ui
;
delete
ui
;
}
}
QString
Dialog_ClrCache
::
getCachePath
()
{
HGChar
cachePath
[
512
];
HGBase_GetDocumentsPath
(
cachePath
,
512
);
strcat
(
cachePath
,
"Huago/ScannerApp/Cache/"
);
QString
filePath
=
getStdFileName
(
StdStringToUtf8
(
cachePath
).
c_str
());
return
filePath
;
}
void
Dialog_ClrCache
::
on_btn_clr_clicked
()
void
Dialog_ClrCache
::
on_btn_clr_clicked
()
{
{
QFileInfo
file
(
APP_CACHE_PATH
);
QFileInfo
file
(
m_cachePath
);
if
(
!
file
.
exists
())
if
(
!
file
.
exists
())
{
{
...
@@ -42,7 +52,7 @@ void Dialog_ClrCache::on_btn_clr_clicked()
...
@@ -42,7 +52,7 @@ void Dialog_ClrCache::on_btn_clr_clicked()
return
;
return
;
}
}
bool
ret
=
clrCache
(
APP_CACHE_PATH
);
bool
ret
=
clrCache
(
m_cachePath
);
if
(
ret
)
if
(
ret
)
{
{
emit
clearCache
();
emit
clearCache
();
...
@@ -53,7 +63,7 @@ void Dialog_ClrCache::on_btn_clr_clicked()
...
@@ -53,7 +63,7 @@ void Dialog_ClrCache::on_btn_clr_clicked()
QMessageBox
::
warning
(
this
,
tr
(
"Warning"
),
tr
(
"Cache clear failed or incompletely clear."
));
QMessageBox
::
warning
(
this
,
tr
(
"Warning"
),
tr
(
"Cache clear failed or incompletely clear."
));
}
}
setInformation
(
APP_CACHE_PATH
);
setInformation
(
m_cachePath
);
}
}
void
Dialog_ClrCache
::
on_btn_close_clicked
()
void
Dialog_ClrCache
::
on_btn_close_clicked
()
...
@@ -65,7 +75,7 @@ bool Dialog_ClrCache::clrCache(const QString &path)
...
@@ -65,7 +75,7 @@ bool Dialog_ClrCache::clrCache(const QString &path)
{
{
QDir
dir
=
QDir
(
path
);
QDir
dir
=
QDir
(
path
);
bool
isSuccessful
=
dir
.
removeRecursively
();
bool
isSuccessful
=
dir
.
removeRecursively
();
dir
.
mkpath
(
APP_CACHE_PATH
);
dir
.
mkpath
(
m_cachePath
);
return
isSuccessful
;
return
isSuccessful
;
}
}
...
...
app/scanner/dialog_clrcache.h
View file @
de7bd5d0
...
@@ -17,6 +17,8 @@ public:
...
@@ -17,6 +17,8 @@ public:
explicit
Dialog_ClrCache
(
QWidget
*
parent
=
nullptr
);
explicit
Dialog_ClrCache
(
QWidget
*
parent
=
nullptr
);
~
Dialog_ClrCache
();
~
Dialog_ClrCache
();
static
QString
getCachePath
();
signals:
signals:
void
clearCache
();
void
clearCache
();
...
@@ -32,6 +34,7 @@ private:
...
@@ -32,6 +34,7 @@ private:
private:
private:
Ui
::
Dialog_ClrCache
*
ui
;
Ui
::
Dialog_ClrCache
*
ui
;
QString
m_cachePath
;
};
};
#endif // DIALOG_CLRCACHE_H
#endif // DIALOG_CLRCACHE_H
app/scanner/global.cpp
deleted
100644 → 0
View file @
e33eb8c7
#include "global.h"
app/scanner/global.h
deleted
100644 → 0
View file @
e33eb8c7
#ifndef GLOBAL_H
#define GLOBAL_H
#include <QStandardPaths>
static
const
QString
APP_AQUIREINTO_PATH
=
QStandardPaths
::
writableLocation
(
QStandardPaths
::
DocumentsLocation
)
+
"/Huago/ScannerApp/AquireInto"
;
static
const
QString
APP_CACHE_PATH
=
QStandardPaths
::
writableLocation
(
QStandardPaths
::
DocumentsLocation
)
+
"/Huago/ScannerApp/Cache"
;
#endif // GLOBAL_H
app/scanner/mainwindow.cpp
View file @
de7bd5d0
#include "mainwindow.h"
#
include
"mainwindow.h"
#include "ui_mainwindow.h"
#include "ui_mainwindow.h"
#include <QDockWidget>
#include <QDockWidget>
#include <QFileDialog>
#include <QFileDialog>
...
@@ -28,7 +28,6 @@
...
@@ -28,7 +28,6 @@
#include "dialog_clrcache.h"
#include "dialog_clrcache.h"
#include "dialog_moveto.h"
#include "dialog_moveto.h"
#include "hg_settingdialog.h"
#include "hg_settingdialog.h"
#include "global.h"
#include "base/HGInfo.h"
#include "base/HGInfo.h"
#include "imgfmt/HGPdf.h"
#include "imgfmt/HGPdf.h"
#include "imgfmt/HGImgFmt.h"
#include "imgfmt/HGImgFmt.h"
...
@@ -36,60 +35,6 @@
...
@@ -36,60 +35,6 @@
#include "base/HGUtility.h"
#include "base/HGUtility.h"
#include "HGUIGlobal.h"
#include "HGUIGlobal.h"
#if defined(HG_CMP_MSC)
static
std
::
string
AnsiToUtf8
(
const
char
*
text
)
{
int
wlen
=
::
MultiByteToWideChar
(
CP_ACP
,
0
,
text
,
-
1
,
NULL
,
0
);
WCHAR
*
pUnicode
=
new
WCHAR
[
wlen
];
::
MultiByteToWideChar
(
CP_ACP
,
0
,
text
,
-
1
,
pUnicode
,
wlen
);
int
len
=
::
WideCharToMultiByte
(
CP_UTF8
,
0
,
pUnicode
,
-
1
,
NULL
,
0
,
NULL
,
NULL
);
CHAR
*
pUTF8
=
new
CHAR
[
len
];
::
WideCharToMultiByte
(
CP_UTF8
,
0
,
pUnicode
,
-
1
,
pUTF8
,
len
,
NULL
,
NULL
);
delete
[]
pUnicode
;
std
::
string
ret
=
pUTF8
;
delete
[]
pUTF8
;
return
ret
;
}
static
std
::
string
Utf8ToAnsi
(
const
char
*
text
)
{
int
wlen
=
::
MultiByteToWideChar
(
CP_UTF8
,
0
,
text
,
-
1
,
NULL
,
0
);
WCHAR
*
pUnicode
=
new
WCHAR
[
wlen
];
::
MultiByteToWideChar
(
CP_UTF8
,
0
,
text
,
-
1
,
pUnicode
,
wlen
);
int
len
=
::
WideCharToMultiByte
(
CP_ACP
,
0
,
pUnicode
,
-
1
,
NULL
,
0
,
NULL
,
NULL
);
CHAR
*
pAnsi
=
new
CHAR
[
len
];
::
WideCharToMultiByte
(
CP_ACP
,
0
,
pUnicode
,
-
1
,
pAnsi
,
len
,
NULL
,
NULL
);
delete
[]
pUnicode
;
std
::
string
ret
=
pAnsi
;
delete
[]
pAnsi
;
return
ret
;
}
#endif
static
std
::
string
Utf8ToStdString
(
const
char
*
utf8
)
{
#if defined(HG_CMP_MSC)
return
Utf8ToAnsi
(
utf8
);
#else
return
utf8
;
#endif
}
static
std
::
string
StdStringToUtf8
(
const
char
*
str
)
{
#if defined(HG_CMP_MSC)
return
AnsiToUtf8
(
str
);
#else
return
str
;
#endif
}
static
void
TrimString
(
std
::
string
&
str
)
{
int
s
=
(
int
)
str
.
find_first_not_of
(
" "
);
int
e
=
(
int
)
str
.
find_last_not_of
(
" "
);
str
=
str
.
substr
(
s
,
e
-
s
+
1
);
}
MainWindow
::
MainWindow
(
QWidget
*
parent
)
MainWindow
::
MainWindow
(
QWidget
*
parent
)
:
QMainWindow
(
parent
)
:
QMainWindow
(
parent
)
,
ui
(
new
Ui
::
MainWindow
)
,
ui
(
new
Ui
::
MainWindow
)
...
@@ -101,6 +46,7 @@ MainWindow::MainWindow(QWidget *parent)
...
@@ -101,6 +46,7 @@ MainWindow::MainWindow(QWidget *parent)
,
m_multiIndex
(
-
1
)
,
m_multiIndex
(
-
1
)
,
m_relation
(
false
)
,
m_relation
(
false
)
,
m_modify
(
false
)
,
m_modify
(
false
)
,
m_singleScan
(
false
)
,
m_scanType
(
0
)
,
m_scanType
(
0
)
,
m_scanInsertPos
(
-
1
)
,
m_scanInsertPos
(
-
1
)
,
m_scanFileName
(
""
)
,
m_scanFileName
(
""
)
...
@@ -695,7 +641,7 @@ void MainWindow::on_clearCache()
...
@@ -695,7 +641,7 @@ void MainWindow::on_clearCache()
{
{
QString
fileName
;
QString
fileName
;
m_thumb
->
getItemFileName
(
i
,
fileName
);
m_thumb
->
getItemFileName
(
i
,
fileName
);
if
(
0
==
fileName
.
indexOf
(
getStdFileName
(
APP_CACHE_PATH
)))
if
(
0
==
fileName
.
indexOf
(
Dialog_ClrCache
::
getCachePath
(
)))
{
{
removeItems
.
push_back
(
i
);
removeItems
.
push_back
(
i
);
}
}
...
@@ -881,9 +827,9 @@ void MainWindow::on_new_image(void *img)
...
@@ -881,9 +827,9 @@ void MainWindow::on_new_image(void *img)
if
(
nullptr
==
m_scanImgFmtWriter
)
if
(
nullptr
==
m_scanImgFmtWriter
)
{
{
assert
(
m_scanFileName
.
isEmpty
());
assert
(
m_scanFileName
.
isEmpty
());
HGBase_CreateDir
(
getStdString
(
getStdFileName
(
m_aquireIntoSaveParam
.
m_savePath
)
).
c_str
());
HGBase_CreateDir
(
getStdString
(
m_aquireIntoSaveParam
.
m_savePath
).
c_str
());
QString
scanFileName
=
QString
(
tr
(
"%1
/
%2%3.%4"
)).
arg
(
m_aquireIntoSaveParam
.
m_savePath
)
QString
scanFileName
=
QString
(
tr
(
"%1%2%3.%4"
)).
arg
(
m_aquireIntoSaveParam
.
m_savePath
)
.
arg
(
m_aquireIntoSaveParam
.
m_fileNamePrefix
)
.
arg
(
m_aquireIntoSaveParam
.
m_fileNamePrefix
)
.
arg
(
m_aquireIntoSaveParam
.
m_fileNameStartIndex
,
m_aquireIntoSaveParam
.
m_fileNameDigits
,
10
,
QLatin1Char
(
'0'
))
.
arg
(
m_aquireIntoSaveParam
.
m_fileNameStartIndex
,
m_aquireIntoSaveParam
.
m_fileNameDigits
,
10
,
QLatin1Char
(
'0'
))
.
arg
(
m_aquireIntoSaveParam
.
m_fileNameExt
);
.
arg
(
m_aquireIntoSaveParam
.
m_fileNameExt
);
...
@@ -900,14 +846,14 @@ void MainWindow::on_new_image(void *img)
...
@@ -900,14 +846,14 @@ void MainWindow::on_new_image(void *img)
{
{
assert
(
m_scanFileName
.
isEmpty
());
assert
(
m_scanFileName
.
isEmpty
());
assert
(
nullptr
==
m_scanImgFmtWriter
);
assert
(
nullptr
==
m_scanImgFmtWriter
);
HGBase_CreateDir
(
getStdString
(
getStdFileName
(
m_aquireIntoSaveParam
.
m_savePath
)
).
c_str
());
HGBase_CreateDir
(
getStdString
(
m_aquireIntoSaveParam
.
m_savePath
).
c_str
());
QString
scanFileName
=
QString
(
tr
(
"%1
/
%2%3.%4"
)).
arg
(
m_aquireIntoSaveParam
.
m_savePath
)
QString
scanFileName
=
QString
(
tr
(
"%1%2%3.%4"
)).
arg
(
m_aquireIntoSaveParam
.
m_savePath
)
.
arg
(
m_aquireIntoSaveParam
.
m_fileNamePrefix
)
.
arg
(
m_aquireIntoSaveParam
.
m_fileNamePrefix
)
.
arg
(
m_aquireIntoSaveParam
.
m_fileNameStartIndex
,
m_aquireIntoSaveParam
.
m_fileNameDigits
,
10
,
QLatin1Char
(
'0'
))
.
arg
(
m_aquireIntoSaveParam
.
m_fileNameStartIndex
,
m_aquireIntoSaveParam
.
m_fileNameDigits
,
10
,
QLatin1Char
(
'0'
))
.
arg
(
m_aquireIntoSaveParam
.
m_fileNameExt
);
.
arg
(
m_aquireIntoSaveParam
.
m_fileNameExt
);
HGImgFmt_SaveImage
(
image
,
0
,
nullptr
,
0
,
getStdString
(
scanFileName
).
c_str
());
HGImgFmt_SaveImage
(
image
,
0
,
nullptr
,
0
,
getStdString
(
getStdFileName
(
scanFileName
)
).
c_str
());
m_thumb
->
addItem
(
scanFileName
);
m_thumb
->
addItem
(
scanFileName
);
++
m_aquireIntoSaveParam
.
m_fileNameStartIndex
;
++
m_aquireIntoSaveParam
.
m_fileNameStartIndex
;
}
}
...
@@ -925,8 +871,6 @@ void MainWindow::on_scan_working(QString workingInfo)
...
@@ -925,8 +871,6 @@ void MainWindow::on_scan_working(QString workingInfo)
void
MainWindow
::
on_scan_finish
(
QString
finishInfo
,
int
err
)
void
MainWindow
::
on_scan_finish
(
QString
finishInfo
,
int
err
)
{
{
m_isScanning
=
false
;
if
(
nullptr
!=
m_scanImgFmtWriter
)
if
(
nullptr
!=
m_scanImgFmtWriter
)
{
{
HGImgFmt_CloseImageWriter
(
m_scanImgFmtWriter
);
HGImgFmt_CloseImageWriter
(
m_scanImgFmtWriter
);
...
@@ -935,6 +879,7 @@ void MainWindow::on_scan_finish(QString finishInfo, int err)
...
@@ -935,6 +879,7 @@ void MainWindow::on_scan_finish(QString finishInfo, int err)
m_scanFileName
.
clear
();
m_scanFileName
.
clear
();
}
}
m_isScanning
=
false
;
m_thumb
->
setAcceptDrops
(
true
);
m_thumb
->
setAcceptDrops
(
true
);
m_dialogLog
->
updateStatus
(
nullptr
!=
m_saneDeviceHandle
&&
0
!=
m_scanType
,
m_isScanning
);
m_dialogLog
->
updateStatus
(
nullptr
!=
m_saneDeviceHandle
&&
0
!=
m_scanType
,
m_isScanning
);
updateActionStatus
();
updateActionStatus
();
...
@@ -956,7 +901,11 @@ void MainWindow::on_continueScan()
...
@@ -956,7 +901,11 @@ void MainWindow::on_continueScan()
return
;
return
;
}
}
SANE_Status
ret
=
sane_start
(
m_saneDeviceHandle
);
SANE_Status
ret
;
if
(
m_singleScan
)
ret
=
sane_io_control
(
m_saneDeviceHandle
,
IO_CTRL_CODE_TEST_SINGLE
,
nullptr
,
nullptr
);
else
ret
=
sane_start
(
m_saneDeviceHandle
);
if
(
ret
!=
SANE_STATUS_GOOD
)
if
(
ret
!=
SANE_STATUS_GOOD
)
{
{
m_wndStatusBar
->
setDeviceStatusInfo
(
tr
(
"start failed"
),
true
);
m_wndStatusBar
->
setDeviceStatusInfo
(
tr
(
"start failed"
),
true
);
...
@@ -1041,12 +990,12 @@ void MainWindow::on_act_last_triggered()
...
@@ -1041,12 +990,12 @@ void MainWindow::on_act_last_triggered()
QString
MainWindow
::
getCacheFileName
()
QString
MainWindow
::
getCacheFileName
()
{
{
QString
filePath
=
APP_CACHE_PATH
;
QString
cachePath
=
Dialog_ClrCache
::
getCachePath
()
;
HGBase_CreateDir
(
getStdString
(
getStdFileName
(
filePath
)
).
c_str
());
HGBase_CreateDir
(
getStdString
(
cachePath
).
c_str
());
char
uuid
[
256
]
=
{
0
};
char
uuid
[
256
]
=
{
0
};
HGBase_GetUuid
(
uuid
,
256
);
HGBase_GetUuid
(
uuid
,
256
);
QString
fileName
=
getStdFileName
(
filePath
+
"/"
+
uuid
+
".jpg"
);
QString
fileName
=
getStdFileName
(
cachePath
+
uuid
+
".jpg"
);
return
fileName
;
return
fileName
;
}
}
...
@@ -1235,10 +1184,10 @@ bool MainWindow::startSpaceCheck(QWidget* parent)
...
@@ -1235,10 +1184,10 @@ bool MainWindow::startSpaceCheck(QWidget* parent)
{
{
QString
savePath
;
QString
savePath
;
if
(
1
==
m_scanType
)
if
(
1
==
m_scanType
)
savePath
=
APP_CACHE_PATH
;
savePath
=
Dialog_ClrCache
::
getCachePath
()
;
else
if
(
2
==
m_scanType
)
else
if
(
2
==
m_scanType
)
savePath
=
m_aquireIntoSaveParam
.
m_savePath
;
savePath
=
m_aquireIntoSaveParam
.
m_savePath
;
if
(
0
==
savePath
.
indexOf
(
storage
.
rootPath
(
)))
if
(
0
==
savePath
.
indexOf
(
getStdFileName
(
storage
.
rootPath
()
)))
{
{
space
=
storage
.
bytesAvailable
()
/
1024
/
1024
;
space
=
storage
.
bytesAvailable
()
/
1024
/
1024
;
break
;
break
;
...
@@ -1783,7 +1732,7 @@ void MainWindow::closeEvent(QCloseEvent *e)
...
@@ -1783,7 +1732,7 @@ void MainWindow::closeEvent(QCloseEvent *e)
}
}
}
}
QDir
dir
=
QDir
(
APP_CACHE_PATH
);
QDir
dir
=
QDir
(
Dialog_ClrCache
::
getCachePath
()
);
dir
.
removeRecursively
();
dir
.
removeRecursively
();
QMainWindow
::
closeEvent
(
e
);
QMainWindow
::
closeEvent
(
e
);
}
}
...
@@ -2196,6 +2145,7 @@ void MainWindow::on_act_acquire_triggered()
...
@@ -2196,6 +2145,7 @@ void MainWindow::on_act_acquire_triggered()
return
;
return
;
}
}
m_singleScan
=
false
;
m_scanType
=
1
;
m_scanType
=
1
;
m_scanInsertPos
=
-
1
;
m_scanInsertPos
=
-
1
;
...
@@ -2239,6 +2189,7 @@ void MainWindow::on_act_acquireSingle_triggered()
...
@@ -2239,6 +2189,7 @@ void MainWindow::on_act_acquireSingle_triggered()
return
;
return
;
}
}
m_singleScan
=
true
;
m_scanType
=
1
;
m_scanType
=
1
;
m_scanInsertPos
=
-
1
;
m_scanInsertPos
=
-
1
;
...
@@ -2285,15 +2236,15 @@ void MainWindow::on_act_acquireInto_triggered()
...
@@ -2285,15 +2236,15 @@ void MainWindow::on_act_acquireInto_triggered()
Dialog_AquireInto
dlg
(
this
);
Dialog_AquireInto
dlg
(
this
);
if
(
dlg
.
exec
())
if
(
dlg
.
exec
())
{
{
m_singleScan
=
false
;
m_scanType
=
2
;
m_scanType
=
2
;
m_aquireIntoSaveParam
=
dlg
.
getSaveParam
();
m_aquireIntoSaveParam
=
dlg
.
getSaveParam
();
if
(
m_aquireIntoSaveParam
.
m_isUseSubfolderByTime
)
if
(
m_aquireIntoSaveParam
.
m_isUseSubfolderByTime
)
{
{
QDate
date
=
QDate
::
currentDate
();
QDate
date
=
QDate
::
currentDate
();
QString
str
=
date
.
toString
(
"yyyy-MM-dd"
);
QString
newSavePath
=
m_aquireIntoSaveParam
.
m_savePath
+
date
.
toString
(
"yyyy-MM-dd"
)
+
"/"
;
m_aquireIntoSaveParam
.
m_savePath
+=
"/"
;
m_aquireIntoSaveParam
.
m_savePath
=
getStdFileName
(
newSavePath
);
m_aquireIntoSaveParam
.
m_savePath
+=
str
;
}
}
if
(
!
startSpaceCheck
(
this
))
if
(
!
startSpaceCheck
(
this
))
...
@@ -2331,6 +2282,7 @@ void MainWindow::on_act_insertFromScanner_triggered()
...
@@ -2331,6 +2282,7 @@ void MainWindow::on_act_insertFromScanner_triggered()
Dialog_InsertIndex
dlg
(
this
);
Dialog_InsertIndex
dlg
(
this
);
if
(
dlg
.
exec
())
if
(
dlg
.
exec
())
{
{
m_singleScan
=
false
;
m_scanType
=
1
;
m_scanType
=
1
;
m_scanInsertPos
=
-
1
;
m_scanInsertPos
=
-
1
;
...
...
app/scanner/mainwindow.h
View file @
de7bd5d0
...
@@ -221,6 +221,7 @@ private:
...
@@ -221,6 +221,7 @@ private:
int
m_multiIndex
;
int
m_multiIndex
;
bool
m_relation
;
// m_view上的图像是否关联到m_thumb
bool
m_relation
;
// m_view上的图像是否关联到m_thumb
bool
m_modify
;
// m_view上面的图像是否改变
bool
m_modify
;
// m_view上面的图像是否改变
bool
m_singleScan
;
// 是否单张扫描
int
m_scanType
;
// 1-扫描到缓存目录,2-扫描到本地目录
int
m_scanType
;
// 1-扫描到缓存目录,2-扫描到本地目录
int
m_scanInsertPos
;
// 扫描插入位置,-1表示插入到最后
int
m_scanInsertPos
;
// 扫描插入位置,-1表示插入到最后
QString
m_scanFileName
;
QString
m_scanFileName
;
...
...
build-qt/windows/HGSolution/HGScanner.pro
View file @
de7bd5d0
...
@@ -59,7 +59,6 @@ SOURCES += \
...
@@ -59,7 +59,6 @@ SOURCES += \
..
/../../
app
/
scanner
/
dialog_passwordchange
.
cpp
\
..
/../../
app
/
scanner
/
dialog_passwordchange
.
cpp
\
..
/../../
app
/
scanner
/
dialog_saveas
.
cpp
\
..
/../../
app
/
scanner
/
dialog_saveas
.
cpp
\
..
/../../
app
/
scanner
/
dialog_savequality
.
cpp
\
..
/../../
app
/
scanner
/
dialog_savequality
.
cpp
\
..
/../../
app
/
scanner
/
global
.
cpp
\
..
/../../
app
/
scanner
/
hg_settingdialog
.
cpp
\
..
/../../
app
/
scanner
/
hg_settingdialog
.
cpp
\
..
/../../
app
/
scanner
/
main
.
cpp
\
..
/../../
app
/
scanner
/
main
.
cpp
\
..
/../../
app
/
scanner
/
mainwindow
.
cpp
\
..
/../../
app
/
scanner
/
mainwindow
.
cpp
\
...
@@ -92,7 +91,6 @@ HEADERS += \
...
@@ -92,7 +91,6 @@ HEADERS += \
..
/../../
app
/
scanner
/
dialog_passwordchange
.
h
\
..
/../../
app
/
scanner
/
dialog_passwordchange
.
h
\
..
/../../
app
/
scanner
/
dialog_saveas
.
h
\
..
/../../
app
/
scanner
/
dialog_saveas
.
h
\
..
/../../
app
/
scanner
/
dialog_savequality
.
h
\
..
/../../
app
/
scanner
/
dialog_savequality
.
h
\
..
/../../
app
/
scanner
/
global
.
h
\
..
/../../
app
/
scanner
/
hg_settingdialog
.
h
\
..
/../../
app
/
scanner
/
hg_settingdialog
.
h
\
..
/../../
app
/
scanner
/
mainwindow
.
h
\
..
/../../
app
/
scanner
/
mainwindow
.
h
\
..
/../../
app
/
scanner
/
widget_imgproc_base
.
h
\
..
/../../
app
/
scanner
/
widget_imgproc_base
.
h
\
...
...
ui/HGUIGlobal.cpp
View file @
de7bd5d0
#include "HGUIGlobal.h"
#include "HGUIGlobal.h"
#include "base/HGDef.h"
#include "base/HGInc.h"
#include "base/HGUtility.h"
#include "base/HGUtility.h"
QString
getStdFileName
(
const
QString
&
fileName
)
QString
getStdFileName
(
const
QString
&
fileName
)
...
@@ -16,3 +18,57 @@ std::string getStdString(const QString &str)
...
@@ -16,3 +18,57 @@ std::string getStdString(const QString &str)
return
str
.
toStdString
();
return
str
.
toStdString
();
#endif
#endif
}
}
#if defined(HG_CMP_MSC)
static
std
::
string
AnsiToUtf8
(
const
char
*
text
)
{
int
wlen
=
::
MultiByteToWideChar
(
CP_ACP
,
0
,
text
,
-
1
,
NULL
,
0
);
WCHAR
*
pUnicode
=
new
WCHAR
[
wlen
];
::
MultiByteToWideChar
(
CP_ACP
,
0
,
text
,
-
1
,
pUnicode
,
wlen
);
int
len
=
::
WideCharToMultiByte
(
CP_UTF8
,
0
,
pUnicode
,
-
1
,
NULL
,
0
,
NULL
,
NULL
);
CHAR
*
pUTF8
=
new
CHAR
[
len
];
::
WideCharToMultiByte
(
CP_UTF8
,
0
,
pUnicode
,
-
1
,
pUTF8
,
len
,
NULL
,
NULL
);
delete
[]
pUnicode
;
std
::
string
ret
=
pUTF8
;
delete
[]
pUTF8
;
return
ret
;
}
static
std
::
string
Utf8ToAnsi
(
const
char
*
text
)
{
int
wlen
=
::
MultiByteToWideChar
(
CP_UTF8
,
0
,
text
,
-
1
,
NULL
,
0
);
WCHAR
*
pUnicode
=
new
WCHAR
[
wlen
];
::
MultiByteToWideChar
(
CP_UTF8
,
0
,
text
,
-
1
,
pUnicode
,
wlen
);
int
len
=
::
WideCharToMultiByte
(
CP_ACP
,
0
,
pUnicode
,
-
1
,
NULL
,
0
,
NULL
,
NULL
);
CHAR
*
pAnsi
=
new
CHAR
[
len
];
::
WideCharToMultiByte
(
CP_ACP
,
0
,
pUnicode
,
-
1
,
pAnsi
,
len
,
NULL
,
NULL
);
delete
[]
pUnicode
;
std
::
string
ret
=
pAnsi
;
delete
[]
pAnsi
;
return
ret
;
}
#endif
std
::
string
Utf8ToStdString
(
const
char
*
utf8
)
{
#if defined(HG_CMP_MSC)
return
Utf8ToAnsi
(
utf8
);
#else
return
utf8
;
#endif
}
std
::
string
StdStringToUtf8
(
const
char
*
str
)
{
#if defined(HG_CMP_MSC)
return
AnsiToUtf8
(
str
);
#else
return
str
;
#endif
}
void
TrimString
(
std
::
string
&
str
)
{
int
s
=
(
int
)
str
.
find_first_not_of
(
" "
);
int
e
=
(
int
)
str
.
find_last_not_of
(
" "
);
str
=
str
.
substr
(
s
,
e
-
s
+
1
);
}
ui/HGUIGlobal.h
View file @
de7bd5d0
...
@@ -7,4 +7,10 @@ QString getStdFileName(const QString &fileName);
...
@@ -7,4 +7,10 @@ QString getStdFileName(const QString &fileName);
std
::
string
getStdString
(
const
QString
&
str
);
std
::
string
getStdString
(
const
QString
&
str
);
std
::
string
Utf8ToStdString
(
const
char
*
utf8
);
std
::
string
StdStringToUtf8
(
const
char
*
str
);
void
TrimString
(
std
::
string
&
str
);
#endif
/* __HGUIGLOBAL_H__ */
#endif
/* __HGUIGLOBAL_H__ */
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment