// fixed bug QTBUG-113143 static inline QDBusMessage xdgDesktopPortalOpenFile(const QUrl &url) { // DBus signature: // OpenFile (IN s parent_window, // IN h fd, // IN a{sv} options, // OUT o handle) // Options: // handle_token (s) - A string that will be used as the last element of the @handle. // writable (b) - Whether to allow the chosen application to write to the file. const int fd = open(QFile::encodeName(url.toLocalFile()), O_PATH|O_CLOEXEC); // const int fd = qt_safe_open(QFile::encodeName(url.toLocalFile()), O_PATH); if (fd != -1) { QDBusMessage message = QDBusMessage::createMethodCall("org.freedesktop.portal.Desktop", "/org/freedesktop/portal/desktop", "org.freedesktop.portal.OpenURI", "OpenFile"); QDBusUnixFileDescriptor descriptor; descriptor.giveFileDescriptor(fd); // don't set option! const QVariantMap options;// = {{"writable"_L1, true}}; // FIXME parent_window_id message << QString() << QVariant::fromValue(descriptor) << options; return QDBusConnection::sessionBus().call(message); } return QDBusMessage::createError(QDBusError::InternalError, qt_error_string()); }