Changeset View
Changeset View
Standalone View
Standalone View
applets/taskmanager/package/contents/ui/AudioStream.qml
Show First 20 Lines • Show All 100 Lines • ▼ Show 20 Line(s) | 24 | MouseArea { | |||
---|---|---|---|---|---|
101 | 101 | | |||
102 | PlasmaCore.Svg { | 102 | PlasmaCore.Svg { | ||
103 | id: audioSvg | 103 | id: audioSvg | ||
104 | imagePath: "icons/audio" | 104 | imagePath: "icons/audio" | ||
105 | } | 105 | } | ||
106 | 106 | | |||
107 | PlasmaCore.SvgItem { | 107 | PlasmaCore.SvgItem { | ||
108 | id: audioStreamIcon | 108 | id: audioStreamIcon | ||
109 | | ||||
110 | // Need audio indicator twice, to keep iconBox in the center. | ||||
111 | readonly property var requiredSpace: Math.min(iconBox.width, iconBox.height) | ||||
112 | + Math.min(Math.min(iconBox.width, iconBox.height), units.iconSizes.smallMedium) * 2 | ||||
109 | svg: audioSvg | 113 | svg: audioSvg | ||
110 | smooth: false | 114 | smooth: false | ||
111 | 115 | | |||
112 | height: Math.round(Math.min(parent.height * 1.4, units.iconSizes.smallMedium) / 2) * 2 | 116 | height: Math.round(Math.min(parent.height * indicatorScale, units.iconSizes.smallMedium)) | ||
113 | width: height | 117 | width: height | ||
114 | 118 | | |||
115 | anchors { | 119 | anchors { | ||
116 | verticalCenter: parent.verticalCenter | 120 | verticalCenter: parent.verticalCenter | ||
117 | right: parent.right | 121 | horizontalCenter: parent.horizontalCenter | ||
118 | // Avoid overlap to the right. | | |||
119 | rightMargin: (parent.width - width) / 2 + units.smallSpacing / 4 | | |||
120 | } | 122 | } | ||
121 | 123 | | |||
122 | states: [ | 124 | states: [ | ||
123 | State { | 125 | State { | ||
126 | name: "verticalIconsOnly" | ||||
127 | when: tasks.vertical && frame.width < audioStreamIcon.requiredSpace | ||||
128 | | ||||
129 | PropertyChanges { | ||||
130 | target: audioStreamIconLoader | ||||
131 | anchors.rightMargin: Math.round(taskFrame.margins.right * indicatorScale) | ||||
132 | } | ||||
133 | }, | ||||
134 | | ||||
135 | State { | ||||
124 | name: "horizontal" | 136 | name: "horizontal" | ||
125 | // When there is enough space for the audio icon, to fit right of the centered task icon. | 137 | when: frame.width > audioStreamIcon.requiredSpace | ||
126 | when: (frame.width > Math.min(iconBox.width, iconBox.height) + | | |||
127 | Math.min(Math.min(iconBox.width, iconBox.height), units.iconSizes.smallMedium) * 2) | | |||
128 | 138 | | |||
129 | AnchorChanges { | 139 | AnchorChanges { | ||
130 | target: audioStreamIconLoader | 140 | target: audioStreamIconLoader | ||
131 | 141 | | |||
132 | anchors.top: undefined | 142 | anchors.top: undefined | ||
133 | anchors.verticalCenter: frame.verticalCenter | 143 | anchors.verticalCenter: frame.verticalCenter | ||
134 | } | 144 | } | ||
135 | 145 | | |||
136 | PropertyChanges { | 146 | PropertyChanges { | ||
137 | target: audioStreamIconLoader | 147 | target: audioStreamIconLoader | ||
138 | | ||||
139 | anchors.rightMargin: iconBox.adjustMargin(true, parent.width, taskFrame.margins.right) | | |||
140 | width: units.roundToIconSize(Math.min(Math.min(iconBox.width, iconBox.height), units.iconSizes.smallMedium)) | 148 | width: units.roundToIconSize(Math.min(Math.min(iconBox.width, iconBox.height), units.iconSizes.smallMedium)) | ||
141 | } | 149 | } | ||
142 | 150 | | |||
143 | PropertyChanges { | 151 | PropertyChanges { | ||
144 | target: audioStreamIcon | 152 | target: audioStreamIcon | ||
145 | 153 | | |||
146 | height: parent.height | 154 | height: parent.height | ||
147 | width: parent.width | 155 | width: parent.width | ||
148 | } | 156 | } | ||
149 | }, | 157 | }, | ||
150 | 158 | | |||
151 | State { | 159 | State { | ||
152 | name: "vertical" | 160 | name: "vertical" | ||
153 | // When audio icon can fit above the centered task icon. | 161 | when: frame.height > audioStreamIcon.requiredSpace | ||
154 | when: (frame.height > Math.min(iconBox.width, iconBox.height) + | | |||
155 | Math.min(Math.min(iconBox.width, iconBox.height), units.iconSizes.smallMedium) * 2) | | |||
156 | 162 | | |||
157 | AnchorChanges { | 163 | AnchorChanges { | ||
158 | target: audioStreamIconLoader | 164 | target: audioStreamIconLoader | ||
159 | 165 | | |||
160 | anchors.right: undefined | 166 | anchors.right: undefined | ||
161 | anchors.horizontalCenter: frame.horizontalCenter | 167 | anchors.horizontalCenter: frame.horizontalCenter | ||
162 | } | 168 | } | ||
163 | 169 | | |||
164 | PropertyChanges { | 170 | PropertyChanges { | ||
165 | target: audioStreamIconLoader | 171 | target: audioStreamIconLoader | ||
166 | 172 | | |||
167 | anchors.topMargin: iconBox.adjustMargin(false, frame.height, taskFrame.margins.top) | 173 | anchors.topMargin: taskFrame.margins.top | ||
168 | width: units.roundToIconSize(Math.min(Math.min(iconBox.width, iconBox.height), units.iconSizes.smallMedium)) | 174 | width: units.roundToIconSize(Math.min(Math.min(iconBox.width, iconBox.height), units.iconSizes.smallMedium)) | ||
169 | } | 175 | } | ||
170 | 176 | | |||
171 | PropertyChanges { | 177 | PropertyChanges { | ||
172 | target: audioStreamIcon | 178 | target: audioStreamIcon | ||
173 | 179 | | |||
174 | height: parent.height | 180 | height: parent.height | ||
175 | width: parent.width | 181 | width: parent.width | ||
176 | } | 182 | } | ||
177 | } | 183 | } | ||
178 | ] | 184 | ] | ||
179 | } | 185 | } | ||
180 | } | 186 | } |