Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests for FileWidget ContextMenu #923

Merged
merged 8 commits into from
Oct 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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