Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc08e64e

Browse files
committed
feat(layouts): introduce layout configuration for bar widget alignment and stretching
Added support for customizable layout options in the bar widget, allowing for specific alignment and stretching behavior for left, center, and right sections. This enhances the flexibility of the UI layout and improves user experience by accommodating various design requirements.
1 parent045c1ee commitc08e64e

File tree

2 files changed

+75
-14
lines changed

2 files changed

+75
-14
lines changed

‎src/core/bar.py

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ def __init__(
2323
bar_screen:QScreen,
2424
stylesheet:str,
2525
widgets:dict[str,list],
26+
layouts:dict[str,dict[str,bool|str]],
2627
init:bool=False,
2728
class_name:str=BAR_DEFAULTS['class_name'],
2829
alignment:dict=BAR_DEFAULTS['alignment'],
@@ -43,6 +44,7 @@ def __init__(
4344
self._padding=padding
4445
self._animation=animation
4546
self._is_dark_theme=None
47+
self._layouts=layouts
4648

4749
self.screen_name=self.screen().name()
4850
self.app_bar_edge= (
@@ -149,31 +151,37 @@ def _add_widgets(self, widgets: dict[str, list] = None):
149151
bar_layout.setSpacing(0)
150152

151153
forcolumn_num,layout_typeinenumerate(['left','center','right']):
154+
config=self._layouts[layout_type]
152155
layout=QHBoxLayout()
153156
layout.setContentsMargins(0,0,0,0)
154157
layout.setSpacing(0)
155158
layout_container=QFrame()
156159
layout_container.setProperty("class",f"container container-{layout_type}")
157160

158-
iflayout_typein ["center","right"]:
159-
layout.addStretch()
161+
# Add widgets
162+
iflayout_typeinwidgets:
163+
forwidgetinwidgets[layout_type]:
164+
widget.parent_layout_type=layout_type
165+
widget.bar_id=self.bar_id
166+
widget.monitor_hwnd=self.monitor_hwnd
167+
layout.addWidget(widget,0)
160168

161-
forwidgetinwidgets[layout_type]:
162-
163-
widget.parent_layout_type=layout_type
164-
widget.bar_id=self.bar_id
165-
widget.monitor_hwnd=self.monitor_hwnd
166-
layout.addWidget(widget,0)
169+
ifconfig['alignment']=="left"andconfig['stretch']:
170+
layout.addStretch(1)
167171

168-
iflayout_typein ["left","center"]:
169-
layout.addStretch()
172+
elifconfig['alignment']=="right"andconfig['stretch']:
173+
layout.insertStretch(0,1)
174+
175+
elifconfig['alignment']=="center"andconfig['stretch']:
176+
layout.insertStretch(0,1)
177+
layout.addStretch(1)
170178

171179
layout_container.setLayout(layout)
172180
bar_layout.addWidget(layout_container,0,column_num)
173-
181+
174182
self._bar_frame.setLayout(bar_layout)
175-
176-
183+
184+
177185
defanimation_bar(self):
178186
self.final_pos=self.pos()
179187
ifself._alignment['position']=="top":

‎src/core/validation/bar.py

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
'window_flags': {'always_on_top':False,'windows_app_bar':False,'hide_on_fullscreen':False},
99
'dimensions': {'width':'100%','height':30},
1010
'padding': {'top':0,'left':0,'bottom':0,'right':0},
11-
'widgets': {'left': [],'center': [],'right': []}
11+
'widgets': {'left': [],'center': [],'right': []},
12+
'layouts': {'left': {'alignment':'left','stretch':True},'center': {'alignment':'center','stretch':True},'right': {'alignment':'right','stretch':True}
13+
}
1214
}
1315

1416
BAR_SCHEMA= {
@@ -177,6 +179,57 @@
177179
}
178180
},
179181
'default':BAR_DEFAULTS['widgets']
182+
},
183+
'layouts': {
184+
'type':'dict',
185+
'schema': {
186+
'left': {
187+
'type':'dict',
188+
'schema': {
189+
'alignment': {
190+
'type':'string',
191+
'allowed': ['left','center','right'],
192+
'default':BAR_DEFAULTS['layouts']['left']['alignment']
193+
},
194+
'stretch': {
195+
'type':'boolean',
196+
'default':BAR_DEFAULTS['layouts']['left']['stretch']
197+
}
198+
},
199+
'default':BAR_DEFAULTS['layouts']['left']
200+
},
201+
'center': {
202+
'type':'dict',
203+
'schema': {
204+
'alignment': {
205+
'type':'string',
206+
'allowed': ['left','center','right'],
207+
'default':BAR_DEFAULTS['layouts']['center']['alignment']
208+
},
209+
'stretch': {
210+
'type':'boolean',
211+
'default':BAR_DEFAULTS['layouts']['center']['stretch']
212+
}
213+
},
214+
'default':BAR_DEFAULTS['layouts']['center']
215+
},
216+
'right': {
217+
'type':'dict',
218+
'schema': {
219+
'alignment': {
220+
'type':'string',
221+
'allowed': ['left','center','right'],
222+
'default':BAR_DEFAULTS['layouts']['right']['alignment']
223+
},
224+
'stretch': {
225+
'type':'boolean',
226+
'default':BAR_DEFAULTS['layouts']['right']['stretch']
227+
}
228+
},
229+
'default':BAR_DEFAULTS['layouts']['right']
230+
}
231+
},
232+
'default':BAR_DEFAULTS['layouts']
180233
}
181234
},
182235
'default':BAR_DEFAULTS

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp