Change left widget defaults

This commit is contained in:
CPD 2025-03-17 16:42:25 +01:00
parent d9947e18a9
commit 9ae5f44e2f

View File

@ -5,7 +5,7 @@ from PyQt6.QtCore import Qt, QTimer, QFileSystemWatcher
from PyQt6.QtWidgets import QMainWindow, QWidget, QHBoxLayout, QLabel, QStatusBar, QFileDialog, \ from PyQt6.QtWidgets import QMainWindow, QWidget, QHBoxLayout, QLabel, QStatusBar, QFileDialog, \
QVBoxLayout QVBoxLayout
from PyQt6.QtWidgets import QTabWidget from PyQt6.QtWidgets import QTabWidget
from PyQt6.QtGui import QIcon, QPixmap, QAction, QKeySequence from PyQt6.QtGui import QIcon, QPixmap, QAction, QKeySequence, QDragEnterEvent
from PyQt6.QtWidgets import QDialog, QDialogButtonBox, QMessageBox from PyQt6.QtWidgets import QDialog, QDialogButtonBox, QMessageBox
from ..resources import get_resource_path from ..resources import get_resource_path
@ -79,16 +79,17 @@ class MainWindow(QMainWindow):
# Left: Toolbox # Left: Toolbox
self.w_lefttab = QTabWidget(self) self.w_lefttab = QTabWidget(self)
self.w_lefttab.setMinimumWidth(300) self.w_lefttab.setMinimumWidth(300)
self.w_lefttab.setMaximumWidth(400)
layout.addWidget(self.w_lefttab) layout.addWidget(self.w_lefttab)
metadata_init_dict = AppConfig.MEAS_CFG.get_or("metadata", {}) metadata_init_dict = AppConfig.MEAS_CFG.get_or("metadata", {})
# Measurement settings # Measurement settings
self.w_measurement_settings = MeasurementSettings() self.w_measurement_settings = MeasurementSettings()
self.w_lefttab.addTab(self.w_measurement_settings, "Measurement settings") self.w_lefttab.addTab(self.w_measurement_settings, "Measurement Settings")
# Measurement metadata # Measurement metadata
self.w_metadata = MetadataInput(metadata_init_dict) self.w_metadata = MetadataInput(metadata_init_dict)
self.w_metadata.metadataChanged.connect(self._metadata_updated) self.w_metadata.metadataChanged.connect(self._metadata_updated)
self.w_lefttab.addTab(self.w_metadata, "Measurement metadata") self.w_lefttab.addTab(self.w_metadata, "Measurement Metadata")
# TODO: the call_f solution isnt pretty # TODO: the call_f solution isnt pretty
# TODO: only accept single file? # TODO: only accept single file?
class RightTab(QTabWidget): class RightTab(QTabWidget):
@ -97,10 +98,13 @@ class MainWindow(QMainWindow):
self.setAcceptDrops(True) self.setAcceptDrops(True)
self.call_f = call_f self.call_f = call_f
def dragEnterEvent(self, event): def dragEnterEvent(self, event):
if event.mimeData().hasUrls(): if not event.mimeData().hasUrls():
event.accept()
else:
event.ignore() event.ignore()
if len(event.mimeData().urls()) != 1:
event.ignore()
event.setDropAction(Qt.DropAction.LinkAction)
event.accept()
def dropEvent(self, event): def dropEvent(self, event):
for url in event.mimeData().urls(): for url in event.mimeData().urls():
file_path = url.path()[1:] file_path = url.path()[1:]