| 276 | } |
| 277 | |
| 278 | QMap<QString, QVariant> ScriptAPI::launchFile(const QString& fileName) const |
| 279 | { |
| 280 | QFileInfo finfo(fileName); |
| 281 | QMap<QString, QVariant> retVal; |
| 282 | |
| 283 | retVal[QString::fromLatin1("status")] = SystemAccess_PermissionDenied; |
| 284 | retVal[QString::fromLatin1("message")] = QVariant(); |
| 285 | |
| 286 | // it's OK to "launch" a directory, as that doesn't normally execute anything |
| 287 | if (finfo.isDir() || mayExecuteSystemCommand(fileName, m_target)) { |
| 288 | if (QDesktopServices::openUrl(QUrl::fromLocalFile(fileName))) |
| 289 | retVal[QString::fromLatin1("status")] = SystemAccess_OK; |
| 290 | else { |
| 291 | retVal[QString::fromLatin1("status")] = SystemAccess_Failed; |
| 292 | retVal[QString::fromLatin1("message")] = tr("\"%1\" could not be opened.").arg(fileName); |
| 293 | } |
| 294 | } |
| 295 | else |
| 296 | retVal[QString::fromLatin1("message")] = tr("System command execution is disabled (see Preferences)"); |
| 297 | return retVal; |
| 298 | } |
| 299 | |
| 300 | //Q_INVOKABLE |
| 301 | int ScriptAPI::writeFile(const QString& filename, const QString& content) const |