Skip to content

Commit 7a518c0

Browse files
committed
#3396 textdiffdialog: add checkbox to not show dialog again
Signed-off-by: Patrizio Bekerle <[email protected]>
1 parent 1f5cabf commit 7a518c0

File tree

6 files changed

+50
-3
lines changed

6 files changed

+50
-3
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# QOwnNotes Changelog
22

3+
## 25.11.4
4+
5+
- In the diff dialog shown the checksum checking of [#3366](https://github.com/pbek/QOwnNotes/issues/3366)
6+
doesn't match you can now choose not to show the dialog again, then the selected
7+
dialog result will be chosen automatically the next time [#3396](https://github.com/pbek/QOwnNotes/issues/3396)
8+
39
## 25.11.3
410

511
- There now is an extra detection of external changes to note files while your

src/dialogs/textdiffdialog.cpp

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,40 @@
44

55
#include <QAbstractButton>
66
#include <QDebug>
7+
#include <QTimer>
78

89
#include "services/settingsservice.h"
910
#include "ui_textdiffdialog.h"
1011

1112
TextDiffDialog::TextDiffDialog(QWidget *parent, const QString &title, const QString &labelText,
12-
const QString &text1, const QString &text2)
13+
const QString &text1, const QString &text2,
14+
const QString &identifier)
1315
: MasterDialog(parent), ui(new Ui::TextDiffDialog) {
1416
ui->setupUi(this);
1517
afterSetupUI();
1618
this->setWindowTitle(title);
1719
this->text1 = text1;
20+
this->identifier = identifier;
1821
this->ui->label_2->setText(labelText);
1922
this->ui->plainTextEdit->setPlainText(text2);
2023

24+
// Show or hide the "don't show again" checkbox based on identifier
25+
if (identifier.isEmpty()) {
26+
this->ui->dontShowAgainCheckBox->setVisible(false);
27+
} else {
28+
this->ui->dontShowAgainCheckBox->setVisible(true);
29+
30+
// Check if user has previously chosen to not show this dialog
31+
QString settingsKey = QStringLiteral("MessageBoxOverride/") + identifier;
32+
QVariant storedResult = SettingsService::instance().value(settingsKey);
33+
34+
if (storedResult.isValid()) {
35+
// Use the stored result and close immediately
36+
this->accepted = storedResult.toBool();
37+
QTimer::singleShot(0, this, &TextDiffDialog::close);
38+
}
39+
}
40+
2141
connect(this->ui->buttonBox, SIGNAL(clicked(QAbstractButton *)),
2242
SLOT(dialogButtonClicked(QAbstractButton *)));
2343
}
@@ -27,6 +47,13 @@ TextDiffDialog::~TextDiffDialog() { delete ui; }
2747
void TextDiffDialog::dialogButtonClicked(QAbstractButton *button) {
2848
auto buttonRole = this->ui->buttonBox->buttonRole(button);
2949
this->accepted = buttonRole == QDialogButtonBox::AcceptRole;
50+
51+
// Save the user's preference if "don't show again" is checked
52+
if (!this->identifier.isEmpty() && this->ui->dontShowAgainCheckBox->isChecked()) {
53+
QString settingsKey = QStringLiteral("MessageBoxOverride/") + this->identifier;
54+
SettingsService::instance().setValue(settingsKey, this->accepted);
55+
}
56+
3057
this->close();
3158
}
3259

src/dialogs/textdiffdialog.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ class TextDiffDialog : public MasterDialog {
1616
public:
1717
explicit TextDiffDialog(QWidget *parent = nullptr, const QString &title = QString(),
1818
const QString &labelText = QString(), const QString &text1 = QString(),
19-
const QString &text2 = QString());
19+
const QString &text2 = QString(),
20+
const QString &identifier = QString());
2021
~TextDiffDialog();
2122
bool resultAccepted();
2223
QString resultText();
@@ -30,4 +31,5 @@ class TextDiffDialog : public MasterDialog {
3031
Ui::TextDiffDialog *ui;
3132
bool accepted = false;
3233
QString text1;
34+
QString identifier;
3335
};

src/dialogs/textdiffdialog.ui

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,13 @@ li.checked::marker { content: &quot;\2612&quot;; }
6666
</property>
6767
</widget>
6868
</item>
69+
<item>
70+
<widget class="QCheckBox" name="dontShowAgainCheckBox">
71+
<property name="text">
72+
<string>Don't show dialog again</string>
73+
</property>
74+
</widget>
75+
</item>
6976
<item>
7077
<widget class="QLabel" name="label">
7178
<property name="text">

src/entities/note.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1546,7 +1546,7 @@ bool Note::storeNoteTextFileToDisk(bool &currentNoteTextChanged,
15461546
"Click 'OK' to save YOUR version and overwrite the external changes.\n"
15471547
"Click 'Cancel' to discard your changes and keep the external version.")
15481548
.arg(_fileName),
1549-
currentFileText, _noteText);
1549+
currentFileText, _noteText, QStringLiteral("note-checksum-diff"));
15501550

15511551
int dialogResult = dialog.exec();
15521552

src/languages/QOwnNotes_en.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9627,6 +9627,11 @@ Your notes will stay intact!</source>
96279627
</message>
96289628
<message>
96299629
<location filename="../dialogs/textdiffdialog.ui" line="72"/>
9630+
<source>Don&apos;t show dialog again</source>
9631+
<translation type="unfinished"></translation>
9632+
</message>
9633+
<message>
9634+
<location filename="../dialogs/textdiffdialog.ui" line="79"/>
96309635
<source>Accept change?</source>
96319636
<translation type="unfinished"></translation>
96329637
</message>

0 commit comments

Comments
 (0)