From 254a4bc9d8259c0d5871f3789ad4383651b68b3b Mon Sep 17 00:00:00 2001 From: JunjieBai Date: Mon, 17 Jun 2024 14:13:05 +0800 Subject: [PATCH] =?UTF-8?q?fix(ukcc-plugin):=20=E6=9B=BF=E6=8D=A2=E6=A8=A1?= =?UTF-8?q?=E5=9E=8B=E4=B8=8B=E8=BD=BD=E5=8C=85=E7=9A=84=E4=BA=8C=E8=BF=9B?= =?UTF-8?q?=E5=88=B6=EF=BC=8C=E5=A2=9E=E5=8A=A0=E9=80=9A=E8=BF=87desktop?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E6=89=93=E5=BC=80=E7=9A=84=E9=80=BB=E8=BE=91?= =?UTF-8?q?.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- search-ukcc-plugin/search.cpp | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/search-ukcc-plugin/search.cpp b/search-ukcc-plugin/search.cpp index e197fc5..601ad68 100644 --- a/search-ukcc-plugin/search.cpp +++ b/search-ukcc-plugin/search.cpp @@ -981,9 +981,28 @@ void Search::initAiSettings() { } void Search::onGetAiModelBtnClicked() { -// if (!isModelReady) { - QProcess::startDetached("kylin-model-downloader", {}); -// } else { -// qWarning() << "Model is ready."; -// } + bool res(false); + auto appLaunchInterface = new QDBusInterface(QStringLiteral("com.kylin.ProcessManager"), + QStringLiteral("/com/kylin/ProcessManager/AppLauncher"), + QStringLiteral("com.kylin.ProcessManager.AppLauncher"), + QDBusConnection::sessionBus()); + if(!appLaunchInterface->isValid()) { + qWarning() << qPrintable(QDBusConnection::sessionBus().lastError().message()); + res = false; + } else { + appLaunchInterface->setTimeout(10000); + QDBusReply reply = appLaunchInterface->call("LaunchApp", "/usr/share/applications/kylin-ai-model-manager.desktop"); + if(reply.isValid()) { + res = true; + } else { + qWarning() << "ProcessManager dbus called failed!" << reply.error(); + res = false; + } + } + delete appLaunchInterface; + appLaunchInterface = nullptr; + + if (!res) { + QProcess::startDetached("kylin-ai-model-manager", {}); + } }