mirror of
https://github.com/KeksPirates/SoftwareManager.git
synced 2026-08-03 17:39:42 +02:00
feat: improve hover row delegate rendering by adjusting focus and selection states
This commit is contained in:
@@ -458,21 +458,27 @@ class MainWindow(QtWidgets.QMainWindow, QWidget):
|
|||||||
|
|
||||||
class HoverRowDelegate(QStyledItemDelegate):
|
class HoverRowDelegate(QStyledItemDelegate):
|
||||||
def paint(self, painter, option, index):
|
def paint(self, painter, option, index):
|
||||||
|
opt = QtWidgets.QStyleOptionViewItem(option)
|
||||||
|
opt.state &= ~QtWidgets.QStyle.StateFlag.State_HasFocus
|
||||||
|
opt.state &= ~QtWidgets.QStyle.StateFlag.State_Selected
|
||||||
if index.row() == MainWindow._instance._hovered_row:
|
if index.row() == MainWindow._instance._hovered_row:
|
||||||
painter.save()
|
painter.save()
|
||||||
painter.fillRect(option.rect, _theme_colors()["hover"])
|
painter.fillRect(opt.rect, _theme_colors()["hover"])
|
||||||
painter.restore()
|
painter.restore()
|
||||||
super().paint(painter, option, index)
|
super().paint(painter, opt, index)
|
||||||
|
|
||||||
class PauseResumeDelegate(QStyledItemDelegate):
|
class PauseResumeDelegate(QStyledItemDelegate):
|
||||||
clicked = Signal(int)
|
clicked = Signal(int)
|
||||||
|
|
||||||
def paint(self, painter, option, index):
|
def paint(self, painter, option, index):
|
||||||
|
opt = QtWidgets.QStyleOptionViewItem(option)
|
||||||
|
opt.state &= ~QtWidgets.QStyle.StateFlag.State_HasFocus
|
||||||
|
opt.state &= ~QtWidgets.QStyle.StateFlag.State_Selected
|
||||||
if index.row() == MainWindow._instance._hovered_row:
|
if index.row() == MainWindow._instance._hovered_row:
|
||||||
painter.save()
|
painter.save()
|
||||||
painter.fillRect(option.rect, _theme_colors()["hover"])
|
painter.fillRect(opt.rect, _theme_colors()["hover"])
|
||||||
painter.restore()
|
painter.restore()
|
||||||
super().paint(painter, option, index)
|
super().paint(painter, opt, index)
|
||||||
|
|
||||||
def setEditorData(self, editor, index):
|
def setEditorData(self, editor, index):
|
||||||
button = editor.findChild(QtWidgets.QPushButton)
|
button = editor.findChild(QtWidgets.QPushButton)
|
||||||
|
|||||||
Reference in New Issue
Block a user