diff --git a/plasmoid/contents/ui/AudioFileDelegate.qml b/plasmoid/contents/ui/AudioFileDelegate.qml new file mode 100644 index 0000000..81323d7 --- /dev/null +++ b/plasmoid/contents/ui/AudioFileDelegate.qml @@ -0,0 +1,114 @@ +/* Copyright 2016 Aditya Mehra + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) version 3, or any + later version accepted by the membership of KDE e.V. (or its + successor approved by the membership of KDE e.V.), which shall + act as a proxy defined in Section 6 of version 3 of the license. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library. If not, see . +*/ + +import QtQuick 2.9 +import QtQml.Models 2.2 +import QtMultimedia 5.8 +import QtQuick.Controls 2.2 +import QtQuick.Layouts 1.3 +import org.kde.plasma.core 2.0 as PlasmaCore +import org.kde.plasma.plasmoid 2.0 +import org.kde.plasma.components 2.0 as PlasmaComponents + +Rectangle { + id: audioFileDelegateItm + implicitHeight: audioFileDelegateInner.height + color: Qt.darker(theme.backgroundColor, 1.2) + width: cbwidth + + Item { + id: audioFileDelegateInner + implicitHeight: Math.max(audioInnerInfoColumn.height, playAudioBtn.height + units.gridUnit * 1) + width: parent.width + + PlasmaCore.IconItem { + id: audioImgType + source: "new-audio-alarm" + anchors.left: parent.left + width: units.gridUnit * 1 + height: units.gridUnit * 1 + anchors.verticalCenter: parent.verticalCenter + } + + Item { + id: audioInnerInfoColumn + implicitHeight: audioFileName.implicitHeight + sprTrinnerAudio.height + audioFileLoc.implicitHeight + units.gridUnit * 0.50 + anchors.left: audioImgType.right + anchors.leftMargin: units.gridUnit * 0.30 + anchors.right: playAudioBtn.left + anchors.rightMargin: units.gridUnit * 0.30 + + PlasmaComponents.Label { + id: audioFileName + color: theme.textColor + anchors.left: parent.left + anchors.right: parent.right + anchors.top: parent.top + anchors.topMargin: units.gridUnit * 0.25 + wrapMode: Text.Wrap + height: units.gridUnit * 1 + + Component.onCompleted: { + var filterName = InputQuery.toString(); + audioFileName.text = filterName.match(/\/([^\/]+)\/?$/)[1] + } + } + + Rectangle { + id: sprTrinnerAudio + anchors.left: parent.left + anchors.right: parent.right + anchors.rightMargin: units.gridUnit * 1 + anchors.top: audioFileName.bottom + anchors.topMargin: units.gridUnit * 0.15 + color: theme.linkColor + height: units.gridUnit * 0.1 + } + + PlasmaComponents.Label { + id: audioFileLoc + color: theme.linkColor + font.pixelSize: 12 + anchors.left: parent.left + anchors.right: parent.right + anchors.top: sprTrinnerAudio.bottom + height: units.gridUnit * 1 + wrapMode: Text.Wrap + Component.onCompleted: { + audioFileLoc.text = "Location: " + InputQuery + "" + } + } + } + + PlasmaComponents.Button { + id: playAudioBtn + anchors.right: parent.right + anchors.rightMargin: units.gridUnit * 0.75 + anchors.verticalCenter: parent.verticalCenter + width: units.gridUnit * 3.5 + height: units.gridUnit * 3 + text: "Listen" + + onClicked: { + var audFile = Qt.resolvedUrl(InputQuery) + Qt.openUrlExternally(audFile) + } + } + } + } diff --git a/plasmoid/contents/ui/DocumentFileDelegate.qml b/plasmoid/contents/ui/DocumentFileDelegate.qml new file mode 100644 index 0000000..de02aba --- /dev/null +++ b/plasmoid/contents/ui/DocumentFileDelegate.qml @@ -0,0 +1,113 @@ +/* Copyright 2016 Aditya Mehra + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) version 3, or any + later version accepted by the membership of KDE e.V. (or its + successor approved by the membership of KDE e.V.), which shall + act as a proxy defined in Section 6 of version 3 of the license. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library. If not, see . +*/ + +import QtQuick 2.9 +import QtQml.Models 2.2 +import QtMultimedia 5.8 +import QtQuick.Controls 2.2 +import QtQuick.Layouts 1.3 +import org.kde.plasma.core 2.0 as PlasmaCore +import org.kde.plasma.plasmoid 2.0 +import org.kde.plasma.components 2.0 as PlasmaComponents + +Rectangle { + id: documentFileDelegateItm + implicitHeight: documentFileDelegateInner.height + color: Qt.darker(theme.backgroundColor, 1.2) + width: cbwidth + + Item { + id: documentFileDelegateInner + implicitHeight: Math.max(documentInnerInfoColumn.height, playDocumentBtn.height + units.gridUnit * 1) + width: parent.width + + PlasmaCore.IconItem { + id: documentImgType + source: "document-new" + anchors.left: parent.left + width: units.gridUnit * 1 + height: units.gridUnit * 1 + anchors.verticalCenter: parent.verticalCenter + } + + Item { + id: documentInnerInfoColumn + implicitHeight: documentFileName.implicitHeight + sprTrinnerDocument.height + documentFileLoc.implicitHeight + units.gridUnit * 0.50 + anchors.left: documentImgType.right + anchors.leftMargin: units.gridUnit * 0.30 + anchors.right: playDocumentBtn.left + anchors.rightMargin: units.gridUnit * 0.30 + + PlasmaComponents.Label { + id: documentFileName + color: theme.textColor + anchors.left: parent.left + anchors.right: parent.right + anchors.top: parent.top + anchors.topMargin: units.gridUnit * 0.25 + wrapMode: Text.Wrap + + Component.onCompleted: { + var filterName = InputQuery.toString(); + documentFileName.text = filterName.match(/\/([^\/]+)\/?$/)[1] + } + } + + Rectangle { + id: sprTrinnerDocument + anchors.left: parent.left + anchors.right: parent.right + anchors.rightMargin: units.gridUnit * 1 + anchors.top: documentFileName.bottom + anchors.topMargin: units.gridUnit * 0.15 + color: theme.linkColor + height: units.gridUnit * 0.1 + } + + PlasmaComponents.Label { + id: documentFileLoc + color: theme.linkColor + font.pointSize: 9 + anchors.left: parent.left + anchors.right: parent.right + anchors.top: sprTrinnerDocument.bottom + + wrapMode: Text.Wrap + Component.onCompleted: { + documentFileLoc.text = "Location: " + InputQuery + "" + } + } + } + + PlasmaComponents.Button { + id: playDocumentBtn + anchors.right: parent.right + anchors.rightMargin: units.gridUnit * 0.75 + anchors.verticalCenter: parent.verticalCenter + width: units.gridUnit * 3.5 + height: units.gridUnit * 3 + text: "Open" + + onClicked: { + var docFile = Qt.resolvedUrl(InputQuery) + Qt.openUrlExternally(docFile) + } + } + } + } diff --git a/plasmoid/contents/ui/VideoFileDelegate.qml b/plasmoid/contents/ui/VideoFileDelegate.qml new file mode 100644 index 0000000..79cf4c5 --- /dev/null +++ b/plasmoid/contents/ui/VideoFileDelegate.qml @@ -0,0 +1,113 @@ +/* Copyright 2016 Aditya Mehra + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) version 3, or any + later version accepted by the membership of KDE e.V. (or its + successor approved by the membership of KDE e.V.), which shall + act as a proxy defined in Section 6 of version 3 of the license. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library. If not, see . +*/ + +import QtQuick 2.9 +import QtQml.Models 2.2 +import QtMultimedia 5.8 +import QtQuick.Controls 2.2 +import QtQuick.Layouts 1.3 +import org.kde.plasma.core 2.0 as PlasmaCore +import org.kde.plasma.plasmoid 2.0 +import org.kde.plasma.components 2.0 as PlasmaComponents + +Rectangle { + id: videoFileDelegateItm + implicitHeight: videoFileDelegateInner.height + color: Qt.darker(theme.backgroundColor, 1.2) + width: cbwidth + + Item { + id: videoFileDelegateInner + implicitHeight: Math.max(videoInnerInfoColumn.height, playVideoBtn.height + units.gridUnit * 1) + width: parent.width + + PlasmaCore.IconItem { + id: videoImgType + source: "videoclip-amarok" + anchors.left: parent.left + width: units.gridUnit * 1 + height: units.gridUnit * 1 + anchors.verticalCenter: parent.verticalCenter + } + + Item { + id: videoInnerInfoColumn + implicitHeight: videoFileName.implicitHeight + sprTrinnerVideo.height + videoFileLoc.implicitHeight + units.gridUnit * 0.50 + anchors.left: videoImgType.right + anchors.leftMargin: units.gridUnit * 0.30 + anchors.right: playVideoBtn.left + anchors.rightMargin: units.gridUnit * 0.30 + + PlasmaComponents.Label { + id: videoFileName + color: theme.textColor + anchors.left: parent.left + anchors.right: parent.right + anchors.top: parent.top + anchors.topMargin: units.gridUnit * 0.25 + wrapMode: Text.Wrap + + Component.onCompleted: { + var filterName = InputQuery.toString(); + videoFileName.text = filterName.match(/\/([^\/]+)\/?$/)[1] + } + } + + Rectangle { + id: sprTrinnerVideo + anchors.left: parent.left + anchors.right: parent.right + anchors.rightMargin: units.gridUnit * 1 + anchors.top: videoFileName.bottom + anchors.topMargin: units.gridUnit * 0.15 + color: theme.linkColor + height: units.gridUnit * 0.1 + } + + PlasmaComponents.Label { + id: videoFileLoc + color: theme.linkColor + font.pixelSize: 12 + anchors.left: parent.left + anchors.right: parent.right + anchors.top: sprTrinnerVideo.bottom + + wrapMode: Text.Wrap + Component.onCompleted: { + videoFileLoc.text = "Location: " + InputQuery + "" + } + } + } + + PlasmaComponents.Button { + id: playVideoBtn + anchors.right: parent.right + anchors.rightMargin: units.gridUnit * 0.75 + anchors.verticalCenter: parent.verticalCenter + width: units.gridUnit * 3.5 + height: units.gridUnit * 3 + text: "Play" + + onClicked: { + var vidFile = Qt.resolvedUrl(InputQuery) + Qt.openUrlExternally(vidFile) + } + } + } + } diff --git a/plasmoid/contents/ui/main.qml b/plasmoid/contents/ui/main.qml index 4665f7e..5135e8d 100644 --- a/plasmoid/contents/ui/main.qml +++ b/plasmoid/contents/ui/main.qml @@ -1,1669 +1,1694 @@ /* Copyright 2016 Aditya Mehra This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) version 3, or any later version accepted by the membership of KDE e.V. (or its successor approved by the membership of KDE e.V.), which shall act as a proxy defined in Section 6 of version 3 of the license. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library. If not, see . */ import QtQuick 2.9 import QtQml.Models 2.2 import QtQuick.Controls 2.2 import QtQuick.Layouts 1.3 import Qt.WebSockets 1.0 import Qt.labs.settings 1.0 import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.plasma.plasmoid 2.0 import org.kde.plasma.components 2.0 as PlasmaComponents import org.kde.plasma.extras 2.0 as PlasmaExtras import org.kde.private.mycroftplasmoid 1.0 as PlasmaLa import org.kde.plasma.private.volume 0.1 import QtWebKit 3.0 import QtQuick.Window 2.0 import QtGraphicalEffects 1.0 Item { id: main Layout.fillWidth: true; Plasmoid.toolTipMainText: i18n("Mycroft") Plasmoid.switchWidth: units.gridUnit * 15 Plasmoid.switchHeight: units.gridUnit * 15 Layout.minimumHeight: units.gridUnit * 24 Layout.minimumWidth: units.gridUnit * 26 Component.onCompleted: { mycroftStatusCheckSocket.active = true detectInstallType(); refreshAllSkills(); } property var skillList: [] property alias cbwidth: rectangle2.width property alias cbheight: rectangle2.height property var dwrpaddedwidth: main.width + units.gridUnit * 1 property var cbdrawercontentheight: parent.height + units.gridUnit * 0.5 - rectanglebottombar.height property string defaultmcorestartpath: "/usr/share/plasma/plasmoids/org.kde.plasma.mycroftplasmoid/contents/code/startservice.sh" property string defaultmcorestoppath: "/usr/share/plasma/plasmoids/org.kde.plasma.mycroftplasmoid/contents/code/stopservice.sh" property string packagemcorestartcmd: "/usr/share/plasma/plasmoids/org.kde.plasma.mycroftplasmoid/contents/code/pkgstartservice.sh" property string packagemcorestopcmd: "/usr/share/plasma/plasmoids/org.kde.plasma.mycroftplasmoid/contents/code/pkgstopservice.sh" property string customlocstartpath: startsrvcustom.text property string customlocstoppath: stopsrvcustom.text property string customloc: " " property string coreinstallstartpath: defaultmcorestartpath property string coreinstallstoppath: defaultmcorestoppath property variant searchIndex: [] property variant results: [] property var smintent property var dataContent property alias autoCompModel: completionItems property alias textInput: qinput property alias plcLmodel: placesListModel property alias dashLmodel: dashListModel property alias recipeLmodel: recipesListModel property alias recipeReadLmodel: recipeReadListModel property bool intentfailure: false property bool locationUserSelected: false property var geoLat property var geoLong property var globalcountrycode property var weatherMetric: "metric" Connections { target: main2 ignoreUnknownSignals: true onSendShowMycroft: { plasmoid.expanded = !plasmoid.expanded tabBar.currentTab = mycroftTab } onSendShowSkills: { tabBar.currentTab = mycroftSkillsTab if(plasmoid.expanded = !plasmoid.expanded){ plasmoid.expanded } } onInstallList: { tabBar.currentTab = mycroftMSMinstTab if(plasmoid.expanded = !plasmoid.expanded){ plasmoid.expanded } } } function detectInstallType(){ if(locationUserSelected == false && PlasmaLa.FileReader.file_exists_local("/usr/bin/mycroft-messagebus")){ settingsTabUnitsOpOne.checked = true coreinstallstartpath = packagemcorestartcmd coreinstallstoppath = packagemcorestopcmd } } function toggleInputMethod(selection){ switch(selection){ case "KeyboardSetActive": qinput.visible = true suggestionbottombox.visible = true customMicIndicator.visible = false keybindic.color = "green" break case "KeyboardSetDisable": qinput.visible = false suggestionbottombox.visible = false customMicIndicator.visible = true keybindic.color = theme.textColor break } } function retryConn(){ socket.active = true if (socket.active = false){ convoLmodel.append({"itemType": "NonVisual", "InputQuery": socket.errorString}) } } function filterSpeak(msg){ convoLmodel.append({ "itemType": "NonVisual", "InputQuery": msg }) inputlistView.positionViewAtEnd(); } function filterincoming(intent, metadata) { var intentVisualArray = ['CurrentWeatherIntent']; var itemType var filterintentname = intent.split(':'); var intentname = filterintentname[1]; if (intentVisualArray.indexOf(intentname) !== -1) { switch (intentname){ case "CurrentWeatherIntent": itemType = "CurrentWeather" break; } convoLmodel.append({"itemType": itemType, "itemData": metadata}) } else { convoLmodel.append({"itemType": "WebViewType", "InputQuery": metadata.url}) } } function filtervisualObj(metadata){ convoLmodel.append({"itemType": "LoaderType", "InputQuery": metadata.url}) inputlistView.positionViewAtEnd(); } function filterplacesObj(metadata){ var filteredData = JSON.parse(metadata.data); var locallat = JSON.parse(metadata.locallat); var locallong = JSON.parse(metadata.locallong); var hereappid = metadata.appid var hereappcode = metadata.appcode; convoLmodel.clear() placesListModel.clear() for (var i = 0; i < filteredData.results.items.length; i++){ var itemsInPlaces = JSON.stringify(filteredData.results.items[i]) var fltritemsinPlc = JSON.parse(itemsInPlaces) var fltrtags = getTags(filteredData.results.items[i].tags) placesListModel.insert(i, {placeposition: JSON.stringify(fltritemsinPlc.position), placetitle: JSON.stringify(fltritemsinPlc.title), placedistance: JSON.stringify(fltritemsinPlc.distance), placeloc: JSON.stringify(fltritemsinPlc.vicinity), placetags: fltrtags, placelocallat: locallat, placelocallong: locallong, placeappid: hereappid, placeappcode: hereappcode}) } convoLmodel.append({"itemType": "PlacesType", "InputQuery": ""}); } function getTags(fltrTags){ if(fltrTags){ var tags = ''; for (var i = 0; i < fltrTags.length; i++){ if(tags) tags += ', ' + fltrTags[i].title; else tags += fltrTags[i].title; } return tags; } return ''; } function filterRecipeObj(metadata){ var filteredData = JSON.parse(metadata.data); convoLmodel.clear() recipeLmodel.clear() for (var i = 0; i < filteredData.hits.length; i++){ var itemsInRecipes = filteredData.hits[i].recipe var itemsReadRecipe = itemsInRecipes.ingredientLines.join(",") var itemsReadRecipeHealthTags = itemsInRecipes.healthLabels[0] var itemsReadRecipeDietType = itemsInRecipes.dietLabels.join(",") var itemsReadRecipeCalories = Math.round(itemsInRecipes.calories) if(itemsReadRecipeDietType == ""){ itemsReadRecipeDietType = "Normal" } recipeLmodel.insert(i, {recipeLabel: itemsInRecipes.label, recipeSource: itemsInRecipes.source, recipeImageUrl: itemsInRecipes.image, recipeCalories: itemsReadRecipeCalories, recipeIngredientLines: itemsReadRecipe, recipeDiet: itemsReadRecipeDietType, recipeHealthTags: itemsReadRecipeHealthTags}) } convoLmodel.append({"itemType": "RecipeType", "InputQuery": ""}) } + + function filterBalooObj(metadata){ + var BalooObj = metadata; + var baloosearchTerm = metadata.searchType + convoLmodel.clear() + for (var i = 0; i < BalooObj.data.length; i++){ + if(baloosearchTerm == "type:audio"){ + convoLmodel.append({"itemType": "AudioFileType", "InputQuery": metadata.data[i]}) + } + if(baloosearchTerm == "type:video"){ + convoLmodel.append({"itemType": "VideoFileType", "InputQuery": metadata.data[i]}) + } + if(baloosearchTerm == "type:document" || baloosearchTerm == "type:spreadsheet" || baloosearchTerm == "type:presentation" || baloosearchTerm == "type:archive" ){ + convoLmodel.append({"itemType": "DocumentFileType", "InputQuery": metadata.data[i]}) + } + } + } function isBottomEdge() { return plasmoid.location == PlasmaCore.Types.BottomEdge; } function clearList() { inputlistView.clear() } function muteMicrophone() { if (!sourceModel.defaultSource) { return; } var toMute = !sourceModel.defaultSource.muted; sourceModel.defaultSource.muted = toMute; } function refreshAllSkills(){ getSkills(); msmskillsModel.reload(); } function getAllSkills(){ if(skillList.length <= 0){ getSkills(); } return skillList; } function getSkillByName(skillName){ var tempSN=[]; for(var i = 0; i Connection error") statusId.color = "red" mycroftstartservicebutton.circolour = "red" midbarAnim.showstatsId() statusRetryBtn.visible = true drawer.open() waitanimoutter.aniRunError() delay(1250, function() { drawer.close() }) } else if (socket.status == WebSocket.Open) { statusId.text = i18n("Mycroft is ready") statusId.color = "green" statusRetryBtn.visible = false mycroftstartservicebutton.circolour = "green" mycroftStatusCheckSocket.active = false; midbarAnim.showstatsId() drawer.open() waitanimoutter.aniRunHappy() delay(1250, function() { drawer.close() }) } else if (socket.status == WebSocket.Closed) { statusId.text = i18n("Mycroft is disabled") statusId.color = theme.textColor mycroftstartservicebutton.circolour = Qt.lighter(theme.backgroundColor, 1.5) midbarAnim.showstatsId() } else if (socket.status == WebSocket.Connecting) { statusId.text = i18n("Starting up..please wait") statusId.color = theme.linkColor mycroftstartservicebutton.circolour = "steelblue" midbarAnim.showstatsId() } else if (socket.status == WebSocket.Closing) { statusId.text = i18n("Shutting down") statusId.color = theme.textColor midbarAnim.showstatsId() } } ColumnLayout { id: sidebar height: units.gridUnit * 6 width: units.gridUnit * 2 PlasmaComponents.TabBar { id: tabBar anchors.fill: parent tabPosition: Qt.LeftEdge; PlasmaComponents.TabButton { id: mycroftTab Layout.fillHeight: true Layout.fillWidth: true iconSource: "user-home" PlasmaCore.ToolTipArea { id: tooltiptab1 mainText: i18n("Home Tab") anchors.fill: parent } } PlasmaComponents.TabButton { id: mycroftSkillsTab Layout.fillHeight: true Layout.fillWidth: true iconSource: "games-hint" PlasmaCore.ToolTipArea { id: tooltiptab2 mainText: i18n("Skills Tab") anchors.fill: parent } } PlasmaComponents.TabButton { id: mycroftSettingsTab Layout.fillHeight: true Layout.fillWidth: true iconSource: "games-config-options" PlasmaCore.ToolTipArea { id: tooltiptab3 mainText: i18n("Settings Tab") anchors.fill: parent } } PlasmaComponents.TabButton { id: mycroftMSMinstTab Layout.fillHeight: true Layout.fillWidth: true iconSource: "kmouth-phresebook-new" PlasmaCore.ToolTipArea { id: tooltiptab4 mainText: i18n("Skill Installs Tab") anchors.fill: parent } } } } PlasmaCore.SvgItem { anchors { left: parent.left leftMargin: sidebar.width top: parent.top topMargin: 1 bottom: parent.bottom bottomMargin: 1 } width: lineSvg.elementSize("vertical-line").width z: 110 elementId: "vertical-line" svg: PlasmaCore.Svg { id: lineSvg; imagePath: "widgets/line" } } ColumnLayout { id: mycroftcolumntab visible: tabBar.currentTab == mycroftTab; anchors.top: root.top anchors.left: sidebar.right anchors.leftMargin: units.gridUnit * 0.25 anchors.right: root.right anchors.bottom: root.bottom Rectangle { id: rectangle2 color: "#00000000" anchors.top: mycroftcolumntab.top anchors.topMargin:15 anchors.left: mycroftcolumntab.left anchors.right: mycroftcolumntab.right anchors.bottom: mycroftcolumntab.bottom DropArea { anchors.fill: parent; id: dragTarget onEntered: { for(var i = 0; i < drag.urls.length; i++) if(validateFileExtension(drag.urls[i])) return console.log("No valid files, refusing drag event") drag.accept() dragTarget.enabled = false } onDropped: { for(var i = 0; i < drop.urls.length; i++){ var ext = getFileExtenion(drop.urls[i]); if(ext === "jpg" || ext === "png" || ext === "jpeg"){ var durl = String(drop.urls[i]); convoLmodel.append({ "itemType": "DropImg", "InputQuery": durl }) inputlistView.positionViewAtEnd(); var irecogmsgsend = innerset.customrecog var socketmessage = {}; socketmessage.type = "recognizer_loop:utterance"; socketmessage.data = {}; socketmessage.data.utterances = [irecogmsgsend + " " + durl]; socket.sendTextMessage(JSON.stringify(socketmessage)); } if(ext === 'mp3'){ console.log('mp3'); } } } Disclaimer{ id: disclaimbox visible: false } ListModel{ id: convoLmodel } Rectangle { id: messageBox anchors.fill: parent anchors.right: parent.right anchors.left: parent.left color: "#00000000" ColumnLayout { id: colconvo anchors.fill: parent ListView { id: inputlistView Layout.fillWidth: true Layout.fillHeight: true verticalLayoutDirection: ListView.TopToBottom spacing: 12 clip: true model: convoLmodel ScrollBar.vertical: ScrollBar {} delegate: Component { Loader { source: switch(itemType) { case "NonVisual": return "SimpleMessageType.qml" case "WebViewType": return "WebViewType.qml" case "CurrentWeather": return "CurrentWeatherType.qml" case "DropImg" : return "ImgRecogType.qml" case "AskType" : return "AskMessageType.qml" case "LoaderType" : return "LoaderType.qml" case "PlacesType" : return "PlacesType.qml" case "RecipeType" : return "RecipeType.qml" case "DashboardType" : return "DashboardType.qml" + case "AudioFileType" : return "AudioFileDelegate.qml" + case "VideoFileType" : return "VideoFileDelegate.qml" + case "DocumentFileType" : return "DocumentFileDelegate.qml" } property var metacontent : dataContent } } onCountChanged: { inputlistView.positionViewAtEnd(); } } } } } } } ColumnLayout { id: mycroftSkillscolumntab visible: tabBar.currentTab == mycroftSkillsTab; anchors.top: root.top anchors.left: sidebar.right anchors.leftMargin: units.gridUnit * 0.25 anchors.right: root.right anchors.bottom: root.bottom ListView { id: skillslistmodelview anchors.top: parent.top anchors.topMargin: 5 anchors.left: parent.left anchors.right: parent.right anchors.bottom: parent.bottom model: SkillModel{} delegate: SkillView{} spacing: 4 focus: false interactive: true clip: true; } } ColumnLayout { id: mycroftSettingsColumn visible: tabBar.currentTab == mycroftSettingsTab; anchors.top: root.top anchors.left: sidebar.right anchors.leftMargin: units.gridUnit * 0.25 anchors.right: root.right anchors.bottom: root.bottom PlasmaComponents.TabBar { id: settingstabBar anchors.top: parent.top anchors.left: parent.left anchors.right: parent. right height: units.gridUnit * 2 tabPosition: Qt.TopEdge; PlasmaComponents.TabButton { id: generalSettingsTab text: "General" } PlasmaComponents.TabButton { id: dashSettingsTab text: "Dash" } } Item { id: settingscontent Layout.fillWidth: true; Layout.fillHeight: true; anchors.top: settingstabBar.bottom anchors.topMargin: units.gridUnit * 0.50 anchors.left: parent.left anchors.right: parent.right anchors.bottom: parent.bottom visible: settingstabBar.currentTab == generalSettingsTab; Flickable { id: settingFlick anchors.fill: parent; contentWidth: mycroftSettingsColumn.width contentHeight: units.gridUnit * 22 clip: true; PlasmaComponents.Label { id: settingsTabUnits anchors.top: parent.top; anchors.topMargin: 5 text: i18n("Your Mycroft Core Installation Path") } PlasmaComponents.ButtonColumn { id: radiobuttonColoumn anchors.top: settingsTabUnits.bottom anchors.topMargin: 5 PlasmaComponents.RadioButton { id: settingsTabUnitsOpZero exclusiveGroup: installPathGroup text: i18n("Default Path") checked: true onCheckedChanged: { locationUserSelected = true if (settingsTabUnitsOpZero.checked === true && coreinstallstartpath === packagemcorestartcmd) { coreinstallstartpath = defaultmcorestartpath; } else if (settingsTabUnitsOpZero.checked === true && coreinstallstartpath === customlocstartpath) { coreinstallstartpath = defaultmcorestartpath; } if (settingsTabUnitsOpZero.checked === true && coreinstallstoppath === packagemcorestopcmd) { coreinstallstoppath = defaultmcorestoppath; } else if (settingsTabUnitsOpZero.checked === true && coreinstallstoppath === customlocstoppath) { coreinstallstoppath = defaultmcorestoppath; } } } PlasmaComponents.RadioButton { id: settingsTabUnitsOpOne exclusiveGroup: installPathGroup text: i18n("Installed Using Mycroft Package") checked: false onCheckedChanged: { if (settingsTabUnitsOpOne.checked === true && coreinstallstartpath === defaultmcorestartpath) { coreinstallstartpath = packagemcorestartcmd; } else if (settingsTabUnitsOpOne.checked === true && coreinstallstartpath === customlocstartpath) { coreinstallstartpath = packagemcorestartcmd; } if (settingsTabUnitsOpOne.checked === true && coreinstallstoppath === defaultmcorestoppath) { coreinstallstoppath = packagemcorestopcmd; } else if (settingsTabUnitsOpOne.checked === true && coreinstallstoppath === customlocstoppath) { coreinstallstoppath = packagemcorestopcmd; } } } PlasmaComponents.RadioButton { id: settingsTabUnitsOpTwo exclusiveGroup: installPathGroup text: i18n("Location of Mycroft-Core Directory") checked: false onCheckedChanged: { locationUserSelected = true if (settingsTabUnitsOpTwo.checked === true && coreinstallstartpath === defaultmcorestartpath) { coreinstallstartpath = customlocstartpath; } else if (settingsTabUnitsOpTwo.checked === true && coreinstallstartpath === packagemcorestartcmd) { coreinstallstartpath = customlocstartpath; } if (settingsTabUnitsOpTwo.checked === true && coreinstallstoppath === defaultmcorestoppath) { coreinstallstoppath = customlocstoppath; } else if (settingsTabUnitsOpTwo.checked === true && coreinstallstoppath === packagemcorestopcmd) { coreinstallstoppath = customlocstoppath; } } } } PlasmaComponents.TextField { id: settingsTabUnitsOpThree width: settingscontent.width / 1.1 anchors.top: radiobuttonColoumn.bottom anchors.topMargin: 10 placeholderText: i18n("/mycroft-core/") onTextChanged: { var cstloc = settingsTabUnitsOpThree.text customloc = cstloc } } PlasmaComponents.Button { id: acceptcustomPath anchors.left: settingsTabUnitsOpThree.right anchors.verticalCenter: settingsTabUnitsOpThree.verticalCenter anchors.right: parent.right iconSource: "checkbox" onClicked: { var cstlocl = customloc var ctstart = cstlocl + "start-mycroft.sh all" var ctstop = cstlocl + "stop-mycroft.sh" startsrvcustom.text = ctstart stopsrvcustom.text = ctstop console.log(startsrvcustom.text) } } PlasmaComponents.TextField { id: settingsTabUnitsWSpath width: settingscontent.width / 1.1 anchors.top: settingsTabUnitsOpThree.bottom anchors.topMargin: 10 placeholderText: i18n("ws://0.0.0.0:8181/core") text: i18n("ws://0.0.0.0:8181/core") } PlasmaComponents.Button { id: acceptcustomWSPath anchors.left: settingsTabUnitsWSpath.right anchors.verticalCenter: settingsTabUnitsWSpath.verticalCenter anchors.right: parent.right iconSource: "checkbox" onClicked: { innerset.wsurl = settingsTabUnitsWSpath.text } } PlasmaComponents.TextField { id: settingsTabUnitsIRCmd width: settingscontent.width / 1.1 anchors.top: settingsTabUnitsWSpath.bottom anchors.topMargin: 10 placeholderText: i18n("Your Custom Image Recognition Skill Voc Keywords") text: i18n("search image url") } PlasmaComponents.Button { id: acceptcustomIRCmd anchors.left: settingsTabUnitsIRCmd.right anchors.verticalCenter: settingsTabUnitsIRCmd.verticalCenter anchors.right: parent.right iconSource: "checkbox" } PlasmaComponents.Switch { id: notificationswitch anchors.top: settingsTabUnitsIRCmd.bottom anchors.topMargin: 10 text: i18n("Enable Notifications") checked: true } PlasmaExtras.Paragraph { id: settingsTabTF2 anchors.top: notificationswitch.bottom anchors.topMargin: 15 text: i18n("Please Note: Default path is set to /home/$USER/mycroft-core/. Change the above settings to match your installation") } PlasmaComponents.Label { id: startsrvcustom visible: false } PlasmaComponents.Label { id: stopsrvcustom visible: false } } } Item { id: dashsettingscontent Layout.fillWidth: true; Layout.fillHeight: true; anchors.top: settingstabBar.bottom anchors.topMargin: units.gridUnit * 0.50 anchors.left: parent.left anchors.right: parent.right anchors.bottom: parent.bottom visible: settingstabBar.currentTab == dashSettingsTab; Flickable { id: dashsettingFlick anchors.fill: parent; contentWidth: mycroftSettingsColumn.width contentHeight: units.gridUnit * 22 clip: true; Column { spacing: 6 PlasmaComponents.Switch { id: dashswitch text: i18n("Enable / Disable Dashboard") checked: true onCheckedChanged: { console.log(dashswitch.checked) if(dashswitch.checked){ showDash("setVisible") } else if(!dashswitch.checked){ convoLmodel.clear() } } } PlasmaComponents.Label { id: dashSettingsLabel1 text: i18n("Card Settings:") font.bold: true; } PlasmaComponents.Switch { id: disclaimercardswitch text: i18n("Enable / Disable Disclaimer Card") checked: true } PlasmaComponents.Switch { id: newscardswitch text: i18n("Enable / Disable News Card") checked: true } Row { spacing: 2 PlasmaComponents.Label { id: newsApiKeyLabelFld text: "NewsApi App_Key:" } PlasmaComponents.TextField{ id: newsApiKeyTextFld width: units.gridUnit * 12 text: "a1091945307b434493258f3dd6f36698" } } PlasmaComponents.Switch { id: weathercardswitch text: i18n("Enable / Disable Weather Card") checked: true } Row { spacing: 2 PlasmaComponents.Label { id: owmApiKeyLabelFld text: "Open Weather Map App_ID:" } PlasmaComponents.TextField{ id: owmApiKeyTextFld width: units.gridUnit * 12 text: "7af5277aee7a659fc98322c4517d3df7" } } Row{ id: weatherCardMetricsRowList spacing: 2 PlasmaComponents.Button { id: owmApiKeyMetricCel text: i18n("Celcius") onClicked: { weatherMetric = "metric" updateCardData() } } PlasmaComponents.Button{ id: owmApiKeyMetricFar text: i18n("Fahrenheit") onClicked: { weatherMetric = "imperial" updateCardData() } } } } } } } ColumnLayout { id: mycroftMsmColumn visible: tabBar.currentTab == mycroftMSMinstTab; anchors.top: root.top anchors.left: sidebar.right anchors.leftMargin: units.gridUnit * 0.25 anchors.right: root.right anchors.bottom: root.bottom Item { id: msmtabtopbar width: parent.width anchors.left: parent.left anchors.right: parent.right height: units.gridUnit * 2 PlasmaComponents.TextField { id: msmsearchfld anchors.left: parent.left anchors.top: parent.top anchors.bottom: parent.bottom anchors.right: getskillsbx.left placeholderText: i18n("Search Skills") clearButtonShown: true onTextChanged: { if(text.length > 0 ) { msmskillsModel.applyFilter(text.toLowerCase()); } else { msmskillsModel.reload(); } } } PlasmaComponents.ToolButton { id: getskillsbx anchors.right: parent.right anchors.top: parent.top anchors.bottom: parent.bottom iconSource: "view-refresh" tooltip: i18n("Refresh List") flat: true width: Math.round(units.gridUnit * 2) height: width z: 102 onClicked: { msmskillsModel.clear(); refreshAllSkills(); } } } ListModel { id: msmskillsModel Component.onCompleted: { reload(); } function reload() { var skList = getAllSkills(); msmskillsModel.clear(); for( var i=0; i < skList.length ; ++i ) { msmskillsModel.append(skList[i]); } } function applyFilter(skName) { var skList = getSkillByName(skName); msmskillsModel.clear(); for( var i=0; i < skList.length ; ++i ) { msmskillsModel.append(skList[i]); } } } ListView { id: msmlistView anchors.top: msmtabtopbar.bottom anchors.topMargin: 5 anchors.left: parent.left anchors.right: parent.right anchors.bottom: parent.bottom model: msmskillsModel delegate: MsmView{} spacing: 4 focus: false interactive: true clip: true; } } } SourceModel { id: sourceModel } PlasmaCore.SvgItem { anchors { left: main.left right: main.right bottom: root.bottom } width: 1 height: horlineSvg.elementSize("horizontal-line").height elementId: "horizontal-line" z: 110 svg: PlasmaCore.Svg { id: horlineSvg; imagePath: "widgets/line" } } Item { id: rectanglebottombar height: units.gridUnit * 3.5 anchors.left: main.left anchors.right: main.right anchors.bottom: main.bottom z: 110 ListModel { id: completionItems } Drawer { id: drawer width: dwrpaddedwidth height: units.gridUnit * 5.5 edge: Qt.BottomEdge Rectangle { color: theme.backgroundColor anchors.fill: parent } CustomIndicator { id: waitanimoutter height: 70 width: 70 anchors.verticalCenter: parent.verticalCenter anchors.horizontalCenter: parent.horizontalCenter } } Rectangle { id: suggestionbottombox anchors.top: parent.top anchors.bottom: qinput.top anchors.right: parent.right anchors.left: parent.left color: theme.backgroundColor Suggestions { id: suggst visible: true; } } Rectangle { id: keyboardactivaterect color: theme.backgroundColor border.width: 1 border.color: Qt.lighter(theme.backgroundColor, 1.2) width: units.gridUnit * 2 height: qinput.height anchors.bottom: parent.bottom anchors.left: parent.left PlasmaCore.IconItem { id: keybdImg source: "input-keyboard" anchors.centerIn: parent width: units.gridUnit * 1.5 height: units.gridUnit * 1.5 } Rectangle { id: keybindic anchors.bottom: parent.bottom anchors.bottomMargin: 4 anchors.left: parent.left anchors.right: parent.right anchors.leftMargin: 8 anchors.rightMargin: 8 height: 2 color: "green" } MouseArea{ anchors.fill: parent hoverEnabled: true onEntered: {} onExited: {} onClicked: { if(qinput.visible === false){ toggleInputMethod("KeyboardSetActive") } else if(qinput.visible === true){ toggleInputMethod("KeyboardSetDisable") } } } } PlasmaComponents.TextField { id: qinput anchors.left: keyboardactivaterect.right anchors.bottom: parent.bottom anchors.right: parent.right placeholderText: i18n("Enter Query or Say 'Hey Mycroft'") clearButtonShown: true onAccepted: { var doesExist = autoAppend(autoCompModel, function(item) { return item.name === qinput.text }, qinput.text) var evaluateExist = doesExist if(evaluateExist === null){ autoCompModel.append({"name": qinput.text}); } suggst.visible = true; var socketmessage = {}; socketmessage.type = "recognizer_loop:utterance"; socketmessage.data = {}; socketmessage.data.utterances = [qinput.text]; socket.sendTextMessage(JSON.stringify(socketmessage)); qinput.text = ""; } onTextChanged: { evalAutoLogic(); } } CustomMicIndicator { id: customMicIndicator anchors.centerIn: parent visible: false } AutocompleteBox { id: suggestionsBox model: completionItems width: parent.width anchors.bottom: qinput.top anchors.left: parent.left anchors.right: parent.right filter: textInput.text property: "name" onItemSelected: complete(item) function complete(item) { if (item !== undefined) textInput.text = item.name } } } Settings { id: innerset property alias wsurl: settingsTabUnitsWSpath.text property alias customrecog: settingsTabUnitsIRCmd.text property alias customsetuppath: settingsTabUnitsOpThree.text property alias notifybool: notificationswitch.checked property alias radiobt1: settingsTabUnitsOpOne.checked property alias radiobt2: settingsTabUnitsOpTwo.checked property alias radiobt3: settingsTabUnitsOpZero.checked property alias dashboardSetting: dashswitch.checked property alias disclaimerCardSetting: disclaimercardswitch.checked property alias newsCardSetting: newscardswitch.checked property alias newsCardAPIKey: newsApiKeyLabelFld.text property alias weatherCardSetting: weathercardswitch.checked property alias weatherCardAPIKey: owmApiKeyLabelFld.text property alias weatherMetricC: owmApiKeyMetricCel.checked property alias weatherMetricF: owmApiKeyMetricFar.checked } }