Exemplo n.º 1
1
def cb_insert_file_list(combobox, index, paths):
    model = combobox.model()
    iconprovider = QFileIconProvider()

    for i, path in enumerate(paths):
        basename = os.path.basename(path)
        item = QStandardItem(basename)
        item.setToolTip(path)
        item.setIcon(iconprovider.icon(QFileInfo(path)))
        model.insertRow(index + i, item)
Exemplo n.º 2
0
    def __init__(self, iconHandler):
        """ Constructor. """

        self._iconHandler = iconHandler
        self._loadedIcons = dict()
        self._decoratedLinkIcons = dict()
        self._decoratedNotRetrievableDataIcons = dict()
        self._decoratedArchiveIcons = dict()
        self._decoratedUnavailableIcons = dict()

        qtIconProvider = QFileIconProvider()
        self._defaultDriveIcon = qtIconProvider.icon(QFileIconProvider.Drive)
        self._defaultFolderIcon = qtIconProvider.icon(QFileIconProvider.Folder)
        self._defaultFileIcon = qtIconProvider.icon(QFileIconProvider.File)
Exemplo n.º 3
0
 def __init__(self, iconHandler):
     """ Constructor. """
     
     self._iconHandler = iconHandler
     self._loadedIcons = dict()
     self._decoratedLinkIcons = dict()
     self._decoratedNotRetrievableDataIcons = dict()
     self._decoratedArchiveIcons = dict()
     self._decoratedUnavailableIcons = dict()
     
     qtIconProvider = QFileIconProvider()
     self._defaultDriveIcon = qtIconProvider.icon(QFileIconProvider.Drive)
     self._defaultFolderIcon = qtIconProvider.icon(QFileIconProvider.Folder)
     self._defaultFileIcon = qtIconProvider.icon(QFileIconProvider.File)
Exemplo n.º 4
0
 def setFileIcon(self, path):
     "每当txtPath的值改变时,就设置快捷方式的图标"
     fi = QFileInfo(path)
     if not fi.exists():
         self.shortcutIcon = QIcon(":/images/unknown.png")
     else:
         ip = QFileIconProvider()
         self.shortcutIcon = ip.icon(fi)
     self.btnFace.setIcon(self.shortcutIcon)
def RecentPath_asqstandarditem(pathitem):
    icon_provider = QFileIconProvider()
    # basename of a normalized name (strip right path component separators)
    basename = os.path.basename(os.path.normpath(pathitem.abspath))
    item = QStandardItem(icon_provider.icon(QFileInfo(pathitem.abspath)),
                         basename)
    item.setToolTip(pathitem.abspath)
    item.setData(pathitem, Qt.UserRole)
    return item
Exemplo n.º 6
0
def cb_insert_file_list(combobox, index, paths):
    model = combobox.model()
    iconprovider = QFileIconProvider()

    for i, path in enumerate(paths):
        basename = os.path.basename(path)
        item = QStandardItem(basename)
        item.setToolTip(path)
        item.setIcon(iconprovider.icon(QFileInfo(path)))
        model.insertRow(index + i, item)
def RecentPath_asqstandarditem(pathitem):
    icon_provider = QFileIconProvider()
    # basename of a normalized name (strip right path component separators)
    basename = os.path.basename(os.path.normpath(pathitem.abspath))
    item = QStandardItem(
        icon_provider.icon(QFileInfo(pathitem.abspath)),
        basename
    )
    item.setToolTip(pathitem.abspath)
    item.setData(pathitem, Qt.UserRole)
    return item
Exemplo n.º 8
0
def getShortcutIcon(shortcut):
    if shortcut["icon"]:
        icon = QIcon(shortcut["icon"])
        if not icon.isNull():
            return icon
    iconProvider = QFileIconProvider()
    if shortcut["path"] == COMPUTER_PATH:
        return QIcon(":/images/user-home.png")
    elif shortcut["path"] == DOCUMENTS_PATH:
        documentsIcon = iconProvider.icon(QFileInfo(QDesktopServices.storageLocation(QDesktopServices.DocumentsLocation)))
        if documentsIcon.isNull():
            return QIcon(":/images/folder-documents.png")
        else:
            return documentsIcon
    elif shortcut["path"] == MUSIC_PATH:
        musicIcon = iconProvider.icon(QFileInfo(QDesktopServices.storageLocation(QDesktopServices.MusicLocation)))
        if musicIcon.isNull():
            return QIcon(":/images/folder-sound.png")
        else:
            return musicIcon
    elif shortcut["path"] == PICTURES_PATH:
        picturesIcon = iconProvider.icon(QFileInfo(QDesktopServices.storageLocation(QDesktopServices.PicturesLocation)))
        if picturesIcon.isNull():
            return QIcon(":/images/folder-image.png")
        else:
            return picturesIcon
    else:
        url = QUrl.fromUserInput(shortcut["path"])
        if url.scheme() == "file":
            if os.path.exists(shortcut["path"]):
                icon = iconProvider.icon(QFileInfo(url.toLocalFile()))
                if not icon.isNull():
                    return icon
            return QIcon(":/images/unknown.png")
        else:
            return QIcon(":/images/httpurl.png")
    return QIcon(":/images/unknown.png")
Exemplo n.º 9
0
 def changeFileIcon(self):
     "用户点击了更换图标按钮。"
     filename = QFileDialog.getOpenFileName(self, self.windowTitle())
     if filename == "":
         return
     image = QImage(filename)
     if not image.isNull():
         self.shortcutIcon = QIcon(QPixmap.fromImage(image))
     else:
         ip = QFileIconProvider()
         shortcutIcon = ip.icon(QFileInfo(filename))
         if shortcutIcon.isNull():
             QMessageBox.information(self, self.trUtf8("更换图标"),
                     self.trUtf8("您选择的文件不包含任何可以使用的图标。"))
             return
         self.shortcutIcon = shortcutIcon
     self.iconPath = filename
     self.btnFace.setIcon(self.shortcutIcon)
Exemplo n.º 10
0
 def icon(self):
     provider = QFileIconProvider()
     return provider.icon(QFileInfo(self.abspath))
Exemplo n.º 11
0
 def icon(self):
     provider = QFileIconProvider()
     return provider.icon(QFileInfo(self.abspath))
Exemplo n.º 12
0
 def icon(self, arg):    # added robustness for filenames like "filename.50.20.jpg"
     if arg.completeSuffix().split(".")[-1] in ["PNG", "png", "jpg", "JPG", "JPEG", "jpeg", "GIF", "gif"]:
         return QIcon(":/image.png")
     else:
         return QFileIconProvider.icon(self, arg)
Exemplo n.º 13
0
 def _setFileIcon(self, curPath):
     if os.path.exists(curPath):
         fileInfo = QFileInfo(curPath)
         iconProvider = QFileIconProvider()
         icon = iconProvider.icon(fileInfo)
         self._fileIconLabel.setPixmap(icon.pixmap(16,16))