diff --git a/plasmoid/contents/ui/BookDelegate.qml b/plasmoid/contents/ui/BookDelegate.qml new file mode 100644 index 0000000..981cdf8 --- /dev/null +++ b/plasmoid/contents/ui/BookDelegate.qml @@ -0,0 +1,191 @@ +/* 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: bookDelegateItem + height: bookContentDelegateItem.height + width: cbwidth + border.width: 1 + border.color: Qt.darker(PlasmaCore.ColorScope.backgroundColor, 1.2) + 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) + } + + Item { + id: bookContentDelegateItem + width: parent.width - units.gridUnit * 0.05 + height: topRowLayout.height + bookHeaderItemSeparator.height + bookContentInnerItem.height + buttnRow.height + + Rectangle { + id: topRowLayout + anchors.top: parent.top + anchors.left: parent.left + anchors.right: parent.right + implicitHeight: bookContentHeader.implicitHeight + units.gridUnit * 0.5 + color: theme.linkColor + + Text { + id: bookContentHeader + anchors.left: parent.left + anchors.leftMargin: units.gridUnit * 0.25 + anchors.verticalCenter: parent.verticalCenter + width: parent.width + wrapMode: Text.Wrap; + font.bold: true; + font.capitalization: Font.SmallCaps + 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 + text: i18n(model.booktitle) + + MouseArea { + anchors.fill: parent + hoverEnabled: true + + onEntered: { + bookContentHeader.color = PlasmaCore.ColorScope.backgroundColor + bookContentHeader.font.underline = true + } + onExited: { + bookContentHeader.color = PlasmaCore.ColorScope.textColor + bookContentHeader.font.underline = false + } + onClicked: { + Qt.openUrlExternally(bookurl) + } + } + } + } + + Rectangle { + id: bookHeaderItemSeparator + width: parent.width + anchors.top: topRowLayout.bottom + anchors.topMargin: 1 + height: 2 + color: theme.linkColor + } + + Item { + id: bookContentInnerItem + width: parent.width + height: cbheight / 2.75 + anchors.top: bookHeaderItemSeparator.bottom + anchors.topMargin: 1 + + Image { + id: bookImageItem + anchors.left: parent.left + source: model.bookcover + width: parent.width / 2.75 + height: parent.height + } + + Item { + id: bookContentAddInfo + anchors.left: bookImageItem.right + anchors.leftMargin: units.gridUnit * 2 + anchors.right: parent.right + height: parent.height + + Column { + id: additionalInfoColumn + width: parent.width + height: parent.height + spacing: 1.5 + + PlasmaComponents.Label { + id: bookAuthorLabel + font.capitalization: Font.Capitalize + text: "Author: " + bookauthor + } + + PlasmaComponents.Label { + id: bookPublisherLabel + font.capitalization: Font.Capitalize + text: "Publisher: " + bookpublisher + } + + PlasmaComponents.Label { + id: bookYearLabel + font.capitalization: Font.Capitalize + text: "Release Year: " + bookdate + } + + PlasmaComponents.Label { + id: bookAvailableLabel + font.capitalization: Font.Capitalize + text: "Availability: " + bookstatus + } + } + } + } + + Row { + id: buttnRow + height: units.gridUnit * 2 + anchors.top: bookContentInnerItem.bottom + + PlasmaComponents.Button { + id: bookReadOnlineBtn + width: cbwidth / 2 + height: units.gridUnit * 2 + text: "Read Online" + + onClicked: { + Qt.openUrlExternally(bookurl); + } + } + + PlasmaComponents.Button { + id: bookDownloadBtn + width: cbwidth / 2 + height: units.gridUnit * 2 + text: "Download" + + onClicked: { + var socketmessage = {}; + socketmessage.type = "recognizer_loop:utterance"; + socketmessage.data = {}; + socketmessage.data.utterances = ["download available book"]; + socket.sendTextMessage(JSON.stringify(socketmessage)); + } + } + } + } +} diff --git a/plasmoid/contents/ui/BookType.qml b/plasmoid/contents/ui/BookType.qml new file mode 100644 index 0000000..b07dd9e --- /dev/null +++ b/plasmoid/contents/ui/BookType.qml @@ -0,0 +1,44 @@ +/* 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/main.qml b/plasmoid/contents/ui/main.qml index 18a3c8b..6d30721 100644 --- a/plasmoid/contents/ui/main.qml +++ b/plasmoid/contents/ui/main.qml @@ -1,1823 +1,1842 @@ /* 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.extras 2.0 as PlasmaExtras import org.kde.private.mycroftplasmoid 1.0 as PlasmaLa import org.kde.plasma.private.volume 0.1 import QtWebKit 3.0 import QtQuick.Window 2.0 import QtGraphicalEffects 1.0 Item { id: main Layout.fillWidth: true; Plasmoid.toolTipMainText: i18n("Mycroft") Plasmoid.switchWidth: units.gridUnit * 15 Plasmoid.switchHeight: units.gridUnit * 15 Layout.minimumHeight: units.gridUnit * 24 Layout.minimumWidth: units.gridUnit * 26 Component.onCompleted: { mycroftStatusCheckSocket.active = true detectInstallType(); refreshAllSkills(); } property var skillList: [] property alias cbwidth: rectangle2.width property alias cbheight: rectangle2.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 autoCompModel: completionItems property alias textInput: qinput 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 bool intentfailure: false property bool locationUserSelected: false property bool connectCtx: false property var geoLat property var geoLong property var globalcountrycode property var weatherMetric: "metric" Connections { target: plasmoid onExpandedChanged: { if (plasmoid.expanded) { checkDashStatus() } } } 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 } } } function detectInstallType(){ if(locationUserSelected == false && PlasmaLa.FileReader.file_exists_local("/usr/bin/mycroft-messagebus")){ settingsTabUnitsOpOne.checked = true coreinstallstartpath = packagemcorestartcmd coreinstallstoppath = packagemcorestopcmd } } function checkDashStatus(){ if(dashListModel.count == 0){ checkConnectionStatus() } } function checkConnectionStatus(){ var isConnected = PlasmaLa.ConnectionCheck.checkConnection() if(!isConnected){ if(!connectCtx){ var conError = i18n("I am not connected to the internet, Please check your network connection") convoLmodel.append({"itemType": "NonVisual", "InputQuery": conError}); connectCtx = true } } else { geoDataSource.connectedSources = ["location"] } } function toggleInputMethod(selection){ switch(selection){ case "KeyboardSetActive": qinput.visible = true suggestionbottombox.visible = true customMicIndicator.visible = false keybindic.color = "green" break case "KeyboardSetDisable": qinput.visible = false suggestionbottombox.visible = false customMicIndicator.visible = true keybindic.color = theme.textColor break } } function retryConn(){ socket.active = true if (socket.active = false){ convoLmodel.append({"itemType": "NonVisual", "InputQuery": socket.errorString}) } } function filterSpeak(msg){ convoLmodel.append({ "itemType": "NonVisual", "InputQuery": msg }) inputlistView.positionViewAtEnd(); } function filterincoming(intent, metadata) { var intentVisualArray = ['CurrentWeatherIntent']; var itemType var filterintentname = intent.split(':'); var intentname = filterintentname[1]; if (intentVisualArray.indexOf(intentname) !== -1) { switch (intentname){ case "CurrentWeatherIntent": itemType = "CurrentWeather" break; } convoLmodel.append({"itemType": itemType, "itemData": metadata}) } else { convoLmodel.append({"itemType": "WebViewType", "InputQuery": metadata.url}) } } function filtervisualObj(metadata){ convoLmodel.append({"itemType": "LoaderType", "InputQuery": metadata.url}) inputlistView.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; 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}) } 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 ''; } function filterRecipeObj(metadata){ var filteredData = JSON.parse(metadata.data); convoLmodel.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}) } convoLmodel.append({"itemType": "RecipeType", "InputQuery": ""}) } function filterBalooObj(metadata){ var BalooObj = metadata; var baloosearchTerm = metadata.searchType convoLmodel.clear() for (var i = 0; i < BalooObj.data.length; i++){ if(baloosearchTerm == "type:audio"){ convoLmodel.append({"itemType": "AudioFileType", "InputQuery": metadata.data[i]}) } if(baloosearchTerm == "type:video"){ convoLmodel.append({"itemType": "VideoFileType", "InputQuery": metadata.data[i]}) } if(baloosearchTerm == "type:document" || baloosearchTerm == "type:spreadsheet" || baloosearchTerm == "type:presentation" || baloosearchTerm == "type:archive" ){ convoLmodel.append({"itemType": "DocumentFileType", "InputQuery": metadata.data[i]}) } } } function filterstackObj(metadata){ var filterStackMeta = JSON.parse(metadata.data) convoLmodel.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}) } convoLmodel.append({"itemType": "StackObjType", "InputQuery": ""}) inputlistView.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}) + convoLmodel.append({"itemType": "BookType", "InputQuery": ""}) + inputlistView.positionViewAtEnd(); + } function isBottomEdge() { return plasmoid.location == PlasmaCore.Types.BottomEdge; } function clearList() { inputlistView.clear() } function muteMicrophone() { if (!sourceModel.defaultSource) { return; } var toMute = !sourceModel.defaultSource.muted; sourceModel.defaultSource.muted = toMute; } function refreshAllSkills(){ getSkills(); msmskillsModel.reload(); } function getAllSkills(){ if(skillList.length <= 0){ getSkills(); } return skillList; } function getSkillByName(skillName){ var tempSN=[]; for(var i = 0; i Connection error") statusId.color = "red" mycroftstartservicebutton.circolour = "red" midbarAnim.showstatsId() statusRetryBtn.visible = true drawer.open() waitanimoutter.aniRunError() delay(1250, function() { drawer.close() }) } else if (socket.status == WebSocket.Open) { statusId.text = i18n("Mycroft is ready") statusId.color = "green" statusRetryBtn.visible = false mycroftstartservicebutton.circolour = "green" mycroftStatusCheckSocket.active = false; midbarAnim.showstatsId() drawer.open() waitanimoutter.aniRunHappy() delay(1250, function() { drawer.close() }) } else if (socket.status == WebSocket.Closed) { statusId.text = i18n("Mycroft is disabled") statusId.color = theme.textColor mycroftstartservicebutton.circolour = Qt.lighter(theme.backgroundColor, 1.5) midbarAnim.showstatsId() } else if (socket.status == WebSocket.Connecting) { statusId.text = i18n("Starting up..please wait") statusId.color = theme.linkColor mycroftstartservicebutton.circolour = "steelblue" midbarAnim.showstatsId() } else if (socket.status == WebSocket.Closing) { statusId.text = i18n("Shutting down") statusId.color = theme.textColor midbarAnim.showstatsId() } } 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: "user-home" PlasmaCore.ToolTipArea { id: tooltiptab1 mainText: i18n("Home Tab") anchors.fill: parent } } PlasmaComponents.TabButton { id: mycroftSkillsTab Layout.fillHeight: true Layout.fillWidth: true iconSource: "games-hint" PlasmaCore.ToolTipArea { id: tooltiptab2 mainText: i18n("Skills Tab") anchors.fill: parent } } PlasmaComponents.TabButton { id: mycroftSettingsTab Layout.fillHeight: true Layout.fillWidth: true iconSource: "games-config-options" PlasmaCore.ToolTipArea { id: tooltiptab3 mainText: i18n("Settings Tab") anchors.fill: parent } } PlasmaComponents.TabButton { id: mycroftMSMinstTab Layout.fillHeight: true Layout.fillWidth: true iconSource: "kmouth-phresebook-new" PlasmaCore.ToolTipArea { id: tooltiptab4 mainText: i18n("Skill Installs Tab") 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 Rectangle { id: rectangle2 color: "#00000000" anchors.top: mycroftcolumntab.top anchors.topMargin:15 anchors.left: mycroftcolumntab.left anchors.right: mycroftcolumntab.right anchors.bottom: mycroftcolumntab.bottom 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]); convoLmodel.append({ "itemType": "DropImg", "InputQuery": durl }) inputlistView.positionViewAtEnd(); } if(ext === 'mp3'){ console.log('mp3'); } } } Disclaimer{ id: disclaimbox visible: false } ListModel{ id: convoLmodel } Rectangle { id: messageBox anchors.fill: parent anchors.right: parent.right anchors.left: parent.left color: "#00000000" ColumnLayout { id: colconvo anchors.fill: parent ListView { id: inputlistView Layout.fillWidth: true Layout.fillHeight: true verticalLayoutDirection: ListView.TopToBottom spacing: 12 clip: true model: convoLmodel ScrollBar.vertical: ScrollBar {} 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 "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" } property var metacontent : dataContent } } onCountChanged: { inputlistView.positionViewAtEnd(); } } } } } } } 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 ListView { id: skillslistmodelview anchors.top: parent.top anchors.topMargin: 5 anchors.left: parent.left anchors.right: parent.right anchors.bottom: parent.bottom model: SkillModel{} delegate: SkillView{} spacing: 4 focus: false interactive: true clip: true; } } 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 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.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 anchors.fill: parent; contentWidth: mycroftSettingsColumn.width contentHeight: units.gridUnit * 22 clip: true; PlasmaComponents.Label { id: settingsTabUnits anchors.top: parent.top; anchors.topMargin: 5 text: i18n("Your Mycroft Core Installation Path") } PlasmaComponents.ButtonColumn { id: radiobuttonColoumn anchors.top: settingsTabUnits.bottom anchors.topMargin: 5 PlasmaComponents.RadioButton { id: settingsTabUnitsOpZero exclusiveGroup: installPathGroup text: i18n("Default Path") checked: true onCheckedChanged: { locationUserSelected = true if (settingsTabUnitsOpZero.checked === true && coreinstallstartpath === packagemcorestartcmd) { coreinstallstartpath = defaultmcorestartpath; } else if (settingsTabUnitsOpZero.checked === true && coreinstallstartpath === customlocstartpath) { coreinstallstartpath = defaultmcorestartpath; } if (settingsTabUnitsOpZero.checked === true && coreinstallstoppath === packagemcorestopcmd) { coreinstallstoppath = defaultmcorestoppath; } else if (settingsTabUnitsOpZero.checked === true && coreinstallstoppath === customlocstoppath) { coreinstallstoppath = defaultmcorestoppath; } } } PlasmaComponents.RadioButton { id: settingsTabUnitsOpOne exclusiveGroup: installPathGroup text: i18n("Installed Using Mycroft Package") checked: false onCheckedChanged: { if (settingsTabUnitsOpOne.checked === true && coreinstallstartpath === defaultmcorestartpath) { coreinstallstartpath = packagemcorestartcmd; } else if (settingsTabUnitsOpOne.checked === true && coreinstallstartpath === customlocstartpath) { coreinstallstartpath = packagemcorestartcmd; } if (settingsTabUnitsOpOne.checked === true && coreinstallstoppath === defaultmcorestoppath) { coreinstallstoppath = packagemcorestopcmd; } else if (settingsTabUnitsOpOne.checked === true && coreinstallstoppath === customlocstoppath) { coreinstallstoppath = packagemcorestopcmd; } } } PlasmaComponents.RadioButton { id: settingsTabUnitsOpTwo exclusiveGroup: installPathGroup text: i18n("Location of Mycroft-Core Directory") checked: false onCheckedChanged: { locationUserSelected = true if (settingsTabUnitsOpTwo.checked === true && coreinstallstartpath === defaultmcorestartpath) { coreinstallstartpath = customlocstartpath; } else if (settingsTabUnitsOpTwo.checked === true && coreinstallstartpath === packagemcorestartcmd) { coreinstallstartpath = customlocstartpath; } if (settingsTabUnitsOpTwo.checked === true && coreinstallstoppath === defaultmcorestoppath) { coreinstallstoppath = customlocstoppath; } else if (settingsTabUnitsOpTwo.checked === true && coreinstallstoppath === packagemcorestopcmd) { coreinstallstoppath = customlocstoppath; } } } } PlasmaComponents.TextField { id: settingsTabUnitsOpThree width: settingscontent.width / 1.1 anchors.top: radiobuttonColoumn.bottom anchors.topMargin: 10 placeholderText: i18n("/mycroft-core/") onTextChanged: { var cstloc = settingsTabUnitsOpThree.text customloc = cstloc } } PlasmaComponents.Button { id: acceptcustomPath anchors.left: settingsTabUnitsOpThree.right anchors.verticalCenter: settingsTabUnitsOpThree.verticalCenter anchors.right: parent.right iconSource: "checkbox" onClicked: { var cstlocl = customloc var ctstart = cstlocl + "start-mycroft.sh all" var ctstop = cstlocl + "stop-mycroft.sh" startsrvcustom.text = ctstart stopsrvcustom.text = ctstop console.log(startsrvcustom.text) } } PlasmaComponents.TextField { id: settingsTabUnitsWSpath width: settingscontent.width / 1.1 anchors.top: settingsTabUnitsOpThree.bottom anchors.topMargin: 10 placeholderText: i18n("ws://0.0.0.0:8181/core") text: i18n("ws://0.0.0.0:8181/core") } PlasmaComponents.Button { id: acceptcustomWSPath anchors.left: settingsTabUnitsWSpath.right anchors.verticalCenter: settingsTabUnitsWSpath.verticalCenter anchors.right: parent.right iconSource: "checkbox" onClicked: { innerset.wsurl = settingsTabUnitsWSpath.text } } PlasmaComponents.TextField { id: settingsTabUnitsIRCmd width: settingscontent.width / 1.1 anchors.top: settingsTabUnitsWSpath.bottom anchors.topMargin: 10 placeholderText: i18n("Your Custom Image Recognition Skill Voc Keywords") text: i18n("search image url") } PlasmaComponents.Button { id: acceptcustomIRCmd anchors.left: settingsTabUnitsIRCmd.right anchors.verticalCenter: settingsTabUnitsIRCmd.verticalCenter anchors.right: parent.right iconSource: "checkbox" } PlasmaComponents.TextField { id: settingsTabUnitsOCRCmd width: settingscontent.width / 1.1 anchors.top: settingsTabUnitsIRCmd.bottom anchors.topMargin: 10 placeholderText: i18n("Your Custom Image OCR Skill Voc Keywords") text: i18n("ocr image url") } PlasmaComponents.Button { id: acceptcustomOCRCmd anchors.left: settingsTabUnitsOCRCmd.right anchors.verticalCenter: settingsTabUnitsOCRCmd.verticalCenter anchors.right: parent.right iconSource: "checkbox" } PlasmaComponents.Switch { id: notificationswitch anchors.top: settingsTabUnitsOCRCmd.bottom anchors.topMargin: 10 text: i18n("Enable Notifications") checked: true } PlasmaComponents.Switch { id: wolframfallbackswitch anchors.top: notificationswitch.bottom anchors.topMargin: 10 text: i18n("Enable Fallback To Wolfram Alpha Web-Search") checked: true } PlasmaComponents.Label { id: wolframkeylabel text: i18n("Wolfram Alpha API:") anchors.top: wolframfallbackswitch.bottom anchors.topMargin: 10 } PlasmaComponents.TextField { id: wolframapikeyfld anchors.right: parent.right anchors.rightMargin: units.gridUnit * 0.25 anchors.left: wolframkeylabel.right anchors.leftMargin: units.gridUnit * 0.25 anchors.verticalCenter: wolframkeylabel.verticalCenter text: i18n("RJVUY3-T6YLWQVXRR") } PlasmaExtras.Paragraph { id: settingsTabTF2 anchors.top: wolframapikeyfld.bottom anchors.topMargin: 15 text: i18n("Please Note: Default path is set to /home/$USER/mycroft-core/. Change the above settings to match your installation") } PlasmaComponents.Label { id: startsrvcustom visible: false } PlasmaComponents.Label { id: stopsrvcustom visible: false } } } 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 onCheckedChanged: { console.log(dashswitch.checked) if(dashswitch.checked){ showDash("setVisible") } else if(!dashswitch.checked){ convoLmodel.clear() } } } 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 } PlasmaComponents.Switch { id: cryptocardswitch text: i18n("Enable / Disable Cryptocurrency Card") checked: false } 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{ id: weatherCardMetricsRowList spacing: 2 PlasmaComponents.Button { id: owmApiKeyMetricCel text: i18n("Celcius") onClicked: { weatherMetric = "metric" updateCardData() } } PlasmaComponents.Button{ id: owmApiKeyMetricFar text: i18n("Fahrenheit") onClicked: { weatherMetric = "imperial" updateCardData() } } } } } } } 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 Item { id: msmtabtopbar width: parent.width anchors.left: parent.left anchors.right: parent.right height: units.gridUnit * 2 PlasmaComponents.TextField { id: msmsearchfld anchors.left: parent.left anchors.top: parent.top anchors.bottom: parent.bottom anchors.right: getskillsbx.left placeholderText: i18n("Search Skills") clearButtonShown: true onTextChanged: { if(text.length > 0 ) { msmskillsModel.applyFilter(text.toLowerCase()); } else { msmskillsModel.reload(); } } } PlasmaComponents.ToolButton { id: getskillsbx anchors.right: parent.right anchors.top: parent.top anchors.bottom: parent.bottom iconSource: "view-refresh" tooltip: i18n("Refresh List") flat: true width: Math.round(units.gridUnit * 2) height: width z: 102 onClicked: { msmskillsModel.clear(); refreshAllSkills(); } } } ListModel { id: msmskillsModel Component.onCompleted: { reload(); } function reload() { var skList = getAllSkills(); msmskillsModel.clear(); for( var i=0; i < skList.length ; ++i ) { msmskillsModel.append(skList[i]); } } function applyFilter(skName) { var skList = getSkillByName(skName); msmskillsModel.clear(); for( var i=0; i < skList.length ; ++i ) { msmskillsModel.append(skList[i]); } } } ListView { id: msmlistView anchors.top: msmtabtopbar.bottom anchors.topMargin: 5 anchors.left: parent.left anchors.right: parent.right anchors.bottom: parent.bottom model: msmskillsModel delegate: MsmView{} spacing: 4 focus: false interactive: true clip: true; } } } SourceModel { id: sourceModel } 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 ListModel { id: completionItems } Drawer { id: drawer width: dwrpaddedwidth height: units.gridUnit * 5.5 edge: Qt.BottomEdge Rectangle { color: theme.backgroundColor anchors.fill: parent } CustomIndicator { id: waitanimoutter height: 70 width: 70 anchors.verticalCenter: parent.verticalCenter anchors.horizontalCenter: parent.horizontalCenter } } Rectangle { id: suggestionbottombox anchors.top: parent.top anchors.bottom: qinput.top anchors.right: parent.right anchors.left: parent.left color: theme.backgroundColor Suggestions { id: suggst visible: true; } } Rectangle { id: keyboardactivaterect color: theme.backgroundColor border.width: 1 border.color: Qt.lighter(theme.backgroundColor, 1.2) width: units.gridUnit * 2 height: qinput.height anchors.bottom: parent.bottom anchors.left: parent.left PlasmaCore.IconItem { id: keybdImg source: "input-keyboard" anchors.centerIn: parent width: units.gridUnit * 1.5 height: units.gridUnit * 1.5 } Rectangle { id: keybindic anchors.bottom: parent.bottom anchors.bottomMargin: 4 anchors.left: parent.left anchors.right: parent.right anchors.leftMargin: 8 anchors.rightMargin: 8 height: 2 color: "green" } MouseArea{ anchors.fill: parent hoverEnabled: true onEntered: {} onExited: {} onClicked: { if(qinput.visible === false){ toggleInputMethod("KeyboardSetActive") } else if(qinput.visible === true){ toggleInputMethod("KeyboardSetDisable") } } } } PlasmaComponents.TextField { id: qinput anchors.left: keyboardactivaterect.right anchors.bottom: parent.bottom anchors.right: parent.right placeholderText: i18n("Enter Query or Say 'Hey Mycroft'") clearButtonShown: true onAccepted: { var doesExist = autoAppend(autoCompModel, function(item) { return item.name === qinput.text }, qinput.text) var evaluateExist = doesExist if(evaluateExist === null){ autoCompModel.append({"name": qinput.text}); } suggst.visible = true; var socketmessage = {}; socketmessage.type = "recognizer_loop:utterance"; socketmessage.data = {}; socketmessage.data.utterances = [qinput.text]; socket.sendTextMessage(JSON.stringify(socketmessage)); qinput.text = ""; } onTextChanged: { evalAutoLogic(); } } CustomMicIndicator { id: customMicIndicator anchors.centerIn: parent visible: false } AutocompleteBox { id: suggestionsBox model: completionItems width: parent.width anchors.bottom: qinput.top anchors.left: parent.left anchors.right: parent.right filter: textInput.text property: "name" onItemSelected: complete(item) function complete(item) { if (item !== undefined) textInput.text = item.name } } } Settings { id: innerset property alias wsurl: settingsTabUnitsWSpath.text property alias customrecog: settingsTabUnitsIRCmd.text property alias customocrrecog: settingsTabUnitsOCRCmd.text property alias customsetuppath: settingsTabUnitsOpThree.text property alias notifybool: notificationswitch.checked property alias wolffallbackbool: wolframfallbackswitch.checked property alias wolframKey: wolframapikeyfld.text 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 property alias weatherMetricC: owmApiKeyMetricCel.checked property alias weatherMetricF: owmApiKeyMetricFar.checked } }