@@ -1499,11 +1499,7 @@ bool Note::storeNoteTextFileToDisk(bool ¤tNoteTextChanged,
14991499 // Read the current file content using the same flags as when writing
15001500 // to ensure newline handling is consistent (important on Windows)
15011501 QFile checkFile (fullNoteFilePath ());
1502- QFile::OpenMode checkFlags = QIODevice::ReadOnly;
1503- if (!useUNIXNewline) {
1504- checkFlags |= QIODevice::Text;
1505- }
1506- if (checkFile.open (checkFlags)) {
1502+ if (checkFile.open (Utils::Misc::getNoteFileOpenFlags ())) {
15071503 QTextStream checkIn (&checkFile);
15081504#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
15091505 checkIn.setCodec (" UTF-8" );
@@ -1949,14 +1945,7 @@ bool Note::updateNoteTextFromDisk() {
19491945 QFile file (fullNoteFilePath ());
19501946
19511947 // Use the same flags as when writing to ensure consistent newline handling
1952- const SettingsService settings;
1953- const bool useUNIXNewline = settings.value (QStringLiteral (" useUNIXNewline" )).toBool ();
1954- QFile::OpenMode flags = QIODevice::ReadOnly;
1955- if (!useUNIXNewline) {
1956- flags |= QIODevice::Text;
1957- }
1958-
1959- if (!file.open (flags)) {
1948+ if (!file.open (Utils::Misc::getNoteFileOpenFlags ())) {
19601949 qDebug () << __func__ << " - 'file': " << file.fileName ();
19611950 qDebug () << __func__ << " - " << file.errorString ();
19621951 return false ;
@@ -2010,7 +1999,7 @@ bool Note::updateNoteTextFromDisk() {
20101999 }
20112000
20122001 // Calculate and store the checksum of the loaded text (if enabled)
2013- // settings was already retrieved at the beginning of the function
2002+ const SettingsService settings;
20142003 const bool enableNoteChecksumChecks =
20152004 settings.value (QStringLiteral (" enableNoteChecksumChecks" ), false ).toBool ();
20162005 if (enableNoteChecksumChecks) {
@@ -2341,14 +2330,7 @@ QString Note::detectNewlineCharacters() {
23412330
23422331void Note::createFromFile (QFile &file, int noteSubFolderId, bool withNoteNameHook) {
23432332 // Use the same flags as when writing to ensure consistent newline handling
2344- const SettingsService settings;
2345- const bool useUNIXNewline = settings.value (QStringLiteral (" useUNIXNewline" )).toBool ();
2346- QFile::OpenMode flags = QIODevice::ReadOnly;
2347- if (!useUNIXNewline) {
2348- flags |= QIODevice::Text;
2349- }
2350-
2351- if (file.open (flags)) {
2333+ if (file.open (Utils::Misc::getNoteFileOpenFlags ())) {
23522334 QFileInfo fileInfo;
23532335 fileInfo.setFile (file);
23542336
@@ -2396,7 +2378,7 @@ void Note::createFromFile(QFile &file, int noteSubFolderId, bool withNoteNameHoo
23962378 this ->_fileLastModified = fileInfo.lastModified ();
23972379
23982380 // Calculate the checksum before storing (if enabled)
2399- // settings was already retrieved above
2381+ const SettingsService settings;
24002382 const bool enableNoteChecksumChecks =
24012383 settings.value (QStringLiteral (" enableNoteChecksumChecks" ), false ).toBool ();
24022384 if (enableNoteChecksumChecks) {
0 commit comments