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

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

View File

@ -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<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", {});
}
}