More profile improvements:

- Now scrolls entire profile instead of only device list, improving the experience on smaller screens
- Fixed centering of room name
- Allow profile to be sized smaller to match the new scrolling behavior
- Silenced warning about room being null for global profiles
- Matrix URLs now open global profiles instead of room-specific profiles if the user is not in the currently opened room
- Opening global profile from room specific profile now uses openGlobalUserProfile function instead of reinventing the wheel
This commit is contained in:
Thulinma 2021-09-07 02:34:32 +02:00
parent 80fa3e801f
commit a39cb537ae
3 changed files with 273 additions and 255 deletions

View File

@ -21,7 +21,7 @@ ApplicationWindow {
height: 650 height: 650
width: 420 width: 420
minimumWidth: 150 minimumWidth: 150
minimumHeight: 420 minimumHeight: 150
palette: Nheko.colors palette: Nheko.colors
color: Nheko.colors.window color: Nheko.colors.window
title: profile.isGlobalUserProfile ? qsTr("Global User Profile") : qsTr("Room User Profile") title: profile.isGlobalUserProfile ? qsTr("Global User Profile") : qsTr("Room User Profile")
@ -34,11 +34,19 @@ ApplicationWindow {
onActivated: userProfileDialog.close() onActivated: userProfileDialog.close()
} }
ColumnLayout {
id: contentL
ListView {
ScrollHelper {
flickable: parent
anchors.fill: parent anchors.fill: parent
anchors.margins: 10 enabled: !Settings.mobileMode
}
header: ColumnLayout {
id: contentL
width: devicelist.width
spacing: 10 spacing: 10
Avatar { Avatar {
@ -151,31 +159,30 @@ ApplicationWindow {
MatrixText { MatrixText {
text: profile.userid text: profile.userid
font.pixelSize: 15
Layout.alignment: Qt.AlignHCenter Layout.alignment: Qt.AlignHCenter
} }
RowLayout {
visible: !profile.isGlobalUserProfile
Layout.alignment: Qt.AlignHCenter
spacing: Nheko.paddingSmall
MatrixText { MatrixText {
id: displayRoomname id: displayRoomname
text: qsTr("Room: %1").arg(profile.room.roomName) text: qsTr("Room: %1").arg(profile.room?profile.room.roomName:"")
Layout.alignment: Qt.AlignHCenter
visible: !profile.isGlobalUserProfile
ToolTip.text: qsTr("This is a room-specific profile. The user's name and avatar may be different from their global versions.") ToolTip.text: qsTr("This is a room-specific profile. The user's name and avatar may be different from their global versions.")
ToolTip.visible: ma.hovered ToolTip.visible: ma.hovered
HoverHandler { HoverHandler {
id: ma id: ma
} }
}
ImageButton { ImageButton {
anchors.leftMargin: Nheko.paddingSmall
anchors.left: displayRoomname.right
anchors.verticalCenter: displayRoomname.verticalCenter
image: ":/icons/icons/ui/world.png" image: ":/icons/icons/ui/world.png"
hoverEnabled: true hoverEnabled: true
ToolTip.visible: hovered ToolTip.visible: hovered
ToolTip.text: qsTr("Open the global profile for this user.") ToolTip.text: qsTr("Open the global profile for this user.")
onClicked: profile.openGlobalProfile() onClicked: profile.openGlobalProfile()
visible: !profile.isGlobalUserProfile
} }
} }
@ -212,7 +219,8 @@ ApplicationWindow {
// } // }
Layout.alignment: Qt.AlignHCenter Layout.alignment: Qt.AlignHCenter
spacing: 8 Layout.bottomMargin: 10
spacing: Nheko.paddingSmall
ImageButton { ImageButton {
image: ":/icons/icons/ui/black-bubble-speech.png" image: ":/icons/icons/ui/black-bubble-speech.png"
@ -241,17 +249,18 @@ ApplicationWindow {
} }
} }
}
ListView {
id: devicelist id: devicelist
Layout.fillHeight: true Layout.fillHeight: true
Layout.minimumHeight: 200
Layout.fillWidth: true Layout.fillWidth: true
clip: true clip: true
spacing: 8 spacing: 8
boundsBehavior: Flickable.StopAtBounds boundsBehavior: Flickable.StopAtBounds
model: profile.deviceList model: profile.deviceList
anchors.fill: parent
anchors.margins: 10
delegate: RowLayout { delegate: RowLayout {
width: devicelist.width width: devicelist.width
@ -299,14 +308,19 @@ ApplicationWindow {
} }
} }
footerPositioning: ListView.OverlayFooter
}
}
footer: DialogButtonBox { footer: DialogButtonBox {
z: 2
width: devicelist.width
alignment: Qt.AlignRight
standardButtons: DialogButtonBox.Ok standardButtons: DialogButtonBox.Ok
onAccepted: userProfileDialog.close() onAccepted: userProfileDialog.close()
background: Rectangle {
anchors.fill: parent
color: Nheko.colors.window
}
}
} }
} }

View File

@ -1279,8 +1279,13 @@ ChatPage::handleMatrixUri(const QByteArray &uri)
if (sigil1 == "u") { if (sigil1 == "u") {
if (action.isEmpty()) { if (action.isEmpty()) {
if (auto t = view_manager_->rooms()->currentRoom()) auto t = view_manager_->rooms()->currentRoom();
if (t &&
cache::isRoomMember(mxid1.toStdString(), t->roomId().toStdString())) {
t->openUserProfile(mxid1); t->openUserProfile(mxid1);
return;
}
emit view_manager_->openGlobalUserProfile(mxid1);
} else if (action == "chat") { } else if (action == "chat") {
this->startChat(mxid1); this->startChat(mxid1);
} }

View File

@ -423,6 +423,5 @@ UserProfile::getGlobalProfileData()
void void
UserProfile::openGlobalProfile() UserProfile::openGlobalProfile()
{ {
UserProfile *userProfile = new UserProfile("", userid_, manager, model); emit manager->openGlobalUserProfile(userid_);
emit manager->openProfile(userProfile);
} }