changeset 11:72bcf6457227

Re #247: Implement menu options in Qt# app * Implement initial save and save as functionality
author IBBoard <dev@ibboard.co.uk>
date Fri, 05 Feb 2010 20:37:30 +0000
parents 3d0c9cf1b924
children 4a724378d66a
files MainWindow.cs
diffstat 1 files changed, 19 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/MainWindow.cs	Tue Feb 02 20:56:39 2010 +0000
+++ b/MainWindow.cs	Fri Feb 05 20:37:30 2010 +0000
@@ -58,6 +58,8 @@
 			QObject.Connect(layout.actionCreateArmy, SIGNAL("triggered()"), CreateNewArmy);
 			QObject.Connect(layout.actionUndo, SIGNAL("triggered()"), UndoAction);
 			QObject.Connect(layout.actionRedo, SIGNAL("triggered()"), RedoAction);
+			QObject.Connect(layout.actionSaveArmyAs, SIGNAL("triggered()"), DoSaveCurrentArmyAs);
+			QObject.Connect(layout.actionSaveArmy, SIGNAL("triggered()"), DoSaveCurrentArmy);
 		}
 		
 		private void CreateNewArmy()
@@ -97,7 +99,7 @@
 			layout.toolBar.AddSeparator();
 		}		
 
-		private void HandleWarFoundryCoreArmyChanged (Army oldValue, Army newValue)
+		private void HandleWarFoundryCoreArmyChanged(Army oldValue, Army newValue)
 		{
 			CommandStack.Reset();
 			loadedFilePath = null;
@@ -142,9 +144,9 @@
 			}
 		}
 
-		private void HandleCommandStackCommandStackUpdated ()
+		private void HandleCommandStackCommandStackUpdated()
 		{
-			
+			layout.actionSaveArmy.Enabled = CommandStack.IsDirty();
 		}
 
 		private void UndoAction()
@@ -162,6 +164,11 @@
 				commandStack.Redo();
 			}
 		}
+		
+		private void DoSaveCurrentArmy()
+		{
+			SaveCurrentArmy();
+		}
 
 		private bool SaveCurrentArmy()
 		{
@@ -182,6 +189,11 @@
 			return saved;
 		}
 
+		private void DoSaveCurrentArmyAs()
+		{
+			SaveCurrentArmyAs();
+		}
+		
 		private bool SaveCurrentArmyAs()
 		{
 			bool saved = false;
@@ -214,15 +226,14 @@
 		private string PromptForArmyFilePath()
 		{
 			int result = saveArmyDialog.Exec();
+			string path = null;
 
 			if (result == (int)QDialog.DialogCode.Accepted)
 			{
-				return saveArmyDialog.SelectedFiles()[0];
+				path = saveArmyDialog.SelectedFiles()[0];
 			}
-			else
-			{
-				return null;
-			}
+			
+			return path;
 		}		
 
 		public GameSystem CurrentGameSystem