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
4c1ae170
Commit
4c1ae170
authored
Apr 01, 2022
by
luoliangyi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1)Scanner减少不必要的图像加载,提高使用体验
2)HGImgThumb减少不必要的CurrItemChanged信号
parent
9dd1a588
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
183 additions
and
128 deletions
+183
-128
app/Scanner/Scanner/dialog_exportimagefile.cpp
app/Scanner/Scanner/dialog_exportimagefile.cpp
+11
-12
app/Scanner/Scanner/dialog_exportimagefile.h
app/Scanner/Scanner/dialog_exportimagefile.h
+0
-2
app/Scanner/Scanner/dialog_fullscreen.cpp
app/Scanner/Scanner/dialog_fullscreen.cpp
+2
-0
app/Scanner/Scanner/dialog_fullscreen.ui
app/Scanner/Scanner/dialog_fullscreen.ui
+1
-1
app/Scanner/Scanner/mainwindow.cpp
app/Scanner/Scanner/mainwindow.cpp
+107
-65
app/Scanner/Scanner/mainwindow.h
app/Scanner/Scanner/mainwindow.h
+1
-0
ui/HGImgThumb.cpp
ui/HGImgThumb.cpp
+60
-47
ui/HGImgView.cpp
ui/HGImgView.cpp
+1
-1
No files found.
app/Scanner/Scanner/dialog_exportimagefile.cpp
View file @
4c1ae170
...
...
@@ -9,8 +9,6 @@ Dialog_ExportImageFile::Dialog_ExportImageFile(const QString &destFile, int save
,
m_destFile
(
destFile
)
,
m_saveQuality
(
saveQuality
)
,
m_srcFiles
(
srcFiles
)
,
m_stopThread
(
false
)
,
m_thread
(
nullptr
)
{
ui
->
setupUi
(
this
);
...
...
@@ -21,24 +19,21 @@ Dialog_ExportImageFile::Dialog_ExportImageFile(const QString &destFile, int save
connect
(
this
,
SIGNAL
(
updateProgress
(
int
)),
this
,
SLOT
(
on_updateProgress
(
int
)),
Qt
::
QueuedConnection
);
connect
(
this
,
SIGNAL
(
finish
()),
this
,
SLOT
(
on_finish
()),
Qt
::
QueuedConnection
);
start
();
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
::
start
()
{
assert
(
NULL
==
m_thread
);
m_stopThread
=
false
;
HGBase_OpenThread
(
ThreadFunc
,
this
,
&
m_thread
);
}
void
Dialog_ExportImageFile
::
ThreadFunc
(
HGThread
thread
,
HGPointer
param
)
{
(
void
)
thread
;
...
...
@@ -102,10 +97,14 @@ void Dialog_ExportImageFile::on_finish()
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
;
}
app/Scanner/Scanner/dialog_exportimagefile.h
View file @
4c1ae170
...
...
@@ -16,8 +16,6 @@ public:
explicit
Dialog_ExportImageFile
(
const
QString
&
destFile
,
int
saveQuality
,
const
QStringList
&
srcFiles
,
QWidget
*
parent
=
nullptr
);
~
Dialog_ExportImageFile
();
void
start
();
private:
static
void
ThreadFunc
(
HGThread
thread
,
HGPointer
param
);
...
...
app/Scanner/Scanner/dialog_fullscreen.cpp
View file @
4c1ae170
...
...
@@ -197,6 +197,8 @@ void Dialog_FullScreen::on_escape()
void
Dialog_FullScreen
::
on_mouseMove
(
int
x
,
int
y
)
{
(
void
)
x
;
(
void
)
y
;
setBtnOpacity
(
0.7
);
}
...
...
app/Scanner/Scanner/dialog_fullscreen.ui
View file @
4c1ae170
...
...
@@ -358,7 +358,7 @@
<customwidget>
<class>
HGImgView
</class>
<extends>
QWidget
</extends>
<header>
hgimgv
iew.h
</header>
<header>
HGImgV
iew.h
</header>
<container>
1
</container>
</customwidget>
</customwidgets>
...
...
app/Scanner/Scanner/mainwindow.cpp
View file @
4c1ae170
...
...
@@ -17,9 +17,11 @@
MainWindow
::
MainWindow
(
QWidget
*
parent
)
:
QMainWindow
(
parent
)
,
ui
(
new
Ui
::
MainWindow
)
,
m_currFilePath
(
""
)
,
m_currIndex
(
-
1
)
,
m_multiPageCount
(
0
)
,
m_multiIndex
(
-
1
)
,
m_relation
(
false
)
,
m_modify
(
false
)
{
ui
->
setupUi
(
this
);
...
...
@@ -128,6 +130,12 @@ MainWindow::MainWindow(QWidget *parent)
MainWindow
::~
MainWindow
()
{
if
(
nullptr
!=
m_dlgFullScreen
)
{
delete
m_dlgFullScreen
;
m_dlgFullScreen
=
nullptr
;
}
delete
ui
;
}
...
...
@@ -220,7 +228,15 @@ void MainWindow::on_currItemChanged(int index)
{
HGImage
img
=
nullptr
;
m_view
->
getImage
(
&
img
);
if
(
nullptr
!=
img
&&
m_modify
&&
-
1
!=
m_currIndex
&&
m_multiPageCount
==
1
)
if
(
nullptr
!=
img
&&
m_relation
&&
m_modify
&&
-
1
!=
m_currIndex
&&
m_multiPageCount
==
1
)
{
assert
(
!
m_currFilePath
.
isEmpty
());
QString
newCurrFilePath
;
if
(
-
1
!=
index
)
m_thumb
->
getItemFileName
(
index
,
newCurrFilePath
);
if
(
m_currFilePath
!=
newCurrFilePath
)
{
int
ret
=
QMessageBox
::
question
(
this
,
tr
(
"Question"
),
tr
(
"modified, save it?"
));
if
(
ret
==
QMessageBox
::
Yes
)
...
...
@@ -228,9 +244,11 @@ void MainWindow::on_currItemChanged(int index)
on_act_save_triggered
();
}
}
}
m_currIndex
=
index
;
QString
oldCurrFilePath
=
m_currFilePath
;
m_currFilePath
.
clear
();
m_currIndex
=
index
;
m_multiIndex
=
(
-
1
!=
m_currIndex
)
?
0
:
-
1
;
m_multiPageCount
=
0
;
...
...
@@ -240,23 +258,30 @@ void MainWindow::on_currItemChanged(int index)
assert
(
!
m_currFilePath
.
isEmpty
());
m_multiPageCount
=
getMultiPageCount
();
if
(
oldCurrFilePath
!=
m_currFilePath
)
{
HGImage
img2
=
createImage
();
if
(
nullptr
!=
img2
)
{
m_view
->
addImage
(
img2
);
HGBase_DestroyImage
(
img2
);
m_relation
=
true
;
m_modify
=
false
;
}
else
{
m_view
->
clearImage
();
m_relation
=
false
;
m_modify
=
false
;
}
}
}
else
{
m_view
->
clearImage
();
}
m_relation
=
false
;
m_modify
=
false
;
}
}
void
MainWindow
::
on_itemDoubleClicked
(
int
index
)
...
...
@@ -266,6 +291,28 @@ void MainWindow::on_itemDoubleClicked(int index)
void
MainWindow
::
on_viewerDrop
(
const
QString
&
fileName
)
{
int
index
=
-
1
;
int
count
=
0
;
m_thumb
->
getItemCount
(
&
count
);
for
(
int
i
=
0
;
i
<
count
;
++
i
)
{
QString
fName
;
m_thumb
->
getItemFileName
(
i
,
fName
);
assert
(
!
fName
.
isEmpty
());
if
(
fName
==
fileName
)
{
index
=
i
;
break
;
}
}
if
(
-
1
!=
index
)
{
m_thumb
->
setCurrItem
(
index
);
}
else
{
HGImage
img
=
nullptr
;
HGPdfReader
pdfReader
=
nullptr
;
...
...
@@ -295,7 +342,9 @@ void MainWindow::on_viewerDrop(const QString &fileName)
m_view
->
addImage
(
img
);
HGBase_DestroyImage
(
img
);
m_relation
=
false
;
m_modify
=
false
;
}
}
void
MainWindow
::
on_act_thumbnailBar_triggered
(
bool
checked
)
...
...
@@ -351,6 +400,8 @@ void MainWindow::on_act_last_triggered()
HGImage
MainWindow
::
createImage
()
{
qDebug
(
"createImage"
);
assert
(
-
1
!=
m_currIndex
&&
-
1
!=
m_multiIndex
);
assert
(
!
m_currFilePath
.
isEmpty
());
...
...
@@ -431,14 +482,16 @@ void MainWindow::on_act_previousPage_triggered()
{
m_view
->
addImage
(
img
);
HGBase_DestroyImage
(
img
);
m_relation
=
true
;
m_modify
=
false
;
}
else
{
m_view
->
clearImage
();
}
m_relation
=
false
;
m_modify
=
false
;
}
}
}
void
MainWindow
::
on_act_nextPage_triggered
()
...
...
@@ -452,14 +505,16 @@ void MainWindow::on_act_nextPage_triggered()
{
m_view
->
addImage
(
img
);
HGBase_DestroyImage
(
img
);
m_relation
=
true
;
m_modify
=
false
;
}
else
{
m_view
->
clearImage
();
}
m_relation
=
false
;
m_modify
=
false
;
}
}
}
void
MainWindow
::
on_act_firstPage_triggered
()
...
...
@@ -473,14 +528,16 @@ void MainWindow::on_act_firstPage_triggered()
{
m_view
->
addImage
(
img
);
HGBase_DestroyImage
(
img
);
m_relation
=
true
;
m_modify
=
false
;
}
else
{
m_view
->
clearImage
();
}
m_relation
=
false
;
m_modify
=
false
;
}
}
}
void
MainWindow
::
on_act_lastPage_triggered
()
...
...
@@ -494,14 +551,16 @@ void MainWindow::on_act_lastPage_triggered()
{
m_view
->
addImage
(
img
);
HGBase_DestroyImage
(
img
);
m_relation
=
true
;
m_modify
=
false
;
}
else
{
m_view
->
clearImage
();
}
m_relation
=
false
;
m_modify
=
false
;
}
}
}
void
MainWindow
::
on_act_adjust_triggered
()
...
...
@@ -553,26 +612,9 @@ void MainWindow::on_act_exit_triggered()
void
MainWindow
::
on_act_save_triggered
()
{
if
(
-
1
==
m_currIndex
)
{
return
;
}
HGImage
img
=
nullptr
;
m_view
->
getImage
(
&
img
);
if
(
nullptr
==
img
)
{
return
;
}
// 没有修改不用保存
if
(
!
m_modify
)
{
return
;
}
// 如果是多张,不保存
if
(
1
!=
m_multiPageCount
)
if
(
nullptr
==
img
||
!
m_relation
||
!
m_modify
||
-
1
==
m_currIndex
||
1
!=
m_multiPageCount
)
{
return
;
}
...
...
@@ -720,7 +762,7 @@ void MainWindow::on_act_imageInfo_triggered()
HGImgFmt_OpenImageReader
(
getStdString
(
m_currFilePath
).
c_str
(),
0
,
&
imgFmtReader
);
if
(
nullptr
!=
imgFmtReader
)
{
HGImgFmt_LoadImageFromReader
(
imgFmtReader
,
m_multiIndex
,
&
imgInfo
,
0
,
0
,
nullptr
);
HGImgFmt_LoadImageFromReader
(
imgFmtReader
,
(
HGUInt
)
m_multiIndex
,
&
imgInfo
,
0
,
0
,
nullptr
);
HGImgFmt_CloseImageReader
(
imgFmtReader
);
}
...
...
@@ -774,7 +816,7 @@ void MainWindow::on_act_imageInfo_triggered()
imageValues
.
append
(
QString
::
number
(
imgInfo
.
width
));
//add image width
imageValues
.
append
(
QString
::
number
(
imgInfo
.
height
));
//add image height
int
depth
=
imgInfo
.
bpp
;
int
depth
=
(
int
)
imgInfo
.
bpp
;
imageValues
.
append
(
QString
::
number
(
depth
));
//add image depth
imageValues
.
append
(
depth
==
0
?
tr
(
"None"
)
:
(
depth
==
1
?
tr
(
"Mono"
)
:
(
depth
==
8
?
tr
(
"Gray"
)
:
tr
(
"Color"
))));
//add image color
QString
dpi
=
QString
::
number
(
imgInfo
.
xDpi
)
+
" x "
+
QString
::
number
(
imgInfo
.
yDpi
);
...
...
@@ -799,7 +841,7 @@ void MainWindow::closeEvent(QCloseEvent *e)
HGImage
img
=
nullptr
;
m_view
->
getImage
(
&
img
);
if
(
nullptr
!=
img
&&
m_modify
&&
-
1
!=
m_currIndex
&&
m_multiPageCount
==
1
)
if
(
nullptr
!=
img
&&
m_
relation
&&
m_
modify
&&
-
1
!=
m_currIndex
&&
m_multiPageCount
==
1
)
{
int
ret
=
QMessageBox
::
question
(
this
,
tr
(
"Question"
),
tr
(
"modified, save it?"
));
if
(
ret
==
QMessageBox
::
Yes
)
...
...
app/Scanner/Scanner/mainwindow.h
View file @
4c1ae170
...
...
@@ -105,6 +105,7 @@ private:
int
m_currIndex
;
int
m_multiPageCount
;
int
m_multiIndex
;
bool
m_relation
;
// m_view上的图像是否关联到m_thumb
bool
m_modify
;
// m_view上面的图像是否改变
class
Dialog_FullScreen
*
m_dlgFullScreen
;
...
...
ui/HGImgThumb.cpp
View file @
4c1ae170
...
...
@@ -1193,12 +1193,17 @@ HGResult HGImgThumb::insertItems(const QStringList &fileNames, int pos)
reset
();
bool
emitItemCount
=
false
;
bool
emitCurrItemChange
=
false
;
bool
emitSelectChanged
=
false
;
int
oldItemCount
=
(
int
)
m_frontItems
.
size
();
int
oldCurrItemIndex
=
m_curItemIndex
;
QString
oldCurrItemFilePath
;
if
(
-
1
!=
oldCurrItemIndex
)
oldCurrItemFilePath
=
m_frontItems
[
oldCurrItemIndex
]
->
fileName
;
std
::
vector
<
int
>
oldSelectedIndexs
;
for
(
int
i
=
0
;
i
<
(
int
)
m_frontItems
.
size
();
++
i
)
{
if
(
m_frontItems
[
i
]
->
selected
)
oldSelectedIndexs
.
push_back
(
i
);
m_frontItems
[
i
]
->
selected
=
false
;
}
...
...
@@ -1270,19 +1275,29 @@ HGResult HGImgThumb::insertItems(const QStringList &fileNames, int pos)
m_thumbRect
.
bottom
=
m_thumbRect
.
top
+
(
double
)
showHeight
;
locateItem
(
posEx
-
1
);
recalcShowRect
(
this
->
width
(),
this
->
height
(),
m_scrollSize
,
m_type
,
m_hScroll
,
m_vScroll
,
m_showThumb
,
m_thumbRect
);
emitItemCount
=
true
;
emitCurrItemChange
=
true
;
emitSelectChanged
=
true
;
}
m_hotItemIndex
=
getItemIndex
(
mapFromGlobal
(
QCursor
::
pos
()),
m_mouseMoveStatus
);
Show
();
if
(
emitItemCount
)
int
newItemCount
=
(
int
)
m_frontItems
.
size
();
int
newCurrItemIndex
=
m_curItemIndex
;
QString
newCurrItemFilePath
;
if
(
-
1
!=
newCurrItemIndex
)
newCurrItemFilePath
=
m_frontItems
[
newCurrItemIndex
]
->
fileName
;
std
::
vector
<
int
>
newSelectedIndexs
;
for
(
int
i
=
0
;
i
<
(
int
)
m_frontItems
.
size
();
++
i
)
{
if
(
m_frontItems
[
i
]
->
selected
)
newSelectedIndexs
.
push_back
(
i
);
}
if
(
newItemCount
!=
oldItemCount
)
emit
itemCountChanged
((
int
)
m_frontItems
.
size
());
if
(
emitCurrItemChange
)
if
(
newCurrItemIndex
!=
oldCurrItemIndex
||
newCurrItemFilePath
!=
oldCurrItemFilePath
)
emit
currItemChanged
(
m_curItemIndex
);
if
(
emitSelectChanged
)
if
(
newSelectedIndexs
!=
oldSelectedIndexs
)
emit
itemSelectingChanged
();
return
HGBASE_ERR_OK
;
}
...
...
@@ -1602,7 +1617,7 @@ HGResult HGImgThumb::updateItem(int index, const QString &fileName)
break
;
}
}
m_backList
.
push_
back
(
stdFileName
);
m_backList
.
push_
front
(
stdFileName
);
HGBase_LeaveLock
(
m_lockBack
);
HGBase_SetEvent
(
m_event
);
...
...
@@ -1621,43 +1636,22 @@ HGResult HGImgThumb::refreshItem(int index)
return
HGBASE_ERR_INVALIDARG
;
}
HGImage
image
=
nullptr
;
HGResult
ret
=
HGImgFmt_LoadImage
(
getStdString
(
m_frontItems
[
index
]
->
fileName
).
c_str
(),
0
,
nullptr
,
HGBASE_IMGTYPE_RGB
,
HGBASE_IMGORIGIN_TOP
,
&
image
);
if
(
nullptr
==
image
)
{
return
ret
;
}
QImage
*
img
=
createItemImage
(
image
,
m_itemSize
);
if
(
nullptr
==
img
)
{
HGBase_DestroyImage
(
image
);
return
HGBASE_ERR_FAIL
;
}
QString
fileName
=
m_frontItems
[
index
]
->
fileName
;
HGBase_EnterLock
(
m_lockBack
);
std
::
list
<
QString
>::
iterator
iter
;
for
(
iter
=
m_backList
.
begin
();
iter
!=
m_backList
.
end
();
++
iter
)
{
if
(
0
==
(
*
iter
).
compare
(
m_frontItems
[
index
]
->
fileName
))
if
(
0
==
(
*
iter
).
compare
(
fileName
))
{
m_backList
.
erase
(
iter
);
break
;
}
}
m_backList
.
push_front
(
fileName
);
HGBase_LeaveLock
(
m_lockBack
);
HGBase_SetEvent
(
m_event
);
HGImageInfo
imgInfo
;
HGBase_GetImageInfo
(
image
,
&
imgInfo
);
HGBase_EnterLock
(
m_lockFront
);
m_frontItems
[
index
]
->
width
=
imgInfo
.
width
;
m_frontItems
[
index
]
->
height
=
imgInfo
.
height
;
delete
m_frontItems
[
index
]
->
image
;
m_frontItems
[
index
]
->
image
=
img
;
HGBase_LeaveLock
(
m_lockFront
);
Show
();
HGBase_DestroyImage
(
image
);
return
HGBASE_ERR_OK
;
}
...
...
@@ -2983,9 +2977,18 @@ void HGImgThumb::dragLeaveEvent(QDragLeaveEvent *e)
void
HGImgThumb
::
dropEvent
(
QDropEvent
*
e
)
{
bool
emitItemCount
=
false
;
bool
emitCurrItemChange
=
false
;
bool
emitSelectChanged
=
false
;
int
oldItemCount
=
(
int
)
m_frontItems
.
size
();
int
oldCurrItemIndex
=
m_curItemIndex
;
QString
oldCurrItemFilePath
;
if
(
-
1
!=
oldCurrItemIndex
)
oldCurrItemFilePath
=
m_frontItems
[
oldCurrItemIndex
]
->
fileName
;
std
::
vector
<
int
>
oldSelectedIndexs
;
for
(
int
i
=
0
;
i
<
(
int
)
m_frontItems
.
size
();
++
i
)
{
if
(
m_frontItems
[
i
]
->
selected
)
oldSelectedIndexs
.
push_back
(
i
);
}
QList
<
QUrl
>
urls
=
e
->
mimeData
()
->
urls
();
if
(
-
1
!=
m_curInsertPos
&&
!
urls
.
isEmpty
())
...
...
@@ -3066,10 +3069,6 @@ void HGImgThumb::dropEvent(QDropEvent *e)
m_thumbRect
.
bottom
=
m_thumbRect
.
top
+
(
double
)
showHeight
;
locateItem
(
posEx
-
1
);
recalcShowRect
(
this
->
width
(),
this
->
height
(),
m_scrollSize
,
m_type
,
m_hScroll
,
m_vScroll
,
m_showThumb
,
m_thumbRect
);
emitItemCount
=
true
;
emitCurrItemChange
=
true
;
emitSelectChanged
=
true
;
}
}
...
...
@@ -3079,11 +3078,25 @@ void HGImgThumb::dropEvent(QDropEvent *e)
m_hotItemIndex
=
getItemIndex
(
mapFromGlobal
(
QCursor
::
pos
()),
m_mouseMoveStatus
);
Show
();
if
(
emitItemCount
)
int
newItemCount
=
(
int
)
m_frontItems
.
size
();
int
newCurrItemIndex
=
m_curItemIndex
;
QString
newCurrItemFilePath
;
if
(
-
1
!=
newCurrItemIndex
)
newCurrItemFilePath
=
m_frontItems
[
newCurrItemIndex
]
->
fileName
;
std
::
vector
<
int
>
newSelectedIndexs
;
for
(
int
i
=
0
;
i
<
(
int
)
m_frontItems
.
size
();
++
i
)
{
if
(
m_frontItems
[
i
]
->
selected
)
newSelectedIndexs
.
push_back
(
i
);
}
if
(
newItemCount
!=
oldItemCount
)
emit
itemCountChanged
((
int
)
m_frontItems
.
size
());
if
(
emitCurrItemChange
)
if
(
newCurrItemIndex
!=
oldCurrItemIndex
||
newCurrItemFilePath
!=
oldCurrItemFilePath
)
emit
currItemChanged
(
m_curItemIndex
);
if
(
emitSelectChanged
)
if
(
newSelectedIndexs
!=
oldSelectedIndexs
)
emit
itemSelectingChanged
();
}
...
...
@@ -4304,7 +4317,7 @@ QRect HGImgThumb::getNullScrollPos()
void
HGImgThumb
::
Show
()
{
update
();
repaint
();
}
void
HGImgThumb
::
ThreadFunc
(
HGThread
thread
,
HGPointer
param
)
...
...
ui/HGImgView.cpp
View file @
4c1ae170
...
...
@@ -2372,5 +2372,5 @@ QRect HGImgView::getNullScrollPos()
void
HGImgView
::
Show
()
{
update
();
repaint
();
}
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