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

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

Closed
justinbeaty opened this issue May 7, 2024 · 16 comments
Closed

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

justinbeaty opened this issue May 7, 2024 · 16 comments
Labels
Milestone

Comments

@justinbeaty
Copy link

justinbeaty commented May 7, 2024

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
@justinbeaty justinbeaty changed the title [FEATURE] [FEATURE] Option to show full file path in statusbar May 7, 2024
@pbek
Copy link
Owner

pbek commented May 7, 2024

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:

  • 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

@pbek pbek added Type: Feature adds functionality Importance: Low and removed Type: Support labels May 7, 2024
@justinbeaty
Copy link
Author

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
Copy link
Owner

pbek commented May 8, 2024

Great! 😉

@pbek
Copy link
Owner

pbek commented May 28, 2024

Do you need any help, @justinbeaty?

@pbek
Copy link
Owner

pbek commented May 29, 2024

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

@justinbeaty
Copy link
Author

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
Copy link
Owner

pbek commented May 30, 2024

24.5.10

  • The absolute path of the current note will now be shown in the status bar
    (for #3023)
    • You can turn on and off the display of the path in the status bar in the
      Interface settings
      • There also is an option to only show the relative path of the note
    • Different shades are used for the note folder path, the subfolder path and
      the note file name
    • The text will be trimmed if there is not enough space to show the complete path
    • If you right-click the text, you will get a context menu to copy the absolute
      note path, the path of the note subfolder or the path of the note folder

@pbek pbek added this to the 24.5.10 milestone May 30, 2024
@pbek
Copy link
Owner

pbek commented May 30, 2024

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

@pbek
Copy link
Owner

pbek commented May 30, 2024

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
Copy link
Author

@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
Copy link
Owner

pbek commented May 30, 2024

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
Copy link
Author

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

@pbek
Copy link
Owner

pbek commented May 31, 2024

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
Copy link
Owner

pbek commented May 31, 2024

24.6.0

  • The absolute path of the current note will now be shown in the status bar
    by default (for #3023)

😉

@pbek pbek closed this as completed May 31, 2024
@justinbeaty
Copy link
Author

@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
Copy link
Owner

pbek commented May 31, 2024

Great, thank you. 😊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants