mirror of
https://github.com/rbreu/beeref.git
synced 2026-03-11 08:54:28 +00:00
Fix grayscale checkbox not updating properly
This commit is contained in:
parent
69dc401d0b
commit
5c308c57b7
3 changed files with 26 additions and 1 deletions
|
|
@ -13,6 +13,8 @@ Fixed
|
|||
|
||||
* Fixed a crash when pressing the keyboard shortcut for New Scene
|
||||
while in the process of doing a rubberband selection
|
||||
* The checkmark of the menu entry Images -> Grayscale is now updating
|
||||
correctly depending on the selected images
|
||||
|
||||
|
||||
0.3.2 - 2024-01-21
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ import os.path
|
|||
from PyQt6 import QtCore, QtGui, QtWidgets
|
||||
from PyQt6.QtCore import Qt
|
||||
|
||||
from beeref.actions import ActionsMixin
|
||||
from beeref.actions import ActionsMixin, actions
|
||||
from beeref import commands
|
||||
from beeref.config import CommandlineArgs, BeeSettings
|
||||
from beeref import constants
|
||||
|
|
@ -603,6 +603,11 @@ class BeeGraphicsView(MainControlsMixin,
|
|||
self.scene.has_selection())
|
||||
self.actiongroup_set_enabled('active_when_single_image',
|
||||
self.scene.has_single_image_selection())
|
||||
|
||||
if self.scene.has_selection():
|
||||
item = self.scene.selectedItems(user_only=True)[0]
|
||||
grayscale = getattr(item, 'grayscale', False)
|
||||
actions.actions['grayscale'].qaction.setChecked(grayscale)
|
||||
self.viewport().repaint()
|
||||
|
||||
def on_cursor_changed(self, cursor):
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ from unittest.mock import MagicMock, patch, mock_open
|
|||
from PyQt6 import QtCore, QtGui, QtWidgets
|
||||
from PyQt6.QtCore import Qt
|
||||
|
||||
from beeref.actions import actions
|
||||
from beeref.config import logfile_name
|
||||
from beeref.items import BeePixmapItem, BeeTextItem
|
||||
from beeref.view import BeeGraphicsView
|
||||
|
|
@ -578,6 +579,23 @@ def test_on_action_cut(copy_mock, view, item):
|
|||
assert view.undo_stack.isClean() is False
|
||||
|
||||
|
||||
def test_on_selection_changed_updates_grayscale_action(view):
|
||||
item = BeePixmapItem(QtGui.QImage())
|
||||
view.scene.addItem(item)
|
||||
item.grayscale = True
|
||||
actions.actions['grayscale'].qaction.setChecked(False)
|
||||
item.setSelected(True)
|
||||
assert actions.actions['grayscale'].qaction.isChecked() is True
|
||||
|
||||
|
||||
def test_on_selection_changed_grayscale_action_ignores_textitem(view):
|
||||
item = BeeTextItem('foo')
|
||||
view.scene.addItem(item)
|
||||
actions.actions['grayscale'].qaction.setChecked(True)
|
||||
item.setSelected(True)
|
||||
assert actions.actions['grayscale'].qaction.isChecked() is False
|
||||
|
||||
|
||||
def test_on_action_reset_scale(view, item):
|
||||
view.scene.addItem(item)
|
||||
item.setScale(2)
|
||||
|
|
|
|||
Loading…
Reference in a new issue