Commit b96ce551 authored by Alexander Lohnau's avatar Alexander Lohnau 💬

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)
cmake_minimum_required(VERSION 2.8.12)
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)
......
......@@ -196,29 +196,19 @@ QStringList KNSResource::extends() const
return knsBackend()->extends();
}
QStringList KNSResource::executables() const
QUrl KNSResource::url() const
{
if (knsBackend()->engine()->hasAdoptionCommand())
return {knsBackend()->engine()->adoptionCommand(m_entry)};
else
return {};
return QUrl(QStringLiteral("kns://")+knsBackend()->name() + QLatin1Char('/') + QUrl(m_entry.providerId()).host() + QLatin1Char('/') + m_entry.uniqueId());
}
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
{
QStringList exes = executables();
if(!exes.isEmpty()) {
const QString exe = exes.constFirst();
auto args = KShell::splitArgs(exe);
QProcess::startDetached(args.takeFirst(), args);
} else {
qWarning() << "cannot execute" << packageName();
}
knsBackend()->engine()->adoptEntry(m_entry);
}
QString KNSResource::executeLabel() const
......
......@@ -48,8 +48,7 @@ public:
void setEntry(const KNSCore::EntryInternal& entry);
KNSCore::EntryInternal entry() const;
bool canExecute() const override { return !executables().isEmpty(); }
QStringList executables() const;
bool canExecute() const override;
void invokeApplication() 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