1
0
Fork 0
mirror of synced 2024-05-19 12:02:54 +12:00

ElideLabel: Improve tooltip handling

This commit is contained in:
loathingKernel 2023-03-13 00:54:25 +02:00
parent 4fd723df2e
commit 97e34d6052
No known key found for this signature in database
GPG key ID: CE0C72D0B53821FD

View file

@ -25,7 +25,11 @@ class ElideLabel(QLabel):
a0, Qt.ElideRight,
self.width() - (self.contentsMargins().left() + self.contentsMargins().right())
)
self.setToolTip(self.__text if elided_text != self.__text and not self.__tooltip else self.__tooltip)
if not self.__tooltip:
if self.__fm.boundingRect(elided_text).width() < self.__fm.boundingRect(self.__text).width():
super(ElideLabel, self).setToolTip(self.__text)
else:
super(ElideLabel, self).setToolTip("")
super(ElideLabel, self).setText(elided_text)
def setToolTip(self, a0: str) -> None: