Add timer to screenshots to avoid rest of animations

This commit is contained in:
Linus Jahn 2020-02-08 13:45:33 +01:00 committed by Jonah Brüchert
parent 88f838d147
commit 67c6f94b9d

View file

@ -80,8 +80,14 @@ void PhonePanel::toggleTorch()
void PhonePanel::takeScreenshot()
{
// wait ~200 ms to wait for rest of animations
QTimer::singleShot(200, [=]() {
auto *interface = new org::kde::kwin::Screenshot(QStringLiteral("org.kde.KWin"), QStringLiteral("/Screenshot"), QDBusConnection::sessionBus(), this);
QDBusPendingReply<QString> reply = interface->screenshotFullscreen();
// screenshot fullscreen currently doesn't work on all devices -> we need to use screenshot area
// this won't work with multiple screens
QSize screenSize = QGuiApplication::primaryScreen()->size();
QDBusPendingReply<QString> reply = interface->screenshotArea(0, 0, screenSize.width(), screenSize.height());
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(reply, this);
connect(watcher, &QDBusPendingCallWatcher::finished, this, [=](QDBusPendingCallWatcher *watcher) {
@ -122,6 +128,7 @@ void PhonePanel::takeScreenshot()
watcher->deleteLater();
interface->deleteLater();
});
});
}
K_EXPORT_PLASMA_APPLET_WITH_JSON(quicksettings, PhonePanel, "metadata.json")