fix(menu): 修复从开始菜单右键添加到桌面的快捷方式无可执行权限问题

This commit is contained in:
hewenfei 2024-04-24 15:27:34 +08:00
parent 0b4b6a129c
commit 523f16bc10
1 changed files with 12 additions and 4 deletions

View File

@ -146,10 +146,18 @@ void AppContentMenu::addToDesktopAction(QObject *parent, const QString &appId, Q
} }
QObject::connect(list.last(), &QAction::triggered, parent, [appId, path] { QObject::connect(list.last(), &QAction::triggered, parent, [appId, path] {
QFile file(appId); if (QFile::copy(appId, path)) {
bool ret = file.copy(path); // 设置权限755
if (ret) { // QFile::Permissions permissions(0x0755); // 这也是可以的
QProcess::startDetached("chmod a+x ", {path}); QFile::Permissions permissions = {
QFile::ReadUser | QFile::WriteUser | QFile::ExeUser |
QFile::ReadGroup | QFile::ExeGroup |
QFile::ReadOther | QFile::ExeOther
};
if (QFile::setPermissions(path, permissions)) {
qWarning() << "set file permissions failed, file:" << path;
}
} }
}); });
} }