From d67df29a0e0379cc9032a57a08ca4159c07ea43c Mon Sep 17 00:00:00 2001 From: Mystechry <112656712+Mystechry@users.noreply.github.com> Date: Thu, 28 Nov 2024 19:57:49 +0100 Subject: [PATCH 1/5] Added toggle to underline the created heading, instead of highlighting it with a preceding hashtag --- new-note-namer/new-note-namer.qml | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/new-note-namer/new-note-namer.qml b/new-note-namer/new-note-namer.qml index 9cf4431..cf7b21a 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========================" + } else { + return "# " + newName; + } } function handleNoteTextFileNameHook(note) { From 67e1b2bee48d29b057dbc5fe03f974264c02d077 Mon Sep 17 00:00:00 2001 From: Mystechry <112656712+Mystechry@users.noreply.github.com> Date: Thu, 28 Nov 2024 20:00:38 +0100 Subject: [PATCH 2/5] Updated info.json --- new-note-namer/info.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/new-note-namer/info.json b/new-note-namer/info.json index ba4db6e..5ec3028 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 :)" } From 245ce3ab3f0defefd8cd48fc7d6930d6f3d1f250 Mon Sep 17 00:00:00 2001 From: Mystechry <112656712+Mystechry@users.noreply.github.com> Date: Thu, 28 Nov 2024 21:02:25 +0100 Subject: [PATCH 3/5] Update new-note-namer.qml 1. Count heading length and adapt the number of '=' characters used for underlining the heading 2. Fixed bug where the first 2 characters were cut from the file name when using '=' to highlight the heading 3. Unified some whitespaces --- new-note-namer/new-note-namer.qml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/new-note-namer/new-note-namer.qml b/new-note-namer/new-note-namer.qml index cf7b21a..6abd98a 100644 --- a/new-note-namer/new-note-namer.qml +++ b/new-note-namer/new-note-namer.qml @@ -50,7 +50,7 @@ QtObject { script.log(note.fileLastModified) if (underlineHeading){ - return newName + "\n========================" + return newName + "\n" + "=".repeat(newName.length); } else { return "# " + newName; } @@ -64,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) @@ -75,7 +78,7 @@ QtObject { } if (extraDialogForFileName){ - return newNamer("New note", "New file name", "File name") + return newNamer("New note", "New file name", "File name") } else{ return noteTitle From 95283ed8fa8e75bb3665afad21784c9964ea4c69 Mon Sep 17 00:00:00 2001 From: Mystechry <112656712+Mystechry@users.noreply.github.com> Date: Thu, 28 Nov 2024 21:03:32 +0100 Subject: [PATCH 4/5] Properly updated the 'authors' array in info.json --- new-note-namer/info.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/new-note-namer/info.json b/new-note-namer/info.json index 5ec3028..ad33d4c 100644 --- a/new-note-namer/info.json +++ b/new-note-namer/info.json @@ -2,7 +2,7 @@ "name": "New note namer", "identifier": "new-note-namer", "script": "new-note-namer.qml", - "authors": ["@diegovskytl,@Mystechry"], + "authors": ["@diegovskytl", "@Mystechry"], "platforms": ["linux", "macos", "windows"], "version": "0.0.2", "minAppVersion": "17.06.2", From 03b91a75284d844c472b1fe4923364c986d43f08 Mon Sep 17 00:00:00 2001 From: Mystechry <112656712+Mystechry@users.noreply.github.com> Date: Thu, 28 Nov 2024 21:08:22 +0100 Subject: [PATCH 5/5] Fixed bad spacing --- new-note-namer/new-note-namer.qml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/new-note-namer/new-note-namer.qml b/new-note-namer/new-note-namer.qml index 6abd98a..e8c9f74 100644 --- a/new-note-namer/new-note-namer.qml +++ b/new-note-namer/new-note-namer.qml @@ -49,7 +49,7 @@ QtObject { script.log(note.fileCreated) script.log(note.fileLastModified) - if (underlineHeading){ + if (underlineHeading) { return newName + "\n" + "=".repeat(newName.length); } else { return "# " + newName; @@ -77,10 +77,9 @@ QtObject { return "" } - if (extraDialogForFileName){ + if (extraDialogForFileName) { return newNamer("New note", "New file name", "File name") - } - else{ + } else { return noteTitle } }