[qet] qet/qet: [5648] Fix : On windows when user drag and drop an element from the common elements collection to the custom elements collection ,

[ Thread Index | Date Index | More lists.tuxfamily.org/qet Archives ]


Revision: 5648
Author:   blacksun
Date:     2018-12-13 22:39:44 +0100 (Thu, 13 Dec 2018)
Log Message:
-----------
Fix : On windows when user drag and drop an element from the common elements collection to the custom elements collection,
the element file stay in read only mode, and so user can't save the element

Modified Paths:
--------------
    trunk/sources/ElementsCollection/elementcollectionhandler.cpp

Modified: trunk/sources/ElementsCollection/elementcollectionhandler.cpp
===================================================================
--- trunk/sources/ElementsCollection/elementcollectionhandler.cpp	2018-12-13 17:34:41 UTC (rev 5647)
+++ trunk/sources/ElementsCollection/elementcollectionhandler.cpp	2018-12-13 21:39:44 UTC (rev 5648)
@@ -135,7 +135,24 @@
     QString new_elmt_name = rename.isEmpty() ? source.fileName() : rename;
     bool rb = QFile::copy(source.fileSystemPath(), destination.fileSystemPath() + "/" + new_elmt_name);
     if (rb)
+	{
+#ifdef Q_OS_WIN
+			//On windows when user drag and drop an element from the common elements collection
+			//to the custom elements collection, the element file stay in read only mode, and so
+			//user can't save the element
+		extern Q_CORE_EXPORT int qt_ntfs_permission_lookup;
+		qt_ntfs_permission_lookup++;
+		QFile file(destination.fileSystemPath() + "/" + new_elmt_name);
+		if (!file.isWritable()) {
+			if (!file.setPermissions(file.permissions() | QFileDevice::WriteUser)) {
+				qDebug() << "Failed to change file permission of : " << QFileInfo(file).canonicalFilePath() \
+						 << " in ECHSFileToFile::copyElement";
+			}
+		}
+		qt_ntfs_permission_lookup--;
+#endif
 		return ElementsLocation (destination.fileSystemPath() + "/" + new_elmt_name);
+	}
     else
 		return ElementsLocation();
 }


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/