Merge lp:~gang65/ubuntu-calculator-app/ubuntu-calculator-app-key-longpress into lp:ubuntu-calculator-app

Proposed by Bartosz Kosiorek
Status: Merged
Approved by: Bartosz Kosiorek
Approved revision: 98
Merged at revision: 98
Proposed branch: lp:~gang65/ubuntu-calculator-app/ubuntu-calculator-app-key-longpress
Merge into: lp:ubuntu-calculator-app
Diff against target: 206 lines (+59/-12)
7 files modified
app/tests/autopilot/ubuntu_calculator_app/__init__.py (+19/-3)
app/tests/autopilot/ubuntu_calculator_app/tests/test_main.py (+17/-5)
app/ubuntu-calculator-app.qml (+9/-0)
app/ui/KeyboardButton.qml (+1/-0)
app/ui/KeyboardPage.qml (+11/-2)
app/ui/LandscapeKeyboard.qml (+1/-1)
app/ui/PortraitKeyboard.qml (+1/-1)
To merge this branch: bzr merge lp:~gang65/ubuntu-calculator-app/ubuntu-calculator-app-key-longpress
Reviewer Review Type Date Requested Status
Alan Pope 🍺🐧🐱 πŸ¦„ (community) Approve
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Review via email: mp+249260@code.launchpad.net

Commit message

Add clear formula feature, by long pressing delete button.

Description of the change

Add clear formula feature, by long pressing delete button.

To post a comment you must log in.
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Alan Pope 🍺🐧🐱 πŸ¦„ (popey) wrote :

Looks good to me!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'app/tests/autopilot/ubuntu_calculator_app/__init__.py'
2--- app/tests/autopilot/ubuntu_calculator_app/__init__.py 2015-01-30 21:36:04 +0000
3+++ app/tests/autopilot/ubuntu_calculator_app/__init__.py 2015-02-10 22:19:21 +0000
4@@ -66,7 +66,7 @@
5 class MainView(ubuntuuitoolkit.MainView):
6 """Calculator MainView Autopilot emulator."""
7
8- BUTTONS = {'clear': 'clearButton', '*': 'multiplyButton',
9+ BUTTONS = {'delete': 'deleteButton', '*': 'multiplyButton',
10 '/': 'divideButton', '.': 'pointButton',
11 '=': 'equalsButton', '-': 'minusButton', '+': 'plusButton',
12 '0': 'zeroButton', '1': 'oneButton', '2': 'twoButton',
13@@ -85,8 +85,24 @@
14 def press_universal_bracket(self):
15 self.press('bracket')
16
17+ def delete(self):
18+ self.press('delete')
19+
20 def clear(self):
21- self.press('clear')
22+ self.press_and_hold('delete')
23+
24+ def press_and_hold(self, button):
25+ button = self.wait_select_single('KeyboardButton',
26+ objectName=MainView.BUTTONS[button])
27+
28+ button_area = button.wait_select_single('QQuickMouseArea',
29+ objectName='buttonMA')
30+
31+ self.pointing_device.move_to_object(button)
32+ self.pointing_device.press()
33+ button_area.pressed.wait_for(True)
34+ sleep(3)
35+ self.pointing_device.release()
36
37 def press(self, button):
38 button = self.wait_select_single('KeyboardButton',
39@@ -106,7 +122,7 @@
40 self.pointing_device.press()
41 # this sleeps represents our minimum press time,
42 # should button_area.pressed be true without any wait
43- sleep(0.3)
44+ sleep(0.1)
45 button_area.pressed.wait_for(True)
46 self.pointing_device.release()
47
48
49=== modified file 'app/tests/autopilot/ubuntu_calculator_app/tests/test_main.py'
50--- app/tests/autopilot/ubuntu_calculator_app/tests/test_main.py 2015-01-28 22:32:08 +0000
51+++ app/tests/autopilot/ubuntu_calculator_app/tests/test_main.py 2015-02-10 22:19:21 +0000
52@@ -70,12 +70,24 @@
53 self._assert_history_contains(u'8βˆ’7=1')
54
55 def test_operation_after_clear(self):
56+ self.app.main_view.insert('7*7')
57+
58+ self._assert_result_is(u'7Γ—7')
59+
60+ self.app.main_view.clear()
61+ self._assert_result_is(u'')
62+ self.app.main_view.insert('2*0=')
63+
64+ self._assert_result_is(u'0')
65+ self._assert_history_contains(u'2Γ—0=0')
66+
67+ def test_operation_after_delete(self):
68 self.app.main_view.insert('8*8=')
69
70 self._assert_result_is(u'64')
71 self._assert_history_contains(u'8Γ—8=64')
72
73- self.app.main_view.clear()
74+ self.app.main_view.delete()
75 self._assert_result_is(u'')
76 self.app.main_view.insert('9*9=')
77
78@@ -87,7 +99,7 @@
79 self._assert_result_is(u'1.000000001')
80 self._assert_history_contains(u'0.000000001+1=1.000000001')
81
82- self.app.main_view.clear()
83+ self.app.main_view.delete()
84
85 self.app.main_view.insert('0.000000001/10=')
86 self._assert_result_is(u'1eβˆ’10')
87@@ -102,7 +114,7 @@
88 self._assert_result_is(u'14')
89 self._assert_history_contains(u'2Γ—(3+4)=14')
90
91- self.app.main_view.clear()
92+ self.app.main_view.delete()
93 self.app.main_view.insert('4')
94 self.app.main_view.press_universal_bracket()
95 self.app.main_view.insert('3-2')
96@@ -118,13 +130,13 @@
97 self._assert_result_is(u'6')
98 self._assert_history_contains(u'2+2Γ—2=6')
99
100- self.app.main_view.clear()
101+ self.app.main_view.delete()
102 self.app.main_view.insert('2-2*2=')
103
104 self._assert_result_is(u'βˆ’2')
105 self._assert_history_contains(u'2βˆ’2Γ—2=-2')
106
107- self.app.main_view.clear()
108+ self.app.main_view.delete()
109 self.app.main_view.insert('5+6/2=')
110
111 self._assert_result_is(u'8')
112
113=== modified file 'app/ubuntu-calculator-app.qml'
114--- app/ubuntu-calculator-app.qml 2015-02-02 22:35:12 +0000
115+++ app/ubuntu-calculator-app.qml 2015-02-10 22:19:21 +0000
116@@ -88,6 +88,15 @@
117 }
118 }
119
120+ /**
121+ * Function to clear formula in input text field
122+ */
123+ function clearFormula() {
124+ shortFormula = "";
125+ longFormula = "";
126+ displayedInputText = "";
127+ }
128+
129 function validateStringForAddingToFormula(formula, stringToAddToFormula) {
130 if (Formula.isOperator(stringToAddToFormula)) {
131 return Formula.couldAddOperator(formula, stringToAddToFormula);
132
133=== modified file 'app/ui/KeyboardButton.qml'
134--- app/ui/KeyboardButton.qml 2015-01-22 22:08:58 +0000
135+++ app/ui/KeyboardButton.qml 2015-02-10 22:19:21 +0000
136@@ -65,5 +65,6 @@
137 objectName: "buttonMA"
138 anchors.fill: parent
139 onClicked: buttonRect.clicked();
140+ onPressAndHold: buttonRect.pressAndHold();
141 }
142 }
143
144=== modified file 'app/ui/KeyboardPage.qml'
145--- app/ui/KeyboardPage.qml 2015-01-29 21:06:53 +0000
146+++ app/ui/KeyboardPage.qml 2015-02-10 22:19:21 +0000
147@@ -69,7 +69,8 @@
148 action: entry.action ? entry.action : "push",
149 objectName: entry.name ? entry.name + "Button" : "",
150 pushText: entry.pushText ? entry.pushText : text,
151- kbdKeys: entry.kbdKeys ? JSON.stringify(entry.kbdKeys) : JSON.stringify([])
152+ kbdKeys: entry.kbdKeys ? JSON.stringify(entry.kbdKeys) : JSON.stringify([]),
153+ secondaryAction: entry.secondaryAction ? entry.secondaryAction : ""
154 }
155 )
156
157@@ -113,7 +114,8 @@
158
159 Item {
160 KeyboardButton {
161- height: Math.min(repeater.baseSize * keyboardRoot.buttonRatio, keyboardRoot.buttonMaxHeight) * model.hFactor + (keyboardRoot.spacing * (model.hFactor - 1))
162+ height: Math.min(repeater.baseSize * keyboardRoot.buttonRatio, keyboardRoot.buttonMaxHeight) *
163+ model.hFactor + (keyboardRoot.spacing * (model.hFactor - 1))
164 width: repeater.baseSize * model.wFactor + (keyboardRoot.spacing * (model.wFactor - 1))
165 text: model.text
166 objectName: model.objectName
167@@ -131,6 +133,13 @@
168 break;
169 }
170 }
171+ onPressAndHold: {
172+ switch (model.secondaryAction) {
173+ case "clearFormula":
174+ clearFormula();
175+ break;
176+ }
177+ }
178 }
179 }
180 }
181
182=== modified file 'app/ui/LandscapeKeyboard.qml'
183--- app/ui/LandscapeKeyboard.qml 2015-02-03 11:42:00 +0000
184+++ app/ui/LandscapeKeyboard.qml 2015-02-10 22:19:21 +0000
185@@ -10,7 +10,7 @@
186 columns: 8
187
188 keyboardModel: new Array(
189- { text: "←", name: "clear", action: "delete", kbdKeys: [Qt.Key_Backspace] },
190+ { text: "←", name: "delete", action: "delete", kbdKeys: [Qt.Key_Backspace], secondaryAction: "clearFormula" },
191 { text: "( )", name: "universalBracket", pushText: "()" },
192 { text: "Γ·", name: "divide", pushText: "/", kbdKeys: [Qt.Key_Slash] },
193 { text: "Γ—", name: "multiply", pushText: "*", kbdKeys: [Qt.Key_Asterisk] },
194
195=== modified file 'app/ui/PortraitKeyboard.qml'
196--- app/ui/PortraitKeyboard.qml 2015-02-03 11:42:00 +0000
197+++ app/ui/PortraitKeyboard.qml 2015-02-10 22:19:21 +0000
198@@ -9,7 +9,7 @@
199 buttonMaxHeight: scrollableView.height / 10.0
200
201 keyboardModel: new Array(
202- { text: "←", name: "clear", action: "delete", kbdKeys: [Qt.Key_Backspace] },
203+ { text: "←", name: "delete", action: "delete", kbdKeys: [Qt.Key_Backspace], secondaryAction: "clearFormula" },
204 { text: "( )", name: "universalBracket", pushText: "()" },
205 { text: "Γ·", name: "divide", pushText: "/", kbdKeys: [Qt.Key_Slash] },
206 { text: "Γ—", name: "multiply", pushText: "*", kbdKeys: [Qt.Key_Asterisk] },

Subscribers

People subscribed via source and target branches