File indexing completed on 2024-12-01 05:05:11
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 0009 #include "context.h" 0010 0011 #include <QIcon> 0012 0013 namespace QPulseAudio 0014 { 0015 PulseObject::PulseObject(QObject *parent) 0016 : QObject(parent) 0017 , m_index(0) 0018 { 0019 } 0020 0021 PulseObject::~PulseObject() = default; 0022 0023 Context *PulseObject::context() const 0024 { 0025 return Context::instance(); 0026 } 0027 0028 uint32_t PulseObject::index() const 0029 { 0030 return m_index; 0031 } 0032 0033 QString PulseObject::iconName() const 0034 { 0035 QString name = m_properties.value(QStringLiteral("device.icon_name")).toString(); 0036 if (!name.isEmpty() && QIcon::hasThemeIcon(name)) { 0037 return name; 0038 } 0039 0040 name = m_properties.value(QStringLiteral("media.icon_name")).toString(); 0041 if (!name.isEmpty() && QIcon::hasThemeIcon(name)) { 0042 return name; 0043 } 0044 0045 name = m_properties.value(QStringLiteral("window.icon_name")).toString(); 0046 if (!name.isEmpty() && QIcon::hasThemeIcon(name)) { 0047 return name; 0048 } 0049 0050 name = m_properties.value(QStringLiteral("application.icon_name")).toString(); 0051 if (!name.isEmpty() && QIcon::hasThemeIcon(name)) { 0052 return name; 0053 } 0054 0055 name = m_properties.value(QStringLiteral("application.process.binary")).toString(); 0056 if (!name.isEmpty() && QIcon::hasThemeIcon(name)) { 0057 return name; 0058 } 0059 0060 name = m_properties.value(QStringLiteral("application.name")).toString(); 0061 if (!name.isEmpty() && QIcon::hasThemeIcon(name)) { 0062 return name; 0063 } 0064 0065 name = m_properties.value(QStringLiteral("pipewire.access.portal.app_id")).toString(); 0066 if (!name.isEmpty() && QIcon::hasThemeIcon(name)) { 0067 return name; 0068 } 0069 0070 name = property("name").toString(); 0071 if (!name.isEmpty() && QIcon::hasThemeIcon(name)) { 0072 return name; 0073 } 0074 0075 return {}; 0076 } 0077 0078 QVariantMap PulseObject::properties() const 0079 { 0080 return m_properties; 0081 } 0082 0083 } // QPulseAudio