Ejemplo n.º 1
0
 def __init__(self):
     QFileIconProvider.__init__(self)
     self.icons = {}
     for key in self.__class__.ICONS.keys():
         self.icons[key] = I('mimetypes/')+self.__class__.ICONS[key]+'.png'
     self.icons['calibre'] = I('lt.png')
     for i in ('dir', 'default', 'zero'):
         self.icons[i] = QIcon(self.icons[i])
Ejemplo n.º 2
0
 def __init__(self):
     QFileIconProvider.__init__(self)
     self.icons = {}
     for key in self.__class__.ICONS.keys():
         self.icons[key] = I(
             'mimetypes/') + self.__class__.ICONS[key] + '.png'
     self.icons['calibre'] = I('lt.png')
     for i in ('dir', 'default', 'zero'):
         self.icons[i] = QIcon(self.icons[i])
Ejemplo n.º 3
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)
Ejemplo n.º 4
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
Ejemplo n.º 5
0
 def __init__(self):
     QFileIconProvider.__init__(self)
     upath, bpath = I('mimetypes'), I('mimetypes', allow_user_override=False)
     if upath != bpath:
         # User has chosen to override mimetype icons
         path_map = {v:I('mimetypes/%s.png' % v) for v in set(self.ICONS.itervalues())}
         icons = self.ICONS.copy()
         for uicon in glob.glob(os.path.join(upath, '*.png')):
             ukey = os.path.basename(uicon).rpartition('.')[0].lower()
             if ukey not in path_map:
                 path_map[ukey] = uicon
                 icons[ukey] = ukey
     else:
         path_map = {v:os.path.join(bpath, v + '.png') for v in set(self.ICONS.itervalues())}
         icons = self.ICONS
     self.icons = {k:path_map[v] for k, v in icons.iteritems()}
     self.icons['calibre'] = I('lt.png', allow_user_override=False)
     for i in ('dir', 'default', 'zero'):
         self.icons[i] = QIcon(self.icons[i])
Ejemplo n.º 6
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()