Commit 45a792b2 authored by Srevin Saju's avatar Srevin Saju 🎲 Committed by Nate Graham
Browse files

feat: add new kcfg settings for after screenshot clipboard preferences

refactor: use clipboardGroup to get user preference

fix: use a unique enum definition for the after screenshot clipboard user preferences

feat: add spectacle.upd to convert old entries to new ones

converts copyImageToClipboard=true and copySaveLocation=false to
clipboardGroup

refactor: rename spectacle.upd to conf/update/spectacle_clipboard.upd
parent 1243e0e0
......@@ -108,6 +108,10 @@ if(kImageAnnotator_FOUND)
set(KIMAGEANNOTATOR_FOUND 1)
endif()
# add the spectacle.upd file
install(FILES conf/update/spectacle_clipboard.upd DESTINATION ${KDE_INSTALL_KCONFUPDATEDIR})
install(FILES conf/update/50-clipboard_settings_change.py DESTINATION ${KDE_INSTALL_KCONFUPDATEDIR})
# fail build if none of the platform backends can be found
if (NOT XCB_FOUND OR NOT XCB_COMPONENTS_FOUND)
message(FATAL_ERROR "No suitable backend platform was found. Currently supported platforms are: XCB Components Required: ${XCB_COMPONENTS_ERRORS}")
......
import fileinput
def check_if_true(line):
return line.split("=")[1].strip() == "true"
for line in fileinput.input():
if line.startswith("copyImageToClipboard"):
if check_if_true(line):
print("clipboardGroup=PostScreenshotCopyImage")
print("# DELETE copyImageToClipboard")
elif line.startswith("copySaveLocation"):
if check_if_true(line):
print("clipboardGroup=PostScreenshotCopyLocation")
print("# DELETE copySaveLocation")
Version=5
Id=clipboard-settings-change
File=spectaclerc
Group=General
Script=50-clipboard_settings_change.py,python3
......@@ -17,17 +17,18 @@
</choices>
<default>TakeNewScreenshot</default>
</entry>
<entry name="copyImageToClipboard" type ="Bool">
<label>Copy screenshot automatically to the clipboard after it is taken</label>
<default>false</default>
</entry>
<entry name="autoSaveImage" type="Bool">
<label>Save screenshot automatically after it is taken</label>
<default>false</default>
</entry>
<entry name="copySaveLocation" type="Bool">
<label>Whether to copy the file path after saving to the clipboard</label>
<default>true</default>
<entry name="clipboardGroup" type="Enum">
<label>Clipboard action which should be executed after the screenshot is taken</label>
<choices>
<choice name="PostScreenshotDoNothing"></choice>
<choice name="PostScreenshotCopyImage"></choice>
<choice name="PostScreenshotCopyLocation"></choice>
</choices>
<default>PostScreenshotDoNothing</default>
</entry>
<entry name="useLightMaskColour" type="Bool">
<label>Whether to use a light color mask in the region selection dialog</label>
......
......@@ -131,7 +131,7 @@ void SpectacleCore::onActivateRequested(QStringList arguments, const QString& /*
switch (mStartMode) {
case StartMode::DBus:
mCopyToClipboard = Settings::copyImageToClipboard();
mCopyImageToClipboard = Settings::clipboardGroup() == Settings::EnumClipboardGroup::PostScreenshotCopyImage;
qApp->setQuitOnLastWindowClosed(false);
break;
......@@ -349,7 +349,7 @@ void SpectacleCore::screenshotUpdated(const QPixmap &thePixmap)
mMainWindow->setScreenshotAndShow(thePixmap);
bool autoSaveImage = Settings::autoSaveImage();
bool mCopyImageToClipboard = Settings::copyImageToClipboard();
bool mCopyImageToClipboard = Settings::clipboardGroup() == Settings::EnumClipboardGroup::PostScreenshotCopyImage;
if (autoSaveImage && mCopyImageToClipboard) {
lExportManager->doSaveAndCopy();
......@@ -461,7 +461,7 @@ void SpectacleCore::doNotify(const QUrl &theSavedAt)
void SpectacleCore::doCopyPath(const QUrl &savedAt)
{
if (Settings::copySaveLocation()) {
if (Settings::clipboardGroup() == Settings::EnumClipboardGroup::PostScreenshotCopyLocation) {
qApp->clipboard()->setText(savedAt.toLocalFile());
}
}
......
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