summary refs log tree commit diff
path: root/resources
diff options
context:
space:
mode:
authorNicolas Werner <nicolas.werner@hotmail.de>2020-11-15 04:52:49 +0100
committerNicolas Werner <nicolas.werner@hotmail.de>2020-11-25 19:05:12 +0100
commita31d3d08165646738d6ae624ac4eff6971207058 (patch)
tree15e3140a8086a105d7bb38ebee6ed771eeaa06c3 /resources
parentBasic text input in qml (diff)
downloadnheko-a31d3d08165646738d6ae624ac4eff6971207058.tar.xz
Add file uploading
Diffstat (limited to 'resources')
-rw-r--r--resources/qml/ActiveCallBar.qml11
-rw-r--r--resources/qml/MessageInput.qml45
-rw-r--r--resources/qml/NhekoBusyIndicator.qml64
-rw-r--r--resources/qml/TimelineView.qml5
-rw-r--r--resources/qml/VideoCall.qml3
-rw-r--r--resources/res.qrc1
6 files changed, 108 insertions, 21 deletions
diff --git a/resources/qml/ActiveCallBar.qml b/resources/qml/ActiveCallBar.qml
index 282cac81..cbe36e6d 100644
--- a/resources/qml/ActiveCallBar.qml
+++ b/resources/qml/ActiveCallBar.qml
@@ -12,8 +12,11 @@ Rectangle {
 
     MouseArea {
         anchors.fill: parent
-        onClicked: if (TimelineManager.onVideoCall)
-                       stackLayout.currentIndex = stackLayout.currentIndex ? 0 : 1;
+        onClicked: {
+            if (TimelineManager.onVideoCall)
+                stackLayout.currentIndex = stackLayout.currentIndex ? 0 : 1;
+
+        }
     }
 
     RowLayout {
@@ -39,8 +42,7 @@ Rectangle {
         Image {
             Layout.preferredWidth: 24
             Layout.preferredHeight: 24
-            source: TimelineManager.onVideoCall ?
-                        "qrc:/icons/icons/ui/video-call.png" : "qrc:/icons/icons/ui/place-call.png"
+            source: TimelineManager.onVideoCall ? "qrc:/icons/icons/ui/video-call.png" : "qrc:/icons/icons/ui/place-call.png"
         }
 
         Label {
@@ -69,6 +71,7 @@ Rectangle {
                     callTimer.startTime = Math.floor(d.getTime() / 1000);
                     if (TimelineManager.onVideoCall)
                         stackLayout.currentIndex = 1;
+
                     break;
                 case WebRTCState.DISCONNECTED:
                     callStateLabel.text = "";
diff --git a/resources/qml/MessageInput.qml b/resources/qml/MessageInput.qml
index b76a44f3..a1220599 100644
--- a/resources/qml/MessageInput.qml
+++ b/resources/qml/MessageInput.qml
@@ -2,7 +2,6 @@ import QtQuick 2.9
 import QtQuick.Controls 2.3
 import QtQuick.Layouts 1.2
 import QtQuick.Window 2.2
-
 import im.nheko 1.0
 
 Rectangle {
@@ -36,6 +35,20 @@ Rectangle {
             image: ":/icons/icons/ui/paper-clip-outline.png"
             Layout.topMargin: 8
             Layout.bottomMargin: 8
+            onClicked: TimelineManager.timeline.input.openFileSelection()
+
+            Rectangle {
+                anchors.fill: parent
+                color: colors.window
+                visible: TimelineManager.timeline.input.uploading
+
+                NhekoBusyIndicator {
+                    anchors.fill: parent
+                    running: parent.visible
+                }
+
+            }
+
         }
 
         ScrollView {
@@ -52,27 +65,27 @@ Rectangle {
                 placeholderTextColor: colors.buttonText
                 color: colors.text
                 wrapMode: TextEdit.Wrap
-
                 onTextChanged: TimelineManager.timeline.input.updateState(selectionStart, selectionEnd, cursorPosition, text)
                 onCursorPositionChanged: TimelineManager.timeline.input.updateState(selectionStart, selectionEnd, cursorPosition, text)
                 onSelectionStartChanged: TimelineManager.timeline.input.updateState(selectionStart, selectionEnd, cursorPosition, text)
                 onSelectionEndChanged: TimelineManager.timeline.input.updateState(selectionStart, selectionEnd, cursorPosition, text)
-
-                Connections {
-                    target: TimelineManager.timeline.input
-                    function onInsertText(text_) { textArea.insert(textArea.cursorPosition, text_); }
-                }
-
                 Keys.onPressed: {
                     if (event.matches(StandardKey.Paste)) {
-                        TimelineManager.timeline.input.paste(false)
-                        event.accepted = true
+                        TimelineManager.timeline.input.paste(false);
+                        event.accepted = true;
+                    } else if (event.matches(StandardKey.InsertParagraphSeparator)) {
+                        TimelineManager.timeline.input.send();
+                        textArea.clear();
+                        event.accepted = true;
                     }
-                    else if (event.matches(StandardKey.InsertParagraphSeparator)) {
-                        TimelineManager.timeline.input.send()
-                        textArea.clear()
-                        event.accepted = true
+                }
+
+                Connections {
+                    function onInsertText(text_) {
+                        textArea.insert(textArea.cursorPosition, text_);
                     }
+
+                    target: TimelineManager.timeline.input
                 }
 
                 MouseArea {
@@ -110,6 +123,10 @@ Rectangle {
             Layout.topMargin: 8
             Layout.bottomMargin: 8
             Layout.rightMargin: 16
+            onClicked: {
+                TimelineManager.timeline.input.send();
+                textArea.clear();
+            }
         }
 
     }
diff --git a/resources/qml/NhekoBusyIndicator.qml b/resources/qml/NhekoBusyIndicator.qml
new file mode 100644
index 00000000..8889989a
--- /dev/null
+++ b/resources/qml/NhekoBusyIndicator.qml
@@ -0,0 +1,64 @@
+import QtQuick 2.9
+import QtQuick.Controls 2.3
+import QtQuick.Layouts 1.2
+
+BusyIndicator {
+    id: control
+
+    contentItem: Item {
+        implicitWidth: Math.min(parent.height, parent.width)
+        implicitHeight: implicitWidth
+
+        Item {
+            id: item
+
+            height: Math.min(parent.height, parent.width)
+            width: height
+            opacity: control.running ? 1 : 0
+
+            RotationAnimator {
+                target: item
+                running: control.visible && control.running
+                from: 0
+                to: 360
+                loops: Animation.Infinite
+                duration: 2000
+            }
+
+            Repeater {
+                id: repeater
+
+                model: 6
+
+                Rectangle {
+                    implicitWidth: radius * 2
+                    implicitHeight: radius * 2
+                    radius: item.height / 6
+                    color: colors.text
+                    opacity: (index + 2) / (repeater.count + 2)
+                    transform: [
+                        Translate {
+                            y: -Math.min(item.width, item.height) * 0.5 + item.height / 6
+                        },
+                        Rotation {
+                            angle: index / repeater.count * 360
+                            origin.x: item.height / 2
+                            origin.y: item.height / 2
+                        }
+                    ]
+                }
+
+            }
+
+            Behavior on opacity {
+                OpacityAnimator {
+                    duration: 250
+                }
+
+            }
+
+        }
+
+    }
+
+}
diff --git a/resources/qml/TimelineView.qml b/resources/qml/TimelineView.qml
index d85167af..5fce0846 100644
--- a/resources/qml/TimelineView.qml
+++ b/resources/qml/TimelineView.qml
@@ -192,13 +192,15 @@ Page {
 
                     StackLayout {
                         id: stackLayout
+
                         currentIndex: 0
 
                         Connections {
-                            target: TimelineManager
                             function onActiveTimelineChanged() {
                                 stackLayout.currentIndex = 0;
                             }
+
+                            target: TimelineManager
                         }
 
                         MessageView {
@@ -210,6 +212,7 @@ Page {
                             source: TimelineManager.onVideoCall ? "VideoCall.qml" : ""
                             onLoaded: TimelineManager.setVideoCallItem()
                         }
+
                     }
 
                     TypingIndicator {
diff --git a/resources/qml/VideoCall.qml b/resources/qml/VideoCall.qml
index 69fc1a2b..14408b6e 100644
--- a/resources/qml/VideoCall.qml
+++ b/resources/qml/VideoCall.qml
@@ -1,7 +1,6 @@
 import QtQuick 2.9
-
 import org.freedesktop.gstreamer.GLVideoItem 1.0
 
 GstGLVideoItem {
-	objectName: "videoCallItem"
+    objectName: "videoCallItem"
 }
diff --git a/resources/res.qrc b/resources/res.qrc
index efb9c907..02f31498 100644
--- a/resources/res.qrc
+++ b/resources/res.qrc
@@ -132,6 +132,7 @@
         <file>qml/Avatar.qml</file>
         <file>qml/ImageButton.qml</file>
         <file>qml/MatrixText.qml</file>
+        <file>qml/NhekoBusyIndicator.qml</file>
         <file>qml/StatusIndicator.qml</file>
         <file>qml/EncryptionIndicator.qml</file>
         <file>qml/Reactions.qml</file>