Skip to content

Commit

Permalink
Topic Modeling: Base selection style on itemdelegates
Browse files Browse the repository at this point in the history
  • Loading branch information
ajdapretnar committed Nov 15, 2021
1 parent ebfd330 commit 28b280b
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions orangecontrib/text/widgets/owtopicmodeling.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
QGroupBox, QTreeWidgetItem, QTreeWidget,
QStyleOptionViewItem, QStyledItemDelegate, QStyle)
from Orange.widgets.utils.concurrent import TaskState, ConcurrentWidgetMixin
from orangewidget.utils.itemdelegates import text_color_for_state

from gensim.models import CoherenceModel

Expand Down Expand Up @@ -368,7 +369,7 @@ class HTMLDelegate(QStyledItemDelegate):
Adopted from https://stackoverflow.com/a/5443112/892987 """
def paint(self, painter, option, index):
options = QStyleOptionViewItem(option)
self.initStyleOption(options,index)
self.initStyleOption(options, index)

style = QApplication.style() if options.widget is None else options.widget.style()

Expand All @@ -380,10 +381,8 @@ def paint(self, painter, option, index):

ctx = QtGui.QAbstractTextDocumentLayout.PaintContext()

if options.state & QStyle.State_Selected:
ctx.palette.setColor(QtGui.QPalette.Text,
options.palette.color(QtGui.QPalette.Active,
QtGui.QPalette.HighlightedText))
painter.setPen(
QtGui.QPen(text_color_for_state(option.palette, option.state)))

textRect = style.subElementRect(QStyle.SE_ItemViewItemText, options)
painter.save()
Expand All @@ -395,7 +394,7 @@ def paint(self, painter, option, index):

def sizeHint(self, option, index):
options = QStyleOptionViewItem(option)
self.initStyleOption(options,index)
self.initStyleOption(options, index)

doc = QtGui.QTextDocument()
doc.setHtml(options.text)
Expand Down

0 comments on commit 28b280b

Please sign in to comment.