예제 #1
0
파일: app.py 프로젝트: Alwnikrotikz/lilykde
 def queryClose(self):
     """Ask user if document modified and saves if desired."""
     # Many stuff copied from KatePart
     if not self.doc or not self.isModified():
         return True
     res = KMessageBox.warningYesNoCancel(self.app.mainwin, i18n(
         "The document \"%1\" has been modified.\n"
         "Do you want to save your changes or discard them?",
         self.documentName()), i18n("Close Document"),
         KStandardGuiItem.save(), KStandardGuiItem.discard())
     if res == KMessageBox.Yes:
         self.save()
     elif res == KMessageBox.No:
         return True
     else: # cancel
         return False
 def __getGuiItem(button):
     """
     Private function to create a KGuiItem for a button.
     
     @param button flag indicating the button (QMessageBox.StandardButton)
     @return item for the button (KGuiItem)
     """
     if button == QMessageBox.Ok:
         return KStandardGuiItem.ok()
     elif button == QMessageBox.Cancel:
         return KStandardGuiItem.cancel()
     elif button == QMessageBox.Yes:
         return KStandardGuiItem.yes()
     elif button == QMessageBox.No:
         return KStandardGuiItem.no()
     elif button == QMessageBox.Discard:
         return KStandardGuiItem.discard()
     elif button == QMessageBox.Save:
         return KStandardGuiItem.save()
     elif button == QMessageBox.Apply:
         return KStandardGuiItem.apply()
     elif button == QMessageBox.Help:
         return KStandardGuiItem.help()
     elif button == QMessageBox.Close:
         return KStandardGuiItem.close()
     elif button == QMessageBox.Open:
         return KStandardGuiItem.open()
     elif button == QMessageBox.Reset:
         return KStandardGuiItem.reset()
     elif button == QMessageBox.Ignore:
         return KGuiItem(QCoreApplication.translate("KQMessageBox", "Ignore"))
     elif button == QMessageBox.Abort:
         return KGuiItem(QCoreApplication.translate("KQMessageBox", "Abort"))
     elif button == QMessageBox.RestoreDefaults:
         return KGuiItem(QCoreApplication.translate("KQMessageBox", "Restore Defaults"))
     elif button == QMessageBox.SaveAll:
         return KGuiItem(QCoreApplication.translate("KQMessageBox", "Save All"))
     elif button == QMessageBox.YesToAll:
         return KGuiItem(QCoreApplication.translate("KQMessageBox", "Yes to &All"))
     elif button == QMessageBox.NoToAll:
         return KGuiItem(QCoreApplication.translate("KQMessageBox", "N&o to All"))
     elif button == QMessageBox.Retry:
         return KGuiItem(QCoreApplication.translate("KQMessageBox", "Retry"))
     elif button == QMessageBox.NoButton:
         return KGuiItem()
     else:
         return KStandardGuiItem.ok()