def changeFile(self, _filePath, _isNew=False): self.fileValues = fu.readTextFile(_filePath, uni.MySettings["fileSystemEncoding"]) self.setWindowTitle(str(fu.getBaseName(self.fileValues["path"]))) if self.pnlClearable is not None: clearAllChildren(self.pnlClearable, True) self.pnlClearable = MWidget() self.vblMain.insertWidget(0, self.pnlClearable, 20) vblClearable = MVBoxLayout(self.pnlClearable) self.infoLabels["path"] = MLabel(self.labels[0]) self.infoLabels["content"] = MLabel(self.labels[1]) dirPath = fu.getDirName(self.fileValues["path"]) baseName = fu.getBaseName(self.fileValues["path"]) self.infoValues["path"] = MLineEdit(str(fu.joinPath(dirPath, Organizer.emend(baseName, "file")))) self.infoValues["content"] = MPlainTextEdit( str(Organizer.emend(self.fileValues["content"], "text", False, True))) self.infoValues["content"].setLineWrapMode(MPlainTextEdit.NoWrap) self.sourceCharSet = MComboBox() self.sourceCharSet.addItems(uni.getCharSets()) self.sourceCharSet.setCurrentIndex(self.sourceCharSet.findText(uni.MySettings["fileSystemEncoding"])) MObject.connect(self.sourceCharSet, SIGNAL("currentIndexChanged(int)"), self.sourceCharSetChanged) HBOXs = [] HBOXs.append(MHBoxLayout()) HBOXs[-1].addWidget(self.infoLabels["path"]) HBOXs[-1].addWidget(self.infoValues["path"]) HBOXs[-1].addWidget(self.sourceCharSet) for hbox in HBOXs: vblClearable.addLayout(hbox) vblClearable.addWidget(self.infoLabels["content"]) vblClearable.addWidget(self.infoValues["content"])
def fillValues(self): filePath = str(self.leFilePath.text()) if fu.isFile(filePath) and fu.isReadableFileOrDir(filePath): self.fileValues = fu.readTextFile(filePath, str(self.sourceCharSet.currentText())) self.pteFileContent.setPlainText(str(Organizer.emend(self.fileValues["content"], "text", False, True))) self.isChangeSourceCharSetChanged = True self.pbtnSave.setEnabled(True) else: self.isChangeSourceCharSetChanged = False self.pbtnSave.setEnabled(False)
def sourceCharSetChanged(self): try: self.fileValues = fu.readTextFile(self.fileValues["path"], str(self.sourceCharSet.currentText())) self.infoValues["content"].setPlainText( str(Organizer.emend(self.fileValues["content"], "text", False, True))) except: Dialogs.showError(translate("TextDetails", "Incorrect File Encoding"), str(translate("TextDetails", "File can not decode by \"%s\" codec.<br>Please select another file encoding type.") ) % str(self.sourceCharSet.currentText()))
def fillValues(self): filePath = str(self.leFilePath.text()) if fu.isFile(filePath) and fu.isReadableFileOrDir(filePath): self.fileValues = fu.readTextFile( filePath, str(self.sourceCharSet.currentText())) self.pteFileContent.setPlainText( str( Organizer.emend(self.fileValues["content"], "text", False, True))) self.isChangeSourceCharSetChanged = True self.pbtnSave.setEnabled(True) else: self.isChangeSourceCharSetChanged = False self.pbtnSave.setEnabled(False)