~mterry/ubuntu-calculator-app/confined

« back to all changes in this revision

Viewing changes to app/ubuntu-calculator-app.qml

  • Committer: Tarmac
  • Author(s): Giulio Collura, Giulio Collura
  • Date: 2015-01-03 15:37:06 UTC
  • mfrom: (45.2.8 reboot-scrollable-view)
  • Revision ID: tarmac-20150103153706-c3kk14iqzo55hnnz
Fix CMakeLists when building click packages. ScrollableView to manage history, textentry and keyboard.

Approved by Ubuntu Phone Apps Jenkins Bot, Riccardo Padovani.

Show diffs side-by-side

added added

removed removed

Lines of Context:
172
172
        keyboardLoader.item.pressedKeyText = "";
173
173
    }
174
174
 
175
 
    VisualItemModel {
176
 
        id: calculatorVisualModel
177
 
 
178
 
        Loader {
179
 
            id: keyboardLoader
180
 
            width: parent.width
181
 
            source: mainListView.width > mainListView.height ? "ui/LandscapeKeyboard.qml" : "ui/PortraiKeyboard.qml"
182
 
        }
183
 
 
184
 
        TextField {
185
 
            id: textInputField
186
 
            objectName: "textInputField"
187
 
            width: contentWidth + units.gu(3)
188
 
            // TODO: Make sure this bug gets fixed in SDK:
189
 
            // https://bugs.launchpad.net/ubuntu/+source/ubuntu-ui-toolkit/+bug/1320885
190
 
            //width: parent.width
191
 
            height: units.gu(6)
192
 
 
193
 
            // remove ubuntu shape
194
 
            style: TextFieldStyle {
195
 
                background: Item {
196
 
                }
197
 
            }
198
 
 
199
 
            text: displayedInputText
200
 
            font.pixelSize: height * 0.7
201
 
            //horizontalAlignment: TextInput.AlignRight
202
 
            anchors.right: parent.right
203
 
            anchors.rightMargin: units.gu(1)
204
 
            readOnly: true
205
 
            selectByMouse: true
206
 
            cursorVisible: true
207
 
            onCursorPositionChanged: if (cursorPosition !== displayedInputText.length ) {
208
 
                var preservedCursorPosition = cursorPosition;
209
 
                displayedInputText = Formula.returnFormulaToDisplay(longFormula);
210
 
                cursorPosition = preservedCursorPosition;
211
 
            } else {
212
 
                displayedInputText = Formula.returnFormulaToDisplay(shortFormula);
213
 
            }
214
 
        }
215
 
 
216
 
        ListView {
 
175
    ScrollableView {
 
176
        anchors.fill: parent
 
177
        id: scrollableView
 
178
        objectName: "scrollableView"
 
179
 
 
180
        Repeater {
217
181
            id: formulaView
218
 
            objectName: "formulaView"
219
 
            width: parent.width
220
 
            height: contentHeight
221
182
            model: calculationHistory.getContents()
222
 
            interactive: false
223
 
 
224
183
            property var _currentSwipedItem: null
225
184
 
226
 
            delegate: Screen {
 
185
            Screen {
227
186
                id: screenDelegate
228
187
                width: parent.width
229
188
 
299
258
                        }
300
259
                        formulaView._currentSwipedItem = item
301
260
                    } else if (item.swipeState !== "Normal"
302
 
                        && formulaView._currentSwipedItem === item) {
 
261
                    && formulaView._currentSwipedItem === item) {
303
262
                        formulaView._currentSwipedItem = null
304
263
                    }
305
264
                }
306
265
            }
307
266
        }
308
 
    }
309
 
 
310
 
    ListView {
311
 
        id: mainListView
312
 
        anchors.fill: parent
313
 
        model: calculatorVisualModel
314
 
        verticalLayoutDirection: ListView.BottomToTop
315
 
        snapMode: ListView.SnapToItem
 
267
 
 
268
        TextField {
 
269
            id: textInputField
 
270
            objectName: "textInputField"
 
271
            width: contentWidth + units.gu(3)
 
272
            // TODO: Make sure this bug gets fixed in SDK:
 
273
            // https://bugs.launchpad.net/ubuntu/+source/ubuntu-ui-toolkit/+bug/1320885
 
274
            //width: parent.width
 
275
            height: units.gu(6)
 
276
 
 
277
            // remove ubuntu shape
 
278
            style: TextFieldStyle {
 
279
                background: Item {
 
280
                }
 
281
            }
 
282
 
 
283
            text: displayedInputText
 
284
            font.pixelSize: height * 0.7
 
285
            //horizontalAlignment: TextInput.AlignRight
 
286
            anchors {
 
287
                right: parent.right
 
288
                rightMargin: units.gu(1)
 
289
            }
 
290
 
 
291
            readOnly: true
 
292
            selectByMouse: true
 
293
            cursorVisible: true
 
294
            onCursorPositionChanged: if (cursorPosition !== displayedInputText.length ) {
 
295
                var preservedCursorPosition = cursorPosition;
 
296
                displayedInputText = Formula.returnFormulaToDisplay(longFormula);
 
297
                cursorPosition = preservedCursorPosition;
 
298
            } else {
 
299
                displayedInputText = Formula.returnFormulaToDisplay(shortFormula);
 
300
            }
 
301
        }
 
302
 
 
303
        Loader {
 
304
            id: keyboardLoader
 
305
            width: parent.width
 
306
            source: mainView.width > mainView.height ? "ui/LandscapeKeyboard.qml" : "ui/PortraiKeyboard.qml"
 
307
        }
 
308
 
316
309
    }
317
310
}
318
311