Mercurial > repos > IBBoard.WarFoundry.GUI.QtSharp
comparison NewUnitDialog.cs @ 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 | 246237c88b9b |
children |
comparison
equal
deleted
inserted
replaced
30:56771b8efdaf | 31:d586244177ff |
---|---|
31 allowed[i] = army.CanAddUnitType(unit).Count == 0; | 31 allowed[i] = army.CanAddUnitType(unit).Count == 0; |
32 layout.unitTypeList.AddItem(unit.Name); | 32 layout.unitTypeList.AddItem(unit.Name); |
33 } | 33 } |
34 | 34 |
35 QObject.Connect(layout.unitTypeList, SIGNAL("currentRowChanged(int)"), UnitTypeSelectionChanged); | 35 QObject.Connect(layout.unitTypeList, SIGNAL("currentRowChanged(int)"), UnitTypeSelectionChanged); |
36 QObject.Connect(layout.unitTypeList, SIGNAL("itemDoubleClicked(QListWidgetItem*)"), UnitTypeDoubleClicked); | |
36 SetOkayButtonState(false); | 37 SetOkayButtonState(false); |
37 } | 38 } |
38 | 39 |
39 private void UnitTypeSelectionChanged() | 40 private void UnitTypeSelectionChanged() |
40 { | 41 { |
41 SetOkayButtonState(layout.unitTypeList.CurrentRow != -1); | 42 SetOkayButtonState(layout.unitTypeList.CurrentRow != -1); |
42 } | 43 } |
43 | 44 |
45 private void UnitTypeDoubleClicked() | |
46 { | |
47 QPushButton button = OkayButton; | |
48 | |
49 if (button.Enabled) | |
50 { | |
51 button.Click(); | |
52 } | |
53 } | |
54 | |
44 public UnitType SelectedUnit | 55 public UnitType SelectedUnit |
45 { | 56 { |
46 get { return units[layout.unitTypeList.CurrentRow]; } | 57 get { return units[layout.unitTypeList.CurrentRow]; } |
47 } | 58 } |
48 | 59 |
60 private QPushButton OkayButton | |
61 { | |
62 get | |
63 { | |
64 return layout.buttonBox.Button(QDialogButtonBox.StandardButton.Ok); | |
65 } | |
66 } | |
67 | |
49 private void SetOkayButtonState(bool boolValue) | 68 private void SetOkayButtonState(bool boolValue) |
50 { | 69 { |
51 layout.buttonBox.Button(QDialogButtonBox.StandardButton.Ok).Enabled = boolValue; | 70 OkayButton.Enabled = boolValue; |
52 } | 71 } |
53 } | 72 } |
54 } | 73 } |
55 | 74 |