Exemplo n.º 1
0
 def icon(self, arg):
     if isinstance(arg, QFileInfo):
         return self.load_icon(arg)
     if arg == QFileIconProvider.Folder:
         return self.icons['dir']
     if arg == QFileIconProvider.File:
         return self.icons['default']
     return QFileIconProvider.icon(self, arg)
Exemplo n.º 2
0
    def iconFromFileName(self, fileName):
        '''
        @param: fileName QString
        @return: QIcon
        '''
        tempInfo = QFileInfo(fileName)
        suffix = tempInfo.suffix()
        if suffix in self._s_iconCache:
            return self._s_iconCache[suffix]

        iconProvider = QFileIconProvider()
        tempFile = DataPaths.path(DataPaths.Temp) + '/XXXXXX.' + suffix
        tempFile.open()
        tempInfo.setFile(tempFile.fileName())

        icon = QIcon(iconProvider.icon(tempInfo))
        self._s_iconCache[suffix] = icon
Exemplo n.º 3
0
    def startDownloading(self):
        self._download.finished.connect(self._finished)
        self._download.downloadProgress.connect(self._downloadProgress)

        self._downloading = True
        if self._downTimer.elapsed() < 1:  # TODO: ?
            self._downTimer.start()

        self._updateDownloadInfo(0, self._download.receivedBytes(),
                                 self._download.totalBytes())

        if const.OS_LINUX:
            # QFileIconProvider uses only suffix on Linux
            iconProvider = QFileIconProvider()
            # QIcon
            fileIcon = iconProvider.icon(QFileInfo(self._fileName))
            if not fileIcon.isNull():
                self._ui.fileIcon.setPixmap(fileIcon.pixmap(30))
            else:
                self._ui.fileIcon.setPixmap(self.style().standardIcon(
                    QStyle.SP_FileIcon).pixmap(30))
        else:
            self._ui.fileIcon.hide()