diff --git a/plasmoid/contents/ui/AudioFileDelegate.qml b/plasmoid/contents/ui/AudioFileDelegate.qml new file mode 100644 --- /dev/null +++ b/plasmoid/contents/ui/AudioFileDelegate.qml @@ -0,0 +1,114 @@ +/* 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 QtMultimedia 5.8 +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: audioFileDelegateItm + implicitHeight: audioFileDelegateInner.height + color: Qt.darker(theme.backgroundColor, 1.2) + width: cbwidth + + Item { + id: audioFileDelegateInner + implicitHeight: Math.max(audioInnerInfoColumn.height, playAudioBtn.height + units.gridUnit * 1) + width: parent.width + + PlasmaCore.IconItem { + id: audioImgType + source: "new-audio-alarm" + anchors.left: parent.left + width: units.gridUnit * 1 + height: units.gridUnit * 1 + anchors.verticalCenter: parent.verticalCenter + } + + Item { + id: audioInnerInfoColumn + implicitHeight: audioFileName.implicitHeight + sprTrinnerAudio.height + audioFileLoc.implicitHeight + units.gridUnit * 0.50 + anchors.left: audioImgType.right + anchors.leftMargin: units.gridUnit * 0.30 + anchors.right: playAudioBtn.left + anchors.rightMargin: units.gridUnit * 0.30 + + PlasmaComponents.Label { + id: audioFileName + color: theme.textColor + anchors.left: parent.left + anchors.right: parent.right + anchors.top: parent.top + anchors.topMargin: units.gridUnit * 0.25 + wrapMode: Text.Wrap + height: units.gridUnit * 1 + + Component.onCompleted: { + var filterName = InputQuery.toString(); + audioFileName.text = filterName.match(/\/([^\/]+)\/?$/)[1] + } + } + + Rectangle { + id: sprTrinnerAudio + anchors.left: parent.left + anchors.right: parent.right + anchors.rightMargin: units.gridUnit * 1 + anchors.top: audioFileName.bottom + anchors.topMargin: units.gridUnit * 0.15 + color: theme.linkColor + height: units.gridUnit * 0.1 + } + + PlasmaComponents.Label { + id: audioFileLoc + color: theme.linkColor + font.pixelSize: 12 + anchors.left: parent.left + anchors.right: parent.right + anchors.top: sprTrinnerAudio.bottom + height: units.gridUnit * 1 + wrapMode: Text.Wrap + Component.onCompleted: { + audioFileLoc.text = "Location: " + InputQuery + "" + } + } + } + + PlasmaComponents.Button { + id: playAudioBtn + anchors.right: parent.right + anchors.rightMargin: units.gridUnit * 0.75 + anchors.verticalCenter: parent.verticalCenter + width: units.gridUnit * 3.5 + height: units.gridUnit * 3 + text: "Listen" + + onClicked: { + var audFile = Qt.resolvedUrl(InputQuery) + Qt.openUrlExternally(audFile) + } + } + } + } diff --git a/plasmoid/contents/ui/DocumentFileDelegate.qml b/plasmoid/contents/ui/DocumentFileDelegate.qml new file mode 100644 --- /dev/null +++ b/plasmoid/contents/ui/DocumentFileDelegate.qml @@ -0,0 +1,113 @@ +/* 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 QtMultimedia 5.8 +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: documentFileDelegateItm + implicitHeight: documentFileDelegateInner.height + color: Qt.darker(theme.backgroundColor, 1.2) + width: cbwidth + + Item { + id: documentFileDelegateInner + implicitHeight: Math.max(documentInnerInfoColumn.height, playDocumentBtn.height + units.gridUnit * 1) + width: parent.width + + PlasmaCore.IconItem { + id: documentImgType + source: "document-new" + anchors.left: parent.left + width: units.gridUnit * 1 + height: units.gridUnit * 1 + anchors.verticalCenter: parent.verticalCenter + } + + Item { + id: documentInnerInfoColumn + implicitHeight: documentFileName.implicitHeight + sprTrinnerDocument.height + documentFileLoc.implicitHeight + units.gridUnit * 0.50 + anchors.left: documentImgType.right + anchors.leftMargin: units.gridUnit * 0.30 + anchors.right: playDocumentBtn.left + anchors.rightMargin: units.gridUnit * 0.30 + + PlasmaComponents.Label { + id: documentFileName + color: theme.textColor + anchors.left: parent.left + anchors.right: parent.right + anchors.top: parent.top + anchors.topMargin: units.gridUnit * 0.25 + wrapMode: Text.Wrap + + Component.onCompleted: { + var filterName = InputQuery.toString(); + documentFileName.text = filterName.match(/\/([^\/]+)\/?$/)[1] + } + } + + Rectangle { + id: sprTrinnerDocument + anchors.left: parent.left + anchors.right: parent.right + anchors.rightMargin: units.gridUnit * 1 + anchors.top: documentFileName.bottom + anchors.topMargin: units.gridUnit * 0.15 + color: theme.linkColor + height: units.gridUnit * 0.1 + } + + PlasmaComponents.Label { + id: documentFileLoc + color: theme.linkColor + font.pointSize: 9 + anchors.left: parent.left + anchors.right: parent.right + anchors.top: sprTrinnerDocument.bottom + + wrapMode: Text.Wrap + Component.onCompleted: { + documentFileLoc.text = "Location: " + InputQuery + "" + } + } + } + + PlasmaComponents.Button { + id: playDocumentBtn + anchors.right: parent.right + anchors.rightMargin: units.gridUnit * 0.75 + anchors.verticalCenter: parent.verticalCenter + width: units.gridUnit * 3.5 + height: units.gridUnit * 3 + text: "Open" + + onClicked: { + var docFile = Qt.resolvedUrl(InputQuery) + Qt.openUrlExternally(docFile) + } + } + } + } diff --git a/plasmoid/contents/ui/VideoFileDelegate.qml b/plasmoid/contents/ui/VideoFileDelegate.qml new file mode 100644 --- /dev/null +++ b/plasmoid/contents/ui/VideoFileDelegate.qml @@ -0,0 +1,113 @@ +/* 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 QtMultimedia 5.8 +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: videoFileDelegateItm + implicitHeight: videoFileDelegateInner.height + color: Qt.darker(theme.backgroundColor, 1.2) + width: cbwidth + + Item { + id: videoFileDelegateInner + implicitHeight: Math.max(videoInnerInfoColumn.height, playVideoBtn.height + units.gridUnit * 1) + width: parent.width + + PlasmaCore.IconItem { + id: videoImgType + source: "videoclip-amarok" + anchors.left: parent.left + width: units.gridUnit * 1 + height: units.gridUnit * 1 + anchors.verticalCenter: parent.verticalCenter + } + + Item { + id: videoInnerInfoColumn + implicitHeight: videoFileName.implicitHeight + sprTrinnerVideo.height + videoFileLoc.implicitHeight + units.gridUnit * 0.50 + anchors.left: videoImgType.right + anchors.leftMargin: units.gridUnit * 0.30 + anchors.right: playVideoBtn.left + anchors.rightMargin: units.gridUnit * 0.30 + + PlasmaComponents.Label { + id: videoFileName + color: theme.textColor + anchors.left: parent.left + anchors.right: parent.right + anchors.top: parent.top + anchors.topMargin: units.gridUnit * 0.25 + wrapMode: Text.Wrap + + Component.onCompleted: { + var filterName = InputQuery.toString(); + videoFileName.text = filterName.match(/\/([^\/]+)\/?$/)[1] + } + } + + Rectangle { + id: sprTrinnerVideo + anchors.left: parent.left + anchors.right: parent.right + anchors.rightMargin: units.gridUnit * 1 + anchors.top: videoFileName.bottom + anchors.topMargin: units.gridUnit * 0.15 + color: theme.linkColor + height: units.gridUnit * 0.1 + } + + PlasmaComponents.Label { + id: videoFileLoc + color: theme.linkColor + font.pixelSize: 12 + anchors.left: parent.left + anchors.right: parent.right + anchors.top: sprTrinnerVideo.bottom + + wrapMode: Text.Wrap + Component.onCompleted: { + videoFileLoc.text = "Location: " + InputQuery + "" + } + } + } + + PlasmaComponents.Button { + id: playVideoBtn + anchors.right: parent.right + anchors.rightMargin: units.gridUnit * 0.75 + anchors.verticalCenter: parent.verticalCenter + width: units.gridUnit * 3.5 + height: units.gridUnit * 3 + text: "Play" + + onClicked: { + var vidFile = Qt.resolvedUrl(InputQuery) + Qt.openUrlExternally(vidFile) + } + } + } + } diff --git a/plasmoid/contents/ui/main.qml b/plasmoid/contents/ui/main.qml --- a/plasmoid/contents/ui/main.qml +++ b/plasmoid/contents/ui/main.qml @@ -214,6 +214,23 @@ } 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 isBottomEdge() { @@ -759,6 +776,11 @@ filterRecipeObj(dataContent) } + if(somestring && somestring.data && typeof somestring.data.desktop !== 'undefined' && somestring.type === "balooObject") { + dataContent = somestring.data.desktop + filterBalooObj(dataContent) + } + if (msgType === "speak" && !plasmoid.expanded && notificationswitch.checked == true) { var post = somestring.data.utterance; var title = "Mycroft's Reply:" @@ -998,6 +1020,9 @@ 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" } property var metacontent : dataContent }