Skip to content

Commit b03021c

Browse files
committed
#3489 notefolder: allow switching note folders when other note folder uses the same path
Signed-off-by: Patrizio Bekerle <patrizio@bekerle.com>
1 parent 74db893 commit b03021c

File tree

2 files changed

+35
-22
lines changed

2 files changed

+35
-22
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
- Fixed the default note sorting in the "Link to a URL or note" dialog regressing
1515
to alphabetical order when note subfolders are disabled; it now again defaults
1616
to modification date descending (for [#3482](https://github.com/pbek/QOwnNotes/issues/3482))
17+
- Fixed switching note folders from the selector when multiple configured note
18+
folders point to the same local directory, ensuring folder-specific UI state
19+
like subfolder panel visibility updates correctly (for [#3489](https://github.com/pbek/QOwnNotes/issues/3489))
1720

1821
## 26.3.5
1922

src/mainwindow.cpp

Lines changed: 32 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2059,8 +2059,14 @@ bool MainWindow::changeNoteFolder(const int noteFolderId, const bool forceChange
20592059
QString folderName = noteFolder.getLocalPath();
20602060
const QString oldPath = this->notesPath;
20612061

2062+
// Switch the active note folder first so all subsequent refresh steps
2063+
// (including combo/menu rebuilding) use the correct current folder.
2064+
noteFolder.setAsCurrent();
2065+
2066+
const bool notesPathChanged = (oldPath != folderName);
2067+
20622068
// reload notes if notes folder was changed
2063-
if (oldPath != folderName) {
2069+
if (notesPathChanged) {
20642070
const QSignalBlocker blocker2(this->ui->searchLineEdit);
20652071
{
20662072
Q_UNUSED(blocker2)
@@ -2073,8 +2079,6 @@ bool MainWindow::changeNoteFolder(const int noteFolderId, const bool forceChange
20732079
// commit the changes in the current note folder to git
20742080
gitCommitCurrentNoteFolder();
20752081

2076-
noteFolder.setAsCurrent();
2077-
20782082
// update the recent note folder list
20792083
storeRecentNoteFolder(this->notesPath, folderName);
20802084

@@ -2092,34 +2096,40 @@ bool MainWindow::changeNoteFolder(const int noteFolderId, const bool forceChange
20922096
// we have to unset the current note otherwise it might show up after
20932097
// switching to another note folder
20942098
unsetCurrentNote();
2099+
} else {
2100+
// Keep selector and Note -> Note folders menu in sync when switching
2101+
// between folders that share the same path.
2102+
loadNoteFolderListMenu();
2103+
}
20952104

2096-
buildNotesIndexAndLoadNoteDirectoryList(false, false, false);
2105+
buildNotesIndexAndLoadNoteDirectoryList(false, !notesPathChanged, false);
20972106

2098-
// update the current folder tooltip
2099-
updateCurrentFolderTooltip();
2107+
// update the current folder tooltip
2108+
updateCurrentFolderTooltip();
21002109

2101-
// restore the note tabs
2102-
Utils::Gui::restoreNoteTabs(ui->noteEditTabWidget, ui->noteEditTabWidgetLayout);
2110+
// restore the note tabs
2111+
Utils::Gui::restoreNoteTabs(ui->noteEditTabWidget, ui->noteEditTabWidgetLayout);
21032112

2104-
// restore the note history of the new note folder
2105-
noteHistory.restoreForCurrentNoteFolder();
2113+
// restore the note history of the new note folder
2114+
noteHistory.restoreForCurrentNoteFolder();
21062115

2107-
// check if there is a note name set and jump to it
2108-
QString noteName = _activeNoteFolderNotePositions[noteFolderId].getNoteName();
2116+
// check if there is a note name set and jump to it
2117+
QString noteName = _activeNoteFolderNotePositions[noteFolderId].getNoteName();
21092118

2110-
// if there was no NoteHistory found try the note history
2111-
if (noteName.isEmpty()) {
2112-
_activeNoteFolderNotePositions[noteFolderId] = noteHistory.getCurrentHistoryItem();
2113-
noteName = _activeNoteFolderNotePositions[noteFolderId].getNoteName();
2114-
}
2119+
// if there was no NoteHistory found try the note history
2120+
if (noteName.isEmpty()) {
2121+
_activeNoteFolderNotePositions[noteFolderId] = noteHistory.getCurrentHistoryItem();
2122+
noteName = _activeNoteFolderNotePositions[noteFolderId].getNoteName();
2123+
}
21152124

2116-
if (!noteName.isEmpty()) {
2117-
jumpToNoteName(noteName);
2125+
if (!noteName.isEmpty()) {
2126+
jumpToNoteName(noteName);
21182127

2119-
// restore the current position in the note
2120-
_activeNoteFolderNotePositions[noteFolderId].restoreTextEditPosition(ui->noteTextEdit);
2121-
}
2128+
// restore the current position in the note
2129+
_activeNoteFolderNotePositions[noteFolderId].restoreTextEditPosition(ui->noteTextEdit);
2130+
}
21222131

2132+
if (notesPathChanged) {
21232133
// commit the changes in the selected note folder to git
21242134
gitCommitCurrentNoteFolder();
21252135
}

0 commit comments

Comments
 (0)