view MainWindow.cs @ 5:1bd8febee385

Re #242: Create Qt# UI for WarFoundry * Add logging library * Set up WarFoundry environment * Log load errors
author IBBoard <dev@ibboard.co.uk>
date Mon, 25 Jan 2010 20:54:33 +0000
parents d8f82945a6ab
children bbf40d66dfe4
line wrap: on
line source

// This file (MainWindow.cs) is a part of the IBBoard.WarFoundry.API project and is copyright 2009 IBBoard
// 
// The file and the library/program it is in are licensed and distributed, without warranty, under the GNU Affero GPL license, either version 3 of the License or (at your option) any later version. Please see COPYING for more information and the full license.
using System;
using System.Collections.Generic;
using Qyoto;

namespace IBBoard.WarFoundry.GUI.QtSharp
{
	public class MainWindow : QMainWindow
	{
		private Ui_MainWindowLayout layout;
		
		public MainWindow ()
		{
			layout = new Ui_MainWindowLayout();
			layout.SetupUi(this);
			WindowIcon = new QIcon("icons/App.png");
			SetUpActionIcons();
			ConnectMenuActions();
			SetUpToolbar();
			layout.unitTabs.Clear();
		}
		
		private void SetUpActionIcons()
		{
			layout.actionCreateArmy.icon = new QIcon("icons/ui/filenew.png");
			layout.actionOpenArmy.icon = new QIcon("icons/ui/fileopen.png");
			layout.actionSaveArmy.icon = new QIcon("icons/ui/filesave.png");
			layout.actionSaveArmyAs.icon = new QIcon("icons/ui/filesaveas.png");
			layout.menuExportArmyAs.icon = new QIcon("icons/ui/export.png");
			layout.actionCloseArmy.icon = new QIcon("icons/ui/window-close.png");
			layout.actionExit.icon = new QIcon("icons/ui/exit.png");
			layout.actionUndo.icon = new QIcon("icons/ui/edit-undo.png");
			layout.actionRedo.icon = new QIcon("icons/ui/edit-redo.png");
			layout.actionAbout.icon = new QIcon("icons/ui/help-about.png");
		}
		
		private void ConnectMenuActions()
		{
			QObject.Connect(layout.actionCreateArmy, "triggered()", CreateNewArmy);
		}
		
		private void CreateNewArmy()
		{
			NewArmyDialog dialog = new NewArmyDialog();
			dialog.Show();
		}
		
		private void SetUpToolbar()
		{
			List<QAction> actions = new List<QAction>(){
				layout.actionCreateArmy,
				layout.actionOpenArmy,
				layout.actionSaveArmy};
			layout.toolBar.AddActions(actions);
			layout.toolBar.AddSeparator();
			layout.toolBar.AddAction(layout.actionUndo);
			layout.toolBar.AddAction(layout.actionRedo);
			layout.toolBar.AddSeparator();
		}
	}
}