Skip to content

Commit

Permalink
Change of the drop plot indicator
Browse files Browse the repository at this point in the history
  • Loading branch information
RebeloAlexis committed Jun 25, 2024
1 parent 0175e0c commit 5ff849b
Showing 1 changed file with 20 additions and 12 deletions.
32 changes: 20 additions & 12 deletions src/silx/app/view/CustomPlotSelectionWindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,24 +359,28 @@ def _createRemoveButton(self, row: int, parentItem: qt.QStandardItem | None):
if parentItem is None:
parentItem = self.model().getXParent()
index = self.model().index(0, 2)
button = qt.QToolButton(self)
button.setIcon(icons.getQIcon("remove"))
button.clicked.connect(
functools.partial(self._removeFile, None, parentItem)
)
button = self._getRemoveButton(None, parentItem)
self.setIndexWidget(index, button)
return

# If the parentItem is not None, the remove button is for a Y dataset
removeItem = parentItem.child(row, 2)
if removeItem:
button = qt.QToolButton(self)
button.setIcon(icons.getQIcon("remove"))
button.clicked.connect(
functools.partial(self._removeFile, removeItem, parentItem)
)
button = self._getRemoveButton(removeItem, parentItem)
self.setIndexWidget(removeItem.index(), button)

def _getRemoveButton(
self, removeItem: qt.QStandardItem | None, parentItem: qt.QStandardItem
) -> qt.QToolButton:
"""Return a remove button widget."""
button = qt.QToolButton(self)
button.setIcon(icons.getQIcon("remove"))
button.setStyleSheet("QToolButton { border-radius: 0px; }")
button.clicked.connect(
functools.partial(self._removeFile, removeItem, parentItem)
)
return button

def _removeFile(
self, removeItem: qt.QStandardItem | None, parentItem: qt.QStandardItem
):
Expand Down Expand Up @@ -566,6 +570,7 @@ def _showDropOverlay(self, event):

class _PlotToolBar(qt.QToolBar):
"""Toolbar widget for the plot."""

def __init__(self, parent=None):
super().__init__(parent)

Expand All @@ -576,8 +581,10 @@ def addClearAction(self, treeView: qt.QTreeView):
clearAction.triggered.connect(treeView.clear)
self.addAction(clearAction)


class DropOverlay(qt.QWidget):
"""Overlay widget for displaying drop zones on the plot."""

def __init__(self, parent=None):
super().__init__(parent)
self.setAttribute(qt.Qt.WA_TransparentForMouseEvents)
Expand All @@ -597,8 +604,9 @@ def paintEvent(self, event):
"""Paint the overlay."""
painter = qt.QPainter(self)
painter.setRenderHint(qt.QPainter.Antialiasing)
painter.setPen(qt.QPen(qt.Qt.red, 3, qt.Qt.DashLine))
painter.setBrush(qt.QBrush(qt.Qt.transparent))
painter.setPen(qt.QPen(qt.Qt.black, 3, qt.Qt.DashLine))
brush_color = qt.QColor(0, 0, 0, 50)
painter.setBrush(qt.QBrush(brush_color))
painter.drawRect(self.rect())


Expand Down

0 comments on commit 5ff849b

Please sign in to comment.