Skip to content

Commit

Permalink
feat(workspace): add workspace animation toggle functionality
Browse files Browse the repository at this point in the history
This commit introduces a new feature that allows users to enable or disable workspace switch animations in the application. The `switch_workspace_animation` parameter has been added to the validation schema and default settings, providing a boolean option for controlling the animation behavior when switching between virtual desktops.
  • Loading branch information
amnweb committed Nov 25, 2024
1 parent dade508 commit 31ffd1d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ pillow
qasync
requests
obs-websocket-py
pyvda
pip install git+https://github.com/amnweb/pyvda.git
6 changes: 6 additions & 0 deletions src/core/validation/widgets/yasb/windows_desktops.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
DEFAULTS = {
'label_workspace_btn': '{index}',
'label_workspace_active_btn': '{index}',
'switch_workspace_animation': True,
'container_padding': {'top': 0, 'left': 0, 'bottom': 0, 'right': 0},
}
VALIDATION_SCHEMA = {
Expand All @@ -12,6 +13,11 @@
'type': 'string',
'default': DEFAULTS['label_workspace_active_btn']
},
'switch_workspace_animation': {
'type': 'boolean',
'required': False,
'default': DEFAULTS['switch_workspace_animation']
},
'container_padding': {
'type': 'dict',
'default': DEFAULTS['container_padding'],
Expand Down
7 changes: 5 additions & 2 deletions src/core/widgets/yasb/windows_desktops.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,20 @@
class WorkspaceButton(QPushButton):
def __init__(self, workspace_index: int, label: str = None, active_label: str = None, parent=None):
super().__init__(parent)

self.workspace_index = workspace_index
self.setProperty("class", "ws-btn")
self.default_label = label if label else str(workspace_index)
self.active_label = active_label if active_label else self.default_label
self.setText(self.default_label)
self.clicked.connect(self.activate_workspace)
self.parent_widget = parent
self.workspace_animation = self.parent_widget._switch_workspace_animation
self.setCursor(QCursor(Qt.CursorShape.PointingHandCursor))

def activate_workspace(self):
try:
VirtualDesktop(self.workspace_index).go()
VirtualDesktop(self.workspace_index).go(self.workspace_animation)
if isinstance(self.parent_widget, WorkspaceWidget):
# Emit event to update desktops on all monitors
self.parent_widget._event_service.emit_event(
Expand All @@ -40,6 +42,7 @@ def __init__(
self,
label_workspace_btn: str,
label_workspace_active_btn: str,
switch_workspace_animation: bool,
container_padding: dict,
):
super().__init__(class_name="windows-desktops")
Expand All @@ -54,7 +57,7 @@ def __init__(
self._label_workspace_btn = label_workspace_btn
self._label_workspace_active_btn = label_workspace_active_btn
self._padding = container_padding

self._switch_workspace_animation = switch_workspace_animation
self._virtual_desktops = range(1, len(get_virtual_desktops()) + 1)
self._prev_workspace_index = None
self._curr_workspace_index = VirtualDesktop.current().number
Expand Down

0 comments on commit 31ffd1d

Please sign in to comment.