diff --git a/src/NotepadNext/DockedEditor.cpp b/src/NotepadNext/DockedEditor.cpp index ea7779639..a243bb099 100644 --- a/src/NotepadNext/DockedEditor.cpp +++ b/src/NotepadNext/DockedEditor.cpp @@ -175,11 +175,16 @@ void DockedEditor::addEditor(ScintillaNext *editor) } // Set the icon - dockWidget->tabWidget()->setIcon(QIcon(":/icons/saved.png")); - connect(editor, &ScintillaNext::savePointChanged, dockWidget, [=](bool dirty) { - const QString iconPath = dirty ? ":/icons/unsaved.png" : ":/icons/saved.png"; - dockWidget->tabWidget()->setIcon(QIcon(iconPath)); - }); + if (editor->readOnly()) { + dockWidget->tabWidget()->setIcon(QIcon(":/icons/readonly.png")); + } + else { + dockWidget->tabWidget()->setIcon(QIcon(":/icons/saved.png")); + connect(editor, &ScintillaNext::savePointChanged, dockWidget, [=](bool dirty) { + const QString iconPath = dirty ? ":/icons/unsaved.png" : ":/icons/saved.png"; + dockWidget->tabWidget()->setIcon(QIcon(iconPath)); + }); + } connect(editor, &ScintillaNext::closed, dockWidget, &ads::CDockWidget::closeDockWidget); connect(editor, &ScintillaNext::renamed, this, [=]() { editorRenamed(editor); }); diff --git a/src/NotepadNext/ScintillaNext.cpp b/src/NotepadNext/ScintillaNext.cpp index 5e26baf9c..8133b8e91 100644 --- a/src/NotepadNext/ScintillaNext.cpp +++ b/src/NotepadNext/ScintillaNext.cpp @@ -463,6 +463,11 @@ bool ScintillaNext::readFromDisk(QFile &file) return false; } + if (!QFileInfo(file).isWritable()) { + qInfo("Setting file as read-only"); + setReadOnly(true); + } + return true; }