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
497b4541
Commit
497b4541
authored
Mar 18, 2022
by
luoliangyi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
完善缩略图的滚动条功能
parent
81171da7
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
1190 additions
and
521 deletions
+1190
-521
app/Scanner/Scanner/mainwindow.cpp
app/Scanner/Scanner/mainwindow.cpp
+25
-2
app/Scanner/Scanner/mainwindow.h
app/Scanner/Scanner/mainwindow.h
+3
-0
ui/HGImgThumb.cpp
ui/HGImgThumb.cpp
+1074
-467
ui/HGImgThumb.hpp
ui/HGImgThumb.hpp
+88
-52
No files found.
app/Scanner/Scanner/mainwindow.cpp
View file @
497b4541
...
...
@@ -39,6 +39,8 @@ MainWindow::MainWindow(QWidget *parent)
m_thumb
->
move
(
450
,
100
);
m_thumb
->
resize
(
200
,
height
()
-
150
);
connect
(
m_thumb
,
SIGNAL
(
currItemChanged
(
int
)),
this
,
SLOT
(
on_currItemChanged
(
int
)),
Qt
::
QueuedConnection
);
HGImage
img
=
NULL
;
HGImgFmt_LoadImage
(
"D:
\\
1.jpg"
,
0
,
NULL
,
HGBASE_IMGTYPE_RGB
,
HGBASE_IMGORIGIN_TOP
,
&
img
);
m_view
->
addImage
(
img
);
...
...
@@ -46,9 +48,13 @@ MainWindow::MainWindow(QWidget *parent)
QImage
img2
(
"D:
\\
image.png"
);
m_thumb
->
setDefItemImage
(
&
img2
);
m_thumb
->
setType
(
ThumbType_Vert
);
m_thumb
->
setType
(
ThumbType_Grid
);
//m_thumb->setGapSize(30);
m_thumb
->
setItemSize
(
80
);
//m_thumb->setItemTextHeight(0);
//m_thumb->setScrollSize(12);
for
(
int
i
=
0
;
i
<
1
000
;
++
i
)
for
(
int
i
=
0
;
i
<
20
000
;
++
i
)
{
char
fileName
[
256
];
sprintf
(
fileName
,
"D:
\\
Pictures
\\
%d.jpg"
,
i
);
...
...
@@ -120,3 +126,20 @@ void MainWindow::on_act_fullscreen_triggered()
{
m_view
->
setFullScreen
(
true
);
}
void
MainWindow
::
on_currItemChanged
(
int
index
)
{
if
(
-
1
!=
index
)
{
QString
fileName
;
m_thumb
->
getItemFileName
(
index
,
fileName
);
HGImage
img
=
NULL
;
HGImgFmt_LoadImage
(
fileName
.
toStdString
().
c_str
(),
0
,
NULL
,
HGBASE_IMGTYPE_RGB
,
HGBASE_IMGORIGIN_TOP
,
&
img
);
if
(
NULL
!=
img
)
{
m_view
->
addImage
(
img
);
HGBase_DestroyImage
(
img
);
}
}
}
app/Scanner/Scanner/mainwindow.h
View file @
497b4541
...
...
@@ -42,6 +42,9 @@ private slots:
void
on_act_fullscreen_triggered
();
private
slots
:
void
on_currItemChanged
(
int
index
);
private:
Ui
::
MainWindow
*
ui
;
HGImgView
*
m_view
;
...
...
ui/HGImgThumb.cpp
View file @
497b4541
This diff is collapsed.
Click to expand it.
ui/HGImgThumb.hpp
View file @
497b4541
...
...
@@ -23,28 +23,6 @@ enum ThumbRemoveFlag
ThumbRemoveFlag_Delete
=
2
// 从列表中删除,并删除文件
};
struct
HGImgThumbItem
{
HGImgThumbItem
()
{
image
=
NULL
;
selected
=
false
;
}
~
HGImgThumbItem
()
{
if
(
NULL
!=
image
)
{
delete
image
;
image
=
NULL
;
}
}
QString
fileName
;
QImage
*
image
;
bool
selected
;
};
class
HGImgThumb
:
public
QWidget
{
Q_OBJECT
...
...
@@ -52,18 +30,22 @@ public:
HGImgThumb
(
QWidget
*
parent
=
nullptr
);
virtual
~
HGImgThumb
();
enum
MoveStauts
{
MoveStatus_Null
=
0
,
MoveStatus_HRoll
=
1
,
MoveStatus_VRoll
=
2
};
HGResult
setGapSize
(
int
size
);
HGResult
setScrollSize
(
int
size
);
HGResult
setItemSize
(
int
size
);
HGResult
setItemTextHeight
(
int
height
);
HGResult
setDefItemImage
(
const
QImage
*
image
);
HGResult
setHScrollLeftImage
(
const
QImage
*
normalImage
,
const
QImage
*
hotImage
,
const
QImage
*
pushImage
);
HGResult
setHScrollRightImage
(
const
QImage
*
normalImage
,
const
QImage
*
hotImage
,
const
QImage
*
pushImage
);
HGResult
setVScrollTopImage
(
const
QImage
*
normalImage
,
const
QImage
*
hotImage
,
const
QImage
*
pushImage
);
HGResult
setVScrollBottomImage
(
const
QImage
*
normalImage
,
const
QImage
*
hotImage
,
const
QImage
*
pushImage
);
HGResult
setScrollImage
(
const
QImage
*
image
,
const
QRect
*
stretch
);
HGResult
setscrollSliderImage
(
const
QImage
*
normalImage
,
const
QRect
*
normalStretch
,
const
QImage
*
hotImage
,
const
QRect
*
hotStretch
,
const
QImage
*
pushImage
,
const
QRect
*
pushStretch
);
HGResult
setType
(
ThumbType
type
);
HGResult
setGap
(
int
width
);
HGResult
zoomIn
();
HGResult
zoomOut
();
HGResult
setDefItemImage
(
const
QImage
*
image
);
HGResult
getItemCount
(
int
*
count
);
HGResult
addItem
(
const
QString
&
fileName
);
...
...
@@ -81,12 +63,50 @@ public:
HGResult
locateItem
(
int
index
);
signals:
void
curr
ent
ItemChanged
(
int
index
);
void
currItemChanged
(
int
index
);
void
itemDoubleClicked
(
int
index
);
void
itemCountChanged
(
int
count
);
void
itemSelectingChanged
();
void
contextMenuEvent
(
int
index
);
private:
struct
HGImgThumbItem
{
HGImgThumbItem
()
{
image
=
NULL
;
selected
=
false
;
}
~
HGImgThumbItem
()
{
if
(
NULL
!=
image
)
{
delete
image
;
image
=
NULL
;
}
}
QString
fileName
;
QImage
*
image
;
bool
selected
;
};
enum
MouseStatus
{
MouseStatus_Null
=
0
,
MouseStatus_HScroll
,
MouseStatus_HScrollSlider
,
MouseStatus_HScrollLeft
,
MouseStatus_HScrollRight
,
MouseStatus_VScroll
,
MouseStatus_VScrollSlider
,
MouseStatus_VScrollTop
,
MouseStatus_VScrollBottom
,
MouseStatus_NullScroll
};
protected:
virtual
void
mousePressEvent
(
QMouseEvent
*
e
);
virtual
void
mouseMoveEvent
(
QMouseEvent
*
e
);
...
...
@@ -110,27 +130,30 @@ private slots:
private:
static
QImage
*
createItemImage
(
const
QImage
*
srcImage
,
int
itemSize
);
static
QImage
*
createItemImage
(
HGImage
srcImage
,
int
itemSize
);
static
void
calcShowSize
(
int
wndWidth
,
int
wndHeight
,
int
rollWidth
,
ThumbType
type
,
int
itemSize
,
int
gapWidth
,
int
itemCount
,
int
&
showWidth
,
int
&
showHeight
,
bool
&
hRoll
,
bool
&
vRoll
);
static
void
recalcShowRect
(
int
wndWidth
,
int
wndHeight
,
int
rollWidth
,
ThumbType
type
,
bool
hRoll
,
bool
vRoll
,
bool
showThumb
,
HGRect
&
showRect
);
static
void
calcShowSize
(
int
wndWidth
,
int
wndHeight
,
int
gapSize
,
int
scrollSize
,
int
itemSize
,
int
itemTextHeight
,
ThumbType
type
,
int
itemCount
,
int
&
showWidth
,
int
&
showHeight
,
bool
&
hScroll
,
bool
&
vScroll
);
static
void
recalcShowRect
(
int
wndWidth
,
int
wndHeight
,
int
scrollSize
,
ThumbType
type
,
bool
hScroll
,
bool
vScroll
,
bool
showThumb
,
HGRect
&
showRect
);
void
locateItemEx
(
int
index
);
QPoint
getItemLoc
(
int
index
);
int
getItemRow
(
int
index
);
int
getItemCol
(
int
index
);
int
getTotalRows
();
int
getTotalCols
();
int
getItem
(
const
QPoint
&
pt
);
int
getItem
(
const
QPoint
&
pt
,
MouseStatus
&
mouseMoveStatus
);
int
getInsertPos
(
const
QPoint
&
pt
);
int
findIndex
(
const
QString
&
fileName
);
QRect
getHRollPos
();
QRect
getHRollLeftPos
();
QRect
getHRollRightPos
();
QRect
getVRollPos
();
QRect
getVRollTopPos
();
QRect
getVRollBottomPos
();
QRect
getHRollSliderPos
();
QRect
getVRollSliderPos
();
QRect
getNullRollPos
();
QRect
getHScrollLeftPos
();
QRect
getHScrollRightPos
();
QRect
getHScrollPos
();
QRect
getHScrollSliderPos
();
QRect
getVScrollTopPos
();
QRect
getVScrollBottomPos
();
QRect
getVScrollPos
();
QRect
getVScrollSliderPos
();
QRect
getNullScrollPos
();
void
Show
();
static
void
ThreadFunc
(
HGThread
thread
,
HGPointer
param
);
...
...
@@ -139,11 +162,23 @@ private:
HGLock
m_lockBack
;
HGLock
m_lockItemSize
;
HGEvent
m_event
;
ThumbType
m_type
;
int
m_gapSize
;
int
m_scrollSize
;
int
m_itemSize
;
int
m_itemTextHeight
;
QImage
*
m_defItemImage
;
QImage
*
m_itemImage
;
int
m_gapWidth
;
int
m_itemSize
;
QImage
*
m_hScrollLeftImage
[
3
];
QImage
*
m_hScrollRightImage
[
3
];
QImage
*
m_vScrollTopImage
[
3
];
QImage
*
m_vScrollBottomImage
[
3
];
QImage
*
m_scrollImage
;
QRect
m_scrollImageStretch
;
QImage
*
m_scrollSliderImage
[
3
];
QRect
m_scrollSliderImageStretch
[
3
];
ThumbType
m_type
;
int
m_curItemIndex
;
int
m_hotItemIndex
;
int
m_signItemIndex
;
...
...
@@ -151,15 +186,16 @@ private:
HGThread
m_thread
;
std
::
vector
<
HGImgThumbItem
*>
m_frontItems
;
std
::
list
<
QString
>
m_backList
;
bool
m_h
R
oll
;
bool
m_v
R
oll
;
bool
m_h
Scr
oll
;
bool
m_v
Scr
oll
;
bool
m_showThumb
;
HGRect
m_showRect
;
int
m_mousePosX
;
int
m_mousePosY
;
MoveStauts
m_moveStatus
;
int
m_beginX
;
int
m_beginY
;
MouseStatus
m_mouseMoveStatus
;
MouseStatus
m_mousePressStatus
;
int
m_mousePressBeginX
;
int
m_mousePressBeginY
;
};
#endif
/* __HGIMGTHUMB_HPP__ */
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