Changeset View
Changeset View
Standalone View
Standalone View
applet/contents/ui/main.qml
Show First 20 Lines • Show All 95 Lines • ▼ Show 20 Line(s) | 34 | Item { | |||
---|---|---|---|---|---|
96 | function increaseVolume() { | 96 | function increaseVolume() { | ||
97 | if (!paSinkModel.preferredSink || isDummyOutput(paSinkModel.preferredSink)) { | 97 | if (!paSinkModel.preferredSink || isDummyOutput(paSinkModel.preferredSink)) { | ||
98 | return; | 98 | return; | ||
99 | } | 99 | } | ||
100 | var volume = boundVolume(paSinkModel.preferredSink.volume + volumeStep); | 100 | var volume = boundVolume(paSinkModel.preferredSink.volume + volumeStep); | ||
101 | var percent = volumePercent(volume, currentMaxVolumeValue); | 101 | var percent = volumePercent(volume, currentMaxVolumeValue); | ||
102 | paSinkModel.preferredSink.muted = percent == 0; | 102 | paSinkModel.preferredSink.muted = percent == 0; | ||
103 | paSinkModel.preferredSink.volume = volume; | 103 | paSinkModel.preferredSink.volume = volume; | ||
104 | osd.show(percent); | 104 | osd.showVolume(percent); | ||
105 | playFeedback(); | 105 | playFeedback(); | ||
106 | } | 106 | } | ||
107 | 107 | | |||
108 | function decreaseVolume() { | 108 | function decreaseVolume() { | ||
109 | if (!paSinkModel.preferredSink || isDummyOutput(paSinkModel.preferredSink)) { | 109 | if (!paSinkModel.preferredSink || isDummyOutput(paSinkModel.preferredSink)) { | ||
110 | return; | 110 | return; | ||
111 | } | 111 | } | ||
112 | var volume = boundVolume(paSinkModel.preferredSink.volume - volumeStep); | 112 | var volume = boundVolume(paSinkModel.preferredSink.volume - volumeStep); | ||
113 | var percent = volumePercent(volume, currentMaxVolumeValue); | 113 | var percent = volumePercent(volume, currentMaxVolumeValue); | ||
114 | paSinkModel.preferredSink.muted = percent == 0; | 114 | paSinkModel.preferredSink.muted = percent == 0; | ||
115 | paSinkModel.preferredSink.volume = volume; | 115 | paSinkModel.preferredSink.volume = volume; | ||
116 | osd.show(percent); | 116 | osd.showVolume(percent); | ||
117 | playFeedback(); | 117 | playFeedback(); | ||
118 | } | 118 | } | ||
119 | 119 | | |||
120 | function muteVolume() { | 120 | function muteVolume() { | ||
121 | if (!paSinkModel.preferredSink || isDummyOutput(paSinkModel.preferredSink)) { | 121 | if (!paSinkModel.preferredSink || isDummyOutput(paSinkModel.preferredSink)) { | ||
122 | return; | 122 | return; | ||
123 | } | 123 | } | ||
124 | var toMute = !paSinkModel.preferredSink.muted; | 124 | var toMute = !paSinkModel.preferredSink.muted; | ||
125 | if (toMute) { | 125 | if (toMute) { | ||
126 | enableGlobalMute(); | 126 | enableGlobalMute(); | ||
127 | osd.show(0); | 127 | osd.showMute(0); | ||
128 | } else { | 128 | } else { | ||
129 | if (globalMute) { | 129 | if (globalMute) { | ||
130 | disableGlobalMute(); | 130 | disableGlobalMute(); | ||
131 | } | 131 | } | ||
132 | paSinkModel.preferredSink.muted = toMute; | 132 | paSinkModel.preferredSink.muted = toMute; | ||
133 | osd.show(volumePercent(paSinkModel.preferredSink.volume, currentMaxVolumeValue)); | 133 | osd.showMute(volumePercent(paSinkModel.preferredSink.volume, currentMaxVolumeValue)); | ||
134 | playFeedback(); | 134 | playFeedback(); | ||
135 | } | 135 | } | ||
136 | } | 136 | } | ||
137 | 137 | | |||
138 | function increaseMicrophoneVolume() { | 138 | function increaseMicrophoneVolume() { | ||
139 | if (!paSourceModel.defaultSource) { | 139 | if (!paSourceModel.defaultSource) { | ||
140 | return; | 140 | return; | ||
141 | } | 141 | } | ||
142 | var volume = boundVolume(paSourceModel.defaultSource.volume + volumeStep); | 142 | var volume = boundVolume(paSourceModel.defaultSource.volume + volumeStep); | ||
143 | var percent = volumePercent(volume, currentMaxVolumeValue); | 143 | var percent = volumePercent(volume, currentMaxVolumeValue); | ||
144 | paSourceModel.defaultSource.muted = percent == 0; | 144 | paSourceModel.defaultSource.muted = percent == 0; | ||
145 | paSourceModel.defaultSource.volume = volume; | 145 | paSourceModel.defaultSource.volume = volume; | ||
146 | osd.showMicrophone(percent); | 146 | osd.showMic(percent); | ||
147 | } | 147 | } | ||
148 | 148 | | |||
149 | function decreaseMicrophoneVolume() { | 149 | function decreaseMicrophoneVolume() { | ||
150 | if (!paSourceModel.defaultSource) { | 150 | if (!paSourceModel.defaultSource) { | ||
151 | return; | 151 | return; | ||
152 | } | 152 | } | ||
153 | var volume = boundVolume(paSourceModel.defaultSource.volume - volumeStep); | 153 | var volume = boundVolume(paSourceModel.defaultSource.volume - volumeStep); | ||
154 | var percent = volumePercent(volume, currentMaxVolumeValue); | 154 | var percent = volumePercent(volume, currentMaxVolumeValue); | ||
155 | paSourceModel.defaultSource.muted = percent == 0; | 155 | paSourceModel.defaultSource.muted = percent == 0; | ||
156 | paSourceModel.defaultSource.volume = volume; | 156 | paSourceModel.defaultSource.volume = volume; | ||
157 | osd.showMicrophone(percent); | 157 | osd.showMic(percent); | ||
158 | } | 158 | } | ||
159 | 159 | | |||
160 | function muteMicrophone() { | 160 | function muteMicrophone() { | ||
161 | if (!paSourceModel.defaultSource) { | 161 | if (!paSourceModel.defaultSource) { | ||
162 | return; | 162 | return; | ||
163 | } | 163 | } | ||
164 | var toMute = !paSourceModel.defaultSource.muted; | 164 | var toMute = !paSourceModel.defaultSource.muted; | ||
165 | paSourceModel.defaultSource.muted = toMute; | 165 | paSourceModel.defaultSource.muted = toMute; | ||
166 | osd.showMicrophone(toMute? 0 : volumePercent(paSourceModel.defaultSource.volume, currentMaxVolumeValue)); | 166 | osd.showMicMute(toMute? 0 : volumePercent(paSourceModel.defaultSource.volume, currentMaxVolumeValue)); | ||
167 | } | 167 | } | ||
168 | 168 | | |||
169 | function playFeedback(sinkIndex) { | 169 | function playFeedback(sinkIndex) { | ||
170 | if (!volumeFeedback) { | 170 | if (!volumeFeedback) { | ||
171 | return; | 171 | return; | ||
172 | } | 172 | } | ||
173 | if (sinkIndex == undefined) { | 173 | if (sinkIndex == undefined) { | ||
174 | sinkIndex = paSinkModel.preferredSink.index; | 174 | sinkIndex = paSinkModel.preferredSink.index; | ||
175 | } | 175 | } | ||
176 | feedback.play(sinkIndex); | 176 | feedback.play(sinkIndex); | ||
177 | } | 177 | } | ||
178 | 178 | | |||
179 | | ||||
cblack: These functions would probably be better declared on the OSD object like so:
```
VolumeOSD… | |||||
179 | function enableGlobalMute() { | 180 | function enableGlobalMute() { | ||
180 | var role = paSinkModel.role("Muted"); | 181 | var role = paSinkModel.role("Muted"); | ||
181 | var rowCount = paSinkModel.rowCount(); | 182 | var rowCount = paSinkModel.rowCount(); | ||
182 | // List for devices that are already muted. Will use to keep muted after disable GlobalMute. | 183 | // List for devices that are already muted. Will use to keep muted after disable GlobalMute. | ||
183 | var globalMuteDevices = []; | 184 | var globalMuteDevices = []; | ||
184 | 185 | | |||
185 | for (var i = 0; i < rowCount; i++) { | 186 | for (var i = 0; i < rowCount; i++) { | ||
186 | var idx = paSinkModel.index(i, 0); | 187 | var idx = paSinkModel.index(i, 0); | ||
187 | var name = paSinkModel.data(idx, paSinkModel.role("Name")); | 188 | var name = paSinkModel.data(idx, paSinkModel.role("Name")); | ||
188 | if (paSinkModel.data(idx, role) === false) { | 189 | if (paSinkModel.data(idx, role) === false) { | ||
189 | paSinkModel.setData(idx, true, role); | 190 | paSinkModel.setData(idx, true, role); | ||
190 | } else { | 191 | } else { | ||
191 | globalMuteDevices.push(name + "." + paSinkModel.data(idx, paSinkModel.role("ActivePortIndex"))); | 192 | globalMuteDevices.push(name + "." + paSinkModel.data(idx, paSinkModel.role("ActivePortIndex"))); | ||
192 | } | 193 | } | ||
193 | } | 194 | } | ||
194 | // If all the devices were muted, will unmute them all with disable GlobalMute. | 195 | // If all the devices were muted, will unmute them all with disable GlobalMute. | ||
195 | plasmoid.configuration.globalMuteDevices = globalMuteDevices.length < rowCount ? globalMuteDevices : []; | 196 | plasmoid.configuration.globalMuteDevices = globalMuteDevices.length < rowCount ? globalMuteDevices : []; | ||
196 | plasmoid.configuration.globalMute = true; | 197 | plasmoid.configuration.globalMute = true; | ||
197 | globalMute = true; | 198 | globalMute = true; | ||
ngraham: `mutecOsd`? :-) | |||||
198 | } | 199 | } | ||
199 | 200 | | |||
200 | function disableGlobalMute() { | 201 | function disableGlobalMute() { | ||
201 | var role = paSinkModel.role("Muted"); | 202 | var role = paSinkModel.role("Muted"); | ||
202 | for (var i = 0; i < paSinkModel.rowCount(); i++) { | 203 | for (var i = 0; i < paSinkModel.rowCount(); i++) { | ||
203 | var idx = paSinkModel.index(i, 0); | 204 | var idx = paSinkModel.index(i, 0); | ||
204 | var name = paSinkModel.data(idx, paSinkModel.role("Name")) + "." + paSinkModel.data(idx, paSinkModel.role("ActivePortIndex")); | 205 | var name = paSinkModel.data(idx, paSinkModel.role("Name")) + "." + paSinkModel.data(idx, paSinkModel.role("ActivePortIndex")); | ||
205 | if (plasmoid.configuration.globalMuteDevices.indexOf(name) === -1) { | 206 | if (plasmoid.configuration.globalMuteDevices.indexOf(name) === -1) { | ||
▲ Show 20 Lines • Show All 147 Lines • ▼ Show 20 Line(s) | 352 | GlobalAction { | |||
353 | text: i18n("Mute Microphone") | 354 | text: i18n("Mute Microphone") | ||
354 | shortcut: Qt.Key_MicMute | 355 | shortcut: Qt.Key_MicMute | ||
355 | onTriggered: muteMicrophone() | 356 | onTriggered: muteMicrophone() | ||
356 | } | 357 | } | ||
357 | } | 358 | } | ||
358 | 359 | | |||
359 | VolumeOSD { | 360 | VolumeOSD { | ||
360 | id: osd | 361 | id: osd | ||
362 | | ||||
363 | function showVolume(text) { | ||||
364 | if (!main.Plasmoid.configuration.volumeOsd) | ||||
365 | return | ||||
366 | show(text) | ||||
367 | } | ||||
368 | | ||||
369 | function showMute(text) { | ||||
370 | if (!main.Plasmoid.configuration.muteOsd) | ||||
371 | return | ||||
372 | show(text) | ||||
373 | } | ||||
374 | | ||||
375 | function showMic(text) { | ||||
376 | if (!main.Plasmoid.configuration.micOsd) | ||||
377 | return | ||||
378 | showMicrophone(text) | ||||
379 | } | ||||
380 | | ||||
381 | function showMicMute(text) { | ||||
382 | if (!main.Plasmoid.configuration.muteOsd) | ||||
383 | return | ||||
384 | showMicrophone(text) | ||||
385 | } | ||||
361 | } | 386 | } | ||
362 | 387 | | |||
363 | VolumeFeedback { | 388 | VolumeFeedback { | ||
364 | id: feedback | 389 | id: feedback | ||
365 | } | 390 | } | ||
366 | 391 | | |||
367 | PlasmaCore.Svg { | 392 | PlasmaCore.Svg { | ||
368 | id: lineSvg | 393 | id: lineSvg | ||
▲ Show 20 Lines • Show All 282 Lines • Show Last 20 Lines |
These functions would probably be better declared on the OSD object like so: