def load_flags(col: Collection) -> List[Flag]: """Return a list of all flags, reloading labels from the config.""" labels = cast(Dict[str, str], col.get_config("flagLabels", {})) icon = ColoredIcon(path=":/icons/flag.svg", color=colors.DISABLED) return [ Flag( 1, labels["1"] if "1" in labels else tr.actions_flag_red(), icon.with_color(colors.FLAG1_FG), SearchNode(flag=SearchNode.FLAG_RED), "actionRed_Flag", ), Flag( 2, labels["2"] if "2" in labels else tr.actions_flag_orange(), icon.with_color(colors.FLAG2_FG), SearchNode(flag=SearchNode.FLAG_ORANGE), "actionOrange_Flag", ), Flag( 3, labels["3"] if "3" in labels else tr.actions_flag_green(), icon.with_color(colors.FLAG3_FG), SearchNode(flag=SearchNode.FLAG_GREEN), "actionGreen_Flag", ), Flag( 4, labels["4"] if "4" in labels else tr.actions_flag_blue(), icon.with_color(colors.FLAG4_FG), SearchNode(flag=SearchNode.FLAG_BLUE), "actionBlue_Flag", ), Flag( 5, labels["5"] if "5" in labels else tr.actions_flag_pink(), icon.with_color(colors.FLAG5_FG), SearchNode(flag=SearchNode.FLAG_PINK), "actionPink_Flag", ), Flag( 6, labels["6"] if "6" in labels else tr.actions_flag_turquoise(), icon.with_color(colors.FLAG6_FG), SearchNode(flag=SearchNode.FLAG_TURQUOISE), "actionTurquoise_Flag", ), Flag( 7, labels["7"] if "7" in labels else tr.actions_flag_purple(), icon.with_color(colors.FLAG7_FG), SearchNode(flag=SearchNode.FLAG_PURPLE), "actionPurple_Flag", ), ]
def _load_flags(self) -> None: labels = cast(dict[str, str], self.mw.col.get_config("flagLabels", {})) icon = ColoredIcon(path=":/icons/flag.svg", color=colors.DISABLED) self._flags = [ Flag( 1, labels["1"] if "1" in labels else tr.actions_flag_red(), icon.with_color(colors.FLAG1_FG), SearchNode(flag=SearchNode.FLAG_RED), "actionRed_Flag", ), Flag( 2, labels["2"] if "2" in labels else tr.actions_flag_orange(), icon.with_color(colors.FLAG2_FG), SearchNode(flag=SearchNode.FLAG_ORANGE), "actionOrange_Flag", ), Flag( 3, labels["3"] if "3" in labels else tr.actions_flag_green(), icon.with_color(colors.FLAG3_FG), SearchNode(flag=SearchNode.FLAG_GREEN), "actionGreen_Flag", ), Flag( 4, labels["4"] if "4" in labels else tr.actions_flag_blue(), icon.with_color(colors.FLAG4_FG), SearchNode(flag=SearchNode.FLAG_BLUE), "actionBlue_Flag", ), Flag( 5, labels["5"] if "5" in labels else tr.actions_flag_pink(), icon.with_color(colors.FLAG5_FG), SearchNode(flag=SearchNode.FLAG_PINK), "actionPink_Flag", ), Flag( 6, labels["6"] if "6" in labels else tr.actions_flag_turquoise(), icon.with_color(colors.FLAG6_FG), SearchNode(flag=SearchNode.FLAG_TURQUOISE), "actionTurquoise_Flag", ), Flag( 7, labels["7"] if "7" in labels else tr.actions_flag_purple(), icon.with_color(colors.FLAG7_FG), SearchNode(flag=SearchNode.FLAG_PURPLE), "actionPurple_Flag", ), ]
def _flags_tree(self, root: SidebarItem) -> None: icon = ColoredIcon(path=":/icons/flag.svg", color=colors.DISABLED) root = self._section_root( root=root, name=tr.browsing_sidebar_flags(), icon=icon, collapse_key=Config.Bool.COLLAPSE_FLAGS, type=SidebarItemType.FLAG_ROOT, ) root.search_node = SearchNode(flag=SearchNode.FLAG_ANY) for flag in load_flags(self.col): root.add_child( SidebarItem( name=flag.label, icon=flag.icon, search_node=flag.search_node, item_type=SidebarItemType.FLAG, id=flag.index, )) root.add_simple( tr.browsing_no_flag(), icon=icon, type=SidebarItemType.FLAG, search_node=SearchNode(flag=SearchNode.FLAG_NONE), )
def _card_state_tree(self, root: SidebarItem) -> None: icon = ColoredIcon(path=":/icons/card-state.svg", color=colors.DISABLED) root = self._section_root( root=root, name=TR.BROWSING_SIDEBAR_CARD_STATE, icon=icon, collapse_key=Config.Bool.COLLAPSE_CARD_STATE, type=SidebarItemType.CARD_STATE_ROOT, ) type = SidebarItemType.CARD_STATE search = self._filter_func root.add_simple( TR.ACTIONS_NEW, icon=icon.with_color(colors.NEW_COUNT), type=type, on_click=search(SearchNode(card_state=SearchNode.CARD_STATE_NEW)), ) root.add_simple( name=TR.SCHEDULING_LEARNING, icon=icon.with_color(colors.LEARN_COUNT), type=type, on_click=search( SearchNode(card_state=SearchNode.CARD_STATE_LEARN)), ) root.add_simple( name=TR.SCHEDULING_REVIEW, icon=icon.with_color(colors.REVIEW_COUNT), type=type, on_click=search( SearchNode(card_state=SearchNode.CARD_STATE_REVIEW)), ) root.add_simple( name=TR.BROWSING_SUSPENDED, icon=icon.with_color(colors.SUSPENDED_FG), type=type, on_click=search( SearchNode(card_state=SearchNode.CARD_STATE_SUSPENDED)), ) root.add_simple( name=TR.BROWSING_BURIED, icon=icon.with_color(colors.BURIED_FG), type=type, on_click=search( SearchNode(card_state=SearchNode.CARD_STATE_BURIED)), )
def _card_state_tree(self, root: SidebarItem) -> None: icon = ":/icons/circle.svg" icon_outline = ":/icons/circle-outline.svg" root = self._section_root( root=root, name=tr.browsing_sidebar_card_state(), icon=icon_outline, collapse_key=Config.Bool.COLLAPSE_CARD_STATE, type=SidebarItemType.CARD_STATE_ROOT, ) type = SidebarItemType.CARD_STATE colored_icon = ColoredIcon(path=icon, color=colors.DISABLED) root.add_simple( tr.actions_new(), icon=colored_icon.with_color(colors.NEW_COUNT), type=type, search_node=SearchNode(card_state=SearchNode.CARD_STATE_NEW), ) root.add_simple( name=tr.scheduling_learning(), icon=colored_icon.with_color(colors.LEARN_COUNT), type=type, search_node=SearchNode(card_state=SearchNode.CARD_STATE_LEARN), ) root.add_simple( name=tr.scheduling_review(), icon=colored_icon.with_color(colors.REVIEW_COUNT), type=type, search_node=SearchNode(card_state=SearchNode.CARD_STATE_REVIEW), ) root.add_simple( name=tr.browsing_suspended(), icon=colored_icon.with_color(colors.SUSPENDED_FG), type=type, search_node=SearchNode(card_state=SearchNode.CARD_STATE_SUSPENDED), ) root.add_simple( name=tr.browsing_buried(), icon=colored_icon.with_color(colors.BURIED_FG), type=type, search_node=SearchNode(card_state=SearchNode.CARD_STATE_BURIED), )
def _flags_tree(self, root: SidebarItem) -> None: icon = ColoredIcon(path=":/icons/flag.svg", color=colors.DISABLED) search = self._filter_func root = self._section_root( root=root, name=TR.BROWSING_SIDEBAR_FLAGS, icon=icon, collapse_key=Config.Bool.COLLAPSE_FLAGS, type=SidebarItemType.FLAG_ROOT, ) root.on_click = search(SearchNode(flag=SearchNode.FLAG_ANY)) type = SidebarItemType.FLAG root.add_simple( TR.ACTIONS_RED_FLAG, icon=icon.with_color(colors.FLAG1_FG), type=type, on_click=search(SearchNode(flag=SearchNode.FLAG_RED)), ) root.add_simple( TR.ACTIONS_ORANGE_FLAG, icon=icon.with_color(colors.FLAG2_FG), type=type, on_click=search(SearchNode(flag=SearchNode.FLAG_ORANGE)), ) root.add_simple( TR.ACTIONS_GREEN_FLAG, icon=icon.with_color(colors.FLAG3_FG), type=type, on_click=search(SearchNode(flag=SearchNode.FLAG_GREEN)), ) root.add_simple( TR.ACTIONS_BLUE_FLAG, icon=icon.with_color(colors.FLAG4_FG), type=type, on_click=search(SearchNode(flag=SearchNode.FLAG_BLUE)), ) root.add_simple( TR.BROWSING_NO_FLAG, icon=icon.with_color(colors.DISABLED), type=type, on_click=search(SearchNode(flag=SearchNode.FLAG_NONE)), )
def _flags_tree(self, root: SidebarItem) -> None: icon = ColoredIcon(path=":/icons/flag.svg", color=colors.DISABLED) root = self._section_root( root=root, name=tr.browsing_sidebar_flags(), icon=icon, collapse_key=Config.Bool.COLLAPSE_FLAGS, type=SidebarItemType.FLAG_ROOT, ) root.search_node = SearchNode(flag=SearchNode.FLAG_ANY) type = SidebarItemType.FLAG root.add_simple( tr.actions_red_flag(), icon=icon.with_color(colors.FLAG1_FG), type=type, search_node=SearchNode(flag=SearchNode.FLAG_RED), ) root.add_simple( tr.actions_orange_flag(), icon=icon.with_color(colors.FLAG2_FG), type=type, search_node=SearchNode(flag=SearchNode.FLAG_ORANGE), ) root.add_simple( tr.actions_green_flag(), icon=icon.with_color(colors.FLAG3_FG), type=type, search_node=SearchNode(flag=SearchNode.FLAG_GREEN), ) root.add_simple( tr.actions_blue_flag(), icon=icon.with_color(colors.FLAG4_FG), type=type, search_node=SearchNode(flag=SearchNode.FLAG_BLUE), ) root.add_simple( tr.browsing_no_flag(), icon=icon.with_color(colors.DISABLED), type=type, search_node=SearchNode(flag=SearchNode.FLAG_NONE), )