From 5658be52154e6a03aece3149aed6324f2ae221bc Mon Sep 17 00:00:00 2001 From: Nicolas Werner Date: Thu, 13 May 2021 11:32:20 +0200 Subject: [PATCH] Move global avatarSize property --- resources/qml/MessageView.qml | 6 +++--- resources/qml/TimelineRow.qml | 2 +- resources/qml/TimelineView.qml | 6 ------ resources/qml/TopBar.qml | 8 ++++---- resources/qml/voip/ActiveCallBar.qml | 4 ++-- resources/qml/voip/CallInviteBar.qml | 4 ++-- resources/qml/voip/PlaceCall.qml | 4 ++-- src/ui/NhekoGlobalObject.h | 3 +++ 8 files changed, 17 insertions(+), 20 deletions(-) diff --git a/resources/qml/MessageView.qml b/resources/qml/MessageView.qml index 0da1dff3..5af4e4de 100644 --- a/resources/qml/MessageView.qml +++ b/resources/qml/MessageView.qml @@ -240,8 +240,8 @@ ScrollView { Avatar { id: messageUserAvatar - width: avatarSize - height: avatarSize + width: Nheko.avatarSize + height: Nheko.avatarSize url: modelData ? chat.model.avatarUrl(modelData.userId).replace("mxc://", "image://MxcImage/") : "" displayName: modelData ? modelData.userName : "" userid: modelData ? modelData.userId : "" @@ -292,7 +292,7 @@ ScrollView { text: modelData ? TimelineManager.userStatus(modelData.userId) : "" textFormat: Text.PlainText elide: Text.ElideRight - width: chat.delegateMaxWidth - parent.spacing * 2 - userName.implicitWidth - avatarSize + width: chat.delegateMaxWidth - parent.spacing * 2 - userName.implicitWidth - Nheko.avatarSize font.italic: true } diff --git a/resources/qml/TimelineRow.qml b/resources/qml/TimelineRow.qml index bae3e5a3..3fa1ad8e 100644 --- a/resources/qml/TimelineRow.qml +++ b/resources/qml/TimelineRow.qml @@ -42,7 +42,7 @@ Item { id: row anchors.rightMargin: 1 - anchors.leftMargin: avatarSize + 16 + anchors.leftMargin: Nheko.avatarSize + 16 anchors.left: parent.left anchors.right: parent.right diff --git a/resources/qml/TimelineView.qml b/resources/qml/TimelineView.qml index 52847db0..a848cb49 100644 --- a/resources/qml/TimelineView.qml +++ b/resources/qml/TimelineView.qml @@ -18,12 +18,6 @@ import im.nheko.EmojiModel 1.0 Page { id: timelineRoot - property var systemInactive - readonly property int avatarSize: 40 - property real highlightHue: Nheko.colors.highlight.hslHue - property real highlightSat: Nheko.colors.highlight.hslSaturation - property real highlightLight: Nheko.colors.highlight.hslLightness - palette: Nheko.colors FontMetrics { diff --git a/resources/qml/TopBar.qml b/resources/qml/TopBar.qml index 4de126b6..d5bcb3a8 100644 --- a/resources/qml/TopBar.qml +++ b/resources/qml/TopBar.qml @@ -43,8 +43,8 @@ Rectangle { Layout.row: 0 Layout.rowSpan: 2 Layout.alignment: Qt.AlignVCenter - width: avatarSize - height: avatarSize + width: Nheko.avatarSize + height: Nheko.avatarSize visible: TimelineManager.isNarrowView image: ":/icons/icons/ui/angle-pointing-to-left.png" ToolTip.visible: hovered @@ -57,8 +57,8 @@ Rectangle { Layout.row: 0 Layout.rowSpan: 2 Layout.alignment: Qt.AlignVCenter - width: avatarSize - height: avatarSize + width: Nheko.avatarSize + height: Nheko.avatarSize url: room ? room.roomAvatarUrl.replace("mxc://", "image://MxcImage/") : "" displayName: room ? room.roomName : qsTr("No room selected") onClicked: TimelineManager.timeline.openRoomSettings() diff --git a/resources/qml/voip/ActiveCallBar.qml b/resources/qml/voip/ActiveCallBar.qml index 68d3bc4a..5798433a 100644 --- a/resources/qml/voip/ActiveCallBar.qml +++ b/resources/qml/voip/ActiveCallBar.qml @@ -31,8 +31,8 @@ Rectangle { anchors.leftMargin: 8 Avatar { - width: avatarSize - height: avatarSize + width: Nheko.avatarSize + height: Nheko.avatarSize url: CallManager.callPartyAvatarUrl.replace("mxc://", "image://MxcImage/") displayName: CallManager.callParty onClicked: TimelineManager.openImageOverlay(TimelineManager.timeline.avatarUrl(userid), TimelineManager.timeline.data.id) diff --git a/resources/qml/voip/CallInviteBar.qml b/resources/qml/voip/CallInviteBar.qml index c20e4fff..a169aca9 100644 --- a/resources/qml/voip/CallInviteBar.qml +++ b/resources/qml/voip/CallInviteBar.qml @@ -38,8 +38,8 @@ Rectangle { anchors.leftMargin: 8 Avatar { - width: avatarSize - height: avatarSize + width: Nheko.avatarSize + height: Nheko.avatarSize url: CallManager.callPartyAvatarUrl.replace("mxc://", "image://MxcImage/") displayName: CallManager.callParty onClicked: TimelineManager.openImageOverlay(TimelineManager.timeline.avatarUrl(userid), TimelineManager.timeline.data.id) diff --git a/resources/qml/voip/PlaceCall.qml b/resources/qml/voip/PlaceCall.qml index d3306099..7e2146cb 100644 --- a/resources/qml/voip/PlaceCall.qml +++ b/resources/qml/voip/PlaceCall.qml @@ -75,8 +75,8 @@ Popup { Avatar { Layout.rightMargin: cameraCombo.visible ? 16 : 64 - width: avatarSize - height: avatarSize + width: Nheko.avatarSize + height: Nheko.avatarSize url: TimelineManager.timeline.roomAvatarUrl.replace("mxc://", "image://MxcImage/") displayName: TimelineManager.timeline.roomName onClicked: TimelineManager.openImageOverlay(TimelineManager.timeline.avatarUrl(userid), TimelineManager.timeline.data.id) diff --git a/src/ui/NhekoGlobalObject.h b/src/ui/NhekoGlobalObject.h index 05a0c050..9875507e 100644 --- a/src/ui/NhekoGlobalObject.h +++ b/src/ui/NhekoGlobalObject.h @@ -13,6 +13,7 @@ class Nheko : public QObject Q_PROPERTY(QPalette colors READ colors NOTIFY colorsChanged) Q_PROPERTY(QPalette inactiveColors READ inactiveColors NOTIFY colorsChanged) + Q_PROPERTY(int avatarSize READ avatarSize CONSTANT) public: Nheko(); @@ -20,6 +21,8 @@ public: QPalette colors() const; QPalette inactiveColors() const; + int avatarSize() const { return 40; } + Q_INVOKABLE void openLink(QString link) const; signals: