[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdegames/kmines
From:       Parker Coates <parker.coates () kdemail ! net>
Date:       2010-04-19 16:46:54
Message-ID: 20100419164654.F41F9AC89D () svn ! kde ! org
[Download RAW message or body]

SVN commit 1116513 by coates:

Dynamically calculate the maximum number of mines in the custom config.

The maximum number of mines that KMines actually allows on a custom
board is WIDTH * HEIGHT - 10. Instead of hardcoding any particular
maximum, the dialog now dynamically sets the maximum value of the
mines spinbox everytime the values of the width and height spinboxes
changed.

BUG: 163806

 M  +1 -1      kmines.kcfg  
 M  +20 -3     mainwindow.cpp  


--- trunk/KDE/kdegames/kmines/kmines.kcfg #1116512:1116513
@@ -29,8 +29,8 @@
     </entry>
     <entry name="CustomMines" type="Int" key="custom mines">
       <label>The number of mines in the playing field.</label>
+      <min>1</min>
       <default>20</default>
-      <max>200</max>
     </entry>
     <entry name="level" type="Int">
       <label>The difficulty level.</label>
--- trunk/KDE/kdegames/kmines/mainwindow.cpp #1116512:1116513
@@ -16,6 +16,7 @@
     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 */
 #include "mainwindow.h"
+#include "minefielditem.h"
 #include "scene.h"
 #include "settings.h"
 #include "renderer.h"
@@ -40,12 +41,26 @@
  */
 class CustomGameConfig : public QWidget
 {
+    Q_OBJECT
+
 public:
     CustomGameConfig(QWidget *parent)
         : QWidget(parent)
-        {
-            ui.setupUi(this);
-        }
+    {
+        ui.setupUi(this);
+        connect(ui.kcfg_CustomWidth, SIGNAL(valueChanged(int)), this, SLOT(updateMaxMines()));
+        connect(ui.kcfg_CustomHeight, SIGNAL(valueChanged(int)), this, SLOT(updateMaxMines()));
+    }
+
+private slots:
+    void updateMaxMines()
+    {
+        int width = ui.kcfg_CustomWidth->value();
+        int height = ui.kcfg_CustomHeight->value();
+        int max = qMax(1, width * height - MineFieldItem::MINIMAL_FREE);
+        ui.kcfg_CustomMines->setMaximum(max);
+    }
+
 private:
     Ui::CustomGameConfig ui;
 };
@@ -58,6 +73,7 @@
     {
         ui.setupUi(this);
     }
+
 private:
     Ui::GeneralOptsConfig ui;
 };
@@ -261,3 +277,4 @@
 }
 
 #include "mainwindow.moc"
+#include "moc_mainwindow.cpp"
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic