Warning, /plasma/plasma-bigscreen/containments/homescreen/package/contents/ui/MycroftWindow.qml is written in an unsupported language. File is not indexed.
0001 /*
0002 SPDX-FileCopyrightText: 2019 Marco Martin <mart@kde.org>
0003 SPDX-FileCopyrightText: 2019 Aditya Mehra <aix.m@outlook.com>
0004
0005 SPDX-License-Identifier: GPL-2.0-or-later
0006 */
0007
0008 import QtQuick 2.14
0009 import QtQuick.Window 2.14
0010 import QtQuick.Layouts 1.14
0011 import QtQuick.Controls 2.14 as Controls
0012 import org.kde.kirigami 2.12 as Kirigami
0013 import org.kde.plasma.core 2.0 as PlasmaCore
0014 import Mycroft 1.0 as Mycroft
0015
0016 Window {
0017 id: window
0018 color: Qt.rgba(0, 0, 0, 0.8)
0019
0020 width: screen.availableGeometry.width
0021 height: screen.availableGeometry.height
0022
0023 Component.onCompleted: Mycroft.MycroftController.start()
0024
0025 function disconnectclose() {
0026 Mycroft.MycroftController.disconnectSocket();
0027 window.close();
0028 mycroftWindowLoader.active = false;
0029 }
0030
0031 Timer {
0032 interval: 10000
0033 running: Mycroft.MycroftController.status != Mycroft.MycroftController.Open
0034 onTriggered: {
0035 print("Trying to connect to Mycroft");
0036 Mycroft.MycroftController.start();
0037 }
0038 }
0039 onVisibleChanged: {
0040 skillView.open = visible;
0041 }
0042
0043 Mycroft.StatusIndicator {
0044 id: si
0045 z: 2
0046 anchors {
0047 right: parent.right
0048 top: parent.top
0049 margins: Kirigami.Units.largeSpacing
0050 topMargin: Kirigami.Units.largeSpacing + plasmoid.availableScreenRect.y
0051 }
0052 }
0053 Kirigami.Heading {
0054 id: inputQuery
0055 anchors.right: si.left
0056 anchors.rightMargin: Kirigami.Units.largeSpacing
0057 anchors.verticalCenter: si.verticalCenter
0058 level: 3
0059 opacity: 0
0060 onTextChanged: {
0061 opacity = 1;
0062 utteranceTimer.restart();
0063 }
0064 Timer {
0065 id: utteranceTimer
0066 interval: 8000
0067 onTriggered: {
0068 inputQuery.text = "";
0069 inputQuery.opacity = 0
0070 }
0071 }
0072 Behavior on opacity {
0073 OpacityAnimator {
0074 duration: Kirigami.units.longDuration
0075 easing.type: Easing.InOutQuad
0076 }
0077 }
0078
0079 Connections {
0080 target: Mycroft.MycroftController
0081 onIntentRecevied: {
0082 if(type == "recognizer_loop:utterance") {
0083 inputQuery.text = data.utterances[0]
0084 }
0085 }
0086
0087 onSkillTimeoutReceived: {
0088 if(skillView.currentItem.contentItem.skillId() == skillidleid) {
0089 window.close()
0090 }
0091 }
0092 }
0093 }
0094
0095 Mycroft.SkillView {
0096 id: skillView
0097 anchors.fill: parent
0098 open: false
0099 Keys.onEscapePressed: window.visible = false;
0100 KeyNavigation.up: closeButton
0101 activeSkills.blackList: plasmoid.nativeInterface.applicationListModel.voiceAppSkills
0102
0103 activeSkills.onBlacklistedSkillActivated: {
0104 plasmoid.nativeInterface.executeCommand("mycroft-gui-app --hideTextInput --skill=" + skillId);
0105 }
0106 // activeSkills.onSkillActivated: window.showMaximized();
0107 activeSkills.onActiveIndexChanged: {
0108 if (activeSkills.activeIndex > 0) {
0109 window.visible = false;
0110 }
0111 }
0112
0113 onOpenChanged: {
0114 if (open) {
0115 window.showMaximized();
0116 } else {
0117 window.visible = false;
0118 }
0119 }
0120
0121 Rectangle {
0122 id: closeButton
0123 anchors.top: parent.top
0124 anchors.left: parent.left
0125 width: PlasmaCore.Units.iconSizes.huge
0126 height: PlasmaCore.Units.iconSizes.huge
0127 opacity: focus ? 1 : 0
0128 color: focus ? Kirigami.Theme.highlightColor :"transparent"
0129
0130 onFocusChanged: {
0131 if(focus){
0132 skillView.currentItem.contentItem.focus = false;
0133 }
0134 }
0135
0136 Keys.onDownPressed: {
0137 skillView.currentItem.contentItem.forceActiveFocus()
0138 }
0139
0140 Kirigami.Icon {
0141 anchors.centerIn: parent
0142 width: PlasmaCore.Units.iconSizes.large
0143 height: PlasmaCore.Units.iconSizes.large
0144 source: "tab-close"
0145 }
0146
0147 Keys.onReturnPressed: {
0148 window.visible = false;
0149 }
0150
0151 MouseArea {
0152 anchors.fill: parent
0153 onClicked: {
0154 window.visible = false;
0155 }
0156 }
0157 }
0158 }
0159
0160 //FIXME: find a better way for timeouts
0161 //onActiveSkillClosed: open = false;
0162 /*
0163 topPadding: plasmoid.availableScreenRect.y
0164 bottomPadding: root.height - plasmoid.availableScreenRect.y - plasmoid.availableScreenRect.height
0165 leftPadding: plasmoid.availableScreenRect.x
0166 rightPadding: root.width - plasmoid.availableScreenRect.x - plasmoid.availableScreenRect.width
0167 */
0168 }