Commits

Yuya Nishihara committed 4319fbe

infobar: emit finished signal like QDialog

The logic of finished signal is loosely based on QDialog.

  • Participants
  • Parent commits 38c54dc

Comments (0)

Files changed (1)

File tortoisehg/hgqt/qtlib.py

 
         |widgets ...                |right widgets ...|x|
     """
+    finished = pyqtSignal(int)  # mimic QDialog
     linkActivated = pyqtSignal(unicode)
 
     # type of InfoBar (the number denotes its priority)
     def addRightWidget(self, w):
         self.layout().insertWidget(self.layout().count() - 1, w)
 
+    def closeEvent(self, event):
+        if self.isVisible():
+            self.finished.emit(0)
+        super(InfoBar, self).closeEvent(event)
+
     def keyPressEvent(self, event):
         if event.key() == Qt.Key_Escape:
             self.close()
 
     def closeEvent(self, event):
         if self.isVisible():
+            self.finished.emit(1)
             self.rejected.emit()
+            self.hide()  # avoid double emission of finished signal
         super(ConfirmInfoBar, self).closeEvent(event)
 
     @pyqtSlot()
     def _accept(self):
+        self.finished.emit(0)
         self.accepted.emit()
         self.hide()
         self.close()
 
     @pyqtSlot()
     def _reject(self):
+        self.finished.emit(1)
         self.rejected.emit()
         self.hide()
         self.close()