Skip to content

Commit

Permalink
feat(workspaces): add container padding configuration option
Browse files Browse the repository at this point in the history
This commit introduces a new configuration option `container_padding` to the `WorkspaceWidget`. The option allows users to specify padding for the workspace container, enhancing layout flexibility.

The default padding values are set to zero for all sides, but users can customize them as needed. This change improves the overall UI design and usability by allowing better control over spacing within the widget. Additionally, the validation schema has been updated to include this new property, ensuring it is properly handled during configuration.
  • Loading branch information
amnweb committed Sep 4, 2024
1 parent d8ec8b2 commit 531550f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
8 changes: 7 additions & 1 deletion src/core/validation/widgets/komorebi/workspaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
'label_default_name': '',
'hide_if_offline': False,
'label_zero_index': False,
'hide_empty_workspaces': False
'hide_empty_workspaces': False,
'container_padding': {'top': 0, 'left': 0, 'bottom': 0, 'right': 0},
}

VALIDATION_SCHEMA = {
Expand Down Expand Up @@ -36,5 +37,10 @@
'hide_empty_workspaces': {
'type': 'boolean',
'default': DEFAULTS['hide_empty_workspaces']
},
'container_padding': {
'type': 'dict',
'default': DEFAULTS['container_padding'],
'required': False
}
}
8 changes: 5 additions & 3 deletions src/core/widgets/komorebi/workspaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ def __init__(
label_default_name: str,
hide_if_offline: bool,
label_zero_index: bool,
hide_empty_workspaces: bool
hide_empty_workspaces: bool,
container_padding: dict
):
super().__init__(class_name="komorebi-workspaces")
self._event_service = EventService()
Expand All @@ -75,6 +76,7 @@ def __init__(
self._label_default_name = label_default_name
self._label_zero_index = label_zero_index
self._hide_if_offline = hide_if_offline
self._padding = container_padding
self._komorebi_screen = None
self._komorebi_workspaces = []
self._prev_workspace_index = None
Expand Down Expand Up @@ -111,7 +113,7 @@ def __init__(
# Construct container which holds workspace buttons
self._workspace_container_layout: QHBoxLayout = QHBoxLayout()
self._workspace_container_layout.setSpacing(0)
# self._workspace_container_layout.setContentsMargins(0, 0, 0, 0)
self._workspace_container_layout.setContentsMargins(self._padding['left'],self._padding['top'],self._padding['right'],self._padding['bottom'])
self._workspace_container_layout.addWidget(self._offline_text)
self._workspace_container: QWidget = QWidget()
self._workspace_container.setLayout(self._workspace_container_layout)
Expand Down Expand Up @@ -229,7 +231,7 @@ def _add_or_update_buttons(self) -> None:
button = self._try_add_workspace_button(workspace_index)
buttons_added = True
self._update_button(button)

if buttons_added:
self._workspace_buttons.sort(key=lambda btn: btn.workspace_index)
self._clear_container_layout()
Expand Down

0 comments on commit 531550f

Please sign in to comment.