Warning, /plasma-mobile/mycroft-plasmoid-mobile/plasmoid/contents/ui/MainPage.qml is written in an unsupported language. File is not indexed.
0001 /* Copyright 2016 Aditya Mehra <aix.m@outlook.com> 0002 0003 This library is free software; you can redistribute it and/or 0004 modify it under the terms of the GNU Lesser General Public 0005 License as published by the Free Software Foundation; either 0006 version 2.1 of the License, or (at your option) version 3, or any 0007 later version accepted by the membership of KDE e.V. (or its 0008 successor approved by the membership of KDE e.V.), which shall 0009 act as a proxy defined in Section 6 of version 3 of the license. 0010 0011 This library is distributed in the hope that it will be useful, 0012 but WITHOUT ANY WARRANTY; without even the implied warranty of 0013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0014 Lesser General Public License for more details. 0015 0016 You should have received a copy of the GNU Lesser General Public 0017 License along with this library. If not, see <http://www.gnu.org/licenses/>. 0018 */ 0019 0020 import QtQuick 2.9 0021 import QtQml.Models 2.2 0022 import QtQuick.Controls 2.2 0023 import QtQuick.Layouts 1.3 0024 import Qt.WebSockets 1.0 0025 import Qt.labs.settings 1.0 0026 import org.kde.plasma.core 2.0 as PlasmaCore 0027 import org.kde.plasma.plasmoid 2.0 0028 import org.kde.plasma.components 2.0 as PlasmaComponents 0029 import org.kde.plasma.components 3.0 as PlasmaComponents3 0030 import org.kde.plasma.extras 2.0 as PlasmaExtras 0031 import org.kde.private.mycroftplasmoidmobile 1.0 as PlasmaLa 0032 import org.kde.plasma.private.volume 0.1 0033 import org.kde.kirigami 2.1 as Kirigami 0034 import QtGraphicalEffects 1.0 0035 0036 Item { 0037 id: main 0038 anchors.fill: parent 0039 z: 999 0040 0041 Component.onCompleted: { 0042 mycroftStatusCheckSocket.active = true 0043 refreshAllSkills(); 0044 } 0045 0046 property var skillList: [] 0047 property alias cbwidth: rectangle2.width 0048 property alias cbheight: rectangle2.height 0049 property var dwrpaddedwidth: main.width + units.gridUnit * 1 0050 property var cbdrawercontentheight: parent.height + units.gridUnit * 0.5 - rectanglebottombar.height 0051 property string defaultmcorestartpath: "/usr/share/plasma/plasmoids/org.kde.phone.mycroftplasmoid/contents/code/startservice.sh" 0052 property string defaultmcorestoppath: "/usr/share/plasma/plasmoids/org.kde.phone.mycroftplasmoid/contents/code/stopservice.sh" 0053 property string packagemcorestartcmd: "/usr/share/plasma/plasmoids/org.kde.phone.mycroftplasmoid/contents/code/pkgstartservice.sh" 0054 property string packagemcorestopcmd: "/usr/share/plasma/plasmoids/org.kde.phone.mycroftplasmoid/contents/code/pkgstopservice.sh" 0055 property string customlocstartpath: startsrvcustom.text 0056 property string customlocstoppath: stopsrvcustom.text 0057 property string customloc: " " 0058 property string coreinstallstartpath: defaultmcorestartpath 0059 property string coreinstallstoppath: defaultmcorestoppath 0060 property variant searchIndex: [] 0061 property variant results: [] 0062 property var smintent 0063 property var dataContent 0064 property alias autoCompModel: completionItems 0065 property alias textInput: qinput 0066 property alias plcLmodel: placesListModel 0067 property alias dashLmodel: dashListModel 0068 property alias recipeLmodel: recipesListModel 0069 property alias recipeReadLmodel: recipeReadListModel 0070 property alias stackLmodel: stackexListModel 0071 property alias bookLmodel: bookListModel 0072 property alias wikiLmodel: wikiListModel 0073 property alias yelpLmodel: yelpListModel 0074 property bool intentfailure: false 0075 property bool locationUserSelected: false 0076 property bool connectCtx: false 0077 property bool micIsMuted 0078 property var geoLat 0079 property var geoLong 0080 property var globalcountrycode 0081 property var weatherMetric: "metric" 0082 property date currentDate: new Date() 0083 0084 0085 function checkDashStatus(){ 0086 if(dashListModel.count == 0){ 0087 checkConnectionStatus() 0088 } 0089 } 0090 0091 function checkConnectionStatus(){ 0092 var isConnected = PlasmaLa.ConnectionCheck.checkConnection() 0093 if(!isConnected){ 0094 if(!connectCtx){ 0095 var conError = i18n("I am not connected to the internet, Please check your network connection") 0096 convoLmodel.append({"itemType": "NonVisual", "InputQuery": conError}); 0097 connectCtx = true 0098 } 0099 } 0100 else { 0101 geoDataSource.connectedSources = ["location"] 0102 } 0103 } 0104 0105 function toggleInputMethod(selection){ 0106 switch(selection){ 0107 case "KeyboardSetActive": 0108 expandbartxtinput.visible = true 0109 keybindic.color = "green" 0110 break 0111 case "KeyboardSetDisable": 0112 expandbartxtinput.visible = false 0113 keybindic.color = theme.textColor 0114 break 0115 } 0116 } 0117 0118 function retryConn(){ 0119 socket.active = true 0120 if (socket.active = false){ 0121 console.log(socket.errorString) 0122 } 0123 } 0124 0125 function filterSpeak(msg){ 0126 convoLmodel.append({ 0127 "itemType": "NonVisual", 0128 "InputQuery": msg 0129 }) 0130 inputlistView.positionViewAtEnd(); 0131 } 0132 0133 function filterincoming(intent, metadata) { 0134 var intentVisualArray = ['CurrentWeatherIntent']; 0135 var itemType 0136 var filterintentname = intent.split(':'); 0137 var intentname = filterintentname[1]; 0138 0139 if (intentVisualArray.indexOf(intentname) !== -1) { 0140 switch (intentname){ 0141 case "CurrentWeatherIntent": 0142 itemType = "CurrentWeather" 0143 break; 0144 } 0145 0146 convoLmodel.append({"itemType": itemType, "itemData": metadata}) 0147 } 0148 0149 else { 0150 convoLmodel.append({"itemType": "WebViewType", "InputQuery": metadata.url}) 0151 } 0152 } 0153 0154 function filtervisualObj(metadata){ 0155 convoLmodel.append({"itemType": "LoaderType", "InputQuery": metadata.url}) 0156 inputlistView.positionViewAtEnd(); 0157 } 0158 0159 0160 function isBottomEdge() { 0161 return plasmoid.location == PlasmaCore.Types.BottomEdge; 0162 } 0163 0164 function clearList() { 0165 inputlistView.clear() 0166 } 0167 0168 function muteMicrophone() { 0169 if (!sourceModel.defaultSource) { 0170 return; 0171 } 0172 var toMute = !sourceModel.defaultSource.muted; 0173 sourceModel.defaultSource.muted = toMute; 0174 } 0175 0176 0177 function refreshAllSkills(){ 0178 getSkills(); 0179 msmskillsModel.reload(); 0180 } 0181 0182 function getAllSkills(){ 0183 if(skillList.length <= 0){ 0184 getSkills(); 0185 } 0186 return skillList; 0187 } 0188 function getSkillByName(skillName){ 0189 var tempSN=[]; 0190 for(var i = 0; i <skillList.length;i++){ 0191 var sList = skillList[i].name; 0192 if(sList.indexOf(skillName) !== -1){ 0193 tempSN.push(skillList[i]); 0194 } 0195 } 0196 return tempSN; 0197 } 0198 function getSkills() { 0199 var doc = new XMLHttpRequest() 0200 var url = "https://raw.githubusercontent.com/MycroftAI/mycroft-skills/master/.gitmodules" 0201 doc.open("GET", url, true); 0202 doc.send(); 0203 0204 doc.onreadystatechange = function() { 0205 if (doc.readyState === XMLHttpRequest.DONE) { 0206 var path, list; 0207 var tempRes = doc.responseText 0208 var moduleList = tempRes.split("["); 0209 for (var i = 1; i < moduleList.length; i++) { 0210 path = moduleList[i].substring(moduleList[i].indexOf("= ") + 2, moduleList[i].indexOf("url")).replace(/^\s+|\s+$/g, ''); 0211 url = moduleList[i].substring(moduleList[i].search("url =") + 6).replace(/^\s+|\s+$/g, ''); 0212 skillList[i-1] = {"name": path, "url": url}; 0213 msmskillsModel.reload(); 0214 } 0215 } 0216 } 0217 } 0218 0219 function getFileExtenion(filePath){ 0220 var ext = filePath.split('.').pop(); 0221 return ext; 0222 } 0223 0224 function validateFileExtension(filePath) { 0225 var ext = filePath.split('.').pop(); 0226 return ext === "jpg" || ext === "png" || ext === "jpeg" || ext === 'mp3' || ext === 'wav' || ext === 'mp4' 0227 } 0228 0229 function readFile(filename) { 0230 if (PlasmaLa.FileReader.file_exists_local(filename)) { 0231 try { 0232 var content = PlasmaLa.FileReader.read(filename).toString("utf-8"); 0233 return content; 0234 } catch (e) { 0235 console.log('Mycroft UI - Read File' + e); 0236 return 0; 0237 } 0238 } else { 0239 return 0; 0240 } 0241 } 0242 0243 function playwaitanim(recoginit){ 0244 switch(recoginit){ 0245 case "recognizer_loop:record_begin": 0246 suggst.outterAnim.aniRunWorking() 0247 break 0248 case "recognizer_loop:wakeword": 0249 suggst.outterAnim.aniRunHappy() 0250 break 0251 case "intent_failure": 0252 suggst.outterAnim.aniRunError() 0253 intentfailure = true 0254 break 0255 case "recognizer_loop:audio_output_start": 0256 break 0257 case "mycroft.skill.handler.complete": 0258 delay(1500, function() { 0259 intentfailure = false; 0260 }) 0261 break 0262 } 0263 } 0264 0265 function autoAppend(model, getinputstring, setinputstring) { 0266 for(var i = 0; i < model.count; ++i) 0267 if (getinputstring(model.get(i))){ 0268 console.log(model.get(i)) 0269 return true 0270 } 0271 return null 0272 } 0273 0274 function evalAutoLogic() { 0275 if (suggestionsBox.currentIndex === -1) { 0276 } else { 0277 suggestionsBox.complete(suggestionsBox.currentItem) 0278 } 0279 } 0280 0281 function filterplacesObj(metadata){ 0282 var filteredData = JSON.parse(metadata.data); 0283 var locallat = JSON.parse(metadata.locallat); 0284 var locallong = JSON.parse(metadata.locallong); 0285 var hereappid = metadata.appid 0286 var hereappcode = metadata.appcode; 0287 convoLmodel.clear() 0288 placesListModel.clear() 0289 for (var i = 0; i < filteredData.results.items.length; i++){ 0290 var itemsInPlaces = JSON.stringify(filteredData.results.items[i]) 0291 var fltritemsinPlc = JSON.parse(itemsInPlaces) 0292 var fltrtags = getTags(filteredData.results.items[i].tags) 0293 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}) 0294 } 0295 convoLmodel.append({"itemType": "PlacesType", "InputQuery": ""}); 0296 } 0297 0298 function getTags(fltrTags){ 0299 if(fltrTags){ 0300 var tags = ''; 0301 for (var i = 0; i < fltrTags.length; i++){ 0302 if(tags) 0303 tags += ', ' + fltrTags[i].title; 0304 else 0305 tags += fltrTags[i].title; 0306 } 0307 return tags; 0308 } 0309 return ''; 0310 } 0311 0312 function filterRecipeObj(metadata){ 0313 var filteredData = JSON.parse(metadata.data); 0314 convoLmodel.clear() 0315 recipeLmodel.clear() 0316 for (var i = 0; i < filteredData.hits.length; i++){ 0317 var itemsInRecipes = filteredData.hits[i].recipe 0318 var itemsReadRecipe = itemsInRecipes.ingredientLines.join(",") 0319 var itemsReadRecipeHealthTags = itemsInRecipes.healthLabels[0] 0320 var itemsReadRecipeDietType = itemsInRecipes.dietLabels.join(",") 0321 var itemsReadRecipeCalories = Math.round(itemsInRecipes.calories) 0322 if(itemsReadRecipeDietType == ""){ 0323 itemsReadRecipeDietType = "Normal" 0324 } 0325 recipeLmodel.insert(i, {recipeLabel: itemsInRecipes.label, recipeSource: itemsInRecipes.source, recipeImageUrl: itemsInRecipes.image, recipeCalories: itemsReadRecipeCalories, recipeIngredientLines: itemsReadRecipe, recipeDiet: itemsReadRecipeDietType, recipeHealthTags: itemsReadRecipeHealthTags}) 0326 } 0327 convoLmodel.append({"itemType": "RecipeType", "InputQuery": ""}) 0328 } 0329 0330 function filterBalooObj(metadata){ 0331 var BalooObj = metadata; 0332 var baloosearchTerm = metadata.searchType 0333 convoLmodel.clear() 0334 for (var i = 0; i < BalooObj.data.length; i++){ 0335 if(baloosearchTerm == "type:audio"){ 0336 convoLmodel.append({"itemType": "AudioFileType", "InputQuery": metadata.data[i]}) 0337 } 0338 if(baloosearchTerm == "type:video"){ 0339 convoLmodel.append({"itemType": "VideoFileType", "InputQuery": metadata.data[i]}) 0340 } 0341 if(baloosearchTerm == "type:document" || baloosearchTerm == "type:spreadsheet" || baloosearchTerm == "type:presentation" || baloosearchTerm == "type:archive" ){ 0342 convoLmodel.append({"itemType": "DocumentFileType", "InputQuery": metadata.data[i]}) 0343 } 0344 } 0345 } 0346 0347 function filterstackObj(metadata){ 0348 var filterStackMeta = JSON.parse(metadata.data) 0349 convoLmodel.clear() 0350 stackexListModel.clear() 0351 for (var i = 0; i < filterStackMeta.items.length; i++){ 0352 stackexListModel.insert(i, {sQuestion: filterStackMeta.items[i].title, sLink: filterStackMeta.items[i].link, sAuthor: filterStackMeta.items[i].owner.display_name, sIsAnswered: filterStackMeta.items[i].is_answered, sAnswerCount: filterStackMeta.items[i].answer_count}) 0353 } 0354 convoLmodel.append({"itemType": "StackObjType", "InputQuery": ""}) 0355 inputlistView.positionViewAtEnd(); 0356 } 0357 0358 function filterbookObj(metadata){ 0359 var filterBookMeta = JSON.parse(metadata.data) 0360 bookListModel.clear() 0361 bookListModel.append({bookcover: filterBookMeta.bkcover, bookurl: filterBookMeta.bkurl, bookstatus: filterBookMeta.bkstatus, booktitle: filterBookMeta.bktitle, bookauthor: filterBookMeta.bkauthor, bookdate: filterBookMeta.bkyear, bookpublisher: filterBookMeta.bkpublisher}) 0362 convoLmodel.append({"itemType": "BookType", "InputQuery": ""}) 0363 inputlistView.positionViewAtEnd(); 0364 } 0365 0366 function filterwikiObj(metadata){ 0367 var wikiSummary = JSON.stringify(metadata.data.summary) 0368 var wikiImage = JSON.stringify(metadata.data.image) 0369 wikiSummary = wikiSummary.replace(/['"]+/g, '') 0370 wikiImage = wikiImage.replace(/['"]+/g, '') 0371 convoLmodel.clear() 0372 wikiListModel.clear() 0373 wikiListModel.append({summary: wikiSummary, image: wikiImage}) 0374 convoLmodel.append({"itemType": "WikiType", "InputQuery": ""}) 0375 inputlistView.positionViewAtEnd(); 0376 } 0377 0378 function filterwikiMoreObj(metadata){ 0379 var wikiSummaryMore = JSON.stringify(metadata.data.summarymore) 0380 var wikiImageMore = JSON.stringify(metadata.data.imagemore) 0381 convoLmodel.clear() 0382 wikiListModel.clear() 0383 wikiSummaryMore = wikiSummaryMore.replace(/['"]+/g, '') 0384 wikiImageMore = wikiImageMore.replace(/['"]+/g, '') 0385 wikiListModel.append({summary: wikiSummaryMore, image: wikiImageMore}) 0386 convoLmodel.append({"itemType": "WikiType", "InputQuery": ""}) 0387 } 0388 0389 function filteryelpObj(metadata){ 0390 var filtermetayelp = metadata 0391 yelpListModel.clear() 0392 yelpListModel.append({'restaurant': filtermetayelp.data.restaurant, 'phone': filtermetayelp.data.phone, 'location': filtermetayelp.data.location, 'status': filtermetayelp.data.status, 'url': filtermetayelp.data.url, 'image_url': filtermetayelp.data.image_url, 'rating': filtermetayelp.data.rating}) 0393 convoLmodel.append({"itemType": "YelpType", "InputQuery": ""}) 0394 } 0395 0396 0397 0398 function fetchDashNews(){ 0399 var doc = new XMLHttpRequest() 0400 var url = 'https://newsapi.org/v2/top-headlines?' + 0401 'country=' + globalcountrycode + '&' + 0402 'apiKey=' + newsApiKeyTextFld.text; 0403 doc.open("GET", url, true); 0404 doc.send(); 0405 0406 doc.onreadystatechange = function() { 0407 if (doc.readyState === XMLHttpRequest.DONE) { 0408 var req = doc.responseText; 0409 var checkNewsItem = JSON.parse(req) 0410 if (checkNewsItem.totalResults == 0){ 0411 globalcountrycode = "us" 0412 fetchDashNews() 0413 } 0414 else { 0415 dashLmodel.append({"iType": "DashNews", "iObj": req}) 0416 } 0417 } 0418 } 0419 } 0420 0421 function fetchDashWeather(){ 0422 var doc = new XMLHttpRequest() 0423 var url = 'https://api.openweathermap.org/data/2.5/forecast?' + 0424 'lat=' + geoLat + '&lon=' + geoLong + '&units=' + weatherMetric + '&cnt=3' + 0425 '&APPID=' + owmApiKeyTextFld.text; 0426 0427 doc.open("GET", url, true); 0428 doc.send(); 0429 0430 doc.onreadystatechange = function() { 0431 if (doc.readyState === XMLHttpRequest.DONE) { 0432 var req = doc.responseText; 0433 dashLmodel.append({"iType": "DashWeather", "iObj": req}) 0434 } 0435 } 0436 } 0437 0438 function fetchDashCryptoCardData(){ 0439 var doc = new XMLHttpRequest 0440 var url = "https://min-api.cryptocompare.com/data/price?fsym=" + innerset.selectedCrypto + "&tsyms=" + innerset.selectedCur1 + "," + innerset.selectedCur2 + "," + innerset.selectedCur3 0441 doc.open("Get", url, true); 0442 doc.send(); 0443 0444 doc.onreadystatechange = function() { 0445 if (doc.readyState === XMLHttpRequest.DONE) { 0446 var req = doc.responseText; 0447 dashLmodel.append({"iType": "DashCryptoPrice", "iObj": req}) 0448 } 0449 } 0450 } 0451 0452 function updateCardData(){ 0453 tabBar.currentTab = mycroftTab 0454 convoLmodel.clear() 0455 showDash("setVisible") 0456 } 0457 0458 function setDisclaimer(){ 0459 dashLmodel.append({"iType": "Disclaimer", "iObj": "none"}) 0460 } 0461 0462 function globalDashRun(){ 0463 if(dashswitch.checked == true){ 0464 if(disclaimercardswitch.checked == true){ 0465 setDisclaimer() 0466 } 0467 if(newscardswitch.checked == true){ 0468 fetchDashNews() 0469 } 0470 if(weathercardswitch.checked == true){ 0471 fetchDashWeather() 0472 } 0473 if(cryptocardswitch.checked == true){ 0474 fetchDashCryptoCardData() 0475 } 0476 convoLmodel.append({"itemType": "DashboardType", "InputQuery": ""}) 0477 } 0478 else { 0479 convoLmodel.clear() 0480 if(mycroftStatusCheckSocket._socketIsAlreadyActive == true){ 0481 disclaimbox.visible = false 0482 } 0483 else { 0484 disclaimbox.visible = false 0485 } 0486 } 0487 } 0488 0489 function showDash(dashState){ 0490 switch(dashState){ 0491 case "setVisible": 0492 dashLmodel.clear() 0493 globalDashRun() 0494 break 0495 case "setHide": 0496 dashLmodel.clear() 0497 convoLmodel.clear() 0498 break 0499 } 0500 } 0501 0502 function getFallBackResult(failedQuery){ 0503 var url = "http://api.wolframalpha.com/v1/simple?appid=" + innerset.wolframKey + "&i=" + failedQuery + "&width=1024&fontsize=32" 0504 convoLmodel.append({"itemType": "FallBackType", "InputQuery": url}) 0505 } 0506 0507 ListModel { 0508 id: dashListModel 0509 } 0510 0511 ListModel { 0512 id: placesListModel 0513 } 0514 0515 ListModel{ 0516 id: recipesListModel 0517 } 0518 0519 ListModel { 0520 id: recipeReadListModel 0521 } 0522 0523 ListModel { 0524 id: stackexListModel 0525 } 0526 0527 ListModel { 0528 id: bookListModel 0529 } 0530 0531 ListModel { 0532 id: wikiListModel 0533 } 0534 ListModel { 0535 id: yelpListModel 0536 } 0537 0538 PlasmaCore.DataSource { 0539 id: dataSource 0540 dataEngine: "geolocation" 0541 connectedSources: ["location"] 0542 0543 onNewData: { 0544 if (sourceName == "location"){ 0545 geoLat = data.latitude 0546 geoLong = data.longitude 0547 globalDashRun() 0548 0549 } 0550 } 0551 } 0552 0553 Timer { 0554 id: timer 0555 } 0556 0557 function delay(delayTime, cb) { 0558 timer.interval = delayTime; 0559 timer.repeat = false; 0560 timer.triggered.connect(cb); 0561 timer.start(); 0562 } 0563 0564 Rectangle { 0565 id: topBar 0566 Layout.fillWidth: true 0567 color: theme.backgroundColor 0568 height: units.gridUnit * 2 0569 z: 101 0570 anchors { 0571 top: main.top 0572 topMargin: -1 0573 left: main.left 0574 leftMargin: -1 0575 right: main.right 0576 rightMargin: -1 0577 } 0578 0579 0580 Item { 0581 id: topBarBGrect 0582 anchors.fill: parent 0583 z: 101 0584 0585 PlasmaComponents.TabBar { 0586 id: tabBar 0587 anchors.left: parent.left 0588 anchors.right: topbarDividerline.left 0589 anchors.top: parent.top 0590 anchors.bottom: parent.bottom 0591 0592 PlasmaComponents.TabButton { 0593 id: mycroftTab 0594 Layout.fillHeight: true 0595 Layout.fillWidth: true 0596 iconSource: "go-home" 0597 0598 PlasmaCore.ToolTipArea { 0599 id: tooltiptab1 0600 mainText: i18n("Home Tab") 0601 anchors.fill: parent 0602 } 0603 } 0604 0605 PlasmaComponents.TabButton { 0606 id: mycroftSkillsTab 0607 Layout.fillHeight: true 0608 Layout.fillWidth: true 0609 iconSource: "games-hint" 0610 0611 PlasmaCore.ToolTipArea { 0612 id: tooltiptab2 0613 mainText: i18n("Skills Tab") 0614 anchors.fill: parent 0615 } 0616 } 0617 0618 PlasmaComponents.TabButton { 0619 id: mycroftSettingsTab 0620 Layout.fillHeight: true 0621 anchors.right: mycroftMSMinstTab.left 0622 Layout.fillWidth: true 0623 iconSource: "games-config-options" 0624 0625 PlasmaCore.ToolTipArea { 0626 id: tooltiptab3 0627 mainText: i18n("Settings Tab") 0628 anchors.fill: parent 0629 } 0630 } 0631 0632 PlasmaComponents.TabButton { 0633 id: mycroftMSMinstTab 0634 anchors.right: parent.right 0635 Layout.fillHeight: true 0636 Layout.fillWidth: true 0637 iconSource: "kmouth-phresebook-new" 0638 0639 0640 PlasmaCore.ToolTipArea { 0641 id: tooltiptab4 0642 mainText: i18n("Skill Installs Tab") 0643 anchors.fill: parent 0644 } 0645 } 0646 } 0647 0648 PlasmaCore.SvgItem { 0649 id: topbarDividerline 0650 anchors { 0651 right: mycroftstartservicebutton.left 0652 rightMargin: units.gridUnit * 0.25 0653 top: parent.top 0654 topMargin: 0 0655 bottom: parent.bottom 0656 bottomMargin: 0 0657 } 0658 0659 width: linetopvertSvg.elementSize("vertical-line").width 0660 z: 110 0661 elementId: "vertical-line" 0662 0663 svg: PlasmaCore.Svg { 0664 id: linetopvertSvg; 0665 imagePath: "widgets/line" 0666 } 0667 } 0668 0669 0670 SwitchButton { 0671 anchors.right: parent.right 0672 anchors.verticalCenter: topBarBGrect.verticalCenter 0673 id: mycroftstartservicebutton 0674 checked: false 0675 width: Math.round(units.gridUnit * 2) 0676 height: width 0677 z: 102 0678 0679 onClicked: { 0680 if (mycroftstartservicebutton.checked === false) { 0681 PlasmaLa.LaunchApp.runCommand("bash", coreinstallstoppath); 0682 convoLmodel.clear() 0683 suggst.visible = true; 0684 socket.active = false; 0685 showDash("setVisible") 0686 } 0687 0688 if (mycroftstartservicebutton.checked === true) { 0689 disclaimbox.visible = false; 0690 PlasmaLa.LaunchApp.runCommand("bash", coreinstallstartpath); 0691 if(dashswitch.checked == "false"){ 0692 convoLmodel.clear() 0693 } 0694 suggst.visible = true; 0695 delay(15000, function() { 0696 socket.active = true; 0697 }) 0698 } 0699 0700 } 0701 } 0702 } 0703 } 0704 0705 PlasmaCore.SvgItem { 0706 anchors { 0707 left: main.left 0708 right: main.right 0709 top: root.top 0710 } 0711 width: 1 0712 height: horlinetopbarSvg.elementSize("horizontal-line").height 0713 0714 elementId: "horizontal-line" 0715 z: 110 0716 svg: PlasmaCore.Svg { 0717 id: horlinetopbarSvg; 0718 imagePath: "widgets/line" 0719 } 0720 } 0721 0722 Rectangle { 0723 id: root 0724 anchors { 0725 top: topBar.bottom 0726 bottom: rectanglebottombar.top 0727 left: parent.left 0728 right: parent.right 0729 } 0730 color: theme.backgroundColor 0731 0732 WebSocket { 0733 id: mycroftStatusCheckSocket 0734 url: innerset.wsurl 0735 active: true 0736 onStatusChanged: 0737 if (mycroftStatusCheckSocket.status == WebSocket.Open && socket.status == WebSocket.Closed) { 0738 console.log("Activated") 0739 socket.active = true 0740 disclaimbox.visible = false; 0741 mycroftstartservicebutton.checked = true 0742 } 0743 0744 else if (mycroftStatusCheckSocket.status == WebSocket.Error) { 0745 mycroftstartservicebutton.checked = false 0746 } 0747 } 0748 0749 WebSocket { 0750 id: socket 0751 url: innerset.wsurl 0752 onTextMessageReceived: { 0753 var somestring = JSON.parse(message) 0754 var msgType = somestring.type; 0755 playwaitanim(msgType); 0756 qinput.focus = false; 0757 suggst.talkingAnim.wsistalking() 0758 0759 if (msgType === "mycroft.mic.get_status.response") { 0760 var micState = somestring.data.muted 0761 if(micState) { 0762 micIsMuted = true 0763 qinputmicbx.iconSource = "mic-off" 0764 } 0765 else if(!micState) { 0766 micIsMuted = false 0767 qinputmicbx.iconSource = "mic-on" 0768 } 0769 } 0770 0771 if (msgType === "recognizer_loop:utterance") { 0772 var intpost = somestring.data.utterances; 0773 qinput.text = intpost.toString() 0774 convoLmodel.append({"itemType": "AskType", "InputQuery": intpost.toString()}) 0775 } 0776 0777 if (msgType === "recognizer_loop:utterance" && dashLmodel.count != 0){ 0778 showDash("setHide") 0779 } 0780 0781 if (somestring.data.handler === "fallback" && somestring.data.fallback_handler === "WolframAlphaSkill.handle_fallback" && somestring.type === "mycroft.skill.handler.complete"){ 0782 if(wolframfallbackswitch.checked == true){ 0783 getFallBackResult(qinput.text) 0784 } 0785 } 0786 0787 if (somestring && somestring.data && typeof somestring.data.intent_type !== 'undefined'){ 0788 smintent = somestring.data.intent_type; 0789 console.log('intent type: ' + smintent); 0790 } 0791 0792 if(somestring && somestring.data && typeof somestring.data.utterance !== 'undefined' && somestring.type === 'speak'){ 0793 filterSpeak(somestring.data.utterance); 0794 } 0795 0796 if(somestring && somestring.data && typeof somestring.data.desktop !== 'undefined' && somestring.type === "data") { 0797 dataContent = somestring.data.desktop 0798 filterincoming(smintent, dataContent) 0799 } 0800 0801 if(somestring && somestring.data && typeof somestring.data.desktop !== 'undefined' && somestring.type === "visualObject") { 0802 dataContent = somestring.data.desktop 0803 filtervisualObj(dataContent) 0804 } 0805 0806 if(somestring && somestring.data && typeof somestring.data.desktop !== 'undefined' && somestring.type === "placesObject") { 0807 dataContent = somestring.data.desktop 0808 filterplacesObj(dataContent) 0809 } 0810 0811 if(somestring && somestring.data && typeof somestring.data.desktop !== 'undefined' && somestring.type === "recipesObject") { 0812 dataContent = somestring.data.desktop 0813 filterRecipeObj(dataContent) 0814 } 0815 0816 if(somestring && somestring.data && typeof somestring.data.desktop !== 'undefined' && somestring.type === "balooObject") { 0817 dataContent = somestring.data.desktop 0818 filterBalooObj(dataContent) 0819 } 0820 0821 if(somestring && somestring.data && typeof somestring.data.desktop !== 'undefined' && somestring.type === "stackresponseObject") { 0822 dataContent = somestring.data.desktop 0823 filterstackObj(dataContent) 0824 } 0825 0826 if(somestring && somestring.data && typeof somestring.data.desktop !== 'undefined' && somestring.type === "bookObject") { 0827 dataContent = somestring.data.desktop 0828 filterbookObj(dataContent) 0829 } 0830 0831 if(somestring && somestring.data && typeof somestring.data.desktop !== 'undefined' && somestring.type === "wikiObject") { 0832 dataContent = somestring.data.desktop 0833 filterwikiObj(dataContent) 0834 } 0835 0836 if(somestring && somestring.data && typeof somestring.data.desktop !== 'undefined' && somestring.type === "wikiaddObject") { 0837 dataContent = somestring.data.desktop 0838 filterwikiMoreObj(dataContent) 0839 } 0840 0841 if(somestring && somestring.data && typeof somestring.data.desktop !== 'undefined' && somestring.type === "yelpObject") { 0842 dataContent = somestring.data.desktop 0843 filteryelpObj(dataContent) 0844 } 0845 0846 if (msgType === "speak" && !plasmoid.expanded && notificationswitch.checked == true) { 0847 var post = somestring.data.utterance; 0848 var title = "Mycroft's Reply:" 0849 var notiftext = " "+ post; 0850 PlasmaLa.Notify.mycroftResponse(title, notiftext); 0851 } 0852 } 0853 } 0854 0855 ColumnLayout { 0856 id: mycroftcolumntab 0857 visible: tabBar.currentTab == mycroftTab; 0858 anchors.top: root.top 0859 anchors.left: root.left 0860 anchors.leftMargin: units.gridUnit * 0.25 0861 anchors.right: root.right 0862 anchors.bottom: root.bottom 0863 0864 Rectangle { 0865 id: rectangle2 0866 color: "#00000000" 0867 anchors.top: mycroftcolumntab.top 0868 anchors.topMargin:15 0869 anchors.left: mycroftcolumntab.left 0870 anchors.right: mycroftcolumntab.right 0871 anchors.bottom: mycroftcolumntab.bottom 0872 0873 DropArea { 0874 anchors.fill: parent; 0875 id: dragTarget 0876 onEntered: { 0877 for(var i = 0; i < drag.urls.length; i++) 0878 if(validateFileExtension(drag.urls[i])) 0879 return 0880 console.log("No valid files, refusing drag event") 0881 drag.accept() 0882 dragTarget.enabled = false 0883 } 0884 0885 onDropped: { 0886 for(var i = 0; i < drop.urls.length; i++){ 0887 var ext = getFileExtenion(drop.urls[i]); 0888 if(ext === "jpg" || ext === "png" || ext === "jpeg"){ 0889 var durl = String(drop.urls[i]); 0890 console.log(durl) 0891 convoLmodel.append({ 0892 "itemType": "DropImg", 0893 "InputQuery": durl 0894 }) 0895 inputlistView.positionViewAtEnd(); 0896 0897 0898 var irecogmsgsend = innerset.customrecog 0899 var socketmessage = {}; 0900 socketmessage.type = "recognizer_loop:utterance"; 0901 socketmessage.data = {}; 0902 socketmessage.data.utterances = [irecogmsgsend + " " + durl]; 0903 socket.sendTextMessage(JSON.stringify(socketmessage)); 0904 console.log(irecogmsgsend + " " + durl); 0905 } 0906 0907 if(ext === 'mp3'){ 0908 console.log('mp3'); 0909 } 0910 } 0911 } 0912 0913 0914 Disclaimer{ 0915 id: disclaimbox 0916 visible: false 0917 } 0918 0919 ListModel{ 0920 id: convoLmodel 0921 } 0922 0923 Rectangle { 0924 id: messageBox 0925 anchors.fill: parent 0926 anchors.right: dragTarget.right 0927 anchors.left: dragTarget.left 0928 color: "#00000000" 0929 0930 ColumnLayout { 0931 id: colconvo 0932 anchors.fill: parent 0933 0934 ListView { 0935 id: inputlistView 0936 Layout.fillWidth: true 0937 Layout.fillHeight: true 0938 verticalLayoutDirection: ListView.TopToBottom 0939 spacing: 12 0940 clip: true 0941 model: convoLmodel 0942 ScrollBar.vertical: ScrollBar {} 0943 delegate: Component { 0944 Loader { 0945 source: switch(itemType) { 0946 case "NonVisual": return "SimpleMessageType.qml" 0947 case "WebViewType": return "WebViewType.qml" 0948 case "CurrentWeather": return "CurrentWeatherType.qml" 0949 case "DropImg" : return "ImgRecogType.qml" 0950 case "AskType" : return "AskMessageType.qml" 0951 case "LoaderType" : return "LoaderType.qml" 0952 case "PlacesType" : return "PlacesType.qml" 0953 case "RecipeType" : return "RecipeType.qml" 0954 case "DashboardType" : return "DashboardType.qml" 0955 case "AudioFileType" : return "AudioFileDelegate.qml" 0956 case "VideoFileType" : return "VideoFileDelegate.qml" 0957 case "DocumentFileType" : return "DocumentFileDelegate.qml" 0958 case "FallBackType" : return "FallbackWebSearchType.qml" 0959 case "StackObjType" : return "StackObjType.qml" 0960 case "BookType" : return "BookType.qml" 0961 case "WikiType" : return "WikiType.qml" 0962 case "YelpType" : return "YelpType.qml" 0963 } 0964 property var metacontent : dataContent 0965 } 0966 } 0967 0968 onCountChanged: { 0969 inputlistView.positionViewAtEnd(); 0970 } 0971 } 0972 } 0973 } 0974 } 0975 } 0976 } 0977 0978 ColumnLayout { 0979 id: mycroftSkillscolumntab 0980 visible: tabBar.currentTab == mycroftSkillsTab; 0981 anchors.top: root.top 0982 anchors.left: root.left 0983 anchors.leftMargin: units.gridUnit * 0.25 0984 anchors.right: root.right 0985 anchors.bottom: root.bottom 0986 0987 ListView { 0988 id: skillslistmodelview 0989 anchors.top: parent.top 0990 anchors.topMargin: 5 0991 anchors.left: parent.left 0992 anchors.right: parent.right 0993 anchors.bottom: parent.bottom 0994 model: SkillModel{} 0995 delegate: SkillView{} 0996 spacing: 4 0997 focus: false 0998 interactive: true 0999 clip: true; 1000 } 1001 1002 } 1003 1004 ColumnLayout { 1005 id: mycroftSettingsColumn 1006 visible: tabBar.currentTab == mycroftSettingsTab; 1007 anchors.top: root.top 1008 anchors.left: root.left 1009 anchors.leftMargin: units.gridUnit * 0.25 1010 anchors.right: root.right 1011 anchors.bottom: root.bottom 1012 1013 PlasmaComponents.TabBar { 1014 id: settingstabBar 1015 anchors.top: parent.top 1016 anchors.left: parent.left 1017 anchors.right: parent. right 1018 height: units.gridUnit * 2 1019 tabPosition: Qt.TopEdge; 1020 1021 PlasmaComponents.TabButton { 1022 id: generalSettingsTab 1023 text: "General" 1024 } 1025 1026 PlasmaComponents.TabButton { 1027 id: dashSettingsTab 1028 text: "Dash" 1029 } 1030 } 1031 1032 Item { 1033 id: settingscontent 1034 Layout.fillWidth: true; 1035 Layout.fillHeight: true; 1036 anchors.top: settingstabBar.bottom 1037 anchors.topMargin: units.gridUnit * 0.50 1038 anchors.left: parent.left 1039 anchors.right: parent.right 1040 anchors.bottom: parent.bottom 1041 visible: settingstabBar.currentTab == generalSettingsTab; 1042 1043 Flickable { 1044 id: settingFlick 1045 anchors.fill: parent; 1046 contentWidth: mycroftSettingsColumn.width 1047 contentHeight: units.gridUnit * 22 1048 clip: true; 1049 1050 PlasmaComponents.Label { 1051 id: settingsTabUnits 1052 anchors.top: parent.top; 1053 anchors.topMargin: 5 1054 text: i18n("<i>Your Mycroft Core Installation Path</i>") 1055 } 1056 1057 PlasmaComponents.ButtonColumn { 1058 id: radiobuttonColoumn 1059 anchors.top: settingsTabUnits.bottom 1060 anchors.topMargin: 5 1061 1062 PlasmaComponents.RadioButton { 1063 id: settingsTabUnitsOpZero 1064 exclusiveGroup: installPathGroup 1065 text: i18n("Default Path") 1066 checked: true 1067 1068 onCheckedChanged: { 1069 locationUserSelected = true 1070 if (settingsTabUnitsOpZero.checked === true && coreinstallstartpath === packagemcorestartcmd) { 1071 coreinstallstartpath = defaultmcorestartpath; 1072 } 1073 else if (settingsTabUnitsOpZero.checked === true && coreinstallstartpath === customlocstartpath) { 1074 coreinstallstartpath = defaultmcorestartpath; 1075 } 1076 1077 if (settingsTabUnitsOpZero.checked === true && coreinstallstoppath === packagemcorestopcmd) { 1078 coreinstallstoppath = defaultmcorestoppath; 1079 } 1080 1081 else if (settingsTabUnitsOpZero.checked === true && coreinstallstoppath === customlocstoppath) { 1082 coreinstallstoppath = defaultmcorestoppath; 1083 } 1084 } 1085 } 1086 1087 PlasmaComponents.RadioButton { 1088 id: settingsTabUnitsOpOne 1089 exclusiveGroup: installPathGroup 1090 text: i18n("Installed Using Mycroft Package") 1091 checked: false 1092 1093 onCheckedChanged: { 1094 1095 if (settingsTabUnitsOpOne.checked === true && coreinstallstartpath === defaultmcorestartpath) { 1096 coreinstallstartpath = packagemcorestartcmd; 1097 } 1098 else if (settingsTabUnitsOpOne.checked === true && coreinstallstartpath === customlocstartpath) { 1099 coreinstallstartpath = packagemcorestartcmd; 1100 } 1101 1102 if (settingsTabUnitsOpOne.checked === true && coreinstallstoppath === defaultmcorestoppath) { 1103 coreinstallstoppath = packagemcorestopcmd; 1104 } 1105 1106 else if (settingsTabUnitsOpOne.checked === true && coreinstallstoppath === customlocstoppath) { 1107 coreinstallstoppath = packagemcorestopcmd; 1108 } 1109 } 1110 } 1111 1112 PlasmaComponents.RadioButton { 1113 id: settingsTabUnitsOpTwo 1114 exclusiveGroup: installPathGroup 1115 text: i18n("Location of Mycroft-Core Directory") 1116 checked: false 1117 1118 onCheckedChanged: { 1119 locationUserSelected = true 1120 if (settingsTabUnitsOpTwo.checked === true && coreinstallstartpath === defaultmcorestartpath) { 1121 coreinstallstartpath = customlocstartpath; 1122 } 1123 else if (settingsTabUnitsOpTwo.checked === true && coreinstallstartpath === packagemcorestartcmd) { 1124 coreinstallstartpath = customlocstartpath; 1125 } 1126 1127 if (settingsTabUnitsOpTwo.checked === true && coreinstallstoppath === defaultmcorestoppath) { 1128 coreinstallstoppath = customlocstoppath; 1129 } 1130 1131 else if (settingsTabUnitsOpTwo.checked === true && coreinstallstoppath === packagemcorestopcmd) { 1132 coreinstallstoppath = customlocstoppath; 1133 } 1134 1135 } 1136 } 1137 } 1138 1139 PlasmaComponents.TextField { 1140 id: settingsTabUnitsOpThree 1141 width: settingscontent.width / 1.1 1142 anchors.top: radiobuttonColoumn.bottom 1143 anchors.topMargin: 10 1144 placeholderText: i18n("<custom location>/mycroft-core/") 1145 1146 onTextChanged: { 1147 var cstloc = settingsTabUnitsOpThree.text 1148 customloc = cstloc 1149 } 1150 } 1151 1152 PlasmaComponents.Button { 1153 id: acceptcustomPath 1154 anchors.left: settingsTabUnitsOpThree.right 1155 anchors.verticalCenter: settingsTabUnitsOpThree.verticalCenter 1156 anchors.right: parent.right 1157 iconSource: "checkbox" 1158 1159 onClicked: { 1160 var cstlocl = customloc 1161 var ctstart = cstlocl + "start-mycroft.sh all" 1162 var ctstop = cstlocl + "stop-mycroft.sh" 1163 startsrvcustom.text = ctstart 1164 stopsrvcustom.text = ctstop 1165 console.log(startsrvcustom.text) 1166 } 1167 } 1168 1169 PlasmaComponents.TextField { 1170 id: settingsTabUnitsWSpath 1171 width: settingscontent.width / 1.1 1172 anchors.top: settingsTabUnitsOpThree.bottom 1173 anchors.topMargin: 10 1174 placeholderText: i18n("ws://0.0.0.0:8181/core") 1175 text: i18n("ws://0.0.0.0:8181/core") 1176 } 1177 1178 PlasmaComponents.Button { 1179 id: acceptcustomWSPath 1180 anchors.left: settingsTabUnitsWSpath.right 1181 anchors.verticalCenter: settingsTabUnitsWSpath.verticalCenter 1182 anchors.right: parent.right 1183 iconSource: "checkbox" 1184 1185 onClicked: { 1186 innerset.wsurl = settingsTabUnitsWSpath.text 1187 } 1188 } 1189 1190 1191 PlasmaComponents.TextField { 1192 id: settingsTabUnitsIRCmd 1193 width: settingscontent.width / 1.1 1194 anchors.top: settingsTabUnitsWSpath.bottom 1195 anchors.topMargin: 10 1196 placeholderText: i18n("Your Custom Image Recognition Skill Voc Keywords") 1197 text: i18n("search image url") 1198 } 1199 1200 PlasmaComponents.Button { 1201 id: acceptcustomIRCmd 1202 anchors.left: settingsTabUnitsIRCmd.right 1203 anchors.verticalCenter: settingsTabUnitsIRCmd.verticalCenter 1204 anchors.right: parent.right 1205 iconSource: "checkbox" 1206 } 1207 1208 1209 PlasmaComponents.TextField { 1210 id: settingsTabUnitsOCRCmd 1211 width: settingscontent.width / 1.1 1212 anchors.top: settingsTabUnitsIRCmd.bottom 1213 anchors.topMargin: 10 1214 placeholderText: i18n("Your Custom Image OCR Skill Voc Keywords") 1215 text: i18n("ocr image url") 1216 } 1217 1218 PlasmaComponents.Button { 1219 id: acceptcustomOCRCmd 1220 anchors.left: settingsTabUnitsOCRCmd.right 1221 anchors.verticalCenter: settingsTabUnitsOCRCmd.verticalCenter 1222 anchors.right: parent.right 1223 iconSource: "checkbox" 1224 } 1225 1226 1227 PlasmaComponents.Switch { 1228 id: notificationswitch 1229 anchors.top: settingsTabUnitsOCRCmd.bottom 1230 anchors.topMargin: 10 1231 text: i18n("Enable Notifications") 1232 checked: true 1233 } 1234 1235 1236 PlasmaComponents.Switch { 1237 id: wolframfallbackswitch 1238 anchors.top: notificationswitch.bottom 1239 anchors.topMargin: 10 1240 text: i18n("Enable Fallback To Wolfram Alpha Web-Search") 1241 checked: true 1242 } 1243 1244 PlasmaComponents.Label { 1245 id: wolframkeylabel 1246 text: i18n("Wolfram Alpha API:") 1247 anchors.top: wolframfallbackswitch.bottom 1248 anchors.topMargin: 10 1249 } 1250 1251 PlasmaComponents.TextField { 1252 id: wolframapikeyfld 1253 anchors.right: parent.right 1254 anchors.rightMargin: units.gridUnit * 0.25 1255 anchors.left: wolframkeylabel.right 1256 anchors.leftMargin: units.gridUnit * 0.25 1257 anchors.verticalCenter: wolframkeylabel.verticalCenter 1258 text: i18n("RJVUY3-T6YLWQVXRR") 1259 } 1260 1261 PlasmaExtras.Paragraph { 1262 id: settingsTabTF2 1263 anchors.top: wolframapikeyfld.bottom 1264 anchors.topMargin: 15 1265 text: i18n("<i>Please Note: Default path is set to /home/$USER/mycroft-core/. Change the above settings to match your installation</i>") 1266 } 1267 1268 PlasmaComponents.Label { 1269 id: startsrvcustom 1270 visible: false 1271 } 1272 1273 PlasmaComponents.Label { 1274 id: stopsrvcustom 1275 visible: false 1276 } 1277 } 1278 } 1279 1280 Item { 1281 id: dashsettingscontent 1282 Layout.fillWidth: true; 1283 Layout.fillHeight: true; 1284 anchors.top: settingstabBar.bottom 1285 anchors.topMargin: units.gridUnit * 0.50 1286 anchors.left: parent.left 1287 anchors.right: parent.right 1288 anchors.bottom: parent.bottom 1289 visible: settingstabBar.currentTab == dashSettingsTab; 1290 1291 Flickable { 1292 id: dashsettingFlick 1293 anchors.fill: parent; 1294 contentWidth: mycroftSettingsColumn.width 1295 contentHeight: units.gridUnit * 22 1296 clip: true; 1297 1298 Column { 1299 spacing: 6 1300 1301 PlasmaComponents.Switch { 1302 id: dashswitch 1303 text: i18n("Enable / Disable Dashboard") 1304 checked: true 1305 1306 onCheckedChanged: { 1307 if(dashswitch.checked){ 1308 tabBar.currentTab = mycroftTab 1309 disclaimbox.visible = false 1310 showDash("setVisible") 1311 } 1312 else if(!dashswitch.checked){ 1313 convoLmodel.clear() 1314 if(!socket.active){ 1315 disclaimbox.visible = true 1316 } 1317 } 1318 } 1319 } 1320 1321 PlasmaComponents.Label { 1322 id: dashSettingsLabel1 1323 text: i18n("Card Settings:") 1324 font.bold: true; 1325 } 1326 1327 PlasmaComponents.Switch { 1328 id: disclaimercardswitch 1329 text: i18n("Enable / Disable Disclaimer Card") 1330 checked: true 1331 } 1332 1333 PlasmaComponents.Switch { 1334 id: newscardswitch 1335 text: i18n("Enable / Disable News Card") 1336 checked: true 1337 } 1338 1339 PlasmaComponents.Switch { 1340 id: cryptocardswitch 1341 text: i18n("Enable / Disable Cryptocurrency Card") 1342 checked: false 1343 } 1344 1345 Row { 1346 spacing: 2 1347 PlasmaComponents.Label{ 1348 id: cryptoCurrencySelected 1349 text: "Selected CryptoCurrency:" 1350 } 1351 PlasmaComponents3.ComboBox { 1352 id: cryptoSelectedBox 1353 textRole: "cryptoname" 1354 displayText: currentText 1355 model: CrypCurModel{} 1356 property string cryptInfo: cryptoSelectedBox.model.get(currentIndex).value 1357 } 1358 } 1359 1360 PlasmaComponents.Label{ 1361 id: localCurrencySelected 1362 text: "Display Currencies:" 1363 } 1364 1365 PlasmaComponents3.ComboBox { 1366 id: cryptoSelectCur1 1367 textRole: "currencyname" 1368 displayText: currentText 1369 model: CurModel{} 1370 property string cur1Info: cryptoSelectCur1.model.get(currentIndex).value 1371 } 1372 1373 PlasmaComponents3.ComboBox { 1374 id: cryptoSelectCur2 1375 textRole: "currencyname" 1376 displayText: currentText 1377 model: CurModel{} 1378 property string cur2Info: cryptoSelectCur2.model.get(currentIndex).value 1379 } 1380 1381 PlasmaComponents3.ComboBox { 1382 id: cryptoSelectCur3 1383 textRole: "currencyname" 1384 displayText: currentText 1385 model: CurModel{} 1386 property string cur3Info: cryptoSelectCur3.model.get(currentIndex).value 1387 } 1388 1389 Row { 1390 spacing: 2 1391 PlasmaComponents.Label { 1392 id: newsApiKeyLabelFld 1393 text: "NewsApi App_Key:" 1394 } 1395 PlasmaComponents.TextField{ 1396 id: newsApiKeyTextFld 1397 width: units.gridUnit * 12 1398 text: "a1091945307b434493258f3dd6f36698" 1399 } 1400 } 1401 1402 PlasmaComponents.Switch { 1403 id: weathercardswitch 1404 text: i18n("Enable / Disable Weather Card") 1405 checked: true 1406 } 1407 1408 Row { 1409 spacing: 2 1410 PlasmaComponents.Label { 1411 id: owmApiKeyLabelFld 1412 text: "Open Weather Map App_ID:" 1413 } 1414 PlasmaComponents.TextField{ 1415 id: owmApiKeyTextFld 1416 width: units.gridUnit * 12 1417 text: "7af5277aee7a659fc98322c4517d3df7" 1418 } 1419 } 1420 1421 Row{ 1422 id: weatherCardMetricsRowList 1423 spacing: 2 1424 1425 PlasmaComponents.Button { 1426 id: owmApiKeyMetricCel 1427 text: i18n("Celcius") 1428 onClicked: { 1429 weatherMetric = "metric" 1430 updateCardData() 1431 } 1432 } 1433 PlasmaComponents.Button{ 1434 id: owmApiKeyMetricFar 1435 text: i18n("Fahrenheit") 1436 onClicked: { 1437 weatherMetric = "imperial" 1438 updateCardData() 1439 } 1440 } 1441 } 1442 1443 } 1444 } 1445 } 1446 } 1447 1448 ColumnLayout { 1449 id: mycroftMsmColumn 1450 visible: tabBar.currentTab == mycroftMSMinstTab; 1451 anchors.top: root.top 1452 anchors.left: root.left 1453 anchors.leftMargin: units.gridUnit * 0.25 1454 anchors.right: root.right 1455 anchors.bottom: root.bottom 1456 1457 Item { 1458 id: msmtabtopbar 1459 width: parent.width 1460 anchors.left: parent.left 1461 anchors.right: parent.right 1462 height: units.gridUnit * 2 1463 1464 PlasmaComponents.TextField { 1465 id: msmsearchfld 1466 anchors.left: parent.left 1467 anchors.top: parent.top 1468 anchors.bottom: parent.bottom 1469 anchors.right: getskillsbx.left 1470 placeholderText: i18n("Search Skills") 1471 clearButtonShown: true 1472 1473 onTextChanged: { 1474 if(text.length > 0 ) { 1475 msmskillsModel.applyFilter(text.toLowerCase()); 1476 } else { 1477 msmskillsModel.reload(); 1478 } 1479 } 1480 } 1481 1482 PlasmaComponents.ToolButton { 1483 id: getskillsbx 1484 anchors.right: parent.right 1485 anchors.top: parent.top 1486 anchors.bottom: parent.bottom 1487 iconSource: "view-refresh" 1488 tooltip: i18n("Refresh List") 1489 flat: true 1490 width: Math.round(units.gridUnit * 2) 1491 height: width 1492 z: 102 1493 1494 onClicked: { 1495 msmskillsModel.clear(); 1496 refreshAllSkills(); 1497 } 1498 } 1499 } 1500 1501 ListModel { 1502 id: msmskillsModel 1503 1504 Component.onCompleted: { 1505 reload(); 1506 //console.log('Completing too early?'); 1507 } 1508 1509 function reload() { 1510 var skList = getAllSkills(); 1511 msmskillsModel.clear(); 1512 for( var i=0; i < skList.length ; ++i ) { 1513 msmskillsModel.append(skList[i]); 1514 } 1515 } 1516 1517 function applyFilter(skName) { 1518 var skList = getSkillByName(skName); 1519 msmskillsModel.clear(); 1520 for( var i=0; i < skList.length ; ++i ) { 1521 msmskillsModel.append(skList[i]); 1522 } 1523 } 1524 } 1525 1526 ListView { 1527 id: msmlistView 1528 anchors.top: msmtabtopbar.bottom 1529 anchors.topMargin: 5 1530 anchors.left: parent.left 1531 anchors.right: parent.right 1532 anchors.bottom: parent.bottom 1533 model: msmskillsModel 1534 delegate: MsmView{} 1535 spacing: 4 1536 focus: false 1537 interactive: true 1538 clip: true; 1539 1540 } 1541 } 1542 } 1543 1544 SourceModel { 1545 id: sourceModel 1546 } 1547 1548 PlasmaCore.SvgItem { 1549 anchors { 1550 left: main.left 1551 right: main.right 1552 bottom: root.bottom 1553 } 1554 width: 1 1555 height: horlineSvg.elementSize("horizontal-line").height 1556 1557 elementId: "horizontal-line" 1558 z: 110 1559 svg: PlasmaCore.Svg { 1560 id: horlineSvg; 1561 imagePath: "widgets/line" 1562 } 1563 } 1564 1565 Item { 1566 id: expandbartxtinput 1567 height: units.gridUnit * 3.5 1568 anchors.bottom: rectanglebottombar.top 1569 anchors.left: parent.left 1570 anchors.right: parent.right 1571 z: 1001 1572 visible: false 1573 1574 Rectangle { 1575 id: topBarSecondary 1576 anchors.fill: parent 1577 color: theme.backgroundColor 1578 height: units.gridUnit * 3.5 1579 z: 101 1580 1581 ListModel { 1582 id: completionItems 1583 } 1584 1585 PlasmaComponents.TextField { 1586 id: qinput 1587 anchors.fill: parent 1588 placeholderText: i18n("Enter Query or Say 'Hey Mycroft'") 1589 clearButtonShown: true 1590 1591 onAccepted: { 1592 var doesExist = autoAppend(autoCompModel, function(item) { return item.name === qinput.text }, qinput.text) 1593 var evaluateExist = doesExist 1594 if(evaluateExist === null){ 1595 autoCompModel.append({"name": qinput.text}); 1596 } 1597 suggst.visible = true; 1598 var socketmessage = {}; 1599 socketmessage.type = "recognizer_loop:utterance"; 1600 socketmessage.data = {}; 1601 socketmessage.data.utterances = [qinput.text]; 1602 socket.sendTextMessage(JSON.stringify(socketmessage)); 1603 qinput.text = ""; 1604 } 1605 1606 onTextChanged: { 1607 //var terms = getTermsForSearchString(qinput.text); 1608 evalAutoLogic(); 1609 } 1610 } 1611 1612 AutocompleteBox { 1613 id: suggestionsBox 1614 model: completionItems 1615 width: parent.width 1616 anchors.bottom: qinput.top 1617 anchors.left: parent.left 1618 anchors.right: parent.right 1619 filter: textInput.text 1620 property: "name" 1621 onItemSelected: complete(item) 1622 1623 function complete(item) { 1624 if (item !== undefined) 1625 textInput.text = item.name 1626 } 1627 } 1628 } 1629 } 1630 1631 1632 Item { 1633 id: rectanglebottombar 1634 height: units.gridUnit * 3.5 1635 anchors.left: main.left 1636 anchors.right: main.right 1637 anchors.bottom: main.bottom 1638 z: 110 1639 1640 Rectangle { 1641 id: suggestionbottombox 1642 anchors.top: parent.top 1643 anchors.bottom: parent.bottom 1644 anchors.right: parent.right 1645 anchors.left: parent.left 1646 color: theme.backgroundColor 1647 1648 Rectangle { 1649 id: keyboardactivaterect 1650 color: theme.backgroundColor 1651 border.width: 1 1652 border.color: Qt.lighter(theme.backgroundColor, 1.2) 1653 width: units.gridUnit * 2 1654 height: qinput.height 1655 anchors.top: parent.top 1656 anchors.bottom: parent.bottom 1657 anchors.left: parent.left 1658 1659 PlasmaCore.IconItem { 1660 id: keybdImg 1661 source: "input-keyboard" 1662 anchors.centerIn: parent 1663 width: units.gridUnit * 2 1664 height: units.gridUnit * 2 1665 } 1666 1667 Rectangle { 1668 id: keybindic 1669 anchors.top: keybdImg.bottom 1670 anchors.topMargin: 2 1671 anchors.left: parent.left 1672 anchors.right: parent.right 1673 anchors.leftMargin: 8 1674 anchors.rightMargin: 8 1675 height: 2 1676 color: theme.textColor 1677 } 1678 1679 MouseArea{ 1680 anchors.fill: parent 1681 hoverEnabled: true 1682 onEntered: {} 1683 onExited: {} 1684 onClicked: { 1685 if(expandbartxtinput.visible === false){ 1686 toggleInputMethod("KeyboardSetActive") 1687 } 1688 else if(expandbartxtinput.visible === true){ 1689 toggleInputMethod("KeyboardSetDisable") 1690 } 1691 } 1692 } 1693 } 1694 1695 Suggestions { 1696 id: suggst 1697 visible: true; 1698 anchors.left: keyboardactivaterect.right 1699 anchors.top: parent.top 1700 anchors.bottom: parent.bottom 1701 anchors.right: voiceinputsettingrect.left 1702 } 1703 1704 Rectangle { 1705 id: voiceinputsettingrect 1706 color: theme.backgroundColor 1707 border.width: 1 1708 border.color: Qt.lighter(theme.backgroundColor, 1.2) 1709 width: units.gridUnit * 2.5 1710 height: qinput.height 1711 anchors.top: parent.top 1712 anchors.bottom: parent.bottom 1713 anchors.right: parent.right 1714 1715 PlasmaCore.IconItem { 1716 id: qinputmicbx 1717 anchors.centerIn: parent 1718 source: "mic-on" 1719 width: units.gridUnit * 2 1720 height: units.gridUnit * 2 1721 z: 102 1722 } 1723 1724 MouseArea { 1725 anchors.fill: parent 1726 1727 onClicked: { 1728 if (qinputmicbx.source == "mic-on") { 1729 qinputmicbx.source = "mic-off" 1730 } 1731 else if (qinputmicbx.source == "mic-off") { 1732 qinputmicbx.source = "mic-on" 1733 } 1734 muteMicrophone() 1735 } 1736 1737 } 1738 1739 } 1740 } 1741 1742 } 1743 1744 Settings { 1745 id: innerset 1746 property alias wsurl: settingsTabUnitsWSpath.text 1747 property alias customrecog: settingsTabUnitsIRCmd.text 1748 property alias customocrrecog: settingsTabUnitsOCRCmd.text 1749 property alias customsetuppath: settingsTabUnitsOpThree.text 1750 property alias notifybool: notificationswitch.checked 1751 property alias wolffallbackbool: wolframfallbackswitch.checked 1752 property alias wolframKey: wolframapikeyfld.text 1753 property alias radiobt1: settingsTabUnitsOpOne.checked 1754 property alias radiobt2: settingsTabUnitsOpTwo.checked 1755 property alias radiobt3: settingsTabUnitsOpZero.checked 1756 property alias dashboardSetting: dashswitch.checked 1757 property alias disclaimerCardSetting: disclaimercardswitch.checked 1758 property alias newsCardSetting: newscardswitch.checked 1759 property alias newsCardAPIKey: newsApiKeyLabelFld.text 1760 property alias weatherCardSetting: weathercardswitch.checked 1761 property alias weatherCardAPIKey: owmApiKeyLabelFld.text 1762 property alias weatherMetricC: owmApiKeyMetricCel.checked 1763 property alias weatherMetricF: owmApiKeyMetricFar.checked 1764 property alias selectedCryptoidx: cryptoSelectedBox.currentIndex 1765 property alias selectedCrypto: cryptoSelectedBox.cryptInfo 1766 property alias selectedCur1idx: cryptoSelectCur1.currentIndex 1767 property alias selectedCur1: cryptoSelectCur1.cur1Info 1768 property alias selectedCur2idx: cryptoSelectCur2.currentIndex 1769 property alias selectedCur2: cryptoSelectCur2.cur2Info 1770 property alias selectedCur3idx: cryptoSelectCur3.currentIndex 1771 property alias selectedCur3: cryptoSelectCur3.cur3Info 1772 } 1773 }