Le mar. 18 août 2020 à 12:04, <kde-devel-requ...@kde.org> a écrit :

> Date: Mon, 17 Aug 2020 12:44:35 +0000
> From: Damir Porobic <damir_poro...@live.com>
> To: "kde-devel@kde.org" <kde-devel@kde.org>
> Subject: Re: Using xdg-desktop-portal-kde to take screenshots
> Message-ID:
>         <
> am0pr09mb389099fac1a15b22f0e6d4afe5...@am0pr09mb3890.eurprd09.prod.outlook.com
> >
>
> Content-Type: text/plain; charset="iso-8859-1"
>
> Hello,
>
> has anyone experience with this portal?
>
> Best regards,
> Damir
>
> ________________________________
> From: kde-devel <kde-devel-boun...@kde.org> on behalf of Damir Porobic <
> damir_poro...@live.com>
> Sent: Thursday, August 13, 2020 16:16
> To: kde-devel@kde.org <kde-devel@kde.org>
> Subject: Using xdg-desktop-portal-kde to take screenshots
>
> Hello,
>
> I'm trying use the xdg-desktop-portal-kde (
> https://invent.kde.org/plasma/xdg-desktop-portal-kde/-/blob/master/src/screenshot.cpp)
> portal in order to take screenshots under Wayland.
>
> If I understand correctly, making a DBus Call like this should open a
> Dialog with a Screenshot that can be shared with my application.
>
> *********************************
> QDBusInterface interface(QStringLiteral("org.freedesktop.portal.Desktop"),
> QStringLiteral("/org/freedesktop/portal/Screenshot"),
> QStringLiteral("org.freedesktop.portal.Screenshot"));
> QDBusPendingReply<QDBusObjectPath> reply;
>
> reply = interface.call(QStringLiteral("Screenshot"), "", QVariantMap());
>
> if (reply.isError()) {
>     qCritical("Invalid reply from DBus: %s",
> qPrintable(reply.error().message()));
>     emit canceled();
> } else {
>     qCritical("Dbus success: %s",
> qPrintable(reply.argumentAt<0>().path()));
> }
> *********************************
>
> But the path to the image is not returned in the result from this call.
> How am I supposed to get the result?
>
> Is there any example implementation that uses this portal? In Spectacle I
> have only seen the solution using org.kde.plasmashell, but not the portal
> solution.
>
> Thanks in advance!
>
> Best regards
> Damir
>

Hi Damir,

You need to pass an instance of QVariantMap that will be filled up with a
uri field according to the code:

auto result = QVariantMap();
reply = interface.call(QStringLiteral("Screenshot"), "", &result);
result.value("uri");

But you might be missing parameters also :

    uint Screenshot(const QDBusObjectPath &handle,
                    const QString &app_id,
                    const QString &parent_window,
                    const QVariantMap &options,
                    QVariantMap &results);

Also the file is saved in QStandardPaths::PicturesLocation with a timestamp.

Documentation is at
https://flatpak.github.io/xdg-desktop-portal/portal-docs.html#gdbus-org.freedesktop.impl.portal.Screenshot

I hope this helps,

Kind regards,

-- 
Méven

Reply via email to