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 diff
     1.1 --- a/MainWindow.cs	Tue Feb 02 20:56:39 2010 +0000
     1.2 +++ b/MainWindow.cs	Fri Feb 05 20:37:30 2010 +0000
     1.3 @@ -58,6 +58,8 @@
     1.4  			QObject.Connect(layout.actionCreateArmy, SIGNAL("triggered()"), CreateNewArmy);
     1.5  			QObject.Connect(layout.actionUndo, SIGNAL("triggered()"), UndoAction);
     1.6  			QObject.Connect(layout.actionRedo, SIGNAL("triggered()"), RedoAction);
     1.7 +			QObject.Connect(layout.actionSaveArmyAs, SIGNAL("triggered()"), DoSaveCurrentArmyAs);
     1.8 +			QObject.Connect(layout.actionSaveArmy, SIGNAL("triggered()"), DoSaveCurrentArmy);
     1.9  		}
    1.10  		
    1.11  		private void CreateNewArmy()
    1.12 @@ -97,7 +99,7 @@
    1.13  			layout.toolBar.AddSeparator();
    1.14  		}		
    1.15  
    1.16 -		private void HandleWarFoundryCoreArmyChanged (Army oldValue, Army newValue)
    1.17 +		private void HandleWarFoundryCoreArmyChanged(Army oldValue, Army newValue)
    1.18  		{
    1.19  			CommandStack.Reset();
    1.20  			loadedFilePath = null;
    1.21 @@ -142,9 +144,9 @@
    1.22  			}
    1.23  		}
    1.24  
    1.25 -		private void HandleCommandStackCommandStackUpdated ()
    1.26 +		private void HandleCommandStackCommandStackUpdated()
    1.27  		{
    1.28 -			
    1.29 +			layout.actionSaveArmy.Enabled = CommandStack.IsDirty();
    1.30  		}
    1.31  
    1.32  		private void UndoAction()
    1.33 @@ -162,6 +164,11 @@
    1.34  				commandStack.Redo();
    1.35  			}
    1.36  		}
    1.37 +		
    1.38 +		private void DoSaveCurrentArmy()
    1.39 +		{
    1.40 +			SaveCurrentArmy();
    1.41 +		}
    1.42  
    1.43  		private bool SaveCurrentArmy()
    1.44  		{
    1.45 @@ -182,6 +189,11 @@
    1.46  			return saved;
    1.47  		}
    1.48  
    1.49 +		private void DoSaveCurrentArmyAs()
    1.50 +		{
    1.51 +			SaveCurrentArmyAs();
    1.52 +		}
    1.53 +		
    1.54  		private bool SaveCurrentArmyAs()
    1.55  		{
    1.56  			bool saved = false;
    1.57 @@ -214,15 +226,14 @@
    1.58  		private string PromptForArmyFilePath()
    1.59  		{
    1.60  			int result = saveArmyDialog.Exec();
    1.61 +			string path = null;
    1.62  
    1.63  			if (result == (int)QDialog.DialogCode.Accepted)
    1.64  			{
    1.65 -				return saveArmyDialog.SelectedFiles()[0];
    1.66 +				path = saveArmyDialog.SelectedFiles()[0];
    1.67  			}
    1.68 -			else
    1.69 -			{
    1.70 -				return null;
    1.71 -			}
    1.72 +			
    1.73 +			return path;
    1.74  		}		
    1.75  
    1.76  		public GameSystem CurrentGameSystem