Fix list items being hoverable through between settings and new room buttons

This commit is contained in:
Nicolas Werner 2022-01-30 20:09:58 +01:00
parent 2613275461
commit f76d679ef6
No known key found for this signature in database
GPG Key ID: C8D75E610773F2D9
3 changed files with 235 additions and 229 deletions

View File

@ -97,6 +97,7 @@ Rectangle {
implicitHeight: chatPage.height implicitHeight: chatPage.height
collapsed: parent.collapsed collapsed: parent.collapsed
anchors.fill: parent
} }
Binding { Binding {

View File

@ -385,7 +385,7 @@ Page {
header: ColumnLayout { header: ColumnLayout {
spacing: 0 spacing: 0
Rectangle { Pane {
id: userInfoPanel id: userInfoPanel
function openUserProfile() { function openUserProfile() {
@ -396,12 +396,15 @@ Page {
userProfile.show(); userProfile.show();
} }
color: Nheko.colors.window
Layout.fillWidth: true Layout.fillWidth: true
Layout.alignment: Qt.AlignBottom Layout.alignment: Qt.AlignBottom
Layout.preferredHeight: userInfoGrid.implicitHeight + 2 * Nheko.paddingMedium //Layout.preferredHeight: userInfoGrid.implicitHeight + 2 * Nheko.paddingMedium
padding: Nheko.paddingMedium
Layout.minimumHeight: 40 Layout.minimumHeight: 40
background: Rectangle {color: Nheko.colors.window}
InputDialog { InputDialog {
id: statusDialog id: statusDialog
@ -442,14 +445,12 @@ Page {
gesturePolicy: TapHandler.ReleaseWithinBounds gesturePolicy: TapHandler.ReleaseWithinBounds
} }
RowLayout { contentItem: RowLayout {
id: userInfoGrid id: userInfoGrid
property var profile: Nheko.currentUser property var profile: Nheko.currentUser
spacing: Nheko.paddingMedium spacing: Nheko.paddingMedium
anchors.fill: parent
anchors.margins: Nheko.paddingMedium
Avatar { Avatar {
id: avatar id: avatar
@ -614,19 +615,17 @@ Page {
Layout.fillWidth: true Layout.fillWidth: true
} }
Rectangle { Pane {
color: Nheko.colors.window
Layout.fillWidth: true Layout.fillWidth: true
Layout.alignment: Qt.AlignBottom Layout.alignment: Qt.AlignBottom
Layout.preferredHeight: buttonRow.implicitHeight
Layout.minimumHeight: 40 Layout.minimumHeight: 40
RowLayout { horizontalPadding: Nheko.paddingMedium
id: buttonRow verticalPadding: 0
anchors.left: parent.left background: Rectangle {color: Nheko.colors.window}
anchors.right: parent.right contentItem: RowLayout {
anchors.margins: Nheko.paddingMedium id: buttonRow
ImageButton { ImageButton {
Layout.fillWidth: true Layout.fillWidth: true

View File

@ -12,7 +12,7 @@ import im.nheko 1.0
import "./delegates" import "./delegates"
Rectangle { Pane {
id: topBar id: topBar
property bool showBackButton: false property bool showBackButton: false
@ -28,7 +28,11 @@ Rectangle {
Layout.fillWidth: true Layout.fillWidth: true
implicitHeight: topLayout.height + Nheko.paddingMedium * 2 implicitHeight: topLayout.height + Nheko.paddingMedium * 2
z: 3 z: 3
color: Nheko.colors.window
padding: 0
background: Rectangle {
color: Nheko.colors.window
}
TapHandler { TapHandler {
onSingleTapped: { onSingleTapped: {
@ -65,248 +69,250 @@ Rectangle {
grabPermissions: PointerHandler.TakeOverForbidden | PointerHandler.CanTakeOverFromAnything grabPermissions: PointerHandler.TakeOverForbidden | PointerHandler.CanTakeOverFromAnything
} }
GridLayout { contentItem: Item {
id: topLayout GridLayout {
id: topLayout
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right
anchors.margins: Nheko.paddingMedium anchors.margins: Nheko.paddingMedium
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
columnSpacing: Nheko.paddingSmall columnSpacing: Nheko.paddingSmall
rowSpacing: Nheko.paddingSmall rowSpacing: Nheko.paddingSmall
ImageButton { ImageButton {
id: backToRoomsButton id: backToRoomsButton
Layout.column: 0 Layout.column: 0
Layout.row: 0 Layout.row: 0
Layout.rowSpan: 2 Layout.rowSpan: 2
Layout.alignment: Qt.AlignVCenter Layout.alignment: Qt.AlignVCenter
Layout.preferredHeight: Nheko.avatarSize - Nheko.paddingMedium Layout.preferredHeight: Nheko.avatarSize - Nheko.paddingMedium
Layout.preferredWidth: Nheko.avatarSize - Nheko.paddingMedium Layout.preferredWidth: Nheko.avatarSize - Nheko.paddingMedium
visible: showBackButton visible: showBackButton
image: ":/icons/icons/ui/angle-arrow-left.svg" image: ":/icons/icons/ui/angle-arrow-left.svg"
ToolTip.visible: hovered ToolTip.visible: hovered
ToolTip.text: qsTr("Back to room list") ToolTip.text: qsTr("Back to room list")
onClicked: Rooms.resetCurrentRoom() onClicked: Rooms.resetCurrentRoom()
}
Avatar {
Layout.column: 1
Layout.row: 0
Layout.rowSpan: 2
Layout.alignment: Qt.AlignVCenter
width: Nheko.avatarSize
height: Nheko.avatarSize
url: avatarUrl.replace("mxc://", "image://MxcImage/")
roomid: roomId
userid: isDirect ? directChatOtherUserId : ""
displayName: roomName
enabled: false
}
Label {
Layout.fillWidth: true
Layout.column: 2
Layout.row: 0
color: Nheko.colors.text
font.pointSize: fontMetrics.font.pointSize * 1.1
text: roomName
maximumLineCount: 1
elide: Text.ElideRight
textFormat: Text.RichText
}
MatrixText {
id: roomTopicC
Layout.fillWidth: true
Layout.column: 2
Layout.row: 1
Layout.maximumHeight: fontMetrics.lineSpacing * 2 // show 2 lines
selectByMouse: false
enabled: false
clip: true
text: roomTopic
}
EncryptionIndicator {
Layout.column: 3
Layout.row: 0
Layout.rowSpan: 2
Layout.preferredHeight: Nheko.avatarSize - Nheko.paddingMedium
Layout.preferredWidth: Nheko.avatarSize - Nheko.paddingMedium
sourceSize.height: Layout.preferredHeight * Screen.devicePixelRatio
sourceSize.width: Layout.preferredWidth * Screen.devicePixelRatio
visible: isEncrypted
encrypted: isEncrypted
trust: trustlevel
ToolTip.text: {
if (!encrypted)
return qsTr("This room is not encrypted!");
switch (trust) {
case Crypto.Verified:
return qsTr("This room contains only verified devices.");
case Crypto.TOFU:
return qsTr("This room contains verified devices and devices which have never changed their master key.");
default:
return qsTr("This room contains unverified devices!");
}
} }
}
ImageButton { Avatar {
id: pinButton Layout.column: 1
Layout.row: 0
Layout.rowSpan: 2
Layout.alignment: Qt.AlignVCenter
width: Nheko.avatarSize
height: Nheko.avatarSize
url: avatarUrl.replace("mxc://", "image://MxcImage/")
roomid: roomId
userid: isDirect ? directChatOtherUserId : ""
displayName: roomName
enabled: false
}
property bool pinsShown: !Settings.hiddenPins.includes(roomId) Label {
Layout.fillWidth: true
Layout.column: 2
Layout.row: 0
color: Nheko.colors.text
font.pointSize: fontMetrics.font.pointSize * 1.1
text: roomName
maximumLineCount: 1
elide: Text.ElideRight
textFormat: Text.RichText
}
visible: !!room && room.pinnedMessages.length > 0 MatrixText {
Layout.column: 4 id: roomTopicC
Layout.row: 0 Layout.fillWidth: true
Layout.rowSpan: 2 Layout.column: 2
Layout.alignment: Qt.AlignVCenter Layout.row: 1
Layout.preferredHeight: Nheko.avatarSize - Nheko.paddingMedium Layout.maximumHeight: fontMetrics.lineSpacing * 2 // show 2 lines
Layout.preferredWidth: Nheko.avatarSize - Nheko.paddingMedium selectByMouse: false
image: pinsShown ? ":/icons/icons/ui/pin.svg" : ":/icons/icons/ui/pin-off.svg" enabled: false
ToolTip.visible: hovered clip: true
ToolTip.text: qsTr("Show or hide pinned messages") text: roomTopic
onClicked: { }
var ps = Settings.hiddenPins;
if (pinsShown) { EncryptionIndicator {
ps.push(roomId); Layout.column: 3
} else { Layout.row: 0
const index = ps.indexOf(roomId); Layout.rowSpan: 2
if (index > -1) { Layout.preferredHeight: Nheko.avatarSize - Nheko.paddingMedium
ps.splice(index, 1); Layout.preferredWidth: Nheko.avatarSize - Nheko.paddingMedium
sourceSize.height: Layout.preferredHeight * Screen.devicePixelRatio
sourceSize.width: Layout.preferredWidth * Screen.devicePixelRatio
visible: isEncrypted
encrypted: isEncrypted
trust: trustlevel
ToolTip.text: {
if (!encrypted)
return qsTr("This room is not encrypted!");
switch (trust) {
case Crypto.Verified:
return qsTr("This room contains only verified devices.");
case Crypto.TOFU:
return qsTr("This room contains verified devices and devices which have never changed their master key.");
default:
return qsTr("This room contains unverified devices!");
} }
} }
Settings.hiddenPins = ps;
} }
} ImageButton {
id: pinButton
ImageButton { property bool pinsShown: !Settings.hiddenPins.includes(roomId)
id: roomOptionsButton
visible: !!room visible: !!room && room.pinnedMessages.length > 0
Layout.column: 5 Layout.column: 4
Layout.row: 0 Layout.row: 0
Layout.rowSpan: 2 Layout.rowSpan: 2
Layout.alignment: Qt.AlignVCenter Layout.alignment: Qt.AlignVCenter
Layout.preferredHeight: Nheko.avatarSize - Nheko.paddingMedium Layout.preferredHeight: Nheko.avatarSize - Nheko.paddingMedium
Layout.preferredWidth: Nheko.avatarSize - Nheko.paddingMedium Layout.preferredWidth: Nheko.avatarSize - Nheko.paddingMedium
image: ":/icons/icons/ui/options.svg" image: pinsShown ? ":/icons/icons/ui/pin.svg" : ":/icons/icons/ui/pin-off.svg"
ToolTip.visible: hovered ToolTip.visible: hovered
ToolTip.text: qsTr("Room options") ToolTip.text: qsTr("Show or hide pinned messages")
onClicked: roomOptionsMenu.open(roomOptionsButton) onClicked: {
var ps = Settings.hiddenPins;
Platform.Menu { if (pinsShown) {
id: roomOptionsMenu ps.push(roomId);
} else {
Platform.MenuItem { const index = ps.indexOf(roomId);
visible: room ? room.permissions.canInvite() : false if (index > -1) {
text: qsTr("Invite users") ps.splice(index, 1);
onTriggered: TimelineManager.openInviteUsers(roomId) }
} }
Settings.hiddenPins = ps;
Platform.MenuItem {
text: qsTr("Members")
onTriggered: TimelineManager.openRoomMembers(room)
}
Platform.MenuItem {
text: qsTr("Leave room")
onTriggered: TimelineManager.openLeaveRoomDialog(roomId)
}
Platform.MenuItem {
text: qsTr("Settings")
onTriggered: TimelineManager.openRoomSettings(roomId)
} }
} }
} ImageButton {
id: roomOptionsButton
ScrollView { visible: !!room
id: pinnedMessages Layout.column: 5
Layout.row: 0
Layout.rowSpan: 2
Layout.alignment: Qt.AlignVCenter
Layout.preferredHeight: Nheko.avatarSize - Nheko.paddingMedium
Layout.preferredWidth: Nheko.avatarSize - Nheko.paddingMedium
image: ":/icons/icons/ui/options.svg"
ToolTip.visible: hovered
ToolTip.text: qsTr("Room options")
onClicked: roomOptionsMenu.open(roomOptionsButton)
Layout.row: 2 Platform.Menu {
Layout.column: 2 id: roomOptionsMenu
Layout.columnSpan: 3
Layout.fillWidth: true Platform.MenuItem {
Layout.preferredHeight: Math.min(contentHeight, Nheko.avatarSize * 4) visible: room ? room.permissions.canInvite() : false
text: qsTr("Invite users")
visible: !!room && room.pinnedMessages.length > 0 && !Settings.hiddenPins.includes(roomId) onTriggered: TimelineManager.openInviteUsers(roomId)
clip: true
palette: Nheko.colors
ScrollBar.horizontal.visible: false
ListView {
spacing: Nheko.paddingSmall
model: room ? room.pinnedMessages : undefined
delegate: RowLayout {
required property string modelData
width: ListView.view.width
height: implicitHeight
Reply {
property var e: room ? room.getDump(modelData, "") : {}
Layout.fillWidth: true
Layout.preferredHeight: height
userColor: TimelineManager.userColor(e.userId, Nheko.colors.window)
blurhash: e.blurhash ?? ""
body: e.body ?? ""
formattedBody: e.formattedBody ?? ""
eventId: e.eventId ?? ""
filename: e.filename ?? ""
filesize: e.filesize ?? ""
proportionalHeight: e.proportionalHeight ?? 1
type: e.type ?? MtxEvent.UnknownMessage
typeString: e.typeString ?? ""
url: e.url ?? ""
originalWidth: e.originalWidth ?? 0
isOnlyEmoji: e.isOnlyEmoji ?? false
userId: e.userId ?? ""
userName: e.userName ?? ""
encryptionError: e.encryptionError ?? ""
} }
ImageButton { Platform.MenuItem {
id: deletePinButton text: qsTr("Members")
onTriggered: TimelineManager.openRoomMembers(room)
Layout.preferredHeight: 16
Layout.preferredWidth: 16
Layout.alignment: Qt.AlignTop | Qt.AlignLeft
visible: room.permissions.canChange(MtxEvent.PinnedEvents)
hoverEnabled: true
image: ":/icons/icons/ui/dismiss.svg"
ToolTip.visible: hovered
ToolTip.text: qsTr("Unpin")
onClicked: room.unpin(modelData)
} }
Platform.MenuItem {
text: qsTr("Leave room")
onTriggered: TimelineManager.openLeaveRoomDialog(roomId)
}
Platform.MenuItem {
text: qsTr("Settings")
onTriggered: TimelineManager.openRoomSettings(roomId)
}
} }
}
ScrollHelper { ScrollView {
flickable: parent id: pinnedMessages
anchors.fill: parent
enabled: !Settings.mobileMode Layout.row: 2
Layout.column: 2
Layout.columnSpan: 3
Layout.fillWidth: true
Layout.preferredHeight: Math.min(contentHeight, Nheko.avatarSize * 4)
visible: !!room && room.pinnedMessages.length > 0 && !Settings.hiddenPins.includes(roomId)
clip: true
palette: Nheko.colors
ScrollBar.horizontal.visible: false
ListView {
spacing: Nheko.paddingSmall
model: room ? room.pinnedMessages : undefined
delegate: RowLayout {
required property string modelData
width: ListView.view.width
height: implicitHeight
Reply {
property var e: room ? room.getDump(modelData, "") : {}
Layout.fillWidth: true
Layout.preferredHeight: height
userColor: TimelineManager.userColor(e.userId, Nheko.colors.window)
blurhash: e.blurhash ?? ""
body: e.body ?? ""
formattedBody: e.formattedBody ?? ""
eventId: e.eventId ?? ""
filename: e.filename ?? ""
filesize: e.filesize ?? ""
proportionalHeight: e.proportionalHeight ?? 1
type: e.type ?? MtxEvent.UnknownMessage
typeString: e.typeString ?? ""
url: e.url ?? ""
originalWidth: e.originalWidth ?? 0
isOnlyEmoji: e.isOnlyEmoji ?? false
userId: e.userId ?? ""
userName: e.userName ?? ""
encryptionError: e.encryptionError ?? ""
}
ImageButton {
id: deletePinButton
Layout.preferredHeight: 16
Layout.preferredWidth: 16
Layout.alignment: Qt.AlignTop | Qt.AlignLeft
visible: room.permissions.canChange(MtxEvent.PinnedEvents)
hoverEnabled: true
image: ":/icons/icons/ui/dismiss.svg"
ToolTip.visible: hovered
ToolTip.text: qsTr("Unpin")
onClicked: room.unpin(modelData)
}
}
ScrollHelper {
flickable: parent
anchors.fill: parent
enabled: !Settings.mobileMode
}
} }
} }
} }
}
CursorShape { CursorShape {
anchors.fill: parent anchors.fill: parent
anchors.bottomMargin: pinnedMessages.visible ? pinnedMessages.height : 0 anchors.bottomMargin: pinnedMessages.visible ? pinnedMessages.height : 0
cursorShape: Qt.PointingHandCursor cursorShape: Qt.PointingHandCursor
}
} }
} }