Commit 6940b080 authored by Antonio Larrosa Jimenez's avatar Antonio Larrosa Jimenez Committed by David Rosca

Show headset icons for devices identifying as "Headset" in Description

A Logitech H600 / H800 headset was showing an "unknown" icon for the player device.

These devices use the following identifiers:

The sink/player device:
currentPort.name: analog-output
currentPort.description: Analog Output H600
Description: [Wireless Headset] Analog Stereo

The source/capture device:
currentPort.name: analog-input-mic
currentPort.description: Microphone H600
Description: [Wireless Headset] Analog Mono

Differential Revision: https://phabricator.kde.org/D8054
parent f5a5fd9f
......@@ -26,18 +26,30 @@ ListItemBase {
draggable: false
label: currentPort ? i18nc("label of device items", "%1 (%2)", currentPort.description, Description) : Description
icon: {
if (currentPort) {
if (currentPort.name.indexOf("speaker") != -1) {
switch(FormFactor) {
case "internal":
return "audio-card";
case "speaker":
return "audio-speakers-symbolic";
} else if (currentPort.name.indexOf("headphones") != -1) {
return "audio-headphones";
} else if (currentPort.name.indexOf("hdmi") != -1) {
case "handset":
return "phone";
case "tv":
return "video-television";
} else if (currentPort.name.indexOf("mic") != -1) {
case "webcam":
return "camera-web";
case "microphone":
return "audio-input-microphone";
} else if (currentPort.name.indexOf("phone") != -1) {
return "phone";
}
case "headset":
return "audio-headset";
case "headphone":
return "audio-headphones";
/* There are some form factors which we don't have any icon for, so we ignore them for now */
// case "hands-free": break;
// case "car": break;
// case "hifi": break;
case "computer":
return "computer"; break;
// case "portable": break;
}
return IconName;
}
......
......@@ -35,6 +35,11 @@ QString QPulseAudio::Device::description() const
return m_description;
}
QString QPulseAudio::Device::formFactor() const
{
return m_formFactor;
}
quint32 QPulseAudio::Device::cardIndex() const
{
return m_cardIndex;
......
......@@ -38,6 +38,7 @@ class Device : public VolumeObject
Q_PROPERTY(State state READ state NOTIFY stateChanged)
Q_PROPERTY(QString name READ name NOTIFY nameChanged)
Q_PROPERTY(QString description READ description NOTIFY descriptionChanged)
Q_PROPERTY(QString formFactor READ formFactor NOTIFY formFactorChanged)
Q_PROPERTY(quint32 cardIndex READ cardIndex NOTIFY cardIndexChanged)
Q_PROPERTY(QList<QObject *> ports READ ports NOTIFY portsChanged)
Q_PROPERTY(quint32 activePortIndex READ activePortIndex WRITE setActivePortIndex NOTIFY activePortIndexChanged)
......@@ -67,6 +68,14 @@ public:
m_description = info->description;
emit descriptionChanged();
}
const char *form_factor = pa_proplist_gets(info->proplist, PA_PROP_DEVICE_FORM_FACTOR);
if (form_factor) {
QString formFactor = QString::fromUtf8(form_factor);
if (m_formFactor != formFactor) {
m_formFactor = formFactor;
emit formFactorChanged();
}
}
m_cardIndex = info->card;
emit cardIndexChanged();
......@@ -98,6 +107,7 @@ public:
State state() const;
QString name() const;
QString description() const;
QString formFactor() const;
quint32 cardIndex() const;
QList<QObject *> ports() const;
quint32 activePortIndex() const;
......@@ -109,6 +119,7 @@ signals:
void stateChanged();
void nameChanged();
void descriptionChanged();
void formFactorChanged();
void cardIndexChanged();
void portsChanged();
void activePortIndexChanged();
......@@ -122,6 +133,7 @@ private:
QString m_name;
QString m_description;
QString m_formFactor;
quint32 m_cardIndex = -1;
QList<QObject *> m_ports;
quint32 m_activePortIndex = -1;
......
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