Add rudimentary drag and drop

This commit is contained in:
CPD 2025-03-12 17:45:58 +01:00
parent f50631521c
commit fab41962fd

View File

@ -86,8 +86,26 @@ class MainWindow(QMainWindow):
# Measurement metadata
self.w_metadata = MetadataInput(metadata_init_dict)
self.w_lefttab.addTab(self.w_metadata, "Measurement metadata")
# TODO: the call_f solution isnt pretty
# TODO: only accept single file?
class RightTab(QTabWidget):
def __init__(self, call_f, parent=None):
super().__init__(parent)
self.setAcceptDrops(True)
self.call_f = call_f
def dragEnterEvent(self, event):
if event.mimeData().hasUrls():
event.accept()
else:
event.ignore()
def dropEvent(self, event):
for url in event.mimeData().urls():
file_path = url.path()[1:]
if file_path.endswith("csv"):
self.call_f(file_path)
return
# Right: Tabs: Script, Plot
self.w_right_tab = QTabWidget()
self.w_right_tab = RightTab(self.measurement_load)
layout.addWidget(self.w_right_tab)
max_data_points = AppConfig.MAIN_CFG.get_or("plot_max_data_points", 40000)
self.w_plot = Plot(max_data_points=max_data_points)