Skip to content

Commit

Permalink
Add previous/next spec buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
mauritiusdadd committed Mar 20, 2024
1 parent aa52896 commit eac0cf1
Show file tree
Hide file tree
Showing 6 changed files with 80 additions and 3 deletions.
57 changes: 55 additions & 2 deletions src/redmost/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -910,6 +910,8 @@ class MainWindow(qt_api.QtWidgets.QMainWindow):
action_controls_layout: QtGui.QAction
action_exit: QtGui.QAction
action_import_spectra: QtGui.QAction
action_import_zcat: QtGui.QAction
action_export_zcat: QtGui.QAction
action_settings: QtGui.QAction
action_zoom_in: QtGui.QAction
action_zoom_out: QtGui.QAction
Expand Down Expand Up @@ -937,9 +939,11 @@ class MainWindow(qt_api.QtWidgets.QMainWindow):
lines_match_list_widget: QtWidgets.QListWidget
lines_table_widget: QtWidgets.QTableWidget
match_lines_button: QtWidgets.QPushButton
next_spec_button: QtWidgets.QPushButton
obj_prop_table_widget: QtWidgets.QTableWidget
other_charts_tab_widget: QtWidgets.QTabWidget
plot_group_box: QtWidgets.QGroupBox
previous_spec_button: QtWidgets.QPushButton
qflag_combo_box: QtWidgets.QComboBox
red_group_box: QtWidgets.QGroupBox
redrock_all_radio: QtWidgets.QRadioButton
Expand Down Expand Up @@ -1221,6 +1225,14 @@ def __init__(self) -> None:

# Connect signals

self.main_wnd.next_spec_button.clicked.connect(
self._next_spec
)

self.main_wnd.previous_spec_button.clicked.connect(
self._previous_spec
)

self.main_wnd.spec_list_widget.currentItemChanged.connect(
self.currentSpecItemChanged
)
Expand Down Expand Up @@ -1476,6 +1488,24 @@ def _lock(self, *args, **kwargs) -> None:
qt_api.QtCharts.QChartView.RubberBand.NoRubberBand
)

def _safe_set_spec_index(self, row: int) -> None:
if (
(row <= 0) or
(row >= self.main_wnd.spec_list_widget.count())
):
return
self.main_wnd.spec_list_widget.setCurrentRow(row)

def _next_spec(self) -> None:
self._safe_set_spec_index(
self.main_wnd.spec_list_widget.currentRow() + 1
)

def _previous_spec(self) -> None:
self._safe_set_spec_index(
self.main_wnd.spec_list_widget.currentRow() - 1
)

def _load_icons(self, theme: Optional[str] = "feather") -> None:

# Icons for actions
Expand All @@ -1489,9 +1519,15 @@ def _load_icons(self, theme: Optional[str] = "feather") -> None:
self.main_wnd.action_exit.setIcon(
qt_api.get_qicon("log-out", theme)
)
self.main_wnd.action_export_zcat.setIcon(
qt_api.get_qicon("share", theme)
)
self.main_wnd.action_import_spectra.setIcon(
qt_api.get_qicon("file-plus", theme)
)
self.main_wnd.action_import_zcat.setIcon(
qt_api.get_qicon("table", theme)
)
self.main_wnd.action_new_project.setIcon(
qt_api.get_qicon("file", theme)
)
Expand Down Expand Up @@ -1546,6 +1582,21 @@ def _load_icons(self, theme: Optional[str] = "feather") -> None:
self.main_wnd.match_lines_button.setIcon(
qt_api.get_qicon("", theme)
)

next_icon = qt_api.get_qicon("chevrons-right", theme)
if next_icon.isNull():
self.main_wnd.next_spec_button.setText("Next")
else:
self.main_wnd.next_spec_button.setText("")
self.main_wnd.next_spec_button.setIcon(next_icon)

previous_icon = qt_api.get_qicon("chevrons-left", theme)
if next_icon.isNull():
self.main_wnd.previous_spec_button.setText("Previous")
else:
self.main_wnd.previous_spec_button.setText("")
self.main_wnd.previous_spec_button.setIcon(previous_icon)

self.main_wnd.redrock_run_button.setIcon(
qt_api.get_qicon("play", theme)
)
Expand Down Expand Up @@ -2742,7 +2793,7 @@ def importZcat(self, zcat_tbl) -> None:

try:
info_dict["quality_flag"] = row[qf_col]
except KeyError:
except Exception:
pass
else:
self._update_spec_item_qf(obj_uuid, row[qf_col])
Expand Down Expand Up @@ -2806,7 +2857,9 @@ def newProject(self) -> None:

self._lock()
self.global_state = GlobalState.READY
self.statusbar.showMessage(self.qapp.tr("New project created"))
self.statusbar.showMessage(
self.qapp.tr("Import some spectra to start!")
)

def openProject(self, file_name: str) -> None:
"""Load the project from a file."""
Expand Down
1 change: 1 addition & 0 deletions src/redmost/ui/icons/feather-dark/chevrons-left.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/redmost/ui/icons/feather-dark/chevrons-right.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/redmost/ui/icons/feather/chevrons-left.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/redmost/ui/icons/feather/chevrons-right.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 21 additions & 1 deletion src/redmost/ui/main_window.ui
Original file line number Diff line number Diff line change
Expand Up @@ -1074,7 +1074,11 @@ li.checked::marker { content: &quot;\2612&quot;; }
<addaction name="action_import_spectra"/>
<addaction name="separator"/>
<addaction name="separator"/>
<addaction name="action_import_zcat"/>
<addaction name="action_export_zcat"/>
<addaction name="separator"/>
<addaction name="action_exit"/>
<addaction name="separator"/>
</widget>
<widget class="QMenu" name="menu_about">
<property name="title">
Expand Down Expand Up @@ -1102,7 +1106,7 @@ li.checked::marker { content: &quot;\2612&quot;; }
<string>toolBar</string>
</property>
<property name="toolButtonStyle">
<enum>Qt::ToolButtonTextBesideIcon</enum>
<enum>Qt::ToolButtonIconOnly</enum>
</property>
<attribute name="toolBarArea">
<enum>TopToolBarArea</enum>
Expand Down Expand Up @@ -1226,6 +1230,9 @@ li.checked::marker { content: &quot;\2612&quot;; }
</property>
</action>
<action name="action_online_user_manual">
<property name="icon">
<iconset theme="help-browser"/>
</property>
<property name="text">
<string>&amp;Online user manual</string>
</property>
Expand All @@ -1247,10 +1254,23 @@ li.checked::marker { content: &quot;\2612&quot;; }
</property>
</action>
<action name="action_settings">
<property name="icon">
<iconset theme="preferences-other"/>
</property>
<property name="text">
<string>&amp;Settings</string>
</property>
</action>
<action name="action_import_zcat">
<property name="text">
<string>Import spectroscopi catalogue</string>
</property>
</action>
<action name="action_export_zcat">
<property name="text">
<string>Export spectroscopic catalogue</string>
</property>
</action>
</widget>
<resources/>
<connections>
Expand Down

0 comments on commit eac0cf1

Please sign in to comment.