Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Disable actions if undo/save stacks are empty

  • Loading branch information...
commit 108a9899d500673fccf720cf74370e9f68e27814 1 parent ea57b30
@schuay authored
Showing with 18 additions and 2 deletions.
  1. +14 −2 src/gui/mainwindow.cpp
  2. +4 −0 src/gui/mainwindow.h
View
16 src/gui/mainwindow.cpp
@@ -148,6 +148,16 @@ void MainWindow::toggleFullscreen(bool full_screen) {
}
}
+void MainWindow::undoStackSizeChanged(int size)
+{
+ m_action_undo->setEnabled(size != 0);
+}
+
+void MainWindow::saveStackSizeChanged(int size)
+{
+ m_action_load_state->setEnabled(size != 0);
+}
+
void MainWindow::closeEvent(QCloseEvent *event) {
saveWindowState();
KXmlGuiWindow::closeEvent(event);
@@ -203,9 +213,9 @@ void MainWindow::startGame() {
disconnect(&m_timer, SIGNAL(timeout()), this, SLOT(updatePlayedTime()));
}
- m_action_undo->setEnabled(true);
+ m_action_undo->setEnabled(false);
m_action_save_state->setEnabled(true);
- m_action_load_state->setEnabled(true);
+ m_action_load_state->setEnabled(false);
m_action_pause->setEnabled(true);
m_action_pause->setChecked(false);
#ifdef HAVE_KGDIFFICULTY
@@ -226,6 +236,8 @@ void MainWindow::startGame() {
connect(&m_timer, SIGNAL(timeout()), this, SLOT(updatePlayedTime()));
connect(m_game.data(), SIGNAL(stateChanged()), this, SLOT(updatePositions()));
connect(m_game.data(), SIGNAL(gameWon()), this, SLOT(gameWon()));
+ connect(m_game.data(), SIGNAL(undoStackSizeChanged(int)), this, SLOT(undoStackSizeChanged(int)));
+ connect(m_game.data(), SIGNAL(saveStackSizeChanged(int)), this, SLOT(saveStackSizeChanged(int)));
m_in_progress = true;
}
View
4 src/gui/mainwindow.h
@@ -70,6 +70,10 @@ private slots:
void loadBoard();
void toggleFullscreen(bool full_screen);
+ /* Enable or disable undo/save state related actions. */
+ void undoStackSizeChanged(int size);
+ void saveStackSizeChanged(int size);
+
private:
enum Mode {
Random, /* board is randomly generated, highscores enabled */
Please sign in to comment.
Something went wrong with that request. Please try again.