Warning, /system/mycroft-gui/application/RemoteStt.qml is written in an unsupported language. File is not indexed.

0001 import QtQuick 2.15
0002 import QtQuick.Layouts 1.15
0003 import QtQuick.Controls 2.15
0004 import org.kde.kirigami 2.19 as Kirigami
0005 import Mycroft 1.0 as Mycroft
0006 import Qt5Compat.GraphicalEffects
0007 
0008 Item {
0009     id: root
0010     anchors.fill: parent
0011     property alias record: audrectimer.running
0012 
0013     Timer {
0014         id: audrectimer
0015         interval: 10000
0016         running: false
0017         onRunningChanged: {
0018             if(running){
0019                 Mycroft.AudioRec.recordTStart()
0020                 numAnim.start()
0021             } else {
0022                 Mycroft.AudioRec.recordTStop()
0023                 numAnim.stop()
0024             }
0025         }
0026     }
0027 
0028     function sendAudioClip() {
0029         Mycroft.AudioRec.returnStream()
0030     }
0031 
0032     Connections {
0033         target: Mycroft.AudioRec
0034 
0035         function onMicAudioLevelChanged(micLevel) {
0036             animatedCircle.width = Kirigami.Units.iconSizes.large + (Kirigami.Units.iconSizes.smallMedium * micLevel)
0037         }
0038 
0039         function onRecordTStatus(recStatus) {
0040             switch(recStatus){
0041             case "Completed":
0042                 console.log("In Completed")
0043                 Mycroft.AudioRec.readStream()
0044                 sendAudioClip()
0045                 audioRecorder.close()
0046                 break;
0047             case "Error":
0048                 console.log("inError")
0049                 break;
0050             }
0051         }
0052     }
0053 
0054     ColumnLayout {
0055         id: closebar
0056         anchors.fill: parent
0057         spacing: 0
0058 
0059         Kirigami.Heading {
0060             id: lbl1
0061             text: "Listening"
0062             Kirigami.Theme.colorSet: nightSwitch.checked ? Kirigami.Theme.Complementary : Kirigami.Theme.View
0063             level: 2
0064             font.bold: true
0065             Layout.alignment: Qt.AlignTop | Qt.AlignHCenter
0066         }
0067 
0068         Kirigami.Separator {
0069             Layout.fillWidth: true
0070             Layout.preferredHeight: 1
0071             color: Kirigami.Theme.disabledTextColor
0072         }
0073 
0074         Item {
0075             Layout.fillHeight: true
0076             Layout.fillWidth: true
0077 
0078             Rectangle {
0079                 id: animatedCircle
0080                 anchors.centerIn: parent
0081                 width: Kirigami.Units.iconSizes.large
0082                 height: width
0083                 radius: 1000
0084                 color: Qt.rgba(Kirigami.Theme.linkColor.r, Kirigami.Theme.linkColor.g, Kirigami.Theme.linkColor.b, 0.7)
0085 
0086                 Image {
0087                     source: "images/microphone.svg"
0088                     anchors.centerIn: parent
0089                     width: Kirigami.Units.iconSizes.large
0090                     height: width
0091 
0092                 }
0093             }
0094         }
0095 
0096         Kirigami.Heading {
0097             Layout.fillWidth: true
0098             Layout.topMargin: Kirigami.Units.smallSpacing
0099             Layout.bottomMargin: Kirigami.Units.smallSpacing
0100             Layout.preferredHeight: paintedHeight
0101             Kirigami.Theme.colorSet: nightSwitch.checked ? Kirigami.Theme.Complementary : Kirigami.Theme.View
0102             wrapMode: Text.WordWrap
0103             maximumLineCount: 2
0104             level: 3
0105             horizontalAlignment: Text.AlignHCenter
0106             text: "Say something to Mycroft"
0107         }
0108 
0109         Item {
0110             Layout.fillWidth: true
0111             Layout.preferredHeight: Kirigami.Units.smallSpacing * 0.15
0112 
0113             ProgressBar {
0114                 id: bar
0115                 to: 100
0116                 from: 0
0117                 anchors.fill: parent
0118 
0119                 background: Rectangle {
0120                     implicitWidth: parent.width
0121                     implicitHeight: parent.height
0122                     color: Kirigami.Theme.disabledTextColor
0123                 }
0124 
0125                 contentItem: Item {
0126                     implicitWidth: parent.width
0127                     implicitHeight: parent.height
0128 
0129                     Rectangle {
0130                         width: bar.visualPosition * parent.width
0131                         height: parent.height
0132                         radius: 2
0133                         gradient: Gradient {
0134                             GradientStop { position: 0.0; color: Kirigami.Theme.linkColor }
0135                             GradientStop { position: 1.0; color: Kirigami.Theme.linkColor }
0136                         }
0137                     }
0138                 }
0139 
0140                 NumberAnimation {
0141                     id: numAnim
0142                     target: bar
0143                     property: "value"
0144                     from: 0
0145                     to: 100
0146                     duration: 10000
0147                 }
0148             }
0149         }
0150 
0151         Rectangle {
0152             Kirigami.Theme.colorSet: nightSwitch.checked ? Kirigami.Theme.Complementary : Kirigami.Theme.View
0153             color: Kirigami.Theme.hoverColor
0154             Layout.fillWidth: true
0155             Layout.topMargin: Kirigami.Units.smallSpacing
0156             Layout.preferredHeight: Kirigami.Units.gridUnit * 1.5
0157 
0158             Kirigami.Heading {
0159                 level: 2
0160                 text: "Close"
0161                 anchors.centerIn: parent
0162                 anchors.margins: Kirigami.Units.largeSpacing
0163             }
0164 
0165             MouseArea {
0166                 anchors.fill: parent
0167                 onClicked: (mouse)=> { 
0168                     audioRecorder.close()
0169                 }
0170             }
0171         }
0172     }
0173 }
0174