forked from M-Labs/artiq
1
0
Fork 0

dashboard: fix pyqt6 gui bugs

This commit is contained in:
Simon Renblad 2024-07-29 10:29:43 +08:00 committed by Sébastien Bourdeauducq
parent 6698a6f80c
commit ab090f9caf
5 changed files with 27 additions and 18 deletions

View File

@ -338,7 +338,7 @@ class _DACWidget(_MoninjWidget):
self.offset_dacs = offset_dacs
self.value = QtWidgets.QLabel()
self.value.setAlignment(QtCore.Qt.AlignHCenter | QtCore.Qt.AlignTop)
self.value.setAlignment(QtCore.Qt.AlignmentFlag.AlignHCenter | QtCore.Qt.AlignmentFlag.AlignTop)
self.grid.addWidget(self.value, 2, 1, 6, 1)
self.grid.setRowStretch(1, 1)

View File

@ -208,16 +208,19 @@ class _BaseWaveform(pg.PlotWidget):
pixmapi = QtWidgets.QApplication.style().standardIcon(
QtWidgets.QStyle.StandardPixmap.SP_FileIcon)
drag.setPixmap(pixmapi.pixmap(32))
drag.exec_(QtCore.Qt.MoveAction)
drag.exec(QtCore.Qt.DropAction.MoveAction)
else:
super().mouseMoveEvent(e)
def wheelEvent(self, e):
if e.modifiers() & QtCore.Qt.ControlModifier:
if e.modifiers() & QtCore.Qt.KeyboardModifier.ControlModifier:
super().wheelEvent(e)
else:
e.ignore()
def mouseDoubleClickEvent(self, e):
pos = self.view_box.mapSceneToView(e.pos())
pos = self.view_box.mapSceneToView(e.position())
self.cursorMove.emit(pos.x())
@ -393,6 +396,13 @@ class LogWaveform(_BaseWaveform):
self.plot_data_item.setData(x=[], y=[])
# pg.GraphicsView ignores dragEnterEvent but not dragLeaveEvent
# https://github.com/pyqtgraph/pyqtgraph/blob/1e98704eac6b85de9c35371079f561042e88ad68/pyqtgraph/widgets/GraphicsView.py#L388
class _RefAxis(pg.PlotWidget):
def dragLeaveEvent(self, ev):
ev.ignore()
class _WaveformView(QtWidgets.QWidget):
cursorMove = QtCore.pyqtSignal(float)
@ -408,7 +418,7 @@ class _WaveformView(QtWidgets.QWidget):
layout.setSpacing(0)
self.setLayout(layout)
self._ref_axis = pg.PlotWidget()
self._ref_axis = _RefAxis()
self._ref_axis.hideAxis("bottom")
self._ref_axis.hideAxis("left")
self._ref_axis.hideButtons()

View File

@ -256,7 +256,7 @@ def main():
right_docks = [
d_explorer, d_shortcuts,
d_datasets, d_applets,
# d_waveform, d_interactive_args
d_waveform, d_interactive_args
]
main_window.addDockWidget(QtCore.Qt.DockWidgetArea.RightDockWidgetArea, right_docks[0])
for d1, d2 in zip(right_docks, right_docks[1:]):

View File

@ -24,7 +24,7 @@ class VDragDropSplitter(QtWidgets.QSplitter):
e.accept()
def dragMoveEvent(self, e):
pos = e.pos()
pos = e.position()
src = e.source()
src_i = self.indexOf(src)
self.setRubberBand(self.height())
@ -48,7 +48,7 @@ class VDragDropSplitter(QtWidgets.QSplitter):
def dropEvent(self, e):
self.setRubberBand(-1)
pos = e.pos()
pos = e.position()
src = e.source()
src_i = self.indexOf(src)
for n in range(self.count()):
@ -81,7 +81,7 @@ class VDragScrollArea(QtWidgets.QScrollArea):
if e.type() == QtCore.QEvent.Type.DragMove:
val = self.verticalScrollBar().value()
height = self.viewport().height()
y = e.pos().y()
y = e.position().y()
self._direction = 0
if y < val + self._margin:
self._direction = -1
@ -119,7 +119,7 @@ class DragDropFlowLayoutWidget(QtWidgets.QWidget):
def mousePressEvent(self, event):
if event.buttons() == QtCore.Qt.MouseButton.LeftButton \
and event.modifiers() == QtCore.Qt.KeyboardModifier.ShiftModifier:
index = self._get_index(event.pos())
index = self._get_index(event.position())
if index == -1:
return
drag = QtGui.QDrag(self)
@ -136,7 +136,7 @@ class DragDropFlowLayoutWidget(QtWidgets.QWidget):
event.accept()
def dropEvent(self, event):
index = self._get_index(event.pos())
index = self._get_index(event.position())
source_layout = event.source()
source_index = int(bytes(event.mimeData().data("index")).decode())
if source_layout == self:

View File

@ -23,13 +23,13 @@ class EntryTreeWidget(QtWidgets.QTreeWidget):
set_resize_mode = self.header().setSectionResizeMode
else:
set_resize_mode = self.header().setResizeMode
set_resize_mode(0, QtWidgets.QHeaderView.ResizeToContents)
set_resize_mode(1, QtWidgets.QHeaderView.Stretch)
set_resize_mode(2, QtWidgets.QHeaderView.ResizeToContents)
set_resize_mode(0, QtWidgets.QHeaderView.ResizeMode.ResizeToContents)
set_resize_mode(1, QtWidgets.QHeaderView.ResizeMode.Stretch)
set_resize_mode(2, QtWidgets.QHeaderView.ResizeMode.ResizeToContents)
self.header().setVisible(False)
self.setSelectionMode(self.NoSelection)
self.setHorizontalScrollMode(self.ScrollPerPixel)
self.setVerticalScrollMode(self.ScrollPerPixel)
self.setSelectionMode(self.SelectionMode.NoSelection)
self.setHorizontalScrollMode(self.ScrollMode.ScrollPerPixel)
self.setVerticalScrollMode(self.ScrollMode.ScrollPerPixel)
self.setStyleSheet("QTreeWidget {background: " +
self.palette().midlight().color().name() + " ;}")
@ -109,7 +109,6 @@ class EntryTreeWidget(QtWidgets.QTreeWidget):
group = QtWidgets.QTreeWidgetItem([key])
for col in range(3):
group.setBackground(col, self.palette().mid())
group.setForeground(col, self.palette().brightText())
font = group.font(col)
font.setBold(True)
group.setFont(col, font)