Warning, /plasma-mobile/mycroft-plasmoid-mobile/plasmoid/contents/ui/MsmView.qml is written in an unsupported language. File is not indexed.
0001 /* Copyright 2016 Aditya Mehra <aix.m@outlook.com>
0002
0003 This library is free software; you can redistribute it and/or
0004 modify it under the terms of the GNU Lesser General Public
0005 License as published by the Free Software Foundation; either
0006 version 2.1 of the License, or (at your option) version 3, or any
0007 later version accepted by the membership of KDE e.V. (or its
0008 successor approved by the membership of KDE e.V.), which shall
0009 act as a proxy defined in Section 6 of version 3 of the license.
0010
0011 This library is distributed in the hope that it will be useful,
0012 but WITHOUT ANY WARRANTY; without even the implied warranty of
0013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
0014 Lesser General Public License for more details.
0015
0016 You should have received a copy of the GNU Lesser General Public
0017 License along with this library. If not, see <http://www.gnu.org/licenses/>.
0018 */
0019
0020 import QtQuick 2.9
0021 import QtQuick.Layouts 1.3
0022 import QtQuick.Controls 2.2
0023 import org.kde.plasma.core 2.0 as PlasmaCore
0024 import org.kde.plasma.plasmoid 2.0
0025 import org.kde.plasma.components 2.0 as PlasmaComponents
0026 import org.kde.plasma.extras 2.0 as PlasmaExtras
0027 import org.kde.private.mycroftplasmoidmobile 1.0 as PlasmaLa
0028 import Qt.labs.settings 1.0
0029
0030 Rectangle {
0031 id: skillcontent
0032 Layout.fillWidth: true;
0033 anchors {
0034 left: parent.left;
0035 leftMargin: 0.5;
0036 right: parent.right
0037 }
0038 height: units.gridUnit * 4
0039 border.width: 1
0040 border.color: Qt.darker(theme.linkColor, 1.2)
0041 color: Qt.darker(theme.backgroundColor, 1.2)
0042
0043 function exec(msmparam) {
0044 var bscrpt = "/usr/share/plasma/plasmoids/org.kde.plasma.mycroftplasmoid/contents/code/msm.sh"
0045 return launchinstaller.msmapp("bash " + bscrpt + " install " + model.url)
0046 }
0047
0048 function getSkillInfoLocal() {
0049 var customFold = '/opt/mycroft/skills/'
0050 var skillPath = customFold + model.name
0051 if(PlasmaLa.FileReader.file_exists_local(skillPath)){
0052 installLabl.text = i18n("Installed")
0053 getskillviamsmRect.color = Qt.lighter(theme.textColor, 1.2)
0054 installLabl.color = Qt.darker(theme.backgroundColor, 1.2)
0055 skillcontent.border.color = Qt.lighter(theme.textColor, 1.2)
0056 }
0057 }
0058
0059 PlasmaLa.MsmApp{
0060 id: launchinstaller
0061 }
0062
0063 Component.onCompleted: {
0064 msmSkillInstallProgBar.visible = false;
0065 getSkillInfoLocal();
0066 }
0067
0068 PlasmaComponents.Label {
0069 id: skllname
0070 font.capitalization: Font.AllUppercase
0071 anchors.top: parent.top
0072 anchors.left: parent.left
0073 anchors.leftMargin: units.gridUnit * 0.5
0074 anchors.right: parent.right
0075 anchors.rightMargin: units.gridUnit * 0.5
0076 wrapMode: Text.WordWrap
0077 text: model.name
0078 Rectangle {
0079 id: sepratrmsm
0080 width: parent.width
0081 height: 1
0082 anchors.left: parent.left
0083 anchors.bottom: parent.bottom
0084 anchors.bottomMargin: 2
0085 color: Qt.darker(theme.linkColor, 1.2)
0086 }
0087 }
0088
0089 PlasmaComponents.Label {
0090 id: urlskllable
0091 anchors.top: skllname.bottom
0092 anchors.topMargin: units.gridUnit * 0.03
0093 anchors.left: parent.left
0094 anchors.leftMargin: units.gridUnit * 0.5
0095 anchors.right: parent.right
0096 anchors.rightMargin: units.gridUnit * 0.5
0097 wrapMode: Text.WordWrap
0098 color: theme.textColor
0099 text: model.url
0100
0101 MouseArea{
0102 id: gotoGit
0103 anchors.fill: parent
0104 hoverEnabled: true
0105 onClicked: {Qt.openUrlExternally(model.url)}
0106 onEntered: {
0107 urlskllable.color = Qt.darker(theme.linkColor, 1.2)
0108 }
0109 onExited: {
0110 urlskllable.color = theme.textColor
0111 }
0112 }
0113 }
0114
0115 Rectangle {
0116 id: getskillviamsmRect
0117 width: parent.width
0118 height: units.gridUnit * 1
0119 anchors.bottom: parent.bottom
0120 color: Qt.darker(theme.linkColor, 1.2)
0121
0122 PlasmaComponents.Label{
0123 id: installLabl
0124 wrapMode: Text.WordWrap
0125 anchors.centerIn: parent
0126 text: i18n("Install")
0127 color: Qt.darker(theme.backgroundColor, 1.2)
0128 }
0129
0130 PlasmaComponents.ProgressBar {
0131 anchors.centerIn: parent
0132 width: parent.width / 1.2
0133 id: msmSkillInstallProgBar
0134 visible: false
0135 indeterminate: false
0136 }
0137
0138 MouseArea {
0139 anchors.fill: parent
0140 hoverEnabled: true
0141 onEntered: {
0142 switch(installLabl.text){
0143 case i18n("Install"):
0144 getskillviamsmRect.color = Qt.lighter(theme.backgroundColor, 1.2)
0145 installLabl.color = Qt.darker(theme.linkColor, 1.2)
0146 getskillviamsmRect.border.width = 1
0147 getskillviamsmRect.border.color = Qt.darker(theme.linkColor, 1.2)
0148 break
0149 case i18n("Installed"):
0150 getskillviamsmRect.color = Qt.lighter(theme.textColor, 1.2)
0151 installLabl.color = Qt.darker(theme.backgroundColor, 1.2)
0152 getskillviamsmRect.border.width = 0
0153 getskillviamsmRect.border.color = Qt.darker(theme.backgroundColor, 1.2)
0154 skillcontent.border.color = Qt.darker(theme.textColor, 1.2)
0155 break
0156 }
0157 }
0158 onExited: {
0159 switch(installLabl.text){
0160 case i18n("Install"):
0161 getskillviamsmRect.color = Qt.darker(theme.linkColor, 1.2)
0162 installLabl.color = Qt.darker(theme.backgroundColor, 1.2)
0163 getskillviamsmRect.border.width = 0
0164 break
0165 case i18n("Installed"):
0166 getskillviamsmRect.color = Qt.lighter(theme.textColor, 1.2)
0167 installLabl.color = Qt.darker(theme.backgroundColor, 1.2)
0168 getskillviamsmRect.border.width = 0
0169 getskillviamsmRect.color = Qt.lighter(theme.textColor, 1.2)
0170 skillcontent.border.color = Qt.lighter(theme.textColor, 1.2)
0171 break
0172 }
0173 }
0174 onClicked: {
0175 var msmprogress = exec()
0176 var getcurrentprogress = msmprogress.split("\n")
0177 if(getcurrentprogress.indexOf("Cloning repository") != -1)
0178 {
0179 installLabl.visible = false
0180 msmSkillInstallProgBar.visible = true;
0181 msmSkillInstallProgBar.indeterminate = true;
0182 }
0183 if(getcurrentprogress.indexOf("Skill installed!") != -1)
0184 {
0185 msmSkillInstallProgBar.visible = false
0186 installLabl.visible = true
0187 installLabl.text = i18n("Installed")
0188 getSkillInfoLocal()
0189 }
0190 }
0191 }
0192 }
0193 }
0194