2022-03-13 21:47:42 +00:00
|
|
|
// SPDX-FileCopyrightText: 2022 Devin Lin <devin@kde.org>
|
|
|
|
|
// SPDX-License-Identifier: LGPL-2.0-or-later
|
|
|
|
|
|
|
|
|
|
import QtQuick 2.15
|
|
|
|
|
|
2023-03-17 02:44:36 +00:00
|
|
|
import org.kde.plasma.private.mobileshell.quicksettingsplugin as QS
|
2023-03-20 01:32:19 +00:00
|
|
|
import org.kde.plasma.private.mobileshell.state as MobileShellState
|
|
|
|
|
import org.kde.plasma.quicksetting.screenshot
|
2022-03-13 21:47:42 +00:00
|
|
|
|
2023-03-17 02:44:36 +00:00
|
|
|
QS.QuickSetting {
|
2022-03-13 21:47:42 +00:00
|
|
|
text: i18n("Screenshot")
|
|
|
|
|
status: i18n("Tap to screenshot")
|
|
|
|
|
icon: "spectacle"
|
|
|
|
|
enabled: false
|
2024-07-27 03:47:44 +00:00
|
|
|
|
2022-03-13 21:47:42 +00:00
|
|
|
property bool screenshotRequested: false
|
2024-07-27 03:47:44 +00:00
|
|
|
|
2022-03-13 21:47:42 +00:00
|
|
|
function toggle() {
|
|
|
|
|
screenshotRequested = true;
|
2023-03-20 01:32:19 +00:00
|
|
|
MobileShellState.ShellDBusClient.closeActionDrawer();
|
2022-03-13 21:47:42 +00:00
|
|
|
}
|
2024-07-27 03:47:44 +00:00
|
|
|
|
2022-03-13 21:47:42 +00:00
|
|
|
Connections {
|
2023-03-20 01:32:19 +00:00
|
|
|
target: MobileShellState.ShellDBusClient
|
|
|
|
|
|
|
|
|
|
function onIsActionDrawerOpenChanged(visible) {
|
2022-03-13 21:47:42 +00:00
|
|
|
if (!visible && screenshotRequested) {
|
|
|
|
|
screenshotRequested = false;
|
|
|
|
|
timer.restart();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-07-27 03:47:44 +00:00
|
|
|
|
2022-03-13 21:47:42 +00:00
|
|
|
// HACK: KWin's fade effect may have the window ending up being in the screenshot if taken too fast
|
|
|
|
|
Timer {
|
|
|
|
|
id: timer
|
|
|
|
|
interval: 500
|
2022-03-17 03:49:51 +00:00
|
|
|
onTriggered: ScreenShotUtil.takeScreenShot()
|
2022-03-13 21:47:42 +00:00
|
|
|
}
|
|
|
|
|
}
|