diff --git a/b_asic/scheduler_gui/main_window.py b/b_asic/scheduler_gui/main_window.py index 78888d824fe8b7146d2f63f7842d85b35bd0256b..c798f72ac358ef4363028f942e23a67c63f49d85 100644 --- a/b_asic/scheduler_gui/main_window.py +++ b/b_asic/scheduler_gui/main_window.py @@ -146,7 +146,12 @@ class ScheduleMainWindow(QMainWindow, Ui_MainWindow): self.splitter.splitterMoved.connect(self._splitter_moved) self.actionDocumentation.triggered.connect(self._open_documentation) self.actionAbout.triggered.connect(self._open_about_window) - + self.actionDecrease_time_resolution.triggered.connect( + self._decrease_time_resolution + ) + self.actionIncrease_time_resolution.triggered.connect( + self._increase_time_resolution + ) # Setup event member functions self.closeEvent = self._close_event @@ -202,6 +207,25 @@ class ScheduleMainWindow(QMainWindow, Ui_MainWindow): if self._graph is not None: self._graph._redraw_from_start() + @Slot() + def _increase_time_resolution(self) -> None: + factor, ok = QInputDialog.getInt( + self, "Increase time resolution", "Factor", 1, 1 + ) + if ok: + self.schedule.increase_time_resolution(factor) + self.open(self.schedule) + + @Slot() + def _decrease_time_resolution(self) -> None: + vals = [str(v) for v in self.schedule.get_possible_time_resolution_decrements()] + factor, ok = QInputDialog.getItem( + self, "Decrease time resolution", "Factor", vals, editable=False + ) + if ok: + self.schedule.decrease_time_resolution(int(factor)) + self.open(self.schedule) + def wheelEvent(self, event) -> None: """Zoom in or out using mouse wheel if control is pressed.""" if event.modifiers() == Qt.KeyboardModifier.ControlModifier: diff --git a/b_asic/scheduler_gui/main_window.ui b/b_asic/scheduler_gui/main_window.ui index a5ae4d2c160d4aac9e82ec1dd934a1de6456f23a..1c55fbe0fe0e3c93c4cdbe74b274d08866fda9be 100644 --- a/b_asic/scheduler_gui/main_window.ui +++ b/b_asic/scheduler_gui/main_window.ui @@ -235,6 +235,11 @@ <property name="title"> <string>&Edit</string> </property> + <addaction name="actionUndo"/> + <addaction name="actionRedo"/> + <addaction name="separator"/> + <addaction name="actionIncrease_time_resolution"/> + <addaction name="actionDecrease_time_resolution"/> </widget> <widget class="QMenu" name="menuWindow"> <property name="title"> @@ -414,6 +419,32 @@ <string>Plot schedule</string> </property> </action> + <action name="actionUndo"> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="text"> + <string>Undo</string> + </property> + </action> + <action name="actionRedo"> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="text"> + <string>Redo</string> + </property> + </action> + <action name="actionIncrease_time_resolution"> + <property name="text"> + <string>Increase time resolution...</string> + </property> + </action> + <action name="actionDecrease_time_resolution"> + <property name="text"> + <string>Decrease time resolution...</string> + </property> + </action> </widget> <resources/> <connections/> diff --git a/b_asic/scheduler_gui/ui_main_window.py b/b_asic/scheduler_gui/ui_main_window.py index a5e1cb743815c613b2440d27929a4a0e72272dcc..220bdec5dfb255a223708834c5ce8f2fdc1cc018 100644 --- a/b_asic/scheduler_gui/ui_main_window.py +++ b/b_asic/scheduler_gui/ui_main_window.py @@ -204,6 +204,20 @@ class Ui_MainWindow(object): self.actionReorder.setObjectName("actionReorder") self.actionPlot_schedule = QtWidgets.QAction(MainWindow) self.actionPlot_schedule.setObjectName("actionPlot_schedule") + self.actionUndo = QtWidgets.QAction(MainWindow) + self.actionUndo.setEnabled(False) + self.actionUndo.setObjectName("actionUndo") + self.actionRedo = QtWidgets.QAction(MainWindow) + self.actionRedo.setEnabled(False) + self.actionRedo.setObjectName("actionRedo") + self.actionIncrease_time_resolution = QtWidgets.QAction(MainWindow) + self.actionIncrease_time_resolution.setObjectName( + "actionIncrease_time_resolution" + ) + self.actionDecrease_time_resolution = QtWidgets.QAction(MainWindow) + self.actionDecrease_time_resolution.setObjectName( + "actionDecrease_time_resolution" + ) self.menuFile.addAction(self.menu_load_from_file) self.menuFile.addAction(self.menu_close_schedule) self.menuFile.addAction(self.menu_save) @@ -215,6 +229,11 @@ class Ui_MainWindow(object): self.menuView.addAction(self.menu_node_info) self.menuView.addSeparator() self.menuView.addAction(self.actionPlot_schedule) + self.menu_Edit.addAction(self.actionUndo) + self.menu_Edit.addAction(self.actionRedo) + self.menu_Edit.addSeparator() + self.menu_Edit.addAction(self.actionIncrease_time_resolution) + self.menu_Edit.addAction(self.actionDecrease_time_resolution) self.menuWindow.addAction(self.menu_exit_dialog) self.menuHelp.addAction(self.actionDocumentation) self.menuHelp.addSeparator() @@ -287,3 +306,11 @@ class Ui_MainWindow(object): _translate("MainWindow", "Reorder schedule based on start time") ) self.actionPlot_schedule.setText(_translate("MainWindow", "Plot schedule")) + self.actionUndo.setText(_translate("MainWindow", "Undo")) + self.actionRedo.setText(_translate("MainWindow", "Redo")) + self.actionIncrease_time_resolution.setText( + _translate("MainWindow", "Increase time resolution...") + ) + self.actionDecrease_time_resolution.setText( + _translate("MainWindow", "Decrease time resolution...") + )