make setting colour work if there's no selection

This commit is contained in:
Damien Elmes 2009-02-08 16:28:26 +09:00
parent 99f9f9cc40
commit 4d4fb8adba

View file

@ -551,14 +551,16 @@ class FactEditor(object):
# we lose the selection when we open the colour dialog on win32, # we lose the selection when we open the colour dialog on win32,
# so we need to save it # so we need to save it
cursor = w.textCursor() cursor = w.textCursor()
haveSel = cursor.hasSelection()
new = QColorDialog.getColor(w.textColor(), self.parent) new = QColorDialog.getColor(w.textColor(), self.parent)
if new.isValid(): if new.isValid():
w.setTextCursor(cursor) w.setTextCursor(cursor)
self.foregroundFrame.setPalette(QPalette(new)) self.foregroundFrame.setPalette(QPalette(new))
w.setTextColor(new) w.setTextColor(new)
# now we clear the selection # now we clear the selection
cursor.clearSelection() if haveSel:
w.setTextCursor(cursor) cursor.clearSelection()
w.setTextCursor(cursor)
self.fontChanged = True self.fontChanged = True
def insertLatex(self): def insertLatex(self):