Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Discover
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
5
Merge Requests
5
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Plasma
Discover
Commits
8ee02d0d
Commit
8ee02d0d
authored
Jan 16, 2018
by
Aleix Pol Gonzalez
🐧
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove sync call to snap to get icons
parent
c510c7c7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
13 deletions
+31
-13
libdiscover/backends/SnapBackend/SnapResource.cpp
libdiscover/backends/SnapBackend/SnapResource.cpp
+29
-13
libdiscover/backends/SnapBackend/SnapResource.h
libdiscover/backends/SnapBackend/SnapResource.h
+2
-0
No files found.
libdiscover/backends/SnapBackend/SnapResource.cpp
View file @
8ee02d0d
...
...
@@ -30,6 +30,7 @@ SnapResource::SnapResource(QSharedPointer<QSnapdSnap> snap, AbstractResource::St
,
m_state
(
state
)
,
m_snap
(
snap
)
{
setObjectName
(
snap
->
name
());
}
QString
SnapResource
::
availableVersion
()
const
...
...
@@ -60,20 +61,31 @@ QUrl SnapResource::homepage()
QVariant
SnapResource
::
icon
()
const
{
const
auto
iconPath
=
m_snap
->
icon
();
if
(
iconPath
.
isEmpty
())
return
QStringLiteral
(
"package-x-generic"
);
if
(
!
iconPath
.
startsWith
(
QLatin1Char
(
'/'
)))
return
QUrl
(
iconPath
);
auto
backend
=
qobject_cast
<
SnapBackend
*>
(
parent
());
auto
req
=
backend
->
client
()
->
getIcon
(
packageName
());
req
->
runSync
();
if
(
m_icon
.
isNull
())
{
m_icon
=
[
this
]()
->
QVariant
{
const
auto
iconPath
=
m_snap
->
icon
();
if
(
iconPath
.
isEmpty
())
return
QStringLiteral
(
"package-x-generic"
);
if
(
!
iconPath
.
startsWith
(
QLatin1Char
(
'/'
)))
return
QUrl
(
iconPath
);
auto
backend
=
qobject_cast
<
SnapBackend
*>
(
parent
());
auto
req
=
backend
->
client
()
->
getIcon
(
packageName
());
connect
(
req
,
&
QSnapdGetIconRequest
::
complete
,
this
,
&
SnapResource
::
gotIcon
);
req
->
runAsync
();
return
{};
}();
}
return
m_icon
;
}
void
SnapResource
::
gotIcon
()
{
auto
req
=
qobject_cast
<
QSnapdGetIconRequest
*>
(
sender
());
if
(
req
->
error
())
{
qWarning
()
<<
"icon error"
<<
req
->
errorString
()
<<
iconPath
;
return
{}
;
qWarning
()
<<
"icon error"
<<
req
->
errorString
();
return
;
}
auto
icon
=
req
->
icon
();
...
...
@@ -82,7 +94,11 @@ QVariant SnapResource::icon() const
buffer
.
setData
(
icon
->
data
());
QImageReader
reader
(
&
buffer
);
return
QVariant
::
fromValue
<
QImage
>
(
reader
.
read
());
auto
theIcon
=
QVariant
::
fromValue
<
QImage
>
(
reader
.
read
());
if
(
theIcon
!=
m_icon
)
{
m_icon
=
theIcon
;
iconChanged
();
}
}
QString
SnapResource
::
installedVersion
()
const
...
...
libdiscover/backends/SnapBackend/SnapResource.h
View file @
8ee02d0d
...
...
@@ -61,9 +61,11 @@ public:
void
setState
(
AbstractResource
::
State
state
);
public:
void
gotIcon
();
AbstractResource
::
State
m_state
;
QSharedPointer
<
QSnapdSnap
>
m_snap
;
mutable
QVariant
m_icon
;
};
#endif // SNAPRESOURCE_H
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