[graphics/spectacle] /: Respect -c, in combination with -b, to only save image into clipboard
Nate Graham
null at kde.org
Wed Jan 19 16:43:59 GMT 2022
Git commit 1de84d561da89686c7059ffa83fa34cde55c1c42 by Nate Graham, on behalf of Antonio Prcela.
Committed on 19/01/2022 at 16:43.
Pushed by ngraham into branch 'master'.
Respect -c, in combination with -b, to only save image into clipboard
Rearranged code to check 'copy-image' before 'output', in case the command goes like:
spectacle -b -c -o ./file.png
So the file also gets saved. Otherwise, with the old arrangement, it would only save
to clipboard ignoring '-o'.
BUG: 447811
FIXED-IN: 22.04
M +1 -1 doc/man-spectacle.1.docbook
M +9 -7 src/SpectacleCore.cpp
https://invent.kde.org/graphics/spectacle/commit/1de84d561da89686c7059ffa83fa34cde55c1c42
diff --git a/doc/man-spectacle.1.docbook b/doc/man-spectacle.1.docbook
index f795cda..1d1c50c 100644
--- a/doc/man-spectacle.1.docbook
+++ b/doc/man-spectacle.1.docbook
@@ -134,7 +134,7 @@
<varlistentry>
<term><option>-c, --copy-image</option></term>
<listitem>
-<para>In background mode, copy screenshot to clipboard.</para>
+<para>In background mode, copy screenshot only to clipboard, unless -o is also used.</para>
</listitem>
</varlistentry>
diff --git a/src/SpectacleCore.cpp b/src/SpectacleCore.cpp
index 3908642..efb5389 100644
--- a/src/SpectacleCore.cpp
+++ b/src/SpectacleCore.cpp
@@ -160,11 +160,19 @@ void SpectacleCore::onActivateRequested(QStringList arguments, const QString & /
case StartMode::Background: {
mCopyImageToClipboard = false;
mCopyLocationToClipboard = false;
+ mSaveToOutput = true;
if (parser->isSet(QStringLiteral("nonotify"))) {
mNotify = false;
}
+ if (parser->isSet(QStringLiteral("copy-image"))) {
+ mSaveToOutput = false;
+ mCopyImageToClipboard = true;
+ } else if (parser->isSet(QStringLiteral("copy-path"))) {
+ mCopyLocationToClipboard = true;
+ }
+
if (parser->isSet(QStringLiteral("output"))) {
mSaveToOutput = true;
QString lFileName = parser->value(QStringLiteral("output"));
@@ -188,12 +196,6 @@ void SpectacleCore::onActivateRequested(QStringList arguments, const QString & /
lDelayMsec = -1;
}
- if (parser->isSet(QStringLiteral("copy-image"))) {
- mCopyImageToClipboard = true;
- } else if (parser->isSet(QStringLiteral("copy-path"))) {
- mCopyLocationToClipboard = true;
- }
-
if (!mIsGuiInited) {
static_cast<QGuiApplication *>(qApp->instance())->setQuitOnLastWindowClosed(false);
}
@@ -535,7 +537,7 @@ void SpectacleCore::populateCommandLineParser(QCommandLineParser *lCmdLineParser
{{QStringLiteral("d"), QStringLiteral("delay")},
i18n("In background mode, delay before taking the shot (in milliseconds)"),
QStringLiteral("delayMsec")},
- {{QStringLiteral("c"), QStringLiteral("copy-image")}, i18n("In background mode, copy screenshot image to clipboard")},
+ {{QStringLiteral("c"), QStringLiteral("copy-image")}, i18n("In background mode, copy screenshot image to clipboard, unless -o is also used.")},
{{QStringLiteral("C"), QStringLiteral("copy-path")}, i18n("In background mode, copy screenshot file path to clipboard")},
{{QStringLiteral("w"), QStringLiteral("onclick")}, i18n("Wait for a click before taking screenshot. Invalidates delay")},
{{QStringLiteral("i"), QStringLiteral("new-instance")}, i18n("Starts a new GUI instance of spectacle without registering to DBus")},
More information about the kde-doc-english
mailing list