From 553f759d89c815e16e0ec910738691d88cfb8c1f Mon Sep 17 00:00:00 2001 From: kolcz <17905157+kolcz@users.noreply.github.com> Date: Sat, 28 Jun 2025 23:24:42 +0200 Subject: [PATCH 1/9] Add message box --- src/NotepadNext/dialogs/MainWindow.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/NotepadNext/dialogs/MainWindow.cpp b/src/NotepadNext/dialogs/MainWindow.cpp index 30df2415c..0b49e0249 100644 --- a/src/NotepadNext/dialogs/MainWindow.cpp +++ b/src/NotepadNext/dialogs/MainWindow.cpp @@ -1853,8 +1853,16 @@ bool MainWindow::checkFileForModification(ScintillaNext *editor) return false; } else if (state == ScintillaNext::Modified) { + // TODO: remove Application name from title / check behaviour in code + // TODO: add finding links + // TODO: add flag to stop reloading qInfo("ScintillaNext::Modified"); - editor->reload(); + const QString filePath = editor->getFilePath(); + auto reply = QMessageBox::question(this, tr("Reload"), tr("\"%1\"

This file has been modified by another program.
Do you want to reload it?").arg(filePath)); + + if (reply == QMessageBox::Yes) { + editor->reload(); + } } else if (state == ScintillaNext::Deleted) { qInfo("ScintillaNext::Deleted"); From 7be7c02544c3a85e9cd233a0584e052ed3794638 Mon Sep 17 00:00:00 2001 From: kolcz <17905157+kolcz@users.noreply.github.com> Date: Tue, 1 Jul 2025 10:31:47 -0500 Subject: [PATCH 2/9] Remove one TODO and precise another TODO task --- src/NotepadNext/dialogs/MainWindow.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/NotepadNext/dialogs/MainWindow.cpp b/src/NotepadNext/dialogs/MainWindow.cpp index 0b49e0249..84fcc89b2 100644 --- a/src/NotepadNext/dialogs/MainWindow.cpp +++ b/src/NotepadNext/dialogs/MainWindow.cpp @@ -1853,8 +1853,7 @@ bool MainWindow::checkFileForModification(ScintillaNext *editor) return false; } else if (state == ScintillaNext::Modified) { - // TODO: remove Application name from title / check behaviour in code - // TODO: add finding links + // TODO: add connect to URLFinder signal // TODO: add flag to stop reloading qInfo("ScintillaNext::Modified"); const QString filePath = editor->getFilePath(); From dcdbec1f2c854f9b4d7efc222d79461ed71bef61 Mon Sep 17 00:00:00 2001 From: kolcz <17905157+kolcz@users.noreply.github.com> Date: Tue, 1 Jul 2025 23:13:27 +0200 Subject: [PATCH 3/9] Set editor as temporary --- src/NotepadNext/dialogs/MainWindow.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/NotepadNext/dialogs/MainWindow.cpp b/src/NotepadNext/dialogs/MainWindow.cpp index 84fcc89b2..6cd80a1a7 100644 --- a/src/NotepadNext/dialogs/MainWindow.cpp +++ b/src/NotepadNext/dialogs/MainWindow.cpp @@ -1854,7 +1854,7 @@ bool MainWindow::checkFileForModification(ScintillaNext *editor) } else if (state == ScintillaNext::Modified) { // TODO: add connect to URLFinder signal - // TODO: add flag to stop reloading + // TODO: add flag to stop spawning message box qInfo("ScintillaNext::Modified"); const QString filePath = editor->getFilePath(); auto reply = QMessageBox::question(this, tr("Reload"), tr("\"%1\"

This file has been modified by another program.
Do you want to reload it?").arg(filePath)); @@ -1862,6 +1862,9 @@ bool MainWindow::checkFileForModification(ScintillaNext *editor) if (reply == QMessageBox::Yes) { editor->reload(); } + else { + editor->setTemporary(true); + } } else if (state == ScintillaNext::Deleted) { qInfo("ScintillaNext::Deleted"); From fb664a00cf31a2d4df0c9042c6af1b9cb0b30006 Mon Sep 17 00:00:00 2001 From: kolcz <17905157+kolcz@users.noreply.github.com> Date: Wed, 2 Jul 2025 10:27:47 -0500 Subject: [PATCH 4/9] Connect signal ScintillaNext::modified to URLFinder --- src/NotepadNext/decorators/URLFinder.cpp | 1 + src/NotepadNext/dialogs/MainWindow.cpp | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/src/NotepadNext/decorators/URLFinder.cpp b/src/NotepadNext/decorators/URLFinder.cpp index 66a124d53..b8b753bd8 100644 --- a/src/NotepadNext/decorators/URLFinder.cpp +++ b/src/NotepadNext/decorators/URLFinder.cpp @@ -46,6 +46,7 @@ URLFinder::URLFinder(ScintillaNext *editor) : connect(this, &EditorDecorator::stateChanged, this, [=](bool b) { if (b) { connect(editor, &ScintillaNext::resized, timer, qOverload<>(&QTimer::start)); + connect(editor, &ScintillaNext::modified, timer, qOverload<>(&QTimer::start)); findURLs(); } else { diff --git a/src/NotepadNext/dialogs/MainWindow.cpp b/src/NotepadNext/dialogs/MainWindow.cpp index 6cd80a1a7..36d4f7f93 100644 --- a/src/NotepadNext/dialogs/MainWindow.cpp +++ b/src/NotepadNext/dialogs/MainWindow.cpp @@ -1853,7 +1853,6 @@ bool MainWindow::checkFileForModification(ScintillaNext *editor) return false; } else if (state == ScintillaNext::Modified) { - // TODO: add connect to URLFinder signal // TODO: add flag to stop spawning message box qInfo("ScintillaNext::Modified"); const QString filePath = editor->getFilePath(); From 6b6c215fdb663010098270a2bbcdef9a35145970 Mon Sep 17 00:00:00 2001 From: kolcz <17905157+kolcz@users.noreply.github.com> Date: Sat, 5 Jul 2025 22:57:15 +0200 Subject: [PATCH 5/9] Add omitModifications function in ScintillaNext class and unset temporary flag after reload --- src/NotepadNext/ScintillaNext.cpp | 13 +++++++++++++ src/NotepadNext/ScintillaNext.h | 1 + src/NotepadNext/dialogs/MainWindow.cpp | 4 ++-- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/NotepadNext/ScintillaNext.cpp b/src/NotepadNext/ScintillaNext.cpp index 68b92567f..a514fa513 100644 --- a/src/NotepadNext/ScintillaNext.cpp +++ b/src/NotepadNext/ScintillaNext.cpp @@ -347,11 +347,24 @@ void ScintillaNext::reload() if (readSuccessful) { updateTimestamp(); setSavePoint(); + + // If this was a temporary file, make sure it is not any more + setTemporary(false); } return; } +void ScintillaNext::omitModifications() +{ + // If file modifications will be ommited just update file timestamp + // so pop-up will be displayed only once per file modifications. + updateTimestamp(); + setTemporary(true); + + return; +} + QFileDevice::FileError ScintillaNext::saveAs(const QString &newFilePath) { bool isRenamed = bufferType == ScintillaNext::New || fileInfo.canonicalFilePath() != newFilePath; diff --git a/src/NotepadNext/ScintillaNext.h b/src/NotepadNext/ScintillaNext.h index 5d3d38bf8..447dfbe22 100644 --- a/src/NotepadNext/ScintillaNext.h +++ b/src/NotepadNext/ScintillaNext.h @@ -122,6 +122,7 @@ public slots: void close(); QFileDevice::FileError save(); void reload(); + void omitModifications(); QFileDevice::FileError saveAs(const QString &newFilePath); QFileDevice::FileError saveCopyAs(const QString &filePath); bool rename(const QString &newFilePath); diff --git a/src/NotepadNext/dialogs/MainWindow.cpp b/src/NotepadNext/dialogs/MainWindow.cpp index 36d4f7f93..72215d1f8 100644 --- a/src/NotepadNext/dialogs/MainWindow.cpp +++ b/src/NotepadNext/dialogs/MainWindow.cpp @@ -1853,7 +1853,7 @@ bool MainWindow::checkFileForModification(ScintillaNext *editor) return false; } else if (state == ScintillaNext::Modified) { - // TODO: add flag to stop spawning message box + // TODO: remain cursor position after reload qInfo("ScintillaNext::Modified"); const QString filePath = editor->getFilePath(); auto reply = QMessageBox::question(this, tr("Reload"), tr("\"%1\"

This file has been modified by another program.
Do you want to reload it?").arg(filePath)); @@ -1862,7 +1862,7 @@ bool MainWindow::checkFileForModification(ScintillaNext *editor) editor->reload(); } else { - editor->setTemporary(true); + editor->omitModifications(); } } else if (state == ScintillaNext::Deleted) { From 8ad5d57b5bd68f16636a3f324a9de97c20bd9789 Mon Sep 17 00:00:00 2001 From: kolcz <17905157+kolcz@users.noreply.github.com> Date: Sat, 5 Jul 2025 23:04:14 +0200 Subject: [PATCH 6/9] Remove TODO comment, because task is assigned in issue #773 --- src/NotepadNext/dialogs/MainWindow.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/NotepadNext/dialogs/MainWindow.cpp b/src/NotepadNext/dialogs/MainWindow.cpp index 72215d1f8..1fb3a5ad0 100644 --- a/src/NotepadNext/dialogs/MainWindow.cpp +++ b/src/NotepadNext/dialogs/MainWindow.cpp @@ -1853,7 +1853,6 @@ bool MainWindow::checkFileForModification(ScintillaNext *editor) return false; } else if (state == ScintillaNext::Modified) { - // TODO: remain cursor position after reload qInfo("ScintillaNext::Modified"); const QString filePath = editor->getFilePath(); auto reply = QMessageBox::question(this, tr("Reload"), tr("\"%1\"

This file has been modified by another program.
Do you want to reload it?").arg(filePath)); From c45396ac475aa3bc1cea3e986eaa5c820388ac27 Mon Sep 17 00:00:00 2001 From: kolcz <17905157+kolcz@users.noreply.github.com> Date: Sat, 5 Jul 2025 23:53:33 +0200 Subject: [PATCH 7/9] Fix spelling error --- src/NotepadNext/ScintillaNext.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/NotepadNext/ScintillaNext.cpp b/src/NotepadNext/ScintillaNext.cpp index a514fa513..af3ca3321 100644 --- a/src/NotepadNext/ScintillaNext.cpp +++ b/src/NotepadNext/ScintillaNext.cpp @@ -357,7 +357,7 @@ void ScintillaNext::reload() void ScintillaNext::omitModifications() { - // If file modifications will be ommited just update file timestamp + // If file modifications will be omitted just update file timestamp // so pop-up will be displayed only once per file modifications. updateTimestamp(); setTemporary(true); From 4655fe222fbd336995c800afd628cb070545f019 Mon Sep 17 00:00:00 2001 From: kolcz <17905157+kolcz@users.noreply.github.com> Date: Mon, 7 Jul 2025 10:36:26 -0500 Subject: [PATCH 8/9] Remove setting to temporary, change signal from modified to reloaded and edit message box text --- src/NotepadNext/ScintillaNext.cpp | 5 ++--- src/NotepadNext/ScintillaNext.h | 1 + src/NotepadNext/decorators/URLFinder.cpp | 2 +- src/NotepadNext/dialogs/MainWindow.cpp | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/NotepadNext/ScintillaNext.cpp b/src/NotepadNext/ScintillaNext.cpp index af3ca3321..2b424cfac 100644 --- a/src/NotepadNext/ScintillaNext.cpp +++ b/src/NotepadNext/ScintillaNext.cpp @@ -348,8 +348,7 @@ void ScintillaNext::reload() updateTimestamp(); setSavePoint(); - // If this was a temporary file, make sure it is not any more - setTemporary(false); + emit reloaded(); } return; @@ -360,7 +359,7 @@ void ScintillaNext::omitModifications() // If file modifications will be omitted just update file timestamp // so pop-up will be displayed only once per file modifications. updateTimestamp(); - setTemporary(true); + emit savePointChanged(true); // TODO: find another signal to mark as dirty return; } diff --git a/src/NotepadNext/ScintillaNext.h b/src/NotepadNext/ScintillaNext.h index 447dfbe22..70a1f07b4 100644 --- a/src/NotepadNext/ScintillaNext.h +++ b/src/NotepadNext/ScintillaNext.h @@ -140,6 +140,7 @@ public slots: void renamed(); void lexerChanged(); + void reloaded(); protected: void dragEnterEvent(QDragEnterEvent *event) override; diff --git a/src/NotepadNext/decorators/URLFinder.cpp b/src/NotepadNext/decorators/URLFinder.cpp index b8b753bd8..f0b2242bc 100644 --- a/src/NotepadNext/decorators/URLFinder.cpp +++ b/src/NotepadNext/decorators/URLFinder.cpp @@ -46,7 +46,7 @@ URLFinder::URLFinder(ScintillaNext *editor) : connect(this, &EditorDecorator::stateChanged, this, [=](bool b) { if (b) { connect(editor, &ScintillaNext::resized, timer, qOverload<>(&QTimer::start)); - connect(editor, &ScintillaNext::modified, timer, qOverload<>(&QTimer::start)); + connect(editor, &ScintillaNext::reloaded, timer, qOverload<>(&QTimer::start)); findURLs(); } else { diff --git a/src/NotepadNext/dialogs/MainWindow.cpp b/src/NotepadNext/dialogs/MainWindow.cpp index 1fb3a5ad0..84be9ebbb 100644 --- a/src/NotepadNext/dialogs/MainWindow.cpp +++ b/src/NotepadNext/dialogs/MainWindow.cpp @@ -1855,7 +1855,7 @@ bool MainWindow::checkFileForModification(ScintillaNext *editor) else if (state == ScintillaNext::Modified) { qInfo("ScintillaNext::Modified"); const QString filePath = editor->getFilePath(); - auto reply = QMessageBox::question(this, tr("Reload"), tr("\"%1\"

This file has been modified by another program.
Do you want to reload it?").arg(filePath)); + auto reply = QMessageBox::question(this, tr("Reload File"), tr("%1 has been modified by another program. Do you want to reload it?").arg(filePath)); if (reply == QMessageBox::Yes) { editor->reload(); From 09446a115e2dc82555234d446cdfc505c899c383 Mon Sep 17 00:00:00 2001 From: kolcz <17905157+kolcz@users.noreply.github.com> Date: Wed, 9 Jul 2025 11:10:11 -0500 Subject: [PATCH 9/9] Revert to setting temporary flag --- src/NotepadNext/ScintillaNext.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/NotepadNext/ScintillaNext.cpp b/src/NotepadNext/ScintillaNext.cpp index 2b424cfac..9f091a480 100644 --- a/src/NotepadNext/ScintillaNext.cpp +++ b/src/NotepadNext/ScintillaNext.cpp @@ -348,6 +348,9 @@ void ScintillaNext::reload() updateTimestamp(); setSavePoint(); + // If this was a temporary file, make sure it is not any more + setTemporary(false); + emit reloaded(); } @@ -359,7 +362,7 @@ void ScintillaNext::omitModifications() // If file modifications will be omitted just update file timestamp // so pop-up will be displayed only once per file modifications. updateTimestamp(); - emit savePointChanged(true); // TODO: find another signal to mark as dirty + setTemporary(true); return; }