本文整理汇总了Python中Core.Dialogs.showState方法的典型用法代码示例。如果您正苦于以下问题:Python Dialogs.showState方法的具体用法?Python Dialogs.showState怎么用?Python Dialogs.showState使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Core.Dialogs
的用法示例。
在下文中一共展示了Dialogs.showState方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: getFromAmarok
# 需要导入模块: from Core import Dialogs [as 别名]
# 或者: from Core.Dialogs import showState [as 别名]
def getFromAmarok(self):
try:
import Amarok
Dialogs.showState(translate("CoverTable", "Checking For Amarok..."), 0, 1)
if Amarok.checkAmarok():
from Amarok import Operations
directoriesAndValues = Operations.getDirectoriesAndValues()
Dialogs.showState(translate("CoverTable", "Values Are Being Processed"), 1, 1)
if directoriesAndValues is not None:
for rowNo in range(self.rowCount()):
if (getMainWindow().checkHiddenColumn("sourceCover") and
getMainWindow().checkHiddenColumn("destinationCover")):
if self.isChangeableItem(rowNo, "sourceCover"):
directoryPath = fu.joinPath(
fu.getDirName(fu.getDirName(self.values[rowNo]["path"])),
str(self.item(rowNo, 0).text()), str(self.item(rowNo, 1).text()))
if directoryPath in directoriesAndValues:
directoryAndValues = directoriesAndValues[directoryPath]
self.item(rowNo, 3).setText(
directoryAndValues["coverPath"][0].replace(directoryPath, "."))
self.item(rowNo, 4).setText("./" + Organizer.getIconName(
directoryAndValues["artist"][0],
directoryAndValues["album"][0],
directoryAndValues["genre"][0],
directoryAndValues["year"][0]))
except:
ReportBug.ReportBug()
示例2: writeContents
# 需要导入模块: from Core import Dialogs [as 别名]
# 或者: from Core.Dialogs import showState [as 别名]
def writeContents(self):
self.changedValueNumber = 0
changedArtistValues = []
uni.startThreadAction()
allItemNumber = len(self.values)
Dialogs.showState(translate("FileUtils/Musics", "Writing Music Tags"), 0, allItemNumber, True)
for rowNo in range(self.rowCount()):
isContinueThreadAction = uni.isContinueThreadAction()
if isContinueThreadAction:
try:
if self.isRowHidden(rowNo) is False:
if self.isChangeableItem(rowNo, "correctedArtist", str(self.values[rowNo]["currentArtist"])):
changedArtistValues.append({})
changedArtistValues[-1]["id"] = str(self.values[rowNo]["id"])
value = str(self.item(rowNo, 1).text())
changedArtistValues[-1]["name"] = value
Records.add(str(translate("AmarokArtistTable", "Artist")),
str(self.values[rowNo]["currentArtist"]), value)
self.changedValueNumber += 1
except:
ReportBug.ReportBug()
else:
allItemNumber = rowNo + 1
Dialogs.showState(translate("FileUtils/Musics", "Writing Music Tags"), rowNo + 1, allItemNumber, True)
if isContinueThreadAction is False:
break
uni.finishThreadAction()
Operations.changeArtistValues(changedArtistValues)
return True
示例3: refreshTable
# 需要导入模块: from Core import Dialogs [as 别名]
# 或者: from Core.Dialogs import showState [as 别名]
def refreshTable(self, _path):
self.values = []
fileAndDirectoryNames = fu.readDirectory(_path, "fileAndDirectory",
uni.getBoolValue("isShowHiddensInFolderTable"))
allItemNumber = len(fileAndDirectoryNames)
uni.startThreadAction()
baseNameOfDirectory = fu.getBaseName(_path)
rowNo = 0
self.setRowCount(allItemNumber)
for baseName in fileAndDirectoryNames:
isContinueThreadAction = uni.isContinueThreadAction()
if isContinueThreadAction:
try:
if fu.isReadableFileOrDir(fu.joinPath(_path, baseName), False, True):
details = fu.getExtendedDetails(fu.joinPath(_path, baseName))
content = {}
content["path"] = fu.joinPath(_path, baseName)
content["baseNameOfDirectory"] = baseNameOfDirectory
content["baseName"] = baseName
content.update(details)
self.values.append(content)
newBaseNameOfDirectory = Organizer.emend(content["baseNameOfDirectory"], "directory")
self.createItem(rowNo, "baseNameOfDirectory", newBaseNameOfDirectory,
content["baseNameOfDirectory"])
newBaseName = Organizer.emend(content["baseName"], fu.getObjectType(self.values[rowNo]["path"]))
self.createItem(rowNo, "baseName", newBaseName, content["baseName"])
self.createItem(rowNo, "size", Organizer.getCorrectedFileSize(content["size"]))
self.createItem(rowNo, "lastAccessed", Organizer.getCorrectedTime(content["lastAccessed"]))
self.createItem(rowNo, "lastModified", Organizer.getCorrectedTime(content["lastModified"]))
self.createItem(rowNo, "lastMetadataChanged",
Organizer.getCorrectedTime(content["lastMetadataChanged"]))
if not uni.isWindows:
self.createItem(rowNo, "accessRights", content["accessRights"])
self.createItem(rowNo, "userIDOfOwner", content["userIDOfOwner"])
self.createItem(rowNo, "groupIDOfOwner", content["groupIDOfOwner"])
self.createItem(rowNo, "numberOfHardLinks", content["numberOfHardLinks"])
rowNo += 1
else:
allItemNumber -= 1
except:
ReportBug.ReportBug()
allItemNumber -= 1
else:
allItemNumber = rowNo
Dialogs.showState(translate("Tables", "Generating Table..."), rowNo, allItemNumber, True)
if isContinueThreadAction is False:
break
uni.finishThreadAction()
self.setRowCount(len(self.values)) # In case of Non Readable Files and Canceled process
示例4: changeArtistValues
# 需要导入模块: from Core import Dialogs [as 别名]
# 或者: from Core.Dialogs import showState [as 别名]
def changeArtistValues(_values):
uni.startThreadAction()
allItemNumber = len(_values)
Dialogs.showState(translate("Amarok/Operations", "Writing Music Tags"), 0, allItemNumber, True)
for x, value in enumerate(_values):
isContinueThreadAction = uni.isContinueThreadAction()
if isContinueThreadAction:
try:
musicFilePathAndArtist = Commands.changeArtistValue(value)
if musicFilePathAndArtist is not None:
artistName = musicFilePathAndArtist[0]
for musicFilePath in musicFilePathAndArtist[1]:
if fu.isWritableFileOrDir(musicFilePath, False, True):
Records.add(str(translate("Amarok/Operations", "File will be updated")), str(musicFilePath))
currentArtistName = ""
tagger = Taggers.getTagger()
if tagger is not None:
try:
tagger.loadFileForWrite(musicFilePath)
currentArtistName = tagger.getArtist()
except:
tagger.loadFileForWrite(musicFilePath)
tagger.setArtist(artistName)
tagger.update()
Records.add(str(translate("Amarok/Operations", "Artist")), str(currentArtistName),
artistName)
for musicFilePath in musicFilePathAndArtist[2]:
if fu.isWritableFileOrDir(musicFilePath, False, True):
Records.add(str(translate("Amarok/Operations", "File will be updated")), str(musicFilePath))
currentArtistName = ""
tagger = Taggers.getTagger()
if tagger is not None:
try:
tagger.loadFileForWrite(musicFilePath)
currentArtistName = tagger.getAlbumArtist()
except:
tagger.loadFileForWrite(musicFilePath)
tagger.setAlbumArtist(artistName)
tagger.update()
Records.add(str(translate("Amarok/Operations", "albumArtist")), str(currentArtistName),
artistName)
except:
ReportBug.ReportBug()
else:
allItemNumber = x + 1
Dialogs.showState(translate("Amarok/Operations", "Writing Music Tags"), x + 1, allItemNumber, True)
if isContinueThreadAction is False:
break
uni.finishThreadAction()
示例5: sendFinished
# 需要导入模块: from Core import Dialogs [as 别名]
# 或者: from Core.Dialogs import showState [as 别名]
def sendFinished(self, _nrpBack):
Dialogs.showState(translate("ReportBug", "Sending Your Report"), 100, 100)
if _nrpBack.error() == MNetworkReply.NoError:
Dialogs.show(translate("ReportBug", "Report Received Successfully"), translate("ReportBug",
"Thank you for sending us your report. You have contributed a lot to make the next release even better."))
self.close()
elif _nrpBack.error() == MNetworkReply.OperationCanceledError:
Dialogs.show(translate("ReportBug", "Report Sending Canceled"),
translate("ReportBug", "Report sending canceled successfully."))
else:
Dialogs.show(translate("ReportBug", "An Error Has Occurred."),
translate("ReportBug", "An unknown error has occurred. Please try again."))
uni.isCanBeShowOnMainWindow = True
self.namMain = None
self.nrqPost = None
self.nrpBack = None
示例6: changeTags
# 需要导入模块: from Core import Dialogs [as 别名]
# 或者: from Core.Dialogs import showState [as 别名]
def changeTags(_values):
uni.startThreadAction()
allItemNumber = len(_values)
for valueNo, value in enumerate(_values):
isContinueThreadAction = uni.isContinueThreadAction()
if isContinueThreadAction:
try:
Commands.changeTag(value)
except:
ReportBug.ReportBug()
else:
allItemNumber = valueNo + 1
Dialogs.showState(translate("Amarok/Operations", "Changing Tags In Amarok Database"),
valueNo + 1, allItemNumber, True)
if isContinueThreadAction is False:
break
uni.finishThreadAction()
示例7: sendAndClose
# 需要导入模块: from Core import Dialogs [as 别名]
# 或者: from Core.Dialogs import showState [as 别名]
def sendAndClose(self):
try:
uni.isCanBeShowOnMainWindow = False
self.namMain = MNetworkAccessManager(self)
self.connect(self.namMain, SIGNAL("finished (QNetworkReply *)"), self.sendFinished)
self.nrqPost = MNetworkRequest(MUrl("http://hamsiapps.com/ForMyProjects/SuggestIdea.php"))
self.nrpBack = self.namMain.post(self.nrqPost,
"p=HamsiManager&l=" + str(uni.MySettings["language"]) + "&v=" + str(
uni.intversion) +
"&thankYouMessages=new style" +
"&userNotes=" + Organizer.quote(str(self.teIdea.toHtml())) +
"&nameAndSurname=" + Organizer.quote(str(self.leName.text())) +
"&mail=" + Organizer.quote(str(self.leEMailAddress.text()))
)
self.connect(self.nrpBack, SIGNAL("downloadProgress (qint64,qint64)"), self.sending)
Dialogs.showState(translate("SuggestIdea", "Sending Your Idea"), 0, 100, True, self.cancelSending)
except:
ReportBug.ReportBug()
示例8: changePaths
# 需要导入模块: from Core import Dialogs [as 别名]
# 或者: from Core.Dialogs import showState [as 别名]
def changePaths(_values, _type="auto"):
uni.startThreadAction()
allItemNumber = len(_values)
for valueNo, value in enumerate(_values):
isContinueThreadAction = uni.isContinueThreadAction()
if isContinueThreadAction:
try:
if _type == "file" or (_type == "auto" and fu.isFile(value["newPath"])):
Commands.changeFilePath(value["oldPath"], value["newPath"])
else:
Commands.changeDirectoryPath(value["oldPath"], value["newPath"])
except:
ReportBug.ReportBug()
else:
allItemNumber = valueNo + 1
Dialogs.showState(translate("Amarok/Operations", "Changing Paths In Amarok Database"),
valueNo + 1, allItemNumber, True)
if isContinueThreadAction is False:
break
uni.finishThreadAction()
示例9: refreshTable
# 需要导入模块: from Core import Dialogs [as 别名]
# 或者: from Core.Dialogs import showState [as 别名]
def refreshTable(self, _path):
self.values = []
uni.startThreadAction()
Dialogs.showState(translate("AmarokArtistTable", "Getting Values From Amarok"), 0, 1)
if Amarok.checkAmarok():
isContinueThreadAction = uni.isContinueThreadAction()
if isContinueThreadAction:
artistValues = Operations.getAllArtistsValues(uni.MySettings[self.amarokFilterKeyName])
Dialogs.showState(translate("AmarokArtistTable", "Values Are Being Processed"), 1, 1)
isContinueThreadAction = uni.isContinueThreadAction()
if isContinueThreadAction:
if artistValues is not None:
allItemNumber = len(artistValues)
self.setRowCount(allItemNumber)
rowNo = 0
for musicFileRow in artistValues:
isContinueThreadAction = uni.isContinueThreadAction()
if isContinueThreadAction:
try:
content = {}
content["id"] = musicFileRow["id"]
content["currentArtist"] = musicFileRow["name"]
content["correctedArtist"] = musicFileRow["name"]
self.values.append(content)
currentName = content["currentArtist"]
self.createItem(rowNo, "currentArtist", currentName, currentName, True)
newName = Organizer.emend(content["correctedArtist"])
isReadOnlyNewName = (content["correctedArtist"].strip() == "")
self.createItem(rowNo, "correctedArtist", newName, content["currentArtist"],
isReadOnlyNewName)
rowNo += 1
except:
ReportBug.ReportBug()
allItemNumber -= 1
else:
allItemNumber = rowNo
Dialogs.showState(translate("Tables", "Generating Table..."), rowNo, allItemNumber, True)
if isContinueThreadAction is False:
break
uni.finishThreadAction()
self.setRowCount(len(self.values)) # In case of Non Readable Files and Canceled process
示例10: sending
# 需要导入模块: from Core import Dialogs [as 别名]
# 或者: from Core.Dialogs import showState [as 别名]
def sending(self, _currentValue, _maxValue):
Dialogs.showState(translate("ReportBug", "Sending Your Report"), _currentValue, _maxValue, True,
self.cancelSending)
示例11: changeArtist
# 需要导入模块: from Core import Dialogs [as 别名]
# 或者: from Core.Dialogs import showState [as 别名]
def changeArtist(self, _artistId, _isNew=False):
self.artistId = _artistId
self.songTableContentValues = None
uni.startThreadAction()
Dialogs.showState(translate("AmarokArtistDetails", "Getting Values From Amarok"), 0, 1)
if Amarok.checkAmarok():
isContinueThreadAction = uni.isContinueThreadAction()
if isContinueThreadAction:
self.artistName = Commands.getArtistName(self.artistId)
self.songTableContentValues = Operations.getAllMusicFileValuesWithNames("", self.artistId)
Dialogs.showState(translate("MusicDetails", "Values Are Being Processed"), 1, 1)
uni.finishThreadAction()
if self.songTableContentValues is None:
self.close()
self.setWindowTitle(str(self.artistName))
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["currentArtist"] = MLabel(self.labels[0])
self.infoLabels["correctedArtist"] = MLabel(self.labels[1])
self.infoValues["currentArtist"] = MLineEdit(str(self.artistName))
self.infoValues["correctedArtist"] = MLineEdit(str(Organizer.emend(self.artistName)))
self.twSongs = MTableWidget()
self.twSongs.clear()
self.twSongs.setColumnCount(len(self.songTableColumns))
self.twSongs.setHorizontalHeaderLabels(self.songTableColumns)
self.twSongs.setRowCount(len(self.songTableContentValues))
for rowNo in range(self.twSongs.rowCount()):
item = MTableWidgetItem(str(self.songTableContentValues[rowNo]["filePath"]))
self.twSongs.setItem(rowNo, 0, item)
item = MTableWidgetItem(str(self.songTableContentValues[rowNo]["artist"]))
self.twSongs.setItem(rowNo, 1, item)
item = MTableWidgetItem(str(self.songTableContentValues[rowNo]["title"]))
self.twSongs.setItem(rowNo, 2, item)
item = MTableWidgetItem(str(self.songTableContentValues[rowNo]["album"]))
self.twSongs.setItem(rowNo, 3, item)
item = MTableWidgetItem(str(self.songTableContentValues[rowNo]["albumArtist"]))
self.twSongs.setItem(rowNo, 4, item)
item = MTableWidgetItem(str(self.songTableContentValues[rowNo]["trackNumber"]))
self.twSongs.setItem(rowNo, 5, item)
item = MTableWidgetItem(str(self.songTableContentValues[rowNo]["year"]))
self.twSongs.setItem(rowNo, 6, item)
item = MTableWidgetItem(str(self.songTableContentValues[rowNo]["genre"]))
self.twSongs.setItem(rowNo, 7, item)
item = MTableWidgetItem(str(self.songTableContentValues[rowNo]["comment"]))
self.twSongs.setItem(rowNo, 8, item)
for x in range(self.twSongs.columnCount()):
self.twSongs.item(rowNo, x).setFlags(Mt.ItemIsSelectable | Mt.ItemIsEnabled)
HBOXs = []
HBOXs.append(MHBoxLayout())
HBOXs[-1].addWidget(self.infoLabels["currentArtist"])
HBOXs[-1].addWidget(self.infoValues["currentArtist"])
HBOXs.append(MHBoxLayout())
HBOXs[-1].addWidget(self.infoLabels["correctedArtist"])
HBOXs[-1].addWidget(self.infoValues["correctedArtist"])
vblInfos = MVBoxLayout()
for hbox in HBOXs:
vblInfos.addLayout(hbox)
vblInfos.addWidget(self.twSongs)
vblClearable.addLayout(vblInfos)
示例12: refreshTable
# 需要导入模块: from Core import Dialogs [as 别名]
# 或者: from Core.Dialogs import showState [as 别名]
def refreshTable(self, _path):
self.values = []
uni.startThreadAction()
import Amarok
Dialogs.showState(translate("AmarokMusicTable", "Getting Values From Amarok"), 0, 1)
if Amarok.checkAmarok():
isContinueThreadAction = uni.isContinueThreadAction()
if isContinueThreadAction:
from Amarok import Operations
directoriesAndValues = Operations.getDirectoriesAndValues(uni.MySettings[self.amarokFilterKeyName])
Dialogs.showState(translate("AmarokMusicTable", "Values Are Being Processed"), 1, 1)
isContinueThreadAction = uni.isContinueThreadAction()
if isContinueThreadAction:
if directoriesAndValues is not None:
allItemNumber = len(directoriesAndValues)
self.setRowCount(allItemNumber)
rowNo = 0
for dirPath, dirRow in directoriesAndValues.items():
isContinueThreadAction = uni.isContinueThreadAction()
if isContinueThreadAction:
try:
if fu.isReadableFileOrDir(dirPath, False, True) and fu.isReadableFileOrDir(
fu.joinPath(dirPath, ".directory"), False, True):
content = {}
content["path"] = dirPath
content["pathOfParentDirectory"] = fu.getDirName(dirPath)
content["baseName"] = fu.getBaseName(dirPath)
currentCover, isCorrectedFileContent = fu.getIconFromDirectory(dirPath)
if currentCover is None:
currentCover = ""
content["currentCover"] = (currentCover)
content["sourceCover"] = (dirRow["coverPath"][0].replace(dirPath, "."))
content["destinationCover"] = ("./" + Organizer.getIconName(
dirRow["artist"][0],
dirRow["album"][0],
dirRow["genre"][0],
dirRow["year"][0]))
content["flagColor"] = {}
if isCorrectedFileContent is False:
content["flagColor"]["currentCover"] = 255, 163, 163
if fu.isFile(content["sourceCover"]) is False:
content["flagColor"]["sourceCover"] = 255, 163, 163
self.values.append(content)
newPathOfParentDirectory = Organizer.emend(
self.values[rowNo]["pathOfParentDirectory"], "directory")
self.createItem(rowNo, "pathOfParentDirectory", newPathOfParentDirectory,
self.values[rowNo]["pathOfParentDirectory"])
newBaseName = Organizer.emend(self.values[rowNo]["baseName"], "directory")
self.createItem(rowNo, "pathOfParentDirectory", newBaseName,
self.values[rowNo]["baseName"])
newCurrentCover = fu.getShortPath(self.values[rowNo]["currentCover"],
self.values[rowNo]["path"])
itemCurrentCover = self.createItem(rowNo, "currentCover", newCurrentCover,
newCurrentCover, True)
self.setItemColor(itemCurrentCover, rowNo, 2, "currentCover")
newSourceCover = fu.getShortPath(self.values[rowNo]["sourceCover"],
self.values[rowNo]["path"])
itemSourceCover = self.createItem(rowNo, "sourceCover", newSourceCover,
fu.getShortPath(
self.values[rowNo]["currentCover"],
self.values[rowNo]["path"]))
self.setItemColor(itemSourceCover, rowNo, 3, "sourceCover")
newDestinationCover = Organizer.emend(
fu.getShortPath(self.values[rowNo]["destinationCover"],
self.values[rowNo]["path"]), "file")
itemDestinationCover = self.createItem(rowNo, "destinationCover",
newDestinationCover,
fu.getShortPath(
self.values[rowNo]["currentCover"],
self.values[rowNo]["path"]))
self.setItemColor(itemDestinationCover, rowNo, 4, "destinationCover")
rowNo += 1
else:
allItemNumber -= 1
except:
ReportBug.ReportBug()
allItemNumber -= 1
else:
allItemNumber = rowNo
Dialogs.showState(translate("Tables", "Generating Table..."), rowNo, allItemNumber, True)
if isContinueThreadAction is False:
break
uni.finishThreadAction()
self.setRowCount(len(self.values)) # In case of Non Readable Files and Canceled process
示例13: writeContents
# 需要导入模块: from Core import Dialogs [as 别名]
# 或者: from Core.Dialogs import showState [as 别名]
def writeContents(self):
self.changedValueNumber = 0
oldAndNewPathValues = []
startRowNo, rowStep = 0, 1
uni.startThreadAction()
allItemNumber = len(self.values)
Dialogs.showState(translate("FileUtils/Covers", "Writing Cover Informations"), 0, allItemNumber, True)
for rowNo in range(startRowNo, self.rowCount(), rowStep):
isContinueThreadAction = uni.isContinueThreadAction()
if isContinueThreadAction:
try:
if fu.isWritableFileOrDir(self.values[rowNo]["path"], False, True):
if self.isRowHidden(rowNo):
fu.removeFileOrDir(self.values[rowNo]["path"])
self.changedValueNumber += 1
else:
pathOfParentDirectory = str(
self.values[rowNo]["pathOfParentDirectory"])
baseName = str(self.values[rowNo]["baseName"])
if self.isChangeableItem(rowNo, "sourceCover") or self.isChangeableItem(rowNo, "destinationCover"):
sourcePath = self.values[rowNo]["sourceCover"]
destinationPath = self.values[rowNo]["destinationCover"]
if self.isChangeableItem(rowNo, "sourceCover"):
sourcePath = str(self.item(rowNo, 3).text()).strip()
if self.isChangeableItem(rowNo, "destinationCover"):
destinationPath = str(self.item(rowNo, 4).text()).strip()
if (str(self.item(rowNo,
2).text()) != sourcePath or sourcePath != destinationPath or str(
self.item(rowNo, 2).text()) != destinationPath) or (
str(self.item(rowNo, 2).text()) !=
self.values[rowNo]["currentCover"] and (
str(self.item(rowNo, 2).text()) != sourcePath and str(
self.item(rowNo, 2).text()) != destinationPath)):
if str(self.item(rowNo, 3).text()).strip() != "":
sourcePath = fu.getRealPath(sourcePath,
self.values[rowNo]["path"])
sourcePath = fu.checkSource(sourcePath, "file")
if sourcePath is not None:
if destinationPath != "":
destinationPath = fu.getRealPath(destinationPath,
self.values[
rowNo]["path"])
if sourcePath != destinationPath:
destinationPath = fu.moveOrChange(sourcePath, destinationPath)
else:
destinationPath = sourcePath
fu.setIconToDirectory(self.values[rowNo]["path"],
destinationPath)
self.changedValueNumber += 1
else:
fu.setIconToDirectory(self.values[rowNo]["path"], "")
self.changedValueNumber += 1
if self.isChangeableItem(rowNo, "baseNameOfDirectory", pathOfParentDirectory):
pathOfParentDirectory = str(self.item(rowNo, 0).text())
self.changedValueNumber += 1
if self.isChangeableItem(rowNo, "baseName", baseName, False):
baseName = str(self.item(rowNo, 1).text())
self.changedValueNumber += 1
newFilePath = fu.joinPath(pathOfParentDirectory, baseName)
oldFilePath = fu.getRealPath(self.values[rowNo]["path"])
newFilePath = fu.getRealPath(newFilePath)
if oldFilePath != newFilePath:
oldAndNewPaths = {}
oldAndNewPaths["oldPath"] = oldFilePath
oldAndNewPaths["newPath"] = fu.moveOrChange(oldFilePath, newFilePath, "directory")
if oldFilePath != oldAndNewPaths["newPath"]:
oldAndNewPathValues.append(oldAndNewPaths)
oldDirName = fu.getDirName(oldFilePath)
if uni.getBoolValue("isClearEmptyDirectoriesWhenFileMove"):
fu.checkEmptyDirectories(oldDirName, True, True,
uni.getBoolValue("isAutoCleanSubFolderWhenFileMove"))
except:
ReportBug.ReportBug()
else:
allItemNumber = rowNo + 1
Dialogs.showState(translate("FileUtils/Covers", "Writing Cover Informations"), rowNo + 1, allItemNumber,
True)
if isContinueThreadAction is False:
break
uni.finishThreadAction()
if len(oldAndNewPathValues) > 0:
from Amarok import Operations
Operations.changePaths(oldAndNewPathValues)
return True
示例14: writeContents
# 需要导入模块: from Core import Dialogs [as 别名]
# 或者: from Core.Dialogs import showState [as 别名]
def writeContents(self):
self.changedValueNumber = 0
uni.startThreadAction()
import Amarok
allItemNumber = len(self.values)
Dialogs.showState(translate("FileUtils/Musics", "Writing Music Tags"), 0, allItemNumber, True)
for rowNo in range(self.rowCount()):
isContinueThreadAction = uni.isContinueThreadAction()
if isContinueThreadAction:
try:
if self.isRowHidden(rowNo) is False:
baseNameOfDirectory = str(self.values[rowNo]["baseNameOfDirectory"])
baseName = str(self.values[rowNo]["baseName"])
if self.isChangeableItem(rowNo, "baseNameOfDirectory", baseNameOfDirectory):
baseNameOfDirectory = str(self.item(rowNo, 0).text())
self.changedValueNumber += 1
if self.isChangeableItem(rowNo, "baseName", baseName, False):
baseName = str(self.item(rowNo, 1).text())
self.changedValueNumber += 1
newFilePath = fu.getRealPath(
fu.joinPath(str(self.leDestinationDirPath.text()), baseNameOfDirectory,
baseName))
if fu.isFile(self.values[rowNo]["path"]) and fu.isReadableFileOrDir(
self.values[rowNo]["path"], False, True):
if fu.isWritableFileOrDir(newFilePath, False, True):
newFilePathCopied = fu.copyOrChange(self.values[rowNo]["path"],
newFilePath)
if self.values[rowNo]["path"] != newFilePathCopied:
newFilePath = newFilePathCopied
try:
tagger = Taggers.getTagger()
tagger.loadFileForWrite(newFilePath)
if self.isChangeableItem(rowNo, "artist"):
value = str(self.item(rowNo, 2).text())
tagger.setArtist(value)
Records.add(str(translate("MusicTable", "Artist")),
str(self.values[rowNo]["artist"]),
value)
self.changedValueNumber += 1
if self.isChangeableItem(rowNo, "title"):
value = str(self.item(rowNo, 3).text())
tagger.setTitle(value)
Records.add(str(translate("MusicTable", "Title")),
str(self.values[rowNo]["title"]),
value)
self.changedValueNumber += 1
if self.isChangeableItem(rowNo, "album"):
value = str(self.item(rowNo, 4).text())
tagger.setAlbum(value)
Records.add(str(translate("MusicTable", "Album")),
str(self.values[rowNo]["album"]),
value)
self.changedValueNumber += 1
if self.isChangeableItem(rowNo, "albumArtist"):
value = str(self.item(rowNo, 5).text())
tagger.setAlbumArtist(value)
Records.add(str(translate("MusicTable", "Album Artist")),
str(self.values[rowNo]["albumArtist"]),
value)
self.changedValueNumber += 1
if self.isChangeableItem(rowNo, "trackNum"):
value = str(self.item(rowNo, 6).text())
tagger.setTrackNum(value)
Records.add(str(translate("MusicTable", "Track No")),
str(self.values[rowNo]["trackNum"]),
value)
self.changedValueNumber += 1
if self.isChangeableItem(rowNo, "year"):
value = str(self.item(rowNo, 7).text())
tagger.setDate(value)
Records.add(str(translate("MusicTable", "Year")),
str(self.values[rowNo]["year"]), value)
self.changedValueNumber += 1
if self.isChangeableItem(rowNo, "genre"):
value = str(self.item(rowNo, 8).text())
tagger.setGenre(value)
Records.add(str(translate("MusicTable", "Genre")),
str(self.values[rowNo]["genre"]),
value)
self.changedValueNumber += 1
if self.isChangeableItem(rowNo, "firstComment"):
value = str(self.item(rowNo, 9).text())
tagger.setFirstComment(value)
Records.add(str(translate("MusicTable", "Comment")), str(
self.values[rowNo]["firstComment"]), value)
self.changedValueNumber += 1
if self.isChangeableItem(rowNo, "firstLyrics"):
value = str(self.item(rowNo, 10).text())
tagger.setFirstLyrics(value)
Records.add(str(translate("MusicTable", "Lyrics")),
str(self.values[rowNo]["firstLyrics"]),
value)
self.changedValueNumber += 1
tagger.update()
except:
Dialogs.showError(translate("MusicTable", "Tags Cannot Changed"),
str(translate("MusicTable",
"\"%s\" : cannot be changed tags.")
) % Organizer.getLink(newFilePath))
#.........这里部分代码省略.........
示例15: refreshTable
# 需要导入模块: from Core import Dialogs [as 别名]
# 或者: from Core.Dialogs import showState [as 别名]
def refreshTable(self, _path):
self.values = []
self.setColumnWidth(6, 70)
self.setColumnWidth(7, 40)
uni.startThreadAction()
import Amarok
Dialogs.showState(translate("AmarokMusicTable", "Getting Values From Amarok"), 0, 1)
if Amarok.checkAmarok():
isContinueThreadAction = uni.isContinueThreadAction()
if isContinueThreadAction:
from Amarok import Operations
musicFileValuesWithNames = Operations.getAllMusicFileValuesWithNames(
uni.MySettings[self.amarokFilterKeyName])
Dialogs.showState(translate("AmarokMusicTable", "Values Are Being Processed"), 1, 1)
isContinueThreadAction = uni.isContinueThreadAction()
if isContinueThreadAction:
if musicFileValuesWithNames is not None:
allItemNumber = len(musicFileValuesWithNames)
self.setRowCount(allItemNumber)
rowNo = 0
for musicFileRow in musicFileValuesWithNames:
isContinueThreadAction = uni.isContinueThreadAction()
if isContinueThreadAction:
try:
if (fu.isFile(musicFileRow["filePath"]) and
fu.isReadableFileOrDir(musicFileRow["filePath"], False, True)):
details = fu.getDetails(musicFileRow["filePath"])
content = {}
if Amarok.getSelectedTagSourseType("AmarokCopyTable") == "Amarok (Smart)":
content["path"] = musicFileRow["filePath"]
content["baseNameOfDirectory"] = fu.getBaseName(
fu.getDirName(musicFileRow["filePath"]))
content["baseName"] = fu.getBaseName(musicFileRow["filePath"])
content["artist"] = musicFileRow["artist"]
content["title"] = musicFileRow["title"]
content["album"] = musicFileRow["album"]
content["albumArtist"] = musicFileRow["albumArtist"]
content["trackNum"] = musicFileRow["trackNumber"]
content["year"] = musicFileRow["year"]
content["genre"] = musicFileRow["genre"]
content["firstComment"] = musicFileRow["comment"]
content["firstLyrics"] = musicFileRow["lyrics"]
tagger = Taggers.getTagger()
try:
tagger.loadFile(musicFileRow["filePath"])
except:
if tagger.isSupportInfo:
content["length"] = ""
content["bitrate"] = ""
content["sampleRate"] = ""
content["mode"] = ""
else:
if content["artist"].strip() == "":
content["artist"] = tagger.getArtist()
if content["title"].strip() == "":
content["title"] = tagger.getTitle()
if content["album"].strip() == "":
content["album"] = tagger.getAlbum()
if content["albumArtist"].strip() == "":
content["albumArtist"] = tagger.getAlbumArtist()
if str(content["trackNum"]).strip() == "":
content["trackNum"] = tagger.getTrackNum()
if str(content["year"]).strip() == "":
content["year"] = tagger.getYear()
if content["genre"].strip() == "":
content["genre"] = tagger.getGenre()
if content["firstComment"].strip() == "":
content["firstComment"] = tagger.getFirstComment()
if content["firstLyrics"].strip() == "":
content["firstLyrics"] = tagger.getFirstLyrics()
if tagger.isSupportInfo:
content["length"] = tagger.getLength()
content["bitrate"] = tagger.getBitrate()
content["sampleRate"] = tagger.getSampleRate()
content["mode"] = tagger.getMode()
elif Amarok.getSelectedTagSourseType("AmarokCopyTable") == "Only Amarok":
content["path"] = musicFileRow["filePath"]
content["baseNameOfDirectory"] = ""
content["baseName"] = fu.getBaseName(musicFileRow["filePath"])
content["artist"] = musicFileRow["artist"]
content["title"] = musicFileRow["title"]
content["album"] = musicFileRow["album"]
content["albumArtist"] = musicFileRow["albumArtist"]
content["trackNum"] = musicFileRow["trackNumber"]
content["year"] = musicFileRow["year"]
content["genre"] = musicFileRow["genre"]
content["firstComment"] = musicFileRow["comment"]
content["firstLyrics"] = musicFileRow["lyrics"]
tagger = Taggers.getTagger()
if tagger.isSupportInfo:
try:
tagger.loadFile(musicFileRow["filePath"])
except:
content["length"] = ""
content["bitrate"] = ""
content["sampleRate"] = ""
content["mode"] = ""
else:
#.........这里部分代码省略.........