changeset 33:be876c03054f

Re #245: Create unit tab implementation * Add stub widget * Record which unit tabs are open * Remove two default tabs
author IBBoard <dev@ibboard.co.uk>
date Sat, 07 Aug 2010 15:40:37 +0000
parents e405b43a405b
children c3c64e139e5f
files IBBoard.WarFoundry.GUI.QtSharp.csproj MainWindow.cs Widgets/UnitWidget.cs qt-gui/MainWindowLayout.cs qt-gui/MainWindowLayout.ui
diffstat 5 files changed, 58 insertions(+), 25 deletions(-) [+]
line wrap: on
line diff
--- a/IBBoard.WarFoundry.GUI.QtSharp.csproj	Sat Aug 07 13:39:35 2010 +0000
+++ b/IBBoard.WarFoundry.GUI.QtSharp.csproj	Sat Aug 07 15:40:37 2010 +0000
@@ -42,6 +42,7 @@
     <Compile Include="Handler\NewUnitEventHandler.cs" />
     <Compile Include="qt-gui\CreateNewUnitLayout.cs" />
     <Compile Include="NewUnitDialog.cs" />
+    <Compile Include="Widgets\UnitWidget.cs" />
   </ItemGroup>
   <ItemGroup>
     <None Include="compile-ui.sh" />
@@ -115,6 +116,7 @@
     <Folder Include="icons\ui\" />
     <Folder Include="lib\" />
     <Folder Include="Handler\" />
+    <Folder Include="Widgets\" />
   </ItemGroup>
   <ItemGroup>
     <Content Include="icons\App.png">
--- a/MainWindow.cs	Sat Aug 07 13:39:35 2010 +0000
+++ b/MainWindow.cs	Sat Aug 07 15:40:37 2010 +0000
@@ -16,6 +16,7 @@
 using IBBoard.WarFoundry.API.Savers;
 using IBBoard.WarFoundry.GUI.QtSharp.Handler;
 using IBBoard.WarFoundry.API.Commands;
+using IBBoard.WarFoundry.GUI.QtSharp.Widgets;
 
 namespace IBBoard.WarFoundry.GUI.QtSharp
 {
@@ -32,6 +33,8 @@
 		private Preferences preferences;
 		private QAction[] categoryActions;
 		private Dictionary<string, QStandardItem> treeNodes;
+		private Dictionary<Unit, UnitWidget> openUnitWidgets;
+		
 		
 		public MainWindow ()
 		{
@@ -40,6 +43,7 @@
 			WindowIcon = new QIcon("icons/App.png");
 			Preferences = new Preferences("WarFoundryQt");
 			treeNodes = new Dictionary<string, QStandardItem>();
+			openUnitWidgets = new Dictionary<Unit, UnitWidget>();
 			
 			try
 			{
@@ -553,7 +557,18 @@
 
 		private void OpenUnitDialog(Unit unit)
 		{
+			UnitWidget currentWidget = DictionaryUtils.GetValue(openUnitWidgets, unit);
 			
+			if (currentWidget != null)
+			{
+				layout.unitTabs.SetCurrentWidget(currentWidget);
+			}
+			else
+			{
+				UnitWidget unitWidget = new UnitWidget(unit);
+				openUnitWidgets.Add(unit, unitWidget);
+				layout.unitTabs.AddTab(unitWidget, unit.Name);
+			}
 		}
 
 		void EnableCategoryButtons ()
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Widgets/UnitWidget.cs	Sat Aug 07 15:40:37 2010 +0000
@@ -0,0 +1,16 @@
+//  This file (UnitWidget.cs) is a part of the IBBoard.WarFoundry.GUI.QtSharp project and is copyright 2010 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 Qyoto;
+using IBBoard.WarFoundry.API.Objects;
+namespace IBBoard.WarFoundry.GUI.QtSharp.Widgets
+{
+	public class UnitWidget : QWidget
+	{
+		public UnitWidget(Unit unit)
+		{
+		}
+	}
+}
+
--- a/qt-gui/MainWindowLayout.cs	Sat Aug 07 13:39:35 2010 +0000
+++ b/qt-gui/MainWindowLayout.cs	Sat Aug 07 15:40:37 2010 +0000
@@ -1,7 +1,7 @@
 /********************************************************************************
 ** Form generated from reading ui file 'MainWindowLayout.ui'
 **
-** Created: Sat Jul 31 16:07:24 2010
+** Created: Sat Aug 7 16:39:03 2010
 **      by: Qt User Interface Compiler for C# version 4.6.3
 **
 ** WARNING! All changes made in this file will be lost when recompiling ui file!
@@ -28,8 +28,6 @@
     public QSplitter splitter;
     public QTreeView armyTree;
     public QTabWidget unitTabs;
-    public QWidget tab;
-    public QWidget tab_2;
     public QMenuBar menubar;
     public QMenu menuFile;
     public QMenu menuExportArmyAs;
@@ -89,13 +87,12 @@
     splitter.AddWidget(armyTree);
     unitTabs = new QTabWidget(splitter);
     unitTabs.ObjectName = "unitTabs";
-    unitTabs.MinimumSize = new QSize(500, 0);
-    tab = new QWidget();
-    tab.ObjectName = "tab";
-    unitTabs.AddTab(tab, QApplication.Translate("MainWindowLayout", "Tab 1", null, QApplication.Encoding.UnicodeUTF8));
-    tab_2 = new QWidget();
-    tab_2.ObjectName = "tab_2";
-    unitTabs.AddTab(tab_2, QApplication.Translate("MainWindowLayout", "Tab 2", null, QApplication.Encoding.UnicodeUTF8));
+    unitTabs.MinimumSize = new QSize(500, 200);
+    unitTabs.tabShape = QTabWidget.TabShape.Rounded;
+    unitTabs.ElideMode = Qt.TextElideMode.ElideMiddle;
+    unitTabs.DocumentMode = false;
+    unitTabs.TabsClosable = true;
+    unitTabs.Movable = true;
     splitter.AddWidget(unitTabs);
 
     gridLayout.AddWidget(splitter, 0, 0, 1, 1);
@@ -142,7 +139,7 @@
 
     RetranslateUi(MainWindowLayout);
 
-    unitTabs.CurrentIndex = 0;
+    unitTabs.CurrentIndex = -1;
 
 
     QMetaObject.ConnectSlotsByName(MainWindowLayout);
@@ -162,8 +159,6 @@
     actionAbout.Text = QApplication.Translate("MainWindowLayout", "&about", null, QApplication.Encoding.UnicodeUTF8);
     actionUndo.Text = QApplication.Translate("MainWindowLayout", "&undo", null, QApplication.Encoding.UnicodeUTF8);
     actionRedo.Text = QApplication.Translate("MainWindowLayout", "&redo", null, QApplication.Encoding.UnicodeUTF8);
-    unitTabs.SetTabText(unitTabs.IndexOf(tab), QApplication.Translate("MainWindowLayout", "Tab 1", null, QApplication.Encoding.UnicodeUTF8));
-    unitTabs.SetTabText(unitTabs.IndexOf(tab_2), QApplication.Translate("MainWindowLayout", "Tab 2", null, QApplication.Encoding.UnicodeUTF8));
     menuFile.Title = QApplication.Translate("MainWindowLayout", "&file", null, QApplication.Encoding.UnicodeUTF8);
     menuExportArmyAs.Title = QApplication.Translate("MainWindowLayout", "export army as", null, QApplication.Encoding.UnicodeUTF8);
     menuEdit.Title = QApplication.Translate("MainWindowLayout", "&edit", null, QApplication.Encoding.UnicodeUTF8);
--- a/qt-gui/MainWindowLayout.ui	Sat Aug 07 13:39:35 2010 +0000
+++ b/qt-gui/MainWindowLayout.ui	Sat Aug 07 15:40:37 2010 +0000
@@ -39,22 +39,27 @@
        <property name="minimumSize">
         <size>
          <width>500</width>
-         <height>0</height>
+         <height>200</height>
         </size>
        </property>
+       <property name="tabShape">
+        <enum>QTabWidget::Rounded</enum>
+       </property>
        <property name="currentIndex">
-        <number>0</number>
+        <number>-1</number>
+       </property>
+       <property name="elideMode">
+        <enum>Qt::ElideMiddle</enum>
        </property>
-       <widget class="QWidget" name="tab">
-        <attribute name="title">
-         <string>Tab 1</string>
-        </attribute>
-       </widget>
-       <widget class="QWidget" name="tab_2">
-        <attribute name="title">
-         <string>Tab 2</string>
-        </attribute>
-       </widget>
+       <property name="documentMode">
+        <bool>false</bool>
+       </property>
+       <property name="tabsClosable">
+        <bool>true</bool>
+       </property>
+       <property name="movable">
+        <bool>true</bool>
+       </property>
       </widget>
      </widget>
     </item>