Changeset View
Changeset View
Standalone View
Standalone View
plasmoid/contents/ui/main.qml
Show All 24 Lines | |||||
25 | import QtQuick.Controls.Styles 1.4 | 25 | import QtQuick.Controls.Styles 1.4 | ||
26 | import Qt.labs.settings 1.0 | 26 | import Qt.labs.settings 1.0 | ||
27 | import org.kde.plasma.core 2.0 as PlasmaCore | 27 | import org.kde.plasma.core 2.0 as PlasmaCore | ||
28 | import org.kde.plasma.plasmoid 2.0 | 28 | import org.kde.plasma.plasmoid 2.0 | ||
29 | import org.kde.plasma.components 2.0 as PlasmaComponents | 29 | import org.kde.plasma.components 2.0 as PlasmaComponents | ||
30 | import org.kde.plasma.extras 2.0 as PlasmaExtras | 30 | import org.kde.plasma.extras 2.0 as PlasmaExtras | ||
31 | import org.kde.private.mycroftplasmoid 1.0 as PlasmaLa | 31 | import org.kde.private.mycroftplasmoid 1.0 as PlasmaLa | ||
32 | import org.kde.plasma.private.volume 0.1 | 32 | import org.kde.plasma.private.volume 0.1 | ||
33 | import QtWebKit 3.0 | ||||
33 | 34 | | |||
34 | Item { | 35 | Item { | ||
35 | id: main | 36 | id: main | ||
36 | Layout.fillWidth: true; | 37 | Layout.fillWidth: true; | ||
37 | Plasmoid.toolTipMainText: i18n("Mycroft") | 38 | Plasmoid.toolTipMainText: i18n("Mycroft") | ||
38 | Plasmoid.switchWidth: units.gridUnit * 15 | 39 | Plasmoid.switchWidth: units.gridUnit * 15 | ||
39 | Plasmoid.switchHeight: units.gridUnit * 15 | 40 | Plasmoid.switchHeight: units.gridUnit * 15 | ||
40 | Layout.minimumHeight: units.gridUnit * 18 | 41 | Layout.minimumHeight: units.gridUnit * 22 | ||
41 | Layout.minimumWidth: units.gridUnit * 22 | 42 | Layout.minimumWidth: units.gridUnit * 24 | ||
42 | 43 | | |||
43 | Component.onCompleted: { | 44 | Component.onCompleted: { | ||
44 | mycroftStatusCheckSocket.active = true | 45 | mycroftStatusCheckSocket.active = true | ||
45 | //console.log(mycroftStatusCheckSocket.status); | 46 | refreshAllSkills(); | ||
46 | initFile(); | 47 | wordIndex(); | ||
47 | | ||||
48 | } | 48 | } | ||
49 | 49 | | |||
50 | property var skillList: [] | ||||
50 | property alias cbwidth: rectangle2.width | 51 | property alias cbwidth: rectangle2.width | ||
51 | property string defaultmcorestartpath: "/usr/share/plasma/plasmoids/org.kde.plasma.mycroftplasmoid/contents/code/startservice.sh" | 52 | property string defaultmcorestartpath: "/usr/share/plasma/plasmoids/org.kde.plasma.mycroftplasmoid/contents/code/startservice.sh" | ||
52 | property string defaultmcorestoppath: "/usr/share/plasma/plasmoids/org.kde.plasma.mycroftplasmoid/contents/code/stopservice.sh" | 53 | property string defaultmcorestoppath: "/usr/share/plasma/plasmoids/org.kde.plasma.mycroftplasmoid/contents/code/stopservice.sh" | ||
53 | property string packagemcorestartcmd: "/usr/share/plasma/plasmoids/org.kde.plasma.mycroftplasmoid/contents/code/pkgstartservice.sh" | 54 | property string packagemcorestartcmd: "/usr/share/plasma/plasmoids/org.kde.plasma.mycroftplasmoid/contents/code/pkgstartservice.sh" | ||
54 | property string packagemcorestopcmd: "/usr/share/plasma/plasmoids/org.kde.plasma.mycroftplasmoid/contents/code/pkgstopservice.sh" | 55 | property string packagemcorestopcmd: "/usr/share/plasma/plasmoids/org.kde.plasma.mycroftplasmoid/contents/code/pkgstopservice.sh" | ||
55 | property string customlocstartpath: startsrvcustom.text | 56 | property string customlocstartpath: startsrvcustom.text | ||
56 | property string customlocstoppath: stopsrvcustom.text | 57 | property string customlocstoppath: stopsrvcustom.text | ||
57 | property string customloc: " " | 58 | property string customloc: " " | ||
58 | property string coreinstallstartpath: defaultmcorestartpath | 59 | property string coreinstallstartpath: defaultmcorestartpath | ||
59 | property string coreinstallstoppath: defaultmcorestoppath | 60 | property string coreinstallstoppath: defaultmcorestoppath | ||
60 | property var files: [] | 61 | property variant searchIndex: [] | ||
61 | property variant wordListArray: [] | 62 | property variant results: [] | ||
63 | property var smintent | ||||
64 | property var dataContent | ||||
62 | 65 | | |||
63 | function initFile() { | 66 | function retryConn(){ | ||
64 | var keywordFileTemp, listFileTemp,path,wordlist; | 67 | socket.active = true | ||
65 | var baseLocation = '/usr/share/plasma/plasmoids/org.kde.plasma.mycroftplasmoid/contents/ui/suggestion/'; | 68 | if (socket.active = false){ | ||
66 | var diclocation = '/usr/share/dict/' | 69 | console.log(socket.errorString) | ||
67 | var path = diclocation + 'words'; | | |||
68 | var wordlist = readFile(path); | | |||
69 | wordListArray = wordlist.toString().split('\n'); | | |||
70 | wordListArray = wordListArray.filter(Boolean); | | |||
71 | | ||||
72 | | ||||
73 | files = [{ | | |||
74 | id: '1', | | |||
75 | category: 'math', | | |||
76 | keywordFile: baseLocation + 'MathKeywords.txt', | | |||
77 | listFile: baseLocation + 'MathList.txt', | | |||
78 | }, { | | |||
79 | id: '2', | | |||
80 | category: 'general', | | |||
81 | keywordFile: baseLocation + 'GeneralKeywords.txt', | | |||
82 | listFile: baseLocation + 'GeneralList.txt', | | |||
83 | }, { | | |||
84 | id: '3', | | |||
85 | category: 'desktop', | | |||
86 | keywordFile: baseLocation + 'DesktopKeywords.txt', | | |||
87 | listFile: baseLocation + 'DesktopList.txt', | | |||
88 | }, { | | |||
89 | id: '4', | | |||
90 | category: 'weather', | | |||
91 | keywordFile: baseLocation + 'WeatherKeywords.txt', | | |||
92 | listFile: baseLocation + 'WeatherList.txt', | | |||
93 | }, { | | |||
94 | id: '5', | | |||
95 | category: 'wiki', | | |||
96 | keywordFile: baseLocation + 'WikiKeywords.txt', | | |||
97 | listFile: baseLocation + 'WikiList.txt', | | |||
98 | }]; | | |||
99 | for (var i = 0; i < files.length; i++) { | | |||
100 | keywordFileTemp = readFile(files[i].keywordFile); | | |||
101 | keywordFileTemp = keywordFileTemp.toString().split('\n'); | | |||
102 | keywordFileTemp = keywordFileTemp.filter(Boolean); | | |||
103 | files[i].keywordFile = keywordFileTemp; | | |||
104 | listFileTemp = readFile(files[i].listFile); | | |||
105 | listFileTemp = listFileTemp.toString().split('\n'); | | |||
106 | listFileTemp = listFileTemp.filter(Boolean); | | |||
107 | files[i].listFile = listFileTemp; | | |||
108 | } | | |||
109 | setSuggestionsRandom(); | | |||
110 | } | | |||
111 | | ||||
112 | function readFile(filename) { | | |||
113 | if (PlasmaLa.FileReader.file_exists_local(filename)) { | | |||
114 | try { | | |||
115 | var content = PlasmaLa.FileReader.read(filename).toString("utf-8"); | | |||
116 | return content; | | |||
117 | } catch (e) { | | |||
118 | console.log('Mycroft UI - Read File' + e); | | |||
119 | return 0; | | |||
120 | } | | |||
121 | } else { | | |||
122 | return 0; | | |||
123 | } | 70 | } | ||
124 | } | 71 | } | ||
125 | 72 | | |||
126 | function suggestionsRandom() { | 73 | function filterSpeak(msg){ | ||
127 | 74 | convoLmodel.append({ | |||
128 | var randomFile, randomText = []; | 75 | "itemType": "NonVisual", | ||
129 | for (var i = 0; i < 3; i++) { | 76 | "InputQuery": msg | ||
130 | randomFile = files[Math.floor(files.length * Math.random())].listFile; | 77 | }) | ||
131 | randomText[i] = randomFile[Math.floor(randomFile.length * Math.random())]; | 78 | inputlistView.positionViewAtEnd(); | ||
132 | } | 79 | } | ||
133 | 80 | | |||
134 | return randomText; | 81 | function filterincoming(intent, metadata) { | ||
82 | var intentVisualArray = ['WeatherSkill:CurrentWeatherIntent']; | ||||
83 | var itemType | ||||
84 | | ||||
85 | if (intentVisualArray.indexOf(intent) !== -1) { | ||||
86 | switch (intent){ | ||||
87 | case "WeatherSkill:CurrentWeatherIntent": | ||||
88 | itemType = "CurrentWeather" | ||||
89 | break; | ||||
135 | } | 90 | } | ||
136 | 91 | | |||
137 | function setSuggestionsRandom() { | 92 | convoLmodel.append({"itemType": itemType, "itemData": metadata}) | ||
138 | var random = suggestionsRandom(); | | |||
139 | suggst.suggest1 = random[0]; | | |||
140 | suggst.suggest2 = random[1]; | | |||
141 | suggst.suggest3 = random[2]; | | |||
142 | } | 93 | } | ||
143 | 94 | | |||
144 | function setTerms(suggestTerm) { | 95 | else { | ||
145 | if (suggestTerm.length > 0) { | 96 | convoLmodel.append({"itemType": "WebViewType", "InputQuery": metadata.url}) | ||
146 | var keywordToSearch = suggestTerm[suggestTerm.length - 1]; | | |||
147 | var result = wordSuggest(keywordToSearch); | | |||
148 | if (result.length>2) { | | |||
149 | suggst.suggest1 = result[0]; | | |||
150 | suggst.suggest2 = result[1]; | | |||
151 | suggst.suggest3 = result[2]; | | |||
152 | } else { | | |||
153 | //console.log('should not ever run'); | | |||
154 | } | 97 | } | ||
155 | } | 98 | } | ||
99 | | ||||
100 | function isBottomEdge() { | ||||
101 | return plasmoid.location == PlasmaCore.Types.BottomEdge; | ||||
156 | } | 102 | } | ||
157 | 103 | | |||
158 | function getTermsForSearchString(searchString) { | 104 | function clearList() { | ||
159 | searchString = searchString.replace(/^\s+/g, '').replace(/\s+$/g, ''); | 105 | inputlistView.clear() | ||
160 | if (searchString === '') { | | |||
161 | return []; | | |||
162 | } | 106 | } | ||
163 | 107 | | |||
164 | var terms = searchString.split(/\s+/); | 108 | function muteMicrophone() { | ||
165 | return terms; | 109 | if (!sourceModel.defaultSource) { | ||
110 | return; | ||||
111 | } | ||||
112 | var toMute = !sourceModel.defaultSource.muted; | ||||
113 | sourceModel.defaultSource.muted = toMute; | ||||
166 | } | 114 | } | ||
167 | 115 | | |||
168 | function wordSuggest(keywordToSearch) { | 116 | | ||
169 | var suggestionFound; | 117 | function refreshAllSkills(){ | ||
170 | keywordToSearch = keywordToSearch.toString().toLowerCase(); | 118 | getSkills(); | ||
171 | var len = 0, | 119 | msmskillsModel.reload(); | ||
172 | a, i, j, l, k, | | |||
173 | baseSearch, keywords, keywordsFile, list, listFile, suggestion = []; | | |||
174 | for (i = 0; i < files.length; i++) { | | |||
175 | baseSearch = files[i]; | | |||
176 | keywords = baseSearch.keywordFile; | | |||
177 | for (j = 0; j < keywords.length; j++) { | | |||
178 | if (keywordToSearch.indexOf(keywords[j]) !== -1) { | | |||
179 | list = baseSearch.listFile; | | |||
180 | len = 0 | | |||
181 | for (l = 0; l < list.length; l++) { | | |||
182 | if (list[l].indexOf(keywordToSearch) !== -1) { | | |||
183 | suggestionFound = true; | | |||
184 | if (len < 3) { | | |||
185 | suggestion[len] = list[l]; | | |||
186 | len++; | | |||
187 | } | 120 | } | ||
121 | | ||||
122 | function getAllSkills(){ | ||||
123 | if(skillList.length <= 0){ | ||||
124 | getSkills(); | ||||
188 | } | 125 | } | ||
126 | return skillList; | ||||
189 | } | 127 | } | ||
190 | if (suggestion.length > 0) { | 128 | function getSkillByName(skillName){ | ||
191 | for (a = suggestion.length; a < 3; a++) { | 129 | var tempSN=[]; | ||
192 | suggestion[a] = list[Math.floor(list.length * Math.random())]; | 130 | for(var i = 0; i <skillList.length;i++){ | ||
193 | } | 131 | var sList = skillList[i].name; | ||
194 | return suggestion; | 132 | if(sList.indexOf(skillName) !== -1){ | ||
195 | } | 133 | tempSN.push(skillList[i]); | ||
196 | for (k = 0; k < 3; k++) { | | |||
197 | suggestion[k] = list[Math.floor(list.length * Math.random())]; | | |||
198 | } | | |||
199 | return suggestion; | | |||
200 | } | 134 | } | ||
201 | } | 135 | } | ||
136 | return tempSN; | ||||
202 | } | 137 | } | ||
203 | if (suggestion.length < 1) { | 138 | function getSkills() { | ||
204 | suggestion = wordListArray.filter(function(stackValue) { | 139 | var doc = new XMLHttpRequest() | ||
205 | if (stackValue) { | 140 | var url = "https://raw.githubusercontent.com/MycroftAI/mycroft-skills/master/.gitmodules" | ||
206 | return (stackValue.substring(0, keywordToSearch.length) === keywordToSearch); | 141 | doc.open("GET", url, true); | ||
207 | } | 142 | doc.send(); | ||
208 | //return stackValue; | 143 | | ||
209 | }); | 144 | doc.onreadystatechange = function() { | ||
210 | if (suggestion.length < 3) { | 145 | if (doc.readyState === XMLHttpRequest.DONE) { | ||
211 | for (a = suggestion.length; a < 3; a++) { | 146 | var path, list; | ||
212 | suggestion[a] = wordListArray[Math.floor(wordListArray.length * Math.random())]; | 147 | var tempRes = doc.responseText | ||
148 | var moduleList = tempRes.split("["); | ||||
149 | for (var i = 1; i < moduleList.length; i++) { | ||||
150 | path = moduleList[i].substring(moduleList[i].indexOf("= ") + 2, moduleList[i].indexOf("url")).replace(/^\s+|\s+$/g, ''); | ||||
151 | url = moduleList[i].substring(moduleList[i].search("url =") + 6).replace(/^\s+|\s+$/g, ''); | ||||
152 | skillList[i-1] = {"name": path, "url": url}; | ||||
153 | msmskillsModel.reload(); | ||||
213 | } | 154 | } | ||
214 | } else { | | |||
215 | for (k = 0; k < 3; k++) { | | |||
216 | suggestion[k] = suggestion[Math.floor(suggestion.length * Math.random())]; | | |||
217 | } | 155 | } | ||
218 | } | 156 | } | ||
219 | suggestionFound = false; | | |||
220 | return suggestion; | | |||
221 | } | 157 | } | ||
222 | return suggestion; | 158 | | ||
159 | function getFileExtenion(filePath){ | ||||
160 | var ext = filePath.split('.').pop(); | ||||
161 | return ext; | ||||
223 | } | 162 | } | ||
224 | 163 | | |||
225 | function muteMicrophone() { | 164 | function validateFileExtension(filePath) { | ||
226 | if (!sourceModel.defaultSource) { | 165 | var ext = filePath.split('.').pop(); | ||
227 | return; | 166 | return ext === "jpg" || ext === "png" || ext === "jpeg" || ext === 'mp3' || ext === 'wav' || ext === 'mp4' | ||
228 | } | 167 | } | ||
229 | var toMute = !sourceModel.defaultSource.muted; | 168 | | ||
230 | sourceModel.defaultSource.muted = toMute; | 169 | function getTermsForSearchString(searchString) { | ||
170 | searchString = searchString.replace(/^\s+/g, '').replace(/\s+$/g, ''); | ||||
171 | if (searchString === '') { | ||||
172 | return []; | ||||
231 | } | 173 | } | ||
232 | 174 | | |||
175 | var interms = searchString.split(/\s+/); | ||||
176 | quicksearch(interms) | ||||
177 | } | ||||
233 | 178 | | |||
234 | function filterinput() { | 179 | function wordIndex(){ | ||
235 | conversationInputList.append({"InputQuery": qboxoutput.text}); | 180 | searchIndex = ["Apache","Autoresponder","BitTorrent","Blog","Bookmark","Bot","Broadband","Captcha","Certificate","Client","Cloud","Cloud Computing","CMS","Cookie","CSS","Cyberspace","Denial of Service","Define","Earth","Facebook","Firefox","Firewall","FTP","Gateway","Google","Google Drive","Gopher","Hashtag","Hit","Home Page","Joke", "Japan", "Inbox","Internet","IP","IP Address","Moon","Meta Tag","Mars","Wallpaper","Mercury","Youtube","Alarm","Pi","News","Time","Distance","Weather","Song","Search Engine","Social Networking","Socket","Spam","Spider","Spoofing","SSH","SSL","Static Website","Twitter", "Venus","XHTML"]; | ||
236 | inputlistView.positionViewAtEnd(); | | |||
237 | } | 181 | } | ||
238 | 182 | | |||
183 | function quicksearch(inputvalue){ | ||||
184 | var inputTerms = inputvalue | ||||
185 | var results = []; | ||||
186 | var termsArray = inputTerms | ||||
187 | var prefix = termsArray; | ||||
188 | var terms = termsArray[termsArray.length -1]; | ||||
239 | 189 | | |||
240 | function isBottomEdge() { | 190 | for (var i = 0; i < searchIndex.length; i++) { | ||
241 | return plasmoid.location == PlasmaCore.Types.BottomEdge; | 191 | var a = searchIndex[i].toLowerCase(), | ||
192 | t = a.indexOf(terms); | ||||
193 | | ||||
194 | if (t > -1) { | ||||
195 | results.push(a); | ||||
196 | } | ||||
197 | } | ||||
198 | evaluateResults(results, inputTerms, terms); | ||||
242 | } | 199 | } | ||
243 | 200 | | |||
244 | function clearList() { | 201 | function evaluateResults(intresult, intinterms, intterms) { | ||
245 | inputlistView.clear() | 202 | var results = intresult | ||
203 | var inputTerms = intinterms | ||||
204 | var terms = intterms | ||||
205 | if (results.length > 0 && inputTerms.length > 0 && terms.length !== 0) { | ||||
206 | if (results.length > 1) { | ||||
207 | suggst.suggest1 = results[0]; | ||||
208 | suggst.suggest2 = results[1]; | ||||
209 | suggst.suggest3 = results[2]; | ||||
246 | } | 210 | } | ||
211 | else { | ||||
212 | //Should not show undefined | ||||
213 | } | ||||
214 | } | ||||
215 | else if (inputTerms.length > 0 && terms.length !== 0) { | ||||
216 | //Should show no results | ||||
217 | } | ||||
218 | } | ||||
219 | | ||||
247 | 220 | | |||
248 | Timer { | 221 | Timer { | ||
249 | id: timer | 222 | id: timer | ||
250 | } | 223 | } | ||
251 | 224 | | |||
252 | function delay(delayTime, cb) { | 225 | function delay(delayTime, cb) { | ||
253 | timer.interval = delayTime; | 226 | timer.interval = delayTime; | ||
254 | timer.repeat = false; | 227 | timer.repeat = false; | ||
255 | timer.triggered.connect(cb); | 228 | timer.triggered.connect(cb); | ||
256 | timer.start(); | 229 | timer.start(); | ||
257 | } | 230 | } | ||
258 | 231 | | |||
259 | Item { | 232 | Item { | ||
260 | id: root | 233 | id: topBar | ||
261 | Layout.fillWidth: true; | 234 | Layout.fillWidth: true | ||
262 | Layout.fillHeight: true; | 235 | height: units.gridUnit * 2 | ||
263 | property int minimumHeight: inputlistView.height ? inputlistView.height : rectanglebottombar.height + 30 | 236 | z: 101 | ||
237 | anchors { | ||||
238 | top: main.top | ||||
239 | topMargin: -1 | ||||
240 | left: main.left | ||||
241 | leftMargin: -1 | ||||
242 | right: main.right | ||||
243 | rightMargin: -1 | ||||
244 | } | ||||
264 | 245 | | |||
265 | property int maximumHeight: minimumHeight | | |||
266 | 246 | | |||
247 | Rectangle { | ||||
248 | id: topBarBGrect | ||||
249 | anchors.fill: parent | ||||
250 | color: Qt.darker(theme.backgroundColor, 1.8) | ||||
251 | z: 101 | ||||
252 | | ||||
253 | | ||||
254 | LeftBarAnim { | ||||
255 | id: barAnim | ||||
256 | anchors.left: parent.left | ||||
257 | anchors.leftMargin: -units.gridUnit * 1 | ||||
258 | anchors.verticalCenter: parent.verticalCenter | ||||
259 | z: 6 | ||||
260 | transformOrigin: Item.Center | ||||
261 | width: units.gridUnit * 4 | ||||
262 | height: units.gridUnit * 4 | ||||
263 | } | ||||
264 | | ||||
265 | PlasmaComponents.Label { | ||||
266 | anchors.top: parent.top | ||||
267 | anchors.topMargin: 4 | ||||
268 | anchors.left: barAnim.right | ||||
269 | anchors.leftMargin: 2 | ||||
270 | id: statusId | ||||
271 | text: i18n("Mycroft is disabled") | ||||
272 | font.bold: false; | ||||
273 | font.pixelSize: 14 | ||||
274 | color: "#fff" | ||||
275 | } | ||||
276 | | ||||
277 | TopBarAnim { | ||||
278 | id: midbarAnim | ||||
279 | anchors.verticalCenter: parent.verticalCenter | ||||
280 | anchors.left: statusId.left | ||||
281 | anchors.right: topbarDividerline.left | ||||
282 | //width: units.gridUnit * 4 | ||||
283 | height: units.gridUnit * 4 | ||||
284 | z: 6 | ||||
285 | } | ||||
286 | | ||||
287 | PlasmaCore.SvgItem { | ||||
288 | id: topbarDividerline | ||||
267 | anchors { | 289 | anchors { | ||
268 | fill: parent | 290 | right: mycroftstartservicebutton.left | ||
269 | topMargin: isBottomEdge() ? 0 : 7 | 291 | rightMargin: units.gridUnit * 0.25 | ||
270 | bottomMargin: isBottomEdge() ? 7 : 0 | 292 | top: parent.top | ||
293 | topMargin: 0 | ||||
294 | bottom: parent.bottom | ||||
295 | bottomMargin: 0 | ||||
296 | } | ||||
297 | | ||||
298 | width: linetopvertSvg.elementSize("vertical-line").width | ||||
299 | z: 110 | ||||
300 | elementId: "vertical-line" | ||||
301 | | ||||
302 | svg: PlasmaCore.Svg { | ||||
303 | id: linetopvertSvg; | ||||
304 | imagePath: "widgets/line" | ||||
305 | } | ||||
306 | } | ||||
307 | | ||||
308 | | ||||
309 | SwitchButton { | ||||
310 | anchors.right: qinputmicbx.left | ||||
311 | anchors.verticalCenter: topBarBGrect.verticalCenter | ||||
312 | id: mycroftstartservicebutton | ||||
313 | //iconSource: "media-playback-start" | ||||
314 | //tooltip: i18n("Start Mycroft") | ||||
315 | //flat: true | ||||
316 | checked: false | ||||
317 | //focus: false | ||||
318 | width: Math.round(units.gridUnit * 2) | ||||
319 | height: width | ||||
320 | z: 102 | ||||
321 | | ||||
322 | onClicked: { | ||||
323 | //mycroftstartservicebutton.checked = !mycroftstartservicebutton.checked | ||||
324 | if (mycroftstartservicebutton.checked === false) { | ||||
325 | //mycroftstartservicebutton.iconSource = "media-playback-start" | ||||
326 | PlasmaLa.LaunchApp.runCommand("bash", coreinstallstoppath); | ||||
327 | convoLmodel.clear() | ||||
328 | suggst.visible = true; | ||||
329 | socket.active = false; | ||||
330 | midbarAnim.showstatsId() | ||||
331 | } | ||||
332 | | ||||
333 | if (mycroftstartservicebutton.checked === true) { | ||||
334 | //mycroftstartservicebutton.iconSource = "media-playback-pause" | ||||
335 | PlasmaLa.LaunchApp.runCommand("bash", coreinstallstartpath); | ||||
336 | convoLmodel.clear() | ||||
337 | suggst.visible = true; | ||||
338 | delay(10000, function() { | ||||
339 | socket.active = true; | ||||
340 | }) | ||||
341 | } | ||||
342 | | ||||
343 | } | ||||
344 | | ||||
345 | } | ||||
346 | | ||||
347 | PlasmaComponents.ToolButton { | ||||
348 | id: qinputmicbx | ||||
349 | anchors.right: pinButton.left | ||||
350 | anchors.verticalCenter: parent.verticalCenter | ||||
351 | iconSource: "mic-on" | ||||
352 | tooltip: i18n("Toggle Mic") | ||||
353 | flat: true | ||||
354 | width: Math.round(units.gridUnit * 2) | ||||
355 | height: width | ||||
356 | z: 102 | ||||
357 | | ||||
358 | onClicked: { | ||||
359 | if (qinputmicbx.iconSource == "mic-on") { | ||||
360 | qinputmicbx.iconSource = "mic-off" | ||||
361 | } | ||||
362 | else if (qinputmicbx.iconSource == "mic-off") { | ||||
363 | qinputmicbx.iconSource = "mic-on" | ||||
364 | } | ||||
365 | muteMicrophone() | ||||
366 | } | ||||
367 | } | ||||
368 | | ||||
369 | | ||||
370 | | ||||
371 | PlasmaComponents.ToolButton { | ||||
372 | id: pinButton | ||||
373 | anchors.right: parent.right | ||||
374 | anchors.verticalCenter: topBarBGrect.verticalCenter | ||||
375 | width: Math.round(units.gridUnit * 1.5) | ||||
376 | height: width | ||||
377 | checkable: true | ||||
378 | iconSource: "window-pin" | ||||
379 | onCheckedChanged: plasmoid.hideOnWindowDeactivate = !checked | ||||
380 | z: 102 | ||||
381 | } | ||||
382 | | ||||
383 | } | ||||
384 | } | ||||
385 | | ||||
386 | PlasmaCore.SvgItem { | ||||
387 | anchors { | ||||
388 | left: main.left | ||||
389 | right: main.right | ||||
390 | top: root.top | ||||
391 | } | ||||
392 | width: 1 | ||||
393 | height: horlinetopbarSvg.elementSize("horizontal-line").height | ||||
394 | | ||||
395 | elementId: "horizontal-line" | ||||
396 | z: 110 | ||||
397 | svg: PlasmaCore.Svg { | ||||
398 | id: horlinetopbarSvg; | ||||
399 | imagePath: "widgets/line" | ||||
400 | } | ||||
401 | } | ||||
402 | | ||||
403 | Item { | ||||
404 | id: root | ||||
405 | anchors { | ||||
406 | top: topBar.bottom | ||||
407 | bottom: rectanglebottombar.top | ||||
408 | left: parent.left | ||||
409 | right: parent.right | ||||
271 | } | 410 | } | ||
272 | 411 | | |||
273 | WebSocket { | 412 | WebSocket { | ||
274 | id: mycroftStatusCheckSocket | 413 | id: mycroftStatusCheckSocket | ||
275 | url: "ws://0.0.0.0:8181/core" | 414 | url: innerset.wsurl | ||
276 | onTextMessageReceived: { | 415 | onTextMessageReceived: { | ||
277 | console.log("Mycroft Status Ping"); | 416 | //console.log("Mycroft Status Ping"); | ||
278 | } | 417 | } | ||
279 | active: true | 418 | active: true | ||
280 | onStatusChanged: | 419 | onStatusChanged: | ||
281 | if (mycroftStatusCheckSocket.status == WebSocket.Open && socket.status == WebSocket.Closed) { | 420 | if (mycroftStatusCheckSocket.status == WebSocket.Open && socket.status == WebSocket.Closed) { | ||
282 | console.log("Activated") | 421 | console.log("Activated") | ||
283 | socket.active = true | 422 | socket.active = true | ||
284 | mycroftstartservicebutton.checked = true | 423 | mycroftstartservicebutton.checked = true | ||
285 | mycroftstartservicebutton.iconSource = "media-playback-pause" | 424 | mycroftstartservicebutton.iconSource = "media-playback-pause" | ||
286 | statusId.text = "Mycroft is Ready" | 425 | statusId.text = i18n("Mycroft is Ready") | ||
287 | statusId.color = "green" | 426 | statusId.color = "green" | ||
427 | statusId.visible = true | ||||
288 | } | 428 | } | ||
289 | 429 | | |||
290 | else if (mycroftStatusCheckSocket.status == WebSocket.Error) { | 430 | else if (mycroftStatusCheckSocket.status == WebSocket.Error) { | ||
291 | mycroftstartservicebutton.checked = false | 431 | mycroftstartservicebutton.checked = false | ||
292 | mycroftstartservicebutton.iconSource = "media-playback-start" | 432 | mycroftstartservicebutton.iconSource = "media-playback-start" | ||
293 | statusId.text = "Mycroft is Disabled" | 433 | statusId.text = i18n("Mycroft is Disabled") | ||
294 | statusId.color = "#f4bf42" | 434 | statusId.color = "#f4bf42" | ||
435 | statusId.visible = true | ||||
295 | } | 436 | } | ||
296 | } | 437 | } | ||
297 | 438 | | |||
298 | WebSocket { | 439 | WebSocket { | ||
299 | id: socket | 440 | id: socket | ||
300 | url: "ws://0.0.0.0:8181/core" | 441 | url: innerset.wsurl | ||
301 | onTextMessageReceived: { | 442 | onTextMessageReceived: { | ||
302 | var somestring = JSON.parse(message) | 443 | var somestring = JSON.parse(message) | ||
303 | var msgType = somestring.type; | 444 | var msgType = somestring.type; | ||
304 | qinput.focus = false; | 445 | qinput.focus = false; | ||
305 | 446 | | |||
306 | if (msgType === "recognizer_loop:utterance") { | 447 | if (msgType === "recognizer_loop:utterance") { | ||
307 | var intpost = somestring.data.utterances; | 448 | var intpost = somestring.data.utterances; | ||
308 | qinput.text = intpost.toString() | 449 | qinput.text = intpost.toString() | ||
450 | midbarAnim.wsistalking() | ||||
309 | } | 451 | } | ||
310 | 452 | | |||
311 | if (msgType === "speak") { | 453 | if (somestring && somestring.data && typeof somestring.data.intent_type !== 'undefined'){ | ||
454 | smintent = somestring.data.intent_type; | ||||
455 | console.log('intent type: ' + smintent); | ||||
456 | } | ||||
457 | | ||||
458 | if(somestring && somestring.data && typeof somestring.data.utterance !== 'undefined' && somestring.type === 'speak'){ | ||||
459 | filterSpeak(somestring.data.utterance); | ||||
460 | } | ||||
461 | | ||||
462 | if(somestring && somestring.data && typeof somestring.data.desktop !== 'undefined') { | ||||
463 | dataContent = somestring.data.desktop | ||||
464 | filterincoming(smintent, dataContent) | ||||
465 | } | ||||
466 | | ||||
467 | if (msgType === "speak" && !plasmoid.expanded && notificationswitch.checked == true) { | ||||
312 | var post = somestring.data.utterance; | 468 | var post = somestring.data.utterance; | ||
313 | qboxoutput.text = post; | | |||
314 | filterinput() | | |||
315 | var title = "Mycroft's Reply:" | 469 | var title = "Mycroft's Reply:" | ||
316 | var notiftext = " "+ post; | 470 | var notiftext = " "+ post; | ||
317 | | ||||
318 | if (!plasmoid.expanded && notificationswitch.checked == true) { | | |||
319 | PlasmaLa.Notify.mycroftResponse(title, notiftext); | 471 | PlasmaLa.Notify.mycroftResponse(title, notiftext); | ||
320 | } | 472 | } | ||
321 | } | | |||
322 | barAnim.wsocmsganimtoggle() | 473 | barAnim.wsocmsganimtoggle() | ||
474 | midbarAnim.wsistalking() | ||||
323 | } | 475 | } | ||
324 | 476 | | |||
325 | onStatusChanged: if (socket.status == WebSocket.Error) { | 477 | onStatusChanged: if (socket.status == WebSocket.Error) { | ||
326 | statusId.text = "Connection Error" | 478 | statusId.text = "Connection Error" | ||
327 | statusId.color = "red" | 479 | statusId.color = "red" | ||
328 | barAnim.wsocerroranimtoggle() | 480 | mycroftstartservicebutton.circolour = "red" | ||
481 | console.log(socket.errorString) | ||||
482 | retryConn() | ||||
483 | barAnim.wsocmsganimtoggle() | ||||
484 | midbarAnim.showstatsId() | ||||
329 | } else if (socket.status == WebSocket.Open) { | 485 | } else if (socket.status == WebSocket.Open) { | ||
330 | statusId.text = "Mycroft is Ready" | 486 | statusId.text = "Mycroft is Ready" | ||
331 | statusId.color = "green" | 487 | statusId.color = "green" | ||
332 | barAnim.wsocrunninganimtoggle() | 488 | mycroftstartservicebutton.circolour = "green" | ||
489 | barAnim.wsocmsganimtoggle() | ||||
490 | //midbarAnim.topanimrun = false; | ||||
333 | mycroftStatusCheckSocket.active = false; | 491 | mycroftStatusCheckSocket.active = false; | ||
492 | midbarAnim.showstatsId() | ||||
334 | } else if (socket.status == WebSocket.Closed) { | 493 | } else if (socket.status == WebSocket.Closed) { | ||
335 | statusId.text = "Mycroft is Disabled" | 494 | statusId.text = "Mycroft is Disabled" | ||
336 | statusId.color = "#f4bf42" | 495 | statusId.color = "#f4bf42" | ||
337 | barAnim.wsocclosedanimtoggle() | 496 | mycroftstartservicebutton.circolour = Qt.lighter(theme.backgroundColor, 1.5) | ||
497 | barAnim.wsocmsganimtoggle() | ||||
498 | midbarAnim.showstatsId() | ||||
338 | } else if (socket.status == WebSocket.Connecting) { | 499 | } else if (socket.status == WebSocket.Connecting) { | ||
339 | statusId.text = "Starting Up" | 500 | statusId.text = "Starting Up" | ||
340 | statusId.color = "grey" | 501 | statusId.color = "grey" | ||
502 | mycroftstartservicebutton.circolour = "steelblue" | ||||
503 | midbarAnim.showstatsId() | ||||
341 | } else if (socket.status == WebSocket.Closing) { | 504 | } else if (socket.status == WebSocket.Closing) { | ||
342 | statusId.text = "Shutting Down" | 505 | statusId.text = "Shutting Down" | ||
343 | statusId.color = "grey" | 506 | statusId.color = "grey" | ||
507 | midbarAnim.showstatsId() | ||||
344 | } | 508 | } | ||
345 | 509 | //active: false; | |||
346 | | ||||
347 | active: false; | | |||
348 | } | | |||
349 | | ||||
350 | Rectangle { | | |||
351 | id: rectangletopbar | | |||
352 | height: 40 | | |||
353 | color: theme.backgroundColor | | |||
354 | anchors.top: root.top | | |||
355 | anchors.right: root.right | | |||
356 | anchors.rightMargin: 0 | | |||
357 | anchors.left: root.left | | |||
358 | anchors.leftMargin: 0 | | |||
359 | border.width: 0 | | |||
360 | border.color: "#80000000" | | |||
361 | z: 2 | | |||
362 | | ||||
363 | | ||||
364 | RowLayout { | | |||
365 | id: topbarinnergridLayout | | |||
366 | anchors.right: parent.right | | |||
367 | anchors.left: parent.left | | |||
368 | Layout.fillHeight: true | | |||
369 | Layout.fillWidth: true | | |||
370 | | ||||
371 | PlasmaComponents.ToolButton { | | |||
372 | anchors.left: parent.left | | |||
373 | id: mycroftSettingsTab | | |||
374 | iconSource: "games-config-options" | | |||
375 | flat: true | | |||
376 | checked: false | | |||
377 | focus: false | | |||
378 | minimumHeight: 4 | | |||
379 | minimumWidth: 4 | | |||
380 | | ||||
381 | onClicked: { | | |||
382 | mycroftSettingsColumn.visible = !mycroftSettingsColumn.visible | | |||
383 | if (mycroftSettingsColumn.visible === true) { | | |||
384 | mycroftanimbar.visible = false | | |||
385 | } else if (mycroftSettingsColumn.visible === false) { | | |||
386 | mycroftanimbar.visible = true | | |||
387 | } | | |||
388 | } | | |||
389 | } | 510 | } | ||
390 | 511 | | |||
391 | 512 | ColumnLayout { | |||
392 | PlasmaComponents.ToolButton { | 513 | id: sidebar | ||
393 | anchors.left: mycroftSettingsTab.right | 514 | Layout.fillHeight: true; | ||
394 | anchors.leftMargin: 2 | 515 | width: units.gridUnit * 2 | ||
395 | id: mycroftstartservicebutton | | |||
396 | iconSource: "media-playback-start" | | |||
397 | flat: true | | |||
398 | checked: false | | |||
399 | focus: false | | |||
400 | minimumHeight: 4 | | |||
401 | minimumWidth: 4 | | |||
402 | | ||||
403 | onClicked: { | | |||
404 | //console.log(coreinstallstartpath); | | |||
405 | mycroftstartservicebutton.checked = !mycroftstartservicebutton.checked | | |||
406 | if (mycroftstartservicebutton.checked === false) { | | |||
407 | mycroftstartservicebutton.iconSource = "media-playback-start" | | |||
408 | PlasmaLa.LaunchApp.runCommand("bash", coreinstallstoppath); | | |||
409 | conversationInputList.clear() | | |||
410 | suggst.visible = true; | | |||
411 | socket.active = false; | | |||
412 | } | | |||
413 | | ||||
414 | if (mycroftstartservicebutton.checked === true) { | | |||
415 | mycroftstartservicebutton.iconSource = "media-playback-pause" | | |||
416 | PlasmaLa.LaunchApp.runCommand("bash", coreinstallstartpath); | | |||
417 | conversationInputList.clear() | | |||
418 | suggst.visible = true; | | |||
419 | delay(15000, function() { | | |||
420 | socket.active = true; | | |||
421 | }) | | |||
422 | } | | |||
423 | | ||||
424 | } | | |||
425 | | ||||
426 | } | | |||
427 | | ||||
428 | | ||||
429 | PlasmaComponents.Label { | | |||
430 | anchors.top: parent.top | | |||
431 | anchors.topMargin: 4 | | |||
432 | anchors.horizontalCenter: parent.horizontalCenter | | |||
433 | anchors.horizontalCenterOffset: -10 | | |||
434 | id: statusId | | |||
435 | text: "Mycroft is disabled" | | |||
436 | font.bold: false; | | |||
437 | font.pixelSize: 14 | | |||
438 | color: "#f4bf42" | | |||
439 | } | | |||
440 | 516 | | |||
441 | PlasmaComponents.TabBar { | 517 | PlasmaComponents.TabBar { | ||
442 | id: tabBar | 518 | id: tabBar | ||
443 | anchors.right: parent.right | 519 | anchors.fill: parent | ||
520 | tabPosition: Qt.LeftEdge; | ||||
444 | 521 | | |||
445 | PlasmaComponents.TabButton { | 522 | PlasmaComponents.TabButton { | ||
446 | id: mycroftTab | 523 | id: mycroftTab | ||
447 | Layout.fillHeight: true | 524 | Layout.fillHeight: true | ||
448 | Layout.fillWidth: true | 525 | Layout.fillWidth: true | ||
449 | iconSource: "system-search" | 526 | iconSource: "user-home" | ||
450 | } | 527 | } | ||
451 | 528 | | |||
452 | PlasmaComponents.TabButton { | 529 | PlasmaComponents.TabButton { | ||
453 | id: mycroftSkillsTab | 530 | id: mycroftSkillsTab | ||
454 | Layout.fillHeight: true | 531 | Layout.fillHeight: true | ||
455 | Layout.fillWidth: true | 532 | Layout.fillWidth: true | ||
456 | iconSource: "games-hint" | 533 | iconSource: "games-hint" | ||
457 | } | 534 | } | ||
535 | | ||||
536 | PlasmaComponents.TabButton { | ||||
537 | id: mycroftSettingsTab | ||||
538 | Layout.fillHeight: true | ||||
539 | Layout.fillWidth: true | ||||
540 | iconSource: "games-config-options" | ||||
458 | } | 541 | } | ||
542 | | ||||
543 | PlasmaComponents.TabButton { | ||||
544 | id: mycroftMSMinstTab | ||||
545 | Layout.fillHeight: true | ||||
546 | Layout.fillWidth: true | ||||
547 | iconSource: "kmouth-phresebook-new" | ||||
548 | } | ||||
549 | | ||||
459 | } | 550 | } | ||
460 | } | 551 | } | ||
461 | 552 | | |||
462 | Rectangle { | 553 | PlasmaCore.SvgItem { | ||
463 | id: mycroftanimbar | 554 | anchors { | ||
464 | height: 80 | 555 | left: parent.left | ||
465 | anchors.left: parent.left | 556 | leftMargin: sidebar.width | ||
466 | anchors.right: parent.right | 557 | top: parent.top | ||
467 | anchors.top: rectangletopbar.bottom | 558 | topMargin: 1 | ||
468 | anchors.topMargin: -12; | 559 | bottom: parent.bottom | ||
469 | color: theme.backgroundColor | 560 | bottomMargin: 1 | ||
470 | z: 3 | 561 | } | ||
471 | 562 | | |||
472 | TopBarAnim { | 563 | width: lineSvg.elementSize("vertical-line").width | ||
473 | id: barAnim | 564 | z: 110 | ||
474 | z: 6 | 565 | elementId: "vertical-line" | ||
566 | | ||||
567 | svg: PlasmaCore.Svg { | ||||
568 | id: lineSvg; | ||||
569 | imagePath: "widgets/line" | ||||
475 | } | 570 | } | ||
476 | } | 571 | } | ||
477 | 572 | | |||
478 | ColumnLayout { | 573 | ColumnLayout { | ||
479 | id: mycroftcolumntab | 574 | id: mycroftcolumntab | ||
480 | visible: tabBar.currentTab == mycroftTab; | 575 | visible: tabBar.currentTab == mycroftTab; | ||
481 | anchors.top: mycroftanimbar.bottom | 576 | anchors.top: root.top | ||
482 | anchors.left: root.left | 577 | anchors.left: sidebar.right | ||
578 | anchors.leftMargin: units.gridUnit * 0.25 | ||||
483 | anchors.right: root.right | 579 | anchors.right: root.right | ||
484 | anchors.bottom: rectanglebottombar.top | 580 | anchors.bottom: root.bottom | ||
485 | 581 | | |||
486 | Rectangle { | 582 | Rectangle { | ||
487 | id: rectangle2 | 583 | id: rectangle2 | ||
488 | color: "#00000000" | 584 | color: "#00000000" | ||
489 | anchors.top: mycroftcolumntab.top | 585 | anchors.top: mycroftcolumntab.top | ||
490 | anchors.topMargin:15 | 586 | anchors.topMargin:15 | ||
491 | anchors.left: mycroftcolumntab.left | 587 | anchors.left: mycroftcolumntab.left | ||
492 | anchors.right: mycroftcolumntab.right | 588 | anchors.right: mycroftcolumntab.right | ||
493 | anchors.bottom: suggestionbottombox.top | 589 | anchors.bottom: mycroftcolumntab.bottom | ||
590 | | ||||
591 | DropArea { | ||||
592 | anchors.fill: parent; | ||||
593 | id: dragTarget | ||||
594 | onEntered: { | ||||
595 | for(var i = 0; i < drag.urls.length; i++) | ||||
596 | if(validateFileExtension(drag.urls[i])) | ||||
597 | return | ||||
598 | console.log("No valid files, refusing drag event") | ||||
599 | drag.accept() | ||||
600 | dragTarget.enabled = false | ||||
601 | } | ||||
602 | | ||||
603 | onDropped: { | ||||
604 | for(var i = 0; i < drop.urls.length; i++){ | ||||
605 | var ext = getFileExtenion(drop.urls[i]); | ||||
606 | if(ext === "jpg" || ext === "png" || ext === "jpeg"){ | ||||
607 | var durl = String(drop.urls[i]); | ||||
608 | console.log(durl) | ||||
609 | convoLmodel.append({ | ||||
610 | "itemType": "DropImg", | ||||
611 | "InputQuery": durl | ||||
612 | }) | ||||
613 | inputlistView.positionViewAtEnd(); | ||||
614 | | ||||
615 | | ||||
616 | var irecogmsgsend = innerset.customrecog | ||||
617 | var socketmessage = {}; | ||||
618 | socketmessage.type = "recognizer_loop:utterance"; | ||||
619 | socketmessage.data = {}; | ||||
620 | socketmessage.data.utterances = [irecogmsgsend + " " + durl]; | ||||
621 | socket.sendTextMessage(JSON.stringify(socketmessage)); | ||||
622 | console.log(irecogmsgsend + " " + durl); | ||||
623 | } | ||||
624 | | ||||
625 | if(ext === 'mp3'){ | ||||
626 | console.log('mp3'); | ||||
627 | } | ||||
628 | } | ||||
629 | } | ||||
494 | 630 | | |||
495 | ListModel{ | 631 | ListModel{ | ||
496 | id: conversationInputList | 632 | id: convoLmodel | ||
497 | } | 633 | } | ||
498 | 634 | | |||
499 | Rectangle { | 635 | Rectangle { | ||
500 | id: messageBox | 636 | id: messageBox | ||
501 | anchors.fill: parent | 637 | anchors.fill: parent | ||
502 | anchors.right: rectangle2.right | 638 | anchors.right: rectangle2.right | ||
639 | anchors.left: rectangle2.left | ||||
503 | color: "#00000000" | 640 | color: "#00000000" | ||
504 | 641 | | |||
505 | ColumnLayout { | 642 | ColumnLayout { | ||
506 | id: colconvo | 643 | id: colconvo | ||
507 | anchors.fill: parent | 644 | anchors.fill: parent | ||
508 | 645 | | |||
509 | ListView { | 646 | ListView { | ||
510 | id: inputlistView | 647 | id: inputlistView | ||
511 | Layout.fillWidth: true | 648 | Layout.fillWidth: true | ||
512 | Layout.fillHeight: true | 649 | Layout.fillHeight: true | ||
513 | verticalLayoutDirection: ListView.TopToBottom | 650 | verticalLayoutDirection: ListView.TopToBottom | ||
514 | spacing: 12 | 651 | spacing: 12 | ||
515 | model: conversationInputList | 652 | model: convoLmodel | ||
516 | delegate: Loader { | | |||
517 | source: "MessageBox.qml" | | |||
518 | } | | |||
519 | ScrollBar.vertical: ScrollBar {} | 653 | ScrollBar.vertical: ScrollBar {} | ||
654 | delegate: Component { | ||||
655 | Loader { | ||||
656 | source: switch(itemType) { | ||||
657 | case "NonVisual": return "SimpleMessageType.qml" | ||||
658 | case "WebViewType": return "WebViewType.qml" | ||||
659 | case "CurrentWeather": return "CurrentWeatherType.qml" | ||||
660 | case "DropImg" : return "ImgRecogType.qml" | ||||
661 | } | ||||
662 | property var metacontent : dataContent | ||||
663 | } | ||||
664 | } | ||||
520 | 665 | | |||
521 | onCountChanged: { | 666 | onCountChanged: { | ||
522 | inputlistView.positionViewAtEnd(); | 667 | inputlistView.positionViewAtEnd(); | ||
523 | } | 668 | } | ||
524 | } | 669 | } | ||
525 | } | 670 | } | ||
526 | } | 671 | } | ||
527 | } | 672 | } | ||
528 | | ||||
529 | Rectangle { | | |||
530 | id: suggestionbottombox | | |||
531 | anchors.bottom: mycroftcolumntab.bottom | | |||
532 | anchors.right: parent.right | | |||
533 | anchors.left: parent.left | | |||
534 | color: theme.backgroundColor | | |||
535 | height: 40; | | |||
536 | | ||||
537 | Flickable { | | |||
538 | width: parent.width | | |||
539 | height: suggestionbottombox.height | | |||
540 | contentWidth: 1000 | | |||
541 | contentHeight: suggestionbottombox.height | | |||
542 | interactive: true; | | |||
543 | | ||||
544 | Suggestions { | | |||
545 | id: suggst | | |||
546 | visible: true; | | |||
547 | } | | |||
548 | | ||||
549 | ScrollBar.horizontal: ScrollBar {} | | |||
550 | | ||||
551 | } | | |||
552 | } | 673 | } | ||
553 | | ||||
554 | } | 674 | } | ||
555 | 675 | | |||
556 | ColumnLayout { | 676 | ColumnLayout { | ||
557 | id: mycroftSkillscolumntab | 677 | id: mycroftSkillscolumntab | ||
558 | visible: tabBar.currentTab == mycroftSkillsTab; | 678 | visible: tabBar.currentTab == mycroftSkillsTab; | ||
559 | anchors.top: mycroftanimbar.bottom | 679 | anchors.top: root.top | ||
560 | anchors.left: root.left | 680 | anchors.left: sidebar.right | ||
681 | anchors.leftMargin: units.gridUnit * 0.25 | ||||
561 | anchors.right: root.right | 682 | anchors.right: root.right | ||
562 | anchors.bottom: rectanglebottombar.top | 683 | anchors.bottom: root.bottom | ||
563 | anchors.bottomMargin: 5 | | |||
564 | 684 | | |||
565 | Text { | | |||
566 | id: qboxoutput | | |||
567 | text: " " | | |||
568 | visible: false | | |||
569 | } | | |||
570 | 685 | | |||
571 | Rectangle { | 686 | Rectangle { | ||
572 | anchors.top: mycroftSkillscolumntab.top | 687 | anchors.top: mycroftSkillscolumntab.top | ||
688 | anchors.left: mycroftSkillscolumntab.left | ||||
689 | anchors.right: mycroftSkillscolumntab.right | ||||
573 | id: skillsrectmain | 690 | id: skillsrectmain | ||
574 | color: "#00000000" | 691 | color: "#00000000" | ||
575 | 692 | | |||
576 | Component { | 693 | Component { | ||
577 | id: skillDelegate | 694 | id: skillDelegate | ||
578 | Rectangle { | 695 | Rectangle { | ||
579 | id: skillcontent | 696 | id: skillcontent | ||
580 | Layout.fillWidth: true; | 697 | Layout.fillWidth: true; | ||
581 | anchors { left: parent.left; right: parent.right } | 698 | anchors { left: parent.left; right: parent.right } | ||
582 | height: 80 | 699 | height: 80 | ||
583 | border.width: 0 | 700 | border.width: 0 | ||
584 | border.color: "lightsteelblue" | 701 | border.color: "lightsteelblue" | ||
585 | radius: 2 | 702 | radius: 2 | ||
586 | color: theme.backgroundColor | 703 | color: theme.backgroundColor | ||
587 | z: -99 | 704 | z: -99 | ||
588 | 705 | | |||
589 | Column { | 706 | RowLayout { | ||
590 | id: skillcolumn | | |||
591 | Layout.fillWidth: true; | | |||
592 | PlasmaComponents.Label { wrapMode: Text.WordWrap; font.bold: true; text: '<b>Skill:</b> ' + Skill } | | |||
593 | | ||||
594 | Row { | | |||
595 | id: skillTopRowLayout | 707 | id: skillTopRowLayout | ||
596 | //height: skillimage.height | 708 | spacing: 5 | ||
597 | spacing: 10 | 709 | anchors.fill: parent | ||
710 | | ||||
711 | PlasmaComponents.Label { | ||||
712 | id: innerskllname | ||||
713 | anchors.top: parent.top | ||||
714 | anchors.topMargin: 2 | ||||
715 | anchors.left: parent.left | ||||
716 | anchors.right: parent.right | ||||
717 | wrapMode: Text.WordWrap; | ||||
718 | font.bold: true; | ||||
719 | text: i18n('<b>Skill:</b>' + Skill) | ||||
720 | } | ||||
721 | | ||||
722 | Rectangle { | ||||
723 | id: skilltipsimage | ||||
724 | anchors.left: parent.left | ||||
725 | anchors.top: innerskllname.bottom | ||||
726 | anchors.bottom: parent.bottom | ||||
727 | width: units.gridUnit * 1.2 | ||||
728 | color: theme.backgroundColor | ||||
729 | | ||||
730 | Image { | ||||
731 | id: innerskImg | ||||
732 | source: Pic | ||||
733 | width: units.gridUnit * 1.2 | ||||
734 | height: units.gridUnit * 1.2 | ||||
735 | anchors.centerIn: parent | ||||
736 | } | ||||
737 | | ||||
738 | PlasmaCore.SvgItem { | ||||
739 | anchors { | ||||
740 | left: innerskImg.right | ||||
741 | leftMargin: 4 | ||||
742 | top: parent.top | ||||
743 | topMargin: 0 | ||||
744 | bottom: parent.bottom | ||||
745 | bottomMargin: 0 | ||||
746 | } | ||||
747 | | ||||
748 | width: lineskillpgSvg.elementSize("vertical-line").width | ||||
749 | z: 110 | ||||
750 | elementId: "vertical-line" | ||||
751 | | ||||
752 | svg: PlasmaCore.Svg { | ||||
753 | id: lineskillpgSvg; | ||||
754 | imagePath: "widgets/line" | ||||
755 | } | ||||
756 | } | ||||
757 | | ||||
758 | } | ||||
759 | | ||||
760 | Rectangle { | ||||
761 | id: skilltipsinner | ||||
762 | anchors.left: skilltipsimage.right | ||||
763 | anchors.leftMargin: 10 | ||||
764 | anchors.right: parent.right | ||||
765 | color: theme.backgroundColor | ||||
766 | anchors.top: innerskllname.bottom | ||||
767 | anchors.bottom: parent.bottom | ||||
598 | 768 | | |||
599 | Column { | 769 | Column{ | ||
600 | id: skillinnercolumn | 770 | id: innerskillscolumn | ||
771 | spacing: 2 | ||||
601 | 772 | | |||
602 | PlasmaComponents.Label {wrapMode: Text.WordWrap; width: main.width; text: '<b>Command:</b> ' + CommandList.get(0).Commands} | 773 | PlasmaComponents.Label {wrapMode: Text.WordWrap; width: main.width; text: i18n('<b>Command:</b> ' + CommandList.get(0).Commands)} | ||
603 | PlasmaComponents.Label {wrapMode: Text.WordWrap; width: main.width; text: '<b>Command:</b> ' + CommandList.get(1).Commands} | 774 | PlasmaComponents.Label {wrapMode: Text.WordWrap; width: main.width; text: i18n('<b>Command:</b> ' + CommandList.get(1).Commands)} | ||
604 | PlasmaComponents.Label { wrapMode: Text.WordWrap; width: main.width; text: '<b>Command:</b> ' + CommandList.get(2).Commands} | | |||
605 | PlasmaComponents.Label { wrapMode: Text.WordWrap; width: main.width; text: '<b>Command:</b> ' + CommandList.get(3).Commands} | | |||
606 | PlasmaComponents.Label { wrapMode: Text.WordWrap; width: main.width; text: '<b>Command:</b> ' + CommandList.get(4).Commands} | | |||
607 | } | 775 | } | ||
608 | } | 776 | } | ||
609 | } | 777 | } | ||
610 | } | 778 | } | ||
611 | } | 779 | } | ||
612 | } | 780 | } | ||
613 | 781 | | |||
614 | ListView { | 782 | ListView { | ||
615 | id: skillslistmodelview | 783 | id: skillslistmodelview | ||
616 | anchors.top: parent.top | 784 | anchors.top: parent.top | ||
617 | anchors.topMargin: 5 | 785 | anchors.topMargin: 5 | ||
618 | anchors.left: parent.left | 786 | anchors.left: parent.left | ||
619 | anchors.right: parent.right | 787 | anchors.right: parent.right | ||
620 | anchors.bottom: parent.bottom | 788 | anchors.bottom: parent.bottom | ||
621 | model: SkillModel{} | 789 | model: SkillModel{} | ||
622 | delegate: skillDelegate | 790 | delegate: skillDelegate | ||
623 | spacing: 4 | 791 | spacing: 4 | ||
624 | focus: false | 792 | focus: false | ||
625 | interactive: true | 793 | interactive: true | ||
794 | clip: true; | ||||
626 | } | 795 | } | ||
796 | | ||||
627 | } | 797 | } | ||
628 | 798 | | |||
629 | ColumnLayout { | 799 | ColumnLayout { | ||
630 | id: mycroftSettingsColumn | 800 | id: mycroftSettingsColumn | ||
631 | anchors.top: rectangletopbar.bottom | 801 | visible: tabBar.currentTab == mycroftSettingsTab; | ||
632 | anchors.left: root.left | 802 | anchors.top: root.top | ||
803 | anchors.left: sidebar.right | ||||
804 | anchors.leftMargin: units.gridUnit * 0.25 | ||||
633 | anchors.right: root.right | 805 | anchors.right: root.right | ||
634 | anchors.bottom: rectanglebottombar.top | 806 | anchors.bottom: root.bottom | ||
635 | anchors.bottomMargin: 5 | | |||
636 | visible: false; | | |||
637 | 807 | | |||
638 | Rectangle { | 808 | Item { | ||
639 | id: settingscontent | 809 | id: settingscontent | ||
640 | Layout.fillWidth: true; | 810 | Layout.fillWidth: true; | ||
641 | Layout.fillHeight: true; | 811 | Layout.fillHeight: true; | ||
642 | anchors.fill: parent; | 812 | anchors.fill: parent; | ||
643 | color: theme.backgroundColor | 813 | //color: theme.backgroundColor | ||
644 | | ||||
645 | 814 | | |||
646 | PlasmaComponents.Label { | 815 | Flickable { | ||
647 | id: settingsTabTopLabel | 816 | id: settingFlick | ||
648 | anchors.top: parent.top; | 817 | anchors.fill: parent; | ||
649 | anchors.topMargin: 5; | 818 | contentWidth: mycroftSettingsColumn.width | ||
650 | text: "<b>Plasmoid Settings</b>" | 819 | contentHeight: units.gridUnit * 22 | ||
651 | } | 820 | clip: true; | ||
652 | 821 | | |||
653 | PlasmaComponents.Label { | 822 | PlasmaComponents.Label { | ||
654 | id: settingsTabUnits | 823 | id: settingsTabUnits | ||
655 | anchors.top: settingsTabTopLabel.bottom | 824 | anchors.top: parent.top; | ||
656 | anchors.topMargin: 5 | 825 | anchors.topMargin: 5 | ||
657 | text: "<i>Your Mycroft Core Installation Path</i>" | 826 | text: i18n("<i>Your Mycroft Core Installation Path</i>") | ||
658 | } | 827 | } | ||
659 | 828 | | |||
660 | PlasmaComponents.ButtonColumn { | 829 | PlasmaComponents.ButtonColumn { | ||
661 | id: radiobuttonColoumn | 830 | id: radiobuttonColoumn | ||
662 | anchors.top: settingsTabUnits.bottom | 831 | anchors.top: settingsTabUnits.bottom | ||
663 | anchors.topMargin: 5 | 832 | anchors.topMargin: 5 | ||
664 | 833 | | |||
665 | PlasmaComponents.RadioButton { | 834 | PlasmaComponents.RadioButton { | ||
666 | id: settingsTabUnitsOpZero | 835 | id: settingsTabUnitsOpZero | ||
667 | exclusiveGroup: installPathGroup | 836 | exclusiveGroup: installPathGroup | ||
668 | text: "Default Path" | 837 | text: i18n("Default Path") | ||
669 | checked: true | 838 | checked: true | ||
670 | 839 | | |||
671 | onCheckedChanged: { | 840 | onCheckedChanged: { | ||
672 | 841 | | |||
673 | if (settingsTabUnitsOpZero.checked === true && coreinstallstartpath === packagemcorestartcmd) { | 842 | if (settingsTabUnitsOpZero.checked === true && coreinstallstartpath === packagemcorestartcmd) { | ||
674 | coreinstallstartpath = defaultmcorestartpath; | 843 | coreinstallstartpath = defaultmcorestartpath; | ||
675 | } | 844 | } | ||
676 | else if (settingsTabUnitsOpZero.checked === true && coreinstallstartpath === customlocstartpath) { | 845 | else if (settingsTabUnitsOpZero.checked === true && coreinstallstartpath === customlocstartpath) { | ||
677 | coreinstallstartpath = defaultmcorestartpath; | 846 | coreinstallstartpath = defaultmcorestartpath; | ||
678 | } | 847 | } | ||
679 | 848 | | |||
680 | if (settingsTabUnitsOpZero.checked === true && coreinstallstoppath === packagemcorestopcmd) { | 849 | if (settingsTabUnitsOpZero.checked === true && coreinstallstoppath === packagemcorestopcmd) { | ||
681 | coreinstallstoppath = defaultmcorestoppath; | 850 | coreinstallstoppath = defaultmcorestoppath; | ||
682 | } | 851 | } | ||
683 | 852 | | |||
684 | else if (settingsTabUnitsOpZero.checked === true && coreinstallstoppath === customlocstoppath) { | 853 | else if (settingsTabUnitsOpZero.checked === true && coreinstallstoppath === customlocstoppath) { | ||
685 | coreinstallstoppath = defaultmcorestoppath; | 854 | coreinstallstoppath = defaultmcorestoppath; | ||
686 | } | 855 | } | ||
687 | } | 856 | } | ||
688 | } | 857 | } | ||
689 | 858 | | |||
690 | PlasmaComponents.RadioButton { | 859 | PlasmaComponents.RadioButton { | ||
691 | id: settingsTabUnitsOpOne | 860 | id: settingsTabUnitsOpOne | ||
692 | exclusiveGroup: installPathGroup | 861 | exclusiveGroup: installPathGroup | ||
693 | text: "Installed Using Mycroft Package" | 862 | text: i18n("Installed Using Mycroft Package") | ||
694 | checked: false | 863 | checked: false | ||
695 | 864 | | |||
696 | onCheckedChanged: { | 865 | onCheckedChanged: { | ||
697 | 866 | | |||
698 | if (settingsTabUnitsOpOne.checked === true && coreinstallstartpath === defaultmcorestartpath) { | 867 | if (settingsTabUnitsOpOne.checked === true && coreinstallstartpath === defaultmcorestartpath) { | ||
699 | coreinstallstartpath = packagemcorestartcmd; | 868 | coreinstallstartpath = packagemcorestartcmd; | ||
700 | } | 869 | } | ||
701 | else if (settingsTabUnitsOpOne.checked === true && coreinstallstartpath === customlocstartpath) { | 870 | else if (settingsTabUnitsOpOne.checked === true && coreinstallstartpath === customlocstartpath) { | ||
702 | coreinstallstartpath = packagemcorestartcmd; | 871 | coreinstallstartpath = packagemcorestartcmd; | ||
703 | } | 872 | } | ||
704 | 873 | | |||
705 | if (settingsTabUnitsOpOne.checked === true && coreinstallstoppath === defaultmcorestoppath) { | 874 | if (settingsTabUnitsOpOne.checked === true && coreinstallstoppath === defaultmcorestoppath) { | ||
706 | coreinstallstoppath = packagemcorestopcmd; | 875 | coreinstallstoppath = packagemcorestopcmd; | ||
707 | } | 876 | } | ||
708 | 877 | | |||
709 | else if (settingsTabUnitsOpOne.checked === true && coreinstallstoppath === customlocstoppath) { | 878 | else if (settingsTabUnitsOpOne.checked === true && coreinstallstoppath === customlocstoppath) { | ||
710 | coreinstallstoppath = packagemcorestopcmd; | 879 | coreinstallstoppath = packagemcorestopcmd; | ||
711 | } | 880 | } | ||
712 | } | 881 | } | ||
713 | } | 882 | } | ||
714 | 883 | | |||
715 | PlasmaComponents.RadioButton { | 884 | PlasmaComponents.RadioButton { | ||
716 | id: settingsTabUnitsOpTwo | 885 | id: settingsTabUnitsOpTwo | ||
717 | exclusiveGroup: installPathGroup | 886 | exclusiveGroup: installPathGroup | ||
718 | text: "Manual Install Path of Mycroft.sh" | 887 | text: i18n("Manual Install Path of Mycroft.sh") | ||
719 | checked: false | 888 | checked: false | ||
720 | 889 | | |||
721 | onCheckedChanged: { | 890 | onCheckedChanged: { | ||
722 | 891 | | |||
723 | if (settingsTabUnitsOpTwo.checked === true && coreinstallstartpath === defaultmcorestartpath) { | 892 | if (settingsTabUnitsOpTwo.checked === true && coreinstallstartpath === defaultmcorestartpath) { | ||
724 | coreinstallstartpath = customlocstartpath; | 893 | coreinstallstartpath = customlocstartpath; | ||
725 | } | 894 | } | ||
726 | else if (settingsTabUnitsOpTwo.checked === true && coreinstallstartpath === packagemcorestartcmd) { | 895 | else if (settingsTabUnitsOpTwo.checked === true && coreinstallstartpath === packagemcorestartcmd) { | ||
Show All 39 Lines | 933 | onClicked: { | |||
766 | var ctstart = cstlocl + " " + "start" | 935 | var ctstart = cstlocl + " " + "start" | ||
767 | var ctstop = cstlocl + " " + "stop" | 936 | var ctstop = cstlocl + " " + "stop" | ||
768 | startsrvcustom.text = ctstart | 937 | startsrvcustom.text = ctstart | ||
769 | stopsrvcustom.text = ctstop | 938 | stopsrvcustom.text = ctstop | ||
770 | console.log(startsrvcustom.text) | 939 | console.log(startsrvcustom.text) | ||
771 | } | 940 | } | ||
772 | } | 941 | } | ||
773 | 942 | | |||
943 | PlasmaComponents.TextField { | ||||
944 | id: settingsTabUnitsWSpath | ||||
945 | width: settingscontent.width / 1.1 | ||||
946 | anchors.top: settingsTabUnitsOpThree.bottom | ||||
947 | anchors.topMargin: 10 | ||||
948 | placeholderText: i18n("ws://0.0.0.0:8181/core") | ||||
949 | text: i18n("ws://0.0.0.0:8181/core") | ||||
950 | } | ||||
951 | | ||||
952 | PlasmaComponents.Button { | ||||
953 | id: acceptcustomWSPath | ||||
954 | anchors.left: settingsTabUnitsWSpath.right | ||||
955 | anchors.verticalCenter: settingsTabUnitsWSpath.verticalCenter | ||||
956 | anchors.right: parent.right | ||||
957 | iconSource: "checkbox" | ||||
958 | | ||||
959 | onClicked: { | ||||
960 | innerset.wsurl = settingsTabUnitsWSpath.text | ||||
961 | } | ||||
962 | } | ||||
963 | | ||||
964 | | ||||
965 | PlasmaComponents.TextField { | ||||
966 | id: settingsTabUnitsIRCmd | ||||
967 | width: settingscontent.width / 1.1 | ||||
968 | anchors.top: settingsTabUnitsWSpath.bottom | ||||
969 | anchors.topMargin: 10 | ||||
970 | placeholderText: i18n("Your Custom Image Recognition Skill Voc Keywords") | ||||
971 | text: i18n("search image url") | ||||
972 | } | ||||
973 | | ||||
974 | PlasmaComponents.Button { | ||||
975 | id: acceptcustomIRCmd | ||||
976 | anchors.left: settingsTabUnitsIRCmd.right | ||||
977 | anchors.verticalCenter: settingsTabUnitsIRCmd.verticalCenter | ||||
978 | anchors.right: parent.right | ||||
979 | iconSource: "checkbox" | ||||
980 | | ||||
981 | onClicked: { | ||||
982 | | ||||
983 | } | ||||
984 | } | ||||
985 | | ||||
986 | | ||||
774 | PlasmaComponents.Switch { | 987 | PlasmaComponents.Switch { | ||
775 | id: notificationswitch | 988 | id: notificationswitch | ||
776 | anchors.top: settingsTabUnitsOpThree.bottom | 989 | anchors.top: settingsTabUnitsIRCmd.bottom | ||
777 | anchors.topMargin: 5 | 990 | anchors.topMargin: 10 | ||
778 | text: "Enable Notifications" | 991 | text: i18n("Enable Notifications") | ||
779 | checked: true | 992 | checked: true | ||
780 | } | 993 | } | ||
781 | 994 | | |||
995 | | ||||
782 | PlasmaExtras.Paragraph { | 996 | PlasmaExtras.Paragraph { | ||
783 | id: settingsTabTF2 | 997 | id: settingsTabTF2 | ||
784 | anchors.top: notificationswitch.bottom | 998 | anchors.top: notificationswitch.bottom | ||
785 | anchors.topMargin: 5 | 999 | anchors.topMargin: 15 | ||
786 | text: "<i>Please Note: Default path is set to /home/$USER/mycroft-core/mycroft.sh. Change the above settings to match your installation</i>" | 1000 | text: i18n("<i>Please Note: Default path is set to /home/$USER/mycroft-core/mycroft.sh. Change the above settings to match your installation</i>") | ||
787 | } | 1001 | } | ||
788 | 1002 | | |||
789 | PlasmaComponents.Label { | 1003 | PlasmaComponents.Label { | ||
790 | id: startsrvcustom | 1004 | id: startsrvcustom | ||
791 | visible: false | 1005 | visible: false | ||
792 | } | 1006 | } | ||
793 | 1007 | | |||
794 | PlasmaComponents.Label { | 1008 | PlasmaComponents.Label { | ||
795 | id: stopsrvcustom | 1009 | id: stopsrvcustom | ||
796 | visible: false | 1010 | visible: false | ||
797 | } | 1011 | } | ||
798 | } | 1012 | } | ||
799 | } | 1013 | } | ||
800 | 1014 | | |||
1015 | } | ||||
801 | 1016 | | |||
802 | Rectangle { | 1017 | ColumnLayout { | ||
803 | id: rectanglebottombar | 1018 | id: mycroftMsmColumn | ||
804 | height: 30 | 1019 | visible: tabBar.currentTab == mycroftMSMinstTab; | ||
805 | color: theme.backgroundColor | 1020 | anchors.top: root.top | ||
806 | radius: 0 | 1021 | anchors.left: sidebar.right | ||
807 | anchors.bottom: root.bottom | 1022 | anchors.leftMargin: units.gridUnit * 0.25 | ||
808 | anchors.bottomMargin: 0 | | |||
809 | anchors.right: root.right | 1023 | anchors.right: root.right | ||
810 | anchors.rightMargin: 0 | 1024 | anchors.bottom: root.bottom | ||
811 | anchors.left: root.left | | |||
812 | anchors.leftMargin: 0 | | |||
813 | border.color: "#80000000" | | |||
814 | border.width: 0 | | |||
815 | z: 4 | | |||
816 | | ||||
817 | | ||||
818 | RowLayout { | | |||
819 | id: rla1 | | |||
820 | anchors.fill: parent | | |||
821 | Rectangle{ | | |||
822 | anchors.fill: parent | | |||
823 | color: "#00000000" | | |||
824 | z: 5 | | |||
825 | 1025 | | |||
1026 | Item { | ||||
1027 | id: msmtabtopbar | ||||
1028 | width: parent.width | ||||
1029 | anchors.left: parent.left | ||||
1030 | anchors.right: parent.right | ||||
1031 | height: units.gridUnit * 2 | ||||
826 | 1032 | | |||
827 | PlasmaComponents.TextField { | 1033 | PlasmaComponents.TextField { | ||
828 | 1034 | id: msmsearchfld | |||
829 | id: qinput | | |||
830 | anchors.left: parent.left | 1035 | anchors.left: parent.left | ||
831 | anchors.top: parent.top | 1036 | anchors.top: parent.top | ||
832 | anchors.bottom: parent.bottom | 1037 | anchors.bottom: parent.bottom | ||
833 | anchors.right: qinputmicbx.left | 1038 | anchors.right: getskillsbx.left | ||
834 | placeholderText: i18n("Enter Query or Say 'Hey Mycroft'") | 1039 | placeholderText: i18n("Search Skills") | ||
835 | clearButtonShown: true | 1040 | clearButtonShown: true | ||
836 | 1041 | | |||
837 | onAccepted: { | 1042 | onTextChanged: { | ||
838 | suggst.visible = true; | 1043 | if(text.length > 0 ) { | ||
839 | conversationInputList.append({"InputQuery": qinput.text}); | 1044 | msmskillsModel.applyFilter(text.toLowerCase()); | ||
840 | inputlistView.positionViewAtEnd(); | 1045 | } else { | ||
841 | 1046 | msmskillsModel.reload(); | |||
842 | var socketmessage = {}; | | |||
843 | socketmessage.type = "recognizer_loop:utterance"; | | |||
844 | socketmessage.data = {}; | | |||
845 | socketmessage.data.utterances = [qinput.text]; | | |||
846 | socket.sendTextMessage(JSON.stringify(socketmessage)); | | |||
847 | qinput.text = ""; | | |||
848 | if (socket.status == WebSocket.Error) { | | |||
849 | barAnim.wsocerroranimtoggle() | | |||
850 | } | 1047 | } | ||
851 | else { | | |||
852 | barAnim.wsocmsganimtoggle(); | | |||
853 | } | 1048 | } | ||
854 | } | 1049 | } | ||
855 | 1050 | | |||
856 | onTextChanged: { | 1051 | PlasmaComponents.ToolButton { | ||
857 | var terms = getTermsForSearchString(qinput.text); | 1052 | id: getskillsbx | ||
858 | var suggestionsActive = (terms.length > 0); | 1053 | anchors.right: parent.right | ||
1054 | anchors.top: parent.top | ||||
1055 | anchors.bottom: parent.bottom | ||||
1056 | iconSource: "view-refresh" | ||||
1057 | tooltip: i18n("Refresh List") | ||||
1058 | flat: true | ||||
1059 | width: Math.round(units.gridUnit * 2) | ||||
1060 | height: width | ||||
1061 | z: 102 | ||||
859 | 1062 | | |||
860 | if (suggestionsActive) { | 1063 | onClicked: { | ||
861 | setTerms(terms); | 1064 | msmskillsModel.clear(); | ||
1065 | refreshAllSkills(); | ||||
862 | } | 1066 | } | ||
863 | else{ | | |||
864 | setSuggestionsRandom(); | | |||
865 | } | 1067 | } | ||
866 | } | 1068 | } | ||
1069 | | ||||
1070 | ListModel { | ||||
1071 | id: msmskillsModel | ||||
1072 | | ||||
1073 | Component.onCompleted: { | ||||
1074 | reload(); | ||||
1075 | console.log('Completing too early?'); | ||||
867 | } | 1076 | } | ||
868 | PlasmaComponents.ToolButton { | | |||
869 | id: qinputmicbx | | |||
870 | anchors.right: parent.right | | |||
871 | anchors.verticalCenter: parent.verticalCenter | | |||
872 | iconSource: "mic-on" | | |||
873 | flat: true | | |||
874 | width: 42 | | |||
875 | height: 42 | | |||
876 | 1077 | | |||
877 | onClicked: { | 1078 | function reload() { | ||
878 | if (qinputmicbx.iconSource == "mic-on") { | 1079 | var skList = getAllSkills(); | ||
879 | qinputmicbx.iconSource = "mic-off" | 1080 | msmskillsModel.clear(); | ||
1081 | for( var i=0; i < skList.length ; ++i ) { | ||||
1082 | msmskillsModel.append(skList[i]); | ||||
880 | } | 1083 | } | ||
881 | else if (qinputmicbx.iconSource == "mic-off") { | | |||
882 | qinputmicbx.iconSource = "mic-on" | | |||
883 | } | 1084 | } | ||
884 | muteMicrophone() | 1085 | | ||
1086 | function applyFilter(skName) { | ||||
1087 | var skList = getSkillByName(skName); | ||||
1088 | msmskillsModel.clear(); | ||||
1089 | for( var i=0; i < skList.length ; ++i ) { | ||||
1090 | msmskillsModel.append(skList[i]); | ||||
885 | } | 1091 | } | ||
886 | } | 1092 | } | ||
887 | } | 1093 | } | ||
888 | 1094 | | |||
1095 | ListView { | ||||
1096 | id: msmlistView | ||||
1097 | anchors.top: msmtabtopbar.bottom | ||||
1098 | anchors.topMargin: 5 | ||||
1099 | anchors.left: parent.left | ||||
1100 | anchors.right: parent.right | ||||
1101 | anchors.bottom: parent.bottom | ||||
1102 | model: msmskillsModel | ||||
1103 | delegate: MsmView{} | ||||
1104 | spacing: 4 | ||||
1105 | focus: false | ||||
1106 | interactive: true | ||||
1107 | clip: true; | ||||
1108 | | ||||
889 | } | 1109 | } | ||
890 | } | 1110 | } | ||
891 | } | 1111 | } | ||
892 | 1112 | | |||
893 | SourceModel { | 1113 | SourceModel { | ||
894 | id: sourceModel | 1114 | id: sourceModel | ||
895 | } | 1115 | } | ||
1116 | | ||||
1117 | PlasmaCore.SvgItem { | ||||
1118 | anchors { | ||||
1119 | left: main.left | ||||
1120 | right: main.right | ||||
1121 | bottom: root.bottom | ||||
1122 | } | ||||
1123 | width: 1 | ||||
1124 | height: horlineSvg.elementSize("horizontal-line").height | ||||
1125 | | ||||
1126 | elementId: "horizontal-line" | ||||
1127 | z: 110 | ||||
1128 | svg: PlasmaCore.Svg { | ||||
1129 | id: horlineSvg; | ||||
1130 | imagePath: "widgets/line" | ||||
1131 | } | ||||
1132 | } | ||||
1133 | | ||||
1134 | | ||||
1135 | Item { | ||||
1136 | id: rectanglebottombar | ||||
1137 | height: units.gridUnit * 3.5 | ||||
1138 | anchors.left: main.left | ||||
1139 | anchors.right: main.right | ||||
1140 | anchors.bottom: main.bottom | ||||
1141 | z: 110 | ||||
1142 | | ||||
1143 | Rectangle { | ||||
1144 | id: suggestionbottombox | ||||
1145 | anchors.top: parent.top | ||||
1146 | anchors.bottom: qinput.top | ||||
1147 | anchors.right: parent.right | ||||
1148 | anchors.left: parent.left | ||||
1149 | color: theme.backgroundColor | ||||
1150 | //height: 40; | ||||
1151 | | ||||
1152 | Suggestions { | ||||
1153 | id: suggst | ||||
1154 | visible: true; | ||||
1155 | } | ||||
1156 | | ||||
1157 | } | ||||
1158 | | ||||
1159 | | ||||
1160 | PlasmaComponents.TextField { | ||||
1161 | id: qinput | ||||
1162 | anchors.left: parent.left | ||||
1163 | //anchors.top: parent.top | ||||
1164 | anchors.bottom: parent.bottom | ||||
1165 | anchors.right: parent.right | ||||
1166 | placeholderText: i18n("Enter Query or Say 'Hey Mycroft'") | ||||
1167 | clearButtonShown: true | ||||
1168 | | ||||
1169 | onAccepted: { | ||||
1170 | suggst.visible = true; | ||||
1171 | //conversationInputList.append({"InputQuery": qinput.text}); | ||||
1172 | //inputlistView.positionViewAtEnd(); | ||||
1173 | | ||||
1174 | var socketmessage = {}; | ||||
1175 | socketmessage.type = "recognizer_loop:utterance"; | ||||
1176 | socketmessage.data = {}; | ||||
1177 | socketmessage.data.utterances = [qinput.text]; | ||||
1178 | socket.sendTextMessage(JSON.stringify(socketmessage)); | ||||
1179 | qinput.text = ""; | ||||
1180 | } | ||||
1181 | | ||||
1182 | onTextChanged: { | ||||
1183 | var terms = getTermsForSearchString(qinput.text); | ||||
1184 | } | ||||
1185 | } | ||||
1186 | } | ||||
1187 | | ||||
896 | Settings { | 1188 | Settings { | ||
1189 | id: innerset | ||||
1190 | property alias wsurl: settingsTabUnitsWSpath.text | ||||
1191 | property alias customrecog: settingsTabUnitsIRCmd.text | ||||
897 | property alias customsetuppath: settingsTabUnitsOpThree.text | 1192 | property alias customsetuppath: settingsTabUnitsOpThree.text | ||
898 | property alias notifybool: notificationswitch.checked | 1193 | property alias notifybool: notificationswitch.checked | ||
899 | property alias radiobt1: settingsTabUnitsOpOne.checked | 1194 | property alias radiobt1: settingsTabUnitsOpOne.checked | ||
900 | property alias radiobt2: settingsTabUnitsOpTwo.checked | 1195 | property alias radiobt2: settingsTabUnitsOpTwo.checked | ||
901 | property alias radiobt3: settingsTabUnitsOpZero.checked | 1196 | property alias radiobt3: settingsTabUnitsOpZero.checked | ||
902 | } | 1197 | } | ||
1198 | | ||||
903 | } | 1199 | } |