summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleix Pol <[email protected]>2017-02-02 01:47:32 +0100
committerAleix Pol <[email protected]>2017-02-02 01:47:32 +0100
commit4648f06cd2e2dc870facaea925064b825a259d57 (patch)
tree9a652d324da6e358deb806fe52428f7a864a0062
parent34552b6f713a8662058ca023f2d970cc2b44f964 (diff)
Move executable processing to AbstractResource
For reusability
-rw-r--r--libdiscover/backends/PackageKitBackend/AppPackageKitResource.cpp12
-rw-r--r--libdiscover/backends/PackageKitBackend/AppPackageKitResource.h2
-rw-r--r--libdiscover/resources/AbstractResource.cpp13
3 files changed, 11 insertions, 16 deletions
diff --git a/libdiscover/backends/PackageKitBackend/AppPackageKitResource.cpp b/libdiscover/backends/PackageKitBackend/AppPackageKitResource.cpp
index 32a30ed..5bb8571 100644
--- a/libdiscover/backends/PackageKitBackend/AppPackageKitResource.cpp
+++ b/libdiscover/backends/PackageKitBackend/AppPackageKitResource.cpp
@@ -131,13 +131,6 @@ QStringList AppPackageKitResource::executables() const
return m_appdata.provided(AppStream::Provided::KindBinary).items();
}
-void AppPackageKitResource::invokeApplication() const
-{
- QStringList exes = executables();
- if(!exes.isEmpty())
- QProcess::startDetached(exes.first());
-}
-
static QUrl imageOfKind(const QList<AppStream::Image>& images, AppStream::Image::Kind kind)
{
QUrl ret;
@@ -188,11 +181,6 @@ void AppPackageKitResource::fetchScreenshots()
Q_EMIT screenshotsFetched(thumbnails, screenshots);
}
-bool AppPackageKitResource::canExecute() const
-{
- return !executables().isEmpty();
-}
-
QStringList AppPackageKitResource::allPackageNames() const
{
return m_appdata.packageNames();
diff --git a/libdiscover/backends/PackageKitBackend/AppPackageKitResource.h b/libdiscover/backends/PackageKitBackend/AppPackageKitResource.h
index 2b6e138..e5415c7 100644
--- a/libdiscover/backends/PackageKitBackend/AppPackageKitResource.h
+++ b/libdiscover/backends/PackageKitBackend/AppPackageKitResource.h
@@ -39,9 +39,7 @@ class AppPackageKitResource : public PackageKitResource
QStringList categories() override;
QString longDescription() override;
QUrl homepage() override;
- bool canExecute() const override;
QStringList executables() const override;
- void invokeApplication() const override;
QString comment() override;
QString license() override;
QUrl screenshotUrl() override;
diff --git a/libdiscover/resources/AbstractResource.cpp b/libdiscover/resources/AbstractResource.cpp
index 78fdcad..6328424 100644
--- a/libdiscover/resources/AbstractResource.cpp
+++ b/libdiscover/resources/AbstractResource.cpp
@@ -24,7 +24,9 @@
#include <Category/CategoryModel.h>
#include <KLocalizedString>
#include <KFormat>
+#include <KShell>
#include <QList>
+#include <QProcess>
#include <QDebug>
AbstractResource::AbstractResource(AbstractResourcesBackend* parent)
@@ -35,11 +37,18 @@ AbstractResource::AbstractResource(AbstractResourcesBackend* parent)
bool AbstractResource::canExecute() const
{
- return false;
+ return !executables().isEmpty();
}
void AbstractResource::invokeApplication() const
-{}
+{
+ QStringList exes = executables();
+ if(!exes.isEmpty()) {
+ const QString exe = exes.at(0);
+ auto args = KShell::splitArgs(exe);
+ QProcess::startDetached(args.takeFirst(), args);
+ }
+}
bool AbstractResource::isTechnical() const
{