Changeset View
Changeset View
Standalone View
Standalone View
plasmoid/contents/ui/main.qml
Show First 20 Lines • Show All 65 Lines • ▼ Show 20 Line(s) | 35 | Item { | |||
---|---|---|---|---|---|
66 | property alias autoCompModel: completionItems | 66 | property alias autoCompModel: completionItems | ||
67 | property alias textInput: qinput | 67 | property alias textInput: qinput | ||
68 | property alias plcLmodel: placesListModel | 68 | property alias plcLmodel: placesListModel | ||
69 | property alias dashLmodel: dashListModel | 69 | property alias dashLmodel: dashListModel | ||
70 | property bool intentfailure: false | 70 | property bool intentfailure: false | ||
71 | property var geoLat | 71 | property var geoLat | ||
72 | property var geoLong | 72 | property var geoLong | ||
73 | property var globalcountrycode | 73 | property var globalcountrycode | ||
74 | property string newsCardSource | 74 | property var weatherMetric: "metric" | ||
75 | property string weatherCardSource | | |||
76 | 75 | | |||
77 | Connections { | 76 | Connections { | ||
78 | target: main2 | 77 | target: main2 | ||
79 | onSendShowMycroft: { | 78 | onSendShowMycroft: { | ||
80 | plasmoid.expanded = !plasmoid.expanded | 79 | plasmoid.expanded = !plasmoid.expanded | ||
81 | tabBar.currentTab = mycroftTab | 80 | tabBar.currentTab = mycroftTab | ||
82 | } | 81 | } | ||
83 | onSendShowSkills: { | 82 | onSendShowSkills: { | ||
▲ Show 20 Lines • Show All 235 Lines • ▼ Show 20 Line(s) | 317 | } else { | |||
319 | suggestionsBox.complete(suggestionsBox.currentItem) | 318 | suggestionsBox.complete(suggestionsBox.currentItem) | ||
320 | } | 319 | } | ||
321 | } | 320 | } | ||
322 | 321 | | |||
323 | function fetchDashNews(){ | 322 | function fetchDashNews(){ | ||
324 | var doc = new XMLHttpRequest() | 323 | var doc = new XMLHttpRequest() | ||
325 | var url = 'https://newsapi.org/v2/top-headlines?' + | 324 | var url = 'https://newsapi.org/v2/top-headlines?' + | ||
326 | 'country=' + globalcountrycode + '&' + | 325 | 'country=' + globalcountrycode + '&' + | ||
327 | 'apiKey=a1091945307b434493258f3dd6f36698'; | 326 | 'apiKey=' + newsApiKeyTextFld.text; | ||
328 | doc.open("GET", url, true); | 327 | doc.open("GET", url, true); | ||
329 | doc.send(); | 328 | doc.send(); | ||
330 | 329 | | |||
331 | doc.onreadystatechange = function() { | 330 | doc.onreadystatechange = function() { | ||
332 | if (doc.readyState === XMLHttpRequest.DONE) { | 331 | if (doc.readyState === XMLHttpRequest.DONE) { | ||
333 | var req = doc.responseText; | 332 | var req = doc.responseText; | ||
334 | dashLmodel.append({"iType": "DashNews", "iObj": req}) | 333 | dashLmodel.append({"iType": "DashNews", "iObj": req}) | ||
335 | } | 334 | } | ||
336 | } | 335 | } | ||
337 | } | 336 | } | ||
338 | 337 | | |||
339 | function fetchDashWeather(){ | 338 | function fetchDashWeather(){ | ||
340 | var doc = new XMLHttpRequest() | 339 | var doc = new XMLHttpRequest() | ||
341 | var url = 'https://api.openweathermap.org/data/2.5/weather?' + | 340 | var url = 'https://api.openweathermap.org/data/2.5/weather?' + | ||
342 | 'lat=' + geoLat + '&lon=' + geoLong + | 341 | 'lat=' + geoLat + '&lon=' + geoLong + '&units=' + weatherMetric + | ||
343 | '&APPID=7af5277aee7a659fc98322c4517d3df7'; | 342 | '&APPID=' + owmApiKeyTextFld.text; | ||
344 | 343 | | |||
345 | doc.open("GET", url, true); | 344 | doc.open("GET", url, true); | ||
346 | doc.send(); | 345 | doc.send(); | ||
347 | 346 | | |||
348 | doc.onreadystatechange = function() { | 347 | doc.onreadystatechange = function() { | ||
349 | if (doc.readyState === XMLHttpRequest.DONE) { | 348 | if (doc.readyState === XMLHttpRequest.DONE) { | ||
350 | var req = doc.responseText; | 349 | var req = doc.responseText; | ||
351 | dashLmodel.append({"iType": "DashWeather", "iObj": req}) | 350 | dashLmodel.append({"iType": "DashWeather", "iObj": req}) | ||
352 | } | 351 | } | ||
353 | } | 352 | } | ||
354 | } | 353 | } | ||
355 | 354 | | |||
355 | function updateCardData(){ | ||||
356 | tabBar.currentTab = mycroftTab | ||||
357 | convoLmodel.clear() | ||||
358 | showDash("setVisible") | ||||
359 | } | ||||
360 | | ||||
356 | function setDisclaimer(){ | 361 | function setDisclaimer(){ | ||
357 | dashLmodel.append({"iType": "Disclaimer", "iObj": "none"}) | 362 | dashLmodel.append({"iType": "Disclaimer", "iObj": "none"}) | ||
358 | } | 363 | } | ||
359 | 364 | | |||
360 | function globalDashRun(){ | 365 | function globalDashRun(){ | ||
361 | if(disclaimercardswitch.checked == true){ | 366 | if(dashswitch.checked == true){ | ||
362 | if(disclaimercardswitch.checked == true){ | 367 | if(disclaimercardswitch.checked == true){ | ||
363 | setDisclaimer() | 368 | setDisclaimer() | ||
364 | } | 369 | } | ||
365 | if(newscardswitch.checked == true){ | 370 | if(newscardswitch.checked == true){ | ||
366 | fetchDashNews() | 371 | fetchDashNews() | ||
367 | } | 372 | } | ||
368 | if(weathercardswitch.checked == true){ | 373 | if(weathercardswitch.checked == true){ | ||
369 | fetchDashWeather() | 374 | fetchDashWeather() | ||
370 | } | 375 | } | ||
371 | convoLmodel.append({"itemType": "DashboardType", "InputQuery": ""}) | 376 | convoLmodel.append({"itemType": "DashboardType", "InputQuery": ""}) | ||
372 | } | 377 | } | ||
373 | else { | 378 | else { | ||
374 | convoLmodel.clear() | 379 | convoLmodel.clear() | ||
375 | disclaimbox.visible = true | 380 | disclaimbox.visible = true | ||
376 | } | 381 | } | ||
377 | } | 382 | } | ||
378 | 383 | | |||
384 | function showDash(dashState){ | ||||
385 | switch(dashState){ | ||||
386 | case "setVisible": | ||||
387 | dashLmodel.clear() | ||||
388 | globalDashRun() | ||||
389 | break | ||||
390 | case "setHide": | ||||
391 | dashLmodel.clear() | ||||
392 | convoLmodel.clear() | ||||
393 | break | ||||
394 | } | ||||
395 | } | ||||
396 | | ||||
379 | PlasmaCore.DataSource { | 397 | PlasmaCore.DataSource { | ||
380 | id: dataSource | 398 | id: dataSource | ||
381 | dataEngine: "geolocation" | 399 | dataEngine: "geolocation" | ||
382 | connectedSources: ["location"] | 400 | connectedSources: ["location"] | ||
383 | 401 | | |||
384 | onNewData: { | 402 | onNewData: { | ||
385 | if (sourceName == "location"){ | 403 | if (sourceName == "location"){ | ||
386 | geoLat = data.latitude | 404 | geoLat = data.latitude | ||
387 | geoLong = data.longitude | 405 | geoLong = data.longitude | ||
388 | var globalcountry = data.country | 406 | var globalcountry = data.country | ||
389 | globalcountrycode = globalcountry.substring(0, 2) | 407 | globalcountrycode = globalcountry.substring(0, 2) | ||
390 | globalDashRun() | 408 | showDash("setVisible") | ||
391 | } | 409 | } | ||
392 | } | 410 | } | ||
393 | } | 411 | } | ||
394 | 412 | | |||
395 | ListModel { | 413 | ListModel { | ||
396 | id: dashListModel | 414 | id: dashListModel | ||
397 | } | 415 | } | ||
398 | 416 | | |||
▲ Show 20 Lines • Show All 118 Lines • ▼ Show 20 Line(s) | 527 | SwitchButton { | |||
517 | 535 | | |||
518 | onClicked: { | 536 | onClicked: { | ||
519 | if (mycroftstartservicebutton.checked === false) { | 537 | if (mycroftstartservicebutton.checked === false) { | ||
520 | PlasmaLa.LaunchApp.runCommand("bash", coreinstallstoppath); | 538 | PlasmaLa.LaunchApp.runCommand("bash", coreinstallstoppath); | ||
521 | convoLmodel.clear() | 539 | convoLmodel.clear() | ||
522 | suggst.visible = true; | 540 | suggst.visible = true; | ||
523 | socket.active = false; | 541 | socket.active = false; | ||
524 | midbarAnim.showstatsId() | 542 | midbarAnim.showstatsId() | ||
543 | showDash("setVisible") | ||||
525 | } | 544 | } | ||
526 | 545 | | |||
527 | if (mycroftstartservicebutton.checked === true) { | 546 | if (mycroftstartservicebutton.checked === true) { | ||
528 | disclaimbox.visible = false; | 547 | disclaimbox.visible = false; | ||
529 | PlasmaLa.LaunchApp.runCommand("bash", coreinstallstartpath); | 548 | PlasmaLa.LaunchApp.runCommand("bash", coreinstallstartpath); | ||
549 | if(dashswitch.checked == "false"){ | ||||
530 | convoLmodel.clear() | 550 | convoLmodel.clear() | ||
551 | } | ||||
531 | suggst.visible = true; | 552 | suggst.visible = true; | ||
532 | delay(15000, function() { | 553 | delay(15000, function() { | ||
533 | socket.active = true; | 554 | socket.active = true; | ||
534 | }) | 555 | }) | ||
535 | } | 556 | } | ||
536 | | ||||
537 | } | 557 | } | ||
538 | | ||||
539 | } | 558 | } | ||
540 | 559 | | |||
541 | PlasmaComponents.ToolButton { | 560 | PlasmaComponents.ToolButton { | ||
542 | id: qinputmicbx | 561 | id: qinputmicbx | ||
543 | anchors.right: pinButton.left | 562 | anchors.right: pinButton.left | ||
544 | anchors.verticalCenter: parent.verticalCenter | 563 | anchors.verticalCenter: parent.verticalCenter | ||
545 | iconSource: "mic-on" | 564 | iconSource: "mic-on" | ||
546 | tooltip: i18n("Toggle Mic") | 565 | tooltip: i18n("Toggle Mic") | ||
547 | flat: true | 566 | flat: true | ||
548 | width: Math.round(units.gridUnit * 2) | 567 | width: Math.round(units.gridUnit * 2) | ||
549 | height: width | 568 | height: width | ||
550 | z: 102 | 569 | z: 102 | ||
551 | 570 | | |||
552 | onClicked: { | 571 | onClicked: { | ||
553 | if (qinputmicbx.iconSource == "mic-on") { | 572 | if (qinputmicbx.iconSource == "mic-on") { | ||
554 | qinputmicbx.iconSource = "mic-off" | 573 | qinputmicbx.iconSource = "mic-off" | ||
555 | } | 574 | } | ||
556 | else if (qinputmicbx.iconSource == "mic-off") { | 575 | else if (qinputmicbx.iconSource == "mic-off") { | ||
557 | qinputmicbx.iconSource = "mic-on" | 576 | qinputmicbx.iconSource = "mic-on" | ||
558 | } | 577 | } | ||
559 | muteMicrophone() | 578 | muteMicrophone() | ||
560 | } | 579 | } | ||
561 | } | 580 | } | ||
562 | 581 | | |||
563 | | ||||
564 | | ||||
565 | PlasmaComponents.ToolButton { | 582 | PlasmaComponents.ToolButton { | ||
566 | id: pinButton | 583 | id: pinButton | ||
567 | anchors.right: parent.right | 584 | anchors.right: parent.right | ||
568 | anchors.verticalCenter: topBarBGrect.verticalCenter | 585 | anchors.verticalCenter: topBarBGrect.verticalCenter | ||
569 | width: Math.round(units.gridUnit * 1.5) | 586 | width: Math.round(units.gridUnit * 1.5) | ||
570 | height: width | 587 | height: width | ||
571 | checkable: true | 588 | checkable: true | ||
572 | iconSource: "window-pin" | 589 | iconSource: "window-pin" | ||
▲ Show 20 Lines • Show All 63 Lines • ▼ Show 20 Line(s) | 648 | onTextMessageReceived: { | |||
636 | 653 | | |||
637 | if (msgType === "recognizer_loop:utterance") { | 654 | if (msgType === "recognizer_loop:utterance") { | ||
638 | var intpost = somestring.data.utterances; | 655 | var intpost = somestring.data.utterances; | ||
639 | qinput.text = intpost.toString() | 656 | qinput.text = intpost.toString() | ||
640 | convoLmodel.append({"itemType": "AskType", "InputQuery": intpost.toString()}) | 657 | convoLmodel.append({"itemType": "AskType", "InputQuery": intpost.toString()}) | ||
641 | midbarAnim.wsistalking() | 658 | midbarAnim.wsistalking() | ||
642 | } | 659 | } | ||
643 | 660 | | |||
661 | if (msgType === "recognizer_loop:utterance" && dashLmodel.count != 0){ | ||||
662 | showDash("setHide") | ||||
663 | } | ||||
664 | | ||||
644 | if (somestring && somestring.data && typeof somestring.data.intent_type !== 'undefined'){ | 665 | if (somestring && somestring.data && typeof somestring.data.intent_type !== 'undefined'){ | ||
645 | smintent = somestring.data.intent_type; | 666 | smintent = somestring.data.intent_type; | ||
646 | } | 667 | } | ||
647 | 668 | | |||
648 | if(somestring && somestring.data && typeof somestring.data.utterance !== 'undefined' && somestring.type === 'speak'){ | 669 | if(somestring && somestring.data && typeof somestring.data.utterance !== 'undefined' && somestring.type === 'speak'){ | ||
649 | filterSpeak(somestring.data.utterance); | 670 | filterSpeak(somestring.data.utterance); | ||
650 | } | 671 | } | ||
651 | 672 | | |||
▲ Show 20 Lines • Show All 543 Lines • ▼ Show 20 Line(s) | 1210 | Flickable { | |||
1195 | 1216 | | |||
1196 | Column { | 1217 | Column { | ||
1197 | spacing: 6 | 1218 | spacing: 6 | ||
1198 | 1219 | | |||
1199 | PlasmaComponents.Switch { | 1220 | PlasmaComponents.Switch { | ||
1200 | id: dashswitch | 1221 | id: dashswitch | ||
1201 | text: i18n("Enable / Disable Dashboard") | 1222 | text: i18n("Enable / Disable Dashboard") | ||
1202 | checked: true | 1223 | checked: true | ||
1224 | | ||||
1225 | onCheckedChanged: { | ||||
1226 | console.log(dashswitch.checked) | ||||
1227 | if(dashswitch.checked){ | ||||
1228 | showDash("setVisible") | ||||
1229 | } | ||||
1230 | else if(!dashswitch.checked){ | ||||
1231 | convoLmodel.clear() | ||||
1232 | } | ||||
1233 | } | ||||
1234 | | ||||
1203 | } | 1235 | } | ||
1204 | 1236 | | |||
1205 | PlasmaComponents.Label { | 1237 | PlasmaComponents.Label { | ||
1206 | id: dashSettingsLabel1 | 1238 | id: dashSettingsLabel1 | ||
1207 | text: i18n("Card Settings:") | 1239 | text: i18n("Card Settings:") | ||
1208 | font.bold: true; | 1240 | font.bold: true; | ||
1209 | } | 1241 | } | ||
1210 | 1242 | | |||
Show All 36 Lines | 1276 | PlasmaComponents.Label { | |||
1247 | } | 1279 | } | ||
1248 | PlasmaComponents.TextField{ | 1280 | PlasmaComponents.TextField{ | ||
1249 | id: owmApiKeyTextFld | 1281 | id: owmApiKeyTextFld | ||
1250 | width: units.gridUnit * 12 | 1282 | width: units.gridUnit * 12 | ||
1251 | text: "7af5277aee7a659fc98322c4517d3df7" | 1283 | text: "7af5277aee7a659fc98322c4517d3df7" | ||
1252 | } | 1284 | } | ||
1253 | } | 1285 | } | ||
1254 | 1286 | | |||
1255 | Row { | 1287 | Row{ | ||
1288 | id: weatherCardMetricsRowList | ||||
1256 | spacing: 2 | 1289 | spacing: 2 | ||
1257 | PlasmaComponents.RadioButton { | 1290 | | ||
1291 | PlasmaComponents.Button { | ||||
1258 | id: owmApiKeyMetricCel | 1292 | id: owmApiKeyMetricCel | ||
1259 | text: i18n("Celcius") | 1293 | text: i18n("Celcius") | ||
1260 | checked: true | 1294 | onClicked: { | ||
1261 | exclusiveGroup: owmMetricsGroup | 1295 | weatherMetric = "metric" | ||
1296 | updateCardData() | ||||
1262 | } | 1297 | } | ||
1263 | PlasmaComponents.RadioButton{ | 1298 | } | ||
1299 | PlasmaComponents.Button{ | ||||
1264 | id: owmApiKeyMetricFar | 1300 | id: owmApiKeyMetricFar | ||
1265 | text: i18n("Fahrenheit") | 1301 | text: i18n("Fahrenheit") | ||
1266 | exclusiveGroup: owmMetricsGroup | 1302 | onClicked: { | ||
1303 | weatherMetric = "imperial" | ||||
1304 | updateCardData() | ||||
1305 | } | ||||
1267 | } | 1306 | } | ||
1268 | } | 1307 | } | ||
1269 | 1308 | | |||
1270 | } | 1309 | } | ||
1271 | } | 1310 | } | ||
1272 | } | 1311 | } | ||
1273 | } | 1312 | } | ||
1274 | 1313 | | |||
▲ Show 20 Lines • Show All 268 Lines • ▼ Show 20 Line(s) | 1575 | Settings { | |||
1543 | property alias radiobt2: settingsTabUnitsOpTwo.checked | 1582 | property alias radiobt2: settingsTabUnitsOpTwo.checked | ||
1544 | property alias radiobt3: settingsTabUnitsOpZero.checked | 1583 | property alias radiobt3: settingsTabUnitsOpZero.checked | ||
1545 | property alias dashboardSetting: dashswitch.checked | 1584 | property alias dashboardSetting: dashswitch.checked | ||
1546 | property alias disclaimerCardSetting: disclaimercardswitch.checked | 1585 | property alias disclaimerCardSetting: disclaimercardswitch.checked | ||
1547 | property alias newsCardSetting: newscardswitch.checked | 1586 | property alias newsCardSetting: newscardswitch.checked | ||
1548 | property alias newsCardAPIKey: newsApiKeyLabelFld.text | 1587 | property alias newsCardAPIKey: newsApiKeyLabelFld.text | ||
1549 | property alias weatherCardSetting: weathercardswitch.checked | 1588 | property alias weatherCardSetting: weathercardswitch.checked | ||
1550 | property alias weatherCardAPIKey: owmApiKeyLabelFld.text | 1589 | property alias weatherCardAPIKey: owmApiKeyLabelFld.text | ||
1590 | property alias weatherMetricC: owmApiKeyMetricCel.checked | ||||
1591 | property alias weatherMetricF: owmApiKeyMetricFar.checked | ||||
1551 | } | 1592 | } | ||
1552 | } | 1593 | } |