fix: 修复部分命令无法执行的问题

调用QProcess::startDetached异步执行的时候,需要将命令和参数分隔,保证该命令正确执行

Log: 修复部分命令无法执行的问题
Influence: 任务栏关机命令观察是否正常执行
Task: https://pms.uniontech.com/task-view-213403.html
Change-Id: I63d3a9629dce9becdfc4dcbe476b438070def5bf
This commit is contained in:
donghualin 2022-11-10 01:11:28 +00:00
parent 7c2f2b38ea
commit ad56764f49
3 changed files with 17 additions and 9 deletions

View File

@ -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<QLabel *>(obj);

View File

@ -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)

View File

@ -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;
}