diff --git a/plasmoid/contents/ui/PulleyItem.qml b/plasmoid/contents/ui/PulleyItem.qml new file mode 100644 --- /dev/null +++ b/plasmoid/contents/ui/PulleyItem.qml @@ -0,0 +1,159 @@ +import QtQuick 2.9 +import org.kde.plasma.core 2.0 as PlasmaCore +import org.kde.plasma.components 2.0 as PlasmaComponents +import org.kde.plasma.extras 2.0 as PlasmaExtras +import QtGraphicalEffects 1.0 + +Item { + id: pulleyFrame + anchors.fill: parent + anchors.topMargin: units.gridUnit * 0.05 + anchors.bottomMargin: units.gridUnit * 0.02 + property bool opened: state === "PulleyExpanded" + property bool closed: state === "PulleyClosed" + property bool _isVisible + property var barColor + signal pulleyExpanded() + signal pulleyClosed() + + function open() { + pulleyFrame.state = "PulleyExpanded"; + pulleyExpanded(); + } + + function close() { + pulleyFrame.state = "PulleyClosed"; + pulleyListView.positionViewAtBeginning() + pulleyClosed(); + } + + states: [ + State { + name: "PulleyExpanded" + PropertyChanges { target: pulleyMenu; height: pulleyFrame.height - pulleyIconBar.height; } + PropertyChanges { target: pulleyListView; interactive: true; } + PropertyChanges { target: menudrawIcon; source: "go-down";} + }, + State { + name: "PulleyClosed" + PropertyChanges { target: pulleyMenu; height: 0; } + PropertyChanges { target: pulleyListView; interactive: false; } + PropertyChanges { target: menudrawIcon; source: "go-up";} + } + ] + + + transitions: [ + Transition { + to: "*" + NumberAnimation { target: pulleyMenu; properties: "height"; duration: 450; easing.type: Easing.OutCubic; } + } + ] + + Rectangle { + id: pulleyIconBar + anchors.bottom: pulleyMenu.top + anchors.bottomMargin: 4 + height: units.gridUnit * 0.40 + color: barColor + width: cbwidth + PlasmaCore.IconItem { + id: menudrawIcon + visible: _isVisible + anchors.centerIn: parent + source: "go-up" + width: units.gridUnit * 1.25 + height: units.gridUnit * 1.25 + } + + MouseArea{ + anchors.fill: parent + propagateComposedEvents: true + onClicked: { + if (pulleyFrame.opened) { + pulleyFrame.close(); + } else { + pulleyFrame.open(); + } + } + } + } + + Rectangle { + id: pulleyMenu + width: parent.width + color: PlasmaCore.ColorScope.backgroundColor + anchors.bottom: parent.bottom + height: 0 + + ListView { + id: pulleyListView + width: parent.width + anchors.top: parent.top + anchors.bottom: pulleyEndArea.bottom + model: SkillModel{} + clip: true + interactive: false; + spacing: 5 + delegate: + Rectangle { + id: pulleyDelegateListBg + height: units.gridUnit * 2.5 + color: Qt.darker(PlasmaCore.ColorScope.backgroundColor, 1.2) + radius: 4 + anchors.left: parent.left + anchors.right: parent.right + anchors.leftMargin: units.gridUnit * 0.50 + anchors.rightMargin: units.gridUnit * 0.50 + layer.enabled: true + layer.effect: DropShadow { + horizontalOffset: 0 + verticalOffset: 1 + radius: 10 + samples: 32 + spread: 0.1 + color: Qt.rgba(0, 0, 0, 0.3) + } + + PlasmaComponents.Label { + id: pulleyDelegateListLabel + anchors.centerIn: parent + text: CommandList.get(0).Commands + color: PlasmaCore.ColorScope.textColor + + MouseArea { + anchors.fill: parent + hoverEnabled: true + propagateComposedEvents: true + + onEntered: { + pulleyDelegateListBg.color = theme.linkColor + } + onExited: { + pulleyDelegateListBg.color = Qt.darker(PlasmaCore.ColorScope.backgroundColor, 1.2) + } + onClicked: { + pulleyFrame.close(); + var genExampleQuery = CommandList.get(0).Commands; + var exampleQuery = genExampleQuery.toString().split(","); + var socketmessage = {}; + socketmessage.type = "recognizer_loop:utterance"; + socketmessage.data = {}; + socketmessage.data.utterances = [exampleQuery[1].toLowerCase()]; + socket.sendTextMessage(JSON.stringify(socketmessage)); + qinput.text = ""; + } + } + } + } + } + + Item { + id: pulleyEndArea + anchors.bottom: parent.bottom + anchors.bottomMargin: units.gridUnit * 1.22 + width: parent.width + height: units.gridUnit * 2.5 + } + } + } diff --git a/plasmoid/contents/ui/main.qml b/plasmoid/contents/ui/main.qml --- a/plasmoid/contents/ui/main.qml +++ b/plasmoid/contents/ui/main.qml @@ -430,7 +430,14 @@ doc.onreadystatechange = function() { if (doc.readyState === XMLHttpRequest.DONE) { var req = doc.responseText; + var checkNewsItem = JSON.parse(req) + if (checkNewsItem.totalResults == 0){ + globalcountrycode = "us" + fetchDashNews() + } + else { dashLmodel.append({"iType": "DashNews", "iObj": req}) + } } } } @@ -496,7 +503,12 @@ } else { convoLmodel.clear() - disclaimbox.visible = true + if(mycroftStatusCheckSocket._socketIsAlreadyActive == true){ + disclaimbox.visible = false + } + else { + disclaimbox.visible = true + } } } @@ -795,9 +807,11 @@ id: mycroftStatusCheckSocket url: innerset.wsurl active: true + property bool _socketIsAlreadyActive: false onStatusChanged: if (mycroftStatusCheckSocket.status == WebSocket.Open && socket.status == WebSocket.Closed) { socket.active = true + mycroftStatusCheckSocket._socketIsAlreadyActive = true disclaimbox.visible = false; mycroftstartservicebutton.checked = true statusId.text = i18n("Mycroft is ready") @@ -807,6 +821,7 @@ else if (mycroftStatusCheckSocket.status == WebSocket.Error) { mycroftstartservicebutton.checked = false + mycroftStatusCheckSocket._socketIsAlreadyActive = false statusId.text = i18n("Mycroft is disabled") statusId.color = theme.textColor statusId.visible = true @@ -1071,6 +1086,15 @@ } } + PulleyItem { + id: favlistPulley + visible: true + barColor: theme.linkColor + _isVisible: true + z: 900 + + onPulleyExpanded: {disclaimbox.visible = false} + } Disclaimer{ id: disclaimbox @@ -1465,10 +1489,13 @@ onCheckedChanged: { console.log(dashswitch.checked) if(dashswitch.checked){ + tabBar.currentTab = mycroftTab + disclaimbox.visible = false showDash("setVisible") } else if(!dashswitch.checked){ convoLmodel.clear() + disclaimbox.visible = true } }