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

Add zoom to fit and statusbar toggle for scheduler GUI

parent 68c3923d
No related branches found
No related tags found
1 merge request!320Add zoom to fit
......@@ -143,8 +143,10 @@ class ScheduleMainWindow(QMainWindow, Ui_MainWindow):
self.menu_node_info.setIcon(get_icon('info'))
self.menu_exit_dialog.triggered.connect(self.hide_exit_dialog)
self.actionReorder.triggered.connect(self._action_reorder)
self.actionStatus_bar.triggered.connect(self._toggle_statusbar)
self.actionPlot_schedule.triggered.connect(self._plot_schedule)
self.actionPlot_schedule.setIcon(get_icon('plot-schedule'))
self.actionZoom_to_fit.triggered.connect(self._zoom_to_fit)
self.actionUndo.setIcon(get_icon('undo'))
self.actionRedo.setIcon(get_icon('redo'))
self.splitter.splitterMoved.connect(self._splitter_moved)
......@@ -741,6 +743,14 @@ class ScheduleMainWindow(QMainWindow, Ui_MainWindow):
self._update_recent_file_list()
def _zoom_to_fit(self, event=None):
"""Callback for zoom to fit schedule in window."""
self.view.fitInView(self._scene.sceneRect(), Qt.AspectRatioMode.KeepAspectRatio)
def _toggle_statusbar(self, event=None) -> None:
"""Callback for toggling the status bar."""
self.statusbar.setVisible(self.actionStatus_bar.isChecked())
def start_scheduler(schedule: Optional[Schedule] = None) -> Schedule:
"""
......
......@@ -92,7 +92,7 @@
<bool>false</bool>
</attribute>
<attribute name="verticalHeaderDefaultSectionSize">
<number>19</number>
<number>24</number>
</attribute>
<row>
<property name="text">
......@@ -202,7 +202,7 @@
<x>0</x>
<y>0</y>
<width>800</width>
<height>20</height>
<height>22</height>
</rect>
</property>
<widget class="QMenu" name="menuFile">
......@@ -228,8 +228,11 @@
<string>&amp;View</string>
</property>
<addaction name="menu_node_info"/>
<addaction name="actionStatus_bar"/>
<addaction name="separator"/>
<addaction name="actionPlot_schedule"/>
<addaction name="separator"/>
<addaction name="actionZoom_to_fit"/>
</widget>
<widget class="QMenu" name="menu_Edit">
<property name="title">
......@@ -445,6 +448,22 @@
<string>Decrease time resolution...</string>
</property>
</action>
<action name="actionZoom_to_fit">
<property name="text">
<string>Zoom to fit</string>
</property>
</action>
<action name="actionStatus_bar">
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="text">
<string>Status bar</string>
</property>
</action>
</widget>
<resources/>
<connections/>
......
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file './main_window.ui'
# Form implementation generated from reading ui file '.\main_window.ui'
#
# Created by: PyQt5 UI code generator 5.15.7
#
......@@ -123,11 +123,11 @@ class Ui_MainWindow(object):
self.info_table.horizontalHeader().setHighlightSections(False)
self.info_table.horizontalHeader().setStretchLastSection(True)
self.info_table.verticalHeader().setVisible(False)
self.info_table.verticalHeader().setDefaultSectionSize(19)
self.info_table.verticalHeader().setDefaultSectionSize(24)
self.horizontalLayout.addWidget(self.splitter)
MainWindow.setCentralWidget(self.centralwidget)
self.menubar = QtWidgets.QMenuBar(MainWindow)
self.menubar.setGeometry(QtCore.QRect(0, 0, 800, 20))
self.menubar.setGeometry(QtCore.QRect(0, 0, 800, 22))
self.menubar.setObjectName("menubar")
self.menuFile = QtWidgets.QMenu(self.menubar)
self.menuFile.setObjectName("menuFile")
......@@ -218,6 +218,12 @@ class Ui_MainWindow(object):
self.actionDecrease_time_resolution.setObjectName(
"actionDecrease_time_resolution"
)
self.actionZoom_to_fit = QtWidgets.QAction(MainWindow)
self.actionZoom_to_fit.setObjectName("actionZoom_to_fit")
self.actionStatus_bar = QtWidgets.QAction(MainWindow)
self.actionStatus_bar.setCheckable(True)
self.actionStatus_bar.setChecked(True)
self.actionStatus_bar.setObjectName("actionStatus_bar")
self.menuFile.addAction(self.menu_load_from_file)
self.menuFile.addAction(self.menu_close_schedule)
self.menuFile.addAction(self.menu_save)
......@@ -227,8 +233,11 @@ class Ui_MainWindow(object):
self.menuFile.addSeparator()
self.menuFile.addAction(self.menu_quit)
self.menuView.addAction(self.menu_node_info)
self.menuView.addAction(self.actionStatus_bar)
self.menuView.addSeparator()
self.menuView.addAction(self.actionPlot_schedule)
self.menuView.addSeparator()
self.menuView.addAction(self.actionZoom_to_fit)
self.menu_Edit.addAction(self.actionUndo)
self.menu_Edit.addAction(self.actionRedo)
self.menu_Edit.addSeparator()
......@@ -314,3 +323,5 @@ class Ui_MainWindow(object):
self.actionDecrease_time_resolution.setText(
_translate("MainWindow", "Decrease time resolution...")
)
self.actionZoom_to_fit.setText(_translate("MainWindow", "Zoom to fit"))
self.actionStatus_bar.setText(_translate("MainWindow", "Status bar"))
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