diff --git a/ftl/core/actions.ftl b/ftl/core/actions.ftl index 57d7d188f..b6d04bfc0 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-pink-flag = Pink 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..f18fa73c3 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` (pink), `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..4d19ba618 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_PINK: + 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..c56b07638 100644 --- a/qt/aqt/data/web/js/reviewer.ts +++ b/qt/aqt/data/web/js/reviewer.ts @@ -146,13 +146,16 @@ function _showAnswer(a: string, bodyclass: string): void { } const _flagColours = { - 1: "#ff6666", - 2: "#ff9900", - 3: "#77ff77", - 4: "#77aaff", + 1: "#e25252", + 2: "#ffb347", + 3: "#54c414", + 4: "#578cff", + 5: "#ff82ee", + 6: "#00d1b5", + 7: "#9649dd", }; -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..af01570d4 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_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", + ), ] diff --git a/qt/aqt/forms/browser.ui b/qt/aqt/forms/browser.ui index eb5528d9a..eda2155e6 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_pink_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 96444d3c7..33cf89c48 100644 --- a/rslib/backend.proto +++ b/rslib/backend.proto @@ -860,6 +860,9 @@ message SearchNode { FLAG_ORANGE = 3; FLAG_GREEN = 4; FLAG_BLUE = 5; + FLAG_PINK = 6; + FLAG_TURQUOISE = 7; + FLAG_PURPLE = 8; } enum Rating { RATING_ANY = 0; @@ -1132,6 +1135,9 @@ message BrowserRow { COLOR_FLAG_ORANGE = 4; COLOR_FLAG_GREEN = 5; COLOR_FLAG_BLUE = 6; + COLOR_FLAG_PINK = 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..d1f9da9ab 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::Pink => 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..634729db5 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::FlagPink, + 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..ec8b2d1bb 100644 --- a/ts/sass/_vars.scss +++ b/ts/sass/_vars.scss @@ -17,14 +17,20 @@ --highlight-bg: #77ccff; --highlight-fg: black; --disabled: #777; - --flag1-fg: #c35617; + --flag1-fg: #e25252; --flag2-fg: #ffb347; - --flag3-fg: #0a0; - --flag4-fg: #77ccff; - --flag1-bg: #ffaaaa; + --flag3-fg: #54c414; + --flag4-fg: #578cff; + --flag5-fg: #ff82ee; + --flag6-fg: #00d1b5; + --flag7-fg: #9649dd; + --flag1-bg: #ff9b9b; --flag2-bg: #ffb347; - --flag3-bg: #82e0aa; - --flag4-bg: #85c1e9; + --flag3-bg: #93e066; + --flag4-bg: #9dbcff; + --flag5-bg: #f5a8eb; + --flag6-bg: #7edbd7; + --flag7-bg: #cca3f1; --buried-fg: #aaaa33; --suspended-fg: #dd0; --suspended-bg: #ffffb2; @@ -48,14 +54,20 @@ --highlight-bg: #77ccff; --highlight-fg: white; --disabled: #777; - --flag1-fg: #ffaaaa; - --flag2-fg: #ffb347; - --flag3-fg: #82e0aa; - --flag4-fg: #85c1e9; + --flag1-fg: #ff7b7b; + --flag2-fg: #f5aa41; + --flag3-fg: #86ce5d; + --flag4-fg: #6f9dff; + --flag5-fg: #f097e4; + --flag6-fg: #5ccfca; + --flag7-fg: #9f63d3; --flag1-bg: #aa5555; - --flag2-bg: #aa6337; - --flag3-bg: #33a055; - --flag4-bg: #3581a9; + --flag2-bg: #ac653a; + --flag3-bg: #559238; + --flag4-bg: #506aa3; + --flag5-bg: #975d8f; + --flag6-bg: #399185; + --flag7-bg: #624b77; --buried-fg: #777733; --suspended-fg: #ffffb2; --suspended-bg: #aaaa33;