summary refs log tree commit diff
path: root/resources
diff options
context:
space:
mode:
authorDeepBlueV7.X <nicolas.werner@hotmail.de>2020-09-25 19:29:21 +0200
committerGitHub <noreply@github.com>2020-09-25 19:29:21 +0200
commit5cce5b9999bd55d7b001ae6f65121bda105eb5a7 (patch)
tree27427ca1f640d64f6609d26638d0c88711e63188 /resources
parentTranslated using Weblate (French) (diff)
parentAllow button colors override (diff)
downloadnheko-5cce5b9999bd55d7b001ae6f65121bda105eb5a7.tar.xz
Merge pull request #289 from trilene/master
Port ActiveCallBar to Qml
Diffstat (limited to 'resources')
-rw-r--r--resources/qml/ActiveCallBar.qml111
-rw-r--r--resources/qml/Avatar.qml2
-rw-r--r--resources/qml/ImageButton.qml4
-rw-r--r--resources/qml/TimelineView.qml5
-rw-r--r--resources/res.qrc1
5 files changed, 121 insertions, 2 deletions
diff --git a/resources/qml/ActiveCallBar.qml b/resources/qml/ActiveCallBar.qml
new file mode 100644

index 00000000..8d837c29 --- /dev/null +++ b/resources/qml/ActiveCallBar.qml
@@ -0,0 +1,111 @@ +import QtQuick 2.9 +import QtQuick.Controls 2.3 +import QtQuick.Layouts 1.2 + +import im.nheko 1.0 + +Rectangle { + id: activeCallBar + visible: timelineManager.callState != WebRTCState.DISCONNECTED + color: "#2ECC71" + implicitHeight: rowLayout.height + 8 + + RowLayout { + id: rowLayout + anchors.left: parent.left + anchors.right: parent.right + anchors.verticalCenter: parent.verticalCenter + anchors.leftMargin: 8 + + Avatar { + width: avatarSize + height: avatarSize + + url: timelineManager.callPartyAvatarUrl.replace("mxc://", "image://MxcImage/") + displayName: timelineManager.callPartyName + } + + Label { + font.pointSize: fontMetrics.font.pointSize * 1.1 + text: " " + timelineManager.callPartyName + " " + } + + Image { + Layout.preferredWidth: 24 + Layout.preferredHeight: 24 + source: "qrc:/icons/icons/ui/place-call.png" + } + + Label { + id: callStateLabel + font.pointSize: fontMetrics.font.pointSize * 1.1 + } + + Connections { + target: timelineManager + function onCallStateChanged(state) { + switch (state) { + case WebRTCState.INITIATING: + callStateLabel.text = qsTr("Initiating...") + break; + case WebRTCState.OFFERSENT: + callStateLabel.text = qsTr("Calling...") + break; + case WebRTCState.CONNECTING: + callStateLabel.text = qsTr("Connecting...") + break; + case WebRTCState.CONNECTED: + callStateLabel.text = "00:00" + var d = new Date() + callTimer.startTime = Math.floor(d.getTime() / 1000) + break; + case WebRTCState.DISCONNECTED: + callStateLabel.text = "" + } + } + } + + Timer { + id: callTimer + property int startTime + interval: 1000 + running: timelineManager.callState == WebRTCState.CONNECTED + repeat: true + onTriggered: { + var d = new Date() + let seconds = Math.floor(d.getTime() / 1000 - startTime) + let s = Math.floor(seconds % 60) + let m = Math.floor(seconds / 60) % 60 + let h = Math.floor(seconds / 3600) + callStateLabel.text = (h ? (pad(h) + ":") : "") + pad(m) + ":" + pad(s) + } + + function pad(n) { + return (n < 10) ? ("0" + n) : n + } + } + + Item { + Layout.fillWidth: true + } + + ImageButton { + width: 24 + height: 24 + buttonTextColor: "#000000" + image: timelineManager.isMicMuted ? + ":/icons/icons/ui/microphone-unmute.png" : + ":/icons/icons/ui/microphone-mute.png" + + hoverEnabled: true + ToolTip.visible: hovered + ToolTip.text: timelineManager.isMicMuted ? qsTr("Unmute Mic") : qsTr("Mute Mic") + + onClicked: timelineManager.toggleMicMute() + } + + Item { + implicitWidth: 16 + } + } +} diff --git a/resources/qml/Avatar.qml b/resources/qml/Avatar.qml
index a3943806..c030c843 100644 --- a/resources/qml/Avatar.qml +++ b/resources/qml/Avatar.qml
@@ -14,7 +14,7 @@ Rectangle { Label { anchors.fill: parent - text: timelineManager.escapeEmoji(String.fromCodePoint(displayName.codePointAt(0))) + text: timelineManager.escapeEmoji(displayName ? String.fromCodePoint(displayName.codePointAt(0)) : "") textFormat: Text.RichText font.pixelSize: avatar.height/2 verticalAlignment: Text.AlignVCenter diff --git a/resources/qml/ImageButton.qml b/resources/qml/ImageButton.qml
index dd67d597..54399ae7 100644 --- a/resources/qml/ImageButton.qml +++ b/resources/qml/ImageButton.qml
@@ -3,6 +3,8 @@ import QtQuick.Controls 2.3 AbstractButton { property string image: undefined + property color highlightColor: colors.highlight + property color buttonTextColor: colors.buttonText width: 16 height: 16 id: button @@ -11,7 +13,7 @@ AbstractButton { id: buttonImg // Workaround, can't get icon.source working for now... anchors.fill: parent - source: "image://colorimage/" + image + "?" + (button.hovered ? colors.highlight : colors.buttonText) + source: "image://colorimage/" + image + "?" + (button.hovered ? highlightColor : buttonTextColor) } MouseArea diff --git a/resources/qml/TimelineView.qml b/resources/qml/TimelineView.qml
index de818cd9..07c5e1a4 100644 --- a/resources/qml/TimelineView.qml +++ b/resources/qml/TimelineView.qml
@@ -497,6 +497,11 @@ Page { } } } + + ActiveCallBar { + Layout.fillWidth: true + z: 3 + } } } } diff --git a/resources/res.qrc b/resources/res.qrc
index b245f48f..63a40431 100644 --- a/resources/res.qrc +++ b/resources/res.qrc
@@ -121,6 +121,7 @@ <file>qtquickcontrols2.conf</file> <file>qml/TimelineView.qml</file> + <file>qml/ActiveCallBar.qml</file> <file>qml/Avatar.qml</file> <file>qml/ImageButton.qml</file> <file>qml/MatrixText.qml</file>