mirror of
https://github.com/marty-oehme/scripts.git
synced 2024-12-22 07:58:08 +00:00
added the meeting-note script
This commit is contained in:
parent
e27872ddc3
commit
602a37c5b2
2 changed files with 71 additions and 0 deletions
9
meeting-note/info.json
Normal file
9
meeting-note/info.json
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
{
|
||||||
|
"name": "Meeting note",
|
||||||
|
"identifier": "meeting-note",
|
||||||
|
"script": "meeting-note.qml",
|
||||||
|
"authors": ["@pbek"],
|
||||||
|
"version": "0.0.1",
|
||||||
|
"minAppVersion": "17.05.7",
|
||||||
|
"description" : "This script creates a menu item and a button to create or jump to the current date's meeting note."
|
||||||
|
}
|
62
meeting-note/meeting-note.qml
Normal file
62
meeting-note/meeting-note.qml
Normal file
|
@ -0,0 +1,62 @@
|
||||||
|
import QtQml 2.0
|
||||||
|
import com.qownnotes.noteapi 1.0
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This script creates a menu item and a button to create or jump to the current date's meeting note
|
||||||
|
*/
|
||||||
|
QtObject {
|
||||||
|
property string headlinePrefix;
|
||||||
|
|
||||||
|
// register your settings variables so the user can set them in the script settings
|
||||||
|
property variant settingsVariables: [
|
||||||
|
{
|
||||||
|
"identifier": "headlinePrefix",
|
||||||
|
"name": "Headline prefix",
|
||||||
|
"description": "Please enter a prefix for your note headline:",
|
||||||
|
"type": "string",
|
||||||
|
"default": "Teammeeting",
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes the custom action
|
||||||
|
*/
|
||||||
|
function init() {
|
||||||
|
script.registerCustomAction("meetingNote", "Create or open a meeting note", "Meeting", "document-new");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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 != "meetingNote") {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// get the date headline
|
||||||
|
var m = new Date();
|
||||||
|
var headline = headlinePrefix + " " + m.getFullYear() + "-" + ("0" + (m.getMonth()+1)).slice(-2) + "-" + ("0" + m.getDate()).slice(-2);
|
||||||
|
|
||||||
|
var fileName = headline + ".md";
|
||||||
|
var note = script.fetchNoteByFileName(fileName);
|
||||||
|
|
||||||
|
// check if note was found
|
||||||
|
if (note.id > 0) {
|
||||||
|
// jump to the note if it was found
|
||||||
|
script.log("found meeting note: " + headline);
|
||||||
|
script.setCurrentNote(note);
|
||||||
|
} else {
|
||||||
|
// create a new meeting note if it wasn't found
|
||||||
|
// keep in mind that the note will not be created instantly on the disk
|
||||||
|
script.log("creating new meeting note: " + headline);
|
||||||
|
script.createNote(headline + "\n====================\n\n");
|
||||||
|
|
||||||
|
// tag the current note
|
||||||
|
script.tagCurrentNote("meeting");
|
||||||
|
script.tagCurrentNote("fuf");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue