Changeset View
Changeset View
Standalone View
Standalone View
src/kcm/package/contents/ui/VolumeSlider.qml
1 | /* | 1 | /* | ||
---|---|---|---|---|---|
2 | Copyright 2014-2015 Harald Sitter <sitter@kde.org> | 2 | Copyright 2014-2015 Harald Sitter <sitter@kde.org> | ||
3 | Copyright 2019 Sefa Eyeoglu <contact@scrumplex.net> | ||||
3 | 4 | | |||
4 | This program is free software; you can redistribute it and/or | 5 | This program is free software; you can redistribute it and/or | ||
5 | modify it under the terms of the GNU General Public License as | 6 | modify it under the terms of the GNU General Public License as | ||
6 | published by the Free Software Foundation; either version 2 of | 7 | published by the Free Software Foundation; either version 2 of | ||
7 | the License or (at your option) version 3 or any later version | 8 | the License or (at your option) version 3 or any later version | ||
8 | accepted by the membership of KDE e.V. (or its successor approved | 9 | accepted by the membership of KDE e.V. (or its successor approved | ||
9 | by the membership of KDE e.V.), which shall act as a proxy | 10 | by the membership of KDE e.V.), which shall act as a proxy | ||
10 | defined in Section 14 of version 3 of the license. | 11 | defined in Section 14 of version 3 of the license. | ||
Show All 24 Lines | 31 | Slider { | |||
35 | // as otherwise we can easily end up in a loop where value | 36 | // as otherwise we can easily end up in a loop where value | ||
36 | // changes trigger volume changes trigger value changes. | 37 | // changes trigger volume changes trigger value changes. | ||
37 | property int volume: Volume | 38 | property int volume: Volume | ||
38 | property bool ignoreValueChange: true | 39 | property bool ignoreValueChange: true | ||
39 | 40 | | |||
40 | Layout.fillWidth: true | 41 | Layout.fillWidth: true | ||
41 | from: PulseAudio.MinimalVolume | 42 | from: PulseAudio.MinimalVolume | ||
42 | to: PulseAudio.MaximalVolume | 43 | to: PulseAudio.MaximalVolume | ||
43 | visible: HasVolume | 44 | visible: HasVolume | ||
ngraham: Hmm, I don't like how this makes tickmarks appear. If you need to round the value, you can do… | |||||
I have removed this now as I can't replicate the same behavior as the applet. Added a TODO for the future sefaeyeoglu: I have removed this now as I can't replicate the same behavior as the applet. Added a TODO for… | |||||
44 | enabled: VolumeWritable | 45 | enabled: VolumeWritable | ||
45 | opacity: Muted ? 0.5 : 1 | 46 | opacity: Muted ? 0.5 : 1 | ||
46 | 47 | | |||
47 | Component.onCompleted: { | 48 | Component.onCompleted: { | ||
48 | ignoreValueChange = false; | 49 | ignoreValueChange = false; | ||
49 | } | 50 | } | ||
50 | 51 | | |||
51 | onVolumeChanged: { | 52 | onVolumeChanged: { | ||
Show All 22 Lines | 71 | if (!pressed) { | |||
74 | // whereas PA rejected the volume change and is | 75 | // whereas PA rejected the volume change and is | ||
75 | // still at v15 (e.g.). | 76 | // still at v15 (e.g.). | ||
76 | updateTimer.restart(); | 77 | updateTimer.restart(); | ||
77 | } | 78 | } | ||
78 | } | 79 | } | ||
79 | 80 | | |||
80 | Label { | 81 | Label { | ||
81 | id: hundredPercentLabel | 82 | id: hundredPercentLabel | ||
82 | readonly property real hundredPos: (slider.width / slider.maximumValue) * PulseAudio.NormalVolume | 83 | readonly property real hundredPos: (slider.width / slider.to) * PulseAudio.NormalVolume | ||
83 | z: slider.z - 1 | 84 | z: slider.z - 1 | ||
84 | x: (Qt.application.layoutDirection == Qt.RightToLeft ? slider.width - hundredPos : hundredPos) - width / 2 | 85 | x: (Qt.application.layoutDirection == Qt.RightToLeft ? slider.width - hundredPos : hundredPos) - width / 2 | ||
85 | y: slider.height / 1.2 | 86 | y: slider.height / 1.2 | ||
86 | opacity: 0.5 | 87 | opacity: 0.5 | ||
87 | font.pixelSize: slider.height / 2.2 | 88 | font.pixelSize: slider.height / 2.2 | ||
88 | text: i18nd("kcm_pulseaudio", "100%") | 89 | text: i18nd("kcm_pulseaudio", "100%") | ||
89 | } | 90 | } | ||
90 | 91 | | |||
Show All 22 Lines |
Hmm, I don't like how this makes tickmarks appear. If you need to round the value, you can do that in onMoved: { blabla; }, or just round the value of the label itself.