Merge lp:~dinko-metalac/sudoku-app/new-game-gui-rework into lp:sudoku-app

Proposed by Dinko Osmankovic
Status: Merged
Approved by: Dinko Osmankovic
Approved revision: 104
Merged at revision: 103
Proposed branch: lp:~dinko-metalac/sudoku-app/new-game-gui-rework
Merge into: lp:sudoku-app
Diff against target: 392 lines (+307/-13)
4 files modified
components/NewGameSelectionButton.qml (+57/-0)
sudoku-app.qml (+105/-3)
tests/autopilot/sudoku_app/emulators/main_window.py (+37/-1)
tests/autopilot/sudoku_app/tests/test_sudoku.py (+108/-9)
To merge this branch: bzr merge lp:~dinko-metalac/sudoku-app/new-game-gui-rework
Reviewer Review Type Date Requested Status
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Review via email: mp+180793@code.launchpad.net

Commit message

Rework of new game action ui

Description of the change

Rework of new game action ui

To post a comment you must log in.
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-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=== added file 'components/NewGameSelectionButton.qml'
2--- components/NewGameSelectionButton.qml 1970-01-01 00:00:00 +0000
3+++ components/NewGameSelectionButton.qml 2013-08-19 07:22:01 +0000
4@@ -0,0 +1,57 @@
5+import QtQuick 2.0
6+import Ubuntu.Components 0.1
7+import Ubuntu.Components.Popups 0.1
8+
9+UbuntuShape {
10+ id: gameDifficultyButton
11+ property string buttonText
12+ color: sudokuBlocksGrid.dialogButtonColor2
13+ Image {
14+ source: "../icons/sudoku-vector-desktop.svg"
15+ anchors.fill: parent
16+ z:-1
17+ }
18+
19+ Label {
20+ text: buttonText
21+ anchors.centerIn: parent
22+ color: sudokuBlocksGrid.dialogButtonTextColor
23+ opacity: 1
24+ }
25+ signal triggered;
26+
27+ SequentialAnimation {
28+ id: animateDialogButton
29+ UbuntuNumberAnimation {
30+ id: animateDialogButton1
31+ target: gameDifficultyButton
32+ properties: "scale"
33+ to: 1.1
34+ from: 1
35+ duration: UbuntuAnimation.SnapDuration
36+ easing: UbuntuAnimation.StandardEasing
37+ }
38+ UbuntuNumberAnimation {
39+ id: animateDialogButton2
40+ target: gameDifficultyButton
41+ properties: "scale"
42+ to: 1
43+ from: 1.1
44+ duration: UbuntuAnimation.SnapDuration
45+ easing: UbuntuAnimation.StandardEasing
46+ }
47+ onRunningChanged: {
48+ if (animateDialogButton.running == false ) {
49+ triggered();
50+ }
51+
52+ }
53+ }
54+ MouseArea {
55+ id: buttonMouseArea
56+ anchors.fill: parent
57+ onClicked: {
58+ animateDialogButton.start();
59+ }
60+ }
61+}
62
63=== modified file 'sudoku-app.qml'
64--- sudoku-app.qml 2013-08-16 20:25:35 +0000
65+++ sudoku-app.qml 2013-08-19 07:22:01 +0000
66@@ -299,6 +299,101 @@
67 }
68 }
69
70+ Component {
71+ id: newGameComponent
72+ Dialog {
73+ id: newGameDialogue
74+ title: i18n.tr("New Game")
75+ text: i18n.tr("Select difficulty level")
76+
77+ Column {
78+ spacing: units.gu(5)
79+ Grid {
80+ rowSpacing: units.gu(3)
81+ columnSpacing: units.gu(3)
82+ columns: 2
83+ anchors.horizontalCenter: parent.horizontalCenter
84+ NewGameSelectionButton {
85+ id: easyGameButton
86+ objectName: "easyGameButton"
87+ buttonText: i18n.tr("Easy")
88+ opacity: 0.8
89+ width: mainView.width/4
90+ height: width
91+ onTriggered: {
92+ //print("EASY")
93+ var randomnumber = Math.floor(Math.random()*9);
94+ randomnumber += 31;
95+ sudokuBlocksGrid.createNewGame(81 - randomnumber);
96+ PopupUtils.close(newGameDialogue)
97+ }
98+ }
99+ NewGameSelectionButton {
100+ id: moderateGameButton
101+ objectName: "moderateGameButton"
102+ buttonText: i18n.tr("Moderate")
103+ opacity: 0.8
104+ width: mainView.width/4
105+ height: width
106+ onTriggered: {
107+ //print("EASY")
108+ var randomnumber = Math.floor(Math.random()*4);
109+ randomnumber += 26;
110+ sudokuBlocksGrid.createNewGame(81 - randomnumber);
111+ PopupUtils.close(newGameDialogue)
112+ }
113+ }
114+ NewGameSelectionButton {
115+ id: hardGameButton
116+ objectName: "hardGameButton"
117+ buttonText: i18n.tr("Hard")
118+ opacity: 0.8
119+ width: mainView.width/4
120+ height: width
121+ onTriggered: {
122+ //print("EASY")
123+ var randomnumber = Math.floor(Math.random()*4);
124+ randomnumber += 21;
125+ sudokuBlocksGrid.createNewGame(81 - randomnumber);
126+ PopupUtils.close(newGameDialogue)
127+ }
128+ }
129+ NewGameSelectionButton {
130+ id: ultrahardGameButton
131+ objectName: "ultrahardGameButton"
132+ buttonText: i18n.tr("Ultra\nHard")
133+ opacity: 0.8
134+ width: mainView.width/4
135+ height: width
136+ onTriggered: {
137+ //print("EASY")
138+ var randomnumber = Math.floor(Math.random()*3);
139+ randomnumber += 17;
140+ sudokuBlocksGrid.createNewGame(81 - randomnumber);
141+ PopupUtils.close(newGameDialogue)
142+ }
143+ }
144+
145+ }
146+
147+ SudokuDialogButton{
148+ buttonText: i18n.tr("Cancel")
149+ width: parent.width/2;
150+ size: units.gu(5)
151+ buttonColor: sudokuBlocksGrid.dialogButtonColor1
152+ textColor: sudokuBlocksGrid.dialogButtonTextColor
153+ anchors.horizontalCenter: parent.horizontalCenter
154+ //border.color: "transparent"
155+ onTriggered: {
156+ PopupUtils.close(newGameDialogue)
157+ }
158+ }
159+
160+ }
161+
162+ }
163+ }
164+
165 function showAlert(title, text, caller)
166 {
167 alertTitle = title
168@@ -436,7 +531,11 @@
169 onTriggered: {
170 if(gameFinishedRectangle.visible) gameFinishedRectangle.visible = false;
171 //print("new block distance:", blockDistance);
172- createNewGame()
173+ //createNewGame()
174+ if (settingsTab.difficultyIndex == 4)
175+ PopupUtils.open(newGameComponent)
176+ else
177+ createNewGame()
178 }
179 }
180 }
181@@ -712,8 +811,8 @@
182 ListItem.ValueSelector {
183 objectName: "difficultySelector"
184 id: difficultySelector
185- text: i18n.tr("Difficulty")
186- values: [i18n.tr("Easy"), i18n.tr("Moderate"), i18n.tr("Hard"), i18n.tr("Ultra Hard")]
187+ text: i18n.tr("Default Difficulty")
188+ values: [i18n.tr("Easy"), i18n.tr("Moderate"), i18n.tr("Hard"), i18n.tr("Ultra Hard"), i18n.tr("Always ask")]
189 onSelectedIndexChanged: {
190 //print(difficultySelector.selectedIndex)
191 switch(difficultySelector.selectedIndex) {
192@@ -741,6 +840,9 @@
193 sudokuBlocksGrid.createNewGame(81 - randomnumber);
194 Settings.setSetting("Difficulty", selectedIndex)
195 break;
196+ case 4:
197+ Settings.setSetting("Difficulty", selectedIndex)
198+ break;
199 }
200 }
201
202
203=== modified file 'tests/autopilot/sudoku_app/emulators/main_window.py'
204--- tests/autopilot/sudoku_app/emulators/main_window.py 2013-07-29 21:38:03 +0000
205+++ tests/autopilot/sudoku_app/emulators/main_window.py 2013-08-19 07:22:01 +0000
206@@ -60,7 +60,7 @@
207
208 def get_current_profile(self):
209 return self.app.select_single("SingleValue", objectName="Current profile")
210-
211+
212 def get_select_profile_sheet(self):
213 return self.app.select_single("DefaultSheet", title="Select profile")
214
215@@ -96,6 +96,18 @@
216
217 def get_edit_profile_delete_button(self):
218 return self.app.select_single("SudokuDialogButton", objectName ="deleteButton")
219+
220+ def get_new_game_easy_button(self):
221+ return self.app.select_single("NewGameSelectionButton", objectName ="easyGameButton")
222+
223+ def get_new_game_moderate_button(self):
224+ return self.app.select_single("NewGameSelectionButton", objectName ="moderateGameButton")
225+
226+ def get_new_game_hard_button(self):
227+ return self.app.select_single("NewGameSelectionButton", objectName ="hardGameButton")
228+
229+ def get_new_game_ultrahard_button(self):
230+ return self.app.select_single("NewGameSelectionButton", objectName ="ultrahardGameButton")
231
232 def try_OK_Button(self):
233 try:
234@@ -114,6 +126,30 @@
235 return self.get_edit_profile_delete_button().buttonText
236 except StateNotFoundError:
237 return None
238+
239+ def try_new_game_easy_button(self):
240+ try:
241+ return self.get_new_game_easy_button().buttonText
242+ except StateNotFoundError:
243+ return None
244+
245+ def try_new_game_moderate_button(self):
246+ try:
247+ return self.get_new_game_moderate_button().buttonText
248+ except StateNotFoundError:
249+ return None
250+
251+ def try_new_game_hard_button(self):
252+ try:
253+ return self.get_new_game_hard_button().buttonText
254+ except StateNotFoundError:
255+ return None
256+
257+ def try_new_game_ultrahard_button(self):
258+ try:
259+ return self.get_new_game_ultrahard_button().buttonText
260+ except StateNotFoundError:
261+ return None
262
263 def try_my_profile(self):
264 try:
265
266=== modified file 'tests/autopilot/sudoku_app/tests/test_sudoku.py'
267--- tests/autopilot/sudoku_app/tests/test_sudoku.py 2013-08-05 20:18:51 +0000
268+++ tests/autopilot/sudoku_app/tests/test_sudoku.py 2013-08-19 07:22:01 +0000
269@@ -130,15 +130,114 @@
270
271
272 def test_new_game_button(self):
273- self.ubuntusdk.click_toolbar_button("newgamebutton")
274-
275- number_of_hints = lambda: self.app.select_single(objectName="blockgrid").numberOfHints
276- number_of_actions = lambda: self.app.select_single(objectName="blockgrid").numberOfActions
277- game_seconds = lambda: self.app.select_single(objectName="blockgrid").gameSeconds
278-
279- self.assertThat(number_of_hints, Eventually(Equals(0)))
280- self.assertThat(number_of_actions, Eventually(Equals(0)))
281- self.assertThat(game_seconds, Eventually(Equals(0)))
282+ self.open_and_check_settings_tab()
283+ difficultySelector = self.main_window.get_difficulty_selector()
284+ self.pointing_device.click_object(difficultySelector)
285+ difficultyChoices = self.main_window.get_difficulty_selector_labelvisual()
286+ difficultyChoice = difficultyChoices[3]
287+ self.assertThat(difficultyChoice.text, Eventually(Equals("Moderate")))
288+
289+ self.pointing_device.click_object(difficultyChoice)
290+ self.verify_settings_tab_open()
291+ self.ubuntusdk.switch_to_tab(0)
292+
293+ #verify settings sudoku tab is open
294+ self.verify_settings_tab_open()
295+
296+ #testing new game with moderate mode
297+ self.ubuntusdk.click_toolbar_button("newgamebutton")
298+
299+ number_of_hints = lambda: self.app.select_single(objectName="blockgrid").numberOfHints
300+ number_of_actions = lambda: self.app.select_single(objectName="blockgrid").numberOfActions
301+ game_seconds = lambda: self.app.select_single(objectName="blockgrid").gameSeconds
302+
303+ self.assertThat(number_of_hints, Eventually(Equals(0)))
304+ self.assertThat(number_of_actions, Eventually(Equals(0)))
305+ self.assertThat(game_seconds, Eventually(Equals(0)))
306+
307+ #----------------------------------------------------------
308+
309+ self.open_and_check_settings_tab()
310+ difficultySelector = self.main_window.get_difficulty_selector()
311+ self.pointing_device.click_object(difficultySelector)
312+ difficultyChoices = self.main_window.get_difficulty_selector_labelvisual()
313+ difficultyChoice = difficultyChoices[6]
314+ self.assertThat(difficultyChoice.text, Eventually(Equals("Always ask")))
315+
316+ self.pointing_device.click_object(difficultyChoice)
317+ self.verify_settings_tab_open()
318+ self.ubuntusdk.switch_to_tab(0)
319+
320+ #verify settings sudoku tab is open
321+ self.verify_settings_tab_open()
322+
323+ #testing new game with always ask mode - easy
324+ self.ubuntusdk.click_toolbar_button("newgamebutton")
325+
326+ newGameEasyButton = self.main_window.get_new_game_easy_button()
327+ self.main_window.try_new_game_easy_button()
328+ self.assertThat(newGameEasyButton.buttonText, Eventually(Equals("Easy")))
329+ self.pointing_device.click_object(newGameEasyButton)
330+
331+ number_of_hints = lambda: self.app.select_single(objectName="blockgrid").numberOfHints
332+ number_of_actions = lambda: self.app.select_single(objectName="blockgrid").numberOfActions
333+ game_seconds = lambda: self.app.select_single(objectName="blockgrid").gameSeconds
334+
335+ self.assertThat(number_of_hints, Eventually(Equals(0)))
336+ self.assertThat(number_of_actions, Eventually(Equals(0)))
337+ self.assertThat(game_seconds, Eventually(Equals(0)))
338+
339+ #----------------------------------------------------------
340+ #testing new game with always ask mode - moderate
341+ self.ubuntusdk.click_toolbar_button("newgamebutton")
342+
343+ newGameModerateButton = self.main_window.get_new_game_moderate_button()
344+ self.main_window.try_new_game_moderate_button()
345+ self.assertThat(newGameModerateButton.buttonText, Eventually(Equals("Moderate")))
346+ self.pointing_device.click_object(newGameModerateButton)
347+
348+ number_of_hints = lambda: self.app.select_single(objectName="blockgrid").numberOfHints
349+ number_of_actions = lambda: self.app.select_single(objectName="blockgrid").numberOfActions
350+ game_seconds = lambda: self.app.select_single(objectName="blockgrid").gameSeconds
351+
352+ self.assertThat(number_of_hints, Eventually(Equals(0)))
353+ self.assertThat(number_of_actions, Eventually(Equals(0)))
354+ self.assertThat(game_seconds, Eventually(Equals(0)))
355+
356+ #----------------------------------------------------------
357+ #testing new game with always ask mode - hard
358+ self.ubuntusdk.click_toolbar_button("newgamebutton")
359+
360+ newGameHardButton = self.main_window.get_new_game_hard_button()
361+ self.main_window.try_new_game_hard_button()
362+ self.assertThat(newGameHardButton.buttonText, Eventually(Equals("Hard")))
363+ self.pointing_device.click_object(newGameHardButton)
364+
365+ number_of_hints = lambda: self.app.select_single(objectName="blockgrid").numberOfHints
366+ number_of_actions = lambda: self.app.select_single(objectName="blockgrid").numberOfActions
367+ game_seconds = lambda: self.app.select_single(objectName="blockgrid").gameSeconds
368+
369+ self.assertThat(number_of_hints, Eventually(Equals(0)))
370+ self.assertThat(number_of_actions, Eventually(Equals(0)))
371+ self.assertThat(game_seconds, Eventually(Equals(0)))
372+
373+ #----------------------------------------------------------
374+ #testing new game with always ask mode - ultra hard
375+ self.ubuntusdk.click_toolbar_button("newgamebutton")
376+
377+ newGameUltraHardButton = self.main_window.get_new_game_ultrahard_button()
378+ self.main_window.try_new_game_ultrahard_button()
379+ self.assertThat(newGameUltraHardButton.buttonText, Eventually(Equals("Ultra\nHard")))
380+ self.pointing_device.click_object(newGameUltraHardButton)
381+
382+ number_of_hints = lambda: self.app.select_single(objectName="blockgrid").numberOfHints
383+ number_of_actions = lambda: self.app.select_single(objectName="blockgrid").numberOfActions
384+ game_seconds = lambda: self.app.select_single(objectName="blockgrid").gameSeconds
385+
386+ self.assertThat(number_of_hints, Eventually(Equals(0)))
387+ self.assertThat(number_of_actions, Eventually(Equals(0)))
388+ self.assertThat(game_seconds, Eventually(Equals(0)))
389+
390
391 def test_about_tab(self):
392 #Switch to the 'About' tab

Subscribers

People subscribed via source and target branches