profile patch

This commit is contained in:
unknown 2025-10-04 03:08:02 +03:00
parent 705d96511d
commit e54cec4c49
2 changed files with 75 additions and 12 deletions

View File

@ -1,5 +1,6 @@
from PySide6.QtCore import Qt, Signal from PySide6.QtCore import Qt, Signal
from PySide6.QtWidgets import QWidget, QVBoxLayout, QLabel, QPushButton, QHBoxLayout, QScrollArea from PySide6.QtGui import QPixmap, QPainter, QColor, QBrush
from PySide6.QtWidgets import QWidget, QVBoxLayout, QLabel, QPushButton, QHBoxLayout, QFrame
class ProfileView(QWidget): class ProfileView(QWidget):
@ -9,38 +10,97 @@ class ProfileView(QWidget):
def __init__(self, user: dict, parent=None): def __init__(self, user: dict, parent=None):
super().__init__(parent) super().__init__(parent)
self.user = user or {} self.user = user or {}
root = QVBoxLayout(self) root = QVBoxLayout(self)
root.setContentsMargins(16, 12, 16, 12) root.setContentsMargins(16, 16, 16, 16)
root.setSpacing(8) root.setSpacing(12)
# Card container
card = QFrame()
card.setObjectName("ProfileCard")
card_layout = QVBoxLayout(card)
card_layout.setContentsMargins(16, 16, 16, 16)
card_layout.setSpacing(10)
# Header: avatar + names
header = QHBoxLayout()
header.setSpacing(12)
self.avatar = QLabel()
self._set_avatar_placeholder()
header.addWidget(self.avatar)
names_box = QVBoxLayout()
names_box.setSpacing(4)
# Header info
login = self.user.get("login") or "user" login = self.user.get("login") or "user"
full_name = self.user.get("full_name") or self.user.get("custom_name") or "" full_name = self.user.get("full_name") or self.user.get("custom_name") or ""
bio = (self.user.get("profile") or {}).get("bio") if isinstance(self.user.get("profile"), dict) else None bio = (self.user.get("profile") or {}).get("bio") if isinstance(self.user.get("profile"), dict) else None
self.name_label = QLabel(full_name or "Пользователь")
self.name_label.setObjectName("ProfileName")
self.login_label = QLabel(f"@{login}") self.login_label = QLabel(f"@{login}")
self.login_label.setObjectName("ProfileLogin") self.login_label.setObjectName("ProfileLogin")
self.name_label = QLabel(full_name) names_box.addWidget(self.name_label)
self.name_label.setObjectName("ProfileName") names_box.addWidget(self.login_label)
root.addWidget(self.login_label) header.addLayout(names_box)
if full_name: header.addStretch(1)
root.addWidget(self.name_label) card_layout.addLayout(header)
if bio: if bio:
bio_label = QLabel(str(bio)) bio_label = QLabel(str(bio))
bio_label.setObjectName("ProfileBio")
bio_label.setWordWrap(True) bio_label.setWordWrap(True)
root.addWidget(bio_label) card_layout.addWidget(bio_label)
# Actions # Actions
actions = QHBoxLayout() actions = QHBoxLayout()
actions.setSpacing(8)
self.message_btn = QPushButton("Написать сообщение") self.message_btn = QPushButton("Написать сообщение")
self.message_btn.setObjectName("ProfileActionPrimary")
self.follow_btn = QPushButton("Подписаться") self.follow_btn = QPushButton("Подписаться")
self.follow_btn.setObjectName("ProfileActionSecondary")
actions.addWidget(self.message_btn) actions.addWidget(self.message_btn)
actions.addWidget(self.follow_btn) actions.addWidget(self.follow_btn)
root.addLayout(actions) card_layout.addLayout(actions)
root.addWidget(card)
# Styles
self.setStyleSheet("""
#ProfileCard {
border: 1px solid #e5e5ea;
border-radius: 12px;
background-color: rgba(0,0,0,0.02);
}
#ProfileName { font-size: 16px; font-weight: 600; }
#ProfileLogin { font-size: 13px; color: #8e8e93; }
#ProfileBio { font-size: 13px; }
QPushButton#ProfileActionPrimary {
background-color: #0A84FF; color: white; border: none; border-radius: 10px; padding: 8px 12px;
}
QPushButton#ProfileActionPrimary:hover { background-color: #1B8CFF; }
QPushButton#ProfileActionPrimary:pressed { background-color: #0a6ed1; }
QPushButton#ProfileActionSecondary {
background-color: transparent; color: #0A84FF; border: 1px solid rgba(10,132,255,0.4); border-radius: 10px; padding: 8px 12px;
}
QPushButton#ProfileActionSecondary:hover { background-color: rgba(10,132,255,0.06); }
QPushButton#ProfileActionSecondary:pressed { background-color: rgba(10,132,255,0.14); }
""")
# Signals
self.message_btn.clicked.connect(lambda: self.start_chat_clicked.emit(self.user)) self.message_btn.clicked.connect(lambda: self.start_chat_clicked.emit(self.user))
self.follow_btn.clicked.connect(lambda: self.follow_clicked.emit(self.user)) self.follow_btn.clicked.connect(lambda: self.follow_clicked.emit(self.user))
def _set_avatar_placeholder(self, size: int = 72):
pixmap = QPixmap(size, size)
pixmap.fill(Qt.transparent)
p = QPainter(pixmap)
p.setRenderHint(QPainter.Antialiasing)
p.setBrush(QBrush(QColor("#d1d1d6")))
p.setPen(Qt.NoPen)
p.drawEllipse(0, 0, size, size)
p.end()
self.avatar.setPixmap(pixmap)
self.avatar.setFixedSize(size, size)
self.avatar.setScaledContents(True)

View File

@ -741,6 +741,9 @@ class YobbleHomeView(QWidget):
def open_profile_view(self, user: dict): def open_profile_view(self, user: dict):
try: try:
self.profile_view = ProfileView(user) self.profile_view = ProfileView(user)
# stub handlers for actions
self.profile_view.start_chat_clicked.connect(lambda u: self.show_notification("Скоро: написать сообщение"))
self.profile_view.follow_clicked.connect(lambda u: self.show_notification("Скоро: подписка"))
self.bottom_bar.hide() self.bottom_bar.hide()
self.burger_menu_button.hide() self.burger_menu_button.hide()
self.back_button.show() self.back_button.show()