Skip to content
This repository has been archived by the owner on Mar 18, 2020. It is now read-only.

Commit

Permalink
added more script functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
pbek committed Mar 6, 2018
1 parent 8657e99 commit add1836
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 9 deletions.
4 changes: 2 additions & 2 deletions scribble/info.json
Original file line number Diff line number Diff line change
Expand Up @@ -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."
}
31 changes: 24 additions & 7 deletions scribble/scribble.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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",
Expand All @@ -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,
}
];

Expand All @@ -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();
}
}
}

0 comments on commit add1836

Please sign in to comment.