pbek / QOwnNotes

QOwnNotes is a plain-text file notepad and todo-list manager with Markdown support and Nextcloud / ownCloud integration.
https://www.qownnotes.org/
GNU General Public License v2.0
4.68k stars 414 forks source link

[FEATURE] Option to show full file path in statusbar #3023

Closed justinbeaty closed 5 months ago

justinbeaty commented 6 months ago

Is your feature request related to a problem? Please describe.

I use subfolders and it would be helpful to see the full file path of the note I currently have open. Sometimes I may have notes with the same filename in multiple folders.

Describe the solution you'd like

It would be beneficial to see the full file path in the status bar, or even the relative path to the notes root folder. Something like this:

image

I created a patch, but it's only a proof of concept.

diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index e790a37b3..0728875dd 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -3068,6 +3068,15 @@ void MainWindow::setupStatusBarWidgets() {

     ui->statusBar->addPermanentWidget(_readOnlyButton);

+    /*
+     * setup of file path label
+     */
+    _noteFilePathLabel = new QLabel(this);
+    _noteFilePathLabel->setText(QStringLiteral(""));
+    _noteFilePathLabel->setToolTip(tr("Full file path"));
+
+    ui->statusBar->addWidget(_noteFilePathLabel);
+
     /*
      * setup of line number label
      */
@@ -3774,6 +3783,9 @@ void MainWindow::setCurrentNote(Note note, bool updateNoteText, bool updateSelec
     // call a script hook that a new note was opened
     ScriptingService::instance()->callHandleNoteOpenedHook(&currentNote);

+    // update file path label
+    _noteFilePathLabel->setText(currentNote.fullNoteFilePath().toLatin1().data());
+
     //    putenv(QString("QOWNNOTES_CURRENT_NOTE_PATH=" + currentNote
     //            .fullNoteFilePath()).toLatin1().data());
     //    setenv("QOWNNOTES_CURRENT_NOTE_PATH",
diff --git a/src/mainwindow.h b/src/mainwindow.h
index f63f4fe63..e70b1ca59 100644
--- a/src/mainwindow.h
+++ b/src/mainwindow.h
@@ -755,6 +755,7 @@ class MainWindow : public QMainWindow {
     NoteHistory noteHistory;
     QHash<int, NoteHistoryItem> noteBookmarks;
     QPushButton *_updateAvailableButton;
+    QLabel *_noteFilePathLabel;
     QLabel *_noteEditLineNumberLabel;
     QPushButton *_readOnlyButton;
     QPushButton *_leaveDistractionFreeModeButton;

Describe alternatives you've considered

Unsure of any alternatives.

Additional context

This should probably be behind a setting option. Also, if the setting is off, then the label shouldn't show in the status bar else there's an empty spot you can hover over and see the tooltip. Thus, I think changing this option may require QOwnNotes to reload so we can reinitialize MainWindow::setupStatusBarWidgets.

Output from the debug section in the settings dialog

Expand
pbek commented 6 months ago

Currently, the left side is used to actually show when something is happening, e.g. notes got stored. 🤔

Normally, I'd say, you could implement that yourself with the help of https://www.qownnotes.org/scripting/methods-and-objects.html#registering-a-label.

But I'd even would look at a pull request in QOwnNotes, if you would want to work on that.

Some things that come to mind:

justinbeaty commented 6 months ago

Currently, the left side is used to actually show when something is happening, e.g. notes got stored. 🤔

Qt actually handles this by using addWidget instead of addPermanentWidget. I tested it by reloading the scripting engine via the menu. Usage of showStatusBarMessage will show the message for the timeout specified, and then it reverts back to displaying the file path.

But I'd even would look at a pull request in QOwnNotes, if you would want to work on that.

Some things that come to mind:

  • Resetting of that label when no note or a new note is selected would need to work better
  • There needs to be a new checkbox in the Editor settings to turn that feature on
  • It would maybe even nice to copy the path to the clipboard when double-clicking the note path

    • This action should then also be shown as status text for a status text

I'll work on a PR with these ideas in mind.

pbek commented 6 months ago

Great! 😉

pbek commented 5 months ago

Do you need any help, @justinbeaty?

pbek commented 5 months ago

I have something more with this in mind, I think I'll do it myself 😊

justinbeaty commented 5 months ago

Hey @pbek, I haven't even started working on it other than the patch in the first post. I'll be more than happy to defer back to you.

pbek commented 5 months ago

24.5.10

pbek commented 5 months ago

There now is a new release, could you please test it and report if it works for you?

pbek commented 5 months ago

Under Non-Windows OSes I replace the home-directory path by ~ to save space, do you think I should also do that under Windows or would that confuse people? 🤔

image

justinbeaty commented 5 months ago

@pbek This works great, I really appreciate the feature.

I'd be okay with ~ since I'm used to the convention, but it would probably confuse others. I think it's okay how it is.

I see only one small cosmetic problem, the very first slash after the document root C:/Users/Justin/Documents/Notes is black instead of dark grey.

image

Possible this only happens on Windows due to whatever method returning a trailing slash on one platform vs the other. Otherwise I tested absolute vs relative, long file names, etc, and all looked good.

pbek commented 5 months ago

Thank you, so I'll leave the full path.

slash

I did it in the foreground color on purpose to get another visual clue if the contrast (or eyesight) is not so good.

justinbeaty commented 5 months ago

Got it, then it’s working perfect for me. Thank you again for the feature!

pbek commented 5 months ago

Great! I'm thinking about turning the showing of the path on by default in the next release (it's now off by default)... Would this annoy you if you hadn't wished for the feature yourself? 😊

pbek commented 5 months ago

24.6.0

😉

justinbeaty commented 5 months ago

@pbek It wouldn't annoy me, and that sort of information used to be much more commonly displayed in status bars. Anyway with it being togglable, it shouldn't annoy anyone I wouldn't think.

pbek commented 5 months ago

Great, thank you. 😊