comparison MainWindow.cs @ 26:55d4f16c982b

Fixes #250: QtSharp app doesn't always quit properly * Override Close event to dispose of file dialogs (open and save) * Remove unnecessary event handler hooked to close * Change app initialisation to match pattern used by Synapse * Create file dialogs without specifying "this" as parent - seems to be main fix, for some reason.
author IBBoard <dev@ibboard.co.uk>
date Sat, 31 Jul 2010 16:03:14 +0000
parents 9641addafffe
children 5ee15def17e7
comparison
equal deleted inserted replaced
25:4ec2083eb755 26:55d4f16c982b
45 log.Error(ex); 45 log.Error(ex);
46 QMessageBox.Critical(this, "Translation loading failed", ex.Message); 46 QMessageBox.Critical(this, "Translation loading failed", ex.Message);
47 } 47 }
48 48
49 SetAppTitle(); 49 SetAppTitle();
50 saveArmyDialog = new QFileDialog(this); 50 saveArmyDialog = new QFileDialog();
51 saveArmyDialog.acceptMode = QFileDialog.AcceptMode.AcceptSave; 51 saveArmyDialog.acceptMode = QFileDialog.AcceptMode.AcceptSave;
52 saveArmyDialog.fileMode = QFileDialog.FileMode.AnyFile; 52 saveArmyDialog.fileMode = QFileDialog.FileMode.AnyFile;
53 saveArmyDialog.SetDirectory(new QDir(Environment.GetFolderPath(Environment.SpecialFolder.Personal))); 53 saveArmyDialog.SetDirectory(new QDir(Environment.GetFolderPath(Environment.SpecialFolder.Personal)));
54 openArmyDialog = new QFileDialog(this); 54 openArmyDialog = new QFileDialog();
55 openArmyDialog.acceptMode = QFileDialog.AcceptMode.AcceptOpen; 55 openArmyDialog.acceptMode = QFileDialog.AcceptMode.AcceptOpen;
56 openArmyDialog.fileMode = QFileDialog.FileMode.ExistingFile; 56 openArmyDialog.fileMode = QFileDialog.FileMode.ExistingFile;
57 openArmyDialog.SetNameFilter("*.army"); 57 openArmyDialog.SetNameFilter("*.army");
58 openArmyDialog.SetDirectory(new QDir(Environment.GetFolderPath(Environment.SpecialFolder.Personal))); 58 openArmyDialog.SetDirectory(new QDir(Environment.GetFolderPath(Environment.SpecialFolder.Personal)));
59 SetUpActionIcons(); 59 SetUpActionIcons();
60 ConnectMenuActions(); 60 ConnectMenuActions();
61 SetUpToolbar(); 61 SetUpToolbar();
62 layout.unitTabs.Clear(); 62 layout.unitTabs.Clear();
63 WarFoundryCore.ArmyChanged+= HandleWarFoundryCoreArmyChanged; 63 WarFoundryCore.ArmyChanged+= HandleWarFoundryCoreArmyChanged;
64 CommandStack.CommandStackUpdated+= HandleCommandStackCommandStackUpdated; 64 CommandStack.CommandStackUpdated+= HandleCommandStackCommandStackUpdated;
65 }
66
67 protected override void CloseEvent(QCloseEvent arg1)
68 {
69 base.CloseEvent(arg1);
70 saveArmyDialog.Dispose();
71 openArmyDialog.Dispose();
65 } 72 }
66 73
67 private void SetUpActionIcons() 74 private void SetUpActionIcons()
68 { 75 {
69 layout.actionCreateArmy.icon = new QIcon("icons/ui/filenew.png"); 76 layout.actionCreateArmy.icon = new QIcon("icons/ui/filenew.png");