Mercurial > repos > IBBoard.WarFoundry.GUI.QtSharp
changeset 6:bbf40d66dfe4
Re #242: Create Qt# UI for WarFoundry
* Fix warnings about Connect strings not being signals
Re #243: Create new Qt# "Create Army" dialog
* Change from List View to List Widget (views need models, which only handle QVariants and not arbitrary objects)
* Populate Game System list
* Populate races list on game system selection changed
* Set text on some labels
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Wed, 27 Jan 2010 20:58:56 +0000 |
parents | 1bd8febee385 |
children | 09bc9a4df412 |
files | MainWindow.cs NewArmyDialog.cs qt-gui/CreateNewArmyLayout.cs qt-gui/CreateNewArmyLayout.ui |
diffstat | 4 files changed, 64 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/MainWindow.cs Mon Jan 25 20:54:33 2010 +0000 +++ b/MainWindow.cs Wed Jan 27 20:58:56 2010 +0000 @@ -38,7 +38,7 @@ private void ConnectMenuActions() { - QObject.Connect(layout.actionCreateArmy, "triggered()", CreateNewArmy); + QObject.Connect(layout.actionCreateArmy, SIGNAL("triggered()"), CreateNewArmy); } private void CreateNewArmy()
--- a/NewArmyDialog.cs Mon Jan 25 20:54:33 2010 +0000 +++ b/NewArmyDialog.cs Wed Jan 27 20:58:56 2010 +0000 @@ -3,7 +3,10 @@ // 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; +using IBBoard.WarFoundry.API; +using IBBoard.WarFoundry.API.Objects; namespace IBBoard.WarFoundry.GUI.QtSharp { @@ -11,11 +14,57 @@ { private Ui_CreateNewArmyLayout layout; + //TODO: Replace local cached arrays with some kind of storing as user data on controls, if possible + //Qt doesn't seem to support it by default, but there should be a better alternative + private GameSystem[] gameSystems; + private Race[] races; + public NewArmyDialog () { layout = new Ui_CreateNewArmyLayout(); layout.SetupUi(this); + PopulateControls(); + layout.gameSystems.CurrentIndex = -1; + QObject.Connect(layout.gameSystems, SIGNAL("currentIndexChanged(int)"), GameSystemSelectionChanged); + } + + private void PopulateControls() + { + gameSystems = WarFoundryLoader.GetDefault().GetGameSystems(); + + foreach (GameSystem system in gameSystems) + { + layout.gameSystems.AddItem(system.Name); + } + } + + private void GameSystemSelectionChanged() + { + layout.raceList.Clear(); + + if (layout.gameSystems.CurrentIndex != -1) + { + races = WarFoundryLoader.GetDefault().GetRaces(GetSelectedSystem()); + + foreach (Race race in races) + { + layout.raceList.AddItem(race.Name); + } + } + } + + private GameSystem GetSelectedSystem() + { + GameSystem system = null; + int selectedIndex = layout.gameSystems.CurrentIndex; + + if (selectedIndex != -1) + { + system = gameSystems[selectedIndex]; + } + + return system; } } }
--- a/qt-gui/CreateNewArmyLayout.cs Mon Jan 25 20:54:33 2010 +0000 +++ b/qt-gui/CreateNewArmyLayout.cs Wed Jan 27 20:58:56 2010 +0000 @@ -1,7 +1,7 @@ /******************************************************************************** ** Form generated from reading ui file 'CreateNewArmyLayout.ui' ** -** Created: Sat Jan 23 20:40:44 2010 +** Created: Wed Jan 27 20:53:01 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! @@ -17,11 +17,11 @@ 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 QListWidget raceList; public void SetupUi(QDialog CreateNewArmyLayout) { @@ -56,11 +56,6 @@ 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"); @@ -83,6 +78,11 @@ gridLayout.AddWidget(armyName, 2, 2, 1, 1); + raceList = new QListWidget(CreateNewArmyLayout); + raceList.ObjectName = "raceList"; + + gridLayout.AddWidget(raceList, 1, 2, 1, 1); + RetranslateUi(CreateNewArmyLayout); QObject.Connect(buttonBox, Qt.SIGNAL("accepted()"), CreateNewArmyLayout, Qt.SLOT("accept()")); @@ -96,8 +96,8 @@ 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); + lblArmyName.Text = QApplication.Translate("CreateNewArmyLayout", "army name:", null, QApplication.Encoding.UnicodeUTF8); + lblArmySize.Text = QApplication.Translate("CreateNewArmyLayout", "army size:", null, QApplication.Encoding.UnicodeUTF8); } // RetranslateUi }
--- a/qt-gui/CreateNewArmyLayout.ui Mon Jan 25 20:54:33 2010 +0000 +++ b/qt-gui/CreateNewArmyLayout.ui Wed Jan 27 20:58:56 2010 +0000 @@ -47,13 +47,10 @@ </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> + <string>army name:</string> </property> <property name="alignment"> <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> @@ -63,7 +60,7 @@ <item row="3" column="0"> <widget class="QLabel" name="lblArmySize"> <property name="text"> - <string>TextLabel</string> + <string>army size:</string> </property> <property name="alignment"> <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> @@ -76,6 +73,9 @@ <item row="2" column="2"> <widget class="QLineEdit" name="armyName"/> </item> + <item row="1" column="2"> + <widget class="QListWidget" name="raceList"/> + </item> </layout> </widget> <resources/>