Exemple #1
0
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_red_flag(),
            icon.with_color(colors.FLAG1_FG),
            SearchNode(flag=SearchNode.FLAG_RED),
            "actionRed_Flag",
        ),
        Flag(
            2,
            labels["2"] if "2" in labels else tr.actions_orange_flag(),
            icon.with_color(colors.FLAG2_FG),
            SearchNode(flag=SearchNode.FLAG_ORANGE),
            "actionOrange_Flag",
        ),
        Flag(
            3,
            labels["3"] if "3" in labels else tr.actions_green_flag(),
            icon.with_color(colors.FLAG3_FG),
            SearchNode(flag=SearchNode.FLAG_GREEN),
            "actionGreen_Flag",
        ),
        Flag(
            4,
            labels["4"] if "4" in labels else tr.actions_blue_flag(),
            icon.with_color(colors.FLAG4_FG),
            SearchNode(flag=SearchNode.FLAG_BLUE),
            "actionBlue_Flag",
        ),
        Flag(
            5,
            labels["5"] if "5" in labels else tr.actions_pink_flag(),
            icon.with_color(colors.FLAG5_FG),
            SearchNode(flag=SearchNode.FLAG_PINK),
            "actionPink_Flag",
        ),
        Flag(
            6,
            labels["6"] if "6" in labels else tr.actions_turquoise_flag(),
            icon.with_color(colors.FLAG6_FG),
            SearchNode(flag=SearchNode.FLAG_TURQUOISE),
            "actionTurquoise_Flag",
        ),
        Flag(
            7,
            labels["7"] if "7" in labels else tr.actions_purple_flag(),
            icon.with_color(colors.FLAG7_FG),
            SearchNode(flag=SearchNode.FLAG_PURPLE),
            "actionPurple_Flag",
        ),
    ]
Exemple #2
0
 def _contextMenu(self) -> List[Any]:
     currentFlag = self.card and self.card.user_flag()
     opts = [
         [
             tr.studying_flag_card(),
             [
                 [
                     tr.actions_red_flag(),
                     "Ctrl+1",
                     lambda: self.set_flag_on_current_card(1),
                     dict(checked=currentFlag == 1),
                 ],
                 [
                     tr.actions_orange_flag(),
                     "Ctrl+2",
                     lambda: self.set_flag_on_current_card(2),
                     dict(checked=currentFlag == 2),
                 ],
                 [
                     tr.actions_green_flag(),
                     "Ctrl+3",
                     lambda: self.set_flag_on_current_card(3),
                     dict(checked=currentFlag == 3),
                 ],
                 [
                     tr.actions_blue_flag(),
                     "Ctrl+4",
                     lambda: self.set_flag_on_current_card(4),
                     dict(checked=currentFlag == 4),
                 ],
             ],
         ],
         [tr.studying_mark_note(), "*", self.toggle_mark_on_current_note],
         [tr.studying_bury_card(), "-", self.bury_current_card],
         [tr.studying_bury_note(), "=", self.bury_current_note],
         [tr.actions_set_due_date(), "Ctrl+Shift+D", self.on_set_due],
         [tr.actions_suspend_card(), "@", self.suspend_current_card],
         [tr.studying_suspend_note(), "!", self.suspend_current_note],
         [
             tr.studying_delete_note(), "Ctrl+Delete",
             self.delete_current_note
         ],
         [tr.actions_options(), "O", self.onOptions],
         None,
         [tr.actions_replay_audio(), "R", self.replayAudio],
         [tr.studying_pause_audio(), "5", self.on_pause_audio],
         [tr.studying_audio_5s(), "6", self.on_seek_backward],
         [tr.studying_audio_and5s(), "7", self.on_seek_forward],
         [tr.studying_record_own_voice(), "Shift+V", self.onRecordVoice],
         [tr.studying_replay_own_voice(), "V", self.onReplayRecorded],
     ]
     return opts
Exemple #3
0
    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),
        )