Changeset View
Changeset View
Standalone View
Standalone View
applet/contents/ui/main.qml
Show First 20 Lines • Show All 163 Lines • ▼ Show 20 Line(s) | 161 | onDefaultSinkChanged: { | |||
---|---|---|---|---|---|
164 | } | 164 | } | ||
165 | 165 | | |||
166 | // avoid showing a OSD on startup | 166 | // avoid showing a OSD on startup | ||
167 | if (!initalDefaultSinkIsSet) { | 167 | if (!initalDefaultSinkIsSet) { | ||
168 | initalDefaultSinkIsSet = true; | 168 | initalDefaultSinkIsSet = true; | ||
169 | return; | 169 | return; | ||
170 | } | 170 | } | ||
171 | 171 | | |||
172 | var icon = Icon.formFactorIcon(defaultSink.formFactor); | 172 | // For some hardware, headphones are a port of the build-in audio sink | ||
173 | var port = defaultSink.ports[defaultSink.activePortIndex]; | ||||
broulik: Please cache `defaultSink.ports[defaultSink.activePortIndex]` in a variable.
Also, can this be… | |||||
174 | var text = port.description; | ||||
175 | var icon; | ||||
I would prefer if hardcoded values like these are put into a helper function or formFactorIcon augmented to take those into account also broulik: I would prefer if hardcoded values like these are put into a helper function or… | |||||
176 | if (port.name == "analog-output-headphones") { | ||||
177 | icon = Icon.formFactorIcon("headphone"); | ||||
178 | } else if (port.name == "analog-output-speaker") { | ||||
179 | icon = Icon.formFactorIcon("speaker"); | ||||
What I don't like about this is that it no longer reflects the actual device volume, e.g. when I unpair my headphones, I get a "Speakers" notification with full volume icon despite the speakers actually being muted. broulik: What I don't like about this is that it no longer reflects the actual device volume, e.g. when… | |||||
180 | } | ||||
181 | | ||||
broulik: `if (!icon) {` is sufficient | |||||
182 | if (!icon) { | ||||
183 | icon = Icon.formFactorIcon(defaultSink.formFactor); | ||||
184 | text = defaultSink.description; | ||||
185 | } | ||||
186 | | ||||
173 | if (!icon) { | 187 | if (!icon) { | ||
174 | // Show "muted" icon for Dummy output | 188 | // Show "muted" icon for Dummy output | ||
The text = assignments seem to serve no purpose, ie. the end result would be no different than having it down where it was broulik: The `text =` assignments seem to serve no purpose, ie. the end result would be no different… | |||||
175 | if (isDummyOutput(defaultSink)) { | 189 | if (isDummyOutput(defaultSink)) { | ||
176 | icon = "audio-volume-muted"; | 190 | icon = "audio-volume-muted"; | ||
177 | } | 191 | } | ||
178 | } | 192 | } | ||
179 | 193 | | |||
180 | if (!icon) { | 194 | if (!icon) { | ||
181 | icon = Icon.name(defaultSink.volume, defaultSink.muted); | 195 | icon = Icon.name(defaultSink.volume, defaultSink.muted); | ||
182 | } | 196 | } | ||
183 | osd.showText(icon, defaultSink.description); | 197 | osd.showText(icon, text); | ||
184 | } | 198 | } | ||
185 | } | 199 | } | ||
186 | 200 | | |||
187 | SourceModel { | 201 | SourceModel { | ||
188 | id: paSourceModel | 202 | id: paSourceModel | ||
189 | } | 203 | } | ||
190 | 204 | | |||
191 | Plasmoid.compactRepresentation: PlasmaCore.IconItem { | 205 | Plasmoid.compactRepresentation: PlasmaCore.IconItem { | ||
▲ Show 20 Lines • Show All 314 Lines • Show Last 20 Lines |
Please cache defaultSink.ports[defaultSink.activePortIndex] in a variable.
Also, can this be out of bounds or otherwise throw an error?