refactor: Remove XML usage and instantiate widgets directly in control center

This commit is contained in:
tr1x_em committed 2025-08-06 11:54:22 +05:30
1 parent 8e1f0de0b8
commit c1c6786b26
1 file changed
+123 -43
+123 -43
View File
@@ -13,7 +13,6 @@ from fabric.widgets.svg import Svg
from modules.controlcenter.bluetooth import BluetoothConnections from modules.controlcenter.bluetooth import BluetoothConnections
from modules.controlcenter.wifi import WifiConnections from modules.controlcenter.wifi import WifiConnections
from services.brightness import Brightness from services.brightness import Brightness
from utils.exml import exml
from utils.roam import audio_service, modus_service from utils.roam import audio_service, modus_service
from widgets.wayland import WaylandWindow as Window from widgets.wayland import WaylandWindow as Window
from modules.controlcenter.player import PlayerBoxStack from modules.controlcenter.player import PlayerBoxStack
@@ -211,52 +210,133 @@ class ModusControlCenter(Window):
on_clicked=self.set_dont_disturb, on_clicked=self.set_dont_disturb,
) )
self.widgets = exml( # Create main widgets directly without XML
file=get_relative_path("controlcenter.xml"), self.widgets = Box(
root=Box, orientation="vertical",
tags={ h_expand=True,
"Box": Box, name="control-center-widgets",
"Button": Button, children=[
"Label": Label, Box(
"Scale": Scale, orientation="horizontal",
"Svg": Svg, name="top-widget",
}, h_expand=True,
refs={ children=[
"self.wlan_label": self.wlan_label, Box(
"self.bluetooth_label": self.bluetooth_label, orientation="vertical",
"self.volume_scale": self.volume_scale, name="wb-widget",
"self.brightness_scale": self.brightness_scale, style_classes="menu",
"self.music_widget": self.music_widget, spacing=5,
"self.bluetooth_widget": self.bluetooth_widget, children=[
"self.wlan_widget": self.wlan_widget, self.wlan_widget,
"self.focus_widget": self.focus_widget, self.bluetooth_widget,
}, ],
),
Box(
orientation="horizontal",
name="dnd-widget",
style_classes="menu",
h_expand=True,
children=[
self.focus_widget,
],
),
],
),
Box(
orientation="vertical",
name="brightness-widget",
style_classes="menu",
h_expand=True,
children=[
Label(
label="Display",
style_classes="title",
h_align="start"
),
self.brightness_scale,
Label(
label="󰖨 ",
name="brightness-widget-icon",
h_align="start"
),
],
),
Box(
orientation="vertical",
name="volume-widget",
style_classes="menu",
h_expand=True,
children=[
Label(
label="Sound",
style_classes="title",
h_align="start"
),
self.volume_scale,
Label(
label=" ",
name="brightness-widget-icon",
h_align="start"
),
],
),
Box(
orientation="vertical",
children=[
self.music_widget,
],
),
],
) )
self.bluetooth_widgets = exml( # Create bluetooth widgets directly without XML
file=get_relative_path("bluetooth.xml"), self.bluetooth_widgets = Box(
root=Box, orientation="vertical",
tags={ h_expand=True,
"Box": Box, name="control-center-widgets",
"Button": Button, children=[
"Label": Label, Box(
"Scale": Scale, orientation="horizontal",
"Svg": Svg, name="top-widget",
}, h_expand=True,
refs={"self.bluetooth_man": self.bluetooth_man}, children=[
Box(
orientation="vertical",
name="wb-widget",
style_classes="menu",
spacing=5,
children=[
self.bluetooth_man,
],
),
],
),
],
) )
self.wifi_widgets = exml( # Create wifi widgets directly without XML
file=get_relative_path("wifi.xml"), self.wifi_widgets = Box(
root=Box, orientation="vertical",
tags={ h_expand=True,
"Box": Box, name="control-center-widgets",
"Button": Button, children=[
"Label": Label, Box(
"Scale": Scale, orientation="horizontal",
"Svg": Svg, name="top-widget",
}, h_expand=True,
refs={"self.wifi_man": self.wifi_man}, children=[
Box(
orientation="vertical",
name="wb-widget",
style_classes="menu",
spacing=5,
children=[
self.wifi_man,
],
),
],
),
],
) )
self.center_box = CenterBox(start_children=[self.widgets]) self.center_box = CenterBox(start_children=[self.widgets])