diff --git a/plasmoid/contents/code/fallback.css b/plasmoid/contents/code/fallback.css new file mode 100644 index 0000000..b16cd3c --- /dev/null +++ b/plasmoid/contents/code/fallback.css @@ -0,0 +1,5 @@ +img { + object-fit: fill; + width: 100% !important; + height: 100% !important; +} diff --git a/plasmoid/contents/ui/FallbackWebSearchType.qml b/plasmoid/contents/ui/FallbackWebSearchType.qml new file mode 100644 index 0000000..63ebea4 --- /dev/null +++ b/plasmoid/contents/ui/FallbackWebSearchType.qml @@ -0,0 +1,65 @@ +/* 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 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 QtWebKit 3.0 +import QtWebKit.experimental 1.0 + +Column { + spacing: 6 + anchors.right: parent.right + + Row { + id: messageRow + spacing: 6 + + Item { + id: messageRect + width: cbwidth + height: newolfFlick.height + + Flickable { + id: newolfFlick + width: messageRect.width + height: units.gridUnit * 10 + contentHeight: wikiview.height + clip: true + + WebView { + id: wikiview + height: units.gridUnit * 20 + width: parent.width + url: InputQuery + experimental.preferredMinimumContentsWidth: cbwidth + experimental.useDefaultContentItemSize: false + experimental.userStyleSheets: "../code/fallback.css" + } + + ScrollIndicator.vertical: ScrollIndicator { } + + } + } + } + } + diff --git a/plasmoid/contents/ui/MsmView.qml b/plasmoid/contents/ui/MsmView.qml index a1d4521..d99f473 100644 --- a/plasmoid/contents/ui/MsmView.qml +++ b/plasmoid/contents/ui/MsmView.qml @@ -1,212 +1,212 @@ /* 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 QtQuick.Layouts 1.3 import QtQuick.Controls 2.2 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 Qt.labs.settings 1.0 Rectangle { id: skillcontent Layout.fillWidth: true; anchors { left: parent.left; leftMargin: 0.5; right: parent.right } height: units.gridUnit * 4 border.width: 1 border.color: Qt.darker(theme.linkColor, 1.2) color: Qt.darker(theme.backgroundColor, 1.2) property var configPath function exec(msmparam) { if(main.coreinstallstartpath == packagemcorestartcmd){ - return launchinstaller.msmapp("konsole --hold -e msm install " + model.url) + return launchinstaller.msmapp("bash msm install " + model.url) } else { var bscrpt = "/usr/share/plasma/plasmoids/org.kde.plasma.mycroftplasmoid/contents/code/msm.sh" - return launchinstaller.msmapp("konsole -e bash " + bscrpt + " install " + model.url) + return launchinstaller.msmapp("bash " + bscrpt + " install " + model.url) } } function execUninstall(msmparam) { if(main.coreinstallstartpath == packagemcorestartcmd){ - return launchinstaller.msmapp("konsole --hold -e msm remove " + model.url) + return launchinstaller.msmapp("bash msm remove " + model.name) } else { var bscrpt = "/usr/share/plasma/plasmoids/org.kde.plasma.mycroftplasmoid/contents/code/msm.sh" - return launchinstaller.msmapp("konsole -e bash " + bscrpt + " remove " + model.url) + return launchinstaller.msmapp("bash " + bscrpt + " remove " + model.name) } } function execUpdate(msmparam) { if(main.coreinstallstartpath == packagemcorestartcmd){ - return launchinstaller.msmapp("konsole --hold -e msm update " + model.name) + return launchinstaller.msmapp("bash msm update " + model.name) } else { var bscrpt = "/usr/share/plasma/plasmoids/org.kde.plasma.mycroftplasmoid/contents/code/msm.sh" - return launchinstaller.msmapp("konsole -e bash " + bscrpt + " update " + model.name) + return launchinstaller.msmapp("bash " + bscrpt + " update " + model.name) } } function execConfiguration(msmparam) { var openConfigUrl = Qt.resolvedUrl(configPath) Qt.openUrlExternally(openConfigUrl) } function getSkillInfoLocal() { var customFold = launchinstaller.skillsPath() var defaultFold = '/opt/mycroft/skills' var skillPath = (defaultFold || customFold) + "/" + model.name configPath = (defaultFold || customFold) + "/" + model.name + "/" + "settingsmeta.json" if(PlasmaLa.FileReader.file_exists_local(skillPath)){ installUpdateLabl.text = "Uninstall" updateskillviamsm.enabled = true } if(PlasmaLa.FileReader.file_exists_local(configPath)){ configureSkillLabl.enabled = true } } PlasmaLa.MsmApp{ id: launchinstaller } Component.onCompleted: { getSkillInfoLocal(); } PlasmaComponents.Label { id: skllname font.capitalization: Font.AllUppercase anchors.top: parent.top anchors.left: parent.left anchors.leftMargin: units.gridUnit * 0.5 anchors.right: parent.right anchors.rightMargin: units.gridUnit * 0.5 wrapMode: Text.WordWrap text: model.name Rectangle { id: sepratrmsm width: parent.width height: 1 anchors.left: parent.left anchors.bottom: parent.bottom anchors.bottomMargin: 2 color: Qt.darker(theme.linkColor, 1.2) } } PlasmaComponents.Label { id: urlskllable anchors.top: skllname.bottom anchors.topMargin: units.gridUnit * 0.03 anchors.left: parent.left anchors.leftMargin: units.gridUnit * 0.5 anchors.right: parent.right anchors.rightMargin: units.gridUnit * 0.5 wrapMode: Text.WordWrap color: theme.textColor text: model.url MouseArea{ id: gotoGit anchors.fill: parent hoverEnabled: true onClicked: {Qt.openUrlExternally(model.url)} onEntered: { urlskllable.color = Qt.darker(theme.linkColor, 1.2) } onExited: { urlskllable.color = theme.textColor } } } Rectangle { id: getskillviamsmRect width: parent.width height: units.gridUnit * 2.5 anchors.bottom: parent.bottom color: Qt.darker(theme.linkColor, 1.2) PlasmaComponents.Button{ id: installUpdateLabl width: parent.width / 4 height: parent.height anchors.left: parent.left text: "Install" onClicked:{ switch(installUpdateLabl.text){ case "Install": var msmprogress = exec() break case "Uninstall": var msmprogress = execUninstall() break } } } PlasmaComponents.Button{ id: updateskillviamsm width: parent.width / 4 height: parent.height anchors.left: installUpdateLabl.right text: "Update" enabled: false onClicked:{ execUpdate() } } PlasmaComponents.Button{ id: viewGit width: parent.width / 4 height: parent.height anchors.left: updateskillviamsm.right text: "Readme" onClicked: { Qt.openUrlExternally(model.url) } } PlasmaComponents.Button{ id: configureSkillLabl width: parent.width / 4 anchors.right: parent.right height: parent.height text: "Configure" enabled: false onClicked: { execConfiguration() } } } } diff --git a/plasmoid/contents/ui/main.qml b/plasmoid/contents/ui/main.qml index ed5a6e5..d34ebba 100644 --- a/plasmoid/contents/ui/main.qml +++ b/plasmoid/contents/ui/main.qml @@ -1,1728 +1,1758 @@ /* 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 bool connectCtx: false property var geoLat property var geoLong property var globalcountrycode property var weatherMetric: "metric" Connections { target: plasmoid onExpandedChanged: { if (plasmoid.expanded) { checkDashStatus() } } } 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 checkDashStatus(){ if(dashListModel.count == 0){ checkConnectionStatus() } } function checkConnectionStatus(){ var isConnected = PlasmaLa.ConnectionCheck.checkConnection() if(!isConnected){ if(!connectCtx){ - var conError = i18n("I am not connected to the 🌐 internet, Please check your network connection") + var conError = i18n("I am not connected to the internet, Please check your network connection") convoLmodel.append({"itemType": "NonVisual", "InputQuery": conError}); connectCtx = true } } else { geoDataSource.connectedSources = ["location"] } } 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" + case "DocumentFileType" : return "DocumentFileDelegate.qml" + case "FallBackType" : return "FallbackWebSearchType.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 } + PlasmaComponents.Switch { + id: wolframfallbackswitch + anchors.top: notificationswitch.bottom + anchors.topMargin: 10 + text: i18n("Enable Fallback To Wolfram Alpha Web-Search") + checked: true + } + + PlasmaComponents.TextField { + id: wolframapikeyfld + width: parent.width + anchors.top: wolframfallbackswitch.bottom + anchors.topMargin: 10 + text: i18n("RJVUY3-T6YLWQVXRR") + } + PlasmaExtras.Paragraph { id: settingsTabTF2 - anchors.top: notificationswitch.bottom + anchors.top: wolframapikeyfld.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 wolffallbackbool: wolframfallbackswitch.checked + property alias wolframKey: wolframapikeyfld.text 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 } } diff --git a/plugin/msmapp.cpp b/plugin/msmapp.cpp index 1279aa1..238ddd8 100644 --- a/plugin/msmapp.cpp +++ b/plugin/msmapp.cpp @@ -1,45 +1,41 @@ /* * Copyright (C) 2016 by Aditya Mehra * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Library General Public License as * published by the Free Software Foundation; either version 2, or * (at your option) any later version. * * This program 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 General Public License for more details * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "msmapp.h" #include #include MsmApp::MsmApp(QObject *parent) : QObject(parent), m_process(new QProcess(this)) { } -QString MsmApp::msmapp(const QString &program) +void MsmApp::msmapp(const QString &program) { - m_process->start(program); - m_process->waitForFinished(-1); - QByteArray bytes = m_process->readAllStandardOutput(); - QString output = QString::fromLocal8Bit(bytes); - return output; + m_process->startDetached(program); } QString MsmApp::skillsPath() { QString path = QDir::homePath()+"/.mycroft/skills"; QDir dir(path); if (dir.exists()) return path; return QStringLiteral("/opt/mycroft/skills"); } diff --git a/plugin/msmapp.h b/plugin/msmapp.h index 68884e0..fa46ded 100644 --- a/plugin/msmapp.h +++ b/plugin/msmapp.h @@ -1,38 +1,38 @@ /* * Copyright (C) 2016 by Aditya Mehra * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Library General Public License as * published by the Free Software Foundation; either version 2, or * (at your option) any later version. * * This program 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 General Public License for more details * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef MSMAPP_H #define MSMAPP_H #include #include class MsmApp : public QObject { Q_OBJECT public: explicit MsmApp(QObject *parent = 0); - Q_INVOKABLE QString msmapp(const QString &program); + Q_INVOKABLE void msmapp(const QString &program); Q_INVOKABLE QString skillsPath(); private: QProcess *m_process; }; #endif // MSMAPP_H