Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update journal-entry.qml #251

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 27 additions & 4 deletions journal-entry/journal-entry.qml
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@ QtObject {
if (!noteTitleFormat || noteTitleFormat.length == 0) {
headline = "Journal " + m.getFullYear() + ("0" + (m.getMonth()+1)).slice(-2) + ("0" + m.getDate()).slice(-2);
} else {
headline = noteTitleFormat.replace(/{[^}]*}/g, function(match) {
return formatDate(m, match.slice(1, -1));
headline = noteTitleFormat.replace(/{[^}]*}/g, function(match) {
return formatDate(m, match.slice(1, -1));
});
}

Expand Down Expand Up @@ -165,8 +165,31 @@ QtObject {
}

// Create the new journal note.
script.createNote(headline + "\n" + '='.repeat(Math.max(4, headline.length)) + "\n\n" + noteBodyTemplate);

// Create the new journal note without the filename and empty line.
// Create the new journal note with only the body template content - code line shortened by ChatGPT.
script.createNote(noteBodyTemplate);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are three descriptions for this line now. Which one of them is the right one?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And you removed the headline, was this intentional?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lines 167 and 168 are the original ones, and should be deleted.

lines 168 and 169 in effect are the same. So, we could rephrase it as:
// Create the new journal note with only the body template content (= without the filename and empty line).

Removing the headline was intentional because I don't want the file name of the note repeated in the note itself, I never do that. Now this is something particular to me, and I understand you may want to keep it. In that case I will use my version of the .qml file.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lines 167 and 168 are the original ones, and should be deleted.
lines 168 and 169 in effect are the same. So, we could rephrase it as

Can you please delete the lines if they shouldn't be part of the script anymore? 😊

Removing the headline was intentional because I don't want the file name of the note repeated in the note itself, I never do that.

Ok, the headline generation is an integral part of the script. We would need a script setting to allow/disallow adding of the headline rather than just removing the code.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You marked this as resolved, but you didn't change anything. Was this an accident?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it was not an accident, I thought I was done. So what is required now?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the 2nd part: If you don't want to / can't create a setting, please add the removed code again.


// Wait for the note to be created and then rename it - new code lines to line 191 by ChatGPT.
function renameNoteWhenReady() {
const currentNote = script.currentNote();

if (currentNote) {
// Rename the note immediately
if (currentNote.allowDifferentFileName()) {
currentNote.renameNoteFile(headline);
// Force a refresh to ensure the filename update is reflected
mainWindow.buildNotesIndexAndLoadNoteDirectoryList(false, true);
script.setCurrentNote(currentNote); // Ensure focus stays on the newly created note
}
} else {
// If the note isn't ready yet, try again after a small delay
setTimeout(renameNoteWhenReady, 100);
}
}

// Call the renaming function after note creation
renameNoteWhenReady();

const currentNote = script.currentNote();

// rename the note file if needed
Expand Down