commit 835a6bea
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);