Mercurial > repos > IBBoard.WarFoundry.GUI.QtSharp
changeset 3:ac1bf60edf63
Re #242: Qt# UI
* Make use of icons
Re #243: Create "New Army" dialog in Qt# app
* Create initial rendering of dialog (non-functional)
Re #247: Implement menu options in Qt# app
* Add initial hook for New Army dialog from menu item
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Sat, 23 Jan 2010 20:54:42 +0000 |
parents | cf68a996b3f1 |
children | d8f82945a6ab |
files | IBBoard.WarFoundry.GUI.QtSharp.csproj MainWindow.cs NewArmyDialog.cs qt-gui/CreateNewArmyLayout.cs qt-gui/CreateNewArmyLayout.ui |
diffstat | 5 files changed, 302 insertions(+), 43 deletions(-) [+] |
line wrap: on
line diff
--- a/IBBoard.WarFoundry.GUI.QtSharp.csproj Sat Jan 23 20:26:04 2010 +0000 +++ b/IBBoard.WarFoundry.GUI.QtSharp.csproj Sat Jan 23 20:54:42 2010 +0000 @@ -36,6 +36,8 @@ <Compile Include="MainWindow.cs" /> <Compile Include="Main.cs" /> <Compile Include="qt-gui\MainWindowLayout.cs" /> + <Compile Include="qt-gui\CreateNewArmyLayout.cs" /> + <Compile Include="NewArmyDialog.cs" /> </ItemGroup> <ItemGroup> <None Include="compile-ui.sh" /> @@ -73,6 +75,7 @@ <None Include="icons\ui\help-about.png"> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> </None> + <None Include="qt-gui\CreateNewArmyLayout.ui" /> </ItemGroup> <ItemGroup> <Folder Include="qt-gui\" />
--- a/MainWindow.cs Sat Jan 23 20:26:04 2010 +0000 +++ b/MainWindow.cs Sat Jan 23 20:54:42 2010 +0000 @@ -5,49 +5,60 @@ using System.Collections.Generic; using Qyoto; -public partial class MainWindow : QMainWindow +namespace IBBoard.WarFoundry.GUI.QtSharp { - 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() + public class MainWindow : QMainWindow { - 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() - { + 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, Qt.SIGNAL("triggered()"), delegate(){CreateNewArmy();}); + } + + [Q_SLOT()] + 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(); + } } - - 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(); - } -} +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/NewArmyDialog.cs Sat Jan 23 20:54:42 2010 +0000 @@ -0,0 +1,21 @@ +// This file (NewArmyDialog.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; + +namespace IBBoard.WarFoundry.GUI.QtSharp +{ + public class NewArmyDialog : QDialog + { + private Ui_CreateNewArmyLayout layout; + + public NewArmyDialog () + { + layout = new Ui_CreateNewArmyLayout(); + layout.SetupUi(this); + + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/qt-gui/CreateNewArmyLayout.cs Sat Jan 23 20:54:42 2010 +0000 @@ -0,0 +1,108 @@ +/******************************************************************************** +** Form generated from reading ui file 'CreateNewArmyLayout.ui' +** +** Created: Sat Jan 23 20:40:44 2010 +** by: Qt User Interface Compiler for C# version 4.5.3 +** +** WARNING! All changes made in this file will be lost when recompiling ui file! +********************************************************************************/ + + +using Qyoto; + +public class Ui_CreateNewArmyLayout +{ + public QGridLayout gridLayout; + public QDialogButtonBox buttonBox; + public QComboBox gameSystems; + public QLabel lblGameSystem; + public QLabel lblRace; + public QListView raceList; + public QLabel lblArmyName; + public QLabel lblArmySize; + public QSpinBox armySize; + public QLineEdit armyName; + + public void SetupUi(QDialog CreateNewArmyLayout) + { + if (CreateNewArmyLayout.ObjectName == "") + CreateNewArmyLayout.ObjectName = "CreateNewArmyLayout"; + QSize Size = new QSize(400, 300); + Size = Size.ExpandedTo(CreateNewArmyLayout.MinimumSizeHint()); + CreateNewArmyLayout.Size = Size; + gridLayout = new QGridLayout(CreateNewArmyLayout); + gridLayout.ObjectName = "gridLayout"; + buttonBox = new QDialogButtonBox(CreateNewArmyLayout); + buttonBox.ObjectName = "buttonBox"; + buttonBox.Orientation = Qt.Orientation.Horizontal; + buttonBox.StandardButtons = Qyoto.Qyoto.GetCPPEnumValue("QDialogButtonBox", "Cancel") | Qyoto.Qyoto.GetCPPEnumValue("QDialogButtonBox", "Ok"); + + gridLayout.AddWidget(buttonBox, 4, 2, 1, 1); + + gameSystems = new QComboBox(CreateNewArmyLayout); + gameSystems.ObjectName = "gameSystems"; + + gridLayout.AddWidget(gameSystems, 0, 2, 1, 1); + + lblGameSystem = new QLabel(CreateNewArmyLayout); + lblGameSystem.ObjectName = "lblGameSystem"; + lblGameSystem.Alignment = Qyoto.Qyoto.GetCPPEnumValue("Qt", "AlignRight") | Qyoto.Qyoto.GetCPPEnumValue("Qt", "AlignTrailing") | Qyoto.Qyoto.GetCPPEnumValue("Qt", "AlignVCenter"); + + gridLayout.AddWidget(lblGameSystem, 0, 0, 1, 1); + + lblRace = new QLabel(CreateNewArmyLayout); + lblRace.ObjectName = "lblRace"; + lblRace.Alignment = Qyoto.Qyoto.GetCPPEnumValue("Qt", "AlignRight") | Qyoto.Qyoto.GetCPPEnumValue("Qt", "AlignTop") | Qyoto.Qyoto.GetCPPEnumValue("Qt", "AlignTrailing"); + + gridLayout.AddWidget(lblRace, 1, 0, 1, 1); + + raceList = new QListView(CreateNewArmyLayout); + raceList.ObjectName = "raceList"; + + gridLayout.AddWidget(raceList, 1, 2, 1, 1); + + lblArmyName = new QLabel(CreateNewArmyLayout); + lblArmyName.ObjectName = "lblArmyName"; + lblArmyName.Alignment = Qyoto.Qyoto.GetCPPEnumValue("Qt", "AlignRight") | Qyoto.Qyoto.GetCPPEnumValue("Qt", "AlignTrailing") | Qyoto.Qyoto.GetCPPEnumValue("Qt", "AlignVCenter"); + + gridLayout.AddWidget(lblArmyName, 2, 0, 1, 1); + + lblArmySize = new QLabel(CreateNewArmyLayout); + lblArmySize.ObjectName = "lblArmySize"; + lblArmySize.Alignment = Qyoto.Qyoto.GetCPPEnumValue("Qt", "AlignRight") | Qyoto.Qyoto.GetCPPEnumValue("Qt", "AlignTrailing") | Qyoto.Qyoto.GetCPPEnumValue("Qt", "AlignVCenter"); + + gridLayout.AddWidget(lblArmySize, 3, 0, 1, 1); + + armySize = new QSpinBox(CreateNewArmyLayout); + armySize.ObjectName = "armySize"; + + gridLayout.AddWidget(armySize, 3, 2, 1, 1); + + armyName = new QLineEdit(CreateNewArmyLayout); + armyName.ObjectName = "armyName"; + + gridLayout.AddWidget(armyName, 2, 2, 1, 1); + + + RetranslateUi(CreateNewArmyLayout); + QObject.Connect(buttonBox, Qt.SIGNAL("accepted()"), CreateNewArmyLayout, Qt.SLOT("accept()")); + QObject.Connect(buttonBox, Qt.SIGNAL("rejected()"), CreateNewArmyLayout, Qt.SLOT("reject()")); + + QMetaObject.ConnectSlotsByName(CreateNewArmyLayout); + } // SetupUi + + public void RetranslateUi(QDialog CreateNewArmyLayout) + { + CreateNewArmyLayout.WindowTitle = QApplication.Translate("CreateNewArmyLayout", "Dialog", null, QApplication.Encoding.UnicodeUTF8); + lblGameSystem.Text = QApplication.Translate("CreateNewArmyLayout", "game system:", null, QApplication.Encoding.UnicodeUTF8); + lblRace.Text = QApplication.Translate("CreateNewArmyLayout", "race:", null, QApplication.Encoding.UnicodeUTF8); + lblArmyName.Text = QApplication.Translate("CreateNewArmyLayout", "TextLabel", null, QApplication.Encoding.UnicodeUTF8); + lblArmySize.Text = QApplication.Translate("CreateNewArmyLayout", "TextLabel", null, QApplication.Encoding.UnicodeUTF8); + } // RetranslateUi + +} + +namespace Ui { + public class CreateNewArmyLayout : Ui_CreateNewArmyLayout {} +} // namespace Ui +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/qt-gui/CreateNewArmyLayout.ui Sat Jan 23 20:54:42 2010 +0000 @@ -0,0 +1,116 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>CreateNewArmyLayout</class> + <widget class="QDialog" name="CreateNewArmyLayout"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>400</width> + <height>300</height> + </rect> + </property> + <property name="windowTitle"> + <string>Dialog</string> + </property> + <layout class="QGridLayout" name="gridLayout"> + <item row="4" column="2"> + <widget class="QDialogButtonBox" name="buttonBox"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="standardButtons"> + <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> + </property> + </widget> + </item> + <item row="0" column="2"> + <widget class="QComboBox" name="gameSystems"/> + </item> + <item row="0" column="0"> + <widget class="QLabel" name="lblGameSystem"> + <property name="text"> + <string>game system:</string> + </property> + <property name="alignment"> + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> + </property> + </widget> + </item> + <item row="1" column="0"> + <widget class="QLabel" name="lblRace"> + <property name="text"> + <string>race:</string> + </property> + <property name="alignment"> + <set>Qt::AlignRight|Qt::AlignTop|Qt::AlignTrailing</set> + </property> + </widget> + </item> + <item row="1" column="2"> + <widget class="QListView" name="raceList"/> + </item> + <item row="2" column="0"> + <widget class="QLabel" name="lblArmyName"> + <property name="text"> + <string>TextLabel</string> + </property> + <property name="alignment"> + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> + </property> + </widget> + </item> + <item row="3" column="0"> + <widget class="QLabel" name="lblArmySize"> + <property name="text"> + <string>TextLabel</string> + </property> + <property name="alignment"> + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> + </property> + </widget> + </item> + <item row="3" column="2"> + <widget class="QSpinBox" name="armySize"/> + </item> + <item row="2" column="2"> + <widget class="QLineEdit" name="armyName"/> + </item> + </layout> + </widget> + <resources/> + <connections> + <connection> + <sender>buttonBox</sender> + <signal>accepted()</signal> + <receiver>CreateNewArmyLayout</receiver> + <slot>accept()</slot> + <hints> + <hint type="sourcelabel"> + <x>248</x> + <y>254</y> + </hint> + <hint type="destinationlabel"> + <x>157</x> + <y>274</y> + </hint> + </hints> + </connection> + <connection> + <sender>buttonBox</sender> + <signal>rejected()</signal> + <receiver>CreateNewArmyLayout</receiver> + <slot>reject()</slot> + <hints> + <hint type="sourcelabel"> + <x>316</x> + <y>260</y> + </hint> + <hint type="destinationlabel"> + <x>286</x> + <y>274</y> + </hint> + </hints> + </connection> + </connections> +</ui>