Fixed om emission
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
from copy import deepcopy
|
||||
|
||||
from PySide6.QtWidgets import QDialog
|
||||
from PySide6.QtWidgets import QButtonGroup, QDialog
|
||||
|
||||
from bedit.gui.generated.ui_simulation_settings_dialog import Ui_SimulationSettingsDialog
|
||||
|
||||
@@ -11,12 +11,50 @@ class SimulationSettingsDialog(QDialog):
|
||||
self.ui = Ui_SimulationSettingsDialog()
|
||||
self.ui.setupUi(self)
|
||||
self._settings = deepcopy(settings)
|
||||
self.ui.placeholderCheckBox.setChecked(
|
||||
bool(self._settings.get("enabled", False))
|
||||
|
||||
self.interval_mode_group = QButtonGroup(self)
|
||||
self.interval_mode_group.setExclusive(True)
|
||||
self.interval_mode_group.addButton(self.ui.numberOfIntervalsRadioButton)
|
||||
self.interval_mode_group.addButton(self.ui.intervalTimeRadioButton)
|
||||
|
||||
self.ui.startTimeSpinBox.setValue(float(settings.get("startTime", 0.0)))
|
||||
self.ui.stopTimeSpinBox.setValue(float(settings.get("stopTime", 1.0)))
|
||||
self.ui.numberOfIntervalsSpinBox.setValue(
|
||||
int(settings.get("numberOfIntervals", 500))
|
||||
)
|
||||
self.ui.intervalTimeSpinBox.setValue(float(settings.get("intervalTime", 0.002)))
|
||||
|
||||
interval_mode = settings.get("intervalMode", "numberOfIntervals")
|
||||
if interval_mode == "intervalTime":
|
||||
self.ui.intervalTimeRadioButton.setChecked(True)
|
||||
else:
|
||||
self.ui.numberOfIntervalsRadioButton.setChecked(True)
|
||||
|
||||
self.ui.numberOfIntervalsRadioButton.toggled.connect(
|
||||
self._update_interval_fields
|
||||
)
|
||||
self.ui.intervalTimeRadioButton.toggled.connect(self._update_interval_fields)
|
||||
self._update_interval_fields()
|
||||
|
||||
def _update_interval_fields(self) -> None:
|
||||
use_number = self.ui.numberOfIntervalsRadioButton.isChecked()
|
||||
self.ui.numberOfIntervalsSpinBox.setEnabled(use_number)
|
||||
self.ui.intervalTimeSpinBox.setEnabled(not use_number)
|
||||
|
||||
@property
|
||||
def settings(self) -> dict:
|
||||
values = deepcopy(self._settings)
|
||||
values["enabled"] = self.ui.placeholderCheckBox.isChecked()
|
||||
values.update(
|
||||
{
|
||||
"startTime": self.ui.startTimeSpinBox.value(),
|
||||
"stopTime": self.ui.stopTimeSpinBox.value(),
|
||||
"intervalMode": (
|
||||
"numberOfIntervals"
|
||||
if self.ui.numberOfIntervalsRadioButton.isChecked()
|
||||
else "intervalTime"
|
||||
),
|
||||
"numberOfIntervals": self.ui.numberOfIntervalsSpinBox.value(),
|
||||
"intervalTime": self.ui.intervalTimeSpinBox.value(),
|
||||
}
|
||||
)
|
||||
return values
|
||||
|
||||
@@ -15,25 +15,76 @@ from PySide6.QtGui import (QBrush, QColor, QConicalGradient, QCursor,
|
||||
QFont, QFontDatabase, QGradient, QIcon,
|
||||
QImage, QKeySequence, QLinearGradient, QPainter,
|
||||
QPalette, QPixmap, QRadialGradient, QTransform)
|
||||
from PySide6.QtWidgets import (QAbstractButton, QApplication, QCheckBox, QDialog,
|
||||
QDialogButtonBox, QGroupBox, QSizePolicy, QSpacerItem,
|
||||
QVBoxLayout, QWidget)
|
||||
from PySide6.QtWidgets import (QAbstractButton, QAbstractSpinBox, QApplication, QDialog,
|
||||
QDialogButtonBox, QDoubleSpinBox, QFormLayout, QGroupBox,
|
||||
QLabel, QRadioButton, QSizePolicy, QSpacerItem,
|
||||
QSpinBox, QVBoxLayout, QWidget)
|
||||
|
||||
class Ui_SimulationSettingsDialog(object):
|
||||
def setupUi(self, SimulationSettingsDialog):
|
||||
if not SimulationSettingsDialog.objectName():
|
||||
SimulationSettingsDialog.setObjectName(u"SimulationSettingsDialog")
|
||||
SimulationSettingsDialog.resize(420, 180)
|
||||
SimulationSettingsDialog.resize(420, 384)
|
||||
self.dialogLayout = QVBoxLayout(SimulationSettingsDialog)
|
||||
self.dialogLayout.setObjectName(u"dialogLayout")
|
||||
self.settingsGroup = QGroupBox(SimulationSettingsDialog)
|
||||
self.settingsGroup.setObjectName(u"settingsGroup")
|
||||
self.settingsLayout = QVBoxLayout(self.settingsGroup)
|
||||
self.settingsLayout.setObjectName(u"settingsLayout")
|
||||
self.placeholderCheckBox = QCheckBox(self.settingsGroup)
|
||||
self.placeholderCheckBox.setObjectName(u"placeholderCheckBox")
|
||||
self.simulationInterval = QGroupBox(self.settingsGroup)
|
||||
self.simulationInterval.setObjectName(u"simulationInterval")
|
||||
self.simulationInterval.setEnabled(True)
|
||||
self.formLayout = QFormLayout(self.simulationInterval)
|
||||
self.formLayout.setObjectName(u"formLayout")
|
||||
self.label = QLabel(self.simulationInterval)
|
||||
self.label.setObjectName(u"label")
|
||||
|
||||
self.settingsLayout.addWidget(self.placeholderCheckBox)
|
||||
self.formLayout.setWidget(0, QFormLayout.ItemRole.LabelRole, self.label)
|
||||
|
||||
self.startTimeSpinBox = QDoubleSpinBox(self.simulationInterval)
|
||||
self.startTimeSpinBox.setObjectName(u"startTimeSpinBox")
|
||||
self.startTimeSpinBox.setEnabled(True)
|
||||
|
||||
self.formLayout.setWidget(0, QFormLayout.ItemRole.FieldRole, self.startTimeSpinBox)
|
||||
|
||||
self.label_2 = QLabel(self.simulationInterval)
|
||||
self.label_2.setObjectName(u"label_2")
|
||||
|
||||
self.formLayout.setWidget(1, QFormLayout.ItemRole.LabelRole, self.label_2)
|
||||
|
||||
self.stopTimeSpinBox = QDoubleSpinBox(self.simulationInterval)
|
||||
self.stopTimeSpinBox.setObjectName(u"stopTimeSpinBox")
|
||||
self.stopTimeSpinBox.setValue(1.000000000000000)
|
||||
|
||||
self.formLayout.setWidget(1, QFormLayout.ItemRole.FieldRole, self.stopTimeSpinBox)
|
||||
|
||||
self.numberOfIntervalsRadioButton = QRadioButton(self.simulationInterval)
|
||||
self.numberOfIntervalsRadioButton.setObjectName(u"numberOfIntervalsRadioButton")
|
||||
|
||||
self.formLayout.setWidget(2, QFormLayout.ItemRole.LabelRole, self.numberOfIntervalsRadioButton)
|
||||
|
||||
self.intervalTimeRadioButton = QRadioButton(self.simulationInterval)
|
||||
self.intervalTimeRadioButton.setObjectName(u"intervalTimeRadioButton")
|
||||
|
||||
self.formLayout.setWidget(3, QFormLayout.ItemRole.LabelRole, self.intervalTimeRadioButton)
|
||||
|
||||
self.numberOfIntervalsSpinBox = QSpinBox(self.simulationInterval)
|
||||
self.numberOfIntervalsSpinBox.setObjectName(u"numberOfIntervalsSpinBox")
|
||||
self.numberOfIntervalsSpinBox.setMaximum(999999999)
|
||||
self.numberOfIntervalsSpinBox.setValue(500)
|
||||
|
||||
self.formLayout.setWidget(2, QFormLayout.ItemRole.FieldRole, self.numberOfIntervalsSpinBox)
|
||||
|
||||
self.intervalTimeSpinBox = QDoubleSpinBox(self.simulationInterval)
|
||||
self.intervalTimeSpinBox.setObjectName(u"intervalTimeSpinBox")
|
||||
self.intervalTimeSpinBox.setDecimals(5)
|
||||
self.intervalTimeSpinBox.setStepType(QAbstractSpinBox.StepType.AdaptiveDecimalStepType)
|
||||
self.intervalTimeSpinBox.setValue(0.002000000000000)
|
||||
|
||||
self.formLayout.setWidget(3, QFormLayout.ItemRole.FieldRole, self.intervalTimeSpinBox)
|
||||
|
||||
|
||||
self.settingsLayout.addWidget(self.simulationInterval)
|
||||
|
||||
self.settingsSpacer = QSpacerItem(20, 40, QSizePolicy.Policy.Minimum, QSizePolicy.Policy.Expanding)
|
||||
|
||||
@@ -59,6 +110,14 @@ class Ui_SimulationSettingsDialog(object):
|
||||
def retranslateUi(self, SimulationSettingsDialog):
|
||||
SimulationSettingsDialog.setWindowTitle(QCoreApplication.translate("SimulationSettingsDialog", u"Simulation Settings", None))
|
||||
self.settingsGroup.setTitle(QCoreApplication.translate("SimulationSettingsDialog", u"Settings", None))
|
||||
self.placeholderCheckBox.setText(QCoreApplication.translate("SimulationSettingsDialog", u"Enable simulation option", None))
|
||||
self.simulationInterval.setTitle(QCoreApplication.translate("SimulationSettingsDialog", u"Simulation Interval", None))
|
||||
self.label.setText(QCoreApplication.translate("SimulationSettingsDialog", u"Start time:", None))
|
||||
self.startTimeSpinBox.setPrefix("")
|
||||
self.startTimeSpinBox.setSuffix(QCoreApplication.translate("SimulationSettingsDialog", u"s", None))
|
||||
self.label_2.setText(QCoreApplication.translate("SimulationSettingsDialog", u"Stop time:", None))
|
||||
self.stopTimeSpinBox.setSuffix(QCoreApplication.translate("SimulationSettingsDialog", u"s", None))
|
||||
self.numberOfIntervalsRadioButton.setText(QCoreApplication.translate("SimulationSettingsDialog", u"Number of intervals:", None))
|
||||
self.intervalTimeRadioButton.setText(QCoreApplication.translate("SimulationSettingsDialog", u"Interval:", None))
|
||||
self.intervalTimeSpinBox.setSuffix(QCoreApplication.translate("SimulationSettingsDialog", u"s", None))
|
||||
# retranslateUi
|
||||
|
||||
|
||||
Reference in New Issue
Block a user