Changeset View
Changeset View
Standalone View
Standalone View
applet/contents/ui/main.qml
Show All 27 Lines | |||||
28 | 28 | | |||
29 | import org.kde.plasma.private.volume 0.1 | 29 | import org.kde.plasma.private.volume 0.1 | ||
30 | 30 | | |||
31 | import "../code/icon.js" as Icon | 31 | import "../code/icon.js" as Icon | ||
32 | 32 | | |||
33 | Item { | 33 | Item { | ||
34 | id: main | 34 | id: main | ||
35 | 35 | | |||
36 | property bool volumeFeedback: Plasmoid.configuration.volumeFeedback | ||||
36 | property int maxVolumePercent: Plasmoid.configuration.maximumVolume | 37 | property int maxVolumePercent: Plasmoid.configuration.maximumVolume | ||
37 | property int maxVolumeValue: Math.round(maxVolumePercent * PulseAudio.NormalVolume / 100.0) | 38 | property int maxVolumeValue: Math.round(maxVolumePercent * PulseAudio.NormalVolume / 100.0) | ||
38 | property int volumeStep: Math.round(Plasmoid.configuration.volumeStep * PulseAudio.NormalVolume / 100.0) | 39 | property int volumeStep: Math.round(Plasmoid.configuration.volumeStep * PulseAudio.NormalVolume / 100.0) | ||
39 | property string displayName: i18n("Audio Volume") | 40 | property string displayName: i18n("Audio Volume") | ||
40 | property QtObject draggedStream: null | 41 | property QtObject draggedStream: null | ||
41 | 42 | | |||
42 | Layout.minimumHeight: units.gridUnit * 12 | 43 | Layout.minimumHeight: units.gridUnit * 12 | ||
43 | Layout.minimumWidth: units.gridUnit * 12 | 44 | Layout.minimumWidth: units.gridUnit * 12 | ||
Show All 20 Lines | |||||
64 | function increaseVolume() { | 65 | function increaseVolume() { | ||
65 | if (!sinkModel.preferredSink) { | 66 | if (!sinkModel.preferredSink) { | ||
66 | return; | 67 | return; | ||
67 | } | 68 | } | ||
68 | var volume = boundVolume(sinkModel.preferredSink.volume + volumeStep); | 69 | var volume = boundVolume(sinkModel.preferredSink.volume + volumeStep); | ||
69 | sinkModel.preferredSink.muted = false; | 70 | sinkModel.preferredSink.muted = false; | ||
70 | sinkModel.preferredSink.volume = volume; | 71 | sinkModel.preferredSink.volume = volume; | ||
71 | osd.show(volumePercent(volume, maxVolumeValue)); | 72 | osd.show(volumePercent(volume, maxVolumeValue)); | ||
73 | playFeedback(); | ||||
72 | } | 74 | } | ||
73 | 75 | | |||
74 | function decreaseVolume() { | 76 | function decreaseVolume() { | ||
75 | if (!sinkModel.preferredSink) { | 77 | if (!sinkModel.preferredSink) { | ||
76 | return; | 78 | return; | ||
77 | } | 79 | } | ||
78 | var volume = boundVolume(sinkModel.preferredSink.volume - volumeStep); | 80 | var volume = boundVolume(sinkModel.preferredSink.volume - volumeStep); | ||
79 | sinkModel.preferredSink.muted = false; | 81 | sinkModel.preferredSink.muted = false; | ||
80 | sinkModel.preferredSink.volume = volume; | 82 | sinkModel.preferredSink.volume = volume; | ||
81 | osd.show(volumePercent(volume, maxVolumeValue)); | 83 | osd.show(volumePercent(volume, maxVolumeValue)); | ||
84 | playFeedback(); | ||||
82 | } | 85 | } | ||
83 | 86 | | |||
84 | function muteVolume() { | 87 | function muteVolume() { | ||
85 | if (!sinkModel.preferredSink) { | 88 | if (!sinkModel.preferredSink) { | ||
86 | return; | 89 | return; | ||
87 | } | 90 | } | ||
88 | var toMute = !sinkModel.preferredSink.muted; | 91 | var toMute = !sinkModel.preferredSink.muted; | ||
89 | sinkModel.preferredSink.muted = toMute; | 92 | sinkModel.preferredSink.muted = toMute; | ||
90 | osd.show(toMute ? 0 : volumePercent(sinkModel.preferredSink.volume, maxVolumeValue)); | 93 | osd.show(toMute ? 0 : volumePercent(sinkModel.preferredSink.volume, maxVolumeValue)); | ||
94 | playFeedback(); | ||||
91 | } | 95 | } | ||
92 | 96 | | |||
93 | function increaseMicrophoneVolume() { | 97 | function increaseMicrophoneVolume() { | ||
94 | if (!sourceModel.defaultSource) { | 98 | if (!sourceModel.defaultSource) { | ||
95 | return; | 99 | return; | ||
96 | } | 100 | } | ||
97 | var volume = boundVolume(sourceModel.defaultSource.volume + volumeStep); | 101 | var volume = boundVolume(sourceModel.defaultSource.volume + volumeStep); | ||
98 | sourceModel.defaultSource.muted = false; | 102 | sourceModel.defaultSource.muted = false; | ||
Show All 36 Lines | 138 | function endMoveStream() { | |||
135 | tabBar.currentTab = streamsTab; | 139 | tabBar.currentTab = streamsTab; | ||
136 | 140 | | |||
137 | sourceView.visible = true; | 141 | sourceView.visible = true; | ||
138 | sourceViewHeader.visible = true; | 142 | sourceViewHeader.visible = true; | ||
139 | sinkView.visible = true; | 143 | sinkView.visible = true; | ||
140 | sinkViewHeader.visible = true; | 144 | sinkViewHeader.visible = true; | ||
141 | } | 145 | } | ||
142 | 146 | | |||
147 | function playFeedback(sinkIndex) { | ||||
148 | if (!volumeFeedback) { | ||||
149 | return; | ||||
150 | } | ||||
151 | if (!sinkIndex) { | ||||
152 | sinkIndex = sinkModel.preferredSink.cardIndex; | ||||
153 | } | ||||
154 | feedback.play(sinkIndex); | ||||
155 | } | ||||
156 | | ||||
143 | Plasmoid.compactRepresentation: PlasmaCore.IconItem { | 157 | Plasmoid.compactRepresentation: PlasmaCore.IconItem { | ||
144 | source: plasmoid.icon | 158 | source: plasmoid.icon | ||
145 | active: mouseArea.containsMouse | 159 | active: mouseArea.containsMouse | ||
146 | colorGroup: PlasmaCore.ColorScope.colorGroup | 160 | colorGroup: PlasmaCore.ColorScope.colorGroup | ||
147 | 161 | | |||
148 | MouseArea { | 162 | MouseArea { | ||
149 | id: mouseArea | 163 | id: mouseArea | ||
150 | 164 | | |||
▲ Show 20 Lines • Show All 81 Lines • ▼ Show 20 Line(s) | 242 | GlobalAction { | |||
232 | onTriggered: muteMicrophone() | 246 | onTriggered: muteMicrophone() | ||
233 | } | 247 | } | ||
234 | } | 248 | } | ||
235 | 249 | | |||
236 | VolumeOSD { | 250 | VolumeOSD { | ||
237 | id: osd | 251 | id: osd | ||
238 | } | 252 | } | ||
239 | 253 | | |||
254 | VolumeFeedback { | ||||
255 | id: feedback | ||||
256 | } | ||||
257 | | ||||
240 | PlasmaComponents.TabBar { | 258 | PlasmaComponents.TabBar { | ||
241 | id: tabBar | 259 | id: tabBar | ||
242 | 260 | | |||
243 | anchors { | 261 | anchors { | ||
244 | top: parent.top | 262 | top: parent.top | ||
245 | left: parent.left | 263 | left: parent.left | ||
246 | right: parent.right | 264 | right: parent.right | ||
247 | } | 265 | } | ||
▲ Show 20 Lines • Show All 146 Lines • Show Last 20 Lines |