1 # BiaWeb Website content manager (c) 2010 V.Harishankar
5 import ui_editor_dialog
8 class EditorDialog (PyQt4
.QtGui
.QDialog
, ui_editor_dialog
.Ui_EditorDialog
):
9 def __init__ (self
, master
, title
, init_text
):
10 PyQt4
.QtGui
.QDialog
.__init
__ (self
, master
)
13 # set the flags to a normal maximizable window
14 self
.setWindowFlags (PyQt4
.QtCore
.Qt
.Window
)
17 self
.setWindowTitle ("Editor - " + title
)
19 # set text highlighting
20 highlighter
.SimpleHtmlHighlighter (self
.text
.document ())
22 self
.text
.setPlainText (init_text
)
23 # set modified flag to false
26 # when cancelled check if modified and confirm first
28 # if modified ask confirmation first
29 if self
.modified
== True:
30 ans
= PyQt4
.QtGui
.QMessageBox
.question (self
, "Confirm",
31 "Changes will be lost. Are you sure you wish to cancel editing?",
32 PyQt4
.QtGui
.QMessageBox
.Yes
, PyQt4
.QtGui
.QMessageBox
.No
)
34 if ans
== PyQt4
.QtGui
.QMessageBox
.Yes
:
35 PyQt4
.QtGui
.QDialog
.reject (self
)
38 PyQt4
.QtGui
.QDialog
.reject (self
)
40 def onTextChanged (self
):