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
=== modified file 'app/tests/autopilot/ubuntu_calculator_app/__init__.py'
--- app/tests/autopilot/ubuntu_calculator_app/__init__.py 2015-01-30 21:36:04 +0000
+++ app/tests/autopilot/ubuntu_calculator_app/__init__.py 2015-02-10 22:19:21 +0000
@@ -66,7 +66,7 @@
66class MainView(ubuntuuitoolkit.MainView):66class MainView(ubuntuuitoolkit.MainView):
67 """Calculator MainView Autopilot emulator."""67 """Calculator MainView Autopilot emulator."""
6868
69 BUTTONS = {'clear': 'clearButton', '*': 'multiplyButton',69 BUTTONS = {'delete': 'deleteButton', '*': 'multiplyButton',
70 '/': 'divideButton', '.': 'pointButton',70 '/': 'divideButton', '.': 'pointButton',
71 '=': 'equalsButton', '-': 'minusButton', '+': 'plusButton',71 '=': 'equalsButton', '-': 'minusButton', '+': 'plusButton',
72 '0': 'zeroButton', '1': 'oneButton', '2': 'twoButton',72 '0': 'zeroButton', '1': 'oneButton', '2': 'twoButton',
@@ -85,8 +85,24 @@
85 def press_universal_bracket(self):85 def press_universal_bracket(self):
86 self.press('bracket')86 self.press('bracket')
8787
88 def delete(self):
89 self.press('delete')
90
88 def clear(self):91 def clear(self):
89 self.press('clear')92 self.press_and_hold('delete')
93
94 def press_and_hold(self, button):
95 button = self.wait_select_single('KeyboardButton',
96 objectName=MainView.BUTTONS[button])
97
98 button_area = button.wait_select_single('QQuickMouseArea',
99 objectName='buttonMA')
100
101 self.pointing_device.move_to_object(button)
102 self.pointing_device.press()
103 button_area.pressed.wait_for(True)
104 sleep(3)
105 self.pointing_device.release()
90106
91 def press(self, button):107 def press(self, button):
92 button = self.wait_select_single('KeyboardButton',108 button = self.wait_select_single('KeyboardButton',
@@ -106,7 +122,7 @@
106 self.pointing_device.press()122 self.pointing_device.press()
107 # this sleeps represents our minimum press time,123 # this sleeps represents our minimum press time,
108 # should button_area.pressed be true without any wait124 # should button_area.pressed be true without any wait
109 sleep(0.3)125 sleep(0.1)
110 button_area.pressed.wait_for(True)126 button_area.pressed.wait_for(True)
111 self.pointing_device.release()127 self.pointing_device.release()
112128
113129
=== modified file 'app/tests/autopilot/ubuntu_calculator_app/tests/test_main.py'
--- app/tests/autopilot/ubuntu_calculator_app/tests/test_main.py 2015-01-28 22:32:08 +0000
+++ app/tests/autopilot/ubuntu_calculator_app/tests/test_main.py 2015-02-10 22:19:21 +0000
@@ -70,12 +70,24 @@
70 self._assert_history_contains(u'8βˆ’7=1')70 self._assert_history_contains(u'8βˆ’7=1')
7171
72 def test_operation_after_clear(self):72 def test_operation_after_clear(self):
73 self.app.main_view.insert('7*7')
74
75 self._assert_result_is(u'7Γ—7')
76
77 self.app.main_view.clear()
78 self._assert_result_is(u'')
79 self.app.main_view.insert('2*0=')
80
81 self._assert_result_is(u'0')
82 self._assert_history_contains(u'2Γ—0=0')
83
84 def test_operation_after_delete(self):
73 self.app.main_view.insert('8*8=')85 self.app.main_view.insert('8*8=')
7486
75 self._assert_result_is(u'64')87 self._assert_result_is(u'64')
76 self._assert_history_contains(u'8Γ—8=64')88 self._assert_history_contains(u'8Γ—8=64')
7789
78 self.app.main_view.clear()90 self.app.main_view.delete()
79 self._assert_result_is(u'')91 self._assert_result_is(u'')
80 self.app.main_view.insert('9*9=')92 self.app.main_view.insert('9*9=')
8193
@@ -87,7 +99,7 @@
87 self._assert_result_is(u'1.000000001')99 self._assert_result_is(u'1.000000001')
88 self._assert_history_contains(u'0.000000001+1=1.000000001')100 self._assert_history_contains(u'0.000000001+1=1.000000001')
89101
90 self.app.main_view.clear()102 self.app.main_view.delete()
91103
92 self.app.main_view.insert('0.000000001/10=')104 self.app.main_view.insert('0.000000001/10=')
93 self._assert_result_is(u'1eβˆ’10')105 self._assert_result_is(u'1eβˆ’10')
@@ -102,7 +114,7 @@
102 self._assert_result_is(u'14')114 self._assert_result_is(u'14')
103 self._assert_history_contains(u'2Γ—(3+4)=14')115 self._assert_history_contains(u'2Γ—(3+4)=14')
104116
105 self.app.main_view.clear()117 self.app.main_view.delete()
106 self.app.main_view.insert('4')118 self.app.main_view.insert('4')
107 self.app.main_view.press_universal_bracket()119 self.app.main_view.press_universal_bracket()
108 self.app.main_view.insert('3-2')120 self.app.main_view.insert('3-2')
@@ -118,13 +130,13 @@
118 self._assert_result_is(u'6')130 self._assert_result_is(u'6')
119 self._assert_history_contains(u'2+2Γ—2=6')131 self._assert_history_contains(u'2+2Γ—2=6')
120132
121 self.app.main_view.clear()133 self.app.main_view.delete()
122 self.app.main_view.insert('2-2*2=')134 self.app.main_view.insert('2-2*2=')
123135
124 self._assert_result_is(u'βˆ’2')136 self._assert_result_is(u'βˆ’2')
125 self._assert_history_contains(u'2βˆ’2Γ—2=-2')137 self._assert_history_contains(u'2βˆ’2Γ—2=-2')
126138
127 self.app.main_view.clear()139 self.app.main_view.delete()
128 self.app.main_view.insert('5+6/2=')140 self.app.main_view.insert('5+6/2=')
129141
130 self._assert_result_is(u'8')142 self._assert_result_is(u'8')
131143
=== modified file 'app/ubuntu-calculator-app.qml'
--- app/ubuntu-calculator-app.qml 2015-02-02 22:35:12 +0000
+++ app/ubuntu-calculator-app.qml 2015-02-10 22:19:21 +0000
@@ -88,6 +88,15 @@
88 }88 }
89 }89 }
9090
91 /**
92 * Function to clear formula in input text field
93 */
94 function clearFormula() {
95 shortFormula = "";
96 longFormula = "";
97 displayedInputText = "";
98 }
99
91 function validateStringForAddingToFormula(formula, stringToAddToFormula) {100 function validateStringForAddingToFormula(formula, stringToAddToFormula) {
92 if (Formula.isOperator(stringToAddToFormula)) {101 if (Formula.isOperator(stringToAddToFormula)) {
93 return Formula.couldAddOperator(formula, stringToAddToFormula);102 return Formula.couldAddOperator(formula, stringToAddToFormula);
94103
=== modified file 'app/ui/KeyboardButton.qml'
--- app/ui/KeyboardButton.qml 2015-01-22 22:08:58 +0000
+++ app/ui/KeyboardButton.qml 2015-02-10 22:19:21 +0000
@@ -65,5 +65,6 @@
65 objectName: "buttonMA"65 objectName: "buttonMA"
66 anchors.fill: parent66 anchors.fill: parent
67 onClicked: buttonRect.clicked();67 onClicked: buttonRect.clicked();
68 onPressAndHold: buttonRect.pressAndHold();
68 }69 }
69}70}
7071
=== modified file 'app/ui/KeyboardPage.qml'
--- app/ui/KeyboardPage.qml 2015-01-29 21:06:53 +0000
+++ app/ui/KeyboardPage.qml 2015-02-10 22:19:21 +0000
@@ -69,7 +69,8 @@
69 action: entry.action ? entry.action : "push",69 action: entry.action ? entry.action : "push",
70 objectName: entry.name ? entry.name + "Button" : "",70 objectName: entry.name ? entry.name + "Button" : "",
71 pushText: entry.pushText ? entry.pushText : text,71 pushText: entry.pushText ? entry.pushText : text,
72 kbdKeys: entry.kbdKeys ? JSON.stringify(entry.kbdKeys) : JSON.stringify([])72 kbdKeys: entry.kbdKeys ? JSON.stringify(entry.kbdKeys) : JSON.stringify([]),
73 secondaryAction: entry.secondaryAction ? entry.secondaryAction : ""
73 }74 }
74 )75 )
7576
@@ -113,7 +114,8 @@
113114
114 Item {115 Item {
115 KeyboardButton {116 KeyboardButton {
116 height: Math.min(repeater.baseSize * keyboardRoot.buttonRatio, keyboardRoot.buttonMaxHeight) * model.hFactor + (keyboardRoot.spacing * (model.hFactor - 1))117 height: Math.min(repeater.baseSize * keyboardRoot.buttonRatio, keyboardRoot.buttonMaxHeight) *
118 model.hFactor + (keyboardRoot.spacing * (model.hFactor - 1))
117 width: repeater.baseSize * model.wFactor + (keyboardRoot.spacing * (model.wFactor - 1))119 width: repeater.baseSize * model.wFactor + (keyboardRoot.spacing * (model.wFactor - 1))
118 text: model.text120 text: model.text
119 objectName: model.objectName121 objectName: model.objectName
@@ -131,6 +133,13 @@
131 break;133 break;
132 }134 }
133 }135 }
136 onPressAndHold: {
137 switch (model.secondaryAction) {
138 case "clearFormula":
139 clearFormula();
140 break;
141 }
142 }
134 }143 }
135 }144 }
136 }145 }
137146
=== modified file 'app/ui/LandscapeKeyboard.qml'
--- app/ui/LandscapeKeyboard.qml 2015-02-03 11:42:00 +0000
+++ app/ui/LandscapeKeyboard.qml 2015-02-10 22:19:21 +0000
@@ -10,7 +10,7 @@
10 columns: 810 columns: 8
1111
12 keyboardModel: new Array(12 keyboardModel: new Array(
13 { text: "←", name: "clear", action: "delete", kbdKeys: [Qt.Key_Backspace] },13 { text: "←", name: "delete", action: "delete", kbdKeys: [Qt.Key_Backspace], secondaryAction: "clearFormula" },
14 { text: "( )", name: "universalBracket", pushText: "()" },14 { text: "( )", name: "universalBracket", pushText: "()" },
15 { text: "Γ·", name: "divide", pushText: "/", kbdKeys: [Qt.Key_Slash] },15 { text: "Γ·", name: "divide", pushText: "/", kbdKeys: [Qt.Key_Slash] },
16 { text: "Γ—", name: "multiply", pushText: "*", kbdKeys: [Qt.Key_Asterisk] },16 { text: "Γ—", name: "multiply", pushText: "*", kbdKeys: [Qt.Key_Asterisk] },
1717
=== modified file 'app/ui/PortraitKeyboard.qml'
--- app/ui/PortraitKeyboard.qml 2015-02-03 11:42:00 +0000
+++ app/ui/PortraitKeyboard.qml 2015-02-10 22:19:21 +0000
@@ -9,7 +9,7 @@
9 buttonMaxHeight: scrollableView.height / 10.09 buttonMaxHeight: scrollableView.height / 10.0
1010
11 keyboardModel: new Array(11 keyboardModel: new Array(
12 { text: "←", name: "clear", action: "delete", kbdKeys: [Qt.Key_Backspace] },12 { text: "←", name: "delete", action: "delete", kbdKeys: [Qt.Key_Backspace], secondaryAction: "clearFormula" },
13 { text: "( )", name: "universalBracket", pushText: "()" },13 { text: "( )", name: "universalBracket", pushText: "()" },
14 { text: "Γ·", name: "divide", pushText: "/", kbdKeys: [Qt.Key_Slash] },14 { text: "Γ·", name: "divide", pushText: "/", kbdKeys: [Qt.Key_Slash] },
15 { text: "Γ—", name: "multiply", pushText: "*", kbdKeys: [Qt.Key_Asterisk] },15 { text: "Γ—", name: "multiply", pushText: "*", kbdKeys: [Qt.Key_Asterisk] },

Subscribers

People subscribed via source and target branches