Skip to content

Commit

Permalink
Add tests for FileWidget ContextMenu (#923)
Browse files Browse the repository at this point in the history
* Fix Copy Display Properties
  • Loading branch information
tov101 authored Oct 10, 2023
1 parent c14390e commit 7671fad
Show file tree
Hide file tree
Showing 3 changed files with 435 additions and 7 deletions.
17 changes: 12 additions & 5 deletions src/asammdf/gui/widgets/tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -773,12 +773,15 @@ def keyPressEvent(self, event):
self.plot.plot.update()

elif modifiers == (QtCore.Qt.ControlModifier | QtCore.Qt.ShiftModifier) and key == QtCore.Qt.Key_C:
selected_items = [item for item in self.selectedItems() if item.type() == ChannelsTreeItem.Channel]
if not selected_items:
return
else:
selected_items = [
item
for item in self.selectedItems()
if item.type() in (ChannelsTreeItem.Channel, ChannelsTreeItem.Group)
]
if selected_items:
item = selected_items[0]
QtWidgets.QApplication.instance().clipboard().setText(item.get_display_properties())
clipboard_text = item.get_display_properties()
QtWidgets.QApplication.instance().clipboard().setText(clipboard_text)

elif modifiers == (QtCore.Qt.ControlModifier | QtCore.Qt.ShiftModifier) and key == QtCore.Qt.Key_V:
info = QtWidgets.QApplication.instance().clipboard().text()
Expand Down Expand Up @@ -1930,6 +1933,10 @@ def get_color_using_ranges(self, value, pen=False):
return get_color_using_ranges(value, self.get_ranges(), self.signal.color, pen=pen)

def get_display_properties(self):
if self.type() == ChannelsTreeItem.Group:
if self.childCount():
return self.child(0).get_display_properties()
return ""
info = {
"color": self.color.name(),
"precision": self.precision,
Expand Down
1 change: 1 addition & 0 deletions test/asammdf/gui/widgets/test_BasePlotWidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ def add_channel_to_plot(self, plot=None, channel_name=None, channel_index=None):
return plot_channel

def context_menu(self, action_text, position=None):
self.processEvents()
with mock.patch("asammdf.gui.widgets.tree.QtWidgets.QMenu", wraps=QMenuWrap):
mo_action = mock.MagicMock()
mo_action.text.return_value = action_text
Expand Down
Loading

0 comments on commit 7671fad

Please sign in to comment.