Commit b96ce551 authored by Alexander Lohnau's avatar Alexander Lohnau
Browse files

Use new adoption API from KNS

The `executables()` method is not needed, it was just used to get the constructed
adoption command and to check if the command is empty.
In that very unlikely case that we want to adopt an
entry, even though there is no adoption command is handled in KNS.

CCBUG: 417983
parent deb599b8
...@@ -5,7 +5,7 @@ set(PROJECT_VERSION_MAJOR 5) ...@@ -5,7 +5,7 @@ set(PROJECT_VERSION_MAJOR 5)
cmake_minimum_required(VERSION 2.8.12) cmake_minimum_required(VERSION 2.8.12)
set(QT_MIN_VERSION "5.15.0") set(QT_MIN_VERSION "5.15.0")
set(KF5_MIN_VERSION "5.74") set(KF5_MIN_VERSION "5.77")
find_package(ECM ${KF5_MIN_VERSION} REQUIRED NO_MODULE) find_package(ECM ${KF5_MIN_VERSION} REQUIRED NO_MODULE)
......
...@@ -196,29 +196,19 @@ QStringList KNSResource::extends() const ...@@ -196,29 +196,19 @@ QStringList KNSResource::extends() const
return knsBackend()->extends(); return knsBackend()->extends();
} }
QStringList KNSResource::executables() const QUrl KNSResource::url() const
{ {
if (knsBackend()->engine()->hasAdoptionCommand()) return QUrl(QStringLiteral("kns://")+knsBackend()->name() + QLatin1Char('/') + QUrl(m_entry.providerId()).host() + QLatin1Char('/') + m_entry.uniqueId());
return {knsBackend()->engine()->adoptionCommand(m_entry)};
else
return {};
} }
QUrl KNSResource::url() const bool KNSResource::canExecute() const
{ {
return QUrl(QStringLiteral("kns://")+knsBackend()->name() + QLatin1Char('/') + QUrl(m_entry.providerId()).host() + QLatin1Char('/') + m_entry.uniqueId()); return knsBackend()->engine()->hasAdoptionCommand();
} }
void KNSResource::invokeApplication() const void KNSResource::invokeApplication() const
{ {
QStringList exes = executables(); knsBackend()->engine()->adoptEntry(m_entry);
if(!exes.isEmpty()) {
const QString exe = exes.constFirst();
auto args = KShell::splitArgs(exe);
QProcess::startDetached(args.takeFirst(), args);
} else {
qWarning() << "cannot execute" << packageName();
}
} }
QString KNSResource::executeLabel() const QString KNSResource::executeLabel() const
......
...@@ -48,8 +48,7 @@ public: ...@@ -48,8 +48,7 @@ public:
void setEntry(const KNSCore::EntryInternal& entry); void setEntry(const KNSCore::EntryInternal& entry);
KNSCore::EntryInternal entry() const; KNSCore::EntryInternal entry() const;
bool canExecute() const override { return !executables().isEmpty(); } bool canExecute() const override;
QStringList executables() const;
void invokeApplication() const override; void invokeApplication() const override;
QUrl url() const override; QUrl url() const override;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment