search patch
This commit is contained in:
parent
527e18883b
commit
859ea0de7d
@ -23,9 +23,17 @@ class SearchResultsView(QWidget):
|
|||||||
def populate(self, data):
|
def populate(self, data):
|
||||||
"""data: SearchData (users, groups, channels, messages)."""
|
"""data: SearchData (users, groups, channels, messages)."""
|
||||||
self.clear()
|
self.clear()
|
||||||
|
# Если пусто — показать заглушку
|
||||||
|
users = getattr(data, 'users', []) or []
|
||||||
|
groups = getattr(data, 'groups', []) or []
|
||||||
|
channels = getattr(data, 'channels', []) or []
|
||||||
|
messages = getattr(data, 'messages', []) or []
|
||||||
|
if not users and not groups and not channels and not messages:
|
||||||
|
self._show_empty_state("Ничего не нашли")
|
||||||
|
return
|
||||||
|
|
||||||
# Users
|
# Users
|
||||||
users = getattr(data, 'users', []) or []
|
users = users
|
||||||
if users:
|
if users:
|
||||||
self._add_section_header("Пользователи")
|
self._add_section_header("Пользователи")
|
||||||
for u in users:
|
for u in users:
|
||||||
@ -34,7 +42,7 @@ class SearchResultsView(QWidget):
|
|||||||
self._add_chat_like_item(title, subtitle, timestamp="", payload={"type": "user", "user_id": str(u.user_id)})
|
self._add_chat_like_item(title, subtitle, timestamp="", payload={"type": "user", "user_id": str(u.user_id)})
|
||||||
|
|
||||||
# Groups
|
# Groups
|
||||||
groups = getattr(data, 'groups', []) or []
|
groups = groups
|
||||||
if groups:
|
if groups:
|
||||||
self._add_section_header("Беседы")
|
self._add_section_header("Беседы")
|
||||||
for g in groups:
|
for g in groups:
|
||||||
@ -42,7 +50,7 @@ class SearchResultsView(QWidget):
|
|||||||
self._add_chat_like_item(title or "Группа", "Беседа", timestamp="", payload={"type": "group", "chat_id": str((g.get("chat_id") if isinstance(g, dict) else getattr(g, "chat_id", "")))})
|
self._add_chat_like_item(title or "Группа", "Беседа", timestamp="", payload={"type": "group", "chat_id": str((g.get("chat_id") if isinstance(g, dict) else getattr(g, "chat_id", "")))})
|
||||||
|
|
||||||
# Channels
|
# Channels
|
||||||
channels = getattr(data, 'channels', []) or []
|
channels = channels
|
||||||
if channels:
|
if channels:
|
||||||
self._add_section_header("Паблики")
|
self._add_section_header("Паблики")
|
||||||
for ch in channels:
|
for ch in channels:
|
||||||
@ -50,7 +58,7 @@ class SearchResultsView(QWidget):
|
|||||||
self._add_chat_like_item(title or "Паблик", "Паблик", timestamp="", payload={"type": "channel", "channel_id": str((ch.get("channel_id") if isinstance(ch, dict) else getattr(ch, "channel_id", "")))})
|
self._add_chat_like_item(title or "Паблик", "Паблик", timestamp="", payload={"type": "channel", "channel_id": str((ch.get("channel_id") if isinstance(ch, dict) else getattr(ch, "channel_id", "")))})
|
||||||
|
|
||||||
# Messages
|
# Messages
|
||||||
messages = getattr(data, 'messages', []) or []
|
messages = messages
|
||||||
if messages:
|
if messages:
|
||||||
self._add_section_header("Сообщения")
|
self._add_section_header("Сообщения")
|
||||||
for m in messages:
|
for m in messages:
|
||||||
@ -105,3 +113,18 @@ class SearchResultsView(QWidget):
|
|||||||
data = item.data(Qt.UserRole)
|
data = item.data(Qt.UserRole)
|
||||||
if data is not None:
|
if data is not None:
|
||||||
self.result_selected.emit(data)
|
self.result_selected.emit(data)
|
||||||
|
|
||||||
|
def _show_empty_state(self, text: str):
|
||||||
|
item = QListWidgetItem()
|
||||||
|
item.setFlags(Qt.ItemIsEnabled)
|
||||||
|
container = QWidget()
|
||||||
|
lay = QVBoxLayout(container)
|
||||||
|
lay.setContentsMargins(0, 40, 0, 0)
|
||||||
|
lay.setSpacing(0)
|
||||||
|
label = QLabel(text)
|
||||||
|
label.setAlignment(Qt.AlignCenter)
|
||||||
|
label.setStyleSheet("font-size: 18px; color: #8e8e93;")
|
||||||
|
lay.addWidget(label)
|
||||||
|
item.setSizeHint(container.sizeHint())
|
||||||
|
self.list.addItem(item)
|
||||||
|
self.list.setItemWidget(item, container)
|
||||||
|
|||||||
@ -708,9 +708,9 @@ class YobbleHomeView(QWidget):
|
|||||||
groups_cnt = len(getattr(data, 'groups', []) or [])
|
groups_cnt = len(getattr(data, 'groups', []) or [])
|
||||||
channels_cnt = len(getattr(data, 'channels', []) or [])
|
channels_cnt = len(getattr(data, 'channels', []) or [])
|
||||||
messages_cnt = len(getattr(data, 'messages', []) or [])
|
messages_cnt = len(getattr(data, 'messages', []) or [])
|
||||||
self.show_notification(localizer.translate(
|
# self.show_notification(localizer.translate(
|
||||||
f"Найдено: пользователи {users_cnt}, беседы {groups_cnt}, паблики {channels_cnt}, сообщения {messages_cnt}"
|
# f"Найдено: пользователи {users_cnt}, беседы {groups_cnt}, паблики {channels_cnt}, сообщения {messages_cnt}"
|
||||||
))
|
# ))
|
||||||
|
|
||||||
# Показать результаты на отдельной странице
|
# Показать результаты на отдельной странице
|
||||||
try:
|
try:
|
||||||
@ -812,6 +812,16 @@ class YobbleHomeView(QWidget):
|
|||||||
color: {title_color};
|
color: {title_color};
|
||||||
background: transparent;
|
background: transparent;
|
||||||
}}
|
}}
|
||||||
|
#SearchButton:hover,
|
||||||
|
#SearchCloseButton:hover {{
|
||||||
|
background-color: {hover_bg};
|
||||||
|
border-radius: 6px;
|
||||||
|
}}
|
||||||
|
#SearchButton:pressed,
|
||||||
|
#SearchCloseButton:pressed {{
|
||||||
|
background-color: {pressed_bg};
|
||||||
|
border-radius: 6px;
|
||||||
|
}}
|
||||||
#BackButton {{
|
#BackButton {{
|
||||||
font-size: 28px;
|
font-size: 28px;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user