Notification when attempt to paste from empty clipboard

This commit is contained in:
Rebecca Breu 2024-03-03 12:18:26 +01:00
parent 7aab1ed38f
commit 113ba39488
3 changed files with 11 additions and 2 deletions

View file

@ -8,6 +8,8 @@ Added
the default arrow cursor.
* Added a color sampler which can copy colors from images to the
clipboard in hex format (Images -> Sample Color)
* Added notification when attempting to paste from an empty or
unusable clipboard
Fixed

View file

@ -621,7 +621,10 @@ class BeeGraphicsView(MainControlsMixin,
item.setScale(1 / self.get_scale())
self.undo_stack.push(commands.InsertItems(self.scene, [item], pos))
return
logger.info('No image data or text in clipboard')
msg = 'No image data or text in clipboard'
logger.info(msg)
widgets.BeeNotification(self, msg)
def on_action_open_settings_dir(self):
dirname = os.path.dirname(self.settings.fileName())

View file

@ -560,12 +560,16 @@ def test_on_action_paste_when_text(img_mock, text_mock, clear_mock, view):
@patch('beeref.scene.BeeGraphicsScene.clearSelection')
@patch('PyQt6.QtGui.QClipboard.text')
@patch('PyQt6.QtGui.QClipboard.image')
def test_on_action_paste_when_empty(img_mock, text_mock, clear_mock, view):
@patch('beeref.widgets.BeeNotification')
def test_on_action_paste_when_empty(
notification_mock, img_mock, text_mock, clear_mock, view):
view.cancel_active_modes = MagicMock()
img_mock.return_value = QtGui.QImage()
text_mock.return_value = ''
view.on_action_paste()
assert len(view.scene.items()) == 0
notification_mock.assert_called_once_with(
view, 'No image data or text in clipboard')
clear_mock.assert_not_called()
view.cancel_active_modes.assert_called_once_with()