shift-shell/components/mobileshell/qml/volumeosd/DeviceListItem.qml
Devin Lin 158af43fd4 audio: Refactor applet and extract singleton to MobileShellState
The eventual goal is to have as few singletons with state as possible in the mobileshell component when it is imported into components such as the lockscreen.

This doesn't fully accomplish it, but moves the audio provider singleton to MobileShellState, which will eventually need to be prevented from importing into non plasmashell processes.

This also disables the sound feedback when changing volume, since it can be a source of lag when showing the applet.
2023-03-16 07:21:01 +00:00

36 lines
1.1 KiB
QML

/*
SPDX-FileCopyrightText: 2014-2015 Harald Sitter <sitter@kde.org>
SPDX-FileCopyrightText: 2021 Devin Lin <espidev@gmail.com>
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
*/
import QtQuick 2.0
import org.kde.plasma.private.volume 0.1
// adapted from https://invent.kde.org/plasma/plasma-pa/-/blob/master/applet/contents/ui/DeviceListItem.qml
ListItemBase {
readonly property var currentPort: Ports[ActivePortIndex]
readonly property var currentActivePortIndex: ActivePortIndex
readonly property var currentMuted: Muted
readonly property var activePortIndex: ActivePortIndex
property bool onlyone: false
label: {
if (currentPort && currentPort.description) {
if (onlyone || !Description) {
return currentPort.description;
} else {
return i18nc("label of device items", "%1 (%2)", currentPort.description, Description);
}
}
if (Description) {
return Description;
}
if (Name) {
return Name;
}
return i18n("Device name not found");
}
}