Esempio n. 1
0
 def iconFromRef(self, sidebar_model, iconRef, _old):
     icon = _old(sidebar_model, iconRef)
     if icon:
         pixmap = icon.pixmap(32, 32)
         image = pixmap.toImage()
         image.invertPixels()
         new_icon = aqt.QIcon(QPixmap.fromImage(image))
         return new_icon
     return icon
Esempio n. 2
0
 def buildTree(self, browser):
     root = browser.sidebarTree
     for item in root.findItems('', Qt.MatchContains | Qt.MatchRecursive):
         icon = item.icon(0)
         pixmap = icon.pixmap(32, 32)
         image = pixmap.toImage()
         image.invertPixels()
         new_icon = aqt.QIcon(QPixmap.fromImage(image))
         item.setIcon(0, new_icon)
Esempio n. 3
0
    def iconFromRef(self, iconRef):
        icon = self.iconCache.get(iconRef)
        if icon is None:
            icon = QIcon(iconRef)

            if self.nightmode:  #TODO: RM later, for 2.1.15
                pixmap = icon.pixmap(32, 32)
                image = pixmap.toImage()
                image.invertPixels()
                icon = aqt.QIcon(QPixmap.fromImage(image))

            self.iconCache[iconRef] = icon
        return icon
Esempio n. 4
0
        def iconFromRef(self, sidebar_model, iconRef, _old):
            icon = _old(sidebar_model, iconRef)
            try:
                if icon and iconRef not in self.inverted:
                    pixmap = icon.pixmap(32, 32)
                    image = pixmap.toImage()
                    image.invertPixels()
                    icon = aqt.QIcon(QPixmap.fromImage(image))

                    self.inverted.append(iconRef)
                    sidebar_model.iconCache[iconRef] = icon
            except TypeError:
                pass
            return icon
Esempio n. 5
0
 def buildTree(self, browser, _old):
     root = _old(browser)
     if root:  # For Anki 2.1.17++
         return root
     # ---------------------------
     # For Anki 2.1.15--
     root = browser.sidebarTree
     for item in root.findItems('', Qt.MatchContains | Qt.MatchRecursive):
         icon = item.icon(0)
         pixmap = icon.pixmap(32, 32)
         image = pixmap.toImage()
         image.invertPixels()
         new_icon = aqt.QIcon(QPixmap.fromImage(image))
         item.setIcon(0, new_icon)