Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Network
KIO Extras
Commits
15fa6e24
Commit
15fa6e24
authored
Jun 05, 2021
by
Méven Car
Browse files
Thumbnails: Refactor, Add ThumbnailProtocol::ensureDirsCreated
parent
01b8eb0f
Pipeline
#64691
passed with stage
in 3 minutes and 8 seconds
Changes
2
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
thumbnail/thumbnail.cpp
View file @
15fa6e24
...
...
@@ -634,6 +634,18 @@ ThumbCreator* ThumbnailProtocol::getThumbCreator(const QString& plugin)
return
creator
;
}
void
ThumbnailProtocol
::
ensureDirsCreated
()
{
if
(
m_thumbBasePath
.
isEmpty
())
{
m_thumbBasePath
=
QStandardPaths
::
writableLocation
(
QStandardPaths
::
GenericCacheLocation
)
+
QLatin1String
(
"/thumbnails/"
);
QDir
basePath
(
m_thumbBasePath
);
basePath
.
mkpath
(
"normal/"
);
QFile
::
setPermissions
(
basePath
.
absoluteFilePath
(
"normal"
),
QFile
::
ReadOwner
|
QFile
::
WriteOwner
|
QFile
::
ExeOwner
);
basePath
.
mkpath
(
"large/"
);
QFile
::
setPermissions
(
basePath
.
absoluteFilePath
(
"large"
),
QFile
::
ReadOwner
|
QFile
::
WriteOwner
|
QFile
::
ExeOwner
);
}
}
bool
ThumbnailProtocol
::
createSubThumbnail
(
QImage
&
thumbnail
,
const
QString
&
filePath
,
int
segmentWidth
,
int
segmentHeight
)
{
...
...
@@ -655,14 +667,7 @@ bool ThumbnailProtocol::createSubThumbnail(QImage &thumbnail, const QString &fil
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/"
);
QDir
basePath
(
m_thumbBasePath
);
basePath
.
mkpath
(
"normal/"
);
QFile
::
setPermissions
(
basePath
.
absoluteFilePath
(
"normal"
),
QFile
::
ReadOwner
|
QFile
::
WriteOwner
|
QFile
::
ExeOwner
);
basePath
.
mkpath
(
"large/"
);
QFile
::
setPermissions
(
basePath
.
absoluteFilePath
(
"large"
),
QFile
::
ReadOwner
|
QFile
::
WriteOwner
|
QFile
::
ExeOwner
);
}
ensureDirsCreated
();
QDir
thumbPath
(
m_thumbBasePath
);
if
((
segmentWidth
<=
128
)
&&
(
segmentHeight
<=
128
))
{
...
...
thumbnail/thumbnail.h
View file @
15fa6e24
...
...
@@ -57,6 +57,8 @@ private:
void
drawSubThumbnail
(
QPainter
&
p
,
QImage
subThumbnail
,
int
width
,
int
height
,
int
xPos
,
int
yPos
,
int
frameWidth
);
private:
void
ensureDirsCreated
();
QString
m_mimeType
;
int
m_width
;
int
m_height
;
...
...
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