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): ...@@ -146,7 +146,12 @@ class ScheduleMainWindow(QMainWindow, Ui_MainWindow):
self.splitter.splitterMoved.connect(self._splitter_moved) self.splitter.splitterMoved.connect(self._splitter_moved)
self.actionDocumentation.triggered.connect(self._open_documentation) self.actionDocumentation.triggered.connect(self._open_documentation)
self.actionAbout.triggered.connect(self._open_about_window) 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 # Setup event member functions
self.closeEvent = self._close_event self.closeEvent = self._close_event
...@@ -202,6 +207,25 @@ class ScheduleMainWindow(QMainWindow, Ui_MainWindow): ...@@ -202,6 +207,25 @@ class ScheduleMainWindow(QMainWindow, Ui_MainWindow):
if self._graph is not None: if self._graph is not None:
self._graph._redraw_from_start() 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: def wheelEvent(self, event) -> None:
"""Zoom in or out using mouse wheel if control is pressed.""" """Zoom in or out using mouse wheel if control is pressed."""
if event.modifiers() == Qt.KeyboardModifier.ControlModifier: if event.modifiers() == Qt.KeyboardModifier.ControlModifier:
......
...@@ -235,6 +235,11 @@ ...@@ -235,6 +235,11 @@
<property name="title"> <property name="title">
<string>&amp;Edit</string> <string>&amp;Edit</string>
</property> </property>
<addaction name="actionUndo"/>
<addaction name="actionRedo"/>
<addaction name="separator"/>
<addaction name="actionIncrease_time_resolution"/>
<addaction name="actionDecrease_time_resolution"/>
</widget> </widget>
<widget class="QMenu" name="menuWindow"> <widget class="QMenu" name="menuWindow">
<property name="title"> <property name="title">
...@@ -414,6 +419,32 @@ ...@@ -414,6 +419,32 @@
<string>Plot schedule</string> <string>Plot schedule</string>
</property> </property>
</action> </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> </widget>
<resources/> <resources/>
<connections/> <connections/>
......
...@@ -204,6 +204,20 @@ class Ui_MainWindow(object): ...@@ -204,6 +204,20 @@ class Ui_MainWindow(object):
self.actionReorder.setObjectName("actionReorder") self.actionReorder.setObjectName("actionReorder")
self.actionPlot_schedule = QtWidgets.QAction(MainWindow) self.actionPlot_schedule = QtWidgets.QAction(MainWindow)
self.actionPlot_schedule.setObjectName("actionPlot_schedule") 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_load_from_file)
self.menuFile.addAction(self.menu_close_schedule) self.menuFile.addAction(self.menu_close_schedule)
self.menuFile.addAction(self.menu_save) self.menuFile.addAction(self.menu_save)
...@@ -215,6 +229,11 @@ class Ui_MainWindow(object): ...@@ -215,6 +229,11 @@ class Ui_MainWindow(object):
self.menuView.addAction(self.menu_node_info) self.menuView.addAction(self.menu_node_info)
self.menuView.addSeparator() self.menuView.addSeparator()
self.menuView.addAction(self.actionPlot_schedule) 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.menuWindow.addAction(self.menu_exit_dialog)
self.menuHelp.addAction(self.actionDocumentation) self.menuHelp.addAction(self.actionDocumentation)
self.menuHelp.addSeparator() self.menuHelp.addSeparator()
...@@ -287,3 +306,11 @@ class Ui_MainWindow(object): ...@@ -287,3 +306,11 @@ class Ui_MainWindow(object):
_translate("MainWindow", "Reorder schedule based on start time") _translate("MainWindow", "Reorder schedule based on start time")
) )
self.actionPlot_schedule.setText(_translate("MainWindow", "Plot schedule")) 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