summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/settings.cc3
-rw-r--r--src/settings.h6
-rw-r--r--src/solverwindow.cc2
-rw-r--r--src/solverwindow.h2
-rw-r--r--src/sudokuwidget.cc24
-rw-r--r--src/sudokuwidget.h4
6 files changed, 29 insertions, 12 deletions
diff --git a/src/settings.cc b/src/settings.cc
index 94504d2..19e3c17 100644
--- a/src/settings.cc
+++ b/src/settings.cc
@@ -15,7 +15,8 @@ const Settings & globalSettings()
Settings::Settings() :
m_homePath(),
m_colorInvalidValue(255, 0, 0),
- m_colorInputError(195, 195, 195)
+ m_colorInputError(195, 195, 195),
+ m_colorSolved(192, 255, 192)
{
#ifdef _WIN32
// get the full path for "Applicaton Data"
diff --git a/src/settings.h b/src/settings.h
index 319bcb1..229d67a 100644
--- a/src/settings.h
+++ b/src/settings.h
@@ -22,10 +22,16 @@ public:
return m_colorInputError;
}
+ inline const QColor & colorSolved() const
+ {
+ return m_colorSolved;
+ }
+
private:
QString m_homePath;
QColor m_colorInvalidValue;
QColor m_colorInputError;
+ QColor m_colorSolved;
};
const Settings & globalSettings();
diff --git a/src/solverwindow.cc b/src/solverwindow.cc
index 410868c..623caa3 100644
--- a/src/solverwindow.cc
+++ b/src/solverwindow.cc
@@ -133,7 +133,7 @@ void SolverWindow::doRevert()
bool SolverWindow::confirmOverwrite(const QString & filename)
{
- QFile file (solverwindow_filename);
+ QFile file (filename);
if (file.exists()) {
QFileInfo fileinfo(file);
return (QMessageBox::warning(this, tr("Overwrite file?"), tr("The file \"%1\" already exists.\nDo you wish to overwrite it?").arg(fileinfo.fileName()), QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes);
diff --git a/src/solverwindow.h b/src/solverwindow.h
index 3a7daf1..4729218 100644
--- a/src/solverwindow.h
+++ b/src/solverwindow.h
@@ -52,7 +52,7 @@ signals:
private:
void step_constraints();
- void step_coverage();
+ void step_coverage();
void saveToFile(const QString & filename);
void openFromFile(const QString & filename);
diff --git a/src/sudokuwidget.cc b/src/sudokuwidget.cc
index 78e90fd..387f5d4 100644
--- a/src/sudokuwidget.cc
+++ b/src/sudokuwidget.cc
@@ -20,7 +20,7 @@ SudokuWidget::SudokuWidget()
}
}
-void SudokuWidget::verify(const QString & text)
+void SudokuWidget::verify()
{
Sudoku values;
for (int row = 0; row < 9; row++) {
@@ -41,7 +41,7 @@ void SudokuWidget::verify(const QString & text)
}
}
- values.validate();
+ bool solved = values.solved();
for (int row = 0; row < 9; row++) {
for (int column = 0; column < 9 ; column++) {
@@ -49,7 +49,9 @@ void SudokuWidget::verify(const QString & text)
int i = values.cell(row, column).value();
if ( (i > 0) && (i <= 9) ) {
// set background color depending on the validity of the cell value
- if (!values.cell(row, column).valid()) {
+ if (solved) {
+ child_palette.setColor(QPalette::Base, globalSettings().colorSolved());
+ } else if (!values.cell(row, column).valid()) {
child_palette.setColor(QPalette::Base, globalSettings().colorInvalidValue());
}
sudokuwidget_value[row][column]->setPalette(child_palette);
@@ -58,6 +60,10 @@ void SudokuWidget::verify(const QString & text)
}
}
+void SudokuWidget::verify(const QString & text) {
+ verify();
+}
+
QSize SudokuWidget::sizeHint () const
{
return QSize(512, 512);
@@ -83,6 +89,8 @@ void SudokuWidget::set_values(const Sudoku & values)
sudokuwidget_value[row][column]->setPalette(child_palette);
}
}
+
+ verify();
}
void SudokuWidget::get_values(Sudoku & values)
@@ -103,22 +111,22 @@ void SudokuWidget::get_values(Sudoku & values)
void SudokuWidget::resizeEvent(QResizeEvent *event)
{
+ // cell size
int sgx = width() / 9;
- int sgy = height() / 9;
-
- // offset
+ int sgy = height() / 9;
if (sgx > sgy) {
sgx = sgy;
} else {
sgy = sgx;
}
+
+ // offset, used to center the grid inside the widget
int offset_x = (width() - 9 * sgx) / 2;
int offset_y = (height() - 9 * sgy) / 2;
QFont font("default", 16);
font.setPixelSize(sgx / 2);
-
-
+
for (int row = 0; row < 9; row++) {
for (int column = 0; column < 9 ; column++) {
sudokuwidget_value[row][column]->setFont(font);
diff --git a/src/sudokuwidget.h b/src/sudokuwidget.h
index e4140a0..9ca6098 100644
--- a/src/sudokuwidget.h
+++ b/src/sudokuwidget.h
@@ -30,7 +30,7 @@ public:
* @brief return the default size hint for this widget
* */
virtual QSize sizeHint() const;
-
+
protected:
/**
* @brief handle paint events
@@ -46,6 +46,8 @@ private:
QLineEdit * sudokuwidget_value[9][9];
private slots:
+ void verify();
+
void verify(const QString & text);
};