--- /dev/null
+# BiaWeb Website content manager (c) 2010 V.Harishankar
+# Editor dialog class
+
+import PyQt4
+import ui_editor_dialog
+import highlighter
+
+class EditorDialog (PyQt4.QtGui.QDialog, ui_editor_dialog.Ui_EditorDialog):
+ def __init__ (self, master, title, init_text):
+ PyQt4.QtGui.QDialog.__init__ (self, master)
+ self.setupUi (self)
+
+ # set the flags to a normal maximizable window
+ self.setWindowFlags (PyQt4.QtCore.Qt.Window)
+
+ # set the title
+ self.setWindowTitle ("Editor - " + title)
+
+ # set text highlighting
+ highlighter.SimpleHtmlHighlighter (self.template_text.document ())
+
+ self.template_text.setPlainText (init_text)
+ # set modified flag to false
+ self.modified = False
+
+ # when cancelled check if modified and confirm first
+ def reject (self):
+ # if modified ask confirmation first
+ if self.modified == True:
+ ans = PyQt4.QtGui.QMessageBox.question (self, "Confirm",
+ "Changes will be lost. Are you sure you wish to cancel editing?",
+ PyQt4.QtGui.QMessageBox.Yes, PyQt4.QtGui.QMessageBox.No)
+ # if confirmed
+ if ans == PyQt4.QtGui.QMessageBox.Yes:
+ PyQt4.QtGui.QDialog.reject (self)
+ # not modified
+ else:
+ PyQt4.QtGui.QDialog.reject (self)
+
+ def onTextChanged (self):
+ self.modified = True