Skip to content

Commit 877f37e

Browse files
committed
fix(systray): added container widget and padding for systray
docs(systray): updated systray widget docs
1 parent 9e11469 commit 877f37e

3 files changed

Lines changed: 51 additions & 8 deletions

File tree

docs/widgets/(Widget)-Systray.md

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
| `show_battery` | boolean | `false` | Whether to show battery icon (from the original systray). |
1313
| `show_volume` | boolean | `false` | Whether to show volume icon (from the original systray). |
1414
| `show_network` | boolean | `false` | Whether to show network icon (from the original systray). |
15+
| `container_padding` | dict | `None` | Container padding. |
1516
| `container_shadow` | dict | `None` | Container shadow options. |
1617
| `unpinned_shadow` | dict | `None` | Unpinned container shadow options. |
1718
| `pinned_shadow` | dict | `None` | Pinned container shadow options. |
@@ -35,6 +36,11 @@ systray:
3536
show_battery: false
3637
show_volume: false
3738
show_network: false
39+
container_padding:
40+
left: 0
41+
top: 0
42+
right: 0
43+
bottom: 0
3844
btn_shadow:
3945
enabled: true
4046
color: "black"
@@ -65,15 +71,22 @@ There are some limitations with the systray widget:
6571
- **show_battery:** Whether to show battery icon (from the original systray).
6672
- **show_volume:** Whether to show volume icon (from the original systray).
6773
- **show_network:** Whether to show network icon (from the original systray).
74+
- **container_padding:** Padding for the widget container.
75+
- **container_shadow:** Container shadow options.
76+
- **unpinned_shadow:** Unpinned container shadow options.
77+
- **pinned_shadow:** Pinned container shadow options.
78+
- **unpinned_vis_btn_shadow:** Unpinned visibility button shadow options.
79+
- **btn_shadow:** Systray button (icons) shadow options.
6880

6981
## Debug Options
7082
Show unpinned button has a right click menu that allows you to refresh the systray icons.
7183

7284
## Style
7385
```css
7486
.systray {} /* The base widget style */
75-
.systray .unpinned-container {} /* Style for unpinned container */
76-
.systray .pinned-container {} /* Style for pinned container */
87+
.systray .widget-container {} /* Style for the widget container */
88+
.systray .unpinned-container {} /* Style for container with unpinned systray icons */
89+
.systray .pinned-container {} /* Style for container with pinned systray icons */
7790
.systray .pinned-container[forceshow=true] {} /* Style for pinned container when it is forced to show during dragging operation */
7891
.systray .button {} /* Style for the individual systray buttons/icons */
7992
.systray .button[dragging=true] {} /* Style for systray buttons/icons when dragging operation is in progress */

src/core/validation/widgets/yasb/systray.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"show_battery": False,
1111
"show_volume": False,
1212
"show_network": False,
13+
"container_padding": {"left": 0, "top": 0, "right": 0, "bottom": 0},
1314
"default_shadow": {
1415
"enabled": False,
1516
"color": "black",
@@ -76,6 +77,17 @@
7677
"required": False,
7778
"default": DEFAULTS["show_network"],
7879
},
80+
"container_padding": {
81+
"type": "dict",
82+
"required": False,
83+
"schema": {
84+
"left": {"type": "integer", "default": 0},
85+
"top": {"type": "integer", "default": 0},
86+
"right": {"type": "integer", "default": 0},
87+
"bottom": {"type": "integer", "default": 0},
88+
},
89+
"default": DEFAULTS["container_padding"],
90+
},
7991
"container_shadow": {
8092
"type": "dict",
8193
"required": False,

src/core/widgets/yasb/systray.py

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
QLayout,
2222
QMenu,
2323
QPushButton,
24+
QWidget,
2425
)
2526

2627
from core.utils.systray.systray_widget import DropWidget, IconState, IconWidget
@@ -98,6 +99,7 @@ def __init__(
9899
show_battery: bool,
99100
show_volume: bool,
100101
show_network: bool,
102+
container_padding: dict[str, int],
101103
container_shadow: dict[str, Any],
102104
unpinned_shadow: dict[str, Any],
103105
pinned_shadow: dict[str, Any],
@@ -111,6 +113,7 @@ def __init__(
111113
self.icon_size = icon_size
112114
self.show_unpinned = show_unpinned
113115
self.show_unpinned_button = show_unpinned_button
116+
self.container_padding = container_padding
114117
self.container_shadow = container_shadow
115118
self.unpinned_shadow = unpinned_shadow
116119
self.pinned_shadow = pinned_shadow
@@ -149,7 +152,20 @@ def __init__(
149152
self.pinned_vis_check_timer.timeout.connect(self.update_pinned_widget_visibility) # type: ignore
150153
self.pinned_vis_check_timer.setSingleShot(True)
151154

152-
self.unpinned_vis_btn = QPushButton()
155+
self.widget_container_layout = QHBoxLayout()
156+
self.widget_container_layout.setSpacing(0)
157+
self.widget_container_layout.setContentsMargins(
158+
self.container_padding["left"],
159+
self.container_padding["top"],
160+
self.container_padding["right"],
161+
self.container_padding["bottom"],
162+
)
163+
164+
self.widget_container = QWidget(self)
165+
self.widget_container.setLayout(self.widget_container_layout)
166+
self.widget_container.setProperty("class", "widget-container")
167+
168+
self.unpinned_vis_btn = QPushButton(self)
153169
self.unpinned_vis_btn.setCheckable(True)
154170
self.unpinned_vis_btn.clicked.connect(self.toggle_unpinned_widget_visibility) # type: ignore
155171
self.unpinned_vis_btn.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu)
@@ -172,18 +188,20 @@ def __init__(
172188
self.pinned_widget.drag_started.connect(self.on_drag_started) # type: ignore
173189
self.pinned_widget.drag_ended.connect(self.on_drag_ended) # type: ignore
174190

175-
add_shadow(self._widget_frame, self.container_shadow)
191+
add_shadow(self.widget_container, self.container_shadow)
176192
add_shadow(self.unpinned_widget, self.unpinned_shadow)
177193
add_shadow(self.pinned_widget, self.pinned_shadow)
178194
add_shadow(self.unpinned_vis_btn, self.unpinned_vis_btn_shadow)
179195

180-
self.widget_layout.addWidget(self.unpinned_widget)
181-
self.widget_layout.addWidget(self.pinned_widget)
196+
self.widget_container_layout.addWidget(self.unpinned_widget)
197+
self.widget_container_layout.addWidget(self.pinned_widget)
182198

183199
if self.label_position == "left":
184-
self.widget_layout.insertWidget(0, self.unpinned_vis_btn)
200+
self.widget_container_layout.insertWidget(0, self.unpinned_vis_btn)
185201
else:
186-
self.widget_layout.insertWidget(-1, self.unpinned_vis_btn)
202+
self.widget_container_layout.insertWidget(-1, self.unpinned_vis_btn)
203+
204+
self.widget_layout.addWidget(self.widget_container)
187205

188206
self.unpinned_vis_btn.setVisible(self.show_unpinned_button)
189207

0 commit comments

Comments
 (0)