Пример #1
0
 def handleUrlPath(self, path: str) -> str:
     url = QUrl(path)
     pathOk = ""
     if url.isLocalFile():
         pathOk = QDir.toNativeSeparators(url.toLocalFile())
     else:
         pathOk = path
     return pathOk
Пример #2
0
    def openModel(self, path):
        qDebug(f'CanvasHandler::openModel(): {path}')
        qurl = QUrl(path) # don't use fromLocalFile (it will add file:/// as prefix)
        localFilePath = None
        if (qurl.isLocalFile()):
		    # Remove the "file:///" if present
            localFilePath = qurl.toLocalFile()
        else:
            localFilePath = qurl
        self.__m_vtkFboItem.addModelFromFile(localFilePath)
Пример #3
0
 def addProjectsByPaths(self, paths: List[str]):
     """QUrl path (typically is sent from the QML GUI)"""
     if len(paths):
         for path_str in paths:  # convert to strings
             path_qurl = QUrl(path_str)
             if path_qurl.isEmpty():
                 module_logger.warning(f"Given path is empty: {path_str}")
                 continue
             elif path_qurl.isLocalFile():  # file://...
                 path: str = path_qurl.toLocalFile()
             elif path_qurl.isRelative():  # this means that the path string is not starting with 'file://' prefix
                 path: str = path_str  # just use a source string
             else:
                 module_logger.error(f"Incorrect path: {path_str}")
                 continue
             self.addListItem(path)
         self.saveInSettings()  # save after all
     else:
         module_logger.warning("No paths were given")