diff --git a/plasmoid/contents/images/ctxmenu.png b/plasmoid/contents/images/ctxmenu.png new file mode 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 GIT binary patch literal 0 Hc$@ + + 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 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 QtGraphicalEffects 1.0 + +Rectangle { + id: dashDelegateItm + height: skillTopRowLayout.height + dashinner.height + dashItemSrcMeta.height + units.gridUnit * 0.5 + width: cbwidth + color: theme.backgroundColor + + Item { + id: contentdlgtitem + width: parent.width + height: parent.height + + Item { + id: skillTopRowLayout + anchors.top: parent.top + anchors.left: parent.left + anchors.right: parent.right + implicitHeight: dashHeader.implicitHeight + units.gridUnit * 0.5 + + Text { + id: dashHeader + anchors.left: parent.left + anchors.leftMargin: 2 + anchors.right: contxtnewsitemmenu.left + anchors.verticalCenter: parent.verticalCenter + wrapMode: Text.Wrap; + font.bold: true; + text: newsTitle + color: theme.textColor + } + + ToolButton { + id: contxtnewsitemmenu + anchors.verticalCenter: parent.verticalCenter + anchors.right: parent.right + width: units.gridUnit * 1 + height: units.gridUnit * 1 + Image { + id: innrnewitemcontxmenuimage + source: "../images/ctxmenu.png" + anchors.top: parent.top + anchors.horizontalCenter: parent.horizontalCenter + width: units.gridUnit * 0.7 + height: units.gridUnit * 0.7 + } + ColorOverlay { + anchors.fill: innrnewitemcontxmenuimage + source: innrnewitemcontxmenuimage + color: theme.textColor + } + onClicked: { + mcmenuItem.open() + } + } + } + + Rectangle { + id: nwsseprator + width: parent.width + anchors.top: skillTopRowLayout.bottom + anchors.topMargin: 1 + height: 2 + color: theme.linkColor + } + + Item { + id: dashinner + width: parent.width + implicitHeight: nwsdesc.height + Layout.minimumHeight: units.gridUnit * 2 + anchors.top: nwsseprator.bottom + anchors.topMargin: 1 + + Text { + id: nwsdesc + wrapMode: Text.Wrap; + anchors.right: ctxImgIcon.left + anchors.left: parent.left + anchors.leftMargin: 2 + color: theme.textColor ; + text: newsDescription + + Component.onCompleted: { + if (!nwsdesc.text) { + nwsdesc.text = newsTitle + } + } + } + + Image { + id: ctxImgIcon + anchors.right: parent.right + anchors.margins: units.gridUnit * 0.5 + source: newsImgURL + width: 64 + height: parent.height + + Component.onCompleted: { + if (ctxImgIcon.source == "") { + ctxImgIcon.source = "../images/newsicon.png" + } + } + + } + } + + Rectangle { + id: nwsseprator2 + width: parent.width + anchors.top: dashinner.bottom + anchors.topMargin: 1 + height: 2 + color: theme.linkColor + } + + Rectangle { + id: dashItemSrcMeta + implicitWidth: dashItemSrcName.implicitWidth + units.gridUnit * 1 + anchors.left: parent.left + anchors.top: nwsseprator2.bottom + anchors.topMargin: 1 + color: theme.linkColor + height: units.gridUnit * 1.25 + + Text { + id: dashItemSrcName + wrapMode: Text.Wrap; + anchors.centerIn: parent + color: theme.textColor ; + text: newsSource + } + } + + Text { + id: dashItemPwrBy + anchors.top: nwsseprator2.bottom + anchors.topMargin: 1 + wrapMode: Text.Wrop; + anchors.right: parent.right + color: theme.textColor; + font.pixelSize: 10 + text: i18n("Powered By: NewsAPI") + } + } + + Drawer { + id: mcmenuItem + width: parent.width + height: units.gridUnit * 5 + edge: Qt.TopEdge + dragMargin: 0 + + Rectangle { + anchors.fill: parent + color: theme.textColor + + Rectangle { + id: readaloudRectbtn + width: parent.width + height: units.gridUnit * 2 + color: theme.textColor + anchors.top: parent.top + anchors.topMargin: units.gridUnit * 0.25 + Row { + spacing: 5 + Image { + id: readAloudIcon + anchors.verticalCenter: parent.verticalCenter + source: "../images/readaloud.png" + width: 32 + height: 32 + } + Rectangle { + id: readAloudSeperater + width: 1 + height: parent.height + color: theme.linkColor + } + Label { + id: readAloudLabel + anchors.verticalCenter: parent.verticalCenter + text: "Listen To/Play The Selected Article" + color: theme.backgroundColor + } + } + } + + Rectangle { + id: btnshorzSepr + width: parent.width + height: 1 + color: theme.linkColor + anchors.top: readaloudRectbtn.bottom + anchors.topMargin: units.gridUnit * 0.25 + } + + Rectangle{ + id: shareNwsBtn + width: parent.width + height: units.gridUnit * 2 + color: theme.textColor + anchors.top: btnshorzSepr.bottom + anchors.topMargin: units.gridUnit * 0.25 + Row { + spacing: 5 + Image { + id: shareNewsIcon + anchors.verticalCenter: parent.verticalCenter + source: "../images/share.png" + width: 32 + height: 32 + } + Rectangle { + id: shareNewsSeperater + width: 1 + height: parent.height + color: theme.linkColor + } + Label { + id: shareNewsLabel + anchors.verticalCenter: parent.verticalCenter + text: "Share" + color: theme.backgroundColor + } + } + } + } + } + } diff --git a/plasmoid/contents/ui/DashWeatherDelegate.qml b/plasmoid/contents/ui/DashWeatherDelegate.qml new file mode 100644 --- /dev/null +++ b/plasmoid/contents/ui/DashWeatherDelegate.qml @@ -0,0 +1,224 @@ +/* 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.Controls 2.2 +import QtQuick.Layouts 1.3 +import QtGraphicalEffects 1.0 + +Rectangle { + id: dashDelegateItm + height: units.gridUnit * 4 + width: cbwidth + color: theme.backgroundColor + + Item { + id: contentdlgtitem + width: parent.width + height: parent.height + + Item { + id: skillTopRowLayout + anchors.top: parent.top + anchors.left: parent.left + anchors.right: parent.right + implicitHeight: dashHeader.implicitHeight + units.gridUnit * 0.5 + + Text { + id: dashHeader + anchors.left: parent.left + anchors.leftMargin: 2 + anchors.right: contxtnewsitemmenu.left + anchors.verticalCenter: parent.verticalCenter + wrapMode: Text.Wrap; + font.bold: true; + text: i18n("Current Weather: " + itemWeatherTempType) + color: theme.textColor + } + + ToolButton { + id: contxtnewsitemmenu + anchors.verticalCenter: parent.verticalCenter + anchors.right: parent.right + width: units.gridUnit * 1 + height: units.gridUnit * 1 + Image { + id: innrnewitemcontxmenuimage + source: "../images/ctxmenu.png" + anchors.top: parent.top + anchors.horizontalCenter: parent.horizontalCenter + width: units.gridUnit * 0.7 + height: units.gridUnit * 0.7 + } + ColorOverlay { + anchors.fill: innrnewitemcontxmenuimage + source: innrnewitemcontxmenuimage + color: theme.textColor + } + onClicked: { + mcmenuItem.open() + } + } + } + + Rectangle { + id: nwsseprator + width: parent.width + anchors.top: skillTopRowLayout.bottom + anchors.topMargin: 1 + height: 2 + color: theme.linkColor + } + + Text { + id: weatherDshTempMinLabel + anchors.top: nwsseprator.bottom + anchors.topMargin: 1 + anchors.left: parent.left + color: theme.textColor + wrapMode: Text.WordWrap; + font.bold: true; + text: "Minimum Temperature: " + itemWeatherTempMin + } + + Rectangle { + id: nwsseprator2 + width: parent.width + anchors.top: weatherDshTempMinLabel.bottom + anchors.topMargin: 1 + height: 2 + color: theme.linkColor + } + + Text { + id: weatherDshTempCurrentLabel + anchors.top: nwsseprator2.bottom + anchors.topMargin: 1 + anchors.left: parent.left + wrapMode: Text.WordWrap; + font.bold: true; + text: "Current Temperature: " + itemWeatherTemp + color: theme.textColor + } + + Rectangle { + id: nwsseprator3 + width: parent.width + anchors.top: weatherDshTempCurrentLabel.bottom + anchors.topMargin: 1 + height: 2 + color: theme.linkColor + } + + Text { + id: weatherDshTempMaxLabel + anchors.top: nwsseprator3.bottom + anchors.topMargin: 1 + anchors.left: parent.left + wrapMode: Text.WordWrap; + font.bold: true; + color: theme.textColor + text:"Maximum Temperature: " + itemWeatherTempMax + } + } + + Drawer { + id: mcmenuItem + width: parent.width + height: units.gridUnit * 5 + edge: Qt.TopEdge + dragMargin: 0 + + Rectangle { + anchors.fill: parent + color: theme.textColor + + Rectangle { + id: readaloudRectbtn + width: parent.width + height: units.gridUnit * 2 + color: theme.textColor + anchors.top: parent.top + anchors.topMargin: units.gridUnit * 0.25 + Row { + spacing: 5 + Image { + id: readAloudIcon + anchors.verticalCenter: parent.verticalCenter + source: "../images/readaloud.png" + width: 32 + height: 32 + } + Rectangle { + id: readAloudSeperater + width: 1 + height: parent.height + color: theme.linkColor + } + Label { + id: readAloudLabel + anchors.verticalCenter: parent.verticalCenter + text: "Listen To/Play The Selected Article" + color: theme.backgroundColor + } + } + } + + Rectangle { + id: btnshorzSepr + width: parent.width + height: 1 + color: theme.linkColor + anchors.top: readaloudRectbtn.bottom + anchors.topMargin: units.gridUnit * 0.25 + } + + Rectangle{ + id: shareNwsBtn + width: parent.width + height: units.gridUnit * 2 + color: theme.textColor + anchors.top: btnshorzSepr.bottom + anchors.topMargin: units.gridUnit * 0.25 + Row { + spacing: 5 + Image { + id: shareNewsIcon + anchors.verticalCenter: parent.verticalCenter + source: "../images/share.png" + width: 32 + height: 32 + } + Rectangle { + id: shareNewsSeperater + width: 1 + height: parent.height + color: theme.linkColor + } + Label { + id: shareNewsLabel + anchors.verticalCenter: parent.verticalCenter + text: "Share" + color: theme.backgroundColor + } + } + } + } + } +} diff --git a/plasmoid/contents/ui/DashboardDelegate.qml b/plasmoid/contents/ui/DashboardDelegate.qml new file mode 100644 --- /dev/null +++ b/plasmoid/contents/ui/DashboardDelegate.qml @@ -0,0 +1,120 @@ +/* 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 org.kde.plasma.core 2.0 as PlasmaCore +import org.kde.plasma.plasmoid 2.0 +import org.kde.plasma.components 2.0 as PlasmaComponents + +Rectangle { + id: dashdelegteType + height: dashdelegatelview.height + width: parent.width + color: theme.backgroundColor + property alias dashnewsLmodel: dashnewsListModel + property alias dashweatherLmodel: dashweatherListModel + + Component.onCompleted: { + //console.log(iType, iObj) + filterSwitchDash(iType, iObj) + } + + function filterSwitchDash(iType, iObj){ + switch(iType){ + case "Disclaimer": + filterDashDisclaimerObj() + console.log("Disclaimer HERE") + break + case "DashNews": + filterDashNewsObj(iObj) + break + case "DashWeather": + filterDashWeatherObj(iObj) + break + } + } + + function filterDashDisclaimerObj() { + dashdelegatelview.model = disclaimerListModel + disclaimerListModel.append({itemType: "Disclaimer"}) + } + + function filterDashWeatherObj(weatherobj){ + if(weatherobj){ + var filteredWeatherObject = JSON.parse(weatherobj) + dashdelegatelview.model = dashweatherLmodel + dashweatherLmodel.append({itemType: "DashWeather", itemWeatherTemp: filteredWeatherObject.main.temp, itemWeatherTempMin: filteredWeatherObject.main.temp_min, itemWeatherTempMax: filteredWeatherObject.main.temp_max, itemWeatherTempType: filteredWeatherObject.weather[0].main}) + } + } + + function filterDashNewsObj(newsobj){ + if(newsobj){ + var filteredNewsObject = JSON.parse(newsobj) + for (var i=0; i + + 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 org.kde.plasma.core 2.0 as PlasmaCore +import org.kde.plasma.plasmoid 2.0 +import org.kde.plasma.components 2.0 as PlasmaComponents + +Rectangle { + id: dashbdtypebg + height: cbheight / 1.1 + width: cbwidth + color: theme.backgroundColor + property alias dashlvmodel: dashboardmodelview.model + +ListView { + id: dashboardmodelview + anchors.fill: parent + model: dashLmodel + spacing: 4 + focus: false + interactive: true + clip: true; + delegate: DashboardDelegate{} + ScrollBar.vertical: ScrollBar { + active: true + } + } +} + diff --git a/plasmoid/contents/ui/DisclaimerCardDelegate.qml b/plasmoid/contents/ui/DisclaimerCardDelegate.qml new file mode 100644 --- /dev/null +++ b/plasmoid/contents/ui/DisclaimerCardDelegate.qml @@ -0,0 +1,196 @@ +/* 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 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 QtGraphicalEffects 1.0 + +Rectangle { + id: dashDelegateItm + height: units.gridUnit * 3 + width: cbwidth + color: theme.backgroundColor + + Item { + id: contentdlgtitem + width: parent.width + height: parent.height + + Item { + id: skillTopRowLayout + anchors.top: parent.top + anchors.left: parent.left + anchors.right: parent.right + implicitHeight: dashHeader.height + + Text { + id: dashHeader + anchors.left: parent.left + anchors.leftMargin: 2 + anchors.right: contxtnewsitemmenu.left + anchors.verticalCenter: parent.verticalCenter + wrapMode: Text.Wrap; + font.bold: true; + text: i18n("Let's Continue ?") + color: theme.textColor + } + + ToolButton { + id: contxtnewsitemmenu + anchors.verticalCenter: parent.verticalCenter + anchors.right: parent.right + width: units.gridUnit * 1 + height: units.gridUnit * 1 + Image { + id: innrnewitemcontxmenuimage + source: "../images/ctxmenu.png" + anchors.top: parent.top + anchors.horizontalCenter: parent.horizontalCenter + width: units.gridUnit * 0.7 + height: units.gridUnit * 0.7 + } + ColorOverlay { + anchors.fill: innrnewitemcontxmenuimage + source: innrnewitemcontxmenuimage + color: theme.textColor + } + onClicked: { + mcmenuItem.open() + } + } + } + + Rectangle { + id: nwsseprator + width: parent.width + anchors.top: skillTopRowLayout.bottom + anchors.topMargin: 1 + height: 2 + color: theme.linkColor + } + + Item { + id: dashinner + width: parent.width + implicitHeight: nwsdesc.height + Layout.minimumHeight: units.gridUnit * 2 + anchors.top: nwsseprator.bottom + anchors.topMargin: 1 + + Text { + id: nwsdesc + wrapMode: Text.Wrap; + anchors.right: parent.right + anchors.left: parent.left + anchors.leftMargin: 2 + color: theme.textColor ; + text: i18n("Mycroft by default is powered by a cloud-based speech to text service. Mycroft gives you the ability to change speech to text services or use a locally configured one within their settings at home.mycroft.ai.") + } + } + } + + Drawer { + id: mcmenuItem + width: parent.width + height: units.gridUnit * 5 + edge: Qt.TopEdge + dragMargin: 0 + + Rectangle { + anchors.fill: parent + color: theme.textColor + + Rectangle { + id: readaloudRectbtn + width: parent.width + height: units.gridUnit * 2 + color: theme.textColor + anchors.top: parent.top + anchors.topMargin: units.gridUnit * 0.25 + Row { + spacing: 5 + Image { + id: readAloudIcon + anchors.verticalCenter: parent.verticalCenter + source: "../images/readaloud.png" + width: 32 + height: 32 + } + Rectangle { + id: readAloudSeperater + width: 1 + height: parent.height + color: theme.linkColor + } + Label { + id: readAloudLabel + anchors.verticalCenter: parent.verticalCenter + text: "Listen To/Play The Selected Article" + color: theme.backgroundColor + } + } + } + + Rectangle { + id: btnshorzSepr + width: parent.width + height: 1 + color: theme.linkColor + anchors.top: readaloudRectbtn.bottom + anchors.topMargin: units.gridUnit * 0.25 + } + + Rectangle{ + id: shareNwsBtn + width: parent.width + height: units.gridUnit * 2 + color: theme.textColor + anchors.top: btnshorzSepr.bottom + anchors.topMargin: units.gridUnit * 0.25 + Row { + spacing: 5 + Image { + id: shareNewsIcon + anchors.verticalCenter: parent.verticalCenter + source: "../images/share.png" + width: 32 + height: 32 + } + Rectangle { + id: shareNewsSeperater + width: 1 + height: parent.height + color: theme.linkColor + } + Label { + id: shareNewsLabel + anchors.verticalCenter: parent.verticalCenter + text: "Share" + color: theme.backgroundColor + } + } + } + } + } + } diff --git a/plasmoid/contents/ui/NavigationDelegate.qml b/plasmoid/contents/ui/NavigationDelegate.qml --- a/plasmoid/contents/ui/NavigationDelegate.qml +++ b/plasmoid/contents/ui/NavigationDelegate.qml @@ -1,3 +1,22 @@ +/* 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 diff --git a/plasmoid/contents/ui/PlacesDelegate.qml b/plasmoid/contents/ui/PlacesDelegate.qml --- a/plasmoid/contents/ui/PlacesDelegate.qml +++ b/plasmoid/contents/ui/PlacesDelegate.qml @@ -1,3 +1,22 @@ +/* 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 diff --git a/plasmoid/contents/ui/PlacesType.qml b/plasmoid/contents/ui/PlacesType.qml --- a/plasmoid/contents/ui/PlacesType.qml +++ b/plasmoid/contents/ui/PlacesType.qml @@ -1,3 +1,22 @@ +/* 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 diff --git a/plasmoid/contents/ui/main.qml b/plasmoid/contents/ui/main.qml --- a/plasmoid/contents/ui/main.qml +++ b/plasmoid/contents/ui/main.qml @@ -66,7 +66,13 @@ property alias autoCompModel: completionItems property alias textInput: qinput property alias plcLmodel: placesListModel + property alias dashLmodel: dashListModel property bool intentfailure: false + property var geoLat + property var geoLong + property var globalcountrycode + property string newsCardSource + property string weatherCardSource Connections { target: main2 @@ -148,33 +154,29 @@ 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}) + 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}) } 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 ''; + 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 ''; } @@ -260,7 +262,7 @@ } } - function playwaitanim(recoginit){ + function playwaitanim(recoginit){ switch(recoginit){ case "recognizer_loop:record_begin": drawer.open() @@ -298,7 +300,7 @@ } } - function autoAppend(model, getinputstring, setinputstring) { + function autoAppend(model, getinputstring, setinputstring) { for(var i = 0; i < model.count; ++i) if (getinputstring(model.get(i))){ console.log(model.get(i)) @@ -313,14 +315,90 @@ suggestionsBox.complete(suggestionsBox.currentItem) } } + + function fetchDashNews(){ + var doc = new XMLHttpRequest() + var url = 'https://newsapi.org/v2/top-headlines?' + + 'country=' + globalcountrycode + '&' + + 'apiKey=a1091945307b434493258f3dd6f36698'; + doc.open("GET", url, true); + doc.send(); + + doc.onreadystatechange = function() { + if (doc.readyState === XMLHttpRequest.DONE) { + var req = doc.responseText; + dashLmodel.append({"iType": "DashNews", "iObj": req}) + } + } + } + + function fetchDashWeather(){ + var doc = new XMLHttpRequest() + var url = 'https://api.openweathermap.org/data/2.5/weather?' + + 'lat=' + geoLat + '&lon=' + geoLong + + '&APPID=7af5277aee7a659fc98322c4517d3df7'; + + doc.open("GET", url, true); + doc.send(); + + doc.onreadystatechange = function() { + if (doc.readyState === XMLHttpRequest.DONE) { + var req = doc.responseText; + dashLmodel.append({"iType": "DashWeather", "iObj": req}) + } + } + } + + function setDisclaimer(){ + dashLmodel.append({"iType": "Disclaimer", "iObj": "none"}) + } + + function globalDashRun(){ + if(disclaimercardswitch.checked == true){ + if(disclaimercardswitch.checked == true){ + setDisclaimer() + } + if(newscardswitch.checked == true){ + fetchDashNews() + } + if(weathercardswitch.checked == true){ + fetchDashWeather() + } + convoLmodel.append({"itemType": "DashboardType", "InputQuery": ""}) + } + else { + convoLmodel.clear() + disclaimbox.visible = true + } + } + +PlasmaCore.DataSource { + id: dataSource + dataEngine: "geolocation" + connectedSources: ["location"] + + onNewData: { + if (sourceName == "location"){ + geoLat = data.latitude + geoLong = data.longitude + var globalcountry = data.country + globalcountrycode = globalcountry.substring(0, 2) + globalDashRun() + } + } + } + +ListModel { + id: dashListModel + } ListModel { id: placesListModel } Timer { id: timer - } + } function delay(delayTime, cb) { timer.interval = delayTime; @@ -781,7 +859,7 @@ Disclaimer{ id: disclaimbox - visible: true + visible: false } ListModel{ @@ -817,7 +895,8 @@ case "DropImg" : return "ImgRecogType.qml" case "AskType" : return "AskMessageType.qml" case "LoaderType" : return "LoaderType.qml" - case "PlacesType" : return "PlacesType.qml" + case "PlacesType" : return "PlacesType.qml" + case "DashboardType" : return "DashboardType.qml" } property var metacontent : dataContent } @@ -867,12 +946,36 @@ 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.fill: parent; + 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 @@ -1067,6 +1170,102 @@ } } } + + 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 + } + + 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 { + spacing: 2 + PlasmaComponents.RadioButton { + id: owmApiKeyMetricCel + text: i18n("Celcius") + checked: true + exclusiveGroup: owmMetricsGroup + } + PlasmaComponents.RadioButton{ + id: owmApiKeyMetricFar + text: i18n("Farahanite") + exclusiveGroup: owmMetricsGroup + } + } + + } + } + } } ColumnLayout { @@ -1339,5 +1538,11 @@ 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 } }