def saveEditor(self, editor = None, saveAs = False): editor = editor or self.currentEditor() if editor.isExternalChanged(): message = "The file '%s' has been changed on the file system, Do you want save the file with other name?" result = QtGui.QMessageBox.question(editor, _("File changed"), _(message) % editor.filePath(), buttons = QtGui.QMessageBox.Yes | QtGui.QMessageBox.No, defaultButton = QtGui.QMessageBox.Yes) if result == QtGui.QMessageBox.Yes: saveAs = True if editor.isNew() or saveAs: fileDirectory = self.application.fileManager.directory(self.projectsDock.currentPath()) if editor.isNew() else editor.fileDirectory() fileName = editor.title() fileFilters = editor.fileFilters() # TODO Armar el archivo destino y no solo el basedir file_path, _ = getSaveFileName( self, caption = "Save file as" if saveAs else "Save file", basedir = fileDirectory, filters = fileFilters ) else: file_path = editor.filePath() if file_path: editor.save(file_path)
def saveEditor(self, editor=None, saveAs=False): editor = editor or self.currentEditor() if editor.isExternalChanged(): message = "The file '%s' has been changed on the file system, Do you want save the file with other name?" result = QtGui.QMessageBox.question( editor, _("File changed"), _(message) % editor.filePath, buttons=QtGui.QMessageBox.Yes | QtGui.QMessageBox.No, defaultButton=QtGui.QMessageBox.Yes) if result == QtGui.QMessageBox.Yes: saveAs = True if editor.isNew() or saveAs: fileDirectory = self.application.fileManager.directory( self.projects.currentPath()) if editor.isNew( ) else editor.fileDirectory() fileName = editor.fileName() fileFilters = editor.fileFilters() # TODO Armar el archivo destino y no solo el basedir filePath, _ = getSaveFileName( self, caption="Save file as" if saveAs else "Save file", basedir=fileDirectory, filters=fileFilters) else: filePath = editor.filePath if filePath: editor.save(filePath)
def saveEditor(self, editor=None, saveAs=False): editor = editor or self.currentEditor() has_file_path = editor.windowFilePath() file_manager = self.application().fileManager if editor.externalAction() == self.application().EXTERNAL_CHANGED: message = "The file '%s' has been changed on the file system, Do you want save the file with other name?" result = QtWidgets.QMessageBox.question(editor, "File changed", message % editor.windowFilePath(), buttons = QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No, defaultButton = QtWidgets.QMessageBox.Yes) if result == QtWidgets.QMessageBox.Yes: saveAs = True if not has_file_path or saveAs: dirname = file_manager.directory(self.projectsDock.currentPath()) \ if not has_file_path \ else editor.windowFileDirectory() basename = editor.accessibleName() filters = editor.fileFilters() # TODO Armar el archivo destino y no solo el basedir file_path, _ = getSaveFileName( self, caption = "Save file as" if saveAs else "Save file", basedir = file_manager.join(dirname, basename), filters = filters ) else: file_path = editor.windowFilePath() if file_path: editor.save(file_path)
def on_pushButtonExport_pressed(self): selected_path, selected_filter = getSaveFileName( self, caption="Export shortcuts", basedir=config.USER_HOME_PATH ) if selected_path: shortcuts = self.shortcutsTreeModel.dictionary(defaults=True) json.write_file(shortcuts, selected_path)