From ad56764f49ae3ba0aef84eb854e977ab794dec29 Mon Sep 17 00:00:00 2001 From: donghualin Date: Thu, 10 Nov 2022 01:11:28 +0000 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E9=83=A8=E5=88=86?= =?UTF-8?q?=E5=91=BD=E4=BB=A4=E6=97=A0=E6=B3=95=E6=89=A7=E8=A1=8C=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 调用QProcess::startDetached异步执行的时候,需要将命令和参数分隔,保证该命令正确执行 Log: 修复部分命令无法执行的问题 Influence: 任务栏关机命令观察是否正常执行 Task: https://pms.uniontech.com/task-view-213403.html Change-Id: I63d3a9629dce9becdfc4dcbe476b438070def5bf --- frame/item/components/multiquickitem.cpp | 9 ++++++--- frame/item/components/singlequickitem.cpp | 9 ++++++--- frame/window/systempluginwindow.cpp | 8 +++++--- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/frame/item/components/multiquickitem.cpp b/frame/item/components/multiquickitem.cpp index cbc2950d5..0f79438a2 100644 --- a/frame/item/components/multiquickitem.cpp +++ b/frame/item/components/multiquickitem.cpp @@ -63,9 +63,12 @@ bool MultiQuickItem::eventFilter(QObject *obj, QEvent *event) Q_EMIT requestShowChildWidget(widget); } else if (obj == this) { - const QString &command = pluginItem()->itemCommand(itemKey()); - if (!command.isEmpty()) - QProcess::startDetached(command, QStringList()); + QStringList commandArgumend = pluginItem()->itemCommand(itemKey()).split(" "); + if (commandArgumend.size() > 0) { + QString command = commandArgumend.first(); + commandArgumend.removeFirst(); + QProcess::startDetached(command, commandArgumend); + } } } else if (event->type() == QEvent::Resize) { QLabel *labelWidget = qobject_cast(obj); diff --git a/frame/item/components/singlequickitem.cpp b/frame/item/components/singlequickitem.cpp index 628f18386..83c8a4b82 100644 --- a/frame/item/components/singlequickitem.cpp +++ b/frame/item/components/singlequickitem.cpp @@ -48,9 +48,12 @@ QuickSettingItem::QuickSettingType SingleQuickItem::type() const void SingleQuickItem::mouseReleaseEvent(QMouseEvent *event) { Q_UNUSED(event); - const QString &command = pluginItem()->itemCommand(itemKey()); - if (!command.isEmpty()) - QProcess::startDetached(command, QStringList()); + QStringList commandArgument = pluginItem()->itemCommand(itemKey()).split(" "); + if (commandArgument.size() > 0) { + QString command = commandArgument.first(); + commandArgument.removeFirst(); + QProcess::startDetached(command, commandArgument); + } QWidget *itemWidget = pluginItem()->itemWidget(QUICK_ITEM_KEY); if (itemWidget) diff --git a/frame/window/systempluginwindow.cpp b/frame/window/systempluginwindow.cpp index 551e0e2bd..e01164ae2 100644 --- a/frame/window/systempluginwindow.cpp +++ b/frame/window/systempluginwindow.cpp @@ -376,9 +376,11 @@ void StretchPluginsItem::mouseReleaseEvent(QMouseEvent *e) void StretchPluginsItem::mouseClick() { - const QString command = m_pluginInter->itemCommand(m_itemKey); - if (!command.isEmpty()) { - QProcess::startDetached(command, QStringList()); + QStringList commandArgument = m_pluginInter->itemCommand(m_itemKey).split(" "); + if (commandArgument.size() > 0) { + QString command = commandArgument.first(); + commandArgument.removeFirst(); + QProcess::startDetached(command, commandArgument); return; }