summary refs log tree commit diff
path: root/resources/qml/UploadBox.qml
diff options
context:
space:
mode:
authorNicolas Werner <nicolas.werner@hotmail.de>2023-06-02 01:45:24 +0200
committerNicolas Werner <nicolas.werner@hotmail.de>2023-06-08 22:32:08 +0200
commit5aee8d609a3fcca63bb9a0f983a77b45eebfefe7 (patch)
tree1f270d525e4e5b5db381d19675467620593368cd /resources/qml/UploadBox.qml
parentlint (diff)
downloadnheko-5aee8d609a3fcca63bb9a0f983a77b45eebfefe7.tar.xz
Format qml
Diffstat (limited to 'resources/qml/UploadBox.qml')
-rw-r--r--resources/qml/UploadBox.qml67
1 files changed, 35 insertions, 32 deletions
diff --git a/resources/qml/UploadBox.qml b/resources/qml/UploadBox.qml
index ccec6131..54007163 100644
--- a/resources/qml/UploadBox.qml
+++ b/resources/qml/UploadBox.qml
@@ -4,7 +4,6 @@
 
 import "./components"
 import "./ui"
-
 import QtQuick 2.9
 import QtQuick.Controls 2.5
 import QtQuick.Layouts 1.3
@@ -12,31 +11,33 @@ import im.nheko 1.0
 
 Page {
     id: uploadPopup
-    visible: room && room.input.uploads.length > 0
-    Layout.preferredHeight: 200
-    clip: true
 
     Layout.fillWidth: true
-
+    Layout.preferredHeight: 200
+    clip: true
     padding: Nheko.paddingMedium
+    visible: room && room.input.uploads.length > 0
 
+    background: Rectangle {
+        color: palette.base
+    }
     contentItem: ListView {
         id: uploadsList
+
         anchors.horizontalCenter: parent.horizontalCenter
         boundsBehavior: Flickable.StopAtBounds
+        model: room ? room.input.uploads : undefined
+        orientation: ListView.Horizontal
+        spacing: Nheko.paddingMedium
+        width: Math.min(contentWidth, parent.availableWidth)
 
         ScrollBar.horizontal: ScrollBar {
             id: scr
-        }
-
-        orientation: ListView.Horizontal
-        width: Math.min(contentWidth, parent.availableWidth)
-        model: room ? room.input.uploads : undefined
-        spacing: Nheko.paddingMedium
 
+        }
         delegate: Pane {
+            height: uploadPopup.availableHeight - buttons.height - (scr.visible ? scr.height : 0)
             padding: Nheko.paddingSmall
-            height: uploadPopup.availableHeight - buttons.height - (scr.visible? scr.height : 0)
             width: uploadPopup.availableHeight - buttons.height
 
             background: Rectangle {
@@ -45,46 +46,48 @@ Page {
             }
             contentItem: ColumnLayout {
                 Image {
+                    property string typeStr: switch (modelData.mediaType) {
+                    case MediaUpload.Video:
+                        return "video-file";
+                    case MediaUpload.Audio:
+                        return "music";
+                    case MediaUpload.Image:
+                        return "image";
+                    default:
+                        return "zip";
+                    }
+
                     Layout.fillHeight: true
                     Layout.fillWidth: true
-
-                    sourceSize.height: parent.availableHeight - namefield.height
-                    sourceSize.width: parent.availableWidth
                     fillMode: Image.PreserveAspectFit
-                    smooth: true
                     mipmap: true
-
-                    property string typeStr: switch(modelData.mediaType) {
-                        case MediaUpload.Video: return "video-file";
-                        case MediaUpload.Audio: return "music";
-                        case MediaUpload.Image: return "image";
-                        default: return "zip";
-                    }
-                    source: (modelData.thumbnail != "") ? modelData.thumbnail : ("image://colorimage/:/icons/icons/ui/"+typeStr+".svg?" + palette.buttonText)
+                    smooth: true
+                    source: (modelData.thumbnail != "") ? modelData.thumbnail : ("image://colorimage/:/icons/icons/ui/" + typeStr + ".svg?" + palette.buttonText)
+                    sourceSize.height: parent.availableHeight - namefield.height
+                    sourceSize.width: parent.availableWidth
                 }
                 MatrixTextField {
                     id: namefield
+
                     Layout.fillWidth: true
                     text: modelData.filename
+
                     onTextEdited: modelData.filename = text
                 }
             }
         }
     }
-
     footer: DialogButtonBox {
         id: buttons
 
         standardButtons: DialogButtonBox.Cancel
-        Button {
-            text: qsTr("Upload %n file(s)", "", (room ? room.input.uploads.length : 0))
-            DialogButtonBox.buttonRole: DialogButtonBox.AcceptRole
-        }
+
         onAccepted: room.input.acceptUploads()
         onRejected: room.input.declineUploads()
-    }
 
-    background: Rectangle {
-        color: palette.base
+        Button {
+            DialogButtonBox.buttonRole: DialogButtonBox.AcceptRole
+            text: qsTr("Upload %n file(s)", "", (room ? room.input.uploads.length : 0))
+        }
     }
 }