Changeset View
Changeset View
Standalone View
Standalone View
plasmoid/contents/ui/Suggestions.qml
1 | import QtQuick 2.0 | 1 | import QtQuick 2.0 | ||
---|---|---|---|---|---|
2 | import QtQuick.Controls 2.0 | 2 | import QtQuick.Controls 2.0 | ||
3 | import org.kde.plasma.components 2.0 as PlasmaComponents | 3 | import org.kde.plasma.components 2.0 as PlasmaComponents | ||
4 | 4 | | |||
5 | Item { | 5 | Rectangle { | ||
6 | id: suggestionsmainitem | 6 | id: suggestionsmainitem | ||
7 | color: "#00000000" | ||||
8 | anchors.fill: parent | ||||
7 | property alias suggest1: suggestiontext1.text | 9 | property alias suggest1: suggestiontext1.text | ||
8 | property alias suggest2: suggestiontext2.text | 10 | property alias suggest2: suggestiontext2.text | ||
9 | property alias suggest3: suggestiontext3.text | 11 | property alias suggest3: suggestiontext3.text | ||
10 | 12 | | |||
11 | Flickable { | | |||
12 | width: parent.width | | |||
13 | height: parent.height | | |||
14 | contentWidth: units.gridUnit * 5 | | |||
15 | contentHeight: parent.height | | |||
16 | interactive: true; | | |||
17 | | ||||
18 | Rectangle { | 13 | Rectangle { | ||
19 | id: suggestionbutton1 | 14 | id: suggestionbutton1 | ||
20 | width: suggestiontext1.contentWidth + 10 | | |||
21 | height: 30 | | |||
22 | color: "#00000000" | 15 | color: "#00000000" | ||
23 | radius: 5 | 16 | anchors.top: parent.top | ||
24 | border.width: 1 | 17 | anchors.topMargin: 0 | ||
25 | border.color: "#ffffff" | 18 | anchors.bottom: parent.bottom | ||
19 | anchors.bottomMargin: 0 | ||||
20 | border.width: 0.2 | ||||
21 | border.color: theme.textColor | ||||
26 | anchors.left: parent.left | 22 | anchors.left: parent.left | ||
27 | anchors.leftMargin: 0 | 23 | anchors.leftMargin: 0 | ||
24 | width: suggestionsmainitem.width / 3 | ||||
28 | 25 | | |||
29 | MouseArea { | 26 | MouseArea { | ||
30 | id: mouseArea1 | 27 | id: mouseArea1 | ||
31 | anchors.fill: parent | 28 | anchors.fill: parent | ||
32 | hoverEnabled: true | 29 | hoverEnabled: true | ||
33 | 30 | | |||
34 | onEntered: { | 31 | onEntered: { | ||
35 | suggestionbutton1.color = "#2b2b2b" | 32 | suggestionbutton1.color = theme.textColor | ||
36 | suggestionbutton1.border.color = "#f2f22f" | 33 | suggestiontext1.color = theme.backgroundColor | ||
37 | } | 34 | } | ||
38 | 35 | | |||
39 | onExited: { | 36 | onExited: { | ||
40 | suggestionbutton1.color = "#00000000" | 37 | suggestionbutton1.color = "#00000000" | ||
41 | suggestionbutton1.border.color = "grey" | 38 | suggestiontext1.color = theme.textColor | ||
42 | } | 39 | } | ||
43 | 40 | | |||
44 | onClicked: { | 41 | onClicked: { | ||
45 | suggst.visible = true | 42 | var suggest1 = qinput.text | ||
46 | conversationInputList.append({"InputQuery": suggestiontext1.text}); | 43 | var lastIndex = suggest1.lastIndexOf(" "); | ||
47 | inputlistView.positionViewAtEnd(); | 44 | qinput.text = suggest1.substring(0, lastIndex) + " " + suggestiontext1.text + " " | ||
48 | var socketmessage = {}; | | |||
49 | socketmessage.type = "recognizer_loop:utterance"; | | |||
50 | socketmessage.data = {}; | | |||
51 | socketmessage.data.utterances = [suggestiontext1.text]; | | |||
52 | socket.sendTextMessage(JSON.stringify(socketmessage)); | | |||
53 | qinput.text = suggestiontext1.text | | |||
54 | } | 45 | } | ||
55 | } | 46 | } | ||
56 | 47 | | |||
57 | PlasmaComponents.Label { | 48 | PlasmaComponents.Label { | ||
58 | id: suggestiontext1 | 49 | id: suggestiontext1 | ||
59 | text: qsTr("Text") | 50 | text: i18n("") | ||
60 | anchors.verticalCenter: parent.verticalCenter | | |||
61 | anchors.horizontalCenter: parent.horizontalCenter | 51 | anchors.horizontalCenter: parent.horizontalCenter | ||
52 | anchors.verticalCenter: parent.verticalCenter | ||||
62 | font.pixelSize: 12 | 53 | font.pixelSize: 12 | ||
63 | } | 54 | } | ||
64 | } | 55 | } | ||
65 | 56 | | |||
66 | Rectangle { | 57 | Rectangle { | ||
67 | id: suggestionbutton2 | 58 | id: suggestionbutton2 | ||
68 | width: suggestiontext2.contentWidth + 10 | | |||
69 | height: 30 | | |||
70 | color: "#00000000" | 59 | color: "#00000000" | ||
71 | radius: 5 | 60 | anchors.bottom: parent.bottom | ||
72 | border.color: "#ffffff" | 61 | anchors.bottomMargin: 0 | ||
62 | anchors.top: parent.top | ||||
63 | anchors.topMargin: 0 | ||||
64 | anchors.right: suggestionbutton3.left | ||||
65 | anchors.rightMargin: 0 | ||||
66 | border.width: 0.2 | ||||
73 | anchors.left: suggestionbutton1.right | 67 | anchors.left: suggestionbutton1.right | ||
74 | anchors.leftMargin: 20 | 68 | anchors.leftMargin: 0 | ||
69 | border.color: theme.textColor | ||||
75 | 70 | | |||
76 | MouseArea { | 71 | MouseArea { | ||
77 | id: mouseArea2 | 72 | id: mouseArea2 | ||
78 | height: 200 | | |||
79 | anchors.fill: parent | 73 | anchors.fill: parent | ||
80 | hoverEnabled: true | 74 | hoverEnabled: true | ||
81 | 75 | | |||
82 | onEntered: { | 76 | onEntered: { | ||
83 | suggestionbutton2.color = "#2b2b2b" | 77 | suggestionbutton2.color = theme.textColor | ||
84 | suggestionbutton2.border.color = "#f2f22f" | 78 | suggestiontext2.color = theme.backgroundColor | ||
85 | } | 79 | } | ||
86 | 80 | | |||
87 | onExited: { | 81 | onExited: { | ||
88 | suggestionbutton2.color = "#00000000" | 82 | suggestionbutton2.color = "#00000000" | ||
89 | suggestionbutton2.border.color = "grey" | 83 | suggestiontext2.color = theme.textColor | ||
90 | } | 84 | } | ||
91 | 85 | | |||
92 | onClicked: { | 86 | onClicked: { | ||
93 | suggst.visible = true | 87 | var suggest2 = qinput.text | ||
94 | conversationInputList.append({"InputQuery": suggestiontext2.text}); | 88 | var lastIndex = suggest2.lastIndexOf(" "); | ||
95 | inputlistView.positionViewAtEnd(); | 89 | qinput.text = suggest2.substring(0, lastIndex) + " " + suggestiontext2.text + " " | ||
96 | var socketmessage = {}; | | |||
97 | socketmessage.type = "recognizer_loop:utterance"; | | |||
98 | socketmessage.data = {}; | | |||
99 | socketmessage.data.utterances = [suggestiontext2.text]; | | |||
100 | socket.sendTextMessage(JSON.stringify(socketmessage)); | | |||
101 | qinput.text = suggestiontext1.text | | |||
102 | } | 90 | } | ||
103 | } | 91 | } | ||
104 | 92 | | |||
105 | PlasmaComponents.Label { | 93 | PlasmaComponents.Label { | ||
106 | id: suggestiontext2 | 94 | id: suggestiontext2 | ||
107 | text: qsTr("Text") | 95 | text: i18n("") | ||
108 | anchors.verticalCenter: parent.verticalCenter | 96 | anchors.verticalCenter: parent.verticalCenter | ||
109 | anchors.horizontalCenter: parent.horizontalCenter | 97 | anchors.horizontalCenter: parent.horizontalCenter | ||
110 | font.pixelSize: 12 | 98 | font.pixelSize: 12 | ||
111 | } | 99 | } | ||
112 | } | 100 | } | ||
113 | 101 | | |||
114 | Rectangle { | 102 | Rectangle { | ||
115 | id: suggestionbutton3 | 103 | id: suggestionbutton3 | ||
116 | width: suggestiontext3.contentWidth + 10 | | |||
117 | height: 30 | | |||
118 | color: "#00000000" | 104 | color: "#00000000" | ||
119 | radius: 5 | 105 | anchors.bottom: parent.bottom | ||
120 | border.color: "#ffffff" | 106 | anchors.bottomMargin: 0 | ||
121 | anchors.left: suggestionbutton2.right | 107 | anchors.top: parent.top | ||
122 | anchors.leftMargin: 20 | 108 | border.color: theme.textColor | ||
109 | anchors.topMargin: 0 | ||||
110 | anchors.right: parent.right | ||||
111 | anchors.rightMargin: 0 | ||||
112 | border.width: 0.2 | ||||
113 | width: parent.width / 3 | ||||
123 | 114 | | |||
124 | MouseArea { | 115 | MouseArea { | ||
125 | id: mouseArea3 | 116 | id: mouseArea3 | ||
126 | anchors.fill: parent | 117 | anchors.fill: parent | ||
127 | hoverEnabled: true | 118 | hoverEnabled: true | ||
128 | 119 | | |||
129 | onEntered: { | 120 | onEntered: { | ||
130 | suggestionbutton3.color = "#2b2b2b" | 121 | suggestionbutton3.color = theme.textColor | ||
131 | suggestionbutton3.border.color = "#f2f22f" | 122 | suggestiontext3.color = theme.backgroundColor | ||
132 | } | 123 | } | ||
133 | 124 | | |||
134 | onExited: { | 125 | onExited: { | ||
135 | suggestionbutton3.color = "#00000000" | 126 | suggestionbutton3.color = "#00000000" | ||
136 | suggestionbutton3.border.color = "grey" | 127 | suggestiontext3.color = theme.textColor | ||
137 | } | 128 | } | ||
138 | 129 | | |||
139 | onClicked: { | 130 | onClicked: { | ||
140 | suggst.visible = true | 131 | var suggest3 = qinput.text | ||
141 | conversationInputList.append({"InputQuery": suggestiontext3.text}); | 132 | var lastIndex = suggest3.lastIndexOf(" "); | ||
142 | inputlistView.positionViewAtEnd(); | 133 | qinput.text = suggest3.substring(0, lastIndex) + " " + suggestiontext3.text + " " | ||
143 | var socketmessage = {}; | | |||
144 | socketmessage.type = "recognizer_loop:utterance"; | | |||
145 | socketmessage.data = {}; | | |||
146 | socketmessage.data.utterances = [suggestiontext3.text]; | | |||
147 | socket.sendTextMessage(JSON.stringify(socketmessage)); | | |||
148 | qinput.text = suggestiontext1.text | | |||
149 | } | 134 | } | ||
150 | } | 135 | } | ||
151 | 136 | | |||
152 | PlasmaComponents.Label { | 137 | PlasmaComponents.Label { | ||
153 | id: suggestiontext3 | 138 | id: suggestiontext3 | ||
154 | text: qsTr("Text") | 139 | text: i18n("") | ||
155 | anchors.verticalCenter: parent.verticalCenter | 140 | anchors.verticalCenter: parent.verticalCenter | ||
156 | anchors.horizontalCenter: parent.horizontalCenter | 141 | anchors.horizontalCenter: parent.horizontalCenter | ||
157 | font.pixelSize: 12 | 142 | font.pixelSize: 12 | ||
158 | } | 143 | } | ||
159 | } | 144 | } | ||
160 | } | 145 | } | ||
161 | } | |