Commit 6db9537d authored by Luca Weiss's avatar Luca Weiss

Quicksettings: convert screenshot interface to class member

parent 782d5831
......@@ -29,14 +29,13 @@
#include <QtConcurrent/QtConcurrent>
#include <QScreen>
#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<QString> reply = interface->screenshotArea(0, 0, screenSize.width(), screenSize.height());
QDBusPendingReply<QString> 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();
});
});
}
......
......@@ -26,6 +26,7 @@
#include <gst/gst.h>
#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
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment