Commit 081b11b7 authored by Nate Graham's avatar Nate Graham 💤
Browse files

[applet] Port towards PlasmaComponents3

Most things can be ported, but tab bar and context menu need to stay
using PC2 for now because:
- PC3 TabBar/TabButton needs a bit of work first
- There's no native PC3 context menu functionality
parent 0cb8d246
......@@ -19,7 +19,8 @@
*/
import QtQuick 2.0
import org.kde.plasma.components 2.0 as PlasmaComponents
import org.kde.plasma.components 2.0 as PlasmaComponents // for ListItem
import org.kde.plasma.components 3.0 as PlasmaComponents3
PlasmaComponents.ListItem {
property alias text: label.text
......@@ -27,7 +28,7 @@ PlasmaComponents.ListItem {
height: units.gridUnit * 1.5
sectionDelegate: true
PlasmaComponents.Label {
PlasmaComponents3.Label {
id: label
anchors.centerIn: parent
font.weight: Font.DemiBold
......
......@@ -24,7 +24,7 @@ import QtQuick.Controls 1.0
import QtQuick.Layouts 1.0
import org.kde.kquickcontrolsaddons 2.0
import org.kde.plasma.components 2.0 as PlasmaComponents
import org.kde.plasma.components 2.0 as PlasmaComponents // for contextMenu and ListItem
import org.kde.plasma.components 3.0 as PlasmaComponents3
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.extras 2.0 as PlasmaExtras
......@@ -139,13 +139,12 @@ PlasmaComponents.ListItem {
SmallToolButton {
id: contextMenuButton
icon: "application-menu"
icon.name: "application-menu"
checkable: true
onClicked: {
contextMenu.visualParent = this;
contextMenu.showRelative();
}
tooltip: i18n("Show additional options for %1", defaultButton.text)
visible: {
// if it is a sink type and there are at least two sink devices. Same for source type.
if (((type == "sink-input" || type == "sink") && sinkView.model.count > 1)
......@@ -170,6 +169,9 @@ PlasmaComponents.ListItem {
}
return false;
}
PlasmaComponents3.ToolTip {
text: i18n("Show additional options for %1", defaultButton.text)
}
}
}
......@@ -177,13 +179,16 @@ PlasmaComponents.ListItem {
SmallToolButton {
id: muteButton
readonly property bool isPlayback: type.substring(0, 4) == "sink"
icon: Icon.name(Volume, Muted, isPlayback ? "audio-volume" : "microphone-sensitivity")
icon.name: Icon.name(Volume, Muted, isPlayback ? "audio-volume" : "microphone-sensitivity")
onClicked: Muted = !Muted
checked: Muted
tooltip: i18n("Mute %1", defaultButton.text)
PlasmaComponents3.ToolTip {
text: i18n("Mute %1", defaultButton.text)
}
}
PlasmaComponents.Slider {
PlasmaComponents3.Slider {
id: slider
// Helper properties to allow async slider updates.
......@@ -196,9 +201,9 @@ PlasmaComponents.ListItem {
|| volume >= PulseAudio.NormalVolume * 1.01
Layout.fillWidth: true
minimumValue: PulseAudio.MinimalVolume
maximumValue: forceRaiseMaxVolume ? PulseAudio.MaximalVolume : PulseAudio.NormalVolume
stepSize: maximumValue / (maximumValue / PulseAudio.NormalVolume * 100.0)
from: PulseAudio.MinimalVolume
to: forceRaiseMaxVolume ? PulseAudio.MaximalVolume : PulseAudio.NormalVolume
stepSize: to / (to / PulseAudio.NormalVolume * 100.0)
visible: HasVolume
enabled: VolumeWritable
opacity: Muted ? 0.5 : 1
......@@ -248,9 +253,9 @@ PlasmaComponents.ListItem {
onTriggered: slider.value = Volume
}
}
PlasmaComponents.Label {
PlasmaComponents3.Label {
id: percentText
readonly property real value: PulseObject.volume > slider.maximumValue ? PulseObject.volume : slider.value
readonly property real value: PulseObject.volume > slider.to ? PulseObject.volume : slider.value
readonly property real displayValue: Math.round(value / PulseAudio.NormalVolume * 100.0)
Layout.alignment: Qt.AlignHCenter
Layout.minimumWidth: percentMetrics.advanceWidth
......
......@@ -22,24 +22,11 @@ import QtQuick 2.0
import QtQuick.Controls 1.0
import QtQuick.Layouts 1.0
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.components 2.0 as PlasmaComponents
import org.kde.plasma.components 3.0 as PlasmaComponents3
PlasmaComponents.ToolButton {
PlasmaComponents3.ToolButton {
id: smallToolButton
property real iconSize: units.iconSizes.small
property real padding: units.smallSpacing
property int size: Math.ceil(iconSize + padding * 2)
readonly property int size: Math.ceil(units.iconSizes.small + units.smallSpacing * 2)
implicitWidth: size
implicitHeight: size
property alias icon: icon.source
PlasmaCore.IconItem {
id: icon
anchors.fill: parent
anchors.margins: parent.padding
// From Plasma's ToolButtonStyle:
active: parent.hovered
colorGroup: parent.hovered ? PlasmaCore.Theme.ButtonColorGroup : PlasmaCore.ColorScope.colorGroup
}
}
......@@ -20,8 +20,6 @@
import QtQuick 2.0
import org.kde.plasma.components 2.0 as PlasmaComponents
import org.kde.plasma.private.volume 0.1
ListItemBase {
......
......@@ -22,7 +22,7 @@ import QtQuick 2.2
import QtQuick.Layouts 1.0
import org.kde.plasma.core 2.1 as PlasmaCore
import org.kde.plasma.components 2.0 as PlasmaComponents
import org.kde.plasma.components 2.0 as PlasmaComponents // PC3 TabBar/TabButton need work first
import org.kde.plasma.components 3.0 as PlasmaComponents3
import org.kde.plasma.extras 2.0 as PlasmaExtras
import org.kde.plasma.plasmoid 2.0
......@@ -633,9 +633,9 @@ Item {
Layout.fillWidth: true
}
PlasmaComponents.ToolButton {
PlasmaComponents3.ToolButton {
id: globalMuteCheckbox
iconName: "audio-volume-muted"
icon.name: "audio-volume-muted"
onClicked: {
if (!globalMute) {
enableGlobalMute();
......@@ -644,14 +644,21 @@ Item {
}
}
checked: globalMute
tooltip: i18n("Force mute all playback devices")
Accessible.name: i18n("Force mute all playback devices")
PlasmaComponents3.ToolTip {
text: i18n("Force mute all playback devices")
}
}
PlasmaComponents.ToolButton {
tooltip: plasmoid.action("configure").text
iconName: "configure"
Accessible.name: tooltip
PlasmaComponents3.ToolButton {
icon.name: "configure"
onClicked: plasmoid.action("configure").trigger()
Accessible.name: plasmoid.action("configure").text
PlasmaComponents3.ToolTip {
text: plasmoid.action("configure").text
}
}
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment