Add tooltips for some browser columns

This commit is contained in:
RumovZ 2021-09-30 12:45:05 +02:00
parent 09cc55b0d3
commit ee2ecd0700
6 changed files with 39 additions and 0 deletions

View file

@ -149,6 +149,13 @@ browsing-sidebar-save-current-search = Save Current Search
browsing-sidebar-card-state = Card State browsing-sidebar-card-state = Card State
browsing-sidebar-flags = Flags browsing-sidebar-flags = Flags
browsing-today = Today browsing-today = Today
browsing-tooltip-card-modified = The last time changes were made to a card, including reviews, flags and deck changes
browsing-tooltip-note-modified = The last time changes were made to a note, usually field content or tag edits
browsing-tooltip-card = The name of a card's card template
browsing-tooltip-cards = The number of cards to a note
browsing-tooltip-notetype = The name of a note's notetype
browsing-tooltip-question = The front side of a card, customisable in the card template editor
browsing-tooltip-answer = The back side of a card, customisable in the card template editor
browsing-studied-today = Studied browsing-studied-today = Studied
browsing-added-today = Added browsing-added-today = Added
browsing-again-today = Again browsing-again-today = Again

View file

@ -149,6 +149,8 @@ message BrowserColumns {
Sorting sorting = 4; Sorting sorting = 4;
bool uses_cell_font = 5; bool uses_cell_font = 5;
Alignment alignment = 6; Alignment alignment = 6;
string cards_mode_tooltip = 7;
string notes_mode_tooltip = 8;
} }
repeated Column columns = 1; repeated Column columns = 1;
} }

View file

@ -47,6 +47,11 @@ class ItemState(ABC):
column.notes_mode_label if self.is_notes_mode() else column.cards_mode_label column.notes_mode_label if self.is_notes_mode() else column.cards_mode_label
) )
def column_tooltip(self, column: Column) -> str:
if self.is_notes_mode():
return column.notes_mode_tooltip
return column.cards_mode_tooltip
# Columns and sorting # Columns and sorting
# abstractproperty is deprecated but used due to mypy limitations # abstractproperty is deprecated but used due to mypy limitations

View file

@ -338,10 +338,12 @@ class Table:
def _on_header_context(self, pos: QPoint) -> None: def _on_header_context(self, pos: QPoint) -> None:
gpos = self._view.mapToGlobal(pos) gpos = self._view.mapToGlobal(pos)
m = QMenu() m = QMenu()
m.setToolTipsVisible(True)
for key, column in self._model.columns.items(): for key, column in self._model.columns.items():
a = m.addAction(self._state.column_label(column)) a = m.addAction(self._state.column_label(column))
a.setCheckable(True) a.setCheckable(True)
a.setChecked(self._model.active_column_index(key) is not None) a.setChecked(self._model.active_column_index(key) is not None)
a.setToolTip(self._state.column_tooltip(column))
qconnect( qconnect(
a.toggled, a.toggled,
lambda checked, key=key: self._on_column_toggled(checked, key), lambda checked, key=key: self._on_column_toggled(checked, key),

View file

@ -14,6 +14,8 @@ impl browser_table::Column {
sorting: self.sorting() as i32, sorting: self.sorting() as i32,
uses_cell_font: self.uses_cell_font(), uses_cell_font: self.uses_cell_font(),
alignment: self.alignment() as i32, alignment: self.alignment() as i32,
cards_mode_tooltip: self.cards_mode_tooltip(i18n),
notes_mode_tooltip: self.notes_mode_tooltip(i18n),
} }
} }
} }

View file

@ -156,6 +156,27 @@ impl Column {
.into() .into()
} }
pub fn cards_mode_tooltip(self, i18n: &I18n) -> String {
match self {
Self::Answer => i18n.browsing_tooltip_answer(),
Self::CardMod => i18n.browsing_tooltip_card_modified(),
Self::Cards => i18n.browsing_tooltip_card(),
Self::NoteMod => i18n.browsing_tooltip_note_modified(),
Self::Notetype => i18n.browsing_tooltip_notetype(),
Self::Question => i18n.browsing_tooltip_question(),
_ => "".into(),
}
.into()
}
pub fn notes_mode_tooltip(self, i18n: &I18n) -> String {
match self {
Self::Cards => i18n.browsing_tooltip_cards(),
_ => return self.cards_mode_label(i18n),
}
.into()
}
pub fn sorting(self) -> pb::browser_columns::Sorting { pub fn sorting(self) -> pb::browser_columns::Sorting {
use pb::browser_columns::Sorting; use pb::browser_columns::Sorting;
match self { match self {