diff --git a/new-note-namer/info.json b/new-note-namer/info.json index ba4db6e..ad33d4c 100644 --- a/new-note-namer/info.json +++ b/new-note-namer/info.json @@ -2,9 +2,9 @@ "name": "New note namer", "identifier": "new-note-namer", "script": "new-note-namer.qml", - "authors": ["@diegovskytl"], + "authors": ["@diegovskytl", "@Mystechry"], "platforms": ["linux", "macos", "windows"], - "version": "0.0.1", + "version": "0.0.2", "minAppVersion": "17.06.2", "description": "Enables a dialog window (or two) so the user can choose the note title and file name at the moment of creation.
Specially useful when the 'Allow note file name to be different to note title. \n No more cumbersome renaming :)" } diff --git a/new-note-namer/new-note-namer.qml b/new-note-namer/new-note-namer.qml index 9cf4431..e8c9f74 100644 --- a/new-note-namer/new-note-namer.qml +++ b/new-note-namer/new-note-namer.qml @@ -8,6 +8,7 @@ import QOwnNotesTypes 1.0 */ QtObject { property bool extraDialogForFileName; + property bool underlineHeading; property variant settingsVariables: [ { 'identifier': 'extraDialogForFileName', @@ -16,6 +17,13 @@ QtObject { 'type': 'boolean', 'default': 'false', }, + { + 'identifier': 'underlineHeading', + 'name': 'Underline heading', + 'description': 'Highlight the first line by underlining it with =, if not checked, use a preceding # instead.', + 'type': 'boolean', + 'default': 'false', + }, ]; function init() { @@ -41,7 +49,11 @@ QtObject { script.log(note.fileCreated) script.log(note.fileLastModified) - return "# " + newName; + if (underlineHeading) { + return newName + "\n" + "=".repeat(newName.length); + } else { + return "# " + newName; + } } function handleNoteTextFileNameHook(note) { @@ -52,7 +64,10 @@ QtObject { var noteLines = note.noteText.split("\n"); var firstLine = noteLines[0]; - var noteTitle = firstLine.slice(2) + var noteTitle = firstLine.slice(2) // Remove the preceding "# " + if (underlineHeading){ // Underlined headings use the entire first line + noteTitle = firstLine; + } script.log("note title: " + noteTitle) @@ -62,10 +77,9 @@ QtObject { return "" } - if (extraDialogForFileName){ - return newNamer("New note", "New file name", "File name") - } - else{ + if (extraDialogForFileName) { + return newNamer("New note", "New file name", "File name") + } else { return noteTitle } }