diff --git a/applet/contents/ui/ListItemBase.qml b/applet/contents/ui/ListItemBase.qml --- a/applet/contents/ui/ListItemBase.qml +++ b/applet/contents/ui/ListItemBase.qml @@ -94,6 +94,7 @@ ColumnLayout { id: column + spacing: 1 RowLayout { Layout.fillWidth: true @@ -106,36 +107,19 @@ wrapMode: Text.NoWrap elide: Text.ElideRight } - PlasmaComponents.ToolButton { + SmallToolButton { id: contextMenuButton - Layout.preferredHeight: units.iconSizes.small + units.smallSpacing * 2 - Layout.preferredWidth: Layout.preferredHeight + icon: "application-menu" checkable: true onClicked: contextMenu.show() - - PlasmaCore.IconItem { - anchors.fill: parent - anchors.margins: units.smallSpacing - source: "application-menu" - - // From Plasma's ToolButtonStyle: - active: parent.hovered - colorGroup: parent.hovered ? PlasmaCore.Theme.ButtonColorGroup : PlasmaCore.ColorScope.colorGroup - } } } RowLayout { - PlasmaCore.IconItem { + SmallToolButton { readonly property bool isPlayback: type.substring(0, 4) == "sink" - Layout.preferredWidth: units.iconSizes.small - Layout.preferredHeight: Layout.preferredWidth - source: Icon.name(Volume, Muted, isPlayback ? "audio-volume" : "microphone-sensitivity") - - MouseArea { - anchors.fill: parent - onPressed: Muted = !Muted - } + icon: Icon.name(Volume, Muted, isPlayback ? "audio-volume" : "microphone-sensitivity") + onClicked: Muted = !Muted } PlasmaComponents.Slider { diff --git a/applet/contents/ui/SmallToolButton.qml b/applet/contents/ui/SmallToolButton.qml new file mode 100644 --- /dev/null +++ b/applet/contents/ui/SmallToolButton.qml @@ -0,0 +1,25 @@ +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 + +PlasmaComponents.ToolButton { + id: smallToolButton + property real iconSize: units.iconSizes.small + property real padding: units.smallSpacing + property int size: Math.ceil(iconSize + padding * 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 + } +}