@@ -3,8 +3,8 @@ pragma ComponentBehavior: Bound
33import QtQuick
44import QtQuick.Layouts
55import qs.components
6- import qs.config
76import qs.services
7+ import qs.config
88import qs.modules.nexus
99
1010Item {
@@ -17,6 +17,30 @@ Item {
1717
1818 property int activeTabIndex: 0
1919
20+ function updateTabIndicator () {
21+ const item = tabRepeater .itemAt (activeTabIndex);
22+ if (item) {
23+ tabIndicator .targetX = item .x ;
24+ tabIndicator .targetWidth = item .width ;
25+ } else {
26+ tabIndicator .targetX = 0 ;
27+ tabIndicator .targetWidth = 0 ;
28+ }
29+ }
30+
31+ function onForcedTabChanged () {
32+ if (session .forcedTab !== " " ) {
33+ const tabList = root .tabs ;
34+ for (let i = 0 ; i < tabList .length ; i++ ) {
35+ if (tabList[i] === session .forcedTab ) {
36+ root .activeTabIndex = i;
37+ break ;
38+ }
39+ }
40+ session .consumeForcedTab ();
41+ }
42+ }
43+
2044 onActiveConfigChanged: {
2145 activeTabIndex = 0 ;
2246 tabIndicatorUpdate .restart ();
@@ -28,35 +52,17 @@ Item {
2852
2953 Timer {
3054 id: tabIndicatorUpdate
55+
3156 interval: 0
3257 onTriggered: root .updateTabIndicator ()
3358 }
3459
35- function updateTabIndicator () {
36- const item = tabRepeater .itemAt (activeTabIndex);
37- if (item) {
38- tabIndicator .targetX = item .x ;
39- tabIndicator .targetWidth = item .width ;
40- } else {
41- tabIndicator .targetX = 0 ;
42- tabIndicator .targetWidth = 0 ;
43- }
44- }
45-
4660 Connections {
47- target: session
4861 function onForcedTabChanged () {
49- if (session .forcedTab !== " " ) {
50- const tabList = root .tabs ;
51- for (let i = 0 ; i < tabList .length ; i++ ) {
52- if (tabList[i] === session .forcedTab ) {
53- root .activeTabIndex = i;
54- break ;
55- }
56- }
57- session .consumeForcedTab ();
58- }
62+ root .onForcedTabChanged ();
5963 }
64+
65+ target: session
6066 }
6167
6268 ColumnLayout {
@@ -109,12 +115,14 @@ Item {
109115
110116 Row {
111117 id: tabRow
118+
112119 anchors .left : parent .left
113120 anchors .bottom : parent .bottom
114121 spacing: 4
115122
116123 Repeater {
117124 id: tabRepeater
125+
118126 model: root .tabs
119127
120128 delegate: Rectangle {
@@ -135,6 +143,7 @@ Item {
135143
136144 StyledText {
137145 id: tabLabel
146+
138147 anchors .centerIn : parent
139148 text: tabItem .modelData
140149 font .pointSize : Appearance .font .size .normal
@@ -150,6 +159,7 @@ Item {
150159 function onClicked () {
151160 root .activeTabIndex = tabItem .index ;
152161 }
162+
153163 radius: Appearance .rounding .small
154164 color: root .activeTabIndex === tabItem .index ? Colours .palette .m3primary : Colours .palette .m3onSurface
155165 }
@@ -160,16 +170,16 @@ Item {
160170 Rectangle {
161171 id: tabIndicator
162172
173+ property real targetX: 0
174+ property real targetWidth: 0
175+
163176 anchors .bottom : parent .bottom
164177 anchors .bottomMargin : - 8
165178 height: 3
166179 radius: 1.5
167180 color: Colours .palette .m3primary
168181 visible: root .tabs .length > 0
169182
170- property real targetX: 0
171- property real targetWidth: 0
172-
173183 x: targetX
174184 width: targetWidth
175185
@@ -199,12 +209,11 @@ Item {
199209 Loader {
200210 id: panelLoader
201211
202- anchors .fill : parent
203- asynchronous: true
204-
205212 readonly property string targetSource: root .activeConfig ? " panels/" + root .activeConfig .id .charAt (0 ).toUpperCase () + root .activeConfig .id .slice (1 ) + " Panel.qml" : " "
206213 property string resolvedSource: targetSource
207214
215+ anchors .fill : parent
216+ asynchronous: true
208217 source: resolvedSource
209218
210219 onTargetSourceChanged: resolvedSource = targetSource
@@ -225,12 +234,13 @@ Item {
225234 }
226235
227236 Connections {
228- target: root
229237 function onActiveTabIndexChanged () {
230238 if (panelLoader .item && panelLoader .item .hasOwnProperty (" activeTabIndex" )) {
231239 panelLoader .item .activeTabIndex = root .activeTabIndex ;
232240 }
233241 }
242+
243+ target: root
234244 }
235245 }
236246 }
0 commit comments