changeset 31:d586244177ff

Fixes #244: Create "New Unit" dialog in Qt# app * Make new unit dialog unit type list use double-click on list
author IBBoard <dev@ibboard.co.uk>
date Sat, 07 Aug 2010 13:34:05 +0000
parents 56771b8efdaf
children e405b43a405b
files NewUnitDialog.cs
diffstat 1 files changed, 20 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/NewUnitDialog.cs	Wed Aug 04 19:37:23 2010 +0000
+++ b/NewUnitDialog.cs	Sat Aug 07 13:34:05 2010 +0000
@@ -33,6 +33,7 @@
 			}
 			
 			QObject.Connect(layout.unitTypeList, SIGNAL("currentRowChanged(int)"), UnitTypeSelectionChanged);
+			QObject.Connect(layout.unitTypeList, SIGNAL("itemDoubleClicked(QListWidgetItem*)"), UnitTypeDoubleClicked);
 			SetOkayButtonState(false);
 		}
 
@@ -41,14 +42,32 @@
 			SetOkayButtonState(layout.unitTypeList.CurrentRow != -1);
 		}
 		
+		private void UnitTypeDoubleClicked()
+		{
+			QPushButton button = OkayButton;
+			
+			if (button.Enabled)
+			{
+				button.Click();
+			}
+		}
+		
 		public UnitType SelectedUnit
 		{
 			get { return units[layout.unitTypeList.CurrentRow]; }
 		}
 
+		private QPushButton OkayButton
+		{
+			get
+			{
+				return layout.buttonBox.Button(QDialogButtonBox.StandardButton.Ok);
+			}
+		}
+
 		private void SetOkayButtonState(bool boolValue)
 		{
-			layout.buttonBox.Button(QDialogButtonBox.StandardButton.Ok).Enabled = boolValue;
+			OkayButton.Enabled = boolValue;
 		}
 	}
 }