Changeset View
Changeset View
Standalone View
Standalone View
plasmoid/contents/ui/main.qml
Show First 20 Lines • Show All 424 Lines • ▼ Show 20 Line(s) | 424 | var url = 'https://newsapi.org/v2/top-headlines?' + | |||
---|---|---|---|---|---|
425 | 'country=' + globalcountrycode + '&' + | 425 | 'country=' + globalcountrycode + '&' + | ||
426 | 'apiKey=' + newsApiKeyTextFld.text; | 426 | 'apiKey=' + newsApiKeyTextFld.text; | ||
427 | doc.open("GET", url, true); | 427 | doc.open("GET", url, true); | ||
428 | doc.send(); | 428 | doc.send(); | ||
429 | 429 | | |||
430 | doc.onreadystatechange = function() { | 430 | doc.onreadystatechange = function() { | ||
431 | if (doc.readyState === XMLHttpRequest.DONE) { | 431 | if (doc.readyState === XMLHttpRequest.DONE) { | ||
432 | var req = doc.responseText; | 432 | var req = doc.responseText; | ||
433 | var checkNewsItem = JSON.parse(req) | ||||
434 | if (checkNewsItem.totalResults == 0){ | ||||
435 | globalcountrycode = "us" | ||||
436 | fetchDashNews() | ||||
437 | } | ||||
438 | else { | ||||
433 | dashLmodel.append({"iType": "DashNews", "iObj": req}) | 439 | dashLmodel.append({"iType": "DashNews", "iObj": req}) | ||
434 | } | 440 | } | ||
435 | } | 441 | } | ||
436 | } | 442 | } | ||
443 | } | ||||
437 | 444 | | |||
438 | function fetchDashWeather(){ | 445 | function fetchDashWeather(){ | ||
439 | var doc = new XMLHttpRequest() | 446 | var doc = new XMLHttpRequest() | ||
440 | var url = 'https://api.openweathermap.org/data/2.5/weather?' + | 447 | var url = 'https://api.openweathermap.org/data/2.5/weather?' + | ||
441 | 'lat=' + geoLat + '&lon=' + geoLong + '&units=' + weatherMetric + | 448 | 'lat=' + geoLat + '&lon=' + geoLong + '&units=' + weatherMetric + | ||
442 | '&APPID=' + owmApiKeyTextFld.text; | 449 | '&APPID=' + owmApiKeyTextFld.text; | ||
443 | 450 | | |||
444 | doc.open("GET", url, true); | 451 | doc.open("GET", url, true); | ||
▲ Show 20 Lines • Show All 46 Lines • ▼ Show 20 Line(s) | 489 | if(dashswitch.checked == true){ | |||
491 | } | 498 | } | ||
492 | if(cryptocardswitch.checked == true){ | 499 | if(cryptocardswitch.checked == true){ | ||
493 | fetchDashCryptoCardData() | 500 | fetchDashCryptoCardData() | ||
494 | } | 501 | } | ||
495 | convoLmodel.append({"itemType": "DashboardType", "InputQuery": ""}) | 502 | convoLmodel.append({"itemType": "DashboardType", "InputQuery": ""}) | ||
496 | } | 503 | } | ||
497 | else { | 504 | else { | ||
498 | convoLmodel.clear() | 505 | convoLmodel.clear() | ||
506 | if(mycroftStatusCheckSocket._socketIsAlreadyActive == true){ | ||||
507 | disclaimbox.visible = false | ||||
508 | } | ||||
509 | else { | ||||
499 | disclaimbox.visible = true | 510 | disclaimbox.visible = true | ||
500 | } | 511 | } | ||
501 | } | 512 | } | ||
513 | } | ||||
502 | 514 | | |||
503 | function showDash(dashState){ | 515 | function showDash(dashState){ | ||
504 | switch(dashState){ | 516 | switch(dashState){ | ||
505 | case "setVisible": | 517 | case "setVisible": | ||
506 | dashLmodel.clear() | 518 | dashLmodel.clear() | ||
507 | globalDashRun() | 519 | globalDashRun() | ||
508 | break | 520 | break | ||
509 | case "setHide": | 521 | case "setHide": | ||
▲ Show 20 Lines • Show All 280 Lines • ▼ Show 20 Line(s) | 797 | Item { | |||
790 | left: parent.left | 802 | left: parent.left | ||
791 | right: parent.right | 803 | right: parent.right | ||
792 | } | 804 | } | ||
793 | 805 | | |||
794 | WebSocket { | 806 | WebSocket { | ||
795 | id: mycroftStatusCheckSocket | 807 | id: mycroftStatusCheckSocket | ||
796 | url: innerset.wsurl | 808 | url: innerset.wsurl | ||
797 | active: true | 809 | active: true | ||
810 | property bool _socketIsAlreadyActive: false | ||||
798 | onStatusChanged: | 811 | onStatusChanged: | ||
799 | if (mycroftStatusCheckSocket.status == WebSocket.Open && socket.status == WebSocket.Closed) { | 812 | if (mycroftStatusCheckSocket.status == WebSocket.Open && socket.status == WebSocket.Closed) { | ||
800 | socket.active = true | 813 | socket.active = true | ||
814 | mycroftStatusCheckSocket._socketIsAlreadyActive = true | ||||
801 | disclaimbox.visible = false; | 815 | disclaimbox.visible = false; | ||
802 | mycroftstartservicebutton.checked = true | 816 | mycroftstartservicebutton.checked = true | ||
803 | statusId.text = i18n("<b>Mycroft is ready</b>") | 817 | statusId.text = i18n("<b>Mycroft is ready</b>") | ||
804 | statusId.color = "green" | 818 | statusId.color = "green" | ||
805 | statusId.visible = true | 819 | statusId.visible = true | ||
806 | } | 820 | } | ||
807 | 821 | | |||
808 | else if (mycroftStatusCheckSocket.status == WebSocket.Error) { | 822 | else if (mycroftStatusCheckSocket.status == WebSocket.Error) { | ||
809 | mycroftstartservicebutton.checked = false | 823 | mycroftstartservicebutton.checked = false | ||
824 | mycroftStatusCheckSocket._socketIsAlreadyActive = false | ||||
810 | statusId.text = i18n("<b>Mycroft is disabled</b>") | 825 | statusId.text = i18n("<b>Mycroft is disabled</b>") | ||
811 | statusId.color = theme.textColor | 826 | statusId.color = theme.textColor | ||
812 | statusId.visible = true | 827 | statusId.visible = true | ||
813 | } | 828 | } | ||
814 | } | 829 | } | ||
815 | 830 | | |||
816 | WebSocket { | 831 | WebSocket { | ||
817 | id: socket | 832 | id: socket | ||
▲ Show 20 Lines • Show All 248 Lines • ▼ Show 20 Line(s) | 1071 | onDropped: { | |||
1066 | } | 1081 | } | ||
1067 | 1082 | | |||
1068 | if(ext === 'mp3'){ | 1083 | if(ext === 'mp3'){ | ||
1069 | console.log('mp3'); | 1084 | console.log('mp3'); | ||
1070 | } | 1085 | } | ||
1071 | } | 1086 | } | ||
1072 | } | 1087 | } | ||
1073 | 1088 | | |||
1089 | PulleyItem { | ||||
1090 | id: favlistPulley | ||||
1091 | visible: true | ||||
1092 | barColor: theme.linkColor | ||||
1093 | _isVisible: true | ||||
1094 | z: 900 | ||||
1095 | | ||||
1096 | onPulleyExpanded: {disclaimbox.visible = false} | ||||
1097 | } | ||||
1074 | 1098 | | |||
1075 | Disclaimer{ | 1099 | Disclaimer{ | ||
1076 | id: disclaimbox | 1100 | id: disclaimbox | ||
1077 | visible: false | 1101 | visible: false | ||
1078 | } | 1102 | } | ||
1079 | 1103 | | |||
1080 | ListModel{ | 1104 | ListModel{ | ||
1081 | id: convoLmodel | 1105 | id: convoLmodel | ||
▲ Show 20 Lines • Show All 378 Lines • ▼ Show 20 Line(s) | 1474 | Flickable { | |||
1460 | PlasmaComponents.Switch { | 1484 | PlasmaComponents.Switch { | ||
1461 | id: dashswitch | 1485 | id: dashswitch | ||
1462 | text: i18n("Enable / Disable Dashboard") | 1486 | text: i18n("Enable / Disable Dashboard") | ||
1463 | checked: true | 1487 | checked: true | ||
1464 | 1488 | | |||
1465 | onCheckedChanged: { | 1489 | onCheckedChanged: { | ||
1466 | console.log(dashswitch.checked) | 1490 | console.log(dashswitch.checked) | ||
1467 | if(dashswitch.checked){ | 1491 | if(dashswitch.checked){ | ||
1492 | tabBar.currentTab = mycroftTab | ||||
1493 | disclaimbox.visible = false | ||||
1468 | showDash("setVisible") | 1494 | showDash("setVisible") | ||
1469 | } | 1495 | } | ||
1470 | else if(!dashswitch.checked){ | 1496 | else if(!dashswitch.checked){ | ||
1471 | convoLmodel.clear() | 1497 | convoLmodel.clear() | ||
1498 | disclaimbox.visible = true | ||||
1472 | } | 1499 | } | ||
1473 | } | 1500 | } | ||
1474 | 1501 | | |||
1475 | } | 1502 | } | ||
1476 | 1503 | | |||
1477 | PlasmaComponents.Label { | 1504 | PlasmaComponents.Label { | ||
1478 | id: dashSettingsLabel1 | 1505 | id: dashSettingsLabel1 | ||
1479 | text: i18n("Card Settings:") | 1506 | text: i18n("Card Settings:") | ||
▲ Show 20 Lines • Show All 363 Lines • Show Last 20 Lines |