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



git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@5648 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
blacksun
2018-12-13 21:39:44 +00:00
parent 7a17200cf6
commit c64b74d328

View File

@@ -135,7 +135,24 @@ ElementsLocation ECHSFileToFile::copyElement(ElementsLocation &source, ElementsL
QString new_elmt_name = rename.isEmpty() ? source.fileName() : rename; QString new_elmt_name = rename.isEmpty() ? source.fileName() : rename;
bool rb = QFile::copy(source.fileSystemPath(), destination.fileSystemPath() + "/" + new_elmt_name); bool rb = QFile::copy(source.fileSystemPath(), destination.fileSystemPath() + "/" + new_elmt_name);
if (rb) 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); return ElementsLocation (destination.fileSystemPath() + "/" + new_elmt_name);
}
else else
return ElementsLocation(); return ElementsLocation();
} }