changeset 21:d6e95d51b9a4

Re #247: Implement menu options in Qt# app * Hook up basic HTML export (currently seems to cause segfault when adding doc type)
author IBBoard <dev@ibboard.co.uk>
date Sun, 21 Feb 2010 14:51:32 +0000
parents f1be1b509134
children ff011053ec3f
files MainWindow.cs
diffstat 1 files changed, 32 insertions(+), 0 deletions(-) [+]
line diff
     1.1 --- a/MainWindow.cs	Sun Feb 21 13:53:47 2010 +0000
     1.2 +++ b/MainWindow.cs	Sun Feb 21 14:51:32 2010 +0000
     1.3 @@ -10,6 +10,7 @@
     1.4  using IBBoard.IO;
     1.5  using IBBoard.Lang;
     1.6  using IBBoard.WarFoundry.API;
     1.7 +using IBBoard.WarFoundry.API.Exporters;
     1.8  using IBBoard.WarFoundry.API.Factories;
     1.9  using IBBoard.WarFoundry.API.Objects;
    1.10  using IBBoard.WarFoundry.API.Savers;
    1.11 @@ -86,6 +87,7 @@
    1.12  			ConnectMenuAction(layout.actionSaveArmy, DoSaveCurrentArmy);
    1.13  			ConnectMenuAction(layout.actionCloseArmy, DoCloseArmy);
    1.14  			ConnectMenuAction(layout.actionOpenArmy, DoOpenArmy);
    1.15 +			ConnectMenuAction(layout.actionExportBasicHtml, DoExportBasicHTML);
    1.16  		}
    1.17  		
    1.18  		private void ConnectMenuAction(QAction menuAction, SlotFunc method)
    1.19 @@ -415,6 +417,12 @@
    1.20  			layout.actionSaveArmyAs.Enabled = false;
    1.21  			layout.actionCloseArmy.Enabled = false;
    1.22  			layout.menuExportArmyAs.Enabled = false;
    1.23 +			
    1.24 +			foreach (QAction exportAction in layout.menuExportArmyAs.Actions())
    1.25 +			{
    1.26 +				exportAction.Enabled = false;	
    1.27 +			}
    1.28 +			
    1.29  			layout.armyTree.SetModel(new QStandardItemModel());
    1.30  			DisableCategoryButtons();
    1.31  		}
    1.32 @@ -432,6 +440,12 @@
    1.33  			layout.actionSaveArmyAs.Enabled = true;
    1.34  			layout.actionCloseArmy.Enabled = true;
    1.35  			layout.menuExportArmyAs.Enabled = true;
    1.36 +			
    1.37 +			foreach (QAction exportAction in layout.menuExportArmyAs.Actions())
    1.38 +			{
    1.39 +				exportAction.Enabled = true;	
    1.40 +			}
    1.41 +			
    1.42  			FillArmyTree(newArmy);
    1.43  		}
    1.44  
    1.45 @@ -544,5 +558,23 @@
    1.46  			get { return preferences; }
    1.47  			set { preferences = value; }
    1.48  		}
    1.49 +		
    1.50 +		private void DoExportBasicHTML()
    1.51 +		{
    1.52 +			log.Debug("Exporting to HTML");
    1.53 +			QFileDialog fileDialog = new QFileDialog(this);
    1.54 +			fileDialog.acceptMode = QFileDialog.AcceptMode.AcceptSave;
    1.55 +			fileDialog.fileMode = QFileDialog.FileMode.AnyFile;
    1.56 +			fileDialog.SetDirectory(new QDir(Environment.GetFolderPath(Environment.SpecialFolder.Personal)));
    1.57 +			log.Debug("Requesting export path");
    1.58 +			int result = fileDialog.Exec();
    1.59 +			
    1.60 +			if (result == (int)QDialog.DialogCode.Accepted)
    1.61 +			{
    1.62 +				string path = fileDialog.SelectedFiles()[0];
    1.63 +				log.DebugFormat("Exporting to {0}", path);
    1.64 +				WarFoundryHtmlExporter.GetDefault().ExportArmy(CurrentArmy, path);
    1.65 +			}
    1.66 +		}
    1.67  	}
    1.68  }
    1.69 \ No newline at end of file