|
17 | 17 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
18 | 18 |
|
19 | 19 | import locale |
| 20 | +import os |
20 | 21 | import time |
21 | | -from os.path import exists, splitext |
| 22 | +from os.path import dirname, exists, isdir, isfile, splitext |
22 | 23 |
|
23 | 24 | from markups import find_markup_class_by_name, get_markup_for_file_name |
24 | 25 | from markups.common import MODULE_HOME_PAGE |
@@ -52,6 +53,11 @@ class ReTextTab(QSplitter): |
52 | 53 | def fileName(self): |
53 | 54 | return self._fileName |
54 | 55 |
|
| 56 | + @fileName.setter |
| 57 | + def fileName(self, newFileName): |
| 58 | + self._fileName = newFileName |
| 59 | + self.fileNameChanged.emit() |
| 60 | + |
55 | 61 | def __init__(self, parent, fileName, previewState=PreviewDisabled): |
56 | 62 | super().__init__(Qt.Orientation.Horizontal, parent=parent) |
57 | 63 | self.p = parent |
@@ -527,7 +533,15 @@ def createFile(self, fileToCreate): |
527 | 533 | return False |
528 | 534 |
|
529 | 535 | def autoSaveActive(self) -> bool: |
530 | | - return (globalSettings.autoSave |
531 | | - and not self.forceDisableAutoSave |
532 | | - and self.fileName is not None |
533 | | - and QFileInfo(self.fileName).isWritable()) |
| 536 | + if not globalSettings.autoSave: |
| 537 | + return False |
| 538 | + if self.forceDisableAutoSave: |
| 539 | + return False |
| 540 | + if self.fileName is None: |
| 541 | + return False |
| 542 | + |
| 543 | + if isfile(self.fileName): |
| 544 | + return os.access(self.fileName, os.W_OK) |
| 545 | + else: |
| 546 | + dirName = dirname(self.fileName) |
| 547 | + return isdir(dirName) and os.access(dirName, os.W_OK) |
0 commit comments