Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Plasma
Plasma Add-ons
Commits
8eedb44f
Commit
8eedb44f
authored
Jan 21, 2022
by
Fushan Wen
Committed by
Nate Graham
Mar 29, 2022
Browse files
dataengines/potd: Use PotdProviderData in the initializer of SaveImageThread
We need to save more information in the thread.
parent
4427e0e9
Changes
3
Hide whitespace changes
Inline
Side-by-side
wallpapers/potd/plugins/cachedprovider.cpp
View file @
8eedb44f
...
...
@@ -29,20 +29,18 @@ void LoadImageThread::run()
Q_EMIT
done
(
image
);
}
SaveImageThread
::
SaveImageThread
(
const
QString
&
identifier
,
const
QImage
&
image
)
:
m_i
mage
(
image
)
,
m_
identifier
(
identifier
)
SaveImageThread
::
SaveImageThread
(
const
QString
&
identifier
,
const
PotdProviderData
&
data
)
:
m_i
dentifier
(
identifier
)
,
m_
data
(
data
)
{
}
void
SaveImageThread
::
run
()
{
const
QString
path
=
CachedProvider
::
identifierToPath
(
m_identifier
);
m_image
.
save
(
path
,
"JPEG"
);
PotdProviderData
data
;
data
.
wallpaperImage
=
m_image
;
data
.
wallpaperLocalUrl
=
path
;
Q_EMIT
done
(
m_identifier
,
data
);
m_data
.
wallpaperLocalUrl
=
CachedProvider
::
identifierToPath
(
m_identifier
);
m_data
.
wallpaperImage
.
save
(
m_data
.
wallpaperLocalUrl
,
"JPEG"
);
Q_EMIT
done
(
m_identifier
,
m_data
);
}
QString
CachedProvider
::
identifierToPath
(
const
QString
&
identifier
)
...
...
wallpapers/potd/plugins/cachedprovider.h
View file @
8eedb44f
...
...
@@ -75,15 +75,15 @@ class SaveImageThread : public QObject, public QRunnable
Q_OBJECT
public:
SaveImageThread
(
const
QString
&
identifier
,
const
QImage
&
image
);
SaveImageThread
(
const
QString
&
identifier
,
const
PotdProviderData
&
data
);
void
run
()
override
;
Q_SIGNALS:
void
done
(
const
QString
&
source
,
const
PotdProviderData
&
data
);
private:
QImage
m_image
;
QString
m_identifier
;
PotdProviderData
m_data
;
};
#endif
wallpapers/potd/plugins/potdprovidermodel.cpp
View file @
8eedb44f
...
...
@@ -320,10 +320,14 @@ void PotdProviderModel::slotFinished(PotdProvider *provider)
}
setImage
(
provider
->
image
());
setInfoUrl
(
provider
->
infoUrl
());
setRemoteUrl
(
provider
->
remoteUrl
());
setTitle
(
provider
->
title
());
setAuthor
(
provider
->
author
());
// Store in cache if it's not the response of a CachedProvider
if
(
qobject_cast
<
CachedProvider
*>
(
provider
)
==
nullptr
&&
!
m_data
.
wallpaperImage
.
isNull
())
{
SaveImageThread
*
thread
=
new
SaveImageThread
(
m_identifier
,
m_data
.
wallpaperImage
);
SaveImageThread
*
thread
=
new
SaveImageThread
(
m_identifier
,
m_data
);
connect
(
thread
,
&
SaveImageThread
::
done
,
this
,
&
PotdProviderModel
::
slotCachingFinished
);
QThreadPool
::
globalInstance
()
->
start
(
thread
);
}
else
{
...
...
@@ -344,6 +348,10 @@ void PotdProviderModel::slotCachingFinished(const QString &source, const PotdPro
Q_UNUSED
(
source
)
setImage
(
data
.
wallpaperImage
);
setLocalUrl
(
data
.
wallpaperLocalUrl
);
setInfoUrl
(
data
.
wallpaperInfoUrl
);
setRemoteUrl
(
data
.
wallpaperRemoteUrl
);
setTitle
(
data
.
wallpaperTitle
);
setAuthor
(
data
.
wallpaperAuthor
);
}
void
PotdProviderModel
::
slotError
(
PotdProvider
*
provider
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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