diff --git a/plasmoid/contents/ui/AskMessageType.qml b/plasmoid/contents/ui/AskMessageDelegate.qml similarity index 98% rename from plasmoid/contents/ui/AskMessageType.qml rename to plasmoid/contents/ui/AskMessageDelegate.qml index e47f519..8209e86 100644 --- a/plasmoid/contents/ui/AskMessageType.qml +++ b/plasmoid/contents/ui/AskMessageDelegate.qml @@ -1,128 +1,128 @@ /* Copyright 2016 Aditya Mehra This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) version 3, or any later version accepted by the membership of KDE e.V. (or its successor approved by the membership of KDE e.V.), which shall act as a proxy defined in Section 6 of version 3 of the license. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library. If not, see . */ import QtQuick 2.9 import QtQml.Models 2.2 import QtQuick.Controls 2.2 import org.kde.plasma.components 2.0 as PlasmaComponents import org.kde.plasma.extras 2.0 as PlasmaExtras import org.kde.plasma.core 2.0 as PlasmaCore import QtGraphicalEffects 1.0 Item { width: cbwidth height: messageRect.height + timeStampLabel.height property alias mssg: messageText.text Column{ anchors.fill: parent spacing: 1 Item { id: messageRectFrameItem anchors.right: parent.right width: parent.width height: messageRect.height Rectangle { id: messageRect anchors.right: messageRectedge.left anchors.rightMargin: -2 implicitWidth: messageText.width + 10 radius: 2 height: messageText.implicitHeight + 24 color: theme.linkColor layer.enabled: true layer.effect: DropShadow { horizontalOffset: 0 verticalOffset: 1 radius: 10 samples: 32 spread: 0.1 color: Qt.rgba(0, 0, 0, 0.3) } MouseArea { anchors.fill: parent hoverEnabled: true propagateComposedEvents: true onEntered: { messageRect.color = Qt.darker(theme.linkColor, 1.2) messageRectedgeOverLay.color = Qt.darker(theme.linkColor, 1.2) } onExited: { messageRect.color = theme.linkColor messageRectedgeOverLay.color = theme.linkColor } onClicked: { askCtxMenu.open() } } PlasmaComponents.Label { id: messageText anchors.centerIn: parent wrapMode: Label.Wrap color: theme.backgroundColor Component.onCompleted: { - var askText = model.InputQuery + var askText = model.itemData.queryData var fixedText = askText.substr(0,1).toUpperCase() + askText.substr(1).toLowerCase() messageText.text = fixedText } } } Image { id: messageRectedge anchors.right: parent.right anchors.verticalCenter: messageRect.verticalCenter source: "../images/arright.png" width: units.gridUnit * 0.50 height: messageRect.height / 2 } ColorOverlay { id: messageRectedgeOverLay anchors.fill: messageRectedge source: messageRectedge color: theme.linkColor } } Text{ id: timeStampLabel anchors.right: parent.right anchors.rightMargin: units.gridUnit * 0.50 width: units.gridUnit * 2.5 height: units.gridUnit * 0.50 color: Qt.darker(theme.textColor, 1.5) font.pointSize: theme.defaultFont.pointSize - 2 font.letterSpacing: theme.defaultFont.letterSpacing font.wordSpacing: theme.defaultFont.wordSpacing font.family: theme.defaultFont.family renderType: Text.NativeRendering text: currentDate.toLocaleTimeString(Qt.locale(), Locale.ShortFormat); } } AskMessageTypeMenu{ id: askCtxMenu } } diff --git a/plasmoid/contents/ui/BookType.qml b/plasmoid/contents/ui/BookType.qml deleted file mode 100644 index b07dd9e..0000000 --- a/plasmoid/contents/ui/BookType.qml +++ /dev/null @@ -1,44 +0,0 @@ -/* 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: booktypebg - height: cbheight / 1.8 - width: cbwidth - color: theme.backgroundColor - -ListView { - id: bookmodelview - anchors.fill: parent - model: bookLmodel - focus: false - interactive: true - clip: true; - delegate: BookDelegate{} - } -} - diff --git a/plasmoid/contents/ui/Conversation.js b/plasmoid/contents/ui/Conversation.js index 295f9e7..5f86890 100644 --- a/plasmoid/contents/ui/Conversation.js +++ b/plasmoid/contents/ui/Conversation.js @@ -1,156 +1,140 @@ function getFallBackResult(failedQuery){ var url = "http://api.wolframalpha.com/v1/simple?appid=" + innerset.wolframKey + "&i=" + failedQuery + "&width=1024&fontsize=32" - mycroftConversationComponent.conversationModel.append({"itemType": "FallBackType", "InputQuery": url}) + mycroftConversationComponent.conversationModel.append({itemType: "FallBackType", inputQuery: "", itemData:{fallbackUrl: url}}) } - function filterSpeak(msg){ - mycroftConversationComponent.conversationModel.append({ - "itemType": "NonVisual", - "InputQuery": msg - }) - mycroftConversationComponent.conversationListView.positionViewAtEnd(); + function filterSpeak(msg){ + mycroftConversationComponent.conversationModel.append({itemType: "NonVisual", inputQuery: "", itemData:{queryData: msg}}) + mycroftConversationComponent.conversationListView.positionViewAtEnd(); } function filterincoming(intent, metadata) { var intentVisualArray = ['handle_current_weather']; var itemType var filterintentname = intent.split(':'); var intentname = filterintentname[1]; console.log("IntentName: " + intentname) if (intentVisualArray.indexOf(intentname) !== -1) { switch (intentname){ case "handle_current_weather": itemType = "CurrentWeather" break; } - mycroftConversationComponent.conversationModel.append({"itemType": itemType, "itemData": metadata}) + mycroftConversationComponent.conversationModel.append({itemType: itemType, inputQuery: "", itemData:{weatherData: metadata}}) } else { - mycroftConversationComponent.conversationModel.append({"itemType": "WebViewType", "InputQuery": metadata.url}) + mycroftConversationComponent.conversationModel.append({itemType: "WebViewType", inputQuery: "", itemData:{webviewUrl: metadata.url}}) } } function filtervisualObj(metadata){ - mycroftConversationComponent.conversationModel.append({"itemType": "LoaderType", "InputQuery": metadata.url}) - mycroftConversationComponent.conversationListView.positionViewAtEnd(); + mycroftConversationComponent.conversationModel.append({itemType: "LoaderType", inputQuery: "", itemData:{loaderUrl: metadata.url}}) + mycroftConversationComponent.conversationListView.positionViewAtEnd(); } function filterplacesObj(metadata){ var filteredData = JSON.parse(metadata.data); var locallat = JSON.parse(metadata.locallat); var locallong = JSON.parse(metadata.locallong); var hereappid = metadata.appid var hereappcode = metadata.appcode; mycroftConversationComponent.conversationModel.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), placeicon: JSON.stringify(fltritemsinPlc.icon), placetags: fltrtags, placelocallat: locallat, placelocallong: locallong, placeappid: hereappid, placeappcode: hereappcode}) + mycroftConversationComponent.conversationModel.append({itemType: "PlacesType", inputQuery: "", itemData:{placeposition: JSON.stringify(fltritemsinPlc.position), placetitle: JSON.stringify(fltritemsinPlc.title), placedistance: JSON.stringify(fltritemsinPlc.distance), placeloc: JSON.stringify(fltritemsinPlc.vicinity), placeicon: JSON.stringify(fltritemsinPlc.icon), placetags: fltrtags, placelocallat: locallat, placelocallong: locallong, placeappid: hereappid, placeappcode: hereappcode}}) } - mycroftConversationComponent.conversationModel.append({"itemType": "PlacesType", "InputQuery": ""}); } function getTags(fltrTags){ if(fltrTags){ var tags = ''; for (var i = 0; i < fltrTags.length; i++){ if(tags) tags += ', ' + fltrTags[i].title; else tags += fltrTags[i].title; } return tags; } return ''; } function filterRecipeObj(metadata){ var filteredData = JSON.parse(metadata.data); mycroftConversationComponent.conversationModel.clear() - recipeLmodel.clear() for (var i = 0; i < filteredData.hits.length; i++){ var itemsInRecipes = filteredData.hits[i].recipe var itemsReadRecipe = itemsInRecipes.ingredientLines.join(",") var itemsReadRecipeHealthTags = itemsInRecipes.healthLabels[0] var itemsReadRecipeDietType = itemsInRecipes.dietLabels.join(",") var itemsReadRecipeCalories = Math.round(itemsInRecipes.calories) if(itemsReadRecipeDietType == ""){ itemsReadRecipeDietType = "Normal" } - recipeLmodel.insert(i, {recipeLabel: itemsInRecipes.label, recipeSource: itemsInRecipes.source, recipeImageUrl: itemsInRecipes.image, recipeCalories: itemsReadRecipeCalories, recipeIngredientLines: itemsReadRecipe, recipeDiet: itemsReadRecipeDietType, recipeHealthTags: itemsReadRecipeHealthTags}) + mycroftConversationComponent.conversationModel.append({itemType: "RecipeType", inputQuery: "", itemData:{recipeLabel: itemsInRecipes.label, recipeSource: itemsInRecipes.source, recipeImageUrl: itemsInRecipes.image, recipeCalories: itemsReadRecipeCalories, recipeIngredientLines: itemsReadRecipe, recipeDiet: itemsReadRecipeDietType, recipeHealthTags: itemsReadRecipeHealthTags}}) } - mycroftConversationComponent.conversationModel.append({"itemType": "RecipeType", "InputQuery": ""}) } function filterBalooObj(metadata){ var BalooObj = metadata; var baloosearchTerm = metadata.searchType mycroftConversationComponent.conversationModel.clear() for (var i = 0; i < BalooObj.data.length; i++){ if(baloosearchTerm == "type:audio"){ - mycroftConversationComponent.conversationModel.append({"itemType": "AudioFileType", "InputQuery": metadata.data[i]}) + mycroftConversationComponent.conversationModel.append({itemType: "AudioFileType", inputQuery: "", itemData:{balooData: metadata.data[i]}}) } if(baloosearchTerm == "type:video"){ - mycroftConversationComponent.conversationModel.append({"itemType": "VideoFileType", "InputQuery": metadata.data[i]}) + mycroftConversationComponent.conversationModel.append({itemType: "VideoFileType", inputQuery: "", itemData:{balooData: metadata.data[i]}}) } if(baloosearchTerm == "type:document" || baloosearchTerm == "type:spreadsheet" || baloosearchTerm == "type:presentation" || baloosearchTerm == "type:archive" ){ - mycroftConversationComponent.conversationModel.append({"itemType": "DocumentFileType", "InputQuery": metadata.data[i]}) + mycroftConversationComponent.conversationModel.append({itemType: "DocumentFileType", inputQuery: "", itemData:{balooData: metadata.data[i]}}) } } } function filterstackObj(metadata){ var filterStackMeta = JSON.parse(metadata.data) mycroftConversationComponent.conversationModel.clear() - stackexListModel.clear() for (var i = 0; i < filterStackMeta.items.length; i++){ - 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}) + mycroftConversationComponent.conversationModel.append({itemType: "StackObjType", inputQuery: "", itemData:{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}}) } - mycroftConversationComponent.conversationModel.append({"itemType": "StackObjType", "InputQuery": ""}) mycroftConversationComponent.conversationListView.positionViewAtEnd(); } function filterbookObj(metadata){ var filterBookMeta = JSON.parse(metadata.data) - bookListModel.clear() - bookListModel.append({bookcover: filterBookMeta.bkcover, bookurl: filterBookMeta.bkurl, bookstatus: filterBookMeta.bkstatus, booktitle: filterBookMeta.bktitle, bookauthor: filterBookMeta.bkauthor, bookdate: filterBookMeta.bkyear, bookpublisher: filterBookMeta.bkpublisher}) - mycroftConversationComponent.conversationModel.append({"itemType": "BookType", "InputQuery": ""}) + mycroftConversationComponent.conversationModel.clear() + mycroftConversationComponent.conversationModel.append({itemType: "BookType", inputQuery: "", itemData:{bookcover: filterBookMeta.bkcover, bookurl: filterBookMeta.bkurl, bookstatus: filterBookMeta.bkstatus, booktitle: filterBookMeta.bktitle, bookauthor: filterBookMeta.bkauthor, bookdate: filterBookMeta.bkyear, bookpublisher: filterBookMeta.bkpublisher}}) mycroftConversationComponent.conversationListView.positionViewAtEnd(); } function filterwikiObj(metadata){ var wikiSummary = JSON.stringify(metadata.data.summary) var wikiImage = JSON.stringify(metadata.data.image) wikiSummary = wikiSummary.replace(/['"]+/g, '') wikiImage = wikiImage.replace(/['"]+/g, '') mycroftConversationComponent.conversationModel.clear() - wikiListModel.clear() - wikiListModel.append({summary: wikiSummary, image: wikiImage}) - mycroftConversationComponent.conversationModel.append({"itemType": "WikiType", "InputQuery": ""}) + mycroftConversationComponent.conversationModel.append({itemType: "WikiType", inputQuery: "", itemData:{summary: wikiSummary, image: wikiImage}}) mycroftConversationComponent.conversationListView.positionViewAtEnd(); } function filterwikiMoreObj(metadata){ var wikiSummaryMore = JSON.stringify(metadata.data.summarymore) var wikiImageMore = JSON.stringify(metadata.data.imagemore) mycroftConversationComponent.conversationModel.clear() - wikiListModel.clear() wikiSummaryMore = wikiSummaryMore.replace(/['"]+/g, '') wikiImageMore = wikiImageMore.replace(/['"]+/g, '') - wikiListModel.append({summary: wikiSummaryMore, image: wikiImageMore}) - mycroftConversationComponent.conversationModel.append({"itemType": "WikiType", "InputQuery": ""}) + mycroftConversationComponent.conversationModel.append({itemType: "WikiType", inputQuery: "", itemData:{summary: wikiSummaryMore, image: wikiImageMore}}) } function filteryelpObj(metadata){ var filtermetayelp = metadata - yelpListModel.clear() - 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}) - mycroftConversationComponent.conversationModel.append({"itemType": "YelpType", "InputQuery": ""}) + mycroftConversationComponent.conversationModel.append({itemType: "YelpType", inputQuery: "", itemData:{'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}}) } function filterImageObject(metadata){ - mycroftConversationComponent.conversationModel.append({"itemType": "ImageType", "InputQuery": metadata.data}) + mycroftConversationComponent.conversationModel.append({itemType: "ImageType", inputQuery: "", itemData:{imageData: metadata.data}}) } diff --git a/plasmoid/contents/ui/ConversationLogic.js b/plasmoid/contents/ui/ConversationLogic.js index 555232e..47b5b3e 100644 --- a/plasmoid/contents/ui/ConversationLogic.js +++ b/plasmoid/contents/ui/ConversationLogic.js @@ -1,107 +1,107 @@ function filterConversation(msgType, somestring){ if (msgType === "mycroft.mic.get_status.response") { var micState = somestring.data.muted if(micState) { micIsMuted = true topBarView.micIcon = "mic-off" } else if(!micState) { micIsMuted = false topBarView.micIcon = "mic-on" } } if (msgType === "mycroft.skills.initialized") { PlasmaLa.Notify.mycroftConnectionStatus(i18n("Ready..Let's Talk")) } if (msgType === "recognizer_loop:utterance") { bottomBarView.queryInput.focus = false; var intpost = somestring.data.utterances; bottomBarView.queryInput.text = intpost.toString() - mycroftConversationComponent.conversationModel.append({"itemType": "AskType", "InputQuery": intpost.toString()}) + mycroftConversationComponent.conversationModel.append({itemType: "AskType", inputQuery: "", itemData:{queryData: intpost.toString()}}) topBarView.animateTalk() } if (msgType === "recognizer_loop:utterance" && dashLmodel.count != 0){ Dash.showDash("setHide") } if (somestring.data.handler === "fallback" && somestring.data.fallback_handler === "WolframAlphaSkill.handle_fallback" && somestring.type === "mycroft.skill.handler.complete"){ if(wolframfallbackswitch.checked == true){ Conversation.getFallBackResult(bottomBarView.queryInput.text) } } if (somestring && somestring.data && typeof somestring.data.intent_type !== 'undefined'){ smintent = somestring.data.intent_type; console.log(smintent) } if(somestring && somestring.data && typeof somestring.data.utterance !== 'undefined' && somestring.type === 'speak'){ Conversation.filterSpeak(somestring.data.utterance); } if(somestring && somestring.data && typeof somestring.data.desktop !== 'undefined' && somestring.type === "data") { dataContent = somestring.data.desktop Conversation.filterincoming(smintent, dataContent) } if(somestring && somestring.data && typeof somestring.data.desktop !== 'undefined' && somestring.type === "visualObject") { dataContent = somestring.data.desktop Conversation.filtervisualObj(dataContent) } if(somestring && somestring.data && typeof somestring.data.desktop !== 'undefined' && somestring.type === "placesObject") { dataContent = somestring.data.desktop Conversation.filterplacesObj(dataContent) } if(somestring && somestring.data && typeof somestring.data.desktop !== 'undefined' && somestring.type === "recipesObject") { dataContent = somestring.data.desktop Conversation.filterRecipeObj(dataContent) } if(somestring && somestring.data && typeof somestring.data.desktop !== 'undefined' && somestring.type === "balooObject") { dataContent = somestring.data.desktop Conversation.filterBalooObj(dataContent) } if(somestring && somestring.data && typeof somestring.data.desktop !== 'undefined' && somestring.type === "stackresponseObject") { dataContent = somestring.data.desktop Conversation.filterstackObj(dataContent) } if(somestring && somestring.data && typeof somestring.data.desktop !== 'undefined' && somestring.type === "bookObject") { dataContent = somestring.data.desktop Conversation.filterbookObj(dataContent) } if(somestring && somestring.data && typeof somestring.data.desktop !== 'undefined' && somestring.type === "wikiObject") { dataContent = somestring.data.desktop Conversation.filterwikiObj(dataContent) } if(somestring && somestring.data && typeof somestring.data.desktop !== 'undefined' && somestring.type === "wikiaddObject") { dataContent = somestring.data.desktop Conversation.filterwikiMoreObj(dataContent) } if(somestring && somestring.data && typeof somestring.data.desktop !== 'undefined' && somestring.type === "yelpObject") { dataContent = somestring.data.desktop Conversation.filteryelpObj(dataContent) } if(somestring && somestring.data && typeof somestring.data.desktop !== 'undefined' && somestring.type === "imageObject") { dataContent = somestring.data.desktop Conversation.filterImageObject(dataContent) } if (msgType === "speak" && !plasmoid.expanded && appletSettings.innerset.notifybool == true) { var post = somestring.data.utterance; var title = "Mycroft's Reply:" var notiftext = " "+ post; PlasmaLa.Notify.mycroftResponse(title, notiftext); } } diff --git a/plasmoid/contents/ui/ConversationView.qml b/plasmoid/contents/ui/ConversationView.qml index 6e64a7e..78abbb5 100644 --- a/plasmoid/contents/ui/ConversationView.qml +++ b/plasmoid/contents/ui/ConversationView.qml @@ -1,138 +1,138 @@ /* Copyright 2016 Aditya Mehra This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) version 3, or any later version accepted by the membership of KDE e.V. (or its successor approved by the membership of KDE e.V.), which shall act as a proxy defined in Section 6 of version 3 of the license. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library. If not, see . */ import QtQuick 2.9 import QtQml.Models 2.2 import QtQuick.Controls 2.2 import QtQuick.Layouts 1.3 import Qt.WebSockets 1.0 import Qt.labs.settings 1.0 import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.plasma.plasmoid 2.0 import org.kde.plasma.components 2.0 as PlasmaComponents import org.kde.plasma.components 3.0 as PlasmaComponents3 import org.kde.plasma.extras 2.0 as PlasmaExtras import org.kde.private.mycroftplasmoid 1.0 as PlasmaLa import QtQuick.Window 2.0 import QtGraphicalEffects 1.0 Item { anchors.fill: parent property alias conversationModel: convoLmodel property alias conversationListView: inputlistView property alias conversationViewScrollBar: conversationListScrollBar DropArea { anchors.fill: parent; id: dragTarget onEntered: { for(var i = 0; i < drag.urls.length; i++) if(validateFileExtension(drag.urls[i])) return console.log("No valid files, refusing drag event") drag.accept() dragTarget.enabled = false } onDropped: { for(var i = 0; i < drop.urls.length; i++){ var ext = getFileExtenion(drop.urls[i]); if(ext === "jpg" || ext === "png" || ext === "jpeg"){ var durl = String(drop.urls[i]); mycroftConversationComponent.conversationModel.append({ "itemType": "DropImg", "InputQuery": durl }) inputlistView.positionViewAtEnd(); } if(ext === 'mp3'){ console.log('mp3'); } } } ListModel{ id: convoLmodel } Item { id: messageBox anchors.fill: parent ColumnLayout { id: colconvo anchors.fill: parent ListView { id: inputlistView anchors.left: parent.left anchors.right: parent.right anchors.top: parent.top anchors.bottom: parent.bottom anchors.rightMargin: units.gridUnit * 0.15 verticalLayoutDirection: ListView.TopToBottom spacing: 12 clip: true model: convoLmodel ScrollBar.vertical: conversationListScrollBar delegate: Component { Loader { source: switch(itemType) { - case "NonVisual": return "SimpleMessageType.qml" - case "WebViewType": return "WebViewType.qml" - case "CurrentWeather": return "CurrentWeatherType.qml" - case "DropImg" : return "ImgRecogType.qml" - case "AskType" : return "AskMessageType.qml" - case "LoaderType" : return "LoaderType.qml" - case "PlacesType" : return "PlacesType.qml" - case "RecipeType" : return "RecipeType.qml" + case "NonVisual": return "SimpleMessageDelegate.qml" + case "WebViewType": return "WebViewDelegate.qml" + case "CurrentWeather": return "CurrentWeatherDelegate.qml" + case "DropImg" : return "ImgRecogDelegate.qml" + case "AskType" : return "AskMessageDelegate.qml" + case "LoaderType" : return "LoaderDelagate.qml" + case "PlacesType" : return "PlacesDelegate.qml" + case "RecipeType" : return "RecipeDelegate.qml" case "DashboardType" : return "DashboardType.qml" case "AudioFileType" : return "AudioFileDelegate.qml" case "VideoFileType" : return "VideoFileDelegate.qml" case "DocumentFileType" : return "DocumentFileDelegate.qml" - case "FallBackType" : return "FallbackWebSearchType.qml" - case "StackObjType" : return "StackObjType.qml" - case "BookType" : return "BookType.qml" - case "WikiType" : return "WikiType.qml" - case "YelpType" : return "YelpType.qml" - case "ImageType" : return "ImageType.qml" + case "FallBackType" : return "FallbackWebSearchDelegte.qml" + case "StackObjType" : return "StackObjDelegate.qml" + case "BookType" : return "BookDelegate.qml" + case "WikiType" : return "WikiDelegate.qml" + case "YelpType" : return "YelpDelegate.qml" + case "ImageType" : return "ImageDelegate.qml" } property var metacontent : dataContent } } onCountChanged: { inputlistView.positionViewAtEnd(); } } PlasmaComponents3.ScrollBar { id: conversationListScrollBar orientation: Qt.Vertical interactive: true anchors.right: parent.right anchors.top: parent.top anchors.bottom: parent.bottom } } } } } diff --git a/plasmoid/contents/ui/CurrentWeatherDelegate.qml b/plasmoid/contents/ui/CurrentWeatherDelegate.qml new file mode 100644 index 0000000..de12877 --- /dev/null +++ b/plasmoid/contents/ui/CurrentWeatherDelegate.qml @@ -0,0 +1,133 @@ +/* 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.Window 2.2 +import QtQuick.Layouts 1.3 +import QtQuick.Controls 2.2 +import QtQml.Models 2.2 +import org.kde.plasma.core 2.0 as PlasmaCore +import org.kde.plasma.plasmoid 2.0 +import org.kde.plasma.components 2.0 as PlasmaComponents +import org.kde.plasma.extras 2.0 as PlasmaExtras + +Column { + spacing: 6 + + property var scttemp: metacontent.currentIntent.currenttemp + property var slttemp: metacontent.currentIntent.mintemp + property var shttemp: metacontent.currentIntent.maxtemp + property var ssum: metacontent.currentIntent.sum + property var sloc: metacontent.currentIntent.loc + property var sicon: metacontent.currentIntent.icon + + Row { + id: messageRow + spacing: 6 + + Rectangle{ + id: messageWrapper + width: cbwidthmargin + height: weathbgImg.height + color: theme.backgroundColor + + Image{ + id: weathbgImg + width: cbwidthmargin + height: messageRect.height + + Component.onCompleted: { + if(metacontent.currentIntent.sum.indexOf("scattered") !== -1 && metacontent.currentIntent.sum.indexOf("clouds") !== -1 || metacontent.currentIntent.sum.indexOf("clear") !== -1 || metacontent.currentIntent.sum.indexOf("clouds") !== -1 ){ + weathbgImg.source = "../images/climatesc.jpg" + } + else if(metacontent.currentIntent.sum.indexOf("rain") !== -1){ + weathbgImg.source = "../images/rain.gif" + } + else if(metacontent.currentIntent.sum.indexOf("thunderstorm") !== -1){ + weathbgImg.source = "../images/rain.gif" + } + else if(metacontent.currentIntent.sum.indexOf("snow") !== -1){ + weathbgImg.source = "../images/snow.gif" + } + else if(metacontent.currentIntent.sum.indexOf("snow") !== -1){ + weathbgImg.source = "../images/snow.gif" + } + else if(metacontent.currentIntent.sum.indexOf("haze") !== -1){ + weathbgImg.source = "../images/haze.gif" + } + else { + weathbgImg.source = "" + } + } + + Item { + id: currentWeatherFrame + anchors.fill: parent + + Rectangle { + id: currentWeatherFrameBg + anchors.fill: parent + color: Qt.darker(PlasmaCore.ColorScope.backgroundColor, 1.2) + layer.enabled: true + layer.effect: DropShadow { + horizontalOffset: 0 + verticalOffset: 1 + radius: 10 + samples: 32 + spread: 0.1 + color: Qt.rgba(0, 0, 0, 0.3) + } + + Coloumn { + id: currentWeatherMainArea + spacing: 2 + + anchors.top: parent.top + anchors.bottom: currentWeatherExtendedAreaSeptr.top + Image{ + id: currentWeatherCurrentTempIcon + + Component.onCompleted:{ + var currentWeatherCondition = getCurrentConditionIcon(ssum) + currentWeatherMainArea.source = currentWeatherCurrentTempIcon + } + } + } + Text { + id: weatherCurrentLabel + anchors.left: parent.left + font.pointSize: theme.defaultFont.pointSize + font.letterSpacing: theme.defaultFont.letterSpacing + font.wordSpacing: theme.defaultFont.wordSpacing + font.family: theme.defaultFont.family + renderType: Text.NativeRendering + color: PlasmaCore.ColorScope.textColor + wrapMode: Text.WordWrap; + font.bold: true; + + Component.onCompleted: { + weatherCurrentLabel.text = "Current Temperature: " + scttemp + } + } + } + } + } + } + } +} diff --git a/plasmoid/contents/ui/CurrentWeatherType.qml b/plasmoid/contents/ui/CurrentWeatherType.qml deleted file mode 100644 index 97ce8d7..0000000 --- a/plasmoid/contents/ui/CurrentWeatherType.qml +++ /dev/null @@ -1,255 +0,0 @@ -/* 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.Window 2.2 -import QtQuick.Layouts 1.3 -import QtQuick.Controls 2.2 -import QtQml.Models 2.2 -import org.kde.plasma.core 2.0 as PlasmaCore -import org.kde.plasma.plasmoid 2.0 -import org.kde.plasma.components 2.0 as PlasmaComponents -import org.kde.plasma.extras 2.0 as PlasmaExtras - -Column { - spacing: 6 - - property var scttemp: metacontent.currentIntent.currenttemp - property var slttemp: metacontent.currentIntent.mintemp - property var shttemp: metacontent.currentIntent.maxtemp - property var ssum: metacontent.currentIntent.sum - property var sloc: metacontent.currentIntent.loc - property var sicon: metacontent.currentIntent.icon - - Row { - id: messageRow - spacing: 6 - - Rectangle{ - id: messageWrapper - width: cbwidth - height: weathbgImg.height - color: theme.backgroundColor - - Image{ - id: weathbgImg - width: cbwidth - height: messageRect.height - - Component.onCompleted: { - if(metacontent.currentIntent.sum.indexOf("scattered") !== -1 && metacontent.currentIntent.sum.indexOf("clouds") !== -1 || metacontent.currentIntent.sum.indexOf("clear") !== -1 || metacontent.currentIntent.sum.indexOf("clouds") !== -1 ){ - weathbgImg.source = "../images/climatesc.jpg" - } - else if(metacontent.currentIntent.sum.indexOf("rain") !== -1){ - weathbgImg.source = "../images/rain.gif" - } - else if(metacontent.currentIntent.sum.indexOf("snow") !== -1){ - weathbgImg.source = "../images/snow.gif" - } - else if(metacontent.currentIntent.sum.indexOf("snow") !== -1){ - weathbgImg.source = "../images/snow.gif" - } - else if(metacontent.currentIntent.sum.indexOf("haze") !== -1){ - weathbgImg.source = "../images/haze.gif" - } - else { - weathbgImg.source = "" - } - } - - Item { - id: messageRect - width: cbwidth - height: weatherinfoBar.height + rectanglectt.height + units.gridUnit * 1 - - Rectangle { - id: weatherinfoBar - width: messageRect - color: theme.backgroundColor - height: units.gridUnit * 2 - anchors.top: parent.top - anchors.topMargin: units.gridUnit * 0.5 - anchors.left: parent.left - anchors.right: parent.right - - PlasmaComponents.Label { - id: weatherLocation - anchors.left: parent.left - anchors.leftMargin: 8 - font.capitalization: Font.SmallCaps - font.italic: false - font.bold: true - font.pixelSize: 15 - - Component.onCompleted: { - weatherLocation.text = sloc - } - } - - Row { - id: sumRow - anchors.right: parent.right - anchors.rightMargin: 12 - height: parent.height - spacing: 2 - - Image { - id: weatherIcon - width: units.gridUnit * 1.25 - height: units.gridUnit * 1.25 - anchors.verticalCenter: parent.verticalCenter - Component.onCompleted: { - weatherIcon.source = "http://openweathermap.org/img/w/" + sicon + ".png" - } - } - - PlasmaCore.SvgItem { - id: weatherheaderSeprtr - anchors.verticalCenter: parent.verticalCenter - height: units.gridUnit * 1 - width: whvertseptSvg.elementSize("vertical-line").width - z: 110 - elementId: "vertical-line" - - svg: PlasmaCore.Svg { - id: whvertseptSvg; - imagePath: "widgets/line" - } - } - - PlasmaComponents.Label { - id: weatherSummary - font.italic: true - font.bold: true - font.capitalization: Font.SmallCaps - font.pixelSize: 15 - - Component.onCompleted: { - weatherSummary.text = ssum - } - } - } - } - - PlasmaCore.SvgItem { - anchors { - left: messageRect.left - right: messageRect.right - top: rectanglectt.top - } - width: 1 - height: horlinewthrtopSvg.elementSize("horizontal-line").height - - elementId: "horizontal-line" - z: 110 - svg: PlasmaCore.Svg { - id: horlinewthrtopSvg; - imagePath: "widgets/line" - } - } - - Rectangle { - id: rectanglectt - anchors.left: parent.left - anchors.right: parent.right - height: weatherMinLabel.height + nwsseprator2.height + weatherCurrentLabel.height + nwsseprator3.height + weatherMaxLabel.height + units.gridUnit * 0.50 - color: theme.backgroundColor - anchors.top: weatherinfoBar.bottom - anchors.topMargin: 5 - - Text { - id: weatherMinLabel - anchors.top: parent.top - anchors.topMargin: 1 - anchors.left: parent.left - font.pointSize: theme.defaultFont.pointSize - font.letterSpacing: theme.defaultFont.letterSpacing - font.wordSpacing: theme.defaultFont.wordSpacing - font.family: theme.defaultFont.family - renderType: Text.NativeRendering - color: PlasmaCore.ColorScope.textColor - wrapMode: Text.WordWrap; - font.bold: true; - - Component.onCompleted: { - weatherMinLabel.text = i18n("Minimum Temperature: %1", slttemp) - } - } - - Rectangle { - id: nwsseprator2 - width: parent.width - anchors.top: weatherMinLabel.bottom - anchors.topMargin: 1 - height: 2 - color: theme.linkColor - } - - Text { - id: weatherCurrentLabel - anchors.top: nwsseprator2.bottom - anchors.topMargin: 1 - anchors.left: parent.left - font.pointSize: theme.defaultFont.pointSize - font.letterSpacing: theme.defaultFont.letterSpacing - font.wordSpacing: theme.defaultFont.wordSpacing - font.family: theme.defaultFont.family - renderType: Text.NativeRendering - color: PlasmaCore.ColorScope.textColor - wrapMode: Text.WordWrap; - font.bold: true; - - Component.onCompleted: { - weatherCurrentLabel.text = i18n("Current Temperature: %1", scttemp) - } - } - - Rectangle { - id: nwsseprator3 - width: parent.width - anchors.top: weatherCurrentLabel.bottom - anchors.topMargin: 1 - height: 2 - color: theme.linkColor - } - - Text { - id: weatherMaxLabel - anchors.top: nwsseprator3.bottom - anchors.topMargin: 1 - anchors.left: parent.left - font.pointSize: theme.defaultFont.pointSize - font.letterSpacing: theme.defaultFont.letterSpacing - font.wordSpacing: theme.defaultFont.wordSpacing - font.family: theme.defaultFont.family - renderType: Text.NativeRendering - color: PlasmaCore.ColorScope.textColor - wrapMode: Text.WordWrap; - font.bold: true; - - Component.onCompleted: { - weatherMaxLabel.text = i18n("Maximum Temperature: %1", shttemp) - } - } - } - } - } - } - } -} diff --git a/plasmoid/contents/ui/FallbackWebSearchType.qml b/plasmoid/contents/ui/FallbackWebSearchDelegate.qml similarity index 98% rename from plasmoid/contents/ui/FallbackWebSearchType.qml rename to plasmoid/contents/ui/FallbackWebSearchDelegate.qml index 2810472..d397696 100644 --- a/plasmoid/contents/ui/FallbackWebSearchType.qml +++ b/plasmoid/contents/ui/FallbackWebSearchDelegate.qml @@ -1,85 +1,85 @@ /* Copyright 2016 Aditya Mehra This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) version 3, or any later version accepted by the membership of KDE e.V. (or its successor approved by the membership of KDE e.V.), which shall act as a proxy defined in Section 6 of version 3 of the license. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library. If not, see . */ import QtQuick 2.9 import QtQml.Models 2.2 import QtQuick.Controls 2.2 import org.kde.plasma.components 2.0 as PlasmaComponents import org.kde.plasma.extras 2.0 as PlasmaExtras import org.kde.private.mycroftplasmoid 1.0 as PlasmaLa import QtWebKit 3.0 import QtWebKit.experimental 1.0 Column { spacing: 6 anchors.right: parent.right Row { id: messageRow spacing: 6 Item { id: messageRect width: cbwidth height: newolfFlick.height Flickable { id: newolfFlick width: messageRect.width height: units.gridUnit * 10 contentHeight: wikiview.height clip: true WebView { id: wikiview height: units.gridUnit * 20 width: parent.width - url: InputQuery + url: model.itemData.fallbackUrl experimental.preferredMinimumContentsWidth: cbwidth experimental.useDefaultContentItemSize: false experimental.transparentBackground: true experimental.userStyleSheets: "../code/fallback.css" opacity: 0 onLoadingChanged: { switch (loadRequest.status) { case WebView.LoadSucceededStatus: opacity = 1 return case WebView.LoadStartedStatus: break case WebView.LoadStoppedStatus: break case WebView.LoadFailedStatus: break } opacity = 0 } } ScrollIndicator.vertical: ScrollIndicator { } } } } } diff --git a/plasmoid/contents/ui/ImgRecogType.qml b/plasmoid/contents/ui/ImgRecogType.qml deleted file mode 100644 index 909fec7..0000000 --- a/plasmoid/contents/ui/ImgRecogType.qml +++ /dev/null @@ -1,95 +0,0 @@ -/* 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 org.kde.plasma.components 2.0 as PlasmaComponents -import org.kde.plasma.extras 2.0 as PlasmaExtras - -Column { - id: colmsg - spacing: 6 - anchors.right: parent.right - - readonly property bool sentByMe: model.recipient !== "User" - //property alias mssg: messageText.text - - Row { - id: messageRow - spacing: 6 - - Rectangle { - id: messageRect - width: cbwidth - radius: 2 - height: messageText.implicitHeight - color: "#222" - - Image { - id: messageText - anchors.top: parent.top - anchors.bottom: buttnRow.top - anchors.left: parent.left - anchors.right: parent.right - anchors.margins: 5 - fillMode: Image.PreserveAspectCrop - source: model.InputQuery - sourceSize.width: cbwidth - sourceSize.height: units.gridUnit * 10 - } - - Row { - id: buttnRow - height: units.gridUnit * 2 - anchors.bottom: parent.bottom - - PlasmaComponents.Button { - id: generalImgRecog - width: cbwidth / 2 - height: units.gridUnit * 2 - text: i18n("Broad Recognition") - - onClicked: { - var irecogmsgsend = innerset.customrecog - var socketmessage = {}; - socketmessage.type = "recognizer_loop:utterance"; - socketmessage.data = {}; - socketmessage.data.utterances = [irecogmsgsend + " " + model.InputQuery]; - socket.sendTextMessage(JSON.stringify(socketmessage)); - } - } - PlasmaComponents.Button { - id: ocrImageRecog - width: cbwidth / 2 - height: units.gridUnit * 2 - text: i18n("OCR Recognition") - - onClicked: { - var irecogmsgsend = innerset.customocrrecog - var socketmessage = {}; - socketmessage.type = "recognizer_loop:utterance"; - socketmessage.data = {}; - socketmessage.data.utterances = [irecogmsgsend + " " + model.InputQuery]; - socket.sendTextMessage(JSON.stringify(socketmessage)); - } - } - } - } - } - } diff --git a/plasmoid/contents/ui/StackObjType.qml b/plasmoid/contents/ui/LoaderDelegate.qml similarity index 50% rename from plasmoid/contents/ui/StackObjType.qml rename to plasmoid/contents/ui/LoaderDelegate.qml index 8748938..fe4d1a0 100644 --- a/plasmoid/contents/ui/StackObjType.qml +++ b/plasmoid/contents/ui/LoaderDelegate.qml @@ -1,75 +1,69 @@ /* 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 QtWebKit 3.0 -import QtWebKit.experimental 1.0 +import org.kde.plasma.extras 2.0 as PlasmaExtras +import org.kde.private.mycroftplasmoid 1.0 as PlasmaLa -Rectangle { - id: stackObjBg - height: cbheight +Item { + id: loaderRoot width: cbwidth - color: theme.backgroundColor + height: parent.height + property string filename: "file:///" + model.InputQuery + property int getHeight -Rectangle { - id: powerdByBg - height: units.gridUnit * 1.25 - width: parent.width - color: theme.linkColor - anchors.top: parent.top - - Text { - id: poweredByLbl - width: parent.width - height: parent.height - anchors.left: parent.left - anchors.leftMargin: units.gridUnit * 0.25 - text: i18n("Powered By StackOverflow") - font.capitalization: Font.SmallCaps - color: theme.textColor + Component.onCompleted: { + var mObj = loaderComp.createObject(loaderView, {}) } -} + + Item { + id: loaderItem + width: cbwidth + height: parent.height -ListView { - id: stackObjModelview - anchors.left: parent.left - anchors.right: parent.right - anchors.top: powerdByBg.bottom - anchors.topMargin: units.gridUnit * 0.25 - anchors.bottom: parent.bottom - model: stackLmodel - spacing: 4 - focus: false - interactive: true - clip: true; - delegate: StackObjDelegate{} - ScrollBar.vertical: ScrollBar { - active: true - policy: ScrollBar.AlwaysOn - snapMode : ScrollBar.SnapAlways - } + Item { + id: loaderView + anchors.fill: parent + } + + Component { + id: loaderComp + + Loader { + id: loaderScreen + anchors.left: parent.left + anchors.right: parent.right + height: Math.max(item ? item.implicitHeight : 0, units.gridUnit * 10) + source: filename + + function reload(){ + source = filename + "?t=" + Date.now() + } + + Component.onCompleted: { + loaderScreen.reload(); + getHeight = height + } + } + } + } } -} - diff --git a/plasmoid/contents/ui/LoaderType.qml b/plasmoid/contents/ui/LoaderType.qml deleted file mode 100644 index 0a48b26..0000000 --- a/plasmoid/contents/ui/LoaderType.qml +++ /dev/null @@ -1,81 +0,0 @@ -/* Copyright 2016 Aditya Mehra - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -import QtQuick 2.9 -import QtQml.Models 2.2 -import QtQuick.Controls 2.2 -import org.kde.plasma.components 2.0 as PlasmaComponents -import org.kde.plasma.extras 2.0 as PlasmaExtras -import org.kde.private.mycroftplasmoid 1.0 as PlasmaLa - -Column { - spacing: 6 - anchors.right: parent.right - property string filename: "file:///" + model.InputQuery - property int getHeight - - Component.onCompleted: { - var mObj = loaderComp.createObject(loaderView, {}) - } - - Row { - id: messageRow - spacing: 6 - - Rectangle { - id: messageRect - width: cbwidth - radius: 2 - height: newikiFlick.height - color: theme.backgroundColor - - Flickable { - id: newikiFlick - width: messageRect.width - height: getHeight - - Item { - id: loaderView - anchors.fill: parent - } - - Component { - id: loaderComp - - Loader { - id: loaderScreen - anchors.left: parent.left - anchors.right: parent.right - height: Math.max(item ? item.implicitHeight : 0, units.gridUnit * 10) - source: filename - - function reload(){ - source = filename + "?t=" + Date.now() - } - - Component.onCompleted: { - loaderScreen.reload(); - getHeight = height - } - } - } - } - } - } - } diff --git a/plasmoid/contents/ui/PlacesType.qml b/plasmoid/contents/ui/NavigationComponentView.qml similarity index 79% rename from plasmoid/contents/ui/PlacesType.qml rename to plasmoid/contents/ui/NavigationComponentView.qml index bba9d1b..6f3cdfd 100644 --- a/plasmoid/contents/ui/PlacesType.qml +++ b/plasmoid/contents/ui/NavigationComponentView.qml @@ -1,106 +1,83 @@ /* 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 QtWebKit 3.0 import QtWebKit.experimental 1.0 - -Rectangle { - id: partclc - height: cbheight - width: cbwidth - color: theme.backgroundColor - property alias routeLmodel: routeListModel - Component.onCompleted: { - console.log(cbheight) - } +Item { + id: navigationComponentView + property alias routeLModel: routeListModel + property alias navMapDrawer: navigationMapDrawer ListModel { id: routeListModel } -ListView { - id: placesmodelview - anchors.fill: parent - model: plcLmodel - spacing: 4 - focus: false - interactive: true - clip: true; - delegate: PlacesDelegate{} - ScrollBar.vertical: ScrollBar { - active: true - policy: ScrollBar.AlwaysOn - snapMode : ScrollBar.SnapAlways - } - } - Drawer { - id: navMapDrawer + id: navigationMapDrawer width: parent.width height: cbdrawercontentheight edge: Qt.RightEdge dragMargin: 0 property alias getURL: navMapView.url Rectangle { id: navParentRect width: parent.width height: parent.height color: Qt.lighter(theme.backgroundColor, 1.2) WebView { id: navMapView width: parent.width height: parent.height / 2 experimental.useDefaultContentItemSize: true experimental.userStyleSheets: "../code/maps.css" experimental.page.height: navMapView.height experimental.page.width: parent.width } ListView { id: navMapDirections anchors.top: navMapView.bottom anchors.left: parent.left anchors.right: parent.right anchors.bottom: parent.bottom - model: routeLmodel + model: routeListModel spacing: 2 focus: false interactive: true clip: true; delegate: NavigationDelegate{} ScrollBar.vertical: ScrollBar { active: true policy: ScrollBar.AlwaysOn snapMode : ScrollBar.SnapAlways - } - } - } - } + } + } + } + } } - diff --git a/plasmoid/contents/ui/PlacesDelegate.qml b/plasmoid/contents/ui/PlacesDelegate.qml index ba706c2..afc0927 100644 --- a/plasmoid/contents/ui/PlacesDelegate.qml +++ b/plasmoid/contents/ui/PlacesDelegate.qml @@ -1,218 +1,233 @@ /* 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 +Item { + id: placesMainDelegate + width: cbwidth + height: nearbyDelegateItm.height + + function getRouteInformation(llat, llong, dlat, dlong, oappid, oappcode){ + var routedoc = new XMLHttpRequest() + var url = "https://route.cit.api.here.com/routing/7.2/calculateroute.json?waypoint0=" + llat + "," + llong + "&waypoint1=" + dlat + "," + dlong + "&mode=fastest;car;&app_id=" + oappid + "&app_code=" + oappcode + "&depature=now" + routedoc.open("GET", url, true); + routedoc.send() + + routedoc.onreadystatechange = function() { + if (routedoc.readyState === XMLHttpRequest.DONE && routedoc.responseText !== "undefined") { + var reqroute = routedoc.responseText + if (reqroute !== "undefined") { + var filterRouteDict = JSON.parse(reqroute) + for (var i = 0; imtrs", placedistance) + text: "Distance: " + model.itemData.placedistance + " mtrs" } } Rectangle { id: placesCrdSeptHeader height: 1 anchors { left: parent.left right: parent.right top: skillTopRowLayout.bottom topMargin: units.gridUnit * 0.2 } color: theme.linkColor } Item { id: plcinner anchors.top: placesCrdSeptHeader.bottom anchors.topMargin: units.gridUnit * 0.15 anchors.left: parent.left anchors.right: parent.right anchors.bottom: parent.bottom Item { id: plcinnerdetails anchors.left: parent.left anchors.right: parent.right anchors.top: parent.top height: navbbtn.height Image { id: placeIconType anchors.left: parent.left anchors.leftMargin: units.gridUnit * 0.05 anchors.verticalCenter: parent.verticalCenter - source: placeicon.replace(/["']/g, "") + source: model.itemData.placeicon.replace(/["']/g, "") width: units.gridUnit * 2 height: units.gridUnit * 2 } PlasmaComponents.Label { id: placeAddressLabel anchors.left: placeIconType.right anchors.leftMargin: units.gridUnit * 0.05 wrapMode: Text.WordWrap; font.bold: true; font.pointSize: theme.defaultFont.pointSize font.letterSpacing: theme.defaultFont.letterSpacing font.wordSpacing: theme.defaultFont.wordSpacing font.family: theme.defaultFont.family renderType: Text.NativeRendering - text: i18n("Address: %1", placeloc.replace(/["']/g, "")) + text: "Address: " + model.itemData.placeloc.replace(/["']/g, "") } Image { id: navbbtn anchors.right: parent.right anchors.margins: units.gridUnit * 0.5 source: "../images/up.png" width: units.gridUnit * 2 height: units.gridUnit * 2 MouseArea { anchors.fill: parent onClicked: { - var navpos = placeposition.replace(/[[\]]/g,'').split(","); - getRouteInformation(placelocallat, placelocallong, navpos[0], navpos[1], placeappid, placeappcode) - var formatedurl = "https://image.maps.cit.api.here.com/mia/1.6/mapview?c=" + placelocallat + "," + placelocallong + "&z=16&poi=" + navpos[0] + "," + navpos[1] + "&poithm=0&app_id=" + placeappid + "&app_code=" + placeappcode + "&h=" + cbheight / 2 + "&w=" + cbwidth + "&ppi=500ppi=120&t=7&f=2&i=true" - navMapDrawer.open() - navMapDrawer.getURL = formatedurl + var navpos = model.itemData.placeposition.replace(/[[\]]/g,'').split(","); + getRouteInformation(model.itemData.placelocallat, model.itemData.placelocallong, navpos[0], navpos[1], model.itemData.placeappid, model.itemData.placeappcode) + var formatedurl = "https://image.maps.cit.api.here.com/mia/1.6/mapview?c=" + model.itemData.placelocallat + "," + model.itemData.placelocallong + "&z=16&poi=" + navpos[0] + "," + navpos[1] + "&poithm=0&app_id=" + model.itemData.placeappid + "&app_code=" + model.itemData.placeappcode + "&h=" + cbheight / 2 + "&w=" + cbwidth + "&ppi=500ppi=120&t=7&f=2&i=true" + navComponentView.navMapDrawer.open() + navComponentView.navMapDrawer.getURL = formatedurl } } } } Rectangle { id: placesCrdSeptFooter height: apiCreds.height anchors { left: parent.left right: parent.right bottom: parent.bottom } color: theme.linkColor PlasmaComponents.Label { id: tagsplccs anchors.left: parent.left anchors.leftMargin: units.gridUnit * 0.15 anchors.right: apiCreds.left anchors.verticalCenter: parent.verticalCenter wrapMode: Text.WordWrap; font.pointSize: theme.defaultFont.pointSize - 2 - text: placetags + text: model.itemData.placetags } PlasmaComponents.Label { id: apiCreds anchors.right: parent.right anchors.rightMargin: units.gridUnit * 0.15 anchors.verticalCenter: parent.verticalCenter wrapMode: Text.WordWrap; font.bold: true font.pointSize: theme.defaultFont.pointSize - 2 text: i18n("Powered By: Here.API") + } } - } - } + } + } } } +} diff --git a/plasmoid/contents/ui/RecipeDelegate.qml b/plasmoid/contents/ui/RecipeDelegate.qml index 21fe0c5..c59edca 100644 --- a/plasmoid/contents/ui/RecipeDelegate.qml +++ b/plasmoid/contents/ui/RecipeDelegate.qml @@ -1,155 +1,170 @@ /* 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 +Item { + id: recipesMainDelegate + width: cbwidth + height: recipeDelegateItm.height + +RecipeExtraComponentView{ + id: recipesExtraView +} + +Column { + id: contentFrameColumn + anchors.fill: parent + Rectangle { id: recipeDelegateItm height: units.gridUnit * 6 color: Qt.darker(theme.backgroundColor, 1.2) anchors.left: parent.left anchors.right: parent.right width: cbwidth property alias viewbtnClickItem: recipeViewBtn Column { id: contentdlgtitem anchors.fill: parent Text { id: recipename anchors.left: parent.left anchors.right: parent.right wrapMode: Text.WordWrap; font.bold: true; - text: recipeLabel.replace(/["']/g, "") + text: model.itemData.recipeLabel.replace(/["']/g, "") color: theme.textColor } Rectangle { anchors.left: parent.left anchors.right: parent.right color: theme.linkColor height: units.gridUnit * 0.1 } Item { id: recipeinner height: units.gridUnit * 4 width: cbwidth Image { id: recipeImgType - source: recipeImageUrl + source: model.itemData.recipeImageUrl anchors.left: parent.left width: units.gridUnit * 4 height: units.gridUnit * 4 } Item { id: recipeInnerInfoColumn height: parent.height anchors.left: recipeImgType.right Text{ id: recipeCalorieCount width: parent.width; color: theme.textColor ; anchors.top: parent.top anchors.left: parent.left anchors.leftMargin: units.gridUnit * 0.25 height: units.gridUnit * 1 - text: i18n("Calories: %1 cal", recipeCalories) + text: "Calories: " + model.itemData.recipeCalories +" cal" } Text{ id: recipeDietLabel width: parent.width; color: theme.textColor ; anchors.top: recipeCalorieCount.bottom anchors.left: parent.left anchors.leftMargin: units.gridUnit * 0.25 height: units.gridUnit * 1 - text: i18n("Diet Type: %1", recipeDiet) + text: "Diet Type: " + model.itemData.recipeDiet } Text{ id: recipeHealthTagsLabel width: parent.width; color: theme.textColor ; anchors.top: recipeDietLabel.bottom anchors.left: parent.left anchors.leftMargin: units.gridUnit * 0.25 height: units.gridUnit * 1 - text: i18n("Health Tags: %1", recipeHealthTags) + text: "Health Tags: " + model.itemData.recipeHealthTags } } PlasmaComponents.Button { id: recipeViewBtn anchors.right: parent.right width: units.gridUnit * 6; height: units.gridUnit * 4; - text: i18n("View Recipe") + text: "View Recipe" onClicked: { - recipeReadLmodel.clear() - recipeReadDrawer.open() - recipeReadDrawer.recipeReadDrawerHeader = "" + recipeLabel.replace(/["']/g, "") + "" + recipesExtraView.recipeReadLmodel.clear() + recipesExtraView.recipeReadDrawer.open() + recipesExtraView.recipeReadDrawer.recipeReadDrawerHeader = "" + model.itemData.recipeLabel.replace(/["']/g, "") + "" var readRecipeLines = recipeIngredientLines.split(",") for(var i = 0; i < readRecipeLines.length; i++){ - recipeReadLmodel.append({ingredients: readRecipeLines[i]}) + recipeReadLmodel.append({ingredients: model.itemData.readRecipeLines[i]}) } } } } Rectangle { id: recipeFooterSrc anchors.left: parent.left anchors.right: parent.right color: theme.linkColor height: units.gridUnit * 1 Text { color: theme.textColor; font.pixelSize: 10 - text: i18n("Recipe Source: %1", recipeSource) + text: "Recipe Source: " + model.itemData.recipeSource + "" anchors.left: parent.left anchors.leftMargin: units.gridUnit * 0.25 anchors.verticalCenter: parent.verticalCenter } Text { color: theme.textColor ; font.pixelSize: 10 - text: i18n("Powered By: Edamam.com") + text: "Powered By: Edamam.com" anchors.right: parent.right anchors.rightMargin: units.gridUnit * 0.25 anchors.verticalCenter: parent.verticalCenter + } } } } } +} diff --git a/plasmoid/contents/ui/RecipeType.qml b/plasmoid/contents/ui/RecipeExtraComponentView.qml similarity index 91% rename from plasmoid/contents/ui/RecipeType.qml rename to plasmoid/contents/ui/RecipeExtraComponentView.qml index b5bcc84..8856cc0 100644 --- a/plasmoid/contents/ui/RecipeType.qml +++ b/plasmoid/contents/ui/RecipeExtraComponentView.qml @@ -1,163 +1,145 @@ /* 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: partclc - height: cbheight - width: cbwidth - color: theme.backgroundColor +Item { + id: recipeReadMain property alias recipeReadLVModel: recipeReadListView.model + property alias recipeReadDrawer: recipeContentsDrawer Connections { target: main2 ignoreUnknownSignals: true onRecipeMethod: { var getRecipeTitle = msgRecipeMethod for (var i = 0; i < recipeLmodel.count; i++) { var recipemodelLables = recipeLmodel.get(i).recipeLabel.toLowerCase(); recipemodelLables.replace(/\W/g, ''); if (recipemodelLables == getRecipeTitle) { recipesmodelview.contentItem.children[i].viewbtnClickItem.clicked() } } } } -ListView { - id: recipesmodelview - anchors.fill: parent - model: recipeLmodel - spacing: 4 - focus: false - interactive: true - clip: true; - delegate: RecipeDelegate{} - ScrollBar.vertical: ScrollBar { - active: true - policy: ScrollBar.AlwaysOn - snapMode : ScrollBar.SnapAlways - } - } - Drawer { - id: recipeReadDrawer + id: recipeContentsDrawer width: parent.width height: cbdrawercontentheight edge: Qt.RightEdge dragMargin: 0 property alias recipeReadDrawerHeader: recipeReadDrwHeaderLabel.text Rectangle { id: recipeReadParentRect width: parent.width height: parent.height color: theme.backgroundColor Rectangle { id: recipeReadDrwHeaderSrc anchors.top: parent.top anchors.left: parent.left anchors.right: parent.right color: theme.linkColor height: units.gridUnit * 2 Text { id: recipeReadDrwHeaderLabel color: theme.textColor; anchors.left: parent.left anchors.leftMargin: units.gridUnit * 0.25 anchors.verticalCenter: parent.verticalCenter } PlasmaCore.IconItem { id: recipeReadDrwHeaderSpeakIcon anchors.right: parent.right anchors.rightMargin: units.gridUnit * 0.25 anchors.verticalCenter: parent.verticalCenter source: "minuet-scales" width: units.gridUnit * 1.25 height: units.gridUnit * 1.25 } } ListView { id: recipeReadListView anchors.top: recipeReadDrwHeaderSrc.bottom anchors.left: parent.left anchors.right: parent.right anchors.bottom: recipeReadDrwFooterSrc.top model: recipeReadLmodel spacing: 3 focus: false interactive: true clip: true; delegate: RecipeReadDelegate{} ScrollBar.vertical: ScrollBar { active: true policy: ScrollBar.AlwaysOn snapMode : ScrollBar.SnapAlways } } Rectangle { id: recipeReadDrwFooterSrc anchors.bottom: parent.bottom anchors.left: parent.left anchors.right: parent.right color: theme.linkColor height: units.gridUnit * 1 PlasmaCore.IconItem { id: recipeReadDrwFooterCloseIcon anchors.right: recipeReadDrwCloseLbl.left anchors.leftMargin: units.gridUnit * 0.25 anchors.verticalCenter: parent.verticalCenter source: "window-close" width: units.gridUnit * 1 height: units.gridUnit * 1 } Text { id: recipeReadDrwCloseLbl color: theme.textColor; text: i18n("Close Ingredients List") anchors.horizontalCenter: parent.horizontalCenter anchors.verticalCenter: parent.verticalCenter } MouseArea{ anchors.fill: parent onClicked: { recipeReadDrawer.close() } } } } } } diff --git a/plasmoid/contents/ui/SimpleMessageType.qml b/plasmoid/contents/ui/SimpleMessageDelegate.qml similarity index 99% rename from plasmoid/contents/ui/SimpleMessageType.qml rename to plasmoid/contents/ui/SimpleMessageDelegate.qml index 36cd2e5..d9650f2 100644 --- a/plasmoid/contents/ui/SimpleMessageType.qml +++ b/plasmoid/contents/ui/SimpleMessageDelegate.qml @@ -1,143 +1,143 @@ /* Copyright 2016 Aditya Mehra This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) version 3, or any later version accepted by the membership of KDE e.V. (or its successor approved by the membership of KDE e.V.), which shall act as a proxy defined in Section 6 of version 3 of the license. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library. If not, see . */ import QtQuick 2.9 import QtQml.Models 2.2 import QtQuick.Controls 2.2 import org.kde.plasma.components 2.0 as PlasmaComponents import org.kde.plasma.extras 2.0 as PlasmaExtras import org.kde.plasma.core 2.0 as PlasmaCore import QtGraphicalEffects 1.0 Item { width: cbwidth height: messageRect.height + timeStampLabel.height property alias mssg: messageText.text Row { id: messageRow spacing: 6 Item { id: repImgBox width: units.gridUnit * 2 height: units.gridUnit * 2 Image { id: repImg anchors.fill: parent source: "../images/mycroftsmaller2.png" } ColorOverlay { anchors.fill: repImg source: repImg color: theme.linkColor } } Column{ spacing: 1 Item { id: simplemsgRectFrameItem width: cbwidth height: messageRect.height Rectangle { id: messageRect anchors.left: simpleMsgRectedge.right anchors.leftMargin: -2 width: cbwidth - units.gridUnit * 2 radius: 2 height: messageText.implicitHeight + 24 color: Qt.lighter(theme.backgroundColor, 1.2) layer.enabled: true layer.effect: DropShadow { horizontalOffset: 0 verticalOffset: 1 radius: 10 samples: 32 spread: 0.1 color: Qt.rgba(0, 0, 0, 0.3) } MouseArea { anchors.fill: parent hoverEnabled: true propagateComposedEvents: true onEntered: { messageRect.color = Qt.lighter(theme.backgroundColor, 1.5) simpleMsgRectedgeOverLay.color = Qt.lighter(theme.backgroundColor, 1.5) } onExited: { messageRect.color = Qt.lighter(theme.backgroundColor, 1.2) simpleMsgRectedgeOverLay.color = Qt.lighter(theme.backgroundColor, 1.2) } onClicked:{ simpleCtxMenu.open() } } PlasmaComponents.Label { id: messageText - text: model.InputQuery + text: model.itemData.queryData anchors.fill: parent anchors.margins: 12 wrapMode: Label.Wrap } } Image { id: simpleMsgRectedge anchors.left: parent.left anchors.top: parent.top source: "../images/arleft.png" width: units.gridUnit * 0.50 height: units.gridUnit * 1.25 } ColorOverlay { id: simpleMsgRectedgeOverLay anchors.fill: simpleMsgRectedge source: simpleMsgRectedge color: Qt.lighter(theme.backgroundColor, 1.2) } } Text { id: timeStampLabel anchors.left: parent.left anchors.leftMargin: units.gridUnit * 0.50 width: units.gridUnit * 2.5 height: units.gridUnit * 0.50 color: Qt.darker(theme.textColor, 1.5) font.pointSize: theme.defaultFont.pointSize - 2 font.letterSpacing: theme.defaultFont.letterSpacing font.wordSpacing: theme.defaultFont.wordSpacing font.family: theme.defaultFont.family renderType: Text.NativeRendering text: currentDate.toLocaleTimeString(Qt.locale(), Locale.ShortFormat); } } } SimpleMessageTypeMenu{ id: simpleCtxMenu } } diff --git a/plasmoid/contents/ui/TomorrowWeatherType.qml b/plasmoid/contents/ui/TomorrowWeatherType.qml deleted file mode 100644 index 6d44926..0000000 --- a/plasmoid/contents/ui/TomorrowWeatherType.qml +++ /dev/null @@ -1,162 +0,0 @@ -/* 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.Window 2.2 -import QtQuick.Layouts 1.3 -import QtQuick.Controls 2.2 -import QtQml.Models 2.2 -import org.kde.plasma.core 2.0 as PlasmaCore -import org.kde.plasma.plasmoid 2.0 -import org.kde.plasma.components 2.0 as PlasmaComponents -import org.kde.plasma.extras 2.0 as PlasmaExtras - -Column { - spacing: 6 - property alias lttemp: lowtempitem.text - property alias httemp: hightempitem.text - - Row { - id: messageRow - spacing: 6 - - Rectangle{ - id: messageWrapper - width: cbwidth - height: messageRect.height - color: theme.backgroundColor - - Rectangle { - id: messageRect - width: cbwidth / 1.1 - height: 100 - //anchors.right: avatar.right - color: theme.backgroundColor - - - Rectangle { - id: rectangleltt - width: 100 - height: 60 - color: "#00000000" - anchors.top: todayweather.bottom - anchors.topMargin: 5 - anchors.left: parent.left - anchors.leftMargin: 0 - - PlasmaComponents.Label { - id: lowtemplable - anchors.left: parent.left - anchors.verticalCenter: lowtempaniimage.verticalCenter - text: i18n("Low") -// font.family: "Courier" - font.pointSize: 12 - font.bold: true - anchors.top: parent.top - anchors.topMargin: 8 - anchors.leftMargin: 30 - } - - PlasmaComponents.Label { - id: lowtempitem - x: 63 - y: 33 - anchors.top: lowtemplable.bottom - text: i18n("100") - anchors.horizontalCenter: lowtemplable.horizontalCenter - anchors.topMargin: 10 - } - - PlasmaComponents.Label { - id: weatherwidgetlowtempdegree - text: i18n("°") - anchors.verticalCenterOffset: -5 - anchors.verticalCenter: lowtempitem.verticalCenter - anchors.left: lowtempitem.right - anchors.leftMargin: 5 - font.pixelSize: 12 - } - - - } - - Rectangle { - id: rectanglehtt - width: 100 - height: 60 - color: "#00000000" - anchors.top: todayweather.bottom - anchors.topMargin: 5 - anchors.left: rectangleltt.right - anchors.leftMargin: 0 - - PlasmaComponents.Label { - id: hightempitem - x: 65 - y: 70 - anchors.top: hightemplable.bottom - text: i18n("100") - anchors.topMargin: 10 - anchors.horizontalCenter: hightemplable.horizontalCenter - } - - PlasmaComponents.Label { - id: hightemplable - anchors.left: parent.left - text: i18n("High") - font.pointSize: 12 - font.bold: true - // font.family: "Courier" - anchors.top: parent.top - anchors.topMargin: 8 - anchors.verticalCenter: hightempaniimage.verticalCenter - anchors.leftMargin: 30 - } - - PlasmaComponents.Label { - id: weatherwidgethightempdegree - text: i18n("°") - anchors.verticalCenterOffset: -5 - anchors.verticalCenter: hightempitem.verticalCenter - anchors.left: hightempitem.right - anchors.leftMargin: 5 - font.pixelSize: 12 - } - - - } - - PlasmaComponents.Label { - id: todayweather - text: i18n("Tomorrow's Weather") - anchors.left: parent.left - anchors.leftMargin: 9 - // font.family: "Courier" - font.italic: false - font.bold: true - font.pixelSize: 17 - } - - - - } - } - - } -} diff --git a/plasmoid/contents/ui/WebViewType.qml b/plasmoid/contents/ui/WebViewType.qml deleted file mode 100644 index bac0108..0000000 --- a/plasmoid/contents/ui/WebViewType.qml +++ /dev/null @@ -1,94 +0,0 @@ -/* Copyright 2016 Aditya Mehra - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -import QtQuick 2.9 -import QtQml.Models 2.2 -import QtQuick.Controls 2.2 -import org.kde.plasma.components 2.0 as PlasmaComponents -import org.kde.plasma.extras 2.0 as PlasmaExtras -import org.kde.private.mycroftplasmoid 1.0 as PlasmaLa -import QtWebKit 3.0 -import QtWebKit.experimental 1.0 - -Column { - spacing: 6 - anchors.right: parent.right - - Row { - id: messageRow - spacing: 6 - - Rectangle { - id: messageRect - width: cbwidth - radius: 2 - height: newikiFlick.height - color: theme.backgroundColor - - Flickable { - id: newikiFlick - width: messageRect.width - height: units.gridUnit * 10 - - WebView { - id: wikiview - anchors.fill: parent - experimental.preferredMinimumContentsWidth: 450 - url: model.InputQuery - - Rectangle { - id: hoverBg1 - anchors.right: parent.right - anchors.rightMargin: 15 - anchors.top: parent.top - anchors.topMargin: 5 - visible: true - height: units.gridUnit * 2.2 - width: units.gridUnit * 2.2 - radius: 10 - z: 2 - color: theme.backgroundColor - - PlasmaComponents.ToolButton { - id: viewExtendedScreen - anchors.verticalCenter: parent.verticalCenter - anchors.horizontalCenter: parent.horizontalCenter - visible: true - iconSource: "file-zoom-in" - flat: false - checked: false - focus: false - height: units.gridUnit * 2 - width: units.gridUnit * 2 - z: 10 - - onClicked: { - var browsrUrl = model.InputQuery - PlasmaLa.LaunchApp.runCommand("x-www-browser", browsrUrl) - } - } - } - - } - ScrollIndicator.vertical: ScrollIndicator { } - - } - } - } - } diff --git a/plasmoid/contents/ui/WikiType.qml b/plasmoid/contents/ui/WikiType.qml deleted file mode 100644 index e7ee932..0000000 --- a/plasmoid/contents/ui/WikiType.qml +++ /dev/null @@ -1,51 +0,0 @@ -/* 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: wikiTypeBase - height: cbheight - width: cbwidth - color: theme.backgroundColor - - ListView { - id: wikimodelview - height: cbheight - width: cbwidth - model: wikiLmodel - spacing: 4 - focus: false - interactive: true - clip: true; - delegate: WikiDelegate{} - ScrollBar.vertical: ScrollBar { - active: true - policy: ScrollBar.AlwaysOn - snapMode : ScrollBar.SnapAlways - } - } -} - diff --git a/plasmoid/contents/ui/YelpType.qml b/plasmoid/contents/ui/YelpType.qml deleted file mode 100644 index dcacb16..0000000 --- a/plasmoid/contents/ui/YelpType.qml +++ /dev/null @@ -1,50 +0,0 @@ -/* 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: yelppartclc - height: cbheight - width: cbwidth - color: theme.backgroundColor - -ListView { - id: yelpmodelview - anchors.fill: parent - model: yelpLmodel - spacing: 4 - focus: false - interactive: true - clip: true; - delegate: YelpDelegate{} - ScrollBar.vertical: ScrollBar { - active: true - policy: ScrollBar.AlwaysOn - snapMode : ScrollBar.SnapAlways - } - } -} - diff --git a/plasmoid/contents/ui/main.qml b/plasmoid/contents/ui/main.qml index 510cc86..24c641c 100644 --- a/plasmoid/contents/ui/main.qml +++ b/plasmoid/contents/ui/main.qml @@ -1,460 +1,426 @@ /* Copyright 2016 Aditya Mehra This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) version 3, or any later version accepted by the membership of KDE e.V. (or its successor approved by the membership of KDE e.V.), which shall act as a proxy defined in Section 6 of version 3 of the license. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library. If not, see . */ import QtQuick 2.9 import QtQml.Models 2.2 import QtQuick.Controls 2.2 import QtQuick.Layouts 1.3 import Qt.WebSockets 1.0 import Qt.labs.settings 1.0 import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.plasma.plasmoid 2.0 import org.kde.plasma.components 2.0 as PlasmaComponents import org.kde.plasma.components 3.0 as PlasmaComponents3 import org.kde.plasma.extras 2.0 as PlasmaExtras import org.kde.private.mycroftplasmoid 1.0 as PlasmaLa import QtQuick.Window 2.0 import QtGraphicalEffects 1.0 import "Applet.js" as Applet import "Autocomplete.js" as Autocomplete import "Conversation.js" as Conversation import "ConversationLogic.js" as ConversationLogic import "Dashboard.js" as Dash Item { id: main Layout.fillWidth: true; Plasmoid.toolTipMainText: i18n("Mycroft") Plasmoid.switchWidth: units.gridUnit * 15 Plasmoid.switchHeight: units.gridUnit * 15 Layout.minimumWidth: units.gridUnit * 26 Component.onCompleted: { mycroftStatusCheckSocket.active = true Applet.detectInstallType(); Applet.refreshAllSkills(); } property var skillList: [] property alias cbwidth: conversationViewFrameBox.width property var cbwidthmargin: conversationViewFrameBox.width - mycroftConversationComponent.conversationViewScrollBar.width - units.gridUnit * 0.25 property alias cbheight: conversationViewFrameBox.height property var dwrpaddedwidth: main.width + units.gridUnit * 1 property var cbdrawercontentheight: parent.height + units.gridUnit * 0.5 - rectanglebottombar.height property string defaultmcorestartpath: "/usr/share/plasma/plasmoids/org.kde.plasma.mycroftplasmoid/contents/code/startservice.sh" property string defaultmcorestoppath: "/usr/share/plasma/plasmoids/org.kde.plasma.mycroftplasmoid/contents/code/stopservice.sh" property string packagemcorestartcmd: "/usr/share/plasma/plasmoids/org.kde.plasma.mycroftplasmoid/contents/code/pkgstartservice.sh" property string packagemcorestopcmd: "/usr/share/plasma/plasmoids/org.kde.plasma.mycroftplasmoid/contents/code/pkgstopservice.sh" property string customlocstartpath: startsrvcustom.text property string customlocstoppath: stopsrvcustom.text property string customloc: " " property string coreinstallstartpath: defaultmcorestartpath property string coreinstallstoppath: defaultmcorestoppath property variant searchIndex: [] property variant results: [] property var smintent property var dataContent property alias textInput: bottomBarView.queryInput - property alias plcLmodel: placesListModel property alias dashLmodel: dashListModel - property alias recipeLmodel: recipesListModel - property alias recipeReadLmodel: recipeReadListModel - property alias stackLmodel: stackexListModel - property alias bookLmodel: bookListModel - property alias wikiLmodel: wikiListModel - property alias yelpLmodel: yelpListModel property bool intentfailure: false property bool locationUserSelected: false property bool connectCtx: false property bool micIsMuted property var geoLat property var geoLong property var globalcountrycode property var weatherMetric: "metric" property date currentDate: new Date() Connections { target: plasmoid onExpandedChanged: { if (plasmoid.expanded) { Dash.checkDashStatus() } } } Connections { target: PlasmaLa.Notify onNotificationStopSpeech: { var socketmessage = {}; socketmessage.type = "recognizer_loop:utterance"; socketmessage.data = {}; socketmessage.data.utterances = ["stop"]; socket.sendTextMessage(JSON.stringify(socketmessage)); } onNotificationShowResponse: { plasmoid.expanded = !plasmoid.expanded tabBar.currentTab = mycroftTab } } Connections { target: main2 ignoreUnknownSignals: true onSendShowMycroft: { plasmoid.expanded = !plasmoid.expanded tabBar.currentTab = mycroftTab } onSendShowSkills: { tabBar.currentTab = mycroftSkillsTab if(plasmoid.expanded = !plasmoid.expanded){ plasmoid.expanded } } onInstallList: { tabBar.currentTab = mycroftMSMinstTab if(plasmoid.expanded = !plasmoid.expanded){ plasmoid.expanded } } onKioMethod: { var sentFromKio = msgKioMethod var socketmessage = {}; socketmessage.type = "recognizer_loop:utterance"; socketmessage.data = {}; socketmessage.data.utterances = [sentFromKio]; socket.sendTextMessage(JSON.stringify(socketmessage)); } } PlasmaCore.DataSource { id: geoDataSource dataEngine: "geolocation" onSourceAdded: { connectSource(source) } onNewData: { mycroftConversationComponent.conversationModel.clear() if (sourceName == "location"){ geoLat = data.latitude geoLong = data.longitude var globalcountry = data.country globalcountrycode = globalcountry.substring(0, 2) Dash.showDash("setVisible") } } } ListModel { id: dashListModel } - -ListModel { - id: placesListModel - } - -ListModel{ - id: recipesListModel - } - -ListModel { - id: recipeReadListModel - } - -ListModel { - id: stackexListModel - } - -ListModel { - id: bookListModel - } - -ListModel { - id: wikiListModel - } -ListModel { - id: yelpListModel - } Timer { id: timer } function delay(delayTime, cb) { timer.interval = delayTime; timer.repeat = false; timer.triggered.connect(cb); timer.start(); } Item { id: topBar Layout.fillWidth: true height: units.gridUnit * 2 z: 101 anchors { top: main.top topMargin: -1 left: main.left leftMargin: -1 right: main.right rightMargin: -1 } TopBarViewComponent { id: topBarView } } PlasmaCore.SvgItem { anchors { left: main.left right: main.right top: root.top } width: 1 height: horlinetopbarSvg.elementSize("horizontal-line").height elementId: "horizontal-line" z: 110 svg: PlasmaCore.Svg { id: horlinetopbarSvg; imagePath: "widgets/line" } } Item { id: root anchors { top: topBar.bottom bottom: rectanglebottombar.top left: parent.left right: parent.right } WebSocket { id: mycroftStatusCheckSocket url: appletSettings.innerset.wsurl active: true property bool _socketIsAlreadyActive: false onStatusChanged: Applet.preSocketStatus() } WebSocket { id: socket url: appletSettings.innerset.wsurl onTextMessageReceived: { var somestring = JSON.parse(message) var msgType = somestring.type; Applet.playwaitanim(msgType); ConversationLogic.filterConversation(msgType, somestring) topBarView.animateTalk() } onStatusChanged: Applet.mainSocketStatus() } ColumnLayout { id: sidebar height: units.gridUnit * 6 width: units.gridUnit * 2 PlasmaComponents.TabBar { id: tabBar anchors.fill: parent tabPosition: Qt.LeftEdge; PlasmaComponents.TabButton { id: mycroftTab Layout.fillHeight: true Layout.fillWidth: true iconSource: "go-home" PlasmaCore.ToolTipArea { id: tooltiptab1 mainText: i18n("Conversation") anchors.fill: parent } } PlasmaComponents.TabButton { id: mycroftSkillsTab Layout.fillHeight: true Layout.fillWidth: true iconSource: "games-hint" PlasmaCore.ToolTipArea { id: tooltiptab2 mainText: i18n("Hints/Tips") anchors.fill: parent } } PlasmaComponents.TabButton { id: mycroftSettingsTab Layout.fillHeight: true Layout.fillWidth: true iconSource: "games-config-options" PlasmaCore.ToolTipArea { id: tooltiptab3 mainText: i18n("Settings") anchors.fill: parent } } PlasmaComponents.TabButton { id: mycroftMSMinstTab Layout.fillHeight: true Layout.fillWidth: true iconSource: "kmouth-phresebook-new" PlasmaCore.ToolTipArea { id: tooltiptab4 mainText: i18n("Skill Browser") anchors.fill: parent } } } } PlasmaCore.SvgItem { anchors { left: parent.left leftMargin: sidebar.width top: parent.top topMargin: 1 bottom: parent.bottom bottomMargin: 1 } width: lineSvg.elementSize("vertical-line").width z: 110 elementId: "vertical-line" svg: PlasmaCore.Svg { id: lineSvg; imagePath: "widgets/line" } } ColumnLayout { id: mycroftcolumntab visible: tabBar.currentTab == mycroftTab; anchors.top: root.top anchors.left: sidebar.right anchors.leftMargin: units.gridUnit * 0.25 anchors.right: root.right anchors.bottom: root.bottom Item { id: conversationViewFrameBox anchors.top: mycroftcolumntab.top anchors.topMargin:15 anchors.left: mycroftcolumntab.left anchors.right: mycroftcolumntab.right anchors.bottom: mycroftcolumntab.bottom Disclaimer{ id: disclaimbox visible: false } ConversationView{ id: mycroftConversationComponent anchors.fill: parent } } } ColumnLayout { id: mycroftSkillscolumntab visible: tabBar.currentTab == mycroftSkillsTab; anchors.top: root.top anchors.left: sidebar.right anchors.leftMargin: units.gridUnit * 0.25 anchors.right: root.right anchors.bottom: root.bottom SkillsTipViewComponent { id: skillTipsView } } ColumnLayout { id: mycroftSettingsColumn visible: tabBar.currentTab == mycroftSettingsTab; anchors.top: root.top anchors.left: sidebar.right anchors.leftMargin: units.gridUnit * 0.25 anchors.right: root.right anchors.bottom: root.bottom SettingsComponent{ id: appletSettings } } ColumnLayout { id: mycroftMsmColumn visible: tabBar.currentTab == mycroftMSMinstTab; anchors.top: root.top anchors.left: sidebar.right anchors.leftMargin: units.gridUnit * 0.25 anchors.right: root.right anchors.bottom: root.bottom SkillsInstallerComponent{ id: skillsInstallerView } } } PlasmaCore.SvgItem { anchors { left: main.left right: main.right bottom: root.bottom } width: 1 height: horlineSvg.elementSize("horizontal-line").height elementId: "horizontal-line" z: 110 svg: PlasmaCore.Svg { id: horlineSvg; imagePath: "widgets/line" } } Item { id: rectanglebottombar height: units.gridUnit * 3.5 anchors.left: main.left anchors.right: main.right anchors.bottom: main.bottom z: 110 BottomBarViewComponent { id: bottomBarView } } }