From ba0b27fbccf59ffeebd623a98bd086551fe57ed3 Mon Sep 17 00:00:00 2001 From: Maboroshy Date: Sun, 23 Jul 2017 15:15:27 +0300 Subject: [PATCH] Added insert text button script --- insert-text/info.json | 10 +++++++ insert-text/insert-text.qml | 52 +++++++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 insert-text/info.json create mode 100644 insert-text/insert-text.qml diff --git a/insert-text/info.json b/insert-text/info.json new file mode 100644 index 0000000..030a743 --- /dev/null +++ b/insert-text/info.json @@ -0,0 +1,10 @@ +{ + "name": "Insert text button", + "identifier": "insert-text", + "script": "insert-text.qml", + "authors": ["@Maboroshy"], + "platforms": ["linux", "macos", "windows"], + "version": "0.0.1", + "minAppVersion": "17.05.8", + "description" : "Simple script, that creates a button and a context menu item that insert text, defined in the script settings." +} diff --git a/insert-text/insert-text.qml b/insert-text/insert-text.qml new file mode 100644 index 0000000..e12f718 --- /dev/null +++ b/insert-text/insert-text.qml @@ -0,0 +1,52 @@ +import QtQml 2.2 +import QOwnNotesTypes 1.0 + +/// Simple script, that creates a button and a context menu item that insert text, defined in the script settings. + +Script { + property string text + property string menuName + property string buttonName + property string buttonIcon + + property variant settingsVariables: [ + { + "identifier": "text", + "name": "Text to insert", + "description": "A text that would be inserted to note text when the button is pressed.", + "type": "string", + "default": "[comment]: # ()", + }, + { + "identifier": "menuName", + "name": "Name of the menu item", + "description": "", + "type": "string", + "default": "Insert comment", + }, + { + "identifier": "buttonName", + "name": "Name of the button", + "description": "", + "type": "string", + "default": "Insert comment", + }, + { + "identifier": "buttonIcon", + "name": "Icon of the button", + "description": "Name or full path to button icon. If empty, button name will be shown.", + "type": "string", + "default": "insert-text.svg", + }, + ] + + function init() { + script.registerCustomAction("insertText", menuName, buttonName, buttonIcon, true) + } + + function customActionInvoked(action) { + if (action == "insertText") { + script.noteTextEditWrite(text) + } + } +}