diff --git a/plasmoid/contents/images/arleft.png b/plasmoid/contents/images/arleft.png new file mode 100644 index 0000000..a5e88d6 Binary files /dev/null and b/plasmoid/contents/images/arleft.png differ diff --git a/plasmoid/contents/images/arright.png b/plasmoid/contents/images/arright.png new file mode 100644 index 0000000..76060b9 Binary files /dev/null and b/plasmoid/contents/images/arright.png differ diff --git a/plasmoid/contents/ui/AskMessageType.qml b/plasmoid/contents/ui/AskMessageType.qml index 2991130..e47f519 100644 --- a/plasmoid/contents/ui/AskMessageType.qml +++ b/plasmoid/contents/ui/AskMessageType.qml @@ -1,109 +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 -Column { - spacing: 6 - anchors.right: parent.right +Item { + width: cbwidth + height: messageRect.height + timeStampLabel.height property alias mssg: messageText.text - - Rectangle { - id: messageRect + + 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: { - removeItemButton.visible = true - searchItemButton.visible = true + onEntered: { + messageRect.color = Qt.darker(theme.linkColor, 1.2) + messageRectedgeOverLay.color = Qt.darker(theme.linkColor, 1.2) } onExited: { - removeItemButton.visible = false - searchItemButton.visible = false + messageRect.color = theme.linkColor + messageRectedgeOverLay.color = theme.linkColor } - } - - PlasmaCore.IconItem { - id: removeItemButton - source: "window-close" - width: units.gridUnit * 1.5 - height: units.gridUnit * 1.5 - anchors.bottom: parent.bottom - anchors.right: parent.right - anchors.bottomMargin: -units.gridUnit * 0.75 - visible: false - - MouseArea { - anchors.fill: parent - hoverEnabled: true - propagateComposedEvents: true - onEntered: { - removeItemButton.visible = true - } - onClicked: { - convoLmodel.remove(index) - } + onClicked: { + askCtxMenu.open() } } - - PlasmaCore.IconItem { - id: searchItemButton - source: "system-search" - width: units.gridUnit * 1.5 - height: units.gridUnit * 1.5 - anchors.bottom: parent.bottom - anchors.right: removeItemButton.right - anchors.rightMargin: units.gridUnit * 1.0 - anchors.bottomMargin: -units.gridUnit * 0.75 - visible: false - MouseArea { - anchors.fill: parent - hoverEnabled: true - propagateComposedEvents: true - onEntered: { - searchItemButton.visible = true - } - onClicked: { - Qt.openUrlExternally("https://duckduckgo.com/?q=" + model.InputQuery) - } - } - } - PlasmaComponents.Label { id: messageText - text: model.InputQuery anchors.centerIn: parent wrapMode: Label.Wrap color: theme.backgroundColor - } + + Component.onCompleted: { + var askText = model.InputQuery + 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/AskMessageTypeMenu.qml b/plasmoid/contents/ui/AskMessageTypeMenu.qml new file mode 100644 index 0000000..58daca1 --- /dev/null +++ b/plasmoid/contents/ui/AskMessageTypeMenu.qml @@ -0,0 +1,151 @@ +/* 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 + +Drawer { + id: askTypeMenuItem + width: dwrpaddedwidth + height: removeRectbtn.height + searchRectbtn.height + edge: Qt.TopEdge + dragMargin: 0 + + Rectangle { + id: askMenuRectItem + anchors.fill: parent + color: theme.backgroundColor + + Column { + id: menuRectColumn + anchors.fill: parent + + Rectangle { + id: removeRectbtn + width: parent.width + height: units.gridUnit * 2 + color: theme.backgroundColor + + Row { + spacing: 5 + PlasmaCore.IconItem { + id: removeRectIcon + anchors.verticalCenter: parent.verticalCenter + source: "window-close" + width: units.gridUnit * 2 + height: units.gridUnit * 2 + } + Rectangle { + id: removeRectSeperater + width: 1 + height: parent.height + color: theme.linkColor + } + PlasmaComponents.Label { + id: removeRectLabel + anchors.verticalCenter: parent.verticalCenter + text: "Remove" + } + } + MouseArea { + anchors.fill: parent + hoverEnabled: true + onEntered: { + removeRectLabel.color = theme.linkColor + } + onExited:{ + removeRectLabel.color = theme.textColor + } + onClicked:{ + convoLmodel.remove(index) + } + } + } + + Rectangle { + id: btnshorzSepr1 + width: parent.width + height: 1 + color: theme.linkColor + } + + Rectangle { + id: searchRectbtn + width: parent.width + height: units.gridUnit * 2 + color: theme.backgroundColor + + Row { + spacing: 5 + PlasmaCore.IconItem { + id: searchRectIcon + anchors.verticalCenter: parent.verticalCenter + source: "system-search" + width: units.gridUnit * 2 + height: units.gridUnit * 2 + } + Rectangle { + id: searchRectSeperater + width: 1 + height: parent.height + color: theme.linkColor + } + PlasmaComponents.Label { + id: searchRectLabel + anchors.verticalCenter: parent.verticalCenter + text: "Search Online" + } + } + MouseArea { + anchors.fill: parent + hoverEnabled: true + onEntered: { + searchRectLabel.color = theme.linkColor + } + onExited:{ + searchRectLabel.color = theme.textColor + } + onClicked:{ + Qt.openUrlExternally("https://duckduckgo.com/?q=" + model.InputQuery) + } + } + } + + Rectangle { + id: btnshorzSeprEnd + width: parent.width + height: units.gridUnit * 0.75 + color: theme.linkColor + + PlasmaCore.IconItem { + id: closemenuDrawer + anchors.centerIn: parent + source: "go-up" + width: units.gridUnit * 2 + height: units.gridUnit * 2 + } + } + } + } + } diff --git a/plasmoid/contents/ui/DashboardDelegate.qml b/plasmoid/contents/ui/DashboardDelegate.qml index 6f6cff3..6e0839d 100644 --- a/plasmoid/contents/ui/DashboardDelegate.qml +++ b/plasmoid/contents/ui/DashboardDelegate.qml @@ -1,224 +1,234 @@ /* 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 org.kde.plasma.components 3.0 as PlasmaComponents3 Item { id: dashdelegteType height: dashdelegatelview.height width: parent.width property Component delegateComponentDisclaimer: Qt.createComponent("DisclaimerCardDelegate.qml") property Component delegateComponentWeather: Qt.createComponent("DashWeatherDelegate.qml") property Component delegateComponentNews: Qt.createComponent("DashNewsDelegate.qml") property Component delegateComponentCrypto: Qt.createComponent("DashCryptoDelegate.qml") Component.onCompleted: { filterSwitchDash(iType, iObj) } function filterSwitchDash(iType, iObj){ switch(iType){ case "Disclaimer": filterDashDisclaimerObj() break case "DashNews": filterDashNewsObj(iObj) break case "DashWeather": filterDashWeatherObj(iObj) break case "DashCryptoPrice": filterDashCryptoObj(iObj) break } } function filterDashDisclaimerObj() { dashCardCollectionModel.append({itemType: "Disclaimer", itemAt: 0, contents:{}}) dashdelegatelview.delegate = delegateComponentDisclaimer } function filterDashWeatherObj(weatherobj){ var filteredMetric if(weatherMetric.indexOf('metric') != -1){ filteredMetric = "°c" } else if (weatherMetric.indexOf('imperial') != -1){ filteredMetric = "°f" } if(weatherobj){ var filteredWeatherObject = JSON.parse(weatherobj) var weatherIcnTypeHourZero = "http://openweathermap.org/img/w/" + filteredWeatherObject.list[0].weather[0].icon + ".png" var weatherIcnTypeHourA = "http://openweathermap.org/img/w/" + filteredWeatherObject.list[1].weather[0].icon + ".png" var weatherIcnTypeHourB = "http://openweathermap.org/img/w/" + filteredWeatherObject.list[2].weather[0].icon + ".png" var weatherdateHourZero = filteredWeatherObject.list[0].dt_txt var weatherdateHourA = filteredWeatherObject.list[1].dt_txt var weatherdateHourB = filteredWeatherObject.list[2].dt_txt dashCardCollectionModel.append({itemType: "DashWeather", itemAt: 1, contents:{itemWeatherTempHourZero: filteredWeatherObject.list[0].main.temp, itemWeatherTempHourA: filteredWeatherObject.list[1].main.temp, itemWeatherTempHourB: filteredWeatherObject.list[2].main.temp, itemWeatherTempMinHourZero: filteredWeatherObject.list[0].main.temp_min, itemWeatherTempMinHourA: filteredWeatherObject.list[1].main.temp_min, itemWeatherTempMinHourB: filteredWeatherObject.list[2].main.temp_min, itemWeatherTempMaxHourZero: filteredWeatherObject.list[0].main.temp_max, itemWeatherTempMaxHourA: filteredWeatherObject.list[1].main.temp_max, itemWeatherTempMaxHourB: filteredWeatherObject.list[2].main.temp_max, itemWeatherTempTypeHourZero: filteredWeatherObject.list[0].weather[0].main, itemWeatherTempTypeHourA: filteredWeatherObject.list[1].weather[0].main, itemWeatherTempTypeHourB: filteredWeatherObject.list[2].weather[0].main, itemWeatherMetricType: filteredMetric, itemWeatherIconTypeHourZero: weatherIcnTypeHourZero, itemWeatherIconTypeHourA: weatherIcnTypeHourA, itemWeatherIconTypeHourB: weatherIcnTypeHourB, itemWeatherWindHourZero: filteredWeatherObject.list[0].wind.speed, itemWeatherWindHourA: filteredWeatherObject.list[1].wind.speed, itemWeatherWindHourB: filteredWeatherObject.list[2].wind.speed, itemWeatherCity: filteredWeatherObject.city.name, itemWeatherDateHourZero: weatherdateHourZero, itemWeatherDateHourA: weatherdateHourA, itemWeatherDateHourB: weatherdateHourB}}) dashdelegatelview.delegate = delegateComponentWeather } } function filterDashNewsObj(newsobj){ if(newsobj){ var filteredNewsObject = JSON.parse(newsobj) for (var i=0; i This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) version 3, or any later version accepted by the membership of KDE e.V. (or its successor approved by the membership of KDE e.V.), which shall act as a proxy defined in Section 6 of version 3 of the license. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library. If not, see . */ import QtQuick 2.9 import QtQml.Models 2.2 import QtQuick.Controls 2.2 import QtQuick.Layouts 1.3 import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.plasma.plasmoid 2.0 import org.kde.plasma.components 2.0 as PlasmaComponents import org.kde.plasma.components 3.0 as PlasmaComponents3 Item { id: dashbdtypebg width: cbwidth height: cbheight property alias dashlvmodel: dashboardmodelview.model property alias dashlvdelegate: dashboardmodelview.delegate PulleyItemDash { id: dashlistPulley visible: true barColor: theme.linkColor anchors.bottom: parent.bottom anchors.bottomMargin: units.gridUnit * 0.10 _isVisible: true z: 900 } ListView { id: dashboardmodelview anchors.top: parent.top anchors.left: parent.left anchors.right: parent.right height: cbheight / 1.05 model: dashLmodel spacing: 2 focus: false interactive: true clip: true; - delegate: DashboardDelegate{} + delegate: DashboardDelegate{} + ScrollBar.vertical: dashscrollBar } PlasmaComponents3.ScrollBar { id: dashscrollBar + orientation: Qt.Vertical + interactive: true anchors.right: parent.right anchors.top: parent.top anchors.bottom: parent.bottom - orientation: Qt.Vertical } } diff --git a/plasmoid/contents/ui/SimpleMessageType.qml b/plasmoid/contents/ui/SimpleMessageType.qml index 5457310..36cd2e5 100644 --- a/plasmoid/contents/ui/SimpleMessageType.qml +++ b/plasmoid/contents/ui/SimpleMessageType.qml @@ -1,106 +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 -Column { - spacing: 6 - anchors.right: parent.right - - readonly property bool sentByMe: model.recipient !== "User" - 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 - } - } +Item { + width: cbwidth + height: messageRect.height + timeStampLabel.height + property alias mssg: messageText.text - Rectangle { - id: messageRect - width: cbwidth - units.gridUnit * 2 - radius: 2 - height: messageText.implicitHeight + 24 - color: Qt.lighter(theme.backgroundColor, 1.2) - - MouseArea { - anchors.fill: parent - hoverEnabled: true - propagateComposedEvents: true - onEntered: removeItemButton.visible = true - onExited: removeItemButton.visible = false - } - - PlasmaCore.IconItem { - id: removeItemButton - source: "window-close" - width: units.gridUnit * 1.5 - height: units.gridUnit * 1.5 - anchors.bottom: parent.bottom - anchors.right: parent.right - anchors.rightMargin: units.gridUnit * 0.2 - anchors.bottomMargin: -units.gridUnit * 0.75 - visible: false - - MouseArea { - anchors.fill: parent - hoverEnabled: true - propagateComposedEvents: true - onEntered: { - removeItemButton.visible = true - } - onClicked: { - convoLmodel.remove(index) - } - } + 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 + 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); + } + } } - - PlasmaComponents.Label { - id: messageText - text: model.InputQuery - anchors.fill: parent - anchors.margins: 12 - wrapMode: Label.Wrap - - } - } - } - } + SimpleMessageTypeMenu{ + id: simpleCtxMenu + } + } diff --git a/plasmoid/contents/ui/SimpleMessageTypeMenu.qml b/plasmoid/contents/ui/SimpleMessageTypeMenu.qml new file mode 100644 index 0000000..58daca1 --- /dev/null +++ b/plasmoid/contents/ui/SimpleMessageTypeMenu.qml @@ -0,0 +1,151 @@ +/* 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 + +Drawer { + id: askTypeMenuItem + width: dwrpaddedwidth + height: removeRectbtn.height + searchRectbtn.height + edge: Qt.TopEdge + dragMargin: 0 + + Rectangle { + id: askMenuRectItem + anchors.fill: parent + color: theme.backgroundColor + + Column { + id: menuRectColumn + anchors.fill: parent + + Rectangle { + id: removeRectbtn + width: parent.width + height: units.gridUnit * 2 + color: theme.backgroundColor + + Row { + spacing: 5 + PlasmaCore.IconItem { + id: removeRectIcon + anchors.verticalCenter: parent.verticalCenter + source: "window-close" + width: units.gridUnit * 2 + height: units.gridUnit * 2 + } + Rectangle { + id: removeRectSeperater + width: 1 + height: parent.height + color: theme.linkColor + } + PlasmaComponents.Label { + id: removeRectLabel + anchors.verticalCenter: parent.verticalCenter + text: "Remove" + } + } + MouseArea { + anchors.fill: parent + hoverEnabled: true + onEntered: { + removeRectLabel.color = theme.linkColor + } + onExited:{ + removeRectLabel.color = theme.textColor + } + onClicked:{ + convoLmodel.remove(index) + } + } + } + + Rectangle { + id: btnshorzSepr1 + width: parent.width + height: 1 + color: theme.linkColor + } + + Rectangle { + id: searchRectbtn + width: parent.width + height: units.gridUnit * 2 + color: theme.backgroundColor + + Row { + spacing: 5 + PlasmaCore.IconItem { + id: searchRectIcon + anchors.verticalCenter: parent.verticalCenter + source: "system-search" + width: units.gridUnit * 2 + height: units.gridUnit * 2 + } + Rectangle { + id: searchRectSeperater + width: 1 + height: parent.height + color: theme.linkColor + } + PlasmaComponents.Label { + id: searchRectLabel + anchors.verticalCenter: parent.verticalCenter + text: "Search Online" + } + } + MouseArea { + anchors.fill: parent + hoverEnabled: true + onEntered: { + searchRectLabel.color = theme.linkColor + } + onExited:{ + searchRectLabel.color = theme.textColor + } + onClicked:{ + Qt.openUrlExternally("https://duckduckgo.com/?q=" + model.InputQuery) + } + } + } + + Rectangle { + id: btnshorzSeprEnd + width: parent.width + height: units.gridUnit * 0.75 + color: theme.linkColor + + PlasmaCore.IconItem { + id: closemenuDrawer + anchors.centerIn: parent + source: "go-up" + width: units.gridUnit * 2 + height: units.gridUnit * 2 + } + } + } + } + } diff --git a/plasmoid/contents/ui/main.qml b/plasmoid/contents/ui/main.qml index 1b60769..0049307 100644 --- a/plasmoid/contents/ui/main.qml +++ b/plasmoid/contents/ui/main.qml @@ -1,2042 +1,2050 @@ /* 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 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 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) { 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)); + } } 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), placeicon: JSON.stringify(fltritemsinPlc.icon), 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 filterwikiObj(metadata){ var wikiSummary = JSON.stringify(metadata.data.summary) var wikiImage = JSON.stringify(metadata.data.image) wikiSummary = wikiSummary.replace(/['"]+/g, '') wikiImage = wikiImage.replace(/['"]+/g, '') convoLmodel.clear() wikiListModel.clear() wikiListModel.append({summary: wikiSummary, image: wikiImage}) convoLmodel.append({"itemType": "WikiType", "InputQuery": ""}) inputlistView.positionViewAtEnd(); } function filterwikiMoreObj(metadata){ var wikiSummaryMore = JSON.stringify(metadata.data.summarymore) var wikiImageMore = JSON.stringify(metadata.data.imagemore) convoLmodel.clear() wikiListModel.clear() wikiSummaryMore = wikiSummaryMore.replace(/['"]+/g, '') wikiImageMore = wikiImageMore.replace(/['"]+/g, '') wikiListModel.append({summary: wikiSummaryMore, image: wikiImageMore}) convoLmodel.append({"itemType": "WikiType", "InputQuery": ""}) } 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}) convoLmodel.append({"itemType": "YelpType", "InputQuery": ""}) } function isBottomEdge() { return plasmoid.location == PlasmaCore.Types.BottomEdge; } function clearList() { inputlistView.clear() } function checkMicrophoneState(){ var socketmessage = {}; socketmessage.type = "mycroft.mic.get_status"; socketmessage.data = {}; socket.sendTextMessage(JSON.stringify(socketmessage)); } function muteMicrophone() { var socketmessage = {}; socketmessage.type = "mycroft.mic.mute"; socketmessage.data = {}; socket.sendTextMessage(JSON.stringify(socketmessage)); qinputmicbx.iconSource = "mic-off" } function unmuteMicrophone(){ var socketmessage = {}; socketmessage.type = "mycroft.mic.unmute"; socketmessage.data = {}; socket.sendTextMessage(JSON.stringify(socketmessage)); qinputmicbx.iconSource = "mic-on" } 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 + statusRetryBtn.enabled = true drawer.open() waitanimoutter.aniRunError() delay(1250, function() { drawer.close() }) } else if (socket.status == WebSocket.Open) { statusId.text = i18n("Connected") statusId.color = "green" statusRetryBtn.visible = false + statusRetryBtn.enabled = false mycroftstartservicebutton.circolour = "green" mycroftStatusCheckSocket.active = false; midbarAnim.showstatsId() PlasmaLa.Notify.mycroftConnectionStatus("Connected") drawer.open() waitanimoutter.aniRunHappy() delay(1250, function() { drawer.close() checkMicrophoneState() }) } else if (socket.status == WebSocket.Closed) { statusId.text = i18n("Disabled") statusId.color = theme.textColor PlasmaLa.Notify.mycroftConnectionStatus("Disconnected") 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: "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 - Rectangle { + Item { 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 { + Item { 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 { + 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" case "WikiType" : return "WikiType.qml" case "YelpType" : return "YelpType.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: { if(dashswitch.checked){ tabBar.currentTab = mycroftTab disclaimbox.visible = false showDash("setVisible") } else if(!dashswitch.checked){ convoLmodel.clear() - disclaimbox.visible = true + if(!socket.active){ + disclaimbox.visible = true + } } } - } PlasmaComponents.Label { id: dashSettingsLabel1 text: i18n("Card Settings:") font.bold: true; } PlasmaComponents.Switch { id: disclaimercardswitch text: i18n("Enable / Disable Disclaimer Card") checked: true } PlasmaComponents.Switch { id: newscardswitch text: i18n("Enable / Disable News Card") checked: true } PlasmaComponents.Switch { id: cryptocardswitch text: i18n("Enable / Disable Cryptocurrency Card") checked: false } Row { spacing: 2 PlasmaComponents.Label{ id: cryptoCurrencySelected text: "Selected CryptoCurrency:" } PlasmaComponents3.ComboBox { id: cryptoSelectedBox textRole: "cryptoname" displayText: currentText model: CrypCurModel{} property string cryptInfo: cryptoSelectedBox.model.get(currentIndex).value } } PlasmaComponents.Label{ id: localCurrencySelected text: "Display Currencies:" } PlasmaComponents3.ComboBox { id: cryptoSelectCur1 textRole: "currencyname" displayText: currentText model: CurModel{} property string cur1Info: cryptoSelectCur1.model.get(currentIndex).value } PlasmaComponents3.ComboBox { id: cryptoSelectCur2 textRole: "currencyname" displayText: currentText model: CurModel{} property string cur2Info: cryptoSelectCur2.model.get(currentIndex).value } PlasmaComponents3.ComboBox { id: cryptoSelectCur3 textRole: "currencyname" displayText: currentText model: CurModel{} property string cur3Info: cryptoSelectCur3.model.get(currentIndex).value } 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 PlasmaComponents3.ComboBox { id: versionBox anchors.left: parent.left anchors.top: parent.top anchors.bottom: parent.bottom width: parent.width / 3.5 textRole: "key" displayText: "Version: " + currentText property string versionInfo: versionItem.get(currentIndex).value model: ListModel { id: versionItem ListElement { key: "18.02"; value: "https://raw.githubusercontent.com/MycroftAI/mycroft-skills/18.02/.gitmodules" } ListElement { key: "18.0x"; value: "https://raw.githubusercontent.com/MycroftAI/mycroft-skills/master/.gitmodules" } } onActivated: { msmskillsModel.clear(); getSkills(); } } PlasmaComponents.TextField { id: msmsearchfld anchors.left: versionBox.right anchors.leftMargin: units.gridUnit * 0.50 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; } } } 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 property alias versionIndex: versionBox.currentIndex property alias versionUrl: versionBox.versionInfo property alias selectedCryptoidx: cryptoSelectedBox.currentIndex property alias selectedCrypto: cryptoSelectedBox.cryptInfo property alias selectedCur1idx: cryptoSelectCur1.currentIndex property alias selectedCur1: cryptoSelectCur1.cur1Info property alias selectedCur2idx: cryptoSelectCur2.currentIndex property alias selectedCur2: cryptoSelectCur2.cur2Info property alias selectedCur3idx: cryptoSelectCur3.currentIndex property alias selectedCur3: cryptoSelectCur3.cur3Info } } diff --git a/plugin/mycroftplasmoid_dbus.cpp b/plugin/mycroftplasmoid_dbus.cpp index c625f4a..b99193b 100644 --- a/plugin/mycroftplasmoid_dbus.cpp +++ b/plugin/mycroftplasmoid_dbus.cpp @@ -1,82 +1,89 @@ /* * Copyright (C) 2016 by Aditya Mehra * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Library General Public License as * published by the Free Software Foundation; either version 2, or * (at your option) any later version. * * This program 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 General Public License for more details * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "mycroftplasmoid_dbus.h" #include "mycroftplasmoidplugin.h" #include #include #include #include #include #include #include #include /* * Implementation of adaptor class MycroftDbusAdapterInterface */ MycroftDbusAdapterInterface::MycroftDbusAdapterInterface(QObject *parent) : QDBusAbstractAdaptor(parent) { // constructor QDBusConnection dbus = QDBusConnection::sessionBus(); dbus.registerObject("/mycroftapplet", this, QDBusConnection::ExportScriptableSlots | QDBusConnection::ExportNonScriptableSlots); dbus.registerService("org.kde.mycroftapplet"); setAutoRelaySignals(true); } MycroftDbusAdapterInterface::~MycroftDbusAdapterInterface() { // destructor } void MycroftDbusAdapterInterface::showMycroft() { // handle method call org.kde.mycroft.showMycroft emit sendShowMycroft("Show"); QMetaObject::invokeMethod(this, "getMethod", Qt::DirectConnection, Q_ARG(QString, "Show")); } void MycroftDbusAdapterInterface::showSkills() { // handle method call org.kde.mycroft.showSkills emit sendShowSkills("ShowSkills"); QMetaObject::invokeMethod(this, "getMethod", Qt::DirectConnection, Q_ARG(QString, "ShowSkills")); } void MycroftDbusAdapterInterface::showSkillsInstaller() { // handle method call org.kde.mycroft.showSkillsInstaller emit installList("ShowInstallSkills"); QMetaObject::invokeMethod(this, "getMethod", Qt::DirectConnection, Q_ARG(QString, "ShowInstallSkills")); } void MycroftDbusAdapterInterface::showRecipeMethod(const QString &recipeName) { // handle method call org.kde.mycroft.showRecipeMethod emit recipeMethod(recipeName); QMetaObject::invokeMethod(this, "getMethod", Qt::DirectConnection, Q_ARG(QString, recipeName)); } +void MycroftDbusAdapterInterface::sendKioMethod(const QString &kioString) +{ + // handle method call org.kde.mycroft.showRecipeMethod + emit kioMethod(kioString); + QMetaObject::invokeMethod(this, "getMethod", Qt::DirectConnection, Q_ARG(QString, kioString)); +} + Q_INVOKABLE QString MycroftDbusAdapterInterface::getMethod(const QString &method) { QString str = method; return str; } diff --git a/plugin/mycroftplasmoid_dbus.h b/plugin/mycroftplasmoid_dbus.h index 74c0139..8e13512 100644 --- a/plugin/mycroftplasmoid_dbus.h +++ b/plugin/mycroftplasmoid_dbus.h @@ -1,80 +1,88 @@ /* * Copyright (C) 2016 by Aditya Mehra * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Library General Public License as * published by the Free Software Foundation; either version 2, or * (at your option) any later version. * * This program 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 General Public License for more details * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef MYCROFTPLASMOID_DBUS_H #define MYCROFTPLASMOID_DBUS_H #include #include QT_BEGIN_NAMESPACE class QByteArray; template class QList; template class QMap; class QString; class QStringList; class QVariant; QT_END_NAMESPACE /* * Adaptor class for interface org.kde.mycroftapplet */ class MycroftDbusAdapterInterface: public QDBusAbstractAdaptor { Q_OBJECT Q_CLASSINFO("D-Bus Interface", "org.kde.mycroftapplet") Q_CLASSINFO("D-Bus Introspection", "" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" +" \n" +" \n" +" \n" " \n" " \n" " \n" " \n" " \n" " \n" +" \n" +" \n" +" \n" " \n" "") public: MycroftDbusAdapterInterface(QObject *parent); virtual ~MycroftDbusAdapterInterface(); Q_INVOKABLE QString getMethod(const QString &method); public: // PROPERTIES public Q_SLOTS: // METHODS void showMycroft(); void showSkills(); void showSkillsInstaller(); void showRecipeMethod(const QString &recipeName); + void sendKioMethod(const QString &kioString); Q_SIGNALS: // SIGNALS void sendShowMycroft(const QString &msgShowMycroft); void sendShowSkills(const QString &msgShowSkills); void installList(const QString &msgShowInstallSkills); void recipeMethod(const QString &msgRecipeMethod); + void kioMethod(const QString &msgKioMethod); }; #endif