diff --git a/app/ui/views/search_results_view.py b/app/ui/views/search_results_view.py index 01c3854..d484014 100644 --- a/app/ui/views/search_results_view.py +++ b/app/ui/views/search_results_view.py @@ -23,9 +23,17 @@ class SearchResultsView(QWidget): def populate(self, data): """data: SearchData (users, groups, channels, messages).""" 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 = getattr(data, 'users', []) or [] + users = users if users: self._add_section_header("Пользователи") 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)}) # Groups - groups = getattr(data, 'groups', []) or [] + groups = groups if groups: self._add_section_header("Беседы") 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", "")))}) # Channels - channels = getattr(data, 'channels', []) or [] + channels = channels if channels: self._add_section_header("Паблики") 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", "")))}) # Messages - messages = getattr(data, 'messages', []) or [] + messages = messages if messages: self._add_section_header("Сообщения") for m in messages: @@ -105,3 +113,18 @@ class SearchResultsView(QWidget): data = item.data(Qt.UserRole) if data is not None: 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) diff --git a/app/ui/views/yobble_home_view.py b/app/ui/views/yobble_home_view.py index 262790b..a6f383b 100644 --- a/app/ui/views/yobble_home_view.py +++ b/app/ui/views/yobble_home_view.py @@ -708,9 +708,9 @@ class YobbleHomeView(QWidget): groups_cnt = len(getattr(data, 'groups', []) or []) channels_cnt = len(getattr(data, 'channels', []) or []) messages_cnt = len(getattr(data, 'messages', []) or []) - self.show_notification(localizer.translate( - f"Найдено: пользователи {users_cnt}, беседы {groups_cnt}, паблики {channels_cnt}, сообщения {messages_cnt}" - )) + # self.show_notification(localizer.translate( + # f"Найдено: пользователи {users_cnt}, беседы {groups_cnt}, паблики {channels_cnt}, сообщения {messages_cnt}" + # )) # Показать результаты на отдельной странице try: @@ -812,6 +812,16 @@ class YobbleHomeView(QWidget): color: {title_color}; 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 {{ font-size: 28px; font-weight: bold;