Make KDE use Freedesktop portal (#2495)

This commit is contained in:
greenfoo
2022-04-05 02:34:12 +02:00
committed by GitHub
parent a4807861f0
commit 3cd2deca58

View File

@@ -100,25 +100,8 @@ QPixmap ScreenGrabber::grabEntireDesktop(bool& ok)
QPixmap res;
// handle screenshot based on DE
switch (m_info.windowManager()) {
case DesktopInfo::GNOME: {
freeDesktopPortal(ok, res);
break;
}
case DesktopInfo::KDE: {
// https://github.com/KDE/spectacle/blob/517a7baf46a4ca0a45f32fd3f2b1b7210b180134/src/PlatformBackends/KWinWaylandImageGrabber.cpp#L145
QDBusInterface kwinInterface(
QStringLiteral("org.kde.KWin"),
QStringLiteral("/Screenshot"),
QStringLiteral("org.kde.kwin.Screenshot"));
QDBusReply<QString> reply =
kwinInterface.call(QStringLiteral("screenshotFullscreen"));
res = QPixmap(reply.value());
if (!res.isNull()) {
QFile dbusResult(reply.value());
dbusResult.remove();
}
break;
}
case DesktopInfo::GNOME:
case DesktopInfo::KDE:
case DesktopInfo::SWAY: {
freeDesktopPortal(ok, res);
break;