From 531550f7e101c91df99c4a2cad2e84f4960c5414 Mon Sep 17 00:00:00 2001 From: amnweb <16545063+forumwt@users.noreply.github.com> Date: Thu, 5 Sep 2024 00:50:27 +0200 Subject: [PATCH] feat(workspaces): add container padding configuration option 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. --- src/core/validation/widgets/komorebi/workspaces.py | 8 +++++++- src/core/widgets/komorebi/workspaces.py | 8 +++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/core/validation/widgets/komorebi/workspaces.py b/src/core/validation/widgets/komorebi/workspaces.py index 4f50f0f..2a1b3c3 100644 --- a/src/core/validation/widgets/komorebi/workspaces.py +++ b/src/core/validation/widgets/komorebi/workspaces.py @@ -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 = { @@ -36,5 +37,10 @@ 'hide_empty_workspaces': { 'type': 'boolean', 'default': DEFAULTS['hide_empty_workspaces'] + }, + 'container_padding': { + 'type': 'dict', + 'default': DEFAULTS['container_padding'], + 'required': False } } \ No newline at end of file diff --git a/src/core/widgets/komorebi/workspaces.py b/src/core/widgets/komorebi/workspaces.py index 97d9757..b423514 100644 --- a/src/core/widgets/komorebi/workspaces.py +++ b/src/core/widgets/komorebi/workspaces.py @@ -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() @@ -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 @@ -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) @@ -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()