Mercurial > repos > IBBoard.WarFoundry.GUI.QtSharp
diff NewArmyDialog.cs @ 8:8a8735679d55
Re #243: Create "New Army" dialog in Qt# app
* Disable "OK" button on army creation form
* Add event hooks and methods to enable OK Button when all values are completed
* Set properties on spinbox
Still need to work out how to stop dialog showing up in task bar.
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Sat, 30 Jan 2010 20:57:36 +0000 |
parents | bbf40d66dfe4 |
children | 3d0c9cf1b924 |
line wrap: on
line diff
--- a/NewArmyDialog.cs Sat Jan 30 20:02:32 2010 +0000 +++ b/NewArmyDialog.cs Sat Jan 30 20:57:36 2010 +0000 @@ -27,6 +27,14 @@ PopulateControls(); layout.gameSystems.CurrentIndex = -1; QObject.Connect(layout.gameSystems, SIGNAL("currentIndexChanged(int)"), GameSystemSelectionChanged); + QObject.Connect(layout.armyName, SIGNAL("textChanged(QString)"), ArmyNameChanged); + QObject.Connect(layout.armySize, SIGNAL("valueChanged(int)"), ArmySizeChanged); + SetOkayButtonState(false); + } + + private void SetOkayButtonState (bool boolValue) + { + layout.buttonBox.Button(QDialogButtonBox.StandardButton.Ok).Enabled = boolValue; } private void PopulateControls() @@ -41,6 +49,7 @@ private void GameSystemSelectionChanged() { + ValidateForm(); layout.raceList.Clear(); if (layout.gameSystems.CurrentIndex != -1) @@ -54,6 +63,15 @@ } } + private void ValidateForm() + { + bool complete = (layout.gameSystems.CurrentIndex != -1); + complete &= (layout.raceList.CurrentRow != -1); + complete &= (layout.armyName.Text != ""); + complete &= (layout.armySize.Value > 0); + SetOkayButtonState(complete); + } + private GameSystem GetSelectedSystem() { GameSystem system = null; @@ -66,5 +84,15 @@ return system; } + + private void ArmyNameChanged() + { + ValidateForm(); + } + + private void ArmySizeChanged() + { + ValidateForm(); + } } }