Merge pull request #1397 from RumovZ/column-tooltips
Add tooltips for some browser columns
This commit is contained in:
commit
a174c41801
@ -151,6 +151,13 @@ browsing-sidebar-save-current-search = Save Current Search
|
||||
browsing-sidebar-card-state = Card State
|
||||
browsing-sidebar-flags = Flags
|
||||
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 a note has
|
||||
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-added-today = Added
|
||||
browsing-again-today = Again
|
||||
|
@ -149,6 +149,8 @@ message BrowserColumns {
|
||||
Sorting sorting = 4;
|
||||
bool uses_cell_font = 5;
|
||||
Alignment alignment = 6;
|
||||
string cards_mode_tooltip = 7;
|
||||
string notes_mode_tooltip = 8;
|
||||
}
|
||||
repeated Column columns = 1;
|
||||
}
|
||||
|
@ -47,6 +47,11 @@ class ItemState(ABC):
|
||||
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
|
||||
|
||||
# abstractproperty is deprecated but used due to mypy limitations
|
||||
|
@ -451,10 +451,12 @@ class Table:
|
||||
def _on_header_context(self, pos: QPoint) -> None:
|
||||
gpos = self._view.mapToGlobal(pos)
|
||||
m = QMenu()
|
||||
m.setToolTipsVisible(True)
|
||||
for key, column in self._model.columns.items():
|
||||
a = m.addAction(self._state.column_label(column))
|
||||
a.setCheckable(True)
|
||||
a.setChecked(self._model.active_column_index(key) is not None)
|
||||
a.setToolTip(self._state.column_tooltip(column))
|
||||
qconnect(
|
||||
a.toggled,
|
||||
lambda checked, key=key: self._on_column_toggled(checked, key),
|
||||
|
@ -14,6 +14,8 @@ impl browser_table::Column {
|
||||
sorting: self.sorting() as i32,
|
||||
uses_cell_font: self.uses_cell_font(),
|
||||
alignment: self.alignment() as i32,
|
||||
cards_mode_tooltip: self.cards_mode_tooltip(i18n),
|
||||
notes_mode_tooltip: self.notes_mode_tooltip(i18n),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -156,6 +156,27 @@ impl Column {
|
||||
.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 {
|
||||
use pb::browser_columns::Sorting;
|
||||
match self {
|
||||
|
Loading…
Reference in New Issue
Block a user