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
Network
KIO Extras
Commits
78a8c7d3
Commit
78a8c7d3
authored
Aug 28, 2020
by
Stefan Brüns
Committed by
David Faure
Aug 29, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Only create file URI when required
The URI is only required when a thumbnail is created or looked up.
parent
900db615
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
6 deletions
+5
-6
thumbnail/thumbnail.cpp
thumbnail/thumbnail.cpp
+5
-6
No files found.
thumbnail/thumbnail.cpp
View file @
78a8c7d3
...
...
@@ -681,11 +681,9 @@ const QImage ThumbnailProtocol::getIcon()
bool
ThumbnailProtocol
::
createSubThumbnail
(
QImage
&
thumbnail
,
const
QString
&
filePath
,
int
segmentWidth
,
int
segmentHeight
)
{
const
QUrl
fileUrl
=
QUrl
::
fromLocalFile
(
filePath
);
auto
getSubCreator
=
[
&
fileUrl
,
this
]()
->
ThumbCreator
*
{
auto
getSubCreator
=
[
&
filePath
,
this
]()
->
ThumbCreator
*
{
const
QMimeDatabase
db
;
const
QString
subPlugin
=
pluginForMimeType
(
db
.
mimeTypeFor
Url
(
file
Url
).
name
());
const
QString
subPlugin
=
pluginForMimeType
(
db
.
mimeTypeFor
File
(
file
Path
).
name
());
if
(
subPlugin
.
isEmpty
()
||
!
m_enabledPlugins
.
contains
(
subPlugin
))
{
return
nullptr
;
}
...
...
@@ -697,8 +695,9 @@ bool ThumbnailProtocol::createSubThumbnail(QImage& thumbnail, const QString& fil
// 128 x 128 or 256 x 256 pixels
int
cacheSize
=
0
;
QCryptographicHash
md5
(
QCryptographicHash
::
Md5
);
md5
.
addData
(
fileUrl
.
toEncoded
());
const
QString
thumbName
=
QFile
::
encodeName
(
md5
.
result
().
toHex
()).
append
(
".png"
);
const
QByteArray
fileUrl
=
QUrl
::
fromLocalFile
(
filePath
).
toEncoded
();
md5
.
addData
(
fileUrl
);
const
QString
thumbName
=
QString
::
fromLatin1
(
md5
.
result
().
toHex
()).
append
(
".png"
);
if
(
m_thumbBasePath
.
isEmpty
())
{
m_thumbBasePath
=
QStandardPaths
::
writableLocation
(
QStandardPaths
::
GenericCacheLocation
)
+
QLatin1String
(
"/thumbnails/"
);
...
...
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