aerothemeplasma/plasma/plasmoids/io.gitgud.wackyideas.volume/contents/ui/DeviceListItem.qml
wackyideas 3475e7e667 Fork volume plasmoid
Big thanks to pswin for helping out
2025-01-31 03:02:13 +01:00

44 lines
1.1 KiB
QML

/*
SPDX-FileCopyrightText: 2014-2015 Harald Sitter <sitter@kde.org>
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
*/
import QtQuick
import org.kde.plasma.private.volume
ListItemBase {
readonly property var currentPort: model.Ports[model.ActivePortIndex]
readonly property bool muted: model.Muted
readonly property int activePortIndex: model.ActivePortIndex
name: {
// >1 entry -> use unique-ish names (e.g. 'Konqi Headset 5')
if (ListView.view.count > 1) {
return nodeName(model.PulseObject)
}
// 1 entry -> use the ambiguous port name (e.g. 'Microphone')
if (currentPort?.description) {
return currentPort.description
}
return nodeName(model.PulseObject)
}
onActivePortIndexChanged: {
if (type === "sink" && globalMute && !model.Muted) {
model.Muted = true;
}
}
onMutedChanged: {
if (type === "sink" && globalMute && !model.Muted) {
config.globalMute = false;
config.globalMuteDevices = [];
config.save();
}
}
}