Use generated DBus interface

This commit is contained in:
Jonah Brüchert 2020-10-01 13:49:32 +02:00
parent 51f4c454c0
commit 849cb5f88f
No known key found for this signature in database
GPG key ID: A81E075ABEC80A7E

View file

@ -168,20 +168,19 @@ void PhonePanel::takeScreenshot()
qWarning() << "Could not take screenshot"; qWarning() << "Could not take screenshot";
return; return;
} }
QDBusInterface lInterface(QStringLiteral("org.kde.KWin"), QStringLiteral("/Screenshot"), QStringLiteral("org.kde.kwin.Screenshot"));
// Take fullscreen screenshot, and no pointer // Take fullscreen screenshot, and no pointer
QDBusPendingCall pcall = lInterface.asyncCall("screenshotFullscreen", QVariant::fromValue(QDBusUnixFileDescriptor(lPipeFds[1])), false); QDBusPendingCall pcall = m_screenshotInterface->screenshotFullscreen(QDBusUnixFileDescriptor(lPipeFds[1]), false);
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pcall, this); QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pcall, this);
QObject::connect(watcher, &QDBusPendingCallWatcher::finished, this, [this](QDBusPendingCallWatcher* watcher) { QObject::connect(watcher, &QDBusPendingCallWatcher::finished, this, [](QDBusPendingCallWatcher* watcher) {
if (watcher->isError()) { if (watcher->isError()) {
const auto error = watcher->error(); const auto error = watcher->error();
qWarning() << "Error calling KWin DBus interface:" << error.name() << error.message(); qWarning() << "Error calling KWin DBus interface:" << error.name() << error.message();
} }
watcher->deleteLater(); watcher->deleteLater();
}); });
auto lWatcher = new QFutureWatcher<QImage>(this); const auto lWatcher = new QFutureWatcher<QImage>(this);
QObject::connect(lWatcher, &QFutureWatcher<QImage>::finished, this, QObject::connect(lWatcher, &QFutureWatcher<QImage>::finished, this,
[lWatcher, filePath, this] () { [lWatcher, filePath] () {
lWatcher->deleteLater(); lWatcher->deleteLater();
const QImage lImage = lWatcher->result(); const QImage lImage = lWatcher->result();
qDebug() << lImage; qDebug() << lImage;