From a8338406c98c266474fcec2a72473aa60f66351b Mon Sep 17 00:00:00 2001 From: Martin Kleusberg Date: Thu, 8 Nov 2018 16:36:09 +0100 Subject: [PATCH] Save read-only state in project file When opening a database in read-only mode and creating a project file, save the read-only flag in the project file. When loading a project file with a read only flag set, open the database in read-only mode. See issue #1598. --- src/MainWindow.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index 443d6edb..c2d58b66 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -2615,6 +2615,10 @@ bool MainWindow::loadProject(QString filename, bool readOnly) { if(xml.name() == "db") { + // Read only? + if(xml.attributes().hasAttribute("readonly")) + readOnly = xml.attributes().value("readonly").toInt(); + // DB file QString dbfilename = xml.attributes().value("path").toString(); if(!QFile::exists(dbfilename)) @@ -2887,6 +2891,7 @@ void MainWindow::saveProject() // Database file name xml.writeStartElement("db"); xml.writeAttribute("path", db.currentFile()); + xml.writeAttribute("readonly", QString::number(db.readOnly())); xml.writeAttribute("foreign_keys", db.getPragma("foreign_keys")); xml.writeAttribute("case_sensitive_like", db.getPragma("case_sensitive_like")); xml.writeAttribute("temp_store", db.getPragma("temp_store"));