Skip to content

Commit d686c6e

Browse files
committed
#3366 note: don't show text diff dialog if note diff dialog is open
Signed-off-by: Patrizio Bekerle <[email protected]>
1 parent 84d20bd commit d686c6e

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed

src/entities/note.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#include "libraries/md4c/src/md4c-html.h"
3333
#include "libraries/md4c/src/md4c.h"
3434
#include "libraries/simplecrypt/simplecrypt.h"
35+
#include "mainwindow.h"
3536
#include "notefolder.h"
3637
#include "notesubfolder.h"
3738
#include "services/settingsservice.h"
@@ -1496,6 +1497,21 @@ bool Note::storeNoteTextFileToDisk(bool &currentNoteTextChanged,
14961497
if (currentChecksum != _fileChecksum) {
14971498
qWarning() << "Note file was modified externally, showing diff dialog";
14981499
#ifndef INTEGRATION_TESTS
1500+
// Check if NoteDiffDialog is open - if so, skip showing the diff dialog
1501+
MainWindow *mainWindow = MainWindow::instance();
1502+
if (mainWindow != nullptr && mainWindow->isNoteDiffDialogOpen()) {
1503+
qDebug() << "NoteDiffDialog is open, skipping TextDiffDialog";
1504+
// Just update the checksum and return false to prevent saving
1505+
_noteText = currentFileText;
1506+
_fileChecksum = currentChecksum;
1507+
1508+
if (wasCancelledDueToExternalModification != nullptr) {
1509+
*wasCancelledDueToExternalModification = true;
1510+
}
1511+
1512+
return false;
1513+
}
1514+
14991515
// Show diff dialog to let user decide what to do
15001516
TextDiffDialog dialog(
15011517
nullptr, QObject::tr("Note file was modified externally"),

src/mainwindow.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5726,6 +5726,13 @@ void MainWindow::filterNotes(bool searchForText) {
57265726
*/
57275727
bool MainWindow::isTagsEnabled() { return _taggingDockWidget->isVisible(); }
57285728

5729+
/**
5730+
* Checks if the NoteDiffDialog is currently open
5731+
*/
5732+
bool MainWindow::isNoteDiffDialogOpen() {
5733+
return noteDiffDialog != nullptr && noteDiffDialog->isVisible();
5734+
}
5735+
57295736
/**
57305737
* Checks if the Markdown view is enabled
57315738
*/

src/mainwindow.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -765,6 +765,7 @@ class MainWindow : public QMainWindow {
765765
public:
766766
void clearNoteDirectoryWatcher();
767767
void updateNoteDirectoryWatcher();
768+
bool isNoteDiffDialogOpen();
768769

769770
private:
770771
Ui::MainWindow *ui;

0 commit comments

Comments
 (0)