mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-01 16:34:53 +01:00
created clickable label in utils
This commit is contained in:
parent
b7f6e2dd55
commit
42f47c868b
2 changed files with 28 additions and 1 deletions
|
|
@ -2,11 +2,12 @@ from .widgets import (
|
|||
PlaceholderLineEdit,
|
||||
BaseClickableFrame,
|
||||
ClickableFrame,
|
||||
ClickableLabel,
|
||||
ExpandBtn,
|
||||
PixmapLabel,
|
||||
IconButton,
|
||||
)
|
||||
|
||||
from .views import DeselectableTreeView
|
||||
from .error_dialog import ErrorMessageBox
|
||||
from .lib import (
|
||||
WrappedCallbackItem,
|
||||
|
|
@ -24,10 +25,13 @@ __all__ = (
|
|||
"PlaceholderLineEdit",
|
||||
"BaseClickableFrame",
|
||||
"ClickableFrame",
|
||||
"ClickableLabel",
|
||||
"ExpandBtn",
|
||||
"PixmapLabel",
|
||||
"IconButton",
|
||||
|
||||
"DeselectableTreeView",
|
||||
|
||||
"ErrorMessageBox",
|
||||
|
||||
"WrappedCallbackItem",
|
||||
|
|
|
|||
|
|
@ -63,6 +63,29 @@ class ClickableFrame(BaseClickableFrame):
|
|||
self.clicked.emit()
|
||||
|
||||
|
||||
class ClickableLabel(QtWidgets.QLabel):
|
||||
"""Label that catch left mouse click and can trigger 'clicked' signal."""
|
||||
clicked = QtCore.Signal()
|
||||
|
||||
def __init__(self, parent):
|
||||
super(ClickableLabel, self).__init__(parent)
|
||||
|
||||
self._mouse_pressed = False
|
||||
|
||||
def mousePressEvent(self, event):
|
||||
if event.button() == QtCore.Qt.LeftButton:
|
||||
self._mouse_pressed = True
|
||||
super(ClickableLabel, self).mousePressEvent(event)
|
||||
|
||||
def mouseReleaseEvent(self, event):
|
||||
if self._mouse_pressed:
|
||||
self._mouse_pressed = False
|
||||
if self.rect().contains(event.pos()):
|
||||
self.clicked.emit()
|
||||
|
||||
super(ClickableLabel, self).mouseReleaseEvent(event)
|
||||
|
||||
|
||||
class ExpandBtnLabel(QtWidgets.QLabel):
|
||||
"""Label showing expand icon meant for ExpandBtn."""
|
||||
def __init__(self, parent):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue