54 property Item background
60 property int currentIndex: -1
66 property string currentText
73 property alias model: gridview.model
86 readonly
property bool isModelArray: model.constructor === Array
95 onCurrentIndexChanged: {
96 currentText = isModelArray ? model[currentIndex].text : (model && model.get(currentIndex) ? model.get(currentIndex).text :
"")
104 width: button.width+labelText.width+10
110 implicitWidth: Math.max(200, currentTextBox.width+radius)
113 border.color:
"black"
116 GradientStop { position: 0 ; color: mouseArea.pressed ?
"#87ff5c" :
"#ffe85c" }
117 GradientStop { position: 1 ; color: mouseArea.pressed ?
"#44ff00" :
"#f8d600" }
122 anchors.horizontalCenter: parent.horizontalCenter
123 anchors.verticalCenter: parent.verticalCenter
140 wrapMode: Text.WordWrap
152 height: parent.height
160 Keys.onPressed: background.currentActivity.Keys.onPressed(event)
162 Keys.onRightPressed: gridview.moveCurrentIndexRight();
163 Keys.onLeftPressed: gridview.moveCurrentIndexLeft();
164 Keys.onDownPressed: gridview.moveCurrentIndexDown();
165 Keys.onUpPressed: gridview.moveCurrentIndexUp();
167 Keys.onEscapePressed: {
170 hidePopUpAndRestoreFocus();
172 Keys.onEnterPressed: {
174 hidePopUpAndRestoreFocus();
176 Keys.onReturnPressed: {
178 hidePopUpAndRestoreFocus();
181 Keys.onSpacePressed: {
183 hidePopUpAndRestoreFocus();
187 function discardChange() {
189 for(var i = 0 ; i < model.count ; ++ i) {
190 if(model[currentIndex].text === currentText) {
197 for(var i = 0 ; i < model.length ; ++ i) {
198 if(model.get(currentIndex).text === currentText) {
204 gridview.currentIndex = currentIndex;
208 function acceptChange() {
209 currentIndex = gridview.currentIndex;
210 currentText = isModelArray ? model[currentIndex].text : (model && model.get(currentIndex) ? model.get(currentIndex).text :
"")
213 function hidePopUpAndRestoreFocus() {
214 popup.visible =
false;
216 background.currentActivity.forceActiveFocus();
226 id : headerDescription
228 width: gridview.width
229 height: gridview.elementHeight
233 wrapMode: Text.WordWrap
234 anchors.horizontalCenter: parent.horizontalCenter
238 anchors.right: headerDescription.right
239 anchors.top: headerDescription.top
244 popup.acceptChange();
245 popup.hidePopUpAndRestoreFocus();
258 readonly
property int numberOfColumns: Math.max(1, Math.floor(width / 300))
259 contentHeight: isModelArray ? elementHeight*model.count/numberOfColumns : elementHeight*model.length/numberOfColumns
260 width: listBackground.width
261 height: listBackground.height-headerDescription.height
262 currentIndex: gccombobox.currentIndex
263 flickableDirection: Flickable.VerticalFlick
265 anchors.top: headerDescription.bottom
266 anchors.topMargin: headerDescription.height / 2
267 cellWidth: width / numberOfColumns
268 cellHeight: elementHeight
270 delegate: Component {
272 width: gridview.cellWidth
273 height: gridview.elementHeight
274 color: GridView.isCurrentItem ?
"darkcyan" :
"beige"
275 border.width: GridView.isCurrentItem ? 3 : 2
279 visible: parent.GridView.isCurrentItem
280 source:
"qrc:/gcompris/src/core/resource/apply.svg"
281 anchors.right: textValue.left
282 anchors.top: parent.top
283 anchors.rightMargin: 10
288 text: isModelArray ? modelData.text : model.text
289 anchors.centerIn: parent
295 popup.acceptChange();
296 popup.hidePopUpAndRestoreFocus();
A QML component unifying text presentation in GCompris.
A general purpose singleton that exposes miscellaneous native functions to the QML layer...
qreal ratio
Ratio factor used for scaling of sizes on high-dpi devices.