diff --git a/containments/panel/phonepanel.cpp b/containments/panel/phonepanel.cpp index 651a77f9..f3cd43dc 100644 --- a/containments/panel/phonepanel.cpp +++ b/containments/panel/phonepanel.cpp @@ -29,14 +29,13 @@ #include #include -#include "screenshotinterface.h" - constexpr int SCREENSHOT_DELAY = 200; PhonePanel::PhonePanel(QObject *parent, const QVariantList &args) : Plasma::Containment(parent, args) { //setHasConfigurationInterface(true); + m_screenshotInterface = new org::kde::kwin::Screenshot(QStringLiteral("org.kde.KWin"), QStringLiteral("/Screenshot"), QDBusConnection::sessionBus(), this); } PhonePanel::~PhonePanel() = default; @@ -84,12 +83,10 @@ void PhonePanel::takeScreenshot() { // wait ~200 ms to wait for rest of animations QTimer::singleShot(SCREENSHOT_DELAY, [=]() { - auto *interface = new org::kde::kwin::Screenshot(QStringLiteral("org.kde.KWin"), QStringLiteral("/Screenshot"), QDBusConnection::sessionBus(), this); - // 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 reply = interface->screenshotArea(0, 0, screenSize.width(), screenSize.height()); + QDBusPendingReply reply = m_screenshotInterface->screenshotArea(0, 0, screenSize.width(), screenSize.height()); auto *watcher = new QDBusPendingCallWatcher(reply, this); connect(watcher, &QDBusPendingCallWatcher::finished, this, [=](QDBusPendingCallWatcher *watcher) { @@ -128,7 +125,6 @@ void PhonePanel::takeScreenshot() } watcher->deleteLater(); - interface->deleteLater(); }); }); } diff --git a/containments/panel/phonepanel.h b/containments/panel/phonepanel.h index 08c279a5..4e0bc67b 100644 --- a/containments/panel/phonepanel.h +++ b/containments/panel/phonepanel.h @@ -26,6 +26,7 @@ #include +#include "screenshotinterface.h" class PhonePanel : public Plasma::Containment { @@ -45,6 +46,8 @@ private: GstElement* m_sink; GstElement* m_source; bool m_running = false; + + org::kde::kwin::Screenshot *m_screenshotInterface; }; #endif