code formatting

This commit is contained in:
nullobsi
2021-02-02 00:18:38 -08:00
committed by borgmanJeremy
parent 799c4c9908
commit ddf69010d8
4 changed files with 49 additions and 42 deletions

View File

@@ -25,10 +25,10 @@
#include <QScreen>
#if defined(Q_OS_LINUX) || defined(Q_OS_UNIX)
#include "request.h"
#include <QDBusInterface>
#include <QDBusReply>
#include <QDir>
#include "request.h"
#endif
ScreenGrabber::ScreenGrabber(QObject* parent)
@@ -90,37 +90,34 @@ QPixmap ScreenGrabber::grabEntireDesktop(bool& ok)
break;
}
case DesktopInfo::SWAY: {
qDebug("Sway");
QDBusInterface screenshotInterface(
QStringLiteral("org.freedesktop.portal.Desktop"),
QStringLiteral("/org/freedesktop/portal/desktop"),
QStringLiteral("org.freedesktop.portal.Screenshot"));
QDBusReply<QDBusObjectPath> reply =
screenshotInterface.call(QStringLiteral("Screenshot"),
"",
QMap<QString, QVariant>());
auto *request = new OrgFreedesktopPortalRequestInterface(
QDBusReply<QDBusObjectPath> reply = screenshotInterface.call(
QStringLiteral("Screenshot"), "", QMap<QString, QVariant>());
auto* request = new OrgFreedesktopPortalRequestInterface(
QStringLiteral("org.freedesktop.portal.Desktop"),
reply.value().path(),
QDBusConnection::sessionBus(),
this);
QEventLoop loop;
const auto gotSignal =
[&res, &loop](uint status,
const QVariantMap &map) {
if (status == 0) {
QString uri = map.value("uri").toString().remove(0, 7);
res = QPixmap(uri);
res.setDevicePixelRatio(qApp->devicePixelRatio());
QFile imgFile(uri);
imgFile.remove();
}
loop.quit();
};
QMetaObject::Connection conn = QObject::connect(request,
&org::freedesktop::portal::Request::Response,
gotSignal);
const auto gotSignal = [&res, &loop](uint status,
const QVariantMap& map) {
if (status == 0) {
QString uri = map.value("uri").toString().remove(0, 7);
res = QPixmap(uri);
res.setDevicePixelRatio(qApp->devicePixelRatio());
QFile imgFile(uri);
imgFile.remove();
}
loop.quit();
};
QMetaObject::Connection conn =
QObject::connect(request,
&org::freedesktop::portal::Request::Response,
gotSignal);
loop.exec();
QObject::disconnect(conn);
request->Close().waitForFinished();