Add violet, turquoise and purple flags

This commit is contained in:
RumovZ 2021-05-31 12:03:30 +02:00
parent 29c4869aef
commit c97c6c6e98
13 changed files with 110 additions and 20 deletions

View file

@ -1,7 +1,6 @@
actions-add = Add actions-add = Add
actions-all-selected = All selected actions-all-selected = All selected
actions-any-selected = Any selected actions-any-selected = Any selected
actions-blue-flag = Blue Flag
actions-cancel = Cancel actions-cancel = Cancel
actions-choose = Choose actions-choose = Choose
actions-close = Close actions-close = Close
@ -11,7 +10,6 @@ actions-decks = Decks
actions-delete = Delete actions-delete = Delete
actions-export = Export actions-export = Export
actions-filter = Filter actions-filter = Filter
actions-green-flag = Green Flag
actions-help = Help actions-help = Help
actions-import = Import actions-import = Import
actions-manage = Manage... actions-manage = Manage...
@ -20,10 +18,8 @@ actions-new = New
actions-new-name = New name: actions-new-name = New name:
actions-options = Options actions-options = Options
actions-options-for = Options for { $val } actions-options-for = Options for { $val }
actions-orange-flag = Orange Flag
actions-preview = Preview actions-preview = Preview
actions-rebuild = Rebuild actions-rebuild = Rebuild
actions-red-flag = Red Flag
actions-rename = Rename actions-rename = Rename
actions-rename-deck = Rename Deck actions-rename-deck = Rename Deck
actions-rename-tag = Rename Tag actions-rename-tag = Rename Tag
@ -53,3 +49,10 @@ actions-add-notetype = Add Notetype
actions-remove-notetype = Remove Notetype actions-remove-notetype = Remove Notetype
actions-update-notetype = Update Notetype actions-update-notetype = Update Notetype
actions-update-config = Update Config 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

View file

@ -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-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-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-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-prop-operator = `prop:{ $val }` must be followed by one of the following comparison operators: `=`, `!=`, `<`, `>`, `<=` or `>=`.
search-invalid-other = please check for typing mistakes. search-invalid-other = please check for typing mistakes.

View file

@ -215,7 +215,7 @@ class Card:
def set_user_flag(self, flag: int) -> None: def set_user_flag(self, flag: int) -> None:
print("use col.set_user_flag_for_cards() instead") print("use col.set_user_flag_for_cards() instead")
assert 0 <= flag <= 4 assert 0 <= flag <= 7
self.flags = (self.flags & ~0b111) | flag self.flags = (self.flags & ~0b111) | flag
# legacy # legacy

View file

@ -88,6 +88,12 @@ def backend_color_to_aqt_color(color: BrowserRow.Color.V) -> Optional[Tuple[str,
return colors.FLAG3_BG return colors.FLAG3_BG
if color == BrowserRow.COLOR_FLAG_BLUE: if color == BrowserRow.COLOR_FLAG_BLUE:
return colors.FLAG4_BG 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 return None

View file

@ -150,9 +150,12 @@ const _flagColours = {
2: "#ff9900", 2: "#ff9900",
3: "#77ff77", 3: "#77ff77",
4: "#77aaff", 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"); const elem = document.getElementById("_flag");
if (flag === 0) { if (flag === 0) {
elem.setAttribute("hidden", ""); elem.setAttribute("hidden", "");

View file

@ -65,4 +65,25 @@ def load_flags(col: Collection) -> List[Flag]:
SearchNode(flag=SearchNode.FLAG_BLUE), SearchNode(flag=SearchNode.FLAG_BLUE),
"actionBlue_Flag", "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",
),
] ]

View file

@ -144,12 +144,12 @@
<attribute name="horizontalHeaderCascadingSectionResizes"> <attribute name="horizontalHeaderCascadingSectionResizes">
<bool>false</bool> <bool>false</bool>
</attribute> </attribute>
<attribute name="horizontalHeaderMinimumSectionSize">
<number>20</number>
</attribute>
<attribute name="horizontalHeaderHighlightSections"> <attribute name="horizontalHeaderHighlightSections">
<bool>false</bool> <bool>false</bool>
</attribute> </attribute>
<attribute name="horizontalHeaderMinimumSectionSize">
<number>20</number>
</attribute>
<attribute name="horizontalHeaderShowSortIndicator" stdset="0"> <attribute name="horizontalHeaderShowSortIndicator" stdset="0">
<bool>true</bool> <bool>true</bool>
</attribute> </attribute>
@ -209,7 +209,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>750</width> <width>750</width>
<height>24</height> <height>21</height>
</rect> </rect>
</property> </property>
<widget class="QMenu" name="menuEdit"> <widget class="QMenu" name="menuEdit">
@ -262,6 +262,9 @@
<addaction name="actionOrange_Flag"/> <addaction name="actionOrange_Flag"/>
<addaction name="actionGreen_Flag"/> <addaction name="actionGreen_Flag"/>
<addaction name="actionBlue_Flag"/> <addaction name="actionBlue_Flag"/>
<addaction name="actionViolet_Flag"/>
<addaction name="actionTurquoise_Flag"/>
<addaction name="actionPurple_Flag"/>
</widget> </widget>
<addaction name="actionChange_Deck"/> <addaction name="actionChange_Deck"/>
<addaction name="separator"/> <addaction name="separator"/>
@ -622,6 +625,39 @@
<string notr="true">Ctrl+Shift+Z</string> <string notr="true">Ctrl+Shift+Z</string>
</property> </property>
</action> </action>
<action name="actionViolet_Flag">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>actions_violet_flag</string>
</property>
<property name="shortcut">
<string notr="true">Ctrl+5</string>
</property>
</action>
<action name="actionTurquoise_Flag">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>actions_turquoise_flag</string>
</property>
<property name="shortcut">
<string notr="true">Ctrl+6</string>
</property>
</action>
<action name="actionPurple_Flag">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>actions_purple_flag</string>
</property>
<property name="shortcut">
<string notr="true">Ctrl+7</string>
</property>
</action>
</widget> </widget>
<resources> <resources>
<include location="icons.qrc"/> <include location="icons.qrc"/>

View file

@ -858,6 +858,9 @@ message SearchNode {
FLAG_ORANGE = 3; FLAG_ORANGE = 3;
FLAG_GREEN = 4; FLAG_GREEN = 4;
FLAG_BLUE = 5; FLAG_BLUE = 5;
FLAG_VIOLET = 6;
FLAG_TURQUOISE = 7;
FLAG_PURPLE = 8;
} }
enum Rating { enum Rating {
RATING_ANY = 0; RATING_ANY = 0;
@ -1130,6 +1133,9 @@ message BrowserRow {
COLOR_FLAG_ORANGE = 4; COLOR_FLAG_ORANGE = 4;
COLOR_FLAG_GREEN = 5; COLOR_FLAG_GREEN = 5;
COLOR_FLAG_BLUE = 6; COLOR_FLAG_BLUE = 6;
COLOR_FLAG_VIOLET = 7;
COLOR_FLAG_TURQUOISE = 8;
COLOR_FLAG_PURPLE = 9;
} }
repeated Cell cells = 1; repeated Cell cells = 1;
Color color = 2; Color color = 2;

View file

@ -70,6 +70,9 @@ impl TryFrom<pb::SearchNode> for Node {
Flag::Orange => Node::Search(SearchNode::Flag(2)), Flag::Orange => Node::Search(SearchNode::Flag(2)),
Flag::Green => Node::Search(SearchNode::Flag(3)), Flag::Green => Node::Search(SearchNode::Flag(3)),
Flag::Blue => Node::Search(SearchNode::Flag(4)), 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::Negated(term) => Node::try_from(*term)?.negated(),
Filter::Group(mut group) => { Filter::Group(mut group) => {

View file

@ -527,6 +527,9 @@ impl RowContext {
2 => Color::FlagOrange, 2 => Color::FlagOrange,
3 => Color::FlagGreen, 3 => Color::FlagGreen,
4 => Color::FlagBlue, 4 => Color::FlagBlue,
5 => Color::FlagViolet,
6 => Color::FlagTurquoise,
7 => Color::FlagPurple,
_ => { _ => {
if self.note.is_marked() { if self.note.is_marked() {
Color::Marked Color::Marked

View file

@ -119,11 +119,8 @@ impl Card {
/// True if flag changed. /// True if flag changed.
fn set_flag(&mut self, flag: u8) -> bool { fn set_flag(&mut self, flag: u8) -> bool {
// we currently only allow 4 flags // The first 3 bits represent one of the 7 supported flags, the rest of
assert!(flag < 5); // the flag byte is preserved.
// but reserve space for 7, preserving the rest of
// the flags (up to a byte)
let updated_flags = (self.flags & !0b111) | flag; let updated_flags = (self.flags & !0b111) | flag;
if self.flags != updated_flags { if self.flags != updated_flags {
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<OpOutput<usize>> { pub fn set_card_flag(&mut self, cards: &[CardId], flag: u32) -> Result<OpOutput<usize>> {
if flag > 4 { if flag > 7 {
return Err(AnkiError::invalid_input("invalid flag")); return Err(AnkiError::invalid_input("invalid flag"));
} }
let flag = flag as u8; let flag = flag as u8;

View file

@ -414,10 +414,10 @@ fn parse_template(s: &str) -> ParseResult<SearchNode> {
})) }))
} }
/// flag:0-4 /// flag:0-7
fn parse_flag(s: &str) -> ParseResult<SearchNode> { fn parse_flag(s: &str) -> ParseResult<SearchNode> {
if let Ok(flag) = s.parse::<u8>() { if let Ok(flag) = s.parse::<u8>() {
if flag > 4 { if flag > 7 {
Err(parse_failure(s, FailKind::InvalidFlag)) Err(parse_failure(s, FailKind::InvalidFlag))
} else { } else {
Ok(SearchNode::Flag(flag)) Ok(SearchNode::Flag(flag))
@ -999,7 +999,7 @@ mod test {
assert_err_kind(r#""flag: ""#, InvalidFlag); assert_err_kind(r#""flag: ""#, InvalidFlag);
assert_err_kind("flag:-0", InvalidFlag); assert_err_kind("flag:-0", InvalidFlag);
assert_err_kind("flag:", 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); assert_err_kind("flag:1.1", InvalidFlag);
for term in &["added", "edited", "rated", "resched"] { for term in &["added", "edited", "rated", "resched"] {

View file

@ -21,10 +21,16 @@
--flag2-fg: #ffb347; --flag2-fg: #ffb347;
--flag3-fg: #0a0; --flag3-fg: #0a0;
--flag4-fg: #77ccff; --flag4-fg: #77ccff;
--flag5-fg: #fc68e8;
--flag6-fg: #00d3b7;
--flag7-fg: #9e3bfa;
--flag1-bg: #ffaaaa; --flag1-bg: #ffaaaa;
--flag2-bg: #ffb347; --flag2-bg: #ffb347;
--flag3-bg: #82e0aa; --flag3-bg: #82e0aa;
--flag4-bg: #85c1e9; --flag4-bg: #85c1e9;
--flag5-bg: #ffafeb;
--flag6-bg: #4bd3cc;
--flag7-bg: #c07dff;
--buried-fg: #aaaa33; --buried-fg: #aaaa33;
--suspended-fg: #dd0; --suspended-fg: #dd0;
--suspended-bg: #ffffb2; --suspended-bg: #ffffb2;
@ -52,10 +58,16 @@
--flag2-fg: #ffb347; --flag2-fg: #ffb347;
--flag3-fg: #82e0aa; --flag3-fg: #82e0aa;
--flag4-fg: #85c1e9; --flag4-fg: #85c1e9;
--flag5-fg: #ffafeb;
--flag6-fg: #3fccc5;
--flag7-fg: #c07dff;
--flag1-bg: #aa5555; --flag1-bg: #aa5555;
--flag2-bg: #aa6337; --flag2-bg: #aa6337;
--flag3-bg: #33a055; --flag3-bg: #33a055;
--flag4-bg: #3581a9; --flag4-bg: #3581a9;
--flag5-bg: #be64b2;
--flag6-bg: #11a591;
--flag7-bg: #904fce;
--buried-fg: #777733; --buried-fg: #777733;
--suspended-fg: #ffffb2; --suspended-fg: #ffffb2;
--suspended-bg: #aaaa33; --suspended-bg: #aaaa33;