Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Multimedia
Kdenlive
Commits
811f9353
Commit
811f9353
authored
Dec 01, 2011
by
Jean-Baptiste Mardelle
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cleanup thumbnails (prefer QImage over QPixmap)
parent
20accf40
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
39 additions
and
62 deletions
+39
-62
src/docclipbase.cpp
src/docclipbase.cpp
+3
-15
src/docclipbase.h
src/docclipbase.h
+1
-10
src/kdenlivedoc.cpp
src/kdenlivedoc.cpp
+2
-2
src/kdenlivedoc.h
src/kdenlivedoc.h
+1
-2
src/kthumb.cpp
src/kthumb.cpp
+5
-6
src/kthumb.h
src/kthumb.h
+1
-1
src/monitor.cpp
src/monitor.cpp
+2
-2
src/projectlist.cpp
src/projectlist.cpp
+24
-22
src/projectlist.h
src/projectlist.h
+0
-2
No files found.
src/docclipbase.cpp
View file @
811f9353
...
@@ -251,17 +251,6 @@ void DocClipBase::setAudioThumbCreated(bool isDone)
...
@@ -251,17 +251,6 @@ void DocClipBase::setAudioThumbCreated(bool isDone)
m_audioThumbCreated
=
isDone
;
m_audioThumbCreated
=
isDone
;
}
}
void
DocClipBase
::
setThumbnail
(
const
QPixmap
&
pixmap
)
{
m_thumbnail
=
pixmap
;
}
const
QPixmap
&
DocClipBase
::
thumbnail
()
const
{
return
m_thumbnail
;
}
void
DocClipBase
::
updateAudioThumbnail
(
const
audioByteArray
&
data
)
void
DocClipBase
::
updateAudioThumbnail
(
const
audioByteArray
&
data
)
{
{
//kDebug() << "CLIPBASE RECIEDVED AUDIO DATA*********************************************";
//kDebug() << "CLIPBASE RECIEDVED AUDIO DATA*********************************************";
...
@@ -1193,12 +1182,11 @@ void DocClipBase::slotExtractImage(QList <int> frames)
...
@@ -1193,12 +1182,11 @@ void DocClipBase::slotExtractImage(QList <int> frames)
m_thumbProd
->
extractImage
(
frames
);
m_thumbProd
->
extractImage
(
frames
);
}
}
Q
Pixmap
DocClipBase
::
extractImage
(
int
frame
,
int
width
,
int
height
)
Q
Image
DocClipBase
::
extractImage
(
int
frame
,
int
width
,
int
height
)
{
{
if
(
m_thumbProd
==
NULL
)
return
Q
Pixmap
(
width
,
height
);
if
(
m_thumbProd
==
NULL
)
return
Q
Image
(
);
QMutexLocker
locker
(
&
m_producerMutex
);
QMutexLocker
locker
(
&
m_producerMutex
);
QPixmap
p
=
m_thumbProd
->
extractImage
(
frame
,
width
,
height
);
return
m_thumbProd
->
extractImage
(
frame
,
width
,
height
);
return
p
;
}
}
src/docclipbase.h
View file @
811f9353
...
@@ -161,15 +161,9 @@ Q_OBJECT public:
...
@@ -161,15 +161,9 @@ Q_OBJECT public:
* it uses it as part of it's own composition. */
* it uses it as part of it's own composition. */
bool
referencesClip
(
DocClipBase
*
clip
)
const
;
bool
referencesClip
(
DocClipBase
*
clip
)
const
;
/** Sets the thumbnail to be used by this clip */
void
setThumbnail
(
const
QPixmap
&
pixmap
);
/** Returns the thumbnail producer used by this clip */
/** Returns the thumbnail producer used by this clip */
KThumb
*
thumbProducer
();
KThumb
*
thumbProducer
();
/** Returns the thumbnail used by this clip */
const
QPixmap
&
thumbnail
()
const
;
/** Cache for every audio Frame with 10 Bytes */
/** Cache for every audio Frame with 10 Bytes */
/** format is frame -> channel ->bytes */
/** format is frame -> channel ->bytes */
QMap
<
int
,
QMap
<
int
,
QByteArray
>
>
m_audioFrameCache
;
QMap
<
int
,
QMap
<
int
,
QByteArray
>
>
m_audioFrameCache
;
...
@@ -203,7 +197,7 @@ Q_OBJECT public:
...
@@ -203,7 +197,7 @@ Q_OBJECT public:
bool
hasAudioCodec
(
const
QString
&
codec
)
const
;
bool
hasAudioCodec
(
const
QString
&
codec
)
const
;
bool
checkHash
()
const
;
bool
checkHash
()
const
;
void
setPlaceHolder
(
bool
place
);
void
setPlaceHolder
(
bool
place
);
Q
Pixmap
extractImage
(
int
frame
,
int
width
,
int
height
);
Q
Image
extractImage
(
int
frame
,
int
width
,
int
height
);
void
clearThumbProducer
();
void
clearThumbProducer
();
void
reloadThumbProducer
();
void
reloadThumbProducer
();
void
cleanupProducers
();
void
cleanupProducers
();
...
@@ -223,9 +217,6 @@ private: // Private attributes
...
@@ -223,9 +217,6 @@ private: // Private attributes
/** A list of snap markers; these markers are added to a clips snap-to points, and are displayed as necessary. */
/** A list of snap markers; these markers are added to a clips snap-to points, and are displayed as necessary. */
QList
<
CommentedTime
>
m_snapMarkers
;
QList
<
CommentedTime
>
m_snapMarkers
;
/** A thumbnail for this clip */
QPixmap
m_thumbnail
;
GenTime
m_duration
;
GenTime
m_duration
;
KThumb
*
m_thumbProd
;
KThumb
*
m_thumbProd
;
...
...
src/kdenlivedoc.cpp
View file @
811f9353
...
@@ -1377,9 +1377,9 @@ QPoint KdenliveDoc::getTracksCount() const
...
@@ -1377,9 +1377,9 @@ QPoint KdenliveDoc::getTracksCount() const
return
QPoint
(
video
,
audio
);
return
QPoint
(
video
,
audio
);
}
}
void
KdenliveDoc
::
cache
Pixmap
(
const
QString
&
fileId
,
const
Q
Pixmap
&
pix
)
const
void
KdenliveDoc
::
cache
Image
(
const
QString
&
fileId
,
const
Q
Image
&
img
)
const
{
{
pix
.
save
(
m_projectFolder
.
path
(
KUrl
::
AddTrailingSlash
)
+
"thumbs/"
+
fileId
+
".png"
);
img
.
save
(
m_projectFolder
.
path
(
KUrl
::
AddTrailingSlash
)
+
"thumbs/"
+
fileId
+
".png"
);
}
}
bool
KdenliveDoc
::
checkDocumentClips
(
QDomNodeList
infoproducers
)
bool
KdenliveDoc
::
checkDocumentClips
(
QDomNodeList
infoproducers
)
...
...
src/kdenlivedoc.h
View file @
811f9353
...
@@ -140,8 +140,7 @@ Q_OBJECT public:
...
@@ -140,8 +140,7 @@ Q_OBJECT public:
* The returned duration might differ from the actual track duration!
* The returned duration might differ from the actual track duration!
* It is the one stored in the track's TrackInfo. */
* It is the one stored in the track's TrackInfo. */
int
trackDuration
(
int
ix
);
int
trackDuration
(
int
ix
);
void
cacheImage
(
const
QString
&
fileId
,
const
QImage
&
img
)
const
;
void
cachePixmap
(
const
QString
&
fileId
,
const
QPixmap
&
pix
)
const
;
void
setProjectFolder
(
KUrl
url
);
void
setProjectFolder
(
KUrl
url
);
void
setZone
(
int
start
,
int
end
);
void
setZone
(
int
start
,
int
end
);
QPoint
zone
()
const
;
QPoint
zone
()
const
;
...
...
src/kthumb.cpp
View file @
811f9353
...
@@ -122,15 +122,14 @@ void KThumb::getThumb(int frame)
...
@@ -122,15 +122,14 @@ void KThumb::getThumb(int frame)
emit
thumbReady
(
frame
,
img
);
emit
thumbReady
(
frame
,
img
);
}
}
Q
Pixmap
KThumb
::
extractImage
(
int
frame
,
int
width
,
int
height
)
Q
Image
KThumb
::
extractImage
(
int
frame
,
int
width
,
int
height
)
{
{
if
(
m_producer
==
NULL
)
{
if
(
m_producer
==
NULL
)
{
Q
Pixmap
p
(
width
,
height
);
Q
Image
img
(
width
,
height
,
QImage
::
Format_ARGB32_Premultiplied
);
p
.
fill
(
Qt
::
black
);
img
.
fill
(
Qt
::
black
);
return
p
;
return
img
;
}
}
QImage
img
=
getProducerFrame
(
frame
,
(
int
)
(
height
*
m_ratio
+
0.5
),
width
,
height
);
return
getProducerFrame
(
frame
,
(
int
)
(
height
*
m_ratio
+
0.5
),
width
,
height
);
return
QPixmap
::
fromImage
(
img
);
}
}
//static
//static
...
...
src/kthumb.h
View file @
811f9353
...
@@ -63,7 +63,7 @@ Q_OBJECT public:
...
@@ -63,7 +63,7 @@ Q_OBJECT public:
void
clearProducer
();
void
clearProducer
();
void
updateThumbUrl
(
const
QString
&
hash
);
void
updateThumbUrl
(
const
QString
&
hash
);
void
extractImage
(
QList
<
int
>
frames
);
void
extractImage
(
QList
<
int
>
frames
);
Q
Pixmap
extractImage
(
int
frame
,
int
width
,
int
height
);
Q
Image
extractImage
(
int
frame
,
int
width
,
int
height
);
#if KDE_IS_VERSION(4,5,0)
#if KDE_IS_VERSION(4,5,0)
/** @brief Request thumbnails for the frame range. */
/** @brief Request thumbnails for the frame range. */
void
queryIntraThumbs
(
QList
<
int
>
missingFrames
);
void
queryIntraThumbs
(
QList
<
int
>
missingFrames
);
...
...
src/monitor.cpp
View file @
811f9353
...
@@ -503,9 +503,9 @@ void Monitor::mouseMoveEvent(QMouseEvent *event)
...
@@ -503,9 +503,9 @@ void Monitor::mouseMoveEvent(QMouseEvent *event)
data
.
append
(
list
.
join
(
";"
).
toUtf8
());
data
.
append
(
list
.
join
(
";"
).
toUtf8
());
mimeData
->
setData
(
"kdenlive/clip"
,
data
);
mimeData
->
setData
(
"kdenlive/clip"
,
data
);
drag
->
setMimeData
(
mimeData
);
drag
->
setMimeData
(
mimeData
);
QPixmap
pix
=
m_currentClip
->
thumbnail
();
/*
QPixmap pix = m_currentClip->thumbnail();
drag->setPixmap(pix);
drag->setPixmap(pix);
drag
->
setHotSpot
(
QPoint
(
0
,
50
));
drag->setHotSpot(QPoint(0, 50));
*/
drag
->
start
(
Qt
::
MoveAction
);
drag
->
start
(
Qt
::
MoveAction
);
//Qt::DropAction dropAction;
//Qt::DropAction dropAction;
...
...
src/projectlist.cpp
View file @
811f9353
...
@@ -1801,28 +1801,30 @@ void ProjectList::slotRefreshClipThumbnail(QTreeWidgetItem *it, bool update)
...
@@ -1801,28 +1801,30 @@ void ProjectList::slotRefreshClipThumbnail(QTreeWidgetItem *it, bool update)
return
;
return
;
}
}
QPixmap
pix
;
QPixmap
pix
;
QImage
img
;
int
height
=
m_listView
->
iconSize
().
height
();
int
height
=
m_listView
->
iconSize
().
height
();
int
swidth
=
(
int
)(
height
*
m_render
->
frameRenderWidth
()
/
m_render
->
renderHeight
()
+
0.5
);
int
swidth
=
(
int
)(
height
*
m_render
->
frameRenderWidth
()
/
m_render
->
renderHeight
()
+
0.5
);
int
dwidth
=
(
int
)(
height
*
m_render
->
dar
()
+
0.5
);
int
dwidth
=
(
int
)(
height
*
m_render
->
dar
()
+
0.5
);
if
(
clip
->
clipType
()
==
AUDIO
)
if
(
clip
->
clipType
()
==
AUDIO
)
pix
=
KIcon
(
"audio-x-generic"
).
pixmap
(
QSize
(
dwidth
,
height
));
pix
=
KIcon
(
"audio-x-generic"
).
pixmap
(
QSize
(
dwidth
,
height
));
else
if
(
clip
->
clipType
()
==
IMAGE
)
else
if
(
clip
->
clipType
()
==
IMAGE
)
pix
=
QPixmap
::
fromImage
(
KThumb
::
getFrame
(
item
->
referencedClip
()
->
getProducer
(),
0
,
swidth
,
dwidth
,
height
)
)
;
img
=
KThumb
::
getFrame
(
item
->
referencedClip
()
->
getProducer
(),
0
,
swidth
,
dwidth
,
height
);
else
{
else
{
pix
=
item
->
referencedClip
()
->
extractImage
(
frame
,
dwidth
,
height
);
img
=
item
->
referencedClip
()
->
extractImage
(
frame
,
dwidth
,
height
);
}
}
if
(
!
pix
.
isNull
())
{
if
(
!
pix
.
isNull
()
||
!
img
.
isNull
()
)
{
monitorItemEditing
(
false
);
monitorItemEditing
(
false
);
if
(
!
img
.
isNull
())
pix
=
QPixmap
::
fromImage
(
img
);
it
->
setData
(
0
,
Qt
::
DecorationRole
,
pix
);
it
->
setData
(
0
,
Qt
::
DecorationRole
,
pix
);
monitorItemEditing
(
true
);
monitorItemEditing
(
true
);
QString
clipId
=
item
->
getClipHash
();
QString
hash
=
item
->
getClipHash
();
if
(
!
clipId
.
isEmpty
())
{
if
(
!
hash
.
isEmpty
()
&&
!
img
.
isNull
()
)
{
if
(
!
isSubItem
)
if
(
!
isSubItem
)
m_doc
->
cache
Pixmap
(
clipId
,
pix
);
m_doc
->
cache
Image
(
hash
,
img
);
else
else
m_doc
->
cache
Pixmap
(
clipId
+
'#'
+
QString
::
number
(
frame
),
pix
);
m_doc
->
cache
Image
(
hash
+
'#'
+
QString
::
number
(
frame
),
img
);
}
}
}
}
if
(
update
)
if
(
update
)
...
@@ -1998,26 +2000,26 @@ bool ProjectList::generateImageProxy() const
...
@@ -1998,26 +2000,26 @@ bool ProjectList::generateImageProxy() const
void
ProjectList
::
slotReplyGetImage
(
const
QString
&
clipId
,
const
QImage
&
img
)
void
ProjectList
::
slotReplyGetImage
(
const
QString
&
clipId
,
const
QImage
&
img
)
{
{
QPixmap
pix
=
QPixmap
::
fromImage
(
img
);
ProjectItem
*
item
=
getItemById
(
clipId
);
setThumbnail
(
clipId
,
pix
);
if
(
item
&&
!
img
.
isNull
())
{
QPixmap
pix
=
QPixmap
::
fromImage
(
img
);
monitorItemEditing
(
false
);
item
->
setData
(
0
,
Qt
::
DecorationRole
,
pix
);
monitorItemEditing
(
true
);
QString
hash
=
item
->
getClipHash
();
if
(
!
hash
.
isEmpty
())
m_doc
->
cacheImage
(
hash
,
img
);
}
}
}
void
ProjectList
::
slotReplyGetImage
(
const
QString
&
clipId
,
const
QString
&
name
,
int
width
,
int
height
)
void
ProjectList
::
slotReplyGetImage
(
const
QString
&
clipId
,
const
QString
&
name
,
int
width
,
int
height
)
{
{
QPixmap
pix
=
KIcon
(
name
).
pixmap
(
QSize
(
width
,
height
));
// For clips that have a generic icon (like audio clips...)
setThumbnail
(
clipId
,
pix
);
}
void
ProjectList
::
setThumbnail
(
const
QString
&
clipId
,
const
QPixmap
&
pix
)
{
ProjectItem
*
item
=
getItemById
(
clipId
);
ProjectItem
*
item
=
getItemById
(
clipId
);
QPixmap
pix
=
KIcon
(
name
).
pixmap
(
QSize
(
width
,
height
));
if
(
item
&&
!
pix
.
isNull
())
{
if
(
item
&&
!
pix
.
isNull
())
{
monitorItemEditing
(
false
);
monitorItemEditing
(
false
);
item
->
setData
(
0
,
Qt
::
DecorationRole
,
pix
);
item
->
setData
(
0
,
Qt
::
DecorationRole
,
pix
);
monitorItemEditing
(
true
);
monitorItemEditing
(
true
);
//update();
QString
clipId
=
item
->
getClipHash
();
if
(
!
clipId
.
isEmpty
())
m_doc
->
cachePixmap
(
clipId
,
pix
);
}
}
}
}
...
@@ -2215,10 +2217,10 @@ void ProjectList::addClipCut(const QString &id, int in, int out, const QString d
...
@@ -2215,10 +2217,10 @@ void ProjectList::addClipCut(const QString &id, int in, int out, const QString d
m_listView
->
scrollToItem
(
sub
);
m_listView
->
scrollToItem
(
sub
);
m_listView
->
editItem
(
sub
,
1
);
m_listView
->
editItem
(
sub
,
1
);
}
}
Q
Pixmap
p
=
clip
->
referencedClip
()
->
extractImage
(
in
,
(
int
)(
sub
->
sizeHint
(
0
).
height
()
*
m_render
->
dar
()),
sub
->
sizeHint
(
0
).
height
()
-
2
);
Q
Image
img
=
clip
->
referencedClip
()
->
extractImage
(
in
,
(
int
)(
sub
->
sizeHint
(
0
).
height
()
*
m_render
->
dar
()),
sub
->
sizeHint
(
0
).
height
()
-
2
);
sub
->
setData
(
0
,
Qt
::
DecorationRole
,
p
);
sub
->
setData
(
0
,
Qt
::
DecorationRole
,
QPixmap
::
fromImage
(
img
)
);
QString
clipId
=
clip
->
getClipHash
();
QString
hash
=
clip
->
getClipHash
();
if
(
!
clipId
.
isEmpty
())
m_doc
->
cache
Pixmap
(
clipId
+
'#'
+
QString
::
number
(
in
),
p
);
if
(
!
hash
.
isEmpty
())
m_doc
->
cache
Image
(
hash
+
'#'
+
QString
::
number
(
in
),
img
);
monitorItemEditing
(
true
);
monitorItemEditing
(
true
);
}
}
emit
projectModified
();
emit
projectModified
();
...
...
src/projectlist.h
View file @
811f9353
...
@@ -342,8 +342,6 @@ private:
...
@@ -342,8 +342,6 @@ private:
/** @brief Process ffmpeg output to find out process progress. */
/** @brief Process ffmpeg output to find out process progress. */
void
processLogInfo
(
QList
<
ProjectItem
*>
items
,
int
*
duration
,
const
QString
&
log
);
void
processLogInfo
(
QList
<
ProjectItem
*>
items
,
int
*
duration
,
const
QString
&
log
);
void
monitorItemEditing
(
bool
enable
);
void
monitorItemEditing
(
bool
enable
);
/** @brief Set thumbnail for a project's clip. */
void
setThumbnail
(
const
QString
&
clipId
,
const
QPixmap
&
pix
);
/** @brief Get cached thumbnail for a project's clip or create it if no cache. */
/** @brief Get cached thumbnail for a project's clip or create it if no cache. */
void
getCachedThumbnail
(
ProjectItem
*
item
);
void
getCachedThumbnail
(
ProjectItem
*
item
);
void
getCachedThumbnail
(
SubProjectItem
*
item
);
void
getCachedThumbnail
(
SubProjectItem
*
item
);
...
...
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