diff --git a/ftl/core/actions.ftl b/ftl/core/actions.ftl index 57d7d188f..263c9d897 100644 --- a/ftl/core/actions.ftl +++ b/ftl/core/actions.ftl @@ -1,7 +1,6 @@ actions-add = Add actions-all-selected = All selected actions-any-selected = Any selected -actions-blue-flag = Blue Flag actions-cancel = Cancel actions-choose = Choose actions-close = Close @@ -11,7 +10,6 @@ actions-decks = Decks actions-delete = Delete actions-export = Export actions-filter = Filter -actions-green-flag = Green Flag actions-help = Help actions-import = Import actions-manage = Manage... @@ -20,10 +18,8 @@ actions-new = New actions-new-name = New name: actions-options = Options actions-options-for = Options for { $val } -actions-orange-flag = Orange Flag actions-preview = Preview actions-rebuild = Rebuild -actions-red-flag = Red Flag actions-rename = Rename actions-rename-deck = Rename Deck actions-rename-tag = Rename Tag @@ -53,3 +49,10 @@ actions-add-notetype = Add Notetype actions-remove-notetype = Remove Notetype actions-update-notetype = Update Notetype actions-update-config = Update Config +actions-red-flag = Red Flag +actions-orange-flag = Orange Flag +actions-green-flag = Green Flag +actions-blue-flag = Blue Flag +actions-violet-flag = Violet Flag +actions-turquoise-flag = Turquoise Flag +actions-purple-flag = Purple Flag diff --git a/ftl/core/search.ftl b/ftl/core/search.ftl index 768d77109..e26ce4a9c 100644 --- a/ftl/core/search.ftl +++ b/ftl/core/search.ftl @@ -16,7 +16,7 @@ search-unclosed-quote = an opening double quote `"` was found, but there was no search-missing-key = a colon `:` was found, but there was no keyword preceding it. If you want to search for a literal `:`, prepend a backslash: `\:`. search-unknown-escape = the escape sequence `{ $val }` is not defined. If you want to search for a literal backslash `\`, prepend another one: `\\`. search-invalid-argument = `{ $term }` was given an invalid argument '`{ $argument }`'. -search-invalid-flag = `flag:` must be followed by a valid flag number: `1` (red), `2` (orange), `3` (green), `4` (blue) or `0` (no flag). +search-invalid-flag = `flag:` must be followed by a valid flag number: `1` (red), `2` (orange), `3` (green), `4` (blue), `5` (violet), `6` (turquoise), `7` (purple) or `0` (no flag). search-invalid-prop-operator = `prop:{ $val }` must be followed by one of the following comparison operators: `=`, `!=`, `<`, `>`, `<=` or `>=`. search-invalid-other = please check for typing mistakes. diff --git a/pylib/anki/cards.py b/pylib/anki/cards.py index eb4b43d17..809efd577 100644 --- a/pylib/anki/cards.py +++ b/pylib/anki/cards.py @@ -215,7 +215,7 @@ class Card: def set_user_flag(self, flag: int) -> None: print("use col.set_user_flag_for_cards() instead") - assert 0 <= flag <= 4 + assert 0 <= flag <= 7 self.flags = (self.flags & ~0b111) | flag # legacy diff --git a/qt/aqt/browser/table/__init__.py b/qt/aqt/browser/table/__init__.py index 6f9bfa110..03d6a0952 100644 --- a/qt/aqt/browser/table/__init__.py +++ b/qt/aqt/browser/table/__init__.py @@ -88,6 +88,12 @@ def backend_color_to_aqt_color(color: BrowserRow.Color.V) -> Optional[Tuple[str, return colors.FLAG3_BG if color == BrowserRow.COLOR_FLAG_BLUE: return colors.FLAG4_BG + if color == BrowserRow.COLOR_FLAG_VIOLET: + return colors.FLAG5_BG + if color == BrowserRow.COLOR_FLAG_TURQUOISE: + return colors.FLAG6_BG + if color == BrowserRow.COLOR_FLAG_PURPLE: + return colors.FLAG7_BG return None diff --git a/qt/aqt/data/web/js/reviewer.ts b/qt/aqt/data/web/js/reviewer.ts index d56d09fe7..650c710ff 100644 --- a/qt/aqt/data/web/js/reviewer.ts +++ b/qt/aqt/data/web/js/reviewer.ts @@ -150,9 +150,12 @@ const _flagColours = { 2: "#ff9900", 3: "#77ff77", 4: "#77aaff", + 5: "#fc68e8", + 6: "#00d3b7", + 7: "#9e3bfa", }; -function _drawFlag(flag: 0 | 1 | 2 | 3 | 4): void { +function _drawFlag(flag: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7): void { const elem = document.getElementById("_flag"); if (flag === 0) { elem.setAttribute("hidden", ""); diff --git a/qt/aqt/flags.py b/qt/aqt/flags.py index 46587d316..a2baa8bc3 100644 --- a/qt/aqt/flags.py +++ b/qt/aqt/flags.py @@ -65,4 +65,25 @@ def load_flags(col: Collection) -> List[Flag]: SearchNode(flag=SearchNode.FLAG_BLUE), "actionBlue_Flag", ), + Flag( + 5, + labels["5"] if "5" in labels else tr.actions_violet_flag(), + icon.with_color(colors.FLAG5_FG), + SearchNode(flag=SearchNode.FLAG_VIOLET), + "actionViolet_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", + ), ] diff --git a/qt/aqt/forms/browser.ui b/qt/aqt/forms/browser.ui index eb5528d9a..ded81567a 100644 --- a/qt/aqt/forms/browser.ui +++ b/qt/aqt/forms/browser.ui @@ -144,12 +144,12 @@ false - - 20 - false + + 20 + true @@ -209,7 +209,7 @@ 0 0 750 - 24 + 21 @@ -262,6 +262,9 @@ + + + @@ -622,6 +625,39 @@ Ctrl+Shift+Z + + + true + + + actions_violet_flag + + + Ctrl+5 + + + + + true + + + actions_turquoise_flag + + + Ctrl+6 + + + + + true + + + actions_purple_flag + + + Ctrl+7 + + diff --git a/rslib/backend.proto b/rslib/backend.proto index 0b8e33631..12d4698e9 100644 --- a/rslib/backend.proto +++ b/rslib/backend.proto @@ -858,6 +858,9 @@ message SearchNode { FLAG_ORANGE = 3; FLAG_GREEN = 4; FLAG_BLUE = 5; + FLAG_VIOLET = 6; + FLAG_TURQUOISE = 7; + FLAG_PURPLE = 8; } enum Rating { RATING_ANY = 0; @@ -1130,6 +1133,9 @@ message BrowserRow { COLOR_FLAG_ORANGE = 4; COLOR_FLAG_GREEN = 5; COLOR_FLAG_BLUE = 6; + COLOR_FLAG_VIOLET = 7; + COLOR_FLAG_TURQUOISE = 8; + COLOR_FLAG_PURPLE = 9; } repeated Cell cells = 1; Color color = 2; diff --git a/rslib/src/backend/search/search_node.rs b/rslib/src/backend/search/search_node.rs index c095a90d0..c3d321551 100644 --- a/rslib/src/backend/search/search_node.rs +++ b/rslib/src/backend/search/search_node.rs @@ -70,6 +70,9 @@ impl TryFrom for Node { Flag::Orange => Node::Search(SearchNode::Flag(2)), Flag::Green => Node::Search(SearchNode::Flag(3)), Flag::Blue => Node::Search(SearchNode::Flag(4)), + Flag::Violet => Node::Search(SearchNode::Flag(5)), + Flag::Turquoise => Node::Search(SearchNode::Flag(6)), + Flag::Purple => Node::Search(SearchNode::Flag(7)), }, Filter::Negated(term) => Node::try_from(*term)?.negated(), Filter::Group(mut group) => { diff --git a/rslib/src/browser_table.rs b/rslib/src/browser_table.rs index 1e988b79a..5fc8a9b1f 100644 --- a/rslib/src/browser_table.rs +++ b/rslib/src/browser_table.rs @@ -527,6 +527,9 @@ impl RowContext { 2 => Color::FlagOrange, 3 => Color::FlagGreen, 4 => Color::FlagBlue, + 5 => Color::FlagViolet, + 6 => Color::FlagTurquoise, + 7 => Color::FlagPurple, _ => { if self.note.is_marked() { Color::Marked diff --git a/rslib/src/card/mod.rs b/rslib/src/card/mod.rs index e45f9458c..26486754b 100644 --- a/rslib/src/card/mod.rs +++ b/rslib/src/card/mod.rs @@ -119,11 +119,8 @@ impl Card { /// True if flag changed. fn set_flag(&mut self, flag: u8) -> bool { - // we currently only allow 4 flags - assert!(flag < 5); - - // but reserve space for 7, preserving the rest of - // the flags (up to a byte) + // The first 3 bits represent one of the 7 supported flags, the rest of + // the flag byte is preserved. let updated_flags = (self.flags & !0b111) | flag; if self.flags != updated_flags { self.flags = updated_flags; @@ -268,7 +265,7 @@ impl Collection { } pub fn set_card_flag(&mut self, cards: &[CardId], flag: u32) -> Result> { - if flag > 4 { + if flag > 7 { return Err(AnkiError::invalid_input("invalid flag")); } let flag = flag as u8; diff --git a/rslib/src/search/parser.rs b/rslib/src/search/parser.rs index 8b4dd355d..22ca55db9 100644 --- a/rslib/src/search/parser.rs +++ b/rslib/src/search/parser.rs @@ -414,10 +414,10 @@ fn parse_template(s: &str) -> ParseResult { })) } -/// flag:0-4 +/// flag:0-7 fn parse_flag(s: &str) -> ParseResult { if let Ok(flag) = s.parse::() { - if flag > 4 { + if flag > 7 { Err(parse_failure(s, FailKind::InvalidFlag)) } else { Ok(SearchNode::Flag(flag)) @@ -999,7 +999,7 @@ mod test { assert_err_kind(r#""flag: ""#, InvalidFlag); assert_err_kind("flag:-0", InvalidFlag); assert_err_kind("flag:", InvalidFlag); - assert_err_kind("flag:5", InvalidFlag); + assert_err_kind("flag:8", InvalidFlag); assert_err_kind("flag:1.1", InvalidFlag); for term in &["added", "edited", "rated", "resched"] { diff --git a/ts/sass/_vars.scss b/ts/sass/_vars.scss index 949307835..45573e354 100644 --- a/ts/sass/_vars.scss +++ b/ts/sass/_vars.scss @@ -21,10 +21,16 @@ --flag2-fg: #ffb347; --flag3-fg: #0a0; --flag4-fg: #77ccff; + --flag5-fg: #fc68e8; + --flag6-fg: #00d3b7; + --flag7-fg: #9e3bfa; --flag1-bg: #ffaaaa; --flag2-bg: #ffb347; --flag3-bg: #82e0aa; --flag4-bg: #85c1e9; + --flag5-bg: #ffafeb; + --flag6-bg: #4bd3cc; + --flag7-bg: #c07dff; --buried-fg: #aaaa33; --suspended-fg: #dd0; --suspended-bg: #ffffb2; @@ -52,10 +58,16 @@ --flag2-fg: #ffb347; --flag3-fg: #82e0aa; --flag4-fg: #85c1e9; + --flag5-fg: #ffafeb; + --flag6-fg: #3fccc5; + --flag7-fg: #c07dff; --flag1-bg: #aa5555; --flag2-bg: #aa6337; --flag3-bg: #33a055; --flag4-bg: #3581a9; + --flag5-bg: #be64b2; + --flag6-bg: #11a591; + --flag7-bg: #904fce; --buried-fg: #777733; --suspended-fg: #ffffb2; --suspended-bg: #aaaa33;