Phonon

platform.cpp
1/* This file is part of the KDE project
2 Copyright (C) 2007 Matthias Kretz <kretz@kde.org>
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) version 3, or any
8 later version accepted by the membership of KDE e.V. (or its
9 successor approved by the membership of KDE e.V.), Nokia Corporation
10 (or its successors, if any) and the KDE Free Qt Foundation, which shall
11 act as a proxy defined in Section 6 of version 3 of the license.
12
13 This library is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Lesser General Public License for more details.
17
18 You should have received a copy of the GNU Lesser General Public
19 License along with this library. If not, see <http://www.gnu.org/licenses/>.
20
21*/
22
23#include "platform_p.h"
24#include "platformplugin.h"
25#include "factory_p.h"
26#include <QCoreApplication>
27#include <QUrl>
28#include <QIcon>
29#include <QStyle>
30#include <QApplication>
31
32namespace Phonon
33{
34
35void Platform::saveVolume(const QString &outputName, qreal volume)
36{
37#ifndef QT_NO_PHONON_PLATFORMPLUGIN
38 PlatformPlugin *f = Factory::platformPlugin();
39 if (f) {
40 f->saveVolume(outputName, volume);
41 }
42#else
43 Q_UNUSED(outputName);
44 Q_UNUSED(volume);
45#endif //QT_NO_PHONON_PLATFORMPLUGIN
46}
47
48qreal Platform::loadVolume(const QString &outputName)
49{
50#ifndef QT_NO_PHONON_PLATFORMPLUGIN
51 const PlatformPlugin *f = Factory::platformPlugin();
52 if (f) {
53 return f->loadVolume(outputName);
54 }
55#else
56 Q_UNUSED(outputName);
57#endif //QT_NO_PHONON_PLATFORMPLUGIN
58 return 1.0;
59}
60
61AbstractMediaStream *Platform::createMediaStream(const QUrl &url, QObject *parent)
62{
63#ifndef QT_NO_PHONON_PLATFORMPLUGIN
64 PlatformPlugin *f = Factory::platformPlugin();
65 if (f) {
66 return f->createMediaStream(url, parent);
67 }
68#else
69 Q_UNUSED(url);
70 Q_UNUSED(parent);
71#endif //QT_NO_PHONON_PLATFORMPLUGIN
72 return nullptr;
73}
74
75QIcon Platform::icon(const QString &name, QStyle *style)
76{
77 QIcon ret;
78#ifndef QT_NO_PHONON_PLATFORMPLUGIN
79 if (const PlatformPlugin *f = Factory::platformPlugin()) {
80 ret = f->icon(name);
81 }
82#endif //QT_NO_PHONON_PLATFORMPLUGIN
83
84 // No platform plugin present. Use internal versions.
85 if (ret.isNull()) {
86 if (!style) {
87 style = QApplication::style();
88 }
89 if (name == QLatin1String("player-volume")) {
91 } else if (name == QLatin1String("player-volume-muted")) {
93 }
94 }
95
96 // Still no icon set. Use QIcon to access the platform theme.
97 if (ret.isNull())
98 ret = QIcon::fromTheme(name);
99
100 // Now we are getting angry... keep dropping '-foo' parts from the end of
101 // the name until we get something usable or run out of substrings.
102 // (this is a simplified version of fallback lookup as done by KIconLoader;
103 // essentially audio-card-pci can also be provided by audio-card which is
104 // the more generic version).
105 QString choppedName = name;
106 while (ret.isNull() && !choppedName.isEmpty()) {
107 choppedName.resize(choppedName.lastIndexOf(QChar('-')));
108 ret = QIcon::fromTheme(choppedName);
109 }
110
111 return ret;
112}
113
114void Platform::notification(const char *notificationName, const QString &text,
115 const QStringList &actions, QObject *receiver,
116 const char *actionSlot)
117{
118#ifndef QT_NO_PHONON_PLATFORMPLUGIN
119 const PlatformPlugin *f = Factory::platformPlugin();
120 if (f) {
121 f->notification(notificationName, text, actions, receiver, actionSlot);
122 }
123#else
124 Q_UNUSED(notificationName);
125 Q_UNUSED(text);
126 Q_UNUSED(actions);
127 Q_UNUSED(receiver);
128 Q_UNUSED(actionSlot);
129#endif //QT_NO_PHONON_PLATFORMPLUGIN
130}
131
132QString Platform::applicationName()
133{
134#ifndef QT_NO_PHONON_PLATFORMPLUGIN
135 const PlatformPlugin *f = Factory::platformPlugin();
136 if (f) {
137 return f->applicationName();
138 }
139#endif //QT_NO_PHONON_PLATFORMPLUGIN
141 if (ret.isEmpty())
143 return ret;
144}
145
146QList<QPair<QByteArray, QString> > Platform::deviceAccessListFor(const Phonon::AudioOutputDevice &deviceDesc)
147{
148#ifndef QT_NO_PHONON_PLATFORMPLUGIN
149 const PlatformPlugin *f = Factory::platformPlugin();
150 if (f) {
151 return f->deviceAccessListFor(deviceDesc);
152 }
153#endif //QT_NO_PHONON_PLATFORMPLUGIN
155}
156
157} // namespace Phonon
Provides a tuple of enduser visible name and description.
QString name(GameStandardAction id)
QStyle * style()
QString applicationFilePath()
QIcon fromTheme(const QString &name)
bool isNull() const const
bool isEmpty() const const
qsizetype lastIndexOf(QChar ch, Qt::CaseSensitivity cs) const const
void resize(qsizetype newSize, QChar fillChar)
virtual QPixmap standardPixmap(StandardPixmap standardPixmap, const QStyleOption *option, const QWidget *widget) const const=0
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 29 2024 11:46:30 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.