Skip to content

Commit

Permalink
Activating 'Move window' shortcut during window move ends the action
Browse files Browse the repository at this point in the history
  • Loading branch information
rbreu committed Dec 6, 2023
1 parent 6942c40 commit 4ae153b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
10 changes: 8 additions & 2 deletions beeref/main_controls.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,19 @@ class MainControlsMixin:

def init_main_controls(self, main_window):
self.main_window = main_window
self.setContextMenuPolicy(
Qt.ContextMenuPolicy.CustomContextMenu)
self.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu)
self.customContextMenuRequested.connect(
self.control_target.on_context_menu)
self.setAcceptDrops(True)
self.movewin_active = False

def on_action_movewin_mode(self):
if self.movewin_active:
# Pressing the same shortcut again should end the action
self.exit_movewin_mode()
else:
self.enter_movewin_mode()

def enter_movewin_mode(self):
logger.debug('Entering movewin mode')
self.setMouseTracking(True)
Expand Down
7 changes: 2 additions & 5 deletions beeref/view.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,9 +222,9 @@ def on_action_show_titlebar(self, checked):

def on_action_move_window(self):
if self.welcome_overlay.isHidden():
self.enter_movewin_mode()
self.on_action_movewin_mode()
else:
self.welcome_overlay.enter_movewin_mode()
self.welcome_overlay.on_action_movewin_mode()

def on_action_undo(self):
logger.debug('Undo: %s' % self.undo_stack.undoText())
Expand Down Expand Up @@ -404,9 +404,6 @@ def on_action_export_scene(self):
filter=';;'.join(('Image Files (*.png *.jpg *.jpeg)',
'PNG (*.png)',
'JPEG (*.jpg *.jpeg)')))
print(';;'.join(('Image Files (*.png *.jpg *.jpeg)',
'PNG (*.png)',
'JPEG (*.jpg *.jpeg)')))
if filename:
logger.debug(f'Got export filename {filename}')
exporter = SceneToPixmapExporter(self.scene)
Expand Down
8 changes: 8 additions & 0 deletions tests/test_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,14 @@ def test_on_action_move_window_when_welcome_overlay(cursor_mock, view):
assert view.welcome_overlay.event_start == QtCore.QPointF(10.0, 20.0)


def test_on_action_move_window_when_already_active(view):
view.welcome_overlay.event_start = QtCore.QPointF(10.0, 20.0)
view.welcome_overlay.movewin_active = True
view.on_action_move_window()
assert view.welcome_overlay.movewin_active is False
assert view.welcome_overlay.event_start == QtCore.QPointF(10.0, 20.0)


@patch('beeref.view.BeeGraphicsView.cursor')
def test_on_action_move_window_when_scene(cursor_mock, view):
cursor_mock.return_value = MagicMock(
Expand Down

0 comments on commit 4ae153b

Please sign in to comment.