diff --git a/Config/Screenshot.qml b/Config/Screenshot.qml index cd6dd49..cf64332 100644 --- a/Config/Screenshot.qml +++ b/Config/Screenshot.qml @@ -5,6 +5,7 @@ JsonObject { property string mode: "manual" property real radius: 12.0 property bool rounding: false + property bool saveOnCopy: false property bool shadow: true property real shadow_blur: 22.0 property list shadow_color: [0, 0, 0, 160] diff --git a/Helpers/Picker.qml b/Helpers/Picker.qml index b59dc8a..f2c1d72 100755 --- a/Helpers/Picker.qml +++ b/Helpers/Picker.qml @@ -8,6 +8,7 @@ import QtQuick.Effects import qs.Components import qs.Config import qs.Helpers.Picker +import qs.Paths Item { id: root @@ -103,8 +104,9 @@ Item { const finalize = finalPath => { if (copyToClipboard) { Quickshell.execDetached(["sh", "-c", `wl-copy --type image/png < '${finalPath.replace(/'/g, `'\\''`)}'`]); - } else { - const dest = `${Quickshell.env("HOME")}/Pictures/Screenshots/zshell-${Date.now()}.png`; + } + if (!copyToClipboard || Config.screenshot.saveOnCopy) { + const dest = `${Paths.screenshots}/zshell-${Date.now()}.png`; Quickshell.execDetached(["sh", "-c", `mkdir -p "$(dirname '${dest}')" && cp '${path.replace(/'/g, `'\\''`)}' '${dest}'`]); } }; @@ -176,6 +178,15 @@ Item { } } Keys.onEscapePressed: root.mode === "edit" ? cancel() : closeAnim.start() + Keys.onPressed: e => { + if ((e.key == Qt.Key_C) && (e.modifiers & Qt.ControlModifier)) { + save(true); + e.accepted = true; + } else if ((e.key == Qt.Key_S) && (e.modifiers & Qt.ControlModifier)) { + save(false); + e.accepted = true; + } + } onClientsChanged: { if (root.mode === "select") checkClientRects(selectArea.mouseX, selectArea.mouseY); diff --git a/Modules/Settings/PageRegistry.qml b/Modules/Settings/PageRegistry.qml index 3971d36..c6381c0 100644 --- a/Modules/Settings/PageRegistry.qml +++ b/Modules/Settings/PageRegistry.qml @@ -15,9 +15,9 @@ Singleton { category: "appearance" }, { - name: qsTr("Screenshot"), + name: qsTr("Screenshots"), icon: "screenshot_region", - description: qsTr("Set screenshot effects"), + description: qsTr("Set screenshot options and effects"), category: "appearance" }, diff --git a/Modules/Settings/Pages/ScreenshotPage.qml b/Modules/Settings/Pages/ScreenshotPage.qml index a97d47c..5a099aa 100644 --- a/Modules/Settings/Pages/ScreenshotPage.qml +++ b/Modules/Settings/Pages/ScreenshotPage.qml @@ -12,7 +12,7 @@ import qs.Modules.Settings.Common PageBase { id: root - title: qsTr("Screenshot effects") + title: qsTr("Screenshots") ColumnLayout { anchors.horizontalCenter: parent.horizontalCenter @@ -22,6 +22,21 @@ PageBase { SectionHeader { first: true + text: qsTr("Behavior") + } + + ToggleRow { + checked: Config.screenshot.saveOnCopy + first: true + last: true + settingAnchor: "screenshot-save-on-copy" + subtext: qsTr("Also save screenshot to disk when copying to clipboard") + text: qsTr("Save on copy") + + onToggled: Config.screenshot.saveOnCopy = checked + } + + SectionHeader { text: qsTr("Effects") } diff --git a/Paths/Paths.qml b/Paths/Paths.qml index 4847062..0dea500 100644 --- a/Paths/Paths.qml +++ b/Paths/Paths.qml @@ -17,6 +17,7 @@ Singleton { readonly property string notifimagecache: `${imagecache}/notifs` readonly property string pictures: Quickshell.env("XDG_PICTURES_DIR") || `${home}/Pictures` readonly property string recsdir: Quickshell.env("ZSHELL_RECORDINGS_DIR") || `${videos}/Recordings` + readonly property string screenshots: Quickshell.env("ZSHELL_SCREENSHOTS_DIR") || `${home}/Pictures/Screenshots` readonly property string state: `${Quickshell.env("XDG_STATE_HOME") || `${home}/.local/state`}/zshell` readonly property string videos: Quickshell.env("XDG_VIDEOS_DIR") || `${home}/Videos` readonly property string wallsdir: Quickshell.env("ZSHELL_WALLPAPERS_DIR") || absolutePath(Config.general.wallpaperPath)