Skip to content

Commit

Permalink
Faker-based author tooltips
Browse files Browse the repository at this point in the history
  • Loading branch information
ichorid committed Jan 7, 2022
1 parent 313abfe commit ab6cfdf
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/tribler-gui/tribler_gui/widgets/tablecontentmodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

from PyQt5.QtCore import QAbstractTableModel, QModelIndex, QRectF, QSize, Qt, pyqtSignal

from faker import Faker

from tribler_common.simpledefs import CHANNELS_VIEW_UUID, CHANNEL_STATE
from tribler_common.utilities import to_fts_query

Expand All @@ -20,6 +22,19 @@
EXPANDING = 0


user_names_cache = {}


def get_user_name_cached(pk):
name = user_names_cache.get(pk)
if name is not None:
return name
Faker.seed(pk)
name = Faker().name()
user_names_cache[pk] = name
return name


class Column(Enum):
ACTIONS = auto()
CATEGORY = auto()
Expand Down Expand Up @@ -62,7 +77,7 @@ def define_columns():
Column.STATE: d('state', "", width=80, tooltip_filter=lambda data: data, sortable=False),
Column.TORRENTS: d('torrents', tr("Torrents"), width=90),
Column.SUBSCRIBED: d('subscribed', tr("Subscribed"), width=95),
Column.AUTHOR: d('public_key', "", width=40),
Column.AUTHOR: d('public_key', "", width=40, tooltip_filter=lambda data:get_user_name_cached(data)),
}
# pylint: enable=line-too-long
# fmt:on
Expand Down

0 comments on commit ab6cfdf

Please sign in to comment.