Implement wish 319522: Option to restart current game
ClosedPublic

Authored by gregormi on May 15 2018, 8:33 PM.

Details

Summary

BUG: 319522

  • Add a new action "Restart Game" between "New" and "Print" to the menu and toolbar
  • "Restart Game" asks for confirmation if game is not finished yet
  • The "Restart Game" button is only active if a game is running

Related changes:

  • Change the confirmation text that appears when the user clicks the "New" button to "New Game" instead of the confusing "Restart Game"
  • The "New" and "Print" buttons are now only available if a game is running (on the welcome screen clicking "New" had no effect, clicking "Print" showed a message box that there is nothing to print)

Diff Detail

Repository
R417 KSudoku
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
gregormi created this revision.May 15 2018, 8:33 PM
Restricted Application added a reviewer: KDE Games. · View Herald TranscriptMay 15 2018, 8:33 PM
Restricted Application added a subscriber: kde-games-devel. · View Herald Transcript
gregormi requested review of this revision.May 15 2018, 8:33 PM
gregormi retitled this revision from Fix Bug 319522: Option to restart current game to Implement wish 319522: Option to restart current game.May 15 2018, 8:42 PM
aacid added a subscriber: aacid.May 15 2018, 9:13 PM
aacid added inline comments.
src/gui/ksudoku.cpp
553

spacing seems off here, also you should move this up and have it be action(bla)->setEnabled(game.isValid())

src/gui/ksudokugame.h
119

spacing is also off.

src/gui/ksudokuui.rc
3

You need to increase the version if you add stuff

gregormi added inline comments.May 15 2018, 9:35 PM
src/gui/ksudoku.cpp
553

also you should move this up and have it be action(bla)->setEnabled(game.isValid())

oh, yes. I'll do that.

spacing seems off here

This is because this file uses tabs instead of spaces. I would convert the file in a separate commit after the patch is accepted or should I do it at once?

src/gui/ksudokugame.h
119

Because of tabs, see above.

gregormi added inline comments.May 15 2018, 9:40 PM
src/gui/ksudoku.cpp
553

About spacing: my fault. Somehow the tab width in Kate was set to 8 characters instead of 4.

gregormi updated this revision to Diff 34231.May 15 2018, 9:45 PM
  • fix whitespace and improve if statement
aacid added inline comments.May 15 2018, 9:47 PM
src/gui/ksudoku.cpp
553

Don't change the spacing policy of a file, you use whatever spacing it has, changing it is usually not a good idea.

gregormi marked 2 inline comments as done.May 15 2018, 9:55 PM
gregormi added inline comments.
src/gui/ksudoku.cpp
553

Other files of the project have the spaces instead of tabs policy. Shouldn't it be harmonized somehow?

gregormi updated this revision to Diff 34232.May 15 2018, 9:58 PM
gregormi marked an inline comment as done.
  • use tabs instead of spaces
gregormi marked 2 inline comments as done.May 15 2018, 9:59 PM
gregormi added inline comments.
src/gui/ksudokugame.h
119

Use now tabs for this.

gregormi updated this revision to Diff 34234.May 15 2018, 10:01 PM
gregormi marked an inline comment as done.
  • ksudokuui.rc: increase version
gregormi marked an inline comment as done.May 15 2018, 10:02 PM
gregormi added inline comments.
src/gui/ksudokuui.rc
3

Done. (This file contains a mixed policy of spaces and tabs: first element spaces, rest tabs)

gregormi marked 3 inline comments as done.May 15 2018, 10:03 PM
aacid added inline comments.May 15 2018, 10:08 PM
src/gui/ksudoku.cpp
553

The problem with doing that is that it makes git blame a bit harder to use :/

gregormi added inline comments.May 15 2018, 10:11 PM
src/gui/ksudoku.cpp
553

Yes, I understand. What about changing those lines to spaces which are touched by a patch anyway. Can I configure Kate or KDevelop to have a spacing policy per file?

aacid added inline comments.May 15 2018, 10:27 PM
src/gui/ksudoku.cpp
553

Then the file looks like a frankenfile. I've no idea if you can configure different spacing per file other than changing it using the statusbar widgets on each file

gregormi added inline comments.May 15 2018, 10:38 PM
src/gui/ksudoku.cpp
553

ksudoku.cpp already looks like this: several code blocks have spaces whereas the most have tabs. Anyway, I'll change my spaces to tabs.

gregormi updated this revision to Diff 34242.May 15 2018, 10:49 PM
  • use tabs in files where mostly tabs instead of spaces are used
gregormi marked 6 inline comments as done.May 15 2018, 10:49 PM
gregormi added inline comments.
src/gui/ksudoku.cpp
553

And thanks for the quick review :-)

aacid added a comment.May 16 2018, 6:09 PM

Do you think it's a good idea that the undo stack is not wiped when doing restart?

I.e. you can do restart and then you can do redo.

I don't have an opinion, just want to know if it's on purpose or a side effect of the implementation of ::restart

gregormi updated this revision to Diff 34685.May 23 2018, 6:58 AM
  • clear history on restart

Do you think it's a good idea that the undo stack is not wiped when doing restart?

I.e. you can do restart and then you can do redo.

I don't have an opinion, just want to know if it's on purpose or a side effect of the implementation of ::restart

It was not on purpose. I changed the implementation accordingly.

aacid accepted this revision.May 25 2018, 11:03 PM
This revision is now accepted and ready to land.May 25 2018, 11:03 PM
gregormi edited the summary of this revision. (Show Details)May 30 2018, 8:59 AM
gregormi edited the summary of this revision. (Show Details)
This revision was automatically updated to reflect the committed changes.