Keyboard shortcuts#134
Conversation
…es a user's individual shortcut preferences. ShortcutEditorDialog handles UI interactions and updates a KSM class instance accordingly. base_instrument.py was updated to implement these new classes and add a button to edit keyboard shortcuts.
…to Station or Log. alert column on right side indicates three states: ok (white), unsaved (orange), and duplicate (red). alert displays tooltip for each tooltip. ServerGui now holds a shortcut editor and shortcut manager, which is passed to an instrument tab when opened.
|
|
||
| @staticmethod | ||
| def _matches_any_pattern(name: str, patterns: List[str]) -> bool: | ||
| def _matches_any_pattern(name: str, patterns: Optional[List[str]]) -> bool: |
There was a problem hiding this comment.
why add the Optional but not a None argument? is this really optional?
|
|
||
| # Indicates if a column is using delegates. | ||
| self.delegateColumns = delegateColumns | ||
| self.delegateColumns: List[int] = delegateColumns or [] |
There was a problem hiding this comment.
does changing the default change the behaviour downstream?
There was a problem hiding this comment.
the default set in the param list is None. the variable is used later in for loops, but if it is None, will this not raise an error? if it is empty, the loop will just exit immediately
| when Save is clicked. Use 'Save to file' / 'Load from file' to persist across sessions. | ||
|
|
||
| Each row has a small colored indicator dot in the rightmost column: | ||
| - white : saved and unique |
There was a problem hiding this comment.
I haven't been able to make it white even when saved
There was a problem hiding this comment.
is it transparent? it just looks normal to me
| else QtCore.Qt.SortOrder.DescendingOrder | ||
| ) | ||
| header.setSortIndicator(col, new_order) | ||
|
|
There was a problem hiding this comment.
why do we need all these new slots?
There was a problem hiding this comment.
I removed the first three and refactored the code accordingly. As for the final four, they act as thin wrappers. They need to resolve what the currently selected item is to execute, something the right-click (for trash/star item) implicitly does
There was a problem hiding this comment.
why was the refactor needed though?
|
On top of the specific coding things 2 things are left on this:
|
…lso, removed 'Save' button, so only can save to file
|
A few things that should probably become issues:
|
| modelKwargs["sub_port"] = kwargs.pop("sub_port") | ||
|
|
||
| shortcutManager = kwargs.pop("shortcutManager", None) | ||
| print(shortcutManager) |
There was a problem hiding this comment.
Remove print statement
| if not patterns: | ||
| return False | ||
| for pattern in patterns: |
There was a problem hiding this comment.
Patterns is a list of strings, how is not [] different than iterating over []?
| @QtCore.Slot() | ||
| def promoteStar(self) -> None: | ||
| self.proxyModel.onToggleStar() | ||
| def _starCurrentItem(self) -> None: | ||
| proxy_index = self.view.currentIndex() | ||
| if not proxy_index.isValid(): | ||
| return | ||
| source_index = self.proxyModel.mapToSource(proxy_index) | ||
| if source_index.column() != 0: | ||
| source_index = source_index.sibling(source_index.row(), 0) | ||
| item = self.model.itemFromIndex(source_index) | ||
| if isinstance(item, ItemBase): | ||
| self.view.lastSelectedItem = item | ||
| self.view.itemStarToggle.emit(item) | ||
|
|
||
| @QtCore.Slot() | ||
| def refreshAll(self) -> None: | ||
| self.model.refreshAll() | ||
| def _trashCurrentItem(self) -> None: | ||
| proxy_index = self.view.currentIndex() | ||
| if not proxy_index.isValid(): | ||
| return | ||
| source_index = self.proxyModel.mapToSource(proxy_index) | ||
| if source_index.column() != 0: | ||
| source_index = source_index.sibling(source_index.row(), 0) | ||
| item = self.model.itemFromIndex(source_index) | ||
| if isinstance(item, ItemBase): | ||
| self.view.lastSelectedItem = item | ||
| self.view.itemTrashToggle.emit(item) |
There was a problem hiding this comment.
why are these 2 functions, instead of being the same one with a flag for star/trash? all the code is exactly the same except the last line
| else QtCore.Qt.SortOrder.DescendingOrder | ||
| ) | ||
| header.setSortIndicator(col, new_order) | ||
|
|
There was a problem hiding this comment.
why was the refactor needed though?
|
|
||
| from instrumentserver import QtCore, QtGui, QtWidgets, getInstrumentserverPath | ||
|
|
||
| _ICON_DIR = getInstrumentserverPath("resource", "icons") |
There was a problem hiding this comment.
Load icons the same way we do in the rest of the project:
| when Save is clicked. Use 'Save to file' / 'Load from file' to persist across sessions. | ||
|
|
||
| Each row has a small colored indicator dot in the rightmost column: | ||
| - white : saved and unique |
There was a problem hiding this comment.
is it transparent? it just looks normal to me
Adds customizable keyboard shortcuts that a user can execute to streamline instrumentserver workflow