Changeset View
Standalone View
src/gui/ksudoku.cpp
Show First 20 Lines • Show All 451 Lines • ▼ Show 20 Line(s) | 451 | { | |||
---|---|---|---|---|---|
452 | m_gameActions = new ksudoku::GameActions(actionCollection()); | 452 | m_gameActions = new ksudoku::GameActions(actionCollection()); | ||
453 | m_gameActions->init(); | 453 | m_gameActions->init(); | ||
454 | 454 | | |||
455 | QKeySequence shortcut; | 455 | QKeySequence shortcut; | ||
456 | 456 | | |||
457 | setAcceptDrops(true); | 457 | setAcceptDrops(true); | ||
458 | 458 | | |||
459 | KStandardGameAction::gameNew(this, SLOT(gameNew()), actionCollection()); | 459 | KStandardGameAction::gameNew(this, SLOT(gameNew()), actionCollection()); | ||
460 | KStandardGameAction::restart(this, SLOT(gameRestart()), actionCollection()); | ||||
460 | KStandardGameAction::load(this, SLOT(gameOpen()), actionCollection()); | 461 | KStandardGameAction::load(this, SLOT(gameOpen()), actionCollection()); | ||
461 | m_gameSave = KStandardGameAction::save(this, SLOT(gameSave()), actionCollection()); | 462 | m_gameSave = KStandardGameAction::save(this, SLOT(gameSave()), actionCollection()); | ||
462 | m_gameSaveAs = KStandardGameAction::saveAs(this, SLOT(gameSaveAs()), actionCollection()); | 463 | m_gameSaveAs = KStandardGameAction::saveAs(this, SLOT(gameSaveAs()), actionCollection()); | ||
463 | KStandardGameAction::print(this, SLOT(gamePrint()), actionCollection()); | 464 | KStandardGameAction::print(this, SLOT(gamePrint()), actionCollection()); | ||
464 | KStandardGameAction::quit(this, SLOT(close()), actionCollection()); | 465 | KStandardGameAction::quit(this, SLOT(close()), actionCollection()); | ||
465 | // TODO Export is disabled due to missing port to KDE4. | 466 | // TODO Export is disabled due to missing port to KDE4. | ||
466 | // createAction("game_export", SLOT(gameExport()), i18n("Export")); | 467 | // createAction("game_export", SLOT(gameExport()), i18n("Export")); | ||
467 | 468 | | |||
▲ Show 20 Lines • Show All 72 Lines • ▼ Show 20 Line(s) | 495 | { | |||
540 | symmetryBox->setCurrentIndex (symmetry); | 541 | symmetryBox->setCurrentIndex (symmetry); | ||
541 | } | 542 | } | ||
542 | 543 | | |||
543 | void KSudoku::adaptActions2View() { | 544 | void KSudoku::adaptActions2View() { | ||
544 | Game game = currentGame(); | 545 | Game game = currentGame(); | ||
545 | 546 | | |||
546 | m_gameSave->setEnabled(game.isValid()); | 547 | m_gameSave->setEnabled(game.isValid()); | ||
547 | m_gameSaveAs->setEnabled(game.isValid()); | 548 | m_gameSaveAs->setEnabled(game.isValid()); | ||
549 | action("game_new")->setEnabled(game.isValid()); | ||||
550 | action("game_restart")->setEnabled(game.isValid()); | ||||
551 | action("game_print")->setEnabled(game.isValid()); | ||||
548 | if(game.isValid()) { | 552 | if(game.isValid()) { | ||
549 | action("move_undo")->setEnabled(game.canUndo()); | 553 | action("move_undo")->setEnabled(game.canUndo()); | ||
aacid: spacing seems off here, also you should move this up and have it be action(bla)->setEnabled… | |||||
oh, yes. I'll do that.
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? gregormi: > also you should move this up and have it be action(bla)->setEnabled(game.isValid())
oh, yes. | |||||
About spacing: my fault. Somehow the tab width in Kate was set to 8 characters instead of 4. gregormi: About spacing: my fault. Somehow the tab width in Kate was set to 8 characters instead of 4. | |||||
Don't change the spacing policy of a file, you use whatever spacing it has, changing it is usually not a good idea. aacid: Don't change the spacing policy of a file, you use whatever spacing it has, changing it is… | |||||
Other files of the project have the spaces instead of tabs policy. Shouldn't it be harmonized somehow? gregormi: Other files of the project have the spaces instead of tabs policy. Shouldn't it be harmonized… | |||||
aacid: The problem with doing that is that it makes git blame a bit harder to use :/ | |||||
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? gregormi: Yes, I understand. What about changing those lines to spaces which are touched by a patch… | |||||
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 aacid: Then the file looks like a frankenfile. I've no idea if you can configure different spacing per… | |||||
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: ksudoku.cpp already looks like this: several code blocks have spaces whereas the most have tabs. | |||||
gregormi: And thanks for the quick review :-) | |||||
550 | action("move_redo")->setEnabled(game.canRedo()); | 554 | action("move_redo")->setEnabled(game.canRedo()); | ||
551 | 555 | | |||
552 | action("move_hint") ->setEnabled( game.puzzle()->hasSolution()); | 556 | action("move_hint") ->setEnabled( game.puzzle()->hasSolution()); | ||
553 | action("move_solve") ->setEnabled( game.puzzle()->hasSolution()); | 557 | action("move_solve") ->setEnabled( game.puzzle()->hasSolution()); | ||
554 | action("move_dub_puzzle")->setEnabled( ! game.puzzle()->hasSolution()); | 558 | action("move_dub_puzzle")->setEnabled( ! game.puzzle()->hasSolution()); | ||
555 | } else { | 559 | } else { | ||
556 | action("move_undo")->setEnabled(false); | 560 | action("move_undo")->setEnabled(false); | ||
557 | action("move_redo")->setEnabled(false); | 561 | action("move_redo")->setEnabled(false); | ||
▲ Show 20 Lines • Show All 84 Lines • ▼ Show 20 Line(s) | 643 | { | |||
642 | // button is clicked | 646 | // button is clicked | ||
643 | 647 | | |||
644 | if(!currentView()) return; | 648 | if(!currentView()) return; | ||
645 | 649 | | |||
646 | // only show question when the current game hasn't been finished until now | 650 | // only show question when the current game hasn't been finished until now | ||
647 | if(!m_gameUI->game().wasFinished()) { | 651 | if(!m_gameUI->game().wasFinished()) { | ||
648 | if(KMessageBox::questionYesNo(this, | 652 | if(KMessageBox::questionYesNo(this, | ||
649 | i18n("Do you really want to end this game in order to start a new one?"), | 653 | i18n("Do you really want to end this game in order to start a new one?"), | ||
650 | i18nc("window title", "Restart Game"), | 654 | i18nc("window title", "New Game"), | ||
651 | KGuiItem(i18nc("button label", "Restart Game")), | 655 | KGuiItem(i18nc("button label", "New Game")), | ||
652 | KStandardGuiItem::cancel() ) != KMessageBox::Yes) | 656 | KStandardGuiItem::cancel() ) != KMessageBox::Yes) | ||
653 | return; | 657 | return; | ||
654 | } | 658 | } | ||
655 | 659 | | |||
656 | showWelcomeScreen(); | 660 | showWelcomeScreen(); | ||
657 | } | 661 | } | ||
658 | 662 | | |||
663 | void KSudoku::gameRestart() | ||||
664 | { | ||||
665 | if (!currentView()) return; | ||||
666 | | ||||
667 | auto game = currentGame(); | ||||
668 | | ||||
669 | // only show question when the current game hasn't been finished until now | ||||
670 | if (!game.wasFinished()) { | ||||
671 | if (KMessageBox::questionYesNo(this, | ||||
672 | i18n("Do you really want to restart this game?"), | ||||
673 | i18nc("window title", "Restart Game"), | ||||
674 | KGuiItem(i18nc("button label", "Restart Game")), | ||||
675 | KStandardGuiItem::cancel() ) != KMessageBox::Yes) { | ||||
676 | return; | ||||
677 | } | ||||
678 | } | ||||
679 | | ||||
680 | game.restart(); | ||||
681 | } | ||||
682 | | ||||
659 | void KSudoku::gameOpen() | 683 | void KSudoku::gameOpen() | ||
660 | { | 684 | { | ||
661 | // this slot is called whenever the Game->Open menu is selected, | 685 | // this slot is called whenever the Game->Open menu is selected, | ||
662 | // the Open shortcut is pressed (usually CTRL+O) or the Open toolbar | 686 | // the Open shortcut is pressed (usually CTRL+O) or the Open toolbar | ||
663 | // button is clicked | 687 | // button is clicked | ||
664 | // standard filedialog | 688 | // standard filedialog | ||
665 | const QUrl Url = QFileDialog::getOpenFileUrl(this, i18n("Open Location"), QUrl::fromLocalFile(QDir::homePath()), QString()); | 689 | const QUrl Url = QFileDialog::getOpenFileUrl(this, i18n("Open Location"), QUrl::fromLocalFile(QDir::homePath()), QString()); | ||
666 | 690 | | |||
▲ Show 20 Lines • Show All 227 Lines • Show Last 20 Lines |
spacing seems off here, also you should move this up and have it be action(bla)->setEnabled(game.isValid())