Commit 75b5dc7d authored by Nicolas Fella's avatar Nicolas Fella
Browse files

Use appropriate jobs to lauch helpers

This is needed for activation on Wayland to work
parent bc35c133
Pipeline #184303 passed with stage
in 1 minute and 16 seconds
......@@ -55,7 +55,7 @@ PlasmaExtras.ExpandableListItem {
text: i18n("Send File")
onTriggered: {
PlasmaBt.LaunchApp.runCommand("bluedevil-sendfile", ["-u", Ubi]);
PlasmaBt.LaunchApp.launchSendFile(Ubi);
}
}
]
......
......@@ -66,7 +66,7 @@ Item {
}
function action_addNewDevice() {
PlasmaBt.LaunchApp.runCommand("bluedevil-wizard");
PlasmaBt.LaunchApp.launchWizard();
}
Component.onCompleted: {
......
......@@ -8,6 +8,7 @@ target_link_libraries(bluetoothplugin
Qt::Core
Qt::Qml
KF5::Notifications
KF5::KIOGui
KF5::BluezQt)
install(TARGETS bluetoothplugin DESTINATION ${KDE_INSTALL_QMLDIR}/org/kde/plasma/private/bluetooth)
......
......@@ -6,14 +6,28 @@
#include "launchapp.h"
#include <QProcess>
#include <KIO/ApplicationLauncherJob>
#include <KIO/CommandLauncherJob>
#include <KNotificationJobUiDelegate>
LaunchApp::LaunchApp(QObject *parent)
: QObject(parent)
{
}
bool LaunchApp::runCommand(const QString &exe, const QStringList &args)
void LaunchApp::launchWizard()
{
return QProcess::startDetached(exe, args);
auto *job = new KIO::ApplicationLauncherJob(KService::serviceByDesktopName(QStringLiteral("org.kde.bluedevilwizard")));
auto *delegate = new KNotificationJobUiDelegate(KNotificationJobUiDelegate::AutoErrorHandlingEnabled);
job->setUiDelegate(delegate);
job->start();
}
void LaunchApp::launchSendFile(const QString &ubi)
{
auto *job = new KIO::CommandLauncherJob(QStringLiteral("bluedevil-sendfile"), {QStringLiteral("-u"), ubi});
job->setDesktopName(QStringLiteral("org.kde.bluedevilsendfile"));
auto *delegate = new KNotificationJobUiDelegate(KNotificationJobUiDelegate::AutoErrorHandlingEnabled);
job->setUiDelegate(delegate);
job->start();
}
......@@ -18,7 +18,8 @@ public:
explicit LaunchApp(QObject *parent = nullptr);
public Q_SLOTS:
bool runCommand(const QString &exe, const QStringList &args = QStringList());
void launchWizard();
void launchSendFile(const QString &ubi);
};
#endif // LAUNCHAPP_H
......@@ -12,6 +12,7 @@ target_link_libraries(kcm_bluetooth
KF5::QuickAddons
KF5::I18n
KF5::BluezQt
KF5::KIOGui
)
install(FILES kcm_bluetooth.desktop DESTINATION ${KDE_INSTALL_APPDIR})
......
......@@ -13,6 +13,8 @@
#include <KAboutData>
#include <KConfigGroup>
#include <KIO/ApplicationLauncherJob>
#include <KIO/CommandLauncherJob>
#include <KLocalizedString>
#include <KPluginFactory>
#include <KSharedConfig>
......@@ -34,12 +36,25 @@ Bluetooth::Bluetooth(QObject *parent, const KPluginMetaData &data, const QVarian
void Bluetooth::runWizard()
{
QProcess::startDetached(QStringLiteral("bluedevil-wizard"), QStringList());
auto *job = new KIO::ApplicationLauncherJob(KService::serviceByDesktopName(QStringLiteral("org.kde.bluedevilwizard")));
connect(job, &KJob::finished, this, [this](KJob *job) {
if (job->error()) {
Q_EMIT errorOccured(job->errorString());
}
});
job->start();
}
void Bluetooth::runSendFile(const QString &ubi)
{
QProcess::startDetached(QStringLiteral("bluedevil-sendfile"), {QStringLiteral("-u"), ubi});
auto *job = new KIO::CommandLauncherJob(QStringLiteral("bluedevil-sendfile"), {QStringLiteral("-u"), ubi});
job->setDesktopName(QStringLiteral("org.kde.bluedevilsendfile"));
connect(job, &KJob::finished, this, [this](KJob *job) {
if (job->error()) {
Q_EMIT errorOccured(job->errorString());
}
});
job->start();
}
void Bluetooth::checkNetworkConnection(const QStringList &uuids, const QString &address)
......
......@@ -31,6 +31,7 @@ public:
Q_SIGNALS:
void networkAvailable(const QString &service, bool available);
QString bluetoothStatusAtLoginChanged(QString newStatus);
void errorOccured(const QString &errorMessage);
private:
void checkNetworkInternal(const QString &service, const QString &address);
......
......@@ -30,6 +30,15 @@ ScrollViewKCM {
})
}
Connections {
target: kcm
function onErrorOccured(errorText) {
errorMessage.text = errorText
errorMessage.visible = true
}
}
Rectangle {
id: deleteApprovalDiag
anchors.fill: parent
......
Supports Markdown
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