Mercurial > repos > IBBoard.WarFoundry.GUI.QtSharp
comparison MainWindow.cs @ 29:246237c88b9b
Re #244: Create "New Unit" dialog in Qt# app
* Add NewUnit dialog
* Fix layout (rename layout and make list enabled)
* Call dialog when clicking on buttons
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Tue, 03 Aug 2010 19:36:49 +0000 |
parents | 5ee15def17e7 |
children | 56771b8efdaf |
comparison
equal
deleted
inserted
replaced
28:5ee15def17e7 | 29:246237c88b9b |
---|---|
13 using IBBoard.WarFoundry.API.Exporters; | 13 using IBBoard.WarFoundry.API.Exporters; |
14 using IBBoard.WarFoundry.API.Factories; | 14 using IBBoard.WarFoundry.API.Factories; |
15 using IBBoard.WarFoundry.API.Objects; | 15 using IBBoard.WarFoundry.API.Objects; |
16 using IBBoard.WarFoundry.API.Savers; | 16 using IBBoard.WarFoundry.API.Savers; |
17 using IBBoard.WarFoundry.GUI.QtSharp.Handler; | 17 using IBBoard.WarFoundry.GUI.QtSharp.Handler; |
18 using IBBoard.WarFoundry.API.Commands; | |
18 | 19 |
19 namespace IBBoard.WarFoundry.GUI.QtSharp | 20 namespace IBBoard.WarFoundry.GUI.QtSharp |
20 { | 21 { |
21 public class MainWindow : QMainWindow | 22 public class MainWindow : QMainWindow |
22 { | 23 { |
108 private void CreateNewArmy() | 109 private void CreateNewArmy() |
109 { | 110 { |
110 if (CloseCurrentArmy()) | 111 if (CloseCurrentArmy()) |
111 { | 112 { |
112 NewArmyDialog dialog = new NewArmyDialog(this); | 113 NewArmyDialog dialog = new NewArmyDialog(this); |
113 int result = dialog.Exec (); | 114 int result = dialog.Exec(); |
114 | 115 |
115 if (result == (int)QDialog.DialogCode.Accepted) | 116 if (result == (int)QDialog.DialogCode.Accepted) |
116 { | 117 { |
117 try | 118 try |
118 { | 119 { |
520 | 521 |
521 foreach (Category category in categories) | 522 foreach (Category category in categories) |
522 { | 523 { |
523 QAction action = new QAction(this); | 524 QAction action = new QAction(this); |
524 action.icon = new QIcon("icons/ui/add.png"); | 525 action.icon = new QIcon("icons/ui/add.png"); |
525 NewUnitEventHandler handler = new NewUnitEventHandler(category, AddUnit); | 526 NewUnitEventHandler handler = new NewUnitEventHandler(category, AddUnitFromCategory); |
526 ConnectMenuAction(action, handler.CreateNewUnit); | 527 ConnectMenuAction(action, handler.CreateNewUnit); |
527 categoryActions[i] = action; | 528 categoryActions[i] = action; |
528 layout.toolBar.AddAction(action); | 529 layout.toolBar.AddAction(action); |
529 i++; | 530 i++; |
530 } | 531 } |
531 } | 532 } |
532 } | 533 } |
533 | 534 |
534 private void AddUnit(Category cat) | 535 private void AddUnitFromCategory(Category cat) |
535 { | 536 { |
536 QMessageBox.Information(this, "Add unit", cat.Name); | 537 NewUnitDialog newUnit = new NewUnitDialog(this, CurrentArmy.Race, cat, CurrentArmy); |
538 int result = newUnit.Exec(); | |
539 | |
540 if (result == (int)QDialog.DialogCode.Accepted) | |
541 { | |
542 CreateAndAddUnitCommand cmd = new CreateAndAddUnitCommand(newUnit.SelectedUnit, CurrentArmy.GetCategory(cat)); | |
543 CommandStack.Execute(cmd); | |
544 OpenUnitDialog(cmd.Unit); | |
545 } | |
546 } | |
547 | |
548 private void OpenUnitDialog(Unit unit) | |
549 { | |
550 | |
537 } | 551 } |
538 | 552 |
539 void EnableCategoryButtons () | 553 void EnableCategoryButtons () |
540 { | 554 { |
541 //TODO enable category buttons | 555 //TODO enable category buttons |