forked from IPKM/nmreval
use of properties did not work properly
This commit is contained in:
parent
ff2ff01da7
commit
7ad1e4b843
@ -225,7 +225,7 @@ class CodeEditor(QtWidgets.QPlainTextEdit):
|
||||
|
||||
def paintevent_linenumber(self, evt):
|
||||
painter = QtGui.QPainter(self.current_linenumber)
|
||||
painter.fillRect(evt.rect(), QtCore.Qt.lightGray)
|
||||
painter.fillRect(evt.rect(), QtCore.Qt.GlobalColor.lightGray)
|
||||
|
||||
block = self.firstVisibleBlock()
|
||||
block_number = block.blockNumber()
|
||||
@ -237,9 +237,9 @@ class CodeEditor(QtWidgets.QPlainTextEdit):
|
||||
while block.isValid() and (top <= evt.rect().bottom()):
|
||||
if block.isVisible() and (bottom >= evt.rect().top()):
|
||||
number = str(block_number + 1)
|
||||
painter.setPen(QtCore.Qt.black)
|
||||
painter.setPen(QtCore.Qt.GlobalColor.black)
|
||||
painter.drawText(0, int(top), self.current_linenumber.width() - 3, height,
|
||||
QtCore.Qt.AlignRight, number)
|
||||
QtCore.Qt.AlignmentFlag.AlignRight, number)
|
||||
|
||||
block = block.next()
|
||||
top = bottom
|
||||
@ -252,7 +252,7 @@ class CodeEditor(QtWidgets.QPlainTextEdit):
|
||||
if not self.isReadOnly():
|
||||
selection = QtWidgets.QTextEdit.ExtraSelection()
|
||||
|
||||
line_color = QtGui.QColor(QtCore.Qt.yellow).lighter(180)
|
||||
line_color = QtGui.QColor(QtCore.Qt.GlobalColor.yellow).lighter(180)
|
||||
|
||||
selection.format.setBackground(line_color)
|
||||
selection.format.setProperty(QtGui.QTextFormat.FullWidthSelection, True)
|
||||
|
@ -55,13 +55,11 @@ class QUsermodelEditor(QtWidgets.QMainWindow):
|
||||
self.size(), QtWidgets.qApp.desktop().availableGeometry()
|
||||
))
|
||||
|
||||
@property
|
||||
def is_modified(self):
|
||||
return self.edit_field.document().isModified()
|
||||
return self.edit_field.editor.document().isModified()
|
||||
|
||||
@is_modified.setter
|
||||
def is_modified(self, val: bool):
|
||||
self.edit_field.document().setModified(val)
|
||||
def set_modified(self, val: bool):
|
||||
self.edit_field.editor.document().setModified(val)
|
||||
|
||||
@QtCore.pyqtSlot()
|
||||
def open_file(self):
|
||||
@ -83,9 +81,8 @@ class QUsermodelEditor(QtWidgets.QMainWindow):
|
||||
self._dir = self.fname.parent
|
||||
self.setWindowTitle('Edit ' + str(fname))
|
||||
|
||||
@property
|
||||
def changes_saved(self) -> bool:
|
||||
if not self.is_modified:
|
||||
if not self.is_modified():
|
||||
return True
|
||||
|
||||
ret = QtWidgets.QMessageBox.question(self, 'Time to think',
|
||||
@ -97,9 +94,9 @@ class QUsermodelEditor(QtWidgets.QMainWindow):
|
||||
self.save_file()
|
||||
|
||||
if ret == QtWidgets.QMessageBox.No:
|
||||
self.is_modified = False
|
||||
self.set_modified(False)
|
||||
|
||||
return not self.is_modified
|
||||
return not self.is_modified()
|
||||
|
||||
@QtCore.pyqtSlot()
|
||||
def save_file(self):
|
||||
@ -111,9 +108,9 @@ class QUsermodelEditor(QtWidgets.QMainWindow):
|
||||
|
||||
self.set_fname_opts(outfile)
|
||||
|
||||
self.is_modified = False
|
||||
self.set_modified(False)
|
||||
|
||||
return self.is_modified
|
||||
return self.is_modified()
|
||||
|
||||
@QtCore.pyqtSlot()
|
||||
def overwrite_file(self):
|
||||
@ -123,10 +120,10 @@ class QUsermodelEditor(QtWidgets.QMainWindow):
|
||||
|
||||
self.modelsChanged.emit()
|
||||
|
||||
self.is_modified = False
|
||||
self.set_modified(False)
|
||||
|
||||
def closeEvent(self, evt: QtGui.QCloseEvent):
|
||||
if self.is_modified:
|
||||
if not self.changes_saved():
|
||||
evt.ignore()
|
||||
else:
|
||||
super().closeEvent(evt)
|
||||
|
Loading…
Reference in New Issue
Block a user