File indexing completed on 2024-07-14 15:04:33

0001 /*
0002     SPDX-FileCopyrightText: 2014-2015 Harald Sitter <sitter@kde.org>
0003 
0004     SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0005 */
0006 
0007 #include "pulseobject.h"
0008 #include "pulseobject_p.h"
0009 
0010 #include "context.h"
0011 
0012 #include <QIcon>
0013 
0014 namespace PulseAudioQt
0015 {
0016 PulseObject::PulseObject(QObject *parent)
0017     : QObject(parent)
0018     , d(new PulseObjectPrivate(this))
0019 {
0020 }
0021 
0022 PulseObject::~PulseObject()
0023 {
0024     delete d;
0025 }
0026 
0027 PulseObjectPrivate::PulseObjectPrivate(PulseObject *q)
0028     : q(q)
0029 {
0030 }
0031 
0032 PulseObjectPrivate::~PulseObjectPrivate()
0033 {
0034 }
0035 
0036 QString PulseObject::name() const
0037 {
0038     return d->m_name;
0039 }
0040 
0041 QString PulseObject::iconName() const
0042 {
0043     QString name = d->m_properties.value(QStringLiteral("device.icon_name")).toString();
0044     if (!name.isEmpty() && QIcon::hasThemeIcon(name)) {
0045         return name;
0046     }
0047 
0048     name = d->m_properties.value(QStringLiteral("media.icon_name")).toString();
0049     if (!name.isEmpty() && QIcon::hasThemeIcon(name)) {
0050         return name;
0051     }
0052 
0053     name = d->m_properties.value(QStringLiteral("window.icon_name")).toString();
0054     if (!name.isEmpty() && QIcon::hasThemeIcon(name)) {
0055         return name;
0056     }
0057 
0058     name = d->m_properties.value(QStringLiteral("application.icon_name")).toString();
0059     if (!name.isEmpty() && QIcon::hasThemeIcon(name)) {
0060         return name;
0061     }
0062 
0063     name = d->m_properties.value(QStringLiteral("application.process.binary")).toString();
0064     if (!name.isEmpty() && QIcon::hasThemeIcon(name)) {
0065         return name;
0066     }
0067 
0068     name = d->m_properties.value(QStringLiteral("application.name")).toString();
0069     if (!name.isEmpty() && QIcon::hasThemeIcon(name)) {
0070         return name;
0071     }
0072 
0073     name = property("name").toString();
0074     if (!name.isEmpty() && QIcon::hasThemeIcon(name)) {
0075         return name;
0076     }
0077 
0078     return QString();
0079 }
0080 
0081 QVariantMap PulseObject::properties() const
0082 {
0083     return d->m_properties;
0084 }
0085 
0086 } // PulseAudioQt