summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2013-07-12 22:14:33 +0000
committerStijn Buys <ingar@osirion.org>2013-07-12 22:14:33 +0000
commit9b45d1a3f15a7d37c6e206ce2fdcb43972113b29 (patch)
tree8e11d6eeb7bd7a0a638e20ab23d7e560c6381c2b
parent359fd932e5925dff7dd722bd9bb2aa463210badd (diff)
Set PACKAGE_NAME and PACKAGE_VERSION from the configure script and use PACKAGE_NAME in the application window title,
adds Help -> About, defines color constants and marks invalid input.
-rw-r--r--src/mainwindow.cc24
-rw-r--r--src/mainwindow.h6
-rw-r--r--src/solverwindow.cc1
-rw-r--r--src/sudokuwidget.cc27
4 files changed, 47 insertions, 11 deletions
diff --git a/src/mainwindow.cc b/src/mainwindow.cc
index 7cfdf4b..adb45e6 100644
--- a/src/mainwindow.cc
+++ b/src/mainwindow.cc
@@ -2,6 +2,8 @@
#include "mainwindow.h"
#include "solverwindow.h"
+#include "config.h"
+
/* XPM */
const char *icon_xpm[] = {
"16 16 2 1",
@@ -107,6 +109,11 @@ void MainWindow::initActions()
action_validate = new QAction(tr("Validate"), this);
action_validate ->setStatusTip(tr("Validate the sudoku"));
connect(action_validate, SIGNAL(triggered()), this, SLOT(doValidate()));
+
+ // Help -> About
+ action_about = new QAction(tr("About..."), this);
+ action_about ->setStatusTip(tr("About %1").arg(PACKAGE_NAME));
+ connect(action_about, SIGNAL(triggered()), this, SLOT(doAbout()));
}
void MainWindow::initMenus()
@@ -130,17 +137,20 @@ void MainWindow::initMenus()
mainwindow_movemenu->addAction(action_search);
mainwindow_movemenu->addSeparator();
mainwindow_movemenu->addAction(action_validate);
+
+ mainwindow_helpmenu = menuBar()->addMenu(tr("&Help"));
+ mainwindow_helpmenu->addAction(action_about);
}
void MainWindow::updateTitle()
{
if (mainwindow_solverwindow->filename().isEmpty()) {
- setWindowTitle("Sudoku");
+ setWindowTitle(PACKAGE_NAME);
action_revert->setEnabled(false);
} else {
- setWindowTitle(mainwindow_solverwindow->filename() + " - Sudoku");
+ setWindowTitle(mainwindow_solverwindow->filename() + " - " + PACKAGE_NAME);
action_revert->setEnabled(true);
}
@@ -187,3 +197,13 @@ void MainWindow::doQuit()
qApp->closeAllWindows();
}
}
+
+void MainWindow::doAbout()
+{
+ QMessageBox::information(this, tr("About %1").arg(PACKAGE_NAME),
+ tr("%1 version %2\n\n"
+ "This application was written by Stijn 'Ingar' Buys and "
+ "is available under the terms and conditions of the GNU Public License, version 3 or higher.")
+ .arg(PACKAGE_NAME)
+ .arg(PACKAGE_VERSION));
+}
diff --git a/src/mainwindow.h b/src/mainwindow.h
index 27a1f33..b928c68 100644
--- a/src/mainwindow.h
+++ b/src/mainwindow.h
@@ -27,6 +27,7 @@ private:
SolverWindow *mainwindow_solverwindow;
QMenu *mainwindow_gamemenu;
QMenu *mainwindow_movemenu;
+ QMenu *mainwindow_helpmenu;
// Game menu actions
QAction *action_new;
@@ -44,6 +45,9 @@ private:
QAction *action_search;
QAction *action_validate;
+ // Help menu actions
+ QAction *action_about;
+
private slots:
void doNew();
@@ -54,6 +58,8 @@ private slots:
void doQuit();
void doValidate();
+
+ void doAbout();
};
diff --git a/src/solverwindow.cc b/src/solverwindow.cc
index bb9a2ec..ed01048 100644
--- a/src/solverwindow.cc
+++ b/src/solverwindow.cc
@@ -16,7 +16,6 @@
* The homepath should probably be a setting.
* This should move to mainwindow
* */
-
const QString HOMEDIR(QDir::homePath() + "/.sudoku");
SolverWindow::SolverWindow()
diff --git a/src/sudokuwidget.cc b/src/sudokuwidget.cc
index 75fc3be..c870663 100644
--- a/src/sudokuwidget.cc
+++ b/src/sudokuwidget.cc
@@ -5,6 +5,16 @@
#include <QGridLayout>
#include <QString>
+/*
+ * TODO
+ * This should be moved into a global configuration sectoion
+ * with a settings dialog
+ * */
+const QColor color_invalid_value(255, 0, 0);
+const QColor color_input_error(195, 195, 195);
+
+
+
SudokuWidget::SudokuWidget()
{
for (int row = 0; row < 9; row++) {
@@ -31,6 +41,11 @@ void SudokuWidget::verify(const QString & text)
values.cell(row, column).set_value(i);
} else {
values.cell(row, column).set_value(0);
+ QPalette child_palette(palette());
+ if (!sudokuwidget_value[row][column]->text().isEmpty()) {
+ child_palette.setColor(QPalette::Base, color_input_error);
+ }
+ sudokuwidget_value[row][column]->setPalette(child_palette);
}
}
}
@@ -44,11 +59,10 @@ void SudokuWidget::verify(const QString & text)
if ( (i > 0) && (i <= 9) ) {
// set background color depending on the validity of the cell value
if (!values.cell(row, column).valid()) {
- // FIXME colors should be configurable
- child_palette.setColor(QPalette::Base, QColor(255, 0, 0));
+ child_palette.setColor(QPalette::Base, color_invalid_value);
}
+ sudokuwidget_value[row][column]->setPalette(child_palette);
}
- sudokuwidget_value[row][column]->setPalette(child_palette);
}
}
}
@@ -69,11 +83,8 @@ void SudokuWidget::set_values(const Sudoku & values)
sudokuwidget_value[row][column]->setText(str);
// set background color depending on the validity of the cell value
- if (values.cell(row, column).valid()) {
- //child_palette.setColor(QPalette::Base, QColor(0, 0, 255));
- } else {
- // FIXME colors should be configurable
- child_palette.setColor(QPalette::Base, QColor(255, 0, 0));
+ if (!values.cell(row, column).valid()) {
+ child_palette.setColor(QPalette::Base, color_invalid_value);
}
} else {
sudokuwidget_value[row][column]->clear();