Changeset View
Changeset View
Standalone View
Standalone View
applet/contents/ui/ListItemBase.qml
Show All 13 Lines | 1 | /* | |||
---|---|---|---|---|---|
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | GNU General Public License for more details. | 15 | GNU General Public License for more details. | ||
16 | 16 | | |||
17 | You should have received a copy of the GNU General Public License | 17 | You should have received a copy of the GNU General Public License | ||
18 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 18 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
19 | */ | 19 | */ | ||
20 | 20 | | |||
21 | import QtQuick 2.4 | 21 | import QtQuick 2.4 | ||
22 | | ||||
23 | import QtQuick.Controls 1.0 | 22 | import QtQuick.Controls 1.0 | ||
24 | import QtQuick.Layouts 1.0 | 23 | import QtQuick.Layouts 1.0 | ||
25 | 24 | | |||
26 | import org.kde.kquickcontrolsaddons 2.0 | 25 | import org.kde.kquickcontrolsaddons 2.0 | ||
27 | import org.kde.plasma.components 2.0 as PlasmaComponents | 26 | import org.kde.plasma.components 2.0 as PlasmaComponents | ||
28 | import org.kde.plasma.core 2.0 as PlasmaCore | 27 | import org.kde.plasma.core 2.0 as PlasmaCore | ||
29 | import org.kde.plasma.extras 2.0 as PlasmaExtras | 28 | import org.kde.plasma.extras 2.0 as PlasmaExtras | ||
30 | import org.kde.draganddrop 2.0 as DragAndDrop | 29 | import org.kde.draganddrop 2.0 as DragAndDrop | ||
31 | 30 | | |||
31 | import org.kde.plasma.private.volume 0.1 | ||||
32 | | ||||
32 | PlasmaComponents.ListItem { | 33 | PlasmaComponents.ListItem { | ||
33 | id: item | 34 | id: item | ||
34 | 35 | | |||
35 | property alias label: textLabel.text | 36 | property alias label: textLabel.text | ||
36 | property alias draggable: dragArea.enabled | 37 | property alias draggable: dragArea.enabled | ||
37 | property alias icon: clientIcon.source | 38 | property alias icon: clientIcon.source | ||
38 | property string type | 39 | property string type | ||
39 | 40 | | |||
▲ Show 20 Lines • Show All 94 Lines • ▼ Show 20 Line(s) | 132 | PlasmaComponents.Slider { | |||
134 | // Helper properties to allow async slider updates. | 135 | // Helper properties to allow async slider updates. | ||
135 | // While we are sliding we must not react to value updates | 136 | // While we are sliding we must not react to value updates | ||
136 | // as otherwise we can easily end up in a loop where value | 137 | // as otherwise we can easily end up in a loop where value | ||
137 | // changes trigger volume changes trigger value changes. | 138 | // changes trigger volume changes trigger value changes. | ||
138 | property int volume: Volume | 139 | property int volume: Volume | ||
139 | property bool ignoreValueChange: false | 140 | property bool ignoreValueChange: false | ||
140 | 141 | | |||
141 | Layout.fillWidth: true | 142 | Layout.fillWidth: true | ||
142 | minimumValue: 0 | 143 | minimumValue: PulseAudio.MinimalVolume | ||
143 | // FIXME: I do wonder if exposing max through the model would be useful at all | 144 | maximumValue: maxVolumeValue | ||
144 | maximumValue: 65536 | 145 | stepSize: maximumValue / maxVolumePercent | ||
145 | stepSize: maximumValue / 100 | | |||
146 | visible: HasVolume | 146 | visible: HasVolume | ||
147 | enabled: VolumeWritable && !Muted | 147 | enabled: VolumeWritable && !Muted | ||
148 | 148 | | |||
149 | onVolumeChanged: { | 149 | onVolumeChanged: { | ||
150 | ignoreValueChange = true; | 150 | ignoreValueChange = true; | ||
151 | value = Volume; | 151 | value = Volume; | ||
152 | ignoreValueChange = false; | 152 | ignoreValueChange = false; | ||
153 | } | 153 | } | ||
Show All 22 Lines | |||||
176 | Timer { | 176 | Timer { | ||
177 | id: updateTimer | 177 | id: updateTimer | ||
178 | interval: 200 | 178 | interval: 200 | ||
179 | onTriggered: slider.value = Volume | 179 | onTriggered: slider.value = Volume | ||
180 | } | 180 | } | ||
181 | } | 181 | } | ||
182 | PlasmaComponents.Label { | 182 | PlasmaComponents.Label { | ||
183 | id: percentText | 183 | id: percentText | ||
184 | readonly property real value: PulseObject.volume > slider.maximumValue ? PulseObject.volume : slider.value | ||||
184 | Layout.alignment: Qt.AlignHCenter | 185 | Layout.alignment: Qt.AlignHCenter | ||
185 | Layout.minimumWidth: percentMetrics.advanceWidth | 186 | Layout.minimumWidth: percentMetrics.advanceWidth | ||
186 | horizontalAlignment: Qt.AlignRight | 187 | horizontalAlignment: Qt.AlignRight | ||
187 | text: i18nc("volume percentage", "%1%", Math.floor(slider.value / slider.maximumValue * 100.0)) | 188 | text: i18nc("volume percentage", "%1%", Math.round(value / PulseAudio.NormalVolume * 100.0)) | ||
188 | } | 189 | } | ||
189 | 190 | | |||
190 | TextMetrics { | 191 | TextMetrics { | ||
191 | id: percentMetrics | 192 | id: percentMetrics | ||
192 | font: percentText.font | 193 | font: percentText.font | ||
193 | text: i18nc("only used for sizing, should be widest possible string", "100%") | 194 | text: i18nc("only used for sizing, should be widest possible string", "100%") | ||
194 | } | 195 | } | ||
195 | } | 196 | } | ||
196 | } | 197 | } | ||
197 | } | 198 | } | ||
198 | } | 199 | } | ||
199 | } | 200 | } |