fix(ukcc-plugin): 替换模型下载包的二进制,增加通过desktop文件打开的逻辑.

This commit is contained in:
JunjieBai 2024-06-17 14:13:05 +08:00 committed by iaom
parent 25baa9140e
commit 254a4bc9d8
1 changed files with 24 additions and 5 deletions

View File

@ -981,9 +981,28 @@ void Search::initAiSettings() {
} }
void Search::onGetAiModelBtnClicked() { void Search::onGetAiModelBtnClicked() {
// if (!isModelReady) { bool res(false);
QProcess::startDetached("kylin-model-downloader", {}); auto appLaunchInterface = new QDBusInterface(QStringLiteral("com.kylin.ProcessManager"),
// } else { QStringLiteral("/com/kylin/ProcessManager/AppLauncher"),
// qWarning() << "Model is ready."; QStringLiteral("com.kylin.ProcessManager.AppLauncher"),
// } QDBusConnection::sessionBus());
if(!appLaunchInterface->isValid()) {
qWarning() << qPrintable(QDBusConnection::sessionBus().lastError().message());
res = false;
} else {
appLaunchInterface->setTimeout(10000);
QDBusReply<void> 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", {});
}
} }