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 wrap: on
line diff
--- a/MainWindow.cs	Sun Feb 21 13:53:47 2010 +0000
+++ b/MainWindow.cs	Sun Feb 21 14:51:32 2010 +0000
@@ -10,6 +10,7 @@
 using IBBoard.IO;
 using IBBoard.Lang;
 using IBBoard.WarFoundry.API;
+using IBBoard.WarFoundry.API.Exporters;
 using IBBoard.WarFoundry.API.Factories;
 using IBBoard.WarFoundry.API.Objects;
 using IBBoard.WarFoundry.API.Savers;
@@ -86,6 +87,7 @@
 			ConnectMenuAction(layout.actionSaveArmy, DoSaveCurrentArmy);
 			ConnectMenuAction(layout.actionCloseArmy, DoCloseArmy);
 			ConnectMenuAction(layout.actionOpenArmy, DoOpenArmy);
+			ConnectMenuAction(layout.actionExportBasicHtml, DoExportBasicHTML);
 		}
 		
 		private void ConnectMenuAction(QAction menuAction, SlotFunc method)
@@ -415,6 +417,12 @@
 			layout.actionSaveArmyAs.Enabled = false;
 			layout.actionCloseArmy.Enabled = false;
 			layout.menuExportArmyAs.Enabled = false;
+			
+			foreach (QAction exportAction in layout.menuExportArmyAs.Actions())
+			{
+				exportAction.Enabled = false;	
+			}
+			
 			layout.armyTree.SetModel(new QStandardItemModel());
 			DisableCategoryButtons();
 		}
@@ -432,6 +440,12 @@
 			layout.actionSaveArmyAs.Enabled = true;
 			layout.actionCloseArmy.Enabled = true;
 			layout.menuExportArmyAs.Enabled = true;
+			
+			foreach (QAction exportAction in layout.menuExportArmyAs.Actions())
+			{
+				exportAction.Enabled = true;	
+			}
+			
 			FillArmyTree(newArmy);
 		}
 
@@ -544,5 +558,23 @@
 			get { return preferences; }
 			set { preferences = value; }
 		}
+		
+		private void DoExportBasicHTML()
+		{
+			log.Debug("Exporting to HTML");
+			QFileDialog fileDialog = new QFileDialog(this);
+			fileDialog.acceptMode = QFileDialog.AcceptMode.AcceptSave;
+			fileDialog.fileMode = QFileDialog.FileMode.AnyFile;
+			fileDialog.SetDirectory(new QDir(Environment.GetFolderPath(Environment.SpecialFolder.Personal)));
+			log.Debug("Requesting export path");
+			int result = fileDialog.Exec();
+			
+			if (result == (int)QDialog.DialogCode.Accepted)
+			{
+				string path = fileDialog.SelectedFiles()[0];
+				log.DebugFormat("Exporting to {0}", path);
+				WarFoundryHtmlExporter.GetDefault().ExportArmy(CurrentArmy, path);
+			}
+		}
 	}
 }
\ No newline at end of file