Commit 060f05a0 authored by Nicolas Fella's avatar Nicolas Fella

[kcm] Use Kirigami.ListSectionHeader

Instead of using a custom header use the standard Kirigami.ListSectionHeader.

Also hide empty sections instead of showing a placeholder.
parent a0624773
/*
Copyright 2014-2015 Harald Sitter <sitter@kde.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of
the License or (at your option) version 3 or any later version
accepted by the membership of KDE e.V. (or its successor approved
by the membership of KDE e.V.), which shall act as a proxy
defined in Section 14 of version 3 of the license.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import QtQuick 2.0
import QtQuick.Layouts 1.1
import QtQuick.Controls 2.0
import org.kde.kirigami 2.5 as Kirigami
ColumnLayout {
property alias text: heading.text
property alias disabledText: disabledLabel.text
Item {
Layout.fillWidth: true
Layout.preferredHeight: Kirigami.Units.gridUnit * 1.5
Layout.topMargin: Kirigami.Units.smallSpacing
Label {
id: heading
anchors.fill: parent
horizontalAlignment: Text.AlignHCenter
elide: Text.ElideRight
font.weight: Font.DemiBold
}
}
Label {
id: disabledLabel
Layout.alignment: Qt.AlignCenter
Layout.fillWidth: true
horizontalAlignment: Text.AlignHCenter
elide: Text.ElideRight
visible: text && !parent.enabled
font.italic: true
}
}
......@@ -26,7 +26,7 @@ import QtQuick.Layouts 1.3
import QtQuick.Controls 2.0
import org.kde.kcm 1.3
import org.kde.kirigami 2.5 as Kirigami
import org.kde.kirigami 2.12 as Kirigami
import org.kde.plasma.private.volume 0.1
ScrollViewKCM {
......@@ -68,129 +68,127 @@ ScrollViewKCM {
contentWidth: column.width
contentHeight: column.height
clip: true
Item {
ColumnLayout {
id: column
width: flickable.width
ColumnLayout {
id: column
anchors.left: parent.left
anchors.leftMargin: Kirigami.Units.largeSpacing
anchors.right: parent.right
anchors.rightMargin: Kirigami.Units.largeSpacing
anchors.top: parent.top
Kirigami.ListSectionHeader {
Layout.fillWidth: true
visible: sinks.count > 0
text: i18nd("kcm_pulseaudio", "Playback Devices")
}
Header {
Layout.fillWidth: true
enabled: sinks.count > 0
text: i18nd("kcm_pulseaudio", "Playback Devices")
disabledText: i18ndc("kcm_pulseaudio", "@label", "No Playback Devices Available")
ListView {
id: sinks
Layout.fillWidth: true
Layout.leftMargin: Kirigami.Units.largeSpacing
Layout.rightMargin: Kirigami.Units.largeSpacing
Layout.preferredHeight: contentHeight
interactive: false
spacing: Kirigami.Units.gridUnit
model: inactiveDevicesButton.checked || !inactiveDevicesButton.visible ? paSinkModel : paSinkFilterModel
delegate: DeviceListItem {
isPlayback: true
}
}
ListView {
id: sinks
Layout.fillWidth: true
Layout.preferredHeight: contentHeight
interactive: false
spacing: Kirigami.Units.gridUnit
model: inactiveDevicesButton.checked || !inactiveDevicesButton.visible ? paSinkModel : paSinkFilterModel
delegate: DeviceListItem {
isPlayback: true
}
}
Kirigami.ListSectionHeader {
Layout.fillWidth: true
visible: sources.count > 0
text: i18nd("kcm_pulseaudio", "Recording Devices")
}
Header {
Layout.fillWidth: true
enabled: sources.count > 0
text: i18nd("kcm_pulseaudio", "Recording Devices")
disabledText: i18ndc("kcm_pulseaudio", "@label", "No Recording Devices Available")
ListView {
id: sources
Layout.fillWidth: true
Layout.leftMargin: Kirigami.Units.largeSpacing
Layout.rightMargin: Kirigami.Units.largeSpacing
Layout.preferredHeight: contentHeight
interactive: false
spacing: Kirigami.Units.gridUnit
model: inactiveDevicesButton.checked || !inactiveDevicesButton.visible ? paSourceModel : paSourceFilterModel
delegate: DeviceListItem {
isPlayback: false
}
}
ListView {
id: sources
Layout.fillWidth: true
Layout.preferredHeight: contentHeight
interactive: false
spacing: Kirigami.Units.gridUnit
model: inactiveDevicesButton.checked || !inactiveDevicesButton.visible ? paSourceModel : paSourceFilterModel
delegate: DeviceListItem {
isPlayback: false
}
}
Button {
id: inactiveDevicesButton
Layout.alignment: Qt.AlignHCenter
checkable: true
text: i18nd("kcm_pulseaudio", "Show Inactive Devices")
icon.name: "view-visible"
// Only show if there actually are any inactive devices
visible: (paSourceModel.count != paSourceFilterModel.count) || (paSinkModel.count != paSinkFilterModel.count)
}
Button {
id: inactiveDevicesButton
Layout.alignment: Qt.AlignHCenter
checkable: true
text: i18nd("kcm_pulseaudio", "Show Inactive Devices")
icon.name: "view-visible"
Kirigami.ListSectionHeader {
Layout.fillWidth: true
visible: eventStreamView.count || sinkInputView.count
text: i18nd("kcm_pulseaudio", "Playback Streams")
}
// Only show if there actually are any inactive devices
visible: (paSourceModel.count != paSourceFilterModel.count) || (paSinkModel.count != paSinkFilterModel.count)
ListView {
id: eventStreamView
Layout.fillWidth: true
Layout.leftMargin: Kirigami.Units.largeSpacing
Layout.rightMargin: Kirigami.Units.largeSpacing
Layout.preferredHeight: contentHeight
interactive: false
spacing: Kirigami.Units.largeSpacing
model: PulseObjectFilterModel {
filters: [ { role: "Name", value: "sink-input-by-media-role:event" } ]
sourceModel: StreamRestoreModel {}
}
Header {
Layout.fillWidth: true
enabled: eventStreamView.count || sinkInputView.count
text: i18nd("kcm_pulseaudio", "Playback Streams")
disabledText: i18ndc("kcm_pulseaudio", "@label", "No Applications Playing Audio")
delegate: StreamListItem {
deviceModel: paSinkModel
isPlayback: true
}
}
ListView {
id: eventStreamView
Layout.fillWidth: true
Layout.preferredHeight: contentHeight
interactive: false
spacing: Kirigami.Units.largeSpacing
model: PulseObjectFilterModel {
filters: [ { role: "Name", value: "sink-input-by-media-role:event" } ]
sourceModel: StreamRestoreModel {}
}
delegate: StreamListItem {
deviceModel: paSinkModel
isPlayback: true
}
ListView {
id: sinkInputView
Layout.fillWidth: true
Layout.leftMargin: Kirigami.Units.largeSpacing
Layout.rightMargin: Kirigami.Units.largeSpacing
Layout.preferredHeight: contentHeight
interactive: false
spacing: Kirigami.Units.largeSpacing
model: PulseObjectFilterModel {
filters: [ { role: "VirtualStream", value: false } ]
sourceModel: SinkInputModel {}
}
ListView {
id: sinkInputView
Layout.fillWidth: true
Layout.preferredHeight: contentHeight
interactive: false
spacing: Kirigami.Units.largeSpacing
model: PulseObjectFilterModel {
filters: [ { role: "VirtualStream", value: false } ]
sourceModel: SinkInputModel {}
}
delegate: StreamListItem {
deviceModel: paSinkModel
isPlayback: true
}
delegate: StreamListItem {
deviceModel: paSinkModel
isPlayback: true
}
}
Kirigami.ListSectionHeader {
Layout.fillWidth: true
visible: sourceOutputView.count > 0
text: i18nd("kcm_pulseaudio", "Recording Streams")
}
Header {
Layout.fillWidth: true
enabled: sourceOutputView.count > 0
text: i18nd("kcm_pulseaudio", "Recording Streams")
disabledText: i18ndc("kcm_pulseaudio", "@label", "No Applications Recording Audio")
ListView {
id: sourceOutputView
Layout.fillWidth: true
Layout.leftMargin: Kirigami.Units.largeSpacing
Layout.rightMargin: Kirigami.Units.largeSpacing
Layout.preferredHeight: contentHeight
interactive: false
spacing: Kirigami.Units.largeSpacing
model: PulseObjectFilterModel {
filters: [ { role: "VirtualStream", value: false } ]
sourceModel: SourceOutputModel {}
}
ListView {
id: sourceOutputView
Layout.fillWidth: true
Layout.preferredHeight: contentHeight
interactive: false
spacing: Kirigami.Units.largeSpacing
model: PulseObjectFilterModel {
filters: [ { role: "VirtualStream", value: false } ]
sourceModel: SourceOutputModel {}
}
delegate: StreamListItem {
deviceModel: sourceModel
isPlayback: false
}
delegate: StreamListItem {
deviceModel: sourceModel
isPlayback: false
}
}
}
......
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