add hidden option to disable tooltips in browse screen

https://forums.ankiweb.net/t/browser-text-pop-up-when-hovering-over-card-poll/13254
This commit is contained in:
Damien Elmes 2021-09-21 15:03:37 +10:00
parent 9720592519
commit 1ceb9965ad
2 changed files with 12 additions and 2 deletions

View file

@ -6,6 +6,7 @@ from __future__ import annotations
import time
from typing import Any, Dict, List, Optional, Sequence, Union, cast
import aqt
from anki.cards import Card, CardId
from anki.collection import BrowserColumns as Columns
from anki.collection import Collection
@ -43,6 +44,7 @@ class DataModel(QAbstractTableModel):
self._rows: Dict[int, CellRow] = {}
self._block_updates = False
self._stale_cutoff = 0.0
self._want_tooltips = aqt.mw.pm.show_browser_table_tooltips()
# Row Object Interface
######################################################################
@ -274,12 +276,14 @@ class DataModel(QAbstractTableModel):
qfont.setFamily(row.font_name)
qfont.setPixelSize(row.font_size)
return qfont
if role == Qt.TextAlignmentRole:
elif role == Qt.TextAlignmentRole:
align: Union[Qt.AlignmentFlag, int] = Qt.AlignVCenter
if self.column_at(index).alignment == Columns.ALIGNMENT_CENTER:
align |= Qt.AlignHCenter
return align
if role in (Qt.DisplayRole, Qt.ToolTipRole):
elif role == Qt.DisplayRole:
return self.get_cell(index).text
elif role == Qt.ToolTipRole and self._want_tooltips:
return self.get_cell(index).text
return QVariant()

View file

@ -657,3 +657,9 @@ create table if not exists profiles
def set_recording_driver(self, driver: RecordingDriver) -> None:
self.profile["recordingDriver"] = driver.value
def show_browser_table_tooltips(self) -> bool:
return self.profile.get("browserTableTooltips", True)
def set_show_browser_table_tooltips(self, val: bool) -> None:
self.profile["browserTableTooltips"] = val