mirror of
https://github.com/marty-oehme/scripts.git
synced 2024-12-21 15:38:09 +00:00
added more script functionality
This commit is contained in:
parent
8657e99640
commit
add183623a
2 changed files with 26 additions and 9 deletions
|
@ -3,8 +3,8 @@
|
|||
"identifier": "scribble",
|
||||
"script": "scribble.qml",
|
||||
"resources": ["scribble.png"],
|
||||
"version": "0.1",
|
||||
"version": "0.2",
|
||||
"minAppVersion": "18.03.2",
|
||||
"authors": ["@pbek"],
|
||||
"description" : "This script adds a menu entry to the context menu of the note edit to insert a scribble image to the media-folder, that will be edited by an external image manipulation application. The paths of the image manipulation application and the template image can be selected in the script settings of the script."
|
||||
"description" : "This script adds a menu entry to the context menu of the note edit to <strong>insert a scribble image</strong> to the media-folder, that will be <strong>edited by an external image editor</strong>. The paths of the image editor and the template image can be selected in the script settings of the script."
|
||||
}
|
||||
|
|
|
@ -2,12 +2,15 @@ import QtQml 2.0
|
|||
import QOwnNotesTypes 1.0
|
||||
|
||||
/**
|
||||
* This script adds a menu entry to the context menu of the note list to diff selected notes in an external diff program
|
||||
* The path of the diff program can be selected in the script settings of the script
|
||||
* This script adds a menu entry to the context menu of the note edit to insert a
|
||||
* scribble image to the media-folder, that will be edited by an external image editor
|
||||
*
|
||||
* The path of the image editor and the image template can be selected in the script settings of the script
|
||||
*/
|
||||
Script {
|
||||
property string executablePath;
|
||||
property string imagePath;
|
||||
property bool executeInBackground;
|
||||
|
||||
// the path to the script's directory will be set here
|
||||
property string scriptDirPath;
|
||||
|
@ -16,7 +19,7 @@ Script {
|
|||
property variant settingsVariables: [
|
||||
{
|
||||
"identifier": "executablePath",
|
||||
"name": "Path of external image manipulation application",
|
||||
"name": "Path of external image editor",
|
||||
"description": "Please select the path of the executable:",
|
||||
"type": "file",
|
||||
"default": "gimp",
|
||||
|
@ -27,6 +30,14 @@ Script {
|
|||
"description": "Please select the path of the template image:",
|
||||
"type": "file",
|
||||
"default": scriptDirPath + "/scribble.png",
|
||||
},
|
||||
{
|
||||
"identifier": "executeInBackground",
|
||||
"name": "Execute image editor in background",
|
||||
"description": "If the image editor is executed in the background you will be able to work with QOwnNotes while you are editing the scribble, but the note preview will not be refreshed automatically after you close the image editor.",
|
||||
"text": "Execute in background",
|
||||
"type": "boolean",
|
||||
"default": false,
|
||||
}
|
||||
];
|
||||
|
||||
|
@ -49,14 +60,20 @@ Script {
|
|||
}
|
||||
|
||||
// insert the scribble template image as media file
|
||||
var mediaFile = script.insertMedia(imagePath, true);
|
||||
var mediaFile = script.insertMediaFile(imagePath, true);
|
||||
var mediaFilePath = mediaFile.replace("file://media", script.currentNoteFolderPath() + "/media");
|
||||
|
||||
// write the scribble image to the note
|
||||
script.noteTextEditWrite("![scribble](" + mediaFile + ")");
|
||||
script.noteTextEditWrite("![scribble](" + mediaFile + ")\n");
|
||||
|
||||
var params = [mediaFilePath];
|
||||
|
||||
// edit the scribble image
|
||||
var params = [mediaFilePath];
|
||||
script.startDetachedProcess(executablePath, params);
|
||||
if (executeInBackground) {
|
||||
script.startDetachedProcess(executablePath, params);
|
||||
} else {
|
||||
script.startSynchronousProcess(executablePath, params);
|
||||
script.regenerateNotePreview();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue