Skip to content
Snippets Groups Projects
Commit 7f2ccdec authored by Oscar Gustafsson's avatar Oscar Gustafsson :bicyclist:
Browse files

Add time resolution functionality to scheduler GUI

parent ea8159f7
No related branches found
No related tags found
1 merge request!310Add time resolution functionality to scheduler GUI
Pipeline #95735 passed
......@@ -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:
......
......@@ -235,6 +235,11 @@
<property name="title">
<string>&amp;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/>
......
......@@ -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...")
)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment