# HG changeset patch # User IBBoard # Date 1264625936 0 # Node ID bbf40d66dfe4011981be3fc88607f81d39394a9b # Parent 1bd8febee3850c2e0b600a64654f219c5cc6264d 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 diff -r 1bd8febee385 -r bbf40d66dfe4 MainWindow.cs --- 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() diff -r 1bd8febee385 -r bbf40d66dfe4 NewArmyDialog.cs --- 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; } } } diff -r 1bd8febee385 -r bbf40d66dfe4 qt-gui/CreateNewArmyLayout.cs --- 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 } diff -r 1bd8febee385 -r bbf40d66dfe4 qt-gui/CreateNewArmyLayout.ui --- 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 @@ - - - - TextLabel + army name: Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter @@ -63,7 +60,7 @@ - TextLabel + army size: Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter @@ -76,6 +73,9 @@ + + +