示例#1
0
def custom_stdTree_until_2_1_17(self, root):
    if config['show_item_marked']:
        item = self.CallbackItem(root, _("Marked"), self._filterFunc("tag:marked"))
        item.setIcon(0, QIcon(icon_tag))
    if config['show_item_suspended']:
        item = self.CallbackItem(root, _("Suspended"), self._filterFunc("is:suspended"))
        item.setIcon(0, QIcon(icon_tag))
    if config['show_item_leech']:
        item = self.CallbackItem(root, _("Leech"), self._filterFunc("tag:leech"))
        item.setIcon(0, QIcon(icon_tag))
    if config['show_tree_today']:
        today = self.CallbackItem(root, _("Today"), None)
        today.setIcon(0, QIcon(icon_tag))
        today.setExpanded(False)
        item = self.CallbackItem(today, _("Added Today"), self._filterFunc("added:1"))
        item = self.CallbackItem(today, _("Studied Today"), self._filterFunc("rated:1"))
        item = self.CallbackItem(today, _("Again Today"), self._filterFunc("rated:1:1"))
    if config['show_tree_flags']:
        flags = self.CallbackItem(root, _("Flags"), None)
        flags.setIcon(0, QIcon(icon_tag))
        flags.setExpanded(False)
        item = self.CallbackItem(flags, _("Red"), self._filterFunc("flag:1"))
        item = self.CallbackItem(flags, _("Orange"), self._filterFunc("flag:2"))
        item = self.CallbackItem(flags, _("Green"), self._filterFunc("flag:3"))
        item = self.CallbackItem(flags, _("Blue"), self._filterFunc("flag:4"))
        item = self.CallbackItem(flags, _("No"), self._filterFunc("flag:0"))
        item = self.CallbackItem(flags, _("Any"), self._filterFunc("-flag:0"))
示例#2
0
    def setupButtons(self):
        main_path = f'{os.path.dirname(os.path.realpath(__file__))}/../icons'

        self.ui.selectButton.setIcon(QIcon(f"{main_path}/select.png"))
        self.ui.moveButton.setIcon(QIcon(f"{main_path}/move.png"))
        self.ui.zoomButton.setIcon(QIcon(f"{main_path}/zoom.png"))

        self.ui.rectButton.setIcon(QIcon(f"{main_path}/rect.png"))
        self.ui.ellipseButton.setIcon(QIcon(f"{main_path}/ellipse.png"))
        self.ui.polygonButton.setIcon(QIcon(f"{main_path}/polygon.png"))
        self.ui.lineButton.setIcon(QIcon(f"{main_path}/line.png"))
        self.ui.arrowButton.setIcon(QIcon(f"{main_path}/arrow.png"))
        self.ui.darrowButton.setIcon(QIcon(f"{main_path}/darrow.png"))
        self.ui.textButton.setIcon(QIcon(f"{main_path}/text.png"))

        self.ui.selectButton.clicked.connect(self.selectTool)
        self.ui.moveButton.clicked.connect(self.moveTool)
        self.ui.zoomButton.clicked.connect(self.zoomTool)

        self.ui.rectButton.clicked.connect(self.rectTool)
        self.ui.ellipseButton.clicked.connect(self.ellipseTool)
        self.ui.polygonButton.clicked.connect(self.polygonTool)
        self.ui.lineButton.clicked.connect(self.lineTool)
        self.ui.arrowButton.clicked.connect(self.arrowTool)
        self.ui.darrowButton.clicked.connect(self.darrowTool)
        self.ui.textButton.clicked.connect(self.textTool)
示例#3
0
    def icon_from_resources(self, path: Union[str, ColoredIcon]) -> QIcon:
        "Fetch icon from Qt resources, and invert if in night mode."
        if self.night_mode:
            cache = self._icon_cache_light
        else:
            cache = self._icon_cache_dark

        if isinstance(path, str):
            key = path
        else:
            key = f"{path.path}-{path.color}"

        icon = cache.get(key)
        if icon:
            return icon

        if isinstance(path, str):
            # default black/white
            icon = QIcon(path)
            if self.night_mode:
                img = icon.pixmap(self._icon_size, self._icon_size).toImage()
                img.invertPixels()
                icon = QIcon(QPixmap(img))
        else:
            # specified colours
            icon = QIcon(path.path)
            pixmap = icon.pixmap(16)
            painter = QPainter(pixmap)
            painter.setCompositionMode(QPainter.CompositionMode_SourceIn)
            painter.fillRect(pixmap.rect(), QColor(path.current_color(self.night_mode)))
            painter.end()
            icon = QIcon(pixmap)
            return icon

        return cache.setdefault(path, icon)
示例#4
0
def custom_modelTree_until_2_1_17(self, root, _old):
    root = self.CallbackItem(root, _("Note Types"), None)
    root.setExpanded(False)
    root.setIcon(0, QIcon(icon_notetype))
    for m in sorted(self.col.models.all(), key=itemgetter("name")):
        mitem = self.CallbackItem(
            root, m['name'], lambda m=m: self.setFilter("note", str(m['name'])))
        mitem.setIcon(0, QIcon(icon_notetype))
示例#5
0
def custom_favTree_until_2_1_17(self, root, _old):
    root = self.CallbackItem(root, _("My Filters"), None)
    root.setExpanded(False)
    root.setIcon(0, QIcon(icon_heart))
    saved = self.col.conf.get('savedFilters', {})
    for name, filt in sorted(saved.items()):
        item = self.CallbackItem(root, name, lambda s=filt: self.setFilter(s))
        item.setIcon(0, QIcon(icon_heart))
def my_favTree(self, root, _old):
    root = self.CallbackItem(root, _("My Filters"), None)
    root.setExpanded(False)
    root.setIcon(0, QIcon(":/icons/heart.svg"))
    saved = self.col.conf.get('savedFilters', {})
    for name, filt in sorted(saved.items()):
        item = self.CallbackItem(root, name, lambda s=filt: self.setFilter(s))
        item.setIcon(0, QIcon(":/icons/heart.svg"))
def my_modelTree(self, root, _old):
    root = self.CallbackItem(root, _("Note Types"), None)
    root.setExpanded(False)
    root.setIcon(0, QIcon(":/icons/notetype.svg"))
    for m in sorted(self.col.models.all(), key=itemgetter("name")):
        mitem = self.CallbackItem(
            root,
            m['name'],
            lambda m=m: self.setFilter("note", str(m['name'])))
        mitem.setIcon(0, QIcon(":/icons/notetype.svg"))
def my_stdTree(self, root):
    if config['show_item_marked']:
        item = self.CallbackItem(root, _("Marked"),
                                 self._filterFunc("tag:marked"))
        item.setIcon(0, QIcon(":/icons/tag.svg"))
    if config['show_item_suspended']:
        item = self.CallbackItem(root, _("Suspended"),
                                 self._filterFunc("is:suspended"))
        item.setIcon(0, QIcon(":/icons/heart.svg"))
    if config['show_item_leech']:
        item = self.CallbackItem(root, _("Leech"),
                                 self._filterFunc("tag:leech"))
        item.setIcon(0, QIcon(":/icons/tag.svg"))
示例#9
0
文件: theme.py 项目: datamadic/anki
    def icon_from_resources(self, path: str) -> QIcon:
        "Fetch icon from Qt resources, and invert if in night mode."
        icon = self._icon_cache.get(path)
        if icon:
            return icon

        icon = QIcon(path)

        if self.night_mode:
            img = icon.pixmap(self._icon_size, self._icon_size).toImage()
            img.invertPixels()
            icon = QIcon(QPixmap(img))

        return self._icon_cache.setdefault(path, icon)
示例#10
0
def anknotes_browser_get_icon(icon=None):
    if icon:
        return QIcon(":/icons/" + icon)
    if not hasattr(anknotes_browser_get_icon, 'default_icon'):
        from anknotes.graphics import icoEvernoteWeb
        anknotes_browser_get_icon.default_icon = icoEvernoteWeb
    return anknotes_browser_get_icon.default_icon
示例#11
0
def _userTagTree(self, root, _old):
    tags = sorted(self.col.tags.all())
    tags_tree = {}

    for t in tags:
        if t.lower() == "marked" or t.lower() == "leech":
            continue

        components = t.split(SEPARATOR)
        for idx, c in enumerate(components):
            partial_tag = SEPARATOR.join(components[0:idx + 1])
            if not tags_tree.get(partial_tag):
                if idx == 0:
                    parent = root
                else:
                    parent_tag = SEPARATOR.join(components[0:idx])
                    parent = tags_tree[parent_tag]

                item = self.CallbackItem(parent,
                                         c,
                                         lambda partial_tag=partial_tag: self.
                                         setFilter("tag", partial_tag + '*'))
                item.setIcon(0, QIcon(":/icons/anki-tag.png"))

                tags_tree[partial_tag] = item
示例#12
0
文件: previewer.py 项目: zlodag/anki
 def __init__(self, parent: QWidget, mw: AnkiQt, on_close: Callable[[], None]):
     super().__init__(None, Qt.Window)
     self._open = True
     self._parent = parent
     self._close_callback = on_close
     self.mw = mw
     icon = QIcon()
     icon.addPixmap(QPixmap(":/icons/anki.png"), QIcon.Normal, QIcon.Off)
     self.setWindowIcon(icon)
示例#13
0
 def _updateButtonColor(self, color):
     """Generate color preview pixmap and place it on button"""
     pixmap = QPixmap(128, 18)
     qcolour = QColor(0, 0, 0)
     qcolour.setNamedColor(color)
     pixmap.fill(qcolour)
     self.setIcon(QIcon(pixmap))
     self.setIconSize(QSize(128, 18))
     self.color = color
示例#14
0
 def fillGroups(root, grps, head=""):
     for g in grps:
         item = self.CallbackItem(
             root, g[0],
             lambda g=g: self.setFilter("deck", head+g[0]),
             lambda g=g: self.mw.col.decks.collapseBrowser(g[1]),
             not self.mw.col.decks.get(g[1]).get('browserCollapsed', False))
         item.setIcon(0, QIcon(icon_deck))
         newhead = head + g[0]+"::"
         fillGroups(item, g[5], newhead)
def get_menu(parent, menuName, icon=None):
    menubar = parent.form.menubar
    for a in menubar.actions():
        if menuName == a.text():
            return a.menu()
    else:
        if icon:
            icon = QIcon(utility.misc.get_web_folder_path() + "icons/" + icon)
            return menubar.addMenu(icon, menuName)
        return menubar.addMenu(menuName)
示例#16
0
 def __init__(self, parent: QWidget, mw: AnkiQt,
              on_close: Callable[[], None]) -> None:
     super().__init__(None, Qt.Window)
     mw.garbage_collect_on_dialog_finish(self)
     self._open = True
     self._parent = parent
     self._close_callback = on_close
     self.mw = mw
     icon = QIcon()
     icon.addPixmap(QPixmap(":/icons/anki.png"), QIcon.Normal, QIcon.Off)
     disable_help_button(self)
     self.setWindowIcon(icon)
示例#17
0
def custom_decksTree_until_2_1_17(self, root, _old):
    for i in range(root.topLevelItemCount()):
        # return item of type QTreeWidgetItem
        item = root.topLevelItem(i)
        #print("item text is '%s'" % (item.text(0)))
    root = self.CallbackItem(root, _("Decks"), None)
    root.setExpanded(False)
    root.setIcon(0, QIcon(icon_deck))
    grps = self.col.sched.deckDueTree()
    def fillGroups(root, grps, head=""):
        for g in grps:
            item = self.CallbackItem(
                root, g[0],
                lambda g=g: self.setFilter("deck", head+g[0]),
                lambda g=g: self.mw.col.decks.collapseBrowser(g[1]),
                not self.mw.col.decks.get(g[1]).get('browserCollapsed', False))
            item.setIcon(0, QIcon(icon_deck))
            newhead = head + g[0]+"::"
            fillGroups(item, g[5], newhead)
    fillGroups(root, grps)
def add_menu_actions(menu, menu_options):
    for mp in menu_options:

        k = mp[0]
        t = mp[1]
        cb = mp[2]

        hk = 0
        if k:
            hk = get_config_value(k)

        act = QAction(t, menu)
        if hk:
            act.setShortcut(QKeySequence(hk))
            act.setShortcutContext(Qt.ApplicationShortcut)

        if len(mp) > 3:
            icon = mp[3]
            icon = QIcon(utility.misc.get_web_folder_path() + "icons/" + icon)
            act.setIcon(icon)

        act.triggered.connect(cb)
        menu.addAction(act)
示例#19
0
from anknotes.constants import *
### Anki Imports
try:
    from aqt.qt import QIcon, QPixmap
except Exception:
    pass

try:
    icoEvernoteWeb = QIcon(FILES.GRAPHICS.ICON.EVERNOTE_WEB)
    icoEvernoteArtcore = QIcon(FILES.GRAPHICS.ICON.EVERNOTE_ARTCORE)
    icoTomato = QIcon(FILES.GRAPHICS.ICON.TOMATO)
    imgEvernoteWeb = QPixmap(FILES.GRAPHICS.IMAGE.EVERNOTE_WEB, "PNG")
    imgEvernoteWebMsgBox = imgEvernoteWeb.scaledToWidth(64)
except Exception:
    pass
示例#20
0
def get_icon(filename):
    curdir = os.path.dirname(os.path.abspath(__file__))
    pardir = os.path.join(curdir, os.pardir)
    path = os.path.join(pardir, 'res', filename)
    return QIcon(path)
示例#21
0
 def get_icon(self, relative_path: str):
     icon = QIcon()
     icon.addPixmap(self.get_pixmap(relative_path))
     return icon