Improve the layout and behaviour of topbar slightly

This commit is contained in:
Nicolas Werner 2021-11-11 04:29:50 +01:00
parent f9362c75cf
commit 8f3a6abfa2
No known key found for this signature in database
GPG key ID: C8D75E610773F2D9
3 changed files with 39 additions and 16 deletions

View file

@ -480,6 +480,8 @@ Page {
visible: !collapsed visible: !collapsed
Layout.alignment: Qt.AlignVCenter Layout.alignment: Qt.AlignVCenter
Layout.preferredWidth: fontMetrics.lineSpacing * 2
Layout.preferredHeight: fontMetrics.lineSpacing * 2
image: ":/icons/icons/ui/power-button-off.png" image: ":/icons/icons/ui/power-button-off.png"
ToolTip.visible: hovered ToolTip.visible: hovered
ToolTip.text: qsTr("Logout") ToolTip.text: qsTr("Logout")

View file

@ -3,8 +3,8 @@
// SPDX-License-Identifier: GPL-3.0-or-later // SPDX-License-Identifier: GPL-3.0-or-later
import Qt.labs.platform 1.1 as Platform import Qt.labs.platform 1.1 as Platform
import QtQuick 2.12 import QtQuick 2.15
import QtQuick.Controls 2.12 import QtQuick.Controls 2.15
import QtQuick.Layouts 1.2 import QtQuick.Layouts 1.2
import im.nheko 1.0 import im.nheko 1.0
@ -28,14 +28,27 @@ Rectangle {
TapHandler { TapHandler {
onSingleTapped: { onSingleTapped: {
if (room) if (room) {
let p = topBar.mapToItem(roomTopicC, eventPoint.position.x, eventPoint.position.y);
let link = roomTopicC.linkAt(p.x, p.y);
if (link) {
Nheko.openLink(link);
} else {
TimelineManager.openRoomSettings(room.roomId); TimelineManager.openRoomSettings(room.roomId);
}
}
eventPoint.accepted = true; eventPoint.accepted = true;
} }
gesturePolicy: TapHandler.ReleaseWithinBounds gesturePolicy: TapHandler.ReleaseWithinBounds
} }
HoverHandler {
grabPermissions: PointerHandler.TakeOverForbidden | PointerHandler.CanTakeOverFromAnything
//cursorShape: Qt.PointingHandCursor
}
GridLayout { GridLayout {
id: topLayout id: topLayout
@ -51,8 +64,8 @@ Rectangle {
Layout.row: 0 Layout.row: 0
Layout.rowSpan: 2 Layout.rowSpan: 2
Layout.alignment: Qt.AlignVCenter Layout.alignment: Qt.AlignVCenter
width: Nheko.avatarSize Layout.preferredHeight: Nheko.avatarSize - Nheko.paddingMedium
height: Nheko.avatarSize Layout.preferredWidth: Nheko.avatarSize - Nheko.paddingMedium
visible: showBackButton visible: showBackButton
image: ":/icons/icons/ui/angle-pointing-to-left.png" image: ":/icons/icons/ui/angle-pointing-to-left.png"
ToolTip.visible: hovered ToolTip.visible: hovered
@ -71,11 +84,7 @@ Rectangle {
roomid: roomId roomid: roomId
userid: isDirect ? directChatOtherUserId : "" userid: isDirect ? directChatOtherUserId : ""
displayName: roomName displayName: roomName
onClicked: { enabled: false
if (room)
TimelineManager.openRoomSettings(roomId);
}
} }
Label { Label {
@ -91,10 +100,13 @@ Rectangle {
} }
MatrixText { MatrixText {
id: roomTopicC
Layout.fillWidth: true Layout.fillWidth: true
Layout.column: 2 Layout.column: 2
Layout.row: 1 Layout.row: 1
Layout.maximumHeight: fontMetrics.lineSpacing * 2 // show 2 lines Layout.maximumHeight: fontMetrics.lineSpacing * 2 // show 2 lines
selectByMouse: false
enabled: false
clip: true clip: true
text: roomTopic text: roomTopic
} }
@ -103,6 +115,8 @@ Rectangle {
Layout.column: 3 Layout.column: 3
Layout.row: 0 Layout.row: 0
Layout.rowSpan: 2 Layout.rowSpan: 2
Layout.preferredHeight: Nheko.avatarSize - Nheko.paddingMedium
Layout.preferredWidth: Nheko.avatarSize - Nheko.paddingMedium
visible: isEncrypted visible: isEncrypted
encrypted: isEncrypted encrypted: isEncrypted
trust: trustlevel trust: trustlevel
@ -129,6 +143,8 @@ Rectangle {
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.preferredWidth: Nheko.avatarSize - Nheko.paddingMedium
image: ":/icons/icons/ui/vertical-ellipsis.png" image: ":/icons/icons/ui/vertical-ellipsis.png"
ToolTip.visible: hovered ToolTip.visible: hovered
ToolTip.text: qsTr("Room options") ToolTip.text: qsTr("Room options")
@ -164,4 +180,9 @@ Rectangle {
} }
CursorShape {
anchors.fill: parent
cursorShape: Qt.PointingHandCursor
}
} }

View file

@ -34,8 +34,8 @@ ApplicationWindow {
id: contentLayout1 id: contentLayout1
anchors.fill: parent anchors.fill: parent
anchors.margins: 10 anchors.margins: Nheko.paddingMedium
spacing: 10 spacing: Nheko.paddingMedium
Avatar { Avatar {
url: roomSettings.roomAvatarUrl.replace("mxc://", "image://MxcImage/") url: roomSettings.roomAvatarUrl.replace("mxc://", "image://MxcImage/")
@ -156,7 +156,7 @@ ApplicationWindow {
GridLayout { GridLayout {
columns: 2 columns: 2
rowSpacing: Nheko.paddingLarge rowSpacing: Nheko.paddingMedium
MatrixText { MatrixText {
text: qsTr("SETTINGS") text: qsTr("SETTINGS")
@ -278,7 +278,7 @@ ApplicationWindow {
MatrixText { MatrixText {
text: roomSettings.roomId text: roomSettings.roomId
font.pixelSize: fontMetrics.font.pixelSize * 1.2 font.pixelSize: Math.floor(fontMetrics.font.pixelSize * 0.8)
Layout.alignment: Qt.AlignRight Layout.alignment: Qt.AlignRight
} }
@ -288,7 +288,7 @@ ApplicationWindow {
MatrixText { MatrixText {
text: roomSettings.roomVersion text: roomSettings.roomVersion
font.pixelSize: fontMetrics.font.pixelSize * 1.2 font.pixelSize: fontMetrics.font.pixelSize
Layout.alignment: Qt.AlignRight Layout.alignment: Qt.AlignRight
} }