summary refs log tree commit diff
path: root/resources/qml/delegates
diff options
context:
space:
mode:
authorNicolas Werner <nicolas.werner@hotmail.de>2023-08-13 11:30:41 +0200
committerNicolas Werner <nicolas.werner@hotmail.de>2023-08-25 19:03:16 +0200
commit2360dfd80ae8991c557c9c7d9474c528c00fdaa6 (patch)
tree70a357307798038525871a5e12e422babc342ccd /resources/qml/delegates
parentGet rid of redundant constructions and make room implicit (diff)
downloadnheko-2360dfd80ae8991c557c9c7d9474c528c00fdaa6.tar.xz
Remaining events apart from verification
Diffstat (limited to 'resources/qml/delegates')
-rw-r--r--resources/qml/delegates/Encrypted.qml33
-rw-r--r--resources/qml/delegates/EncryptionEnabled.qml47
-rw-r--r--resources/qml/delegates/FileMessage.qml36
-rw-r--r--resources/qml/delegates/Redacted.qml1
4 files changed, 66 insertions, 51 deletions
diff --git a/resources/qml/delegates/Encrypted.qml b/resources/qml/delegates/Encrypted.qml
index fdfe958e..7aeeb28a 100644
--- a/resources/qml/delegates/Encrypted.qml
+++ b/resources/qml/delegates/Encrypted.qml
@@ -8,37 +8,34 @@ import QtQuick.Controls 2.15
 import QtQuick.Layouts 1.15
 import im.nheko 1.0
 
-Rectangle {
+Control {
     id: r
 
     required property int encryptionError
     required property string eventId
 
-    radius: fontMetrics.lineSpacing / 2 + Nheko.paddingMedium
-    width: parent.width? parent.width : 0
-    implicitWidth: encryptedText.implicitWidth+24+Nheko.paddingMedium*3 // Column doesn't provide a useful implicitWidth, should be replaced by ColumnLayout
-    height: contents.implicitHeight + Nheko.paddingMedium * 2
-    color: palette.alternateBase
+    padding: Nheko.paddingMedium
+    implicitHeight: contents.implicitHeight + Nheko.paddingMedium * 2
+    Layout.maximumWidth: contents.Layout.maximumWidth + padding * 2
+    Layout.fillWidth: true
 
-    RowLayout {
+    contentItem: RowLayout {
         id: contents
 
-        anchors.fill: parent
-        anchors.margins: Nheko.paddingMedium
         spacing: Nheko.paddingMedium
 
         Image {
             source: "image://colorimage/:/icons/icons/ui/shield-filled-cross.svg?" + Nheko.theme.error
             Layout.alignment: Qt.AlignVCenter
-            width: 24
-            height: width
+            Layout.preferredWidth: 24
+            Layout.preferredHeight: 24
         }
 
-        Column {
+        ColumnLayout {
             spacing: Nheko.paddingSmall
             Layout.fillWidth: true
 
-            MatrixText {
+            Label {
                 id: encryptedText
                 text: {
                     switch (encryptionError) {
@@ -58,8 +55,11 @@ Rectangle {
                         return qsTr("Unknown decryption error");
                     }
                 }
+                textFormat: Text.PlainText
+                wrapMode: Label.WordWrap
                 color: palette.text
-                width: parent.width
+                Layout.fillWidth: true
+                Layout.maximumWidth: implicitWidth + 1
             }
 
             Button {
@@ -72,4 +72,9 @@ Rectangle {
 
     }
 
+    background: Rectangle {
+        color: palette.alternateBase
+        radius: fontMetrics.lineSpacing / 2 + 2 * Nheko.paddingMedium
+        visible: !Settings.bubbles // the bubble in a bubble looks odd
+    }
 }
diff --git a/resources/qml/delegates/EncryptionEnabled.qml b/resources/qml/delegates/EncryptionEnabled.qml
index 0e2b7fc0..40894543 100644
--- a/resources/qml/delegates/EncryptionEnabled.qml
+++ b/resources/qml/delegates/EncryptionEnabled.qml
@@ -3,27 +3,24 @@
 // SPDX-License-Identifier: GPL-3.0-or-later
 
 import ".."
-import QtQuick 2.15
-import QtQuick.Layouts 1.15
-import im.nheko 1.0
+import QtQuick
+import QtQuick.Controls
+import QtQuick.Layouts
+import im.nheko
 
-Rectangle {
+Control {
     id: r
 
-    required property string username
+    required property string userName
 
-    radius: fontMetrics.lineSpacing / 2 + Nheko.paddingMedium
-    width: parent.width ? Math.min(parent.width, 700) : 0
-    height: contents.implicitHeight + Nheko.paddingMedium * 2
-    color: palette.alternateBase
-    border.color: Nheko.theme.green
-    border.width: 2
+    padding: Nheko.paddingMedium
+    //implicitHeight: contents.implicitHeight + padd * 2
+    Layout.maximumWidth: contents.Layout.maximumWidth + padding * 2
+    Layout.fillWidth: true
 
-    RowLayout {
+    contentItem: RowLayout {
         id: contents
 
-        anchors.fill: parent
-        anchors.margins: Nheko.paddingMedium
         spacing: Nheko.paddingMedium
 
         Image {
@@ -33,26 +30,36 @@ Rectangle {
             Layout.preferredHeight: 24
         }
 
-        Column {
+        ColumnLayout {
             spacing: Nheko.paddingSmall
             Layout.fillWidth: true
 
             MatrixText {
-                text: qsTr("%1 enabled end-to-end encryption").arg(r.username)
+                text: qsTr("%1 enabled end-to-end encryption").arg(r.userName)
                 font.bold: true
                 font.pointSize: 14
                 color: palette.text
-                width: parent.width
+                Layout.fillWidth: true
+                Layout.maximumWidth: implicitWidth + 1
             }
 
-            MatrixText {
+            Label {
                 text: qsTr("Encryption keeps your messages safe by only allowing the people you sent the message to to read it. For extra security, if you want to make sure you are talking to the right people, you can verify them in real life.")
-                color: palette.text
-                width: parent.width
+                textFormat: Text.PlainText
+                wrapMode: Label.WordWrap
+                Layout.fillWidth: true
+                Layout.maximumWidth: implicitWidth + 1
             }
 
         }
 
     }
 
+    background: Rectangle {
+        radius: fontMetrics.lineSpacing / 2 + Nheko.paddingMedium
+        height: contents.implicitHeight + Nheko.paddingMedium * 2
+        color: palette.alternateBase
+        border.color: Nheko.theme.green
+        border.width: 2
+    }
 }
diff --git a/resources/qml/delegates/FileMessage.qml b/resources/qml/delegates/FileMessage.qml
index 82b82c1b..9f350123 100644
--- a/resources/qml/delegates/FileMessage.qml
+++ b/resources/qml/delegates/FileMessage.qml
@@ -2,26 +2,30 @@
 //
 // SPDX-License-Identifier: GPL-3.0-or-later
 
-import QtQuick 2.12
-import QtQuick.Layouts 1.2
-import im.nheko 1.0
+import QtQuick
+import QtQuick.Layouts
+import QtQuick.Controls
+import im.nheko
+
+Control {
+    id: evRoot
 
-Item {
     required property string eventId
     required property string filename
     required property string filesize
 
-    height: rowa.height + (Settings.bubbles? 16: 24)
-    implicitWidth: rowa.implicitWidth + metadataWidth
-    property int metadataWidth
-    property bool fitsMetadata: true
+    padding: Settings.bubbles? 8 : 12
+    //Layout.preferredHeight: rowa.implicitHeight + padding
+    //Layout.maximumWidth: rowa.Layout.maximumWidth + metadataWidth + padding
+    property int metadataWidth: 0
+    property bool fitsMetadata: false
+
+    Layout.maximumWidth: rowa.Layout.maximumWidth + padding * 2
 
-    RowLayout {
+    contentItem: RowLayout {
         id: rowa
 
-        anchors.centerIn: parent
-        width: parent.width - (Settings.bubbles? 16 : 24)
-        spacing: 15
+        spacing: 16
 
         Rectangle {
             id: button
@@ -63,6 +67,7 @@ Item {
                 id: filename_
 
                 Layout.fillWidth: true
+                Layout.maximumWidth: implicitWidth + 1
                 text: filename
                 textFormat: Text.PlainText
                 elide: Text.ElideRight
@@ -73,6 +78,7 @@ Item {
                 id: filesize_
 
                 Layout.fillWidth: true
+                Layout.maximumWidth: implicitWidth + 1
                 text: filesize
                 textFormat: Text.PlainText
                 elide: Text.ElideRight
@@ -83,11 +89,9 @@ Item {
 
     }
 
-    Rectangle {
+    background: Rectangle {
         color: palette.alternateBase
-        z: -1
-        radius: 10
-        anchors.fill: parent
+        radius: fontMetrics.lineSpacing / 2 + 2 * Nheko.paddingSmall
         visible: !Settings.bubbles // the bubble in a bubble looks odd
     }
 
diff --git a/resources/qml/delegates/Redacted.qml b/resources/qml/delegates/Redacted.qml
index 1bb3209f..3c496f08 100644
--- a/resources/qml/delegates/Redacted.qml
+++ b/resources/qml/delegates/Redacted.qml
@@ -36,7 +36,6 @@ Control {
             property var redactedPair: room.formatRedactedEvent(msgRoot.eventId)
             text: redactedPair["first"]
             wrapMode: Label.WordWrap
-            color: palette.text
 
             ToolTip.text: redactedPair["second"]
             ToolTip.visible: hh.hovered