diff --git a/Orange/widgets/unsupervised/owhierarchicalclustering.py b/Orange/widgets/unsupervised/owhierarchicalclustering.py index f6cc9dcdfb6..6a30d2fade6 100644 --- a/Orange/widgets/unsupervised/owhierarchicalclustering.py +++ b/Orange/widgets/unsupervised/owhierarchicalclustering.py @@ -7,10 +7,10 @@ import numpy as np from AnyQt.QtWidgets import ( - QGraphicsWidget, QGraphicsObject, QGraphicsScene, QGridLayout, QSizePolicy, + QGraphicsWidget, QGraphicsScene, QGridLayout, QSizePolicy, QAction, QComboBox, QGraphicsGridLayout, QGraphicsSceneMouseEvent ) -from AnyQt.QtGui import QColor, QPen, QFont, QKeySequence +from AnyQt.QtGui import QPen, QFont, QKeySequence, QPainterPath from AnyQt.QtCore import Qt, QSizeF, QPointF, QRectF, QLineF, QEvent from AnyQt.QtCore import pyqtSignal as Signal, pyqtSlot as Slot @@ -891,7 +891,7 @@ def mouseReleaseEvent(self, event): event.accept() -class SliderLine(QGraphicsObject): +class SliderLine(QGraphicsWidget): """A movable slider line.""" valueChanged = Signal(float) @@ -907,14 +907,10 @@ def __init__(self, parent=None, orientation=Qt.Vertical, value=0.0, self._length = length self._min = 0.0 self._max = 1.0 - self._line = QLineF() # type: Optional[QLineF] - self._pen = QPen() + self._line: Optional[QLineF] = QLineF() + self._pen: Optional[QPen] = None super().__init__(parent, **kwargs) - self.setAcceptedMouseButtons(Qt.LeftButton) - self.setPen(make_pen(brush=QColor(50, 50, 50), width=1, cosmetic=False, - style=Qt.DashLine)) - if self._orientation == Qt.Vertical: self.setCursor(Qt.SizeVerCursor) else: @@ -929,7 +925,10 @@ def setPen(self, pen: Union[QPen, Qt.GlobalColor, Qt.PenStyle]) -> None: self.update() def pen(self) -> QPen: - return QPen(self._pen) + if self._pen is None: + return QPen(self.palette().text(), 1.0, Qt.DashLine) + else: + return QPen(self._pen) def setValue(self, value: float): value = min(max(value, self._min), self._max) @@ -991,6 +990,11 @@ def mouseReleaseEvent(self, event: QGraphicsSceneMouseEvent) -> None: self.lineReleased.emit() event.accept() + def shape(self) -> QPainterPath: + path = QPainterPath() + path.addRect(self.boundingRect()) + return path + def boundingRect(self) -> QRectF: if self._line is None: if self._orientation == Qt.Vertical: