Merge lp:~sinabakh/ubuntu-calculator-app/history-using-arrow-keys into lp:ubuntu-calculator-app

Proposed by Sina Bakhtiari
Status: Merged
Approved by: Bartosz Kosiorek
Approved revision: 305
Merged at revision: 316
Proposed branch: lp:~sinabakh/ubuntu-calculator-app/history-using-arrow-keys
Merge into: lp:ubuntu-calculator-app
Diff against target: 78 lines (+35/-1)
2 files modified
app/ubuntu-calculator-app.qml (+34/-1)
app/ui/KeyboardPage.qml (+1/-0)
To merge this branch: bzr merge lp:~sinabakh/ubuntu-calculator-app/history-using-arrow-keys
Reviewer Review Type Date Requested Status
Jenkins Bot continuous-integration Approve
Bartosz Kosiorek Approve
Review via email: mp+301567@code.launchpad.net

Commit message

Allow navigating the history using the arrow keys

To post a comment you must log in.
Revision history for this message
Bartosz Kosiorek (gang65) wrote :

Thanks. Nice improvement.

Unfortunately it is causing lost of last typed formula.
Steps to reproduce:
1. Create several entries in calculation history
2. Type some formula: 25*25
2. Press up key (the previous calculation will appear)
3. Press down key

Currently:
- Empty formula is shown

Expected:
- 25*25 should be shown

review: Needs Fixing
Revision history for this message
Bartosz Kosiorek (gang65) wrote :

It will be also great to show some indicator what is currently selected formula.
It could be in form of background color.

Also I would expect that if any other than "up" and "down" key were pressed, then the formula selection were reset (it is starting from bottom).

review: Needs Fixing
Revision history for this message
Sina Bakhtiari (sinabakh) wrote :

> Thanks. Nice improvement.
>
> Unfortunately it is causing lost of last typed formula.
> Steps to reproduce:
> 1. Create several entries in calculation history
> 2. Type some formula: 25*25
> 2. Press up key (the previous calculation will appear)
> 3. Press down key
>
> Currently:
> - Empty formula is shown
>
> Expected:
> - 25*25 should be shown

Yes, currently it just uses the history of calculated formulas not the one which is being written. I will try to fix it.
Thanks for pointing it out.

Revision history for this message
Sina Bakhtiari (sinabakh) wrote :

The first problem that you mentioned is fixed.
Regarding the 2 next points you made:

> Also I would expect that if any other than "up" and "down" key were pressed,
> then the formula selection were reset (it is starting from bottom).

I think it might be better not to implement this, because there are cases where people want to access a formula in the history but edit parts of it. In that case they will use left/right keys to change the position of the cursor and other keys to edit the formula.

> It will be also great to show some indicator what is currently selected
> formula.
> It could be in form of background color.

Wouldn't it be better to implement this features in different branch ? I mean registering a different Bug and implement it independent of this history related branch. Because it have things more related to UI than the history logics.

Revision history for this message
Bartosz Kosiorek (gang65) wrote :

I have submitted ticket for left and right cursor:
https://bugs.launchpad.net/ubuntu-calculator-app/+bug/1610207

> The first problem that you mentioned is fixed.
> Regarding the 2 next points you made:
>
> > Also I would expect that if any other than "up" and "down" key were pressed,
> > then the formula selection were reset (it is starting from bottom).

Let's leave it as it is already implemented, and get UX feedback

> I think it might be better not to implement this, because there are cases
> where people want to access a formula in the history but edit parts of it. In
> that case they will use left/right keys to change the position of the cursor
> and other keys to edit the formula.
>
> > It will be also great to show some indicator what is currently selected
> > formula.
> > It could be in form of background color.
>
> Wouldn't it be better to implement this features in different branch ? I mean
> registering a different Bug and implement it independent of this history
> related branch. Because it have things more related to UI than the history
> logics.

I don't think this work could be separated, as it is stricly connected with "up and down" feature. Without indicator of currently selected calculation from history, it gives bad User Excperience.
For example user could press accidently "up" key, and the whole formula which was typed will gone. With indicator it will be visible that formula was changed with calculation from the history.

It will be also great to implement "Escape" press. If you press Escape key, then it exit from history preview and go back to the old formula.

What do you think about that?

Revision history for this message
Sina Bakhtiari (sinabakh) wrote :

> Let's leave it as it is already implemented, and get UX feedback
>
Sure, thanks!

>
> I don't think this work could be separated, as it is stricly connected with
> "up and down" feature. Without indicator of currently selected calculation
> from history, it gives bad User Excperience.
> For example user could press accidently "up" key, and the whole formula which
> was typed will gone. With indicator it will be visible that formula was
> changed with calculation from the history.

Yes, you are completely right.
Just a question, in you opinion, when user is browsing history and starts to edit one of past formulas, is it better to reset the history and take the edited formula as the current formula, or no, save the current state of history and do not overwrite the last formula (like what happens in terminal) ?

> It will be also great to implement "Escape" press. If you press Escape key,
> then it exit from history preview and go back to the old formula.
>
> What do you think about that?
I like the idea, it will be implemented.

P.S: Is there a place (IRC or mailing list) where I can reach you or other calculator developers in case that I have development questions?

Regards

Revision history for this message
Bartosz Kosiorek (gang65) wrote :

> Just a question, in you opinion, when user is browsing history and starts to
> edit one of past formulas, is it better to reset the history and take the
> edited formula as the current formula, or no, save the current state of
> history and do not overwrite the last formula (like what happens in terminal)
> ?

I would prefer to reset history and take the edited formula as the current formula. We cannot save every formula in history, as our assumption was that it should be mathematically correct (e.g. "100-" or "100*("

> > It will be also great to implement "Escape" press. If you press Escape key,
> > then it exit from history preview and go back to the old formula.
> >
> > What do you think about that?
> I like the idea, it will be implemented.

Great. We will be closer to use calculator only via keyboard.

> P.S: Is there a place (IRC or mailing list) where I can reach you or other
> calculator developers in case that I have development questions?

Some more information you could find on:
https://developer.ubuntu.com/en/community/core-apps/calculator/

Revision history for this message
Bartosz Kosiorek (gang65) wrote :

Let's merge it for now.

review: Approve
Revision history for this message
Jenkins Bot (ubuntu-core-apps-jenkins-bot) wrote :

FAILED: Autolanding.
No commit message was specified in the merge proposal. Hit 'Add commit message' on the merge proposal web page or follow the link below. You can approve the merge proposal yourself to rerun.
https://code.launchpad.net/~sinabakh/ubuntu-calculator-app/history-using-arrow-keys/+merge/301567/+edit-commit-message

review: Needs Fixing (continuous-integration)
Revision history for this message
Jenkins Bot (ubuntu-core-apps-jenkins-bot) :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'app/ubuntu-calculator-app.qml'
2--- app/ubuntu-calculator-app.qml 2016-01-18 23:40:25 +0000
3+++ app/ubuntu-calculator-app.qml 2016-08-03 17:03:28 +0000
4@@ -64,6 +64,15 @@
5 // Var used to save favourite calcs
6 property bool isFavourite: false
7
8+ // Var used to store calculation history position
9+ property var historyPosition: calculationHistory.getContents().count;
10+
11+ // Var used to save if user is using history.
12+ property bool isUsingHistory: false;
13+
14+ // Var used to store the last formula which is being written.
15+ property string lastWrittenFormula: "";
16+
17 // Var used to store currently edited calculation history item
18 property int editedCalculationIndex: -1
19
20@@ -312,7 +321,7 @@
21
22 // Some special keys like backspace captured in TextField,
23 // are for some reason not sent to the application but to the text input
24- Keys.onPressed: textInputField.keyPress(event)
25+ Keys.onPressed: {event.accepted = true; textInputField.keyPress(event)}
26 Keys.onReleased: textInputField.keyRelease(event)
27
28 head.visible: false
29@@ -618,6 +627,24 @@
30
31 function keyPress(event) {
32 if (!(event.modifiers & Qt.ControlModifier || event.modifiers & Qt.AltModifier)) { // Shift needs to be passed through as it may be required for some special keys
33+ if((event.key === Qt.Key_Up || event.key === Qt.Key_Down) && event.accepted) {
34+ if(event.key === Qt.Key_Up && historyPosition > 1)
35+ historyPosition--;
36+ if(event.key === Qt.Key_Down && historyPosition < calculationHistory.getContents().count)
37+ historyPosition++;
38+ if(historyPosition !== calculationHistory.getContents().count) {
39+ isUsingHistory = true;
40+ clearFormula();
41+ formulaPush(calculationHistory.getContents().get(historyPosition).formula);
42+ }
43+ else if(isUsingHistory)
44+ {
45+ clearFormula();
46+ formulaPush(lastWrittenFormula);
47+ isUsingHistory = false;
48+ }
49+ }
50+
51 keyboardLoader.item.pressedKey = event.key;
52 keyboardLoader.item.pressedKeyText = event.text;
53 } else if (event.modifiers & Qt.ControlModifier) {
54@@ -697,6 +724,12 @@
55 displayedInputText = shortFormula;
56 }
57
58+ onTextChanged: {
59+ if(! isUsingHistory) {
60+ lastWrittenFormula = textInputField.text;
61+ }
62+ }
63+
64 SequentialAnimation {
65 id: errorAnimation
66 running: false
67
68=== modified file 'app/ui/KeyboardPage.qml'
69--- app/ui/KeyboardPage.qml 2015-11-09 14:18:18 +0000
70+++ app/ui/KeyboardPage.qml 2016-08-03 17:03:28 +0000
71@@ -154,6 +154,7 @@
72 break;
73 case "calculate":
74 calculate();
75+ historyPosition = calculationHistory.getContents().count;
76 scrollableView.scrollToBottom();
77 break;
78 }

Subscribers

People subscribed via source and target branches