Example #1
0
 def __init__(self, _filePath, _isOpenDetailsOnNewWindow):
     try:
         if uni.getBoolValue("isForceOpenWithDefaultApplication"):
             _path = fu.checkSource(_filePath)
             Execute.openWith([_path])
         else:
             _path = fu.checkSource(_filePath, "file", False)
             if _path is not None:
                 isOpened = False
                 mtype = fu.getMimeType(_path)
                 if mtype[0] is not None:
                     if mtype[0].split("/")[0] == "text":
                         TextDetails.TextDetails(_path, _isOpenDetailsOnNewWindow)
                         isOpened = True
                     elif mtype[0].split("/")[0] == "audio":
                         if Taggers.getTagger(True) is not None:
                             MusicDetails.MusicDetails(_path, _isOpenDetailsOnNewWindow)
                             isOpened = True
                     elif mtype[0].split("/")[0] == "image":
                         ImageDetails.ImageDetails(_path, "file", _isOpenDetailsOnNewWindow)
                         isOpened = True
                     elif fu.isBinary(_path) is False:
                         TextDetails.TextDetails(_path, _isOpenDetailsOnNewWindow)
                         isOpened = True
                 else:
                     if fu.isBinary(_path) is False:
                         TextDetails.TextDetails(_path, _isOpenDetailsOnNewWindow)
                         isOpened = True
                 if isOpened is False:
                     if uni.getBoolValue("isOpenWithDefaultApplication"):
                         Execute.openWith([_path])
                     else:
                         Dialogs.showError(translate("Details", "File Is Not Supported"),
                                           str(translate("Details",
                                                         "\"%s\" couldn't opened. This file is not supported.")) % Organizer.getLink(
                                               str(_path)))
             elif fu.isDir(_filePath):
                 if uni.getBoolValue("isOpenWithDefaultApplication"):
                     Execute.openWith([_filePath])
                 else:
                     Dialogs.showError(translate("Details", "Directories Is Not Supported"),
                                       str(translate("Details",
                                                     "\"%s\" couldn't opened. Directories is not supported to show details.")) % Organizer.getLink(
                                           str(_filePath)))
             else:
                 Dialogs.showError(translate("Details", "File Is Not Exist"),
                                   str(translate("Details",
                                                 "\"%s\" couldn't opened. This file is not exist.")) % Organizer.getLink(
                                       str(_filePath)))
     except:
         answer = Dialogs.askSpecial(translate("Details", "File Couldn't Opened"),
                                     str(translate("Details",
                                                   "\"%s\" couldn't opened. This file may is not supported. <br>If you think this is a bug, please report us.")) % Organizer.getLink(
                                         str(_filePath)),
                                     translate("QuickMake", "Report This Bug"), translate("QuickMake", "OK"), None)
         if answer == translate("QuickMake", "Report This Bug"):
             ReportBug.ReportBug()
Example #2
0
 def hash(self):
     sourceFile = str(self.lePathOfPackage.text())
     sourceFile = fu.checkSource(sourceFile, "file")
     if sourceFile is not None:
         hashType = str(self.cbHash.currentText())
         if hashType is not None:
             hashDigestContent = fu.getHashDigest(sourceFile, hashType)
             if hashDigestContent is not False:
                 self.teHashDigest.setText(str(hashDigestContent))
                 if self.cbHashOutput.currentIndex() == 1:
                     if fu.createHashDigestFile(sourceFile, str(self.leHashDigestFile.text()), hashType, False,
                                                hashDigestContent):
                         Dialogs.show(translate("Hasher", "Hash Digest File Created"),
                                      str(translate("Hasher", "Hash digest writed into %s")) % str(
                                          self.leHashDigestFile.text()))
                     else:
                         Dialogs.showError(translate("Hasher", "Hash Digest File Is Not Created"),
                                           translate("Hasher", "Hash digest file not cteated."))
                 elif self.cbHashOutput.currentIndex() == 2:
                     MApplication.clipboard().setText(str(hashDigestContent))
                     Dialogs.show(translate("Hasher", "Hash Digest Copied To Clipboard"),
                                  str(translate("Hasher",
                                                "Hash digest copied to clipboard.Hash digest is : <br>%s")) % hashDigestContent)
             else:
                 Dialogs.showError(translate("Hasher", "Hash Digest Is Not Created"),
                                   translate("Hasher", "Hash digest not cteated."))
Example #3
0
 def checkSource(self, _oldPath, _objectType="fileAndDirectory", _isCheckWritable=True):
     _path = fu.checkSource(_oldPath, _objectType, False)
     if _path is None:
         if _objectType == "file":
             answer = Dialogs.ask(translate("QuickMake", "Cannot Find File"),
                                  str(translate("FileUtils",
                                                "\"%s\" : cannot find a file with this name.<br>Are you want to organize parent directory with Hamsi Manager?")) % Organizer.getLink(
                                      _oldPath))
             if answer == Dialogs.Yes:
                 self.organizeWithHamsiManager(_oldPath)
             return None
         elif _objectType == "directory":
             answer = Dialogs.ask(translate("QuickMake", "Cannot Find Directory"),
                                  str(translate("FileUtils",
                                                "\"%s\" : cannot find a folder with this name.<br>Are you want to organize parent directory with Hamsi Manager?")) % Organizer.getLink(
                                      _oldPath))
             if answer == Dialogs.Yes:
                 self.organizeWithHamsiManager(_oldPath)
             return None
         else:
             answer = Dialogs.ask(translate("QuickMake", "Cannot Find File Or Directory"),
                                  str(translate("FileUtils",
                                                "\"%s\" : cannot find a file or directory with this name.<br>Are you want to organize parent directory with Hamsi Manager?")) % Organizer.getLink(
                                      _oldPath))
             if answer == Dialogs.Yes:
                 self.organizeWithHamsiManager(_oldPath)
             return None
     if _isCheckWritable:
         if fu.isWritableFileOrDir(_oldPath) is False:
             return None
     return _path
Example #4
0
 def changeCoverValues(self, _image=None, _valueType="file"):
     self.zoomValue = 1.0
     if _image is not None and _valueType == "file":
         _image = fu.checkSource(_image, "file", False)
         if _image is None:
             if self.isCorrectedWhenNotExist:
                 _image = fu.joinPath(fu.themePath, "Images", "ok.png")
             else:
                 _image = fu.joinPath(fu.themePath, "Images",
                                      "notExist.png")
     elif _valueType == "file":
         _image = fu.joinPath(fu.themePath, "Images", "notExist.png")
     self.pmapImage.detach()
     if _valueType == "data":
         self.pmapImage.loadFromData(_image)
     else:
         self.pmapImage.load(str(_image))
     self.lblImage.setPixmap(self.pmapImage)
     self.width = self.pmapImage.width()
     self.height = self.pmapImage.height()
     while 1 == 1:
         if self.width > self.defaultMaxSize[
                 0] or self.height > self.defaultMaxSize[1]:
             self.width *= 0.9
             self.height *= 0.9
         else:
             break
     self.lblImage.resize(int(self.width), int(self.height))
Example #5
0
 def setSourceToSearch(self, _isReload=True, _isLoadFromCache=False):
     try:
         if self.sourceToSearch is None or _isReload:
             sourceToSearch = ""
             self.isMultipleSource = False
             pathToSearchs = str(self.lePathToSeach.text())
             if fu.isExist(pathToSearchs) is False and pathToSearchs.find(";") != -1:
                 self.isMultipleSource = True
             for pathToSearch in uni.getListFromListString(pathToSearchs, ";"):
                 if pathToSearch in self.sourceToSearchCache and _isLoadFromCache:
                     sourceToSearch += self.sourceToSearchCache[pathToSearch]
                 else:
                     pathToSearch = fu.checkSource(pathToSearch)
                     if pathToSearch is not None:
                         if fu.isReadableFileOrDir(pathToSearch):
                             if fu.isFile(pathToSearch) and fu.isBinary(pathToSearch) is False:
                                 sts = fu.readFromFile(pathToSearch) + "\n"
                                 sourceToSearch += sts
                                 self.sourceToSearchCache[pathToSearch] = sts
                             elif fu.isDir(pathToSearch):
                                 sts = fu.getFileTree(pathToSearch, -1, "return", "plainText", "fileList") + "\n"
                                 sourceToSearch += sts
                                 self.sourceToSearchCache[pathToSearch] = sts
             self.sourceToSearch = sourceToSearch
             if sourceToSearch != "":
                 return True
             return False
         else:
             return True
     except:
         ReportBug.ReportBug()
Example #6
0
 def __init__(self, _filePath, _isOpenDetailsOnNewWindow):
     global currentDialogs
     _filePath = fu.checkSource(_filePath, "file")
     if _filePath is not None:
         if _isOpenDetailsOnNewWindow is False:
             isHasOpenedDialog = False
             for dialog in currentDialogs:
                 if dialog.isVisible():
                     isHasOpenedDialog = True
                     dialog.changeFile(_filePath)
                     dialog.activateWindow()
                     dialog.raise_()
                     break
             if isHasOpenedDialog is False:
                 _isOpenDetailsOnNewWindow = True
         if _isOpenDetailsOnNewWindow:
             currentDialogs.append(self)
             MDialog.__init__(self, MApplication.activeWindow())
             if isActivePyKDE4:
                 self.setButtons(MDialog.NoDefault)
             self.charSet = MComboBox()
             self.charSet.addItems(uni.getCharSets())
             self.charSet.setCurrentIndex(self.charSet.findText(uni.MySettings["fileSystemEncoding"]))
             self.infoLabels = {}
             self.infoValues = {}
             self.fileValues = {}
             pbtnClose = MPushButton(translate("TextDetails", "Close"))
             pbtnSave = MPushButton(translate("TextDetails", "Save Changes"))
             pbtnSave.setIcon(MIcon("Images:save.png"))
             MObject.connect(pbtnClose, SIGNAL("clicked()"), self.close)
             MObject.connect(pbtnSave, SIGNAL("clicked()"), self.save)
             self.labels = [translate("TextDetails", "File Path : "),
                            translate("TextDetails", "Content : ")]
             self.pnlMain = MWidget()
             self.vblMain = MVBoxLayout(self.pnlMain)
             self.pnlClearable = None
             self.changeFile(_filePath, True)
             HBOXs, VBOXs = [], []
             VBOXs.append(MVBoxLayout())
             HBOXs.append(MHBoxLayout())
             HBOXs[-1].addWidget(self.charSet, 1)
             HBOXs[-1].addWidget(pbtnSave, 4)
             VBOXs[0].addLayout(HBOXs[-1])
             VBOXs[0].addWidget(pbtnClose)
             self.vblMain.addLayout(VBOXs[0], 1)
             if isActivePyKDE4:
                 self.setMainWidget(self.pnlMain)
             else:
                 self.setLayout(self.vblMain)
             self.show()
             self.setMinimumWidth(700)
             self.setMinimumHeight(500)
     else:
         Dialogs.showError(translate("TextDetails", "File Does Not Exist"),
                           str(translate("TextDetails",
                                         "\"%s\" does not exist.<br>Table will be refreshed automatically!<br>Please retry.")
                           ) % Organizer.getLink(str(_filePath)))
         if hasattr(getMainWindow(),
                    "FileManager") and getMainWindow().FileManager is not None: getMainWindow().FileManager.makeRefresh()
Example #7
0
 def makeRefresh(self, _newDirectoryPath="", _isOnlyBrowser=False):
     try:
         if _newDirectoryPath != "" and _newDirectoryPath is not True and _newDirectoryPath is not False:
             self.goTo(_newDirectoryPath, False)
         else:
             sourcePath = fu.checkSource(str(self.currentDirectory), "directory")
             if sourcePath is not None:
                 if self.currentDirectory != str(sourcePath):
                     self.goTo(sourcePath, False)
                 else:
                     self.makeRefreshOnlyFileList()
                     self.makeRefreshOnlyFileListByTree()
                     if _isOnlyBrowser is False:
                         self.showInTable()
             else:
                 self.goTo(fu.getRealDirName(str(self.currentDirectory)), False)
     except:
         ReportBug.ReportBug()
Example #8
0
    def goTo(self, _path, _isRemember=True, _isOnlyBrowser=False):
        try:
            _path = fu.checkSource(str(_path))
            if _path is not None:
                if fu.isReadableFileOrDir(_path):
                    if fu.isDir(_path):
                        if _isRemember:
                            self.future = []
                            self.history.append(self.currentDirectory)
                        if len(_path) > 1 and _path[-1] == fu.sep:
                            _path = _path[:-1]
                        self.currentDirectory = str(_path)
                        if isActivePyKDE4:
                            self.dirLister.openUrl(MUrl(self.currentDirectory))
                            self.trvFileManager.setCurrentIndex(
                                self.dirModelForTree.index(_path))
                            self.isGoToFromUrlNavigator = False
                            self.urlNavigator.setUrl(
                                MUrl(self.currentDirectory))
                            self.isGoToFromUrlNavigator = True
                            self.isGoToFromDirOperator = False
                            self.dirOperator.setUrl(
                                MUrl(self.currentDirectory), False)
                            self.isGoToFromDirOperator = True
                        else:
                            self.lstvFileManager.setRootIndex(
                                self.dirModel.index(_path))
                            self.trvFileManager.setCurrentIndex(
                                self.dirModelForTree.index(_path))
                        self.actForward.setEnabled(False)
                        if _isOnlyBrowser is False:
                            self.showInTable()
                        self.actBack.setEnabled(True)
                        if str(self.currentDirectory) == fu.sep:
                            self.actUp.setEnabled(False)
                        else:
                            self.actUp.setEnabled(True)
                    elif fu.isFile(_path):
                        from Details import Details

                        Details(str(_path),
                                uni.getBoolValue("isOpenDetailsInNewWindow"))
        except:
            ReportBug.ReportBug()
Example #9
0
 def makeRefresh(self, _newDirectoryPath="", _isOnlyBrowser=False):
     try:
         if _newDirectoryPath != "" and _newDirectoryPath is not True and _newDirectoryPath is not False:
             self.goTo(_newDirectoryPath, False)
         else:
             sourcePath = fu.checkSource(str(self.currentDirectory),
                                         "directory")
             if sourcePath is not None:
                 if self.currentDirectory != str(sourcePath):
                     self.goTo(sourcePath, False)
                 else:
                     self.makeRefreshOnlyFileList()
                     self.makeRefreshOnlyFileListByTree()
                     if _isOnlyBrowser is False:
                         self.showInTable()
             else:
                 self.goTo(fu.getRealDirName(str(self.currentDirectory)),
                           False)
     except:
         ReportBug.ReportBug()
Example #10
0
    def play(self, _filePath="", _isPlayNow=True):
        try:
            MApplication.processEvents()
            playerName = uni.MySettings["playerName"]
            if self.Player is None or self.PlayerName != playerName:
                self.stop()
                self.PlayerName = playerName
                if playerName == "Phonon":
                    self.Player = M_Phonon()
                elif playerName == "Phonon (PySide)":
                    self.Player = M_Phonon_PySide()
                elif playerName == "tkSnack":
                    self.Player = M_tkSnack()
                else:
                    self.Player = M_MPlayer()
            self.stop()
            if _filePath == "":
                _filePath = getMainTable().values[getMainTable().currentRow()]["path"]
            if _filePath == "" and self.file != "":
                _filePath = self.file
            else:
                self.file = _filePath
            _filePath = fu.checkSource(_filePath, "file")
            if _filePath is not None:
                import Taggers

                if Taggers.getTagger(True) is not None:
                    self.musicTags = Musics.readMusicFile(_filePath, False)
                    self.setInfoText(str(("%s - %s (%s)") % (
                        self.musicTags["artist"], self.musicTags["title"], self.musicTags["album"])))
                else:
                    self.musicTags = None
                    self.setInfoText(str("- - -"))
                if _isPlayNow:
                    if self.Player.play(_filePath):
                        self.tbPause.setEnabled(True)
                        self.tbMute.setEnabled(True)
                        self.tbStop.setEnabled(True)
                        self.tbPlay.setEnabled(False)
        except:
            ReportBug.ReportBug()
Example #11
0
 def hash(self):
     sourceFile = str(self.lePathOfPackage.text())
     sourceFile = fu.checkSource(sourceFile, "file")
     if sourceFile is not None:
         hashType = str(self.cbHash.currentText())
         if hashType is not None:
             hashDigestContent = fu.getHashDigest(sourceFile, hashType)
             if hashDigestContent is not False:
                 self.teHashDigest.setText(str(hashDigestContent))
                 if self.cbHashOutput.currentIndex() == 1:
                     if fu.createHashDigestFile(
                             sourceFile, str(self.leHashDigestFile.text()),
                             hashType, False, hashDigestContent):
                         Dialogs.show(
                             translate("Hasher",
                                       "Hash Digest File Created"),
                             str(
                                 translate("Hasher",
                                           "Hash digest writed into %s")) %
                             str(self.leHashDigestFile.text()))
                     else:
                         Dialogs.showError(
                             translate("Hasher",
                                       "Hash Digest File Is Not Created"),
                             translate("Hasher",
                                       "Hash digest file not cteated."))
                 elif self.cbHashOutput.currentIndex() == 2:
                     MApplication.clipboard().setText(
                         str(hashDigestContent))
                     Dialogs.show(
                         translate("Hasher",
                                   "Hash Digest Copied To Clipboard"),
                         str(
                             translate(
                                 "Hasher",
                                 "Hash digest copied to clipboard.Hash digest is : <br>%s"
                             )) % hashDigestContent)
             else:
                 Dialogs.showError(
                     translate("Hasher", "Hash Digest Is Not Created"),
                     translate("Hasher", "Hash digest not cteated."))
Example #12
0
 def setSourceToSearch(self, _isReload=True, _isLoadFromCache=False):
     try:
         if self.sourceToSearch is None or _isReload:
             sourceToSearch = ""
             self.isMultipleSource = False
             pathToSearchs = str(self.lePathToSeach.text())
             if fu.isExist(pathToSearchs) is False and pathToSearchs.find(
                     ";") != -1:
                 self.isMultipleSource = True
             for pathToSearch in uni.getListFromListString(
                     pathToSearchs, ";"):
                 if pathToSearch in self.sourceToSearchCache and _isLoadFromCache:
                     sourceToSearch += self.sourceToSearchCache[
                         pathToSearch]
                 else:
                     pathToSearch = fu.checkSource(pathToSearch)
                     if pathToSearch is not None:
                         if fu.isReadableFileOrDir(pathToSearch):
                             if fu.isFile(pathToSearch) and fu.isBinary(
                                     pathToSearch) is False:
                                 sts = fu.readFromFile(pathToSearch) + "\n"
                                 sourceToSearch += sts
                                 self.sourceToSearchCache[
                                     pathToSearch] = sts
                             elif fu.isDir(pathToSearch):
                                 sts = fu.getFileTree(
                                     pathToSearch, -1, "return",
                                     "plainText", "fileList") + "\n"
                                 sourceToSearch += sts
                                 self.sourceToSearchCache[
                                     pathToSearch] = sts
             self.sourceToSearch = sourceToSearch
             if sourceToSearch != "":
                 return True
             return False
         else:
             return True
     except:
         ReportBug.ReportBug()
Example #13
0
    def goTo(self, _path, _isRemember=True, _isOnlyBrowser=False):
        try:
            _path = fu.checkSource(str(_path))
            if _path is not None:
                if fu.isReadableFileOrDir(_path):
                    if fu.isDir(_path):
                        if _isRemember:
                            self.future = []
                            self.history.append(self.currentDirectory)
                        if len(_path) > 1 and _path[-1] == fu.sep:
                            _path = _path[:-1]
                        self.currentDirectory = str(_path)
                        if isActivePyKDE4:
                            self.dirLister.openUrl(MUrl(self.currentDirectory))
                            self.trvFileManager.setCurrentIndex(self.dirModelForTree.index(_path))
                            self.isGoToFromUrlNavigator = False
                            self.urlNavigator.setUrl(MUrl(self.currentDirectory))
                            self.isGoToFromUrlNavigator = True
                            self.isGoToFromDirOperator = False
                            self.dirOperator.setUrl(MUrl(self.currentDirectory), False)
                            self.isGoToFromDirOperator = True
                        else:
                            self.lstvFileManager.setRootIndex(self.dirModel.index(_path))
                            self.trvFileManager.setCurrentIndex(self.dirModelForTree.index(_path))
                        self.actForward.setEnabled(False)
                        if _isOnlyBrowser is False:
                            self.showInTable()
                        self.actBack.setEnabled(True)
                        if str(self.currentDirectory) == fu.sep:
                            self.actUp.setEnabled(False)
                        else:
                            self.actUp.setEnabled(True)
                    elif fu.isFile(_path):
                        from Details import Details

                        Details(str(_path), uni.getBoolValue("isOpenDetailsInNewWindow"))
        except:
            ReportBug.ReportBug()
Example #14
0
 def writeContents(self):
     self.changedValueNumber = 0
     oldAndNewPathValues = []
     isNewDirectoriesSame = True
     isMovedToNewDirectory = False
     currentDirectoryPath = ""
     newDirectoryPath = ""
     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:
                         baseNameOfDirectory = str(
                             self.values[rowNo]["baseNameOfDirectory"])
                         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", baseNameOfDirectory):
                             baseNameOfDirectory = str(self.item(rowNo, 0).text())
                             self.changedValueNumber += 1
                             isMovedToNewDirectory = True
                             currentDirectoryPath = fu.getDirName(
                                 self.values[rowNo]["path"])
                             newDirectoryPath = fu.joinPath(
                                 fu.getDirName(fu.getDirName(self.values[rowNo]["path"])),
                                 baseNameOfDirectory)
                             self.setNewDirectory(newDirectoryPath)
                             if rowNo > 0:
                                 if str(self.item(rowNo - 1, 0).text()) != baseNameOfDirectory:
                                     isNewDirectoriesSame = False
                         if self.isChangeableItem(rowNo, "baseName", baseName, False):
                             baseName = str(self.item(rowNo, 1).text())
                             self.changedValueNumber += 1
                         newFilePath = fu.joinPath(
                             fu.getDirName(fu.getDirName(self.values[rowNo]["path"])),
                             baseNameOfDirectory, 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 self.rowCount() == len(oldAndNewPathValues) and isMovedToNewDirectory and isNewDirectoriesSame:
         otherFileNames = fu.readDirectory(currentDirectoryPath, "fileAndDirectory", True)
         if len(otherFileNames) > 0:
             answer = Dialogs.ask(translate("FileUtils/Musics", "There Are More Files"),
                                  str(translate("FileUtils/Musics",
                                                "\"%s\" : there are more files in this directory.<br>Are you want to move all found files into new directory?<br>New Directory : \"%s\"")) % (
                                      Organizer.getLink(currentDirectoryPath), Organizer.getLink(newDirectoryPath)))
             if answer == Dialogs.Yes:
                 uni.startThreadAction()
                 allItemNumber = len(otherFileNames)
                 for rowNo, fileName in enumerate(otherFileNames):
                     isContinueThreadAction = uni.isContinueThreadAction()
                     if isContinueThreadAction:
                         try:
                             oldFilePath = fu.getRealPath(fu.joinPath(currentDirectoryPath, fileName))
                             newFilePath = fu.getRealPath(fu.joinPath(newDirectoryPath, fileName))
                             if oldFilePath != newFilePath:
                                 oldAndNewPaths = {}
                                 oldAndNewPaths["oldPath"] = oldFilePath
                                 oldAndNewPaths["newPath"] = fu.moveOrChange(oldFilePath, newFilePath,
                                                                             fu.getObjectType(oldFilePath))
                                 if oldFilePath != oldAndNewPaths["newPath"]:
                                     oldAndNewPathValues.append(oldAndNewPaths)
                         except:
                             ReportBug.ReportBug()
                     else:
                         allItemNumber = rowNo + 1
                     Dialogs.showState(translate("FileUtils/Covers", "Writing Directory And File Informations"),
                                       rowNo + 1, allItemNumber, True)
                     if isContinueThreadAction is False:
                         break
                 uni.finishThreadAction()
                 if uni.getBoolValue("isClearEmptyDirectoriesWhenFileMove"):
                     fu.checkEmptyDirectories(currentDirectoryPath, True, True,
                                              uni.getBoolValue("isAutoCleanSubFolderWhenFileMove"))
                 if (uni.isActiveDirectoryCover and uni.getBoolValue("isActiveAutoMakeIconToDirectory") and
                         uni.getBoolValue("isAutoMakeIconToDirectoryWhenFileMove")):
                     fu.checkIcon(newDirectoryPath)
     return True
Example #15
0
def getScript(_filePath):
    _filePath = fu.checkSource(_filePath, "file", False)
    if _filePath is not None:
        return fu.readFromFile(_filePath)
    return None
Example #16
0
 def writeContents(self):
     self.changedValueNumber = 0
     oldAndNewPathValues = []
     isNewDirectoriesSame = True
     isMovedToNewDirectory = False
     currentDirectoryPath = ""
     newDirectoryPath = ""
     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:
                         baseNameOfDirectory = str(
                             self.values[rowNo]["baseNameOfDirectory"])
                         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",
                                                  baseNameOfDirectory):
                             baseNameOfDirectory = str(
                                 self.item(rowNo, 0).text())
                             self.changedValueNumber += 1
                             isMovedToNewDirectory = True
                             currentDirectoryPath = fu.getDirName(
                                 self.values[rowNo]["path"])
                             newDirectoryPath = fu.joinPath(
                                 fu.getDirName(
                                     fu.getDirName(
                                         self.values[rowNo]["path"])),
                                 baseNameOfDirectory)
                             self.setNewDirectory(newDirectoryPath)
                             if rowNo > 0:
                                 if str(self.item(
                                         rowNo - 1,
                                         0).text()) != baseNameOfDirectory:
                                     isNewDirectoriesSame = False
                         if self.isChangeableItem(rowNo, "baseName",
                                                  baseName, False):
                             baseName = str(self.item(rowNo, 1).text())
                             self.changedValueNumber += 1
                         newFilePath = fu.joinPath(
                             fu.getDirName(
                                 fu.getDirName(self.values[rowNo]["path"])),
                             baseNameOfDirectory, 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 self.rowCount() == len(
             oldAndNewPathValues
     ) and isMovedToNewDirectory and isNewDirectoriesSame:
         otherFileNames = fu.readDirectory(currentDirectoryPath,
                                           "fileAndDirectory", True)
         if len(otherFileNames) > 0:
             answer = Dialogs.ask(
                 translate("FileUtils/Musics", "There Are More Files"),
                 str(
                     translate(
                         "FileUtils/Musics",
                         "\"%s\" : there are more files in this directory.<br>Are you want to move all found files into new directory?<br>New Directory : \"%s\""
                     )) % (Organizer.getLink(currentDirectoryPath),
                           Organizer.getLink(newDirectoryPath)))
             if answer == Dialogs.Yes:
                 uni.startThreadAction()
                 allItemNumber = len(otherFileNames)
                 for rowNo, fileName in enumerate(otherFileNames):
                     isContinueThreadAction = uni.isContinueThreadAction()
                     if isContinueThreadAction:
                         try:
                             oldFilePath = fu.getRealPath(
                                 fu.joinPath(currentDirectoryPath,
                                             fileName))
                             newFilePath = fu.getRealPath(
                                 fu.joinPath(newDirectoryPath, fileName))
                             if oldFilePath != newFilePath:
                                 oldAndNewPaths = {}
                                 oldAndNewPaths["oldPath"] = oldFilePath
                                 oldAndNewPaths[
                                     "newPath"] = fu.moveOrChange(
                                         oldFilePath, newFilePath,
                                         fu.getObjectType(oldFilePath))
                                 if oldFilePath != oldAndNewPaths["newPath"]:
                                     oldAndNewPathValues.append(
                                         oldAndNewPaths)
                         except:
                             ReportBug.ReportBug()
                     else:
                         allItemNumber = rowNo + 1
                     Dialogs.showState(
                         translate(
                             "FileUtils/Covers",
                             "Writing Directory And File Informations"),
                         rowNo + 1, allItemNumber, True)
                     if isContinueThreadAction is False:
                         break
                 uni.finishThreadAction()
                 if uni.getBoolValue("isClearEmptyDirectoriesWhenFileMove"):
                     fu.checkEmptyDirectories(
                         currentDirectoryPath, True, True,
                         uni.getBoolValue(
                             "isAutoCleanSubFolderWhenFileMove"))
                 if (uni.isActiveDirectoryCover and
                         uni.getBoolValue("isActiveAutoMakeIconToDirectory")
                         and uni.getBoolValue(
                             "isAutoMakeIconToDirectoryWhenFileMove")):
                     fu.checkIcon(newDirectoryPath)
     return True
    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
Example #18
0
    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
Example #19
0
    def __init__(self, _filePath, _isOpenDetailsOnNewWindow=True):
        global currentDialogs
        MDialog.__init__(self, MApplication.activeWindow())
        self.currenctImageDialogs = []
        _filePath = fu.checkSource(_filePath, "file")
        if _filePath is not None:
            if _isOpenDetailsOnNewWindow is False:
                isHasOpenedDialog = False
                for dialog in currentDialogs:
                    if dialog.isVisible():
                        isHasOpenedDialog = True
                        dialog.closeCurrenctImageDialogs()
                        dialog.changeFile(_filePath)
                        dialog.activateWindow()
                        dialog.raise_()
                        dialog.player.play(_filePath,
                                           dialog.isPlayNow.isChecked())
                        break
                if isHasOpenedDialog is False:
                    _isOpenDetailsOnNewWindow = True
            if _isOpenDetailsOnNewWindow:
                currentDialogs.append(self)
                if isActivePyKDE4:
                    self.setButtons(MDialog.NoDefault)
                self.isActiveAddImage = False
                self.infoLabels = {}
                self.infoValues = {}
                self.musicValues = {}
                self.pbtnClose = MPushButton(translate("MusicDetails",
                                                       "Close"))
                self.pbtnSave = MPushButton(
                    translate("MusicDetails", "Save Changes"))
                self.pbtnSave.setIcon(MIcon("Images:save.png"))
                MObject.connect(self.pbtnClose, SIGNAL("clicked()"),
                                self.close)
                MObject.connect(self.pbtnSave, SIGNAL("clicked()"), self.save)
                self.labels = [
                    translate("MusicDetails", "Directory: "),
                    translate("MusicDetails", "File Name: "),
                    translate("MusicDetails", "Artist: "),
                    translate("MusicDetails", "Title: "),
                    translate("MusicDetails", "Album: "),
                    translate("MusicDetails", "Album Artist: "),
                    translate("MusicDetails", "Track: "),
                    translate("MusicDetails", "Year: "),
                    translate("MusicDetails", "Genre: ")
                ]
                self.pnlMain = MWidget()
                self.vblMain = MVBoxLayout(self.pnlMain)
                self.pnlClearable = None
                self.changeFile(_filePath)

                buttonHBOXs = MHBoxLayout()
                buttonHBOXs.addWidget(self.pbtnSave)
                buttonHBOXs.addWidget(self.pbtnClose)
                self.vblMain.addLayout(buttonHBOXs)
                if isActivePyKDE4:
                    self.setMainWidget(self.pnlMain)
                else:
                    self.setLayout(self.vblMain)
                self.show()
                self.player.play(_filePath, self.isPlayNow.isChecked())
        else:
            Dialogs.showError(
                translate("MusicDetails", "File Does Not Exist"),
                str(
                    translate(
                        "MusicDetails",
                        "\"%s\" does not exist.<br>Table will be refreshed automatically!<br>Please retry."
                    )) % Organizer.getLink(str(_filePath)))
            if hasattr(
                    getMainWindow(),
                    "FileManager") and getMainWindow().FileManager is not None:
                getMainWindow().FileManager.makeRefresh()
Example #20
0
 def __init__(self, _filePath, _isOpenDetailsOnNewWindow):
     try:
         if uni.getBoolValue("isForceOpenWithDefaultApplication"):
             _path = fu.checkSource(_filePath)
             Execute.openWith([_path])
         else:
             _path = fu.checkSource(_filePath, "file", False)
             if _path is not None:
                 isOpened = False
                 mtype = fu.getMimeType(_path)
                 if mtype[0] is not None:
                     if mtype[0].split("/")[0] == "text":
                         TextDetails.TextDetails(_path,
                                                 _isOpenDetailsOnNewWindow)
                         isOpened = True
                     elif mtype[0].split("/")[0] == "audio":
                         if Taggers.getTagger(True) is not None:
                             MusicDetails.MusicDetails(
                                 _path, _isOpenDetailsOnNewWindow)
                             isOpened = True
                     elif mtype[0].split("/")[0] == "image":
                         ImageDetails.ImageDetails(
                             _path, "file", _isOpenDetailsOnNewWindow)
                         isOpened = True
                     elif fu.isBinary(_path) is False:
                         TextDetails.TextDetails(_path,
                                                 _isOpenDetailsOnNewWindow)
                         isOpened = True
                 else:
                     if fu.isBinary(_path) is False:
                         TextDetails.TextDetails(_path,
                                                 _isOpenDetailsOnNewWindow)
                         isOpened = True
                 if isOpened is False:
                     if uni.getBoolValue("isOpenWithDefaultApplication"):
                         Execute.openWith([_path])
                     else:
                         Dialogs.showError(
                             translate("Details", "File Is Not Supported"),
                             str(
                                 translate(
                                     "Details",
                                     "\"%s\" couldn't opened. This file is not supported."
                                 )) % Organizer.getLink(str(_path)))
             elif fu.isDir(_filePath):
                 if uni.getBoolValue("isOpenWithDefaultApplication"):
                     Execute.openWith([_filePath])
                 else:
                     Dialogs.showError(
                         translate("Details",
                                   "Directories Is Not Supported"),
                         str(
                             translate(
                                 "Details",
                                 "\"%s\" couldn't opened. Directories is not supported to show details."
                             )) % Organizer.getLink(str(_filePath)))
             else:
                 Dialogs.showError(
                     translate("Details", "File Is Not Exist"),
                     str(
                         translate(
                             "Details",
                             "\"%s\" couldn't opened. This file is not exist."
                         )) % Organizer.getLink(str(_filePath)))
     except:
         answer = Dialogs.askSpecial(
             translate("Details", "File Couldn't Opened"),
             str(
                 translate(
                     "Details",
                     "\"%s\" couldn't opened. This file may is not supported. <br>If you think this is a bug, please report us."
                 )) % Organizer.getLink(str(_filePath)),
             translate("QuickMake", "Report This Bug"),
             translate("QuickMake", "OK"), None)
         if answer == translate("QuickMake", "Report This Bug"):
             ReportBug.ReportBug()
Example #21
0
    def __init__(self, _filePath, _isOpenDetailsOnNewWindow=True):
        global currentDialogs
        MDialog.__init__(self, MApplication.activeWindow())
        self.currenctImageDialogs = []
        _filePath = fu.checkSource(_filePath, "file")
        if _filePath is not None:
            if _isOpenDetailsOnNewWindow is False:
                isHasOpenedDialog = False
                for dialog in currentDialogs:
                    if dialog.isVisible():
                        isHasOpenedDialog = True
                        dialog.closeCurrenctImageDialogs()
                        dialog.changeFile(_filePath)
                        dialog.activateWindow()
                        dialog.raise_()
                        dialog.player.play(_filePath, dialog.isPlayNow.isChecked())
                        break
                if isHasOpenedDialog is False:
                    _isOpenDetailsOnNewWindow = True
            if _isOpenDetailsOnNewWindow:
                currentDialogs.append(self)
                if isActivePyKDE4:
                    self.setButtons(MDialog.NoDefault)
                self.isActiveAddImage = False
                self.infoLabels = {}
                self.infoValues = {}
                self.musicValues = {}
                self.pbtnClose = MPushButton(translate("MusicDetails", "Close"))
                self.pbtnSave = MPushButton(translate("MusicDetails", "Save Changes"))
                self.pbtnSave.setIcon(MIcon("Images:save.png"))
                MObject.connect(self.pbtnClose, SIGNAL("clicked()"), self.close)
                MObject.connect(self.pbtnSave, SIGNAL("clicked()"), self.save)
                self.labels = [translate("MusicDetails", "Directory: "),
                               translate("MusicDetails", "File Name: "),
                               translate("MusicDetails", "Artist: "),
                               translate("MusicDetails", "Title: "),
                               translate("MusicDetails", "Album: "),
                               translate("MusicDetails", "Album Artist: "),
                               translate("MusicDetails", "Track: "),
                               translate("MusicDetails", "Year: "),
                               translate("MusicDetails", "Genre: ")]
                self.pnlMain = MWidget()
                self.vblMain = MVBoxLayout(self.pnlMain)
                self.pnlClearable = None
                self.changeFile(_filePath)

                buttonHBOXs = MHBoxLayout()
                buttonHBOXs.addWidget(self.pbtnSave)
                buttonHBOXs.addWidget(self.pbtnClose)
                self.vblMain.addLayout(buttonHBOXs)
                if isActivePyKDE4:
                    self.setMainWidget(self.pnlMain)
                else:
                    self.setLayout(self.vblMain)
                self.show()
                self.player.play(_filePath, self.isPlayNow.isChecked())
        else:
            Dialogs.showError(translate("MusicDetails", "File Does Not Exist"),
                              str(translate("MusicDetails",
                                            "\"%s\" does not exist.<br>Table will be refreshed automatically!<br>Please retry.")
                              ) % Organizer.getLink(str(_filePath)))
            if hasattr(getMainWindow(),
                       "FileManager") and getMainWindow().FileManager is not None: getMainWindow().FileManager.makeRefresh()