Changeset View
Changeset View
Standalone View
Standalone View
plasmoid/contents/ui/MsmView.qml
- This file was added.
1 | import QtQuick 2.0 | ||||
---|---|---|---|---|---|
2 | import QtQuick.Layouts 1.0 | ||||
3 | import QtQuick.Controls 2.0 | ||||
4 | import QtQuick.Controls.Styles 1.4 | ||||
5 | import org.kde.plasma.core 2.0 as PlasmaCore | ||||
6 | import org.kde.plasma.plasmoid 2.0 | ||||
7 | import org.kde.plasma.components 2.0 as PlasmaComponents | ||||
8 | import org.kde.plasma.extras 2.0 as PlasmaExtras | ||||
9 | import org.kde.private.mycroftplasmoid 1.0 as PlasmaLa | ||||
10 | import Qt.labs.settings 1.0 | ||||
11 | | ||||
12 | Rectangle { | ||||
13 | id: skillcontent | ||||
14 | Layout.fillWidth: true; | ||||
15 | anchors { left: parent.left; right: parent.right } | ||||
16 | height: 60 | ||||
17 | border.width: 0 | ||||
18 | border.color: "lightsteelblue" | ||||
19 | radius: 2 | ||||
20 | color: theme.backgroundColor | ||||
21 | | ||||
22 | PlasmaLa.MsmApp{ | ||||
23 | id: launchinstaller | ||||
24 | } | ||||
25 | | ||||
26 | Component.onCompleted: { | ||||
27 | getSkillInfoLocal() | ||||
28 | msmSkillInstallProgBar.visible = false; | ||||
29 | } | ||||
30 | | ||||
31 | function getSkillInfoLocal() { | ||||
32 | var customFold = '/opt/mycroft/skills/' | ||||
33 | var skillPath = customFold + model.name +'/__init__.py' | ||||
34 | if(PlasmaLa.FileReader.file_exists_local(skillPath)){ | ||||
35 | //msminstllbtn.visible = false | ||||
36 | instlabel.color = "Green" | ||||
37 | instlabel.text = "Installed" | ||||
38 | } | ||||
39 | else { | ||||
40 | instlabel.text = "Not Installed" | ||||
41 | } | ||||
42 | } | ||||
43 | | ||||
44 | function exec(msmparam) { | ||||
45 | var bscrpt = "/usr/share/plasma/plasmoids/org.kde.plasma.mycroftplasmoid/contents/code/msm.sh" | ||||
46 | return launchinstaller.msmapp("bash " + bscrpt + " install " + model.url) | ||||
47 | } | ||||
48 | | ||||
49 | Column { | ||||
50 | id: skillcolumn | ||||
51 | width: parent.width / 80 | ||||
52 | | ||||
53 | PlasmaComponents.Label { | ||||
54 | font.capitalization: Font.AllUppercase | ||||
55 | wrapMode: Text.WordWrap | ||||
56 | text: model.name | ||||
57 | } | ||||
58 | | ||||
59 | PlasmaComponents.Label { | ||||
60 | font.pointSize: 8 | ||||
61 | wrapMode: Text.WordWrap | ||||
62 | width: units.gridUnit * 14 | ||||
63 | text: model.url | ||||
64 | } | ||||
65 | } | ||||
66 | | ||||
67 | PlasmaComponents.Label { | ||||
68 | id: instlabel | ||||
69 | font.pointSize: 8 | ||||
70 | wrapMode: Text.WordWrap | ||||
71 | anchors.right: msminstllbtn.left | ||||
72 | anchors.rightMargin: 5 | ||||
73 | text: "" | ||||
74 | } | ||||
75 | | ||||
76 | PlasmaComponents.ToolButton { | ||||
77 | anchors.right: parent.right | ||||
78 | id: msminstllbtn | ||||
79 | visible: true | ||||
80 | iconSource: "download" | ||||
81 | flat: true | ||||
82 | checked: false | ||||
83 | focus: false | ||||
84 | width: Math.round(units.gridUnit * 2) | ||||
85 | height: width | ||||
86 | | ||||
87 | onClicked: { | ||||
88 | console.log(model.url) | ||||
89 | var msmprogress = exec() | ||||
90 | var getcurrentprogress = msmprogress.split("\n") | ||||
91 | console.log(getcurrentprogress); | ||||
92 | if(getcurrentprogress.indexOf("Cloning repository") != -1) | ||||
93 | { | ||||
94 | msmSkillInstallProgBar.visible = true; | ||||
95 | msmSkillInstallProgBar.indeterminate = true; | ||||
96 | } | ||||
97 | if(getcurrentprogress.indexOf("Skill installed!") != -1) | ||||
98 | { | ||||
99 | msmSkillInstallProgBar.indeterminate = false; | ||||
100 | msmSkillInstallProgBar.value = 100; | ||||
101 | instlabel.color = "Green" | ||||
102 | instlabel.text = "Installed" | ||||
103 | } | ||||
104 | } | ||||
105 | | ||||
106 | } | ||||
107 | | ||||
108 | PlasmaComponents.ProgressBar { | ||||
109 | anchors.right: parent.right | ||||
110 | anchors.rightMargin: units.gridUnit * 1 | ||||
111 | anchors.bottom: parent.bottom | ||||
112 | width: units.gridUnit * 4 | ||||
113 | id: msmSkillInstallProgBar | ||||
114 | visible: false | ||||
115 | indeterminate: false | ||||
116 | } | ||||
117 | | ||||
118 | } | ||||
119 | |