git repos / SagoImageBrowser

commit 835a6bea

Poul Sander · 2026-05-19 22:03
835a6beaac5173c3d0fd74a9c75db0246f4ab65f patch · browse files
parent beb4a823bf843df49a4f4732fcb66f5c10e90fc5

Warn if file is write protected

Changed files

M src/mainwindow.cpp before
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 7b2cce9..4275c07 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp
@@ -33,6 +33,7 @@
#include <QVBoxLayout>
#include <QDialogButtonBox>
#include <QPlainTextEdit>
+#include <QMessageBox>
#include <iostream>
#include <fcntl.h>
@@ -419,6 +420,13 @@ void MainWindow::onEditCaption()
if (path.isEmpty())
return;
+ if (::access(path.constData(), W_OK) != 0) {
+ QMessageBox::warning(this, tr("Cannot Edit Caption"),
+ tr("The file is write-protected and cannot be edited.\n\n%1")
+ .arg(QString::fromLocal8Bit(path)));
+ return;
+ }
+
ExifData data = ExifReader::read(path);
QDialog dlg(this);