changeset 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 09bc9a4df412
children 6bbc5c08c06d
files NewArmyDialog.cs qt-gui/CreateNewArmyLayout.cs qt-gui/CreateNewArmyLayout.ui
diffstat 3 files changed, 55 insertions(+), 2 deletions(-) [+]
line diff
     1.1 --- a/NewArmyDialog.cs	Sat Jan 30 20:02:32 2010 +0000
     1.2 +++ b/NewArmyDialog.cs	Sat Jan 30 20:57:36 2010 +0000
     1.3 @@ -27,6 +27,14 @@
     1.4  			PopulateControls();
     1.5  			layout.gameSystems.CurrentIndex = -1;
     1.6  			QObject.Connect(layout.gameSystems, SIGNAL("currentIndexChanged(int)"), GameSystemSelectionChanged);
     1.7 +			QObject.Connect(layout.armyName, SIGNAL("textChanged(QString)"), ArmyNameChanged);
     1.8 +			QObject.Connect(layout.armySize, SIGNAL("valueChanged(int)"), ArmySizeChanged);
     1.9 +			SetOkayButtonState(false);
    1.10 +		}
    1.11 +		
    1.12 +		private void SetOkayButtonState (bool boolValue)
    1.13 +		{
    1.14 +			layout.buttonBox.Button(QDialogButtonBox.StandardButton.Ok).Enabled = boolValue;
    1.15  		}
    1.16  		
    1.17  		private void PopulateControls()
    1.18 @@ -41,6 +49,7 @@
    1.19  		
    1.20  		private void GameSystemSelectionChanged()
    1.21  		{
    1.22 +			ValidateForm();
    1.23  			layout.raceList.Clear();
    1.24  			
    1.25  			if (layout.gameSystems.CurrentIndex != -1)
    1.26 @@ -54,6 +63,15 @@
    1.27  			}				
    1.28  		}
    1.29  		
    1.30 +		private void ValidateForm()
    1.31 +		{
    1.32 +			bool complete = (layout.gameSystems.CurrentIndex != -1);
    1.33 +			complete &= (layout.raceList.CurrentRow != -1);
    1.34 +			complete &= (layout.armyName.Text != "");
    1.35 +			complete &= (layout.armySize.Value > 0);
    1.36 +			SetOkayButtonState(complete);
    1.37 +		}
    1.38 +		
    1.39  		private GameSystem GetSelectedSystem()
    1.40  		{
    1.41  			GameSystem system = null;			
    1.42 @@ -66,5 +84,15 @@
    1.43  			
    1.44  			return system;
    1.45  		}
    1.46 +		
    1.47 +		private void ArmyNameChanged()
    1.48 +		{
    1.49 +			ValidateForm();
    1.50 +		}
    1.51 +		
    1.52 +		private void ArmySizeChanged()
    1.53 +		{
    1.54 +			ValidateForm();
    1.55 +		}
    1.56  	}
    1.57  }
     2.1 --- a/qt-gui/CreateNewArmyLayout.cs	Sat Jan 30 20:02:32 2010 +0000
     2.2 +++ b/qt-gui/CreateNewArmyLayout.cs	Sat Jan 30 20:57:36 2010 +0000
     2.3 @@ -1,7 +1,7 @@
     2.4  /********************************************************************************
     2.5  ** Form generated from reading ui file 'CreateNewArmyLayout.ui'
     2.6  **
     2.7 -** Created: Wed Jan 27 20:53:01 2010
     2.8 +** Created: Sat Jan 30 20:56:06 2010
     2.9  **      by: Qt User Interface Compiler for C# version 4.5.3
    2.10  **
    2.11  ** WARNING! All changes made in this file will be lost when recompiling ui file!
    2.12 @@ -27,6 +27,7 @@
    2.13      {
    2.14      if (CreateNewArmyLayout.ObjectName == "")
    2.15          CreateNewArmyLayout.ObjectName = "CreateNewArmyLayout";
    2.16 +    CreateNewArmyLayout.WindowModality = Qt.WindowModality.WindowModal;
    2.17      QSize Size = new QSize(400, 300);
    2.18      Size = Size.ExpandedTo(CreateNewArmyLayout.MinimumSizeHint());
    2.19      CreateNewArmyLayout.Size = Size;
    2.20 @@ -70,6 +71,11 @@
    2.21  
    2.22      armySize = new QSpinBox(CreateNewArmyLayout);
    2.23      armySize.ObjectName = "armySize";
    2.24 +    armySize.Frame = true;
    2.25 +    armySize.buttonSymbols = QAbstractSpinBox.ButtonSymbols.UpDownArrows;
    2.26 +    armySize.Maximum = 100000;
    2.27 +    armySize.SingleStep = 10;
    2.28 +    armySize.Value = 2000;
    2.29  
    2.30      gridLayout.AddWidget(armySize, 3, 2, 1, 1);
    2.31  
     3.1 --- a/qt-gui/CreateNewArmyLayout.ui	Sat Jan 30 20:02:32 2010 +0000
     3.2 +++ b/qt-gui/CreateNewArmyLayout.ui	Sat Jan 30 20:57:36 2010 +0000
     3.3 @@ -2,6 +2,9 @@
     3.4  <ui version="4.0">
     3.5   <class>CreateNewArmyLayout</class>
     3.6   <widget class="QDialog" name="CreateNewArmyLayout">
     3.7 +  <property name="windowModality">
     3.8 +   <enum>Qt::WindowModal</enum>
     3.9 +  </property>
    3.10    <property name="geometry">
    3.11     <rect>
    3.12      <x>0</x>
    3.13 @@ -68,7 +71,23 @@
    3.14      </widget>
    3.15     </item>
    3.16     <item row="3" column="2">
    3.17 -    <widget class="QSpinBox" name="armySize"/>
    3.18 +    <widget class="QSpinBox" name="armySize">
    3.19 +     <property name="frame">
    3.20 +      <bool>true</bool>
    3.21 +     </property>
    3.22 +     <property name="buttonSymbols">
    3.23 +      <enum>QAbstractSpinBox::UpDownArrows</enum>
    3.24 +     </property>
    3.25 +     <property name="maximum">
    3.26 +      <number>100000</number>
    3.27 +     </property>
    3.28 +     <property name="singleStep">
    3.29 +      <number>10</number>
    3.30 +     </property>
    3.31 +     <property name="value">
    3.32 +      <number>2000</number>
    3.33 +     </property>
    3.34 +    </widget>
    3.35     </item>
    3.36     <item row="2" column="2">
    3.37      <widget class="QLineEdit" name="armyName"/>