mirror of
https://github.com/olivierkes/manuskript.git
synced 2024-06-01 10:39:34 +12:00
Improves colors of index card delegate editor
This commit is contained in:
parent
0c3f96014a
commit
845aa8b205
|
@ -21,6 +21,8 @@ class corkDelegate(QStyledItemDelegate):
|
||||||
self.editing = None
|
self.editing = None
|
||||||
self.margin = 5
|
self.margin = 5
|
||||||
|
|
||||||
|
self.bgColors = {}
|
||||||
|
|
||||||
def newStyle(self):
|
def newStyle(self):
|
||||||
return settings.corkStyle == "new"
|
return settings.corkStyle == "new"
|
||||||
|
|
||||||
|
@ -43,6 +45,8 @@ class corkDelegate(QStyledItemDelegate):
|
||||||
def createEditor(self, parent, option, index):
|
def createEditor(self, parent, option, index):
|
||||||
self.updateRects(option, index)
|
self.updateRects(option, index)
|
||||||
|
|
||||||
|
bgColor = self.bgColors.get(index, "white")
|
||||||
|
|
||||||
if self.mainLineRect.contains(self.lastPos):
|
if self.mainLineRect.contains(self.lastPos):
|
||||||
# One line summary
|
# One line summary
|
||||||
self.editing = Outline.summarySentence
|
self.editing = Outline.summarySentence
|
||||||
|
@ -57,6 +61,7 @@ class corkDelegate(QStyledItemDelegate):
|
||||||
edt.setAlignment(Qt.AlignCenter)
|
edt.setAlignment(Qt.AlignCenter)
|
||||||
edt.setPlaceholderText(self.tr("One line summary"))
|
edt.setPlaceholderText(self.tr("One line summary"))
|
||||||
edt.setFont(f)
|
edt.setFont(f)
|
||||||
|
edt.setStyleSheet("background: {}; color: black;".format(bgColor))
|
||||||
return edt
|
return edt
|
||||||
|
|
||||||
elif self.titleRect.contains(self.lastPos):
|
elif self.titleRect.contains(self.lastPos):
|
||||||
|
@ -72,6 +77,7 @@ class corkDelegate(QStyledItemDelegate):
|
||||||
edt.setAlignment(Qt.AlignCenter)
|
edt.setAlignment(Qt.AlignCenter)
|
||||||
f.setBold(True)
|
f.setBold(True)
|
||||||
edt.setFont(f)
|
edt.setFont(f)
|
||||||
|
edt.setStyleSheet("background: {}; color: black;".format(bgColor))
|
||||||
# edt.setGeometry(self.titleRect)
|
# edt.setGeometry(self.titleRect)
|
||||||
return edt
|
return edt
|
||||||
|
|
||||||
|
@ -86,6 +92,7 @@ class corkDelegate(QStyledItemDelegate):
|
||||||
edt.setPlaceholderText(self.tr("Full summary"))
|
edt.setPlaceholderText(self.tr("Full summary"))
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
pass
|
pass
|
||||||
|
edt.setStyleSheet("background: {}; color: black;".format(bgColor))
|
||||||
return edt
|
return edt
|
||||||
|
|
||||||
def updateEditorGeometry(self, editor, option, index):
|
def updateEditorGeometry(self, editor, option, index):
|
||||||
|
@ -247,6 +254,9 @@ class corkDelegate(QStyledItemDelegate):
|
||||||
p.setBrush(Qt.white)
|
p.setBrush(Qt.white)
|
||||||
backgroundColor = QColor(Qt.white)
|
backgroundColor = QColor(Qt.white)
|
||||||
|
|
||||||
|
# Cache background color
|
||||||
|
self.bgColors[index] = backgroundColor.name()
|
||||||
|
|
||||||
p.setPen(Qt.NoPen)
|
p.setPen(Qt.NoPen)
|
||||||
p.drawRect(self.cardRect)
|
p.drawRect(self.cardRect)
|
||||||
if item.isFolder():
|
if item.isFolder():
|
||||||
|
|
Loading…
Reference in a new issue