Sina Bakhtiari has proposed merging lp:~sinabakh/ubuntu-calculator-app/history-using-arrow-keys into lp:ubuntu-calculator-app.
Requested reviews: Ubuntu Calculator Developers (ubuntu-calculator-dev) Related bugs: Bug #1466627 in Ubuntu Calculator App: "Allow navigating the history using the arrow keys" https://bugs.launchpad.net/ubuntu-calculator-app/+bug/1466627 For more details, see: https://code.launchpad.net/~sinabakh/ubuntu-calculator-app/history-using-arrow-keys/+merge/301567 -- Your team Ubuntu Calculator Developers is requested to review the proposed merge of lp:~sinabakh/ubuntu-calculator-app/history-using-arrow-keys into lp:ubuntu-calculator-app.
=== modified file 'app/ubuntu-calculator-app.qml' --- app/ubuntu-calculator-app.qml 2016-01-18 23:40:25 +0000 +++ app/ubuntu-calculator-app.qml 2016-07-30 11:41:19 +0000 @@ -64,6 +64,9 @@ // Var used to save favourite calcs property bool isFavourite: false + // Var used to store calculation history position + property var historyPosition: calculationHistory.getContents().count; + // Var used to store currently edited calculation history item property int editedCalculationIndex: -1 @@ -312,7 +315,7 @@ // Some special keys like backspace captured in TextField, // are for some reason not sent to the application but to the text input - Keys.onPressed: textInputField.keyPress(event) + Keys.onPressed: {event.accepted = true; textInputField.keyPress(event)} Keys.onReleased: textInputField.keyRelease(event) head.visible: false @@ -618,6 +621,19 @@ function keyPress(event) { if (!(event.modifiers & Qt.ControlModifier || event.modifiers & Qt.AltModifier)) { // Shift needs to be passed through as it may be required for some special keys + if((event.key === Qt.Key_Up || event.key === Qt.Key_Down) && event.accepted) { + if(event.key === Qt.Key_Up && historyPosition > 1) + historyPosition--; + if(event.key === Qt.Key_Down && historyPosition < calculationHistory.getContents().count) + historyPosition++; + if(historyPosition !== calculationHistory.getContents().count) { + clearFormula(); + formulaPush(calculationHistory.getContents().get(historyPosition).formula); + } + else + clearFormula(); + } + keyboardLoader.item.pressedKey = event.key; keyboardLoader.item.pressedKeyText = event.text; } else if (event.modifiers & Qt.ControlModifier) { === modified file 'app/ui/KeyboardPage.qml' --- app/ui/KeyboardPage.qml 2015-11-09 14:18:18 +0000 +++ app/ui/KeyboardPage.qml 2016-07-30 11:41:19 +0000 @@ -154,6 +154,7 @@ break; case "calculate": calculate(); + historyPosition = calculationHistory.getContents().count; scrollableView.scrollToBottom(); break; }
-- Mailing list: https://launchpad.net/~ubuntu-touch-coreapps-reviewers Post to : ubuntu-touch-coreapps-reviewers@lists.launchpad.net Unsubscribe : https://launchpad.net/~ubuntu-touch-coreapps-reviewers More help : https://help.launchpad.net/ListHelp