File Exit and window closing event handled
authorHarishankar <v.harishankar@gmail.com>
Tue, 6 Dec 2011 05:45:33 +0000 (11:15 +0530)
committerHarishankar <v.harishankar@gmail.com>
Tue, 6 Dec 2011 05:45:33 +0000 (11:15 +0530)
Implemented handler for menu action File -> Exit and window
closing.

biacv_mainwindow.py
biacv_mainwindow.ui
biacv_mainwindow_ui.py

index 681469d..91599b9 100644 (file)
@@ -2,6 +2,8 @@
 # class for main window
 
 import PyQt4
+import sys
+
 import biacv_mainwindow_ui as bui
 import biacv_lang as lang
 import biacv_data as data
@@ -14,6 +16,20 @@ class Biacv_mainwindow (PyQt4.QtGui.QMainWindow, bui.Ui_biacv_mainwindow):
                self.ismodified = False
                self.setWindowTitle ("BiaCV - untitled")
 
+       # on window closing
+       def closeEvent (self, event):
+               if self.ismodified is True:
+                       ans = PyQt4.QtGui.QMessageBox.question (self, lang.CONFIRM, lang.CONFIRM_DISCARD_SAVE,
+                               PyQt4.QtGui.QMessageBox.Yes, PyQt4.QtGui.QMessageBox.No)
+                       # ignore event if not confirmed
+                       if ans <> PyQt4.QtGui.QMessageBox.Yes:
+                               event.ignore ()
+
+       # on file exit
+       def on_exit (self):
+               # call the close event
+               self.close()
+
        # function to open a file
        def on_file_open (self):
                # if modified, confirm
index 9be86cd..37d6511 100644 (file)
    <slot>on_add_education()</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>70</x>
-     <y>98</y>
+     <x>426</x>
+     <y>189</y>
     </hint>
     <hint type="destinationlabel">
      <x>730</x>
    <slot>on_delete_education()</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>100</x>
-     <y>98</y>
+     <x>658</x>
+     <y>189</y>
     </hint>
     <hint type="destinationlabel">
      <x>728</x>
    <hints>
     <hint type="sourcelabel">
      <x>100</x>
-     <y>102</y>
+     <y>217</y>
     </hint>
     <hint type="destinationlabel">
      <x>726</x>
    <slot>on_update_education()</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>85</x>
-     <y>98</y>
+     <x>579</x>
+     <y>189</y>
     </hint>
     <hint type="destinationlabel">
      <x>728</x>
    <hints>
     <hint type="sourcelabel">
      <x>100</x>
-     <y>102</y>
+     <y>217</y>
     </hint>
     <hint type="destinationlabel">
      <x>729</x>
    <slot>on_change_currentemployment()</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>80</x>
-     <y>88</y>
+     <x>328</x>
+     <y>136</y>
     </hint>
     <hint type="destinationlabel">
      <x>728</x>
    <slot>on_add_profession()</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>61</x>
-     <y>99</y>
+     <x>309</x>
+     <y>216</y>
     </hint>
     <hint type="destinationlabel">
      <x>729</x>
    <hints>
     <hint type="sourcelabel">
      <x>99</x>
-     <y>103</y>
+     <y>244</y>
     </hint>
     <hint type="destinationlabel">
      <x>727</x>
    <hints>
     <hint type="sourcelabel">
      <x>99</x>
-     <y>103</y>
+     <y>244</y>
     </hint>
     <hint type="destinationlabel">
      <x>729</x>
    <slot>on_delete_profession()</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>99</x>
-     <y>99</y>
+     <x>596</x>
+     <y>216</y>
     </hint>
     <hint type="destinationlabel">
      <x>729</x>
    <slot>on_update_profession()</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>80</x>
-     <y>99</y>
+     <x>453</x>
+     <y>216</y>
     </hint>
     <hint type="destinationlabel">
      <x>726</x>
    <slot>on_add_skill()</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>51</x>
-     <y>96</y>
+     <x>207</x>
+     <y>234</y>
     </hint>
     <hint type="destinationlabel">
      <x>730</x>
    <slot>on_delete_skill()</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>99</x>
-     <y>96</y>
+     <x>566</x>
+     <y>234</y>
     </hint>
     <hint type="destinationlabel">
      <x>728</x>
    <hints>
     <hint type="sourcelabel">
      <x>99</x>
-     <y>102</y>
+     <y>261</y>
     </hint>
     <hint type="destinationlabel">
      <x>730</x>
    <hints>
     <hint type="sourcelabel">
      <x>99</x>
-     <y>102</y>
+     <y>261</y>
     </hint>
     <hint type="destinationlabel">
      <x>726</x>
    <slot>on_update_skill()</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>75</x>
-     <y>96</y>
+     <x>386</x>
+     <y>234</y>
     </hint>
     <hint type="destinationlabel">
      <x>728</x>
    <slot>on_add_lang()</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>107</x>
-     <y>110</y>
+     <x>547</x>
+     <y>155</y>
     </hint>
     <hint type="destinationlabel">
      <x>729</x>
    <slot>on_delete_lang()</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>107</x>
-     <y>110</y>
+     <x>716</x>
+     <y>155</y>
     </hint>
     <hint type="destinationlabel">
      <x>733</x>
    <slot>on_select_lang()</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>98</x>
-     <y>110</y>
+     <x>103</x>
+     <y>189</y>
     </hint>
     <hint type="destinationlabel">
      <x>730</x>
    <slot>on_select_lang()</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>98</x>
-     <y>110</y>
+     <x>103</x>
+     <y>189</y>
     </hint>
     <hint type="destinationlabel">
      <x>730</x>
    <slot>on_update_lang()</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>107</x>
-     <y>110</y>
+     <x>644</x>
+     <y>155</y>
     </hint>
     <hint type="destinationlabel">
      <x>729</x>
    <slot>on_document_modified()</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>480</x>
+     <x>182</x>
      <y>41</y>
     </hint>
     <hint type="destinationlabel">
    <hints>
     <hint type="sourcelabel">
      <x>223</x>
-     <y>186</y>
+     <y>174</y>
     </hint>
     <hint type="destinationlabel">
      <x>538</x>
    <hints>
     <hint type="sourcelabel">
      <x>170</x>
-     <y>265</y>
+     <y>245</y>
     </hint>
     <hint type="destinationlabel">
      <x>196</x>
    <hints>
     <hint type="sourcelabel">
      <x>437</x>
-     <y>268</y>
+     <y>248</y>
     </hint>
     <hint type="destinationlabel">
      <x>88</x>
    <hints>
     <hint type="sourcelabel">
      <x>527</x>
-     <y>264</y>
+     <y>244</y>
     </hint>
     <hint type="destinationlabel">
      <x>165</x>
    <hints>
     <hint type="sourcelabel">
      <x>204</x>
-     <y>305</y>
+     <y>281</y>
     </hint>
     <hint type="destinationlabel">
      <x>-1</x>
    <hints>
     <hint type="sourcelabel">
      <x>409</x>
-     <y>309</y>
+     <y>285</y>
     </hint>
     <hint type="destinationlabel">
      <x>575</x>
    <hints>
     <hint type="sourcelabel">
      <x>588</x>
-     <y>305</y>
+     <y>281</y>
     </hint>
     <hint type="destinationlabel">
      <x>0</x>
    <hints>
     <hint type="sourcelabel">
      <x>93</x>
-     <y>356</y>
+     <y>328</y>
     </hint>
     <hint type="destinationlabel">
      <x>-3</x>
    <hints>
     <hint type="sourcelabel">
      <x>372</x>
-     <y>351</y>
+     <y>323</y>
     </hint>
     <hint type="destinationlabel">
      <x>2</x>
    <hints>
     <hint type="sourcelabel">
      <x>118</x>
-     <y>396</y>
+     <y>364</y>
     </hint>
     <hint type="destinationlabel">
      <x>0</x>
    <hints>
     <hint type="sourcelabel">
      <x>149</x>
-     <y>436</y>
+     <y>400</y>
     </hint>
     <hint type="destinationlabel">
      <x>1</x>
    <hints>
     <hint type="sourcelabel">
      <x>212</x>
-     <y>431</y>
+     <y>395</y>
     </hint>
     <hint type="destinationlabel">
      <x>3</x>
    <hints>
     <hint type="sourcelabel">
      <x>303</x>
-     <y>436</y>
+     <y>400</y>
     </hint>
     <hint type="destinationlabel">
      <x>-2</x>
    <hints>
     <hint type="sourcelabel">
      <x>99</x>
-     <y>89</y>
+     <y>101</y>
     </hint>
     <hint type="destinationlabel">
      <x>0</x>
    <hints>
     <hint type="sourcelabel">
      <x>90</x>
-     <y>102</y>
+     <y>297</y>
     </hint>
     <hint type="destinationlabel">
      <x>2</x>
    <hints>
     <hint type="sourcelabel">
      <x>94</x>
-     <y>103</y>
+     <y>333</y>
     </hint>
     <hint type="destinationlabel">
      <x>1</x>
     </hint>
    </hints>
   </connection>
+  <connection>
+   <sender>actionE_xit</sender>
+   <signal>triggered()</signal>
+   <receiver>biacv_mainwindow</receiver>
+   <slot>on_exit()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>-1</x>
+     <y>-1</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>364</x>
+     <y>248</y>
+    </hint>
+   </hints>
+  </connection>
  </connections>
  <slots>
   <slot>on_add_education()</slot>
   <slot>on_file_save()</slot>
   <slot>on_file_open()</slot>
   <slot>on_file_save_as()</slot>
+  <slot>on_exit()</slot>
  </slots>
 </ui>
index 504b102..35ef21f 100644 (file)
@@ -2,7 +2,7 @@
 
 # Form implementation generated from reading ui file 'biacv_mainwindow.ui'
 #
-# Created: Tue Dec  6 10:37:09 2011
+# Created: Tue Dec  6 11:15:27 2011
 #      by: PyQt4 UI code generator 4.8.6
 #
 # WARNING! All changes made in this file will be lost!
@@ -610,6 +610,7 @@ class Ui_biacv_mainwindow(object):
         QtCore.QObject.connect(self.action_Save, QtCore.SIGNAL(_fromUtf8("triggered()")), biacv_mainwindow.on_file_save)
         QtCore.QObject.connect(self.action_Open, QtCore.SIGNAL(_fromUtf8("triggered()")), biacv_mainwindow.on_file_open)
         QtCore.QObject.connect(self.actionSave_As, QtCore.SIGNAL(_fromUtf8("triggered()")), biacv_mainwindow.on_file_save_as)
+        QtCore.QObject.connect(self.actionE_xit, QtCore.SIGNAL(_fromUtf8("triggered()")), biacv_mainwindow.on_exit)
         QtCore.QMetaObject.connectSlotsByName(biacv_mainwindow)
 
     def retranslateUi(self, biacv_mainwindow):