From 780e0bada8c4872a140dfbf611b1eec8ef910d98 Mon Sep 17 00:00:00 2001 From: Simon Renblad Date: Mon, 15 Jan 2024 17:22:45 +0800 Subject: [PATCH] dndwidgets: improvements --- artiq/gui/dndwidgets.py | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/artiq/gui/dndwidgets.py b/artiq/gui/dndwidgets.py index f7afd5e0e..43cc20d4b 100644 --- a/artiq/gui/dndwidgets.py +++ b/artiq/gui/dndwidgets.py @@ -23,6 +23,7 @@ class DragDropSplitter(QtWidgets.QSplitter): pos = e.pos() src = e.source() src_i = self.indexOf(src) + self.setRubberBand(self.height()) # case 0: smaller than source widget if pos.y() < src.y(): for n in range(src_i): @@ -34,8 +35,8 @@ class DragDropSplitter(QtWidgets.QSplitter): elif pos.y() > src.y() + src.size().height(): for n in range(src_i + 1, self.count()): w = self.widget(n) - if pos.y() < w.y() + w.size().height(): - self.setRubberBand(w.y() + w.size().height()) + if pos.y() < w.y(): + self.setRubberBand(w.y()) break else: self.setRubberBand(-1) @@ -46,20 +47,11 @@ class DragDropSplitter(QtWidgets.QSplitter): pos = e.pos() src = e.source() src_i = self.indexOf(src) - # case 0: smaller than source widget - if pos.y() < src.y(): - for n in range(src_i): - w = self.widget(n) - if pos.y() < w.y() + w.size().height(): - self.insertWidget(n, src) - break - # case 2: greater than source widget - elif pos.y() > src.y() + src.size().height(): - for n in range(src_i + 1, self.count()): - w = self.widget(n) - if pos.y() < w.y() + w.size().height(): - self.insertWidget(n, src) - break + for n in range(self.count()): + w = self.widget(n) + if pos.y() < w.y() + w.size().height(): + self.insertWidget(n, src) + break e.accept()