@@ -8541,7 +8541,30 @@ void MainWindow::reloadCurrentNoteTags() {
85418541 } else {
85428542 const QVector<Note> notes = selectedNotes ();
85438543 tagList = Tag::fetchAllOfNotes (notes);
8544- const QString notesSelectedText = tr (" %n notes selected" , " " , selectedNotesCount);
8544+
8545+ // Count notes and folders separately
8546+ const auto selectedItems = ui->noteTreeWidget ->selectedItems ();
8547+ int noteCount = 0 ;
8548+ int folderCount = 0 ;
8549+ for (const auto *item : selectedItems) {
8550+ const int itemType = item->data (0 , Qt::UserRole + 1 ).toInt ();
8551+ if (itemType == NoteType) {
8552+ noteCount++;
8553+ } else if (itemType == FolderType) {
8554+ folderCount++;
8555+ }
8556+ }
8557+
8558+ // Build selection text based on what's selected
8559+ QString notesSelectedText;
8560+ if (noteCount > 0 && folderCount > 0 ) {
8561+ notesSelectedText =
8562+ tr (" %n note(s) and %1 folder(s) selected" , " " , noteCount).arg (folderCount);
8563+ } else if (folderCount > 0 ) {
8564+ notesSelectedText = tr (" %n folder(s) selected" , " " , folderCount);
8565+ } else {
8566+ notesSelectedText = tr (" %n notes selected" , " " , noteCount);
8567+ }
85458568
85468569 ui->selectedTagsToolButton ->setText (QString::number (selectedNotesCount));
85478570 ui->selectedTagsToolButton ->setToolTip (notesSelectedText);
@@ -9884,20 +9907,53 @@ void MainWindow::on_noteTreeWidget_customContextMenuRequested(const QPoint pos)
98849907 }
98859908
98869909 const QPoint globalPos = ui->noteTreeWidget ->mapToGlobal (pos);
9887- const int type = item->data (0 , Qt::UserRole + 1 ).toInt ();
9910+ const auto selectedItems = ui->noteTreeWidget ->selectedItems ();
9911+
9912+ // Check if we have a mixed selection of notes and folders
9913+ bool hasNotes = false ;
9914+ bool hasFolders = false ;
9915+ for (const auto *selectedItem : selectedItems) {
9916+ const int itemType = selectedItem->data (0 , Qt::UserRole + 1 ).toInt ();
9917+ if (itemType == NoteType) {
9918+ hasNotes = true ;
9919+ } else if (itemType == FolderType) {
9920+ hasFolders = true ;
9921+ }
9922+ if (hasNotes && hasFolders) {
9923+ break ;
9924+ }
9925+ }
98889926
9889- if (type == FolderType) {
9927+ // If we have a mixed selection or notes, show the notes context menu
9928+ // (which now supports both notes and folders)
9929+ if (hasNotes || (hasNotes && hasFolders)) {
9930+ openNotesContextMenu (globalPos, hasNotes, hasFolders);
9931+ } else if (hasFolders) {
9932+ // Only folders selected, show folder-specific context menu
98909933 std::unique_ptr<QMenu> menu (NoteSubFolderTree::contextMenu (ui->noteTreeWidget ));
98919934 menu->exec (globalPos);
9892- } else if (type == NoteType) {
9893- openNotesContextMenu (globalPos);
98949935 }
98959936}
98969937
9897- void MainWindow::openNotesContextMenu (const QPoint globalPos, bool multiNoteMenuEntriesOnly ) {
9938+ void MainWindow::openNotesContextMenu (const QPoint globalPos, bool hasNotes, bool hasFolders ) {
98989939 QMenu noteMenu;
98999940 QAction *renameAction = nullptr ;
99009941
9942+ // Calculate counts for proper labels
9943+ const auto selectedItems = ui->noteTreeWidget ->selectedItems ();
9944+ int noteCount = 0 ;
9945+ int folderCount = 0 ;
9946+ for (const auto *item : selectedItems) {
9947+ const int itemType = item->data (0 , Qt::UserRole + 1 ).toInt ();
9948+ if (itemType == NoteType) {
9949+ noteCount++;
9950+ } else if (itemType == FolderType) {
9951+ folderCount++;
9952+ }
9953+ }
9954+
9955+ bool multiNoteMenuEntriesOnly = (noteCount + folderCount) > 1 ;
9956+
99019957 if (!multiNoteMenuEntriesOnly) {
99029958 auto *createNoteAction = noteMenu.addAction (tr (" New note" ));
99039959 connect (createNoteAction, &QAction::triggered, this ,
@@ -9909,7 +9965,16 @@ void MainWindow::openNotesContextMenu(const QPoint globalPos, bool multiNoteMenu
99099965 " the note" ));
99109966 }
99119967
9912- auto *removeAction = noteMenu.addAction (tr (" &Remove notes" ));
9968+ // Set dynamic remove action text based on selection
9969+ QString removeActionText;
9970+ if (hasNotes && hasFolders) {
9971+ removeActionText = tr (" &Remove notes and folders" );
9972+ } else if (hasFolders) {
9973+ removeActionText = tr (" &Remove folders" );
9974+ } else {
9975+ removeActionText = tr (" &Remove notes" );
9976+ }
9977+ auto *removeAction = noteMenu.addAction (removeActionText);
99139978 noteMenu.addSeparator ();
99149979
99159980 const QList<NoteFolder> noteFolders = NoteFolder::fetchAll ();
@@ -9974,7 +10039,6 @@ void MainWindow::openNotesContextMenu(const QPoint globalPos, bool multiNoteMenu
997410039 }
997510040
997610041 QStringList noteNameList;
9977- const auto selectedItems = ui->noteTreeWidget ->selectedItems ();
997810042 for (QTreeWidgetItem *item : selectedItems) {
997910043 // the note names are not unique anymore but the note subfolder
998010044 // path will be taken into account in
0 commit comments