Skip to content

Commit

Permalink
Add structure beat text to beat tooltip timeline widget, closes #1374
Browse files Browse the repository at this point in the history
  • Loading branch information
zkovari committed Oct 2, 2024
1 parent 14e3b3d commit e3d50a2
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/main/python/plotlyst/view/widget/structure/timeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import qtanim
from PyQt6.QtCore import Qt, QEvent, pyqtSignal, QObject, QSize
from PyQt6.QtGui import QColor, QDragEnterEvent, QDropEvent, QResizeEvent, QCursor, QPainter, QPaintEvent, QPen
from PyQt6.QtWidgets import QWidget, QToolButton, QSizePolicy, QPushButton, QSplitter, QAbstractButton
from PyQt6.QtWidgets import QWidget, QToolButton, QSizePolicy, QPushButton, QSplitter, QAbstractButton, QToolTip
from overrides import overrides
from qthandy import hbox, transparent, italic, translucent, gc, clear_layout, vbox, margins, decr_font
from qthandy.filter import InstantTooltipEventFilter, DragEventFilter
Expand Down Expand Up @@ -65,6 +65,20 @@ def setBorderStyle(self):
# else:
# transparent(self)

@overrides
def event(self, event: QEvent) -> bool:
if event.type() == QEvent.Type.ToolTip:
tip = f'''<html><div style="color: {self.beat.icon_color}"><b align=center>{self.beat.text}</b>
<p/>
<hr/>
<p/>
{self.beat.notes}</div>
'''
QToolTip.showText(event.globalPos(), tip)
return True

return super().event(event)

def setTextStyle(self):
self.style = _BeatButtonStyle.Text
self.setToolButtonStyle(Qt.ToolButtonStyle.ToolButtonTextUnderIcon)
Expand Down Expand Up @@ -246,7 +260,6 @@ def __initButton(self, beat: StoryBeat, btn: Union[QAbstractButton, _BeatButton]
else:
icon = f'mdi.numeric-{beat.seq}'
btn.setIcon(IconRegistry.from_name(icon, beat.icon_color, scale=1.5))
btn.setToolTip(f'<b style="color: {beat.icon_color}">{beat.text}')
if beat.type == StoryBeatType.BEAT:
btn.toggled.connect(partial(self._beatToggled, btn))
btn.clicked.connect(partial(self._beatClicked, btn))
Expand Down

0 comments on commit e3d50a2

Please sign in to comment.