1
0
Fork 0
mirror of https://github.com/marty-oehme/scripts.git synced 2024-12-21 23:48:08 +00:00

added scribble script

This commit is contained in:
Patrizio Bekerle 2018-03-06 17:16:27 +01:00
parent 1fe188b72e
commit 8657e99640
No known key found for this signature in database
GPG key ID: 2E9FFD770DABE838
3 changed files with 72 additions and 0 deletions

10
scribble/info.json Normal file
View file

@ -0,0 +1,10 @@
{
"name": "Scribble",
"identifier": "scribble",
"script": "scribble.qml",
"resources": ["scribble.png"],
"version": "0.1",
"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."
}

BIN
scribble/scribble.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

62
scribble/scribble.qml Normal file
View file

@ -0,0 +1,62 @@
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
*/
Script {
property string executablePath;
property string imagePath;
// the path to the script's directory will be set here
property string scriptDirPath;
// register your settings variables so the user can set them in the script settings
property variant settingsVariables: [
{
"identifier": "executablePath",
"name": "Path of external image manipulation application",
"description": "Please select the path of the executable:",
"type": "file",
"default": "gimp",
},
{
"identifier": "imagePath",
"name": "Path of template image",
"description": "Please select the path of the template image:",
"type": "file",
"default": scriptDirPath + "/scribble.png",
}
];
/**
* Initializes the custom actions
*/
function init() {
script.registerCustomAction("scribble", "Add scribble", "Scribble", "view-preview", true, false, false);
}
/**
* This function is invoked when a custom action is triggered
* in the menu or via button
*
* @param identifier string the identifier defined in registerCustomAction
*/
function customActionInvoked(identifier) {
if (identifier != "scribble") {
return;
}
// insert the scribble template image as media file
var mediaFile = script.insertMedia(imagePath, true);
var mediaFilePath = mediaFile.replace("file://media", script.currentNoteFolderPath() + "/media");
// write the scribble image to the note
script.noteTextEditWrite("![scribble](" + mediaFile + ")");
// edit the scribble image
var params = [mediaFilePath];
script.startDetachedProcess(executablePath, params);
}
}