diff --git a/CHANGELOG.md b/CHANGELOG.md index 4a5fae3fca..684981b16f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,9 @@ # QOwnNotes Changelog ## 23.11.3 +- if the current note is encrypted, read-only or the doesn't exist any more now + some menu actions are also disabled to prevent writing to the note text edit + (for [#2904](https://github.com/pbek/QOwnNotes/issues/2904)) - a PPA for Ubuntu 24.04 (Noble Numbat) was added ## 23.11.2 diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 311ed62cb3..b60c583d33 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -3825,6 +3825,18 @@ void MainWindow::updateCurrentNoteTextHash() { .toHex()); } +void MainWindow::updateActionUiEnabled() { + const bool allowEditing = !ui->noteTextEdit->isReadOnly(); + + setMenuEnabled(ui->menuEditNote, allowEditing); + setMenuEnabled(ui->menuInsert, allowEditing); + setMenuEnabled(ui->menuFormat, allowEditing); + ui->actionPaste_image->setEnabled(allowEditing); + ui->actionReplace_in_current_note->setEnabled(allowEditing); + ui->actionAutocomplete->setEnabled(allowEditing); + ui->actionSplit_note_at_cursor_position->setEnabled(allowEditing); +} + /** * Sets the note text edit to readonly if the note does not exist or the * note file is not writable or the note is encrypted @@ -3837,6 +3849,9 @@ void MainWindow::updateNoteTextEditReadOnly() { ui->noteTextEdit->setReadOnly(true); } + // Also update the other UI elements + updateActionUiEnabled(); + ui->noteTextEdit->setTextInteractionFlags(ui->noteTextEdit->textInteractionFlags() | Qt::TextSelectableByKeyboard); } @@ -10842,14 +10857,7 @@ void MainWindow::on_actionAllow_note_editing_triggered(bool checked) { settings.setValue(QStringLiteral("allowNoteEditing"), checked); updateNoteTextEditReadOnly(); - setMenuEnabled(ui->menuEditNote, checked); - setMenuEnabled(ui->menuInsert, checked); - setMenuEnabled(ui->menuFormat, checked); setMenuEnabled(ui->menuEncryption, checked); - ui->actionPaste_image->setEnabled(checked); - ui->actionReplace_in_current_note->setEnabled(checked); - ui->actionAutocomplete->setEnabled(checked); - ui->actionSplit_note_at_cursor_position->setEnabled(checked); _readOnlyButton->setHidden(checked); ui->actionAllow_note_editing->setText(checked ? tr("Disallow all note editing") diff --git a/src/mainwindow.h b/src/mainwindow.h index 11f60b599a..054e693489 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -1100,4 +1100,5 @@ class MainWindow : public QMainWindow { void updateJumpToActionsAvailability(); int getNoteTabIndex(int noteId) const; bool startAutoReadOnlyModeIfEnabled(); + void updateActionUiEnabled(); };