11import { ProgressIndicator , Button , StyleMetrics , Palette , ScrollView , Slider , ComboBox , TabWidget } from "std-widgets.slint" ;
22import { VirtualKeyboardButton } from "virtual_keyboard.slint" ;
33import "../AdwaitaSans-Regular.ttf" ;
4- import { TemperatureSensors , DisplayStatus , PrinterAdministration , GcodeCommands , Filesystem , Utils , Webhooks } from "state.slint" ;
4+ import { TemperatureSensors , DisplayStatus , PrinterAdministration , GcodeCommands , Filesystem , Utils , Webhooks , UiSettings } from "state.slint" ;
55import { Heater , TemperatureSensor , MoonrakerFile } from "types.slint" ;
66import { Icons } from "constants.slint" ;
77import { Page } from "components/page.slint" ;
@@ -89,20 +89,34 @@ component MainView inherits Rectangle
8989 property <bool> is_emergency_prompt_open: false ;
9090 background: Palette.alternate-background;
9191
92+
93+
9294 VerticalLayout {
9395 TopBar {
9496
9597 }
9698
9799 HorizontalLayout {
98- VerticalLayout {
100+ if UiSettings.left-sidebar.length > 0 : VerticalLayout {
99101 min-width: 50px ;
100102 spacing: 5px ;
101103
102- LeftSideIconButton { icon: Icons.print; checked: root .current-page == 0 ; clicked => { root .current-page = 0 ; } }
103- LeftSideIconButton { icon: Icons.temperature; checked: root .current-page == 1 ; clicked => { root .current-page = 1 ; } }
104- LeftSideIconButton { icon: Icons.move; checked: root .current-page == 2 ; clicked => { root .current-page = 2 ; } }
105- LeftSideIconButton { icon: Icons.emergency_stop; checked: root .current-page == 3 ; clicked => { is_emergency_prompt_open = true ; } foreground: red; }
104+ for component in UiSettings.left-sidebar: LeftSideIconButton {
105+ icon: UiSettings.id-to-image[component];
106+ checked: root .current-page == component;
107+ clicked => {
108+ if (component == 3 ) {
109+ is_emergency_prompt_open = true ;
110+ } else {
111+ current-page = component;
112+ }
113+ }
114+ foreground: component == 3
115+ ? red
116+ : root .current-page == component
117+ ? Palette.accent-foreground
118+ : Palette.foreground;
119+ }
106120 }
107121
108122 Rectangle {
@@ -118,14 +132,26 @@ component MainView inherits Rectangle
118132 if root .current-page == 6 : ExtruderPage {}
119133 }
120134
121- VerticalLayout {
135+ if UiSettings.right-sidebar.length > 0 : VerticalLayout {
122136 spacing: 5px ;
123137 min-width: 50px ;
124138
125- RightSideIconButton { icon: Icons.fan; checked: root .current-page == 4 ; clicked => { root .current-page = 4 ; } }
126- RightSideIconButton { icon: Icons.quick_action; checked: root .current-page == 5 ; clicked => { root .current-page = 5 ; }}
127- RightSideIconButton { icon: Icons.console; checked: root .current-page == 6 ; clicked => { root .current-page = 6 ; } }
128- RightSideIconButton { icon: Icons.settings; checked: root .current-page == 7 ; clicked => { root .current-page = 7 ; } }
139+ for component in UiSettings.right-sidebar: RightSideIconButton {
140+ icon: UiSettings.id-to-image[component];
141+ checked: root .current-page == component;
142+ clicked => {
143+ if (component == 3 ) {
144+ is_emergency_prompt_open = true ;
145+ } else {
146+ current-page = component;
147+ }
148+ }
149+ foreground: component == 3
150+ ? red
151+ : root .current-page == component
152+ ? Palette.accent-foreground
153+ : Palette.foreground;
154+ }
129155 }
130156 }
131157
0 commit comments