diff --git a/CMakeLists.txt b/CMakeLists.txt index 62912f6..becca1a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,96 +1,92 @@ cmake_minimum_required(VERSION 3.0) set(KF5_VERSION "5.45.0") # handled by release scripts project(PulseAudioQt VERSION ${KF5_VERSION}) include(FeatureSummary) find_package(ECM 5.44.0 NO_MODULE) set_package_properties(ECM PROPERTIES TYPE REQUIRED DESCRIPTION "Extra CMake Modules." URL "https://projects.kde.org/projects/kdesupport/extra-cmake-modules") feature_summary(WHAT REQUIRED_PACKAGES_NOT_FOUND FATAL_ON_MISSING_REQUIRED_PACKAGES) set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/cmake) include(GenerateExportHeader) include(CMakePackageConfigHelpers) include(ECMSetupVersion) include(ECMGenerateHeaders) include(ECMQtDeclareLoggingCategory) include(ECMAddQch) include(KDEInstallDirs) include(KDECompilerSettings NO_POLICY_SCOPE) # include(KDEFrameworkCompilerSettings NO_POLICY_SCOPE) include(KDECMakeSettings) option(BUILD_QCH "Build API documentation in QCH format (for e.g. Qt Assistant, Qt Creator & KDevelop)" OFF) add_feature_info(QCH ${BUILD_QCH} "API documentation in QCH format (for e.g. Qt Assistant, Qt Creator & KDevelop)") ecm_setup_version(PROJECT VARIABLE_PREFIX PULSEAUDIOQT VERSION_HEADER "${CMAKE_CURRENT_BINARY_DIR}/pulseaudioqt_version.h" PACKAGE_VERSION_FILE "${CMAKE_CURRENT_BINARY_DIR}/KF5PulseAudioQtConfigVersion.cmake" SOVERSION 1) set(REQUIRED_QT_VERSION 5.7.0) find_package(Qt5 ${REQUIRED_QT_VERSION} CONFIG REQUIRED Core Gui DBus) find_package(Qt5Test ${REQUIRED_QT_VERSION} CONFIG) set_package_properties(Qt5Test PROPERTIES DESCRIPTION "Autotests for PulseAudioQt" TYPE OPTIONAL) # create a Config.cmake and a ConfigVersion.cmake file and install them set(CMAKECONFIG_INSTALL_DIR "${KDE_INSTALL_CMAKEPACKAGEDIR}/KF5PulseAudioQt") if (BUILD_QCH) ecm_install_qch_export( TARGETS KF5PulseAudioQt_QCH FILE KF5PulseAudioQtTargets.cmake DESTINATION "${CMAKECONFIG_INSTALL_DIR}" COMPONENT Devel ) set(PACKAGE_INCLUDE_QCHTARGETS "include(\"\${CMAKE_CURRENT_LIST_DIR}/KF5PulseAudioQtQchTargets.cmake\")") endif() install(FILES "${CMAKE_CURRENT_BINARY_DIR}/KF5PulseAudioQtConfig.cmake" "${CMAKE_CURRENT_BINARY_DIR}/KF5PulseAudioQtConfigVersion.cmake" DESTINATION "${CMAKECONFIG_INSTALL_DIR}" COMPONENT Devel ) configure_package_config_file( "${CMAKE_CURRENT_SOURCE_DIR}/KF5PulseAudioQtConfig.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/KF5PulseAudioQtConfig.cmake" INSTALL_DESTINATION ${CMAKECONFIG_INSTALL_DIR} ) - -include(FindPkgConfig) -pkg_check_modules(GCONF REQUIRED gconf-2.0) -pkg_check_modules(GOBJECT REQUIRED gobject-2.0) find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS CoreAddons DocTools I18n ) find_package(PulseAudio 5.0.0 REQUIRED) find_package(Canberra REQUIRED) find_package(GLIB2 REQUIRED) if (IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/po") ecm_install_po_files_as_qm(po) endif() add_subdirectory(src) if (BUILD_TESTING) # add_subdirectory(tests) if(Qt5Test_FOUND) add_subdirectory(autotests) endif() endif() install(EXPORT KF5PulseAudioQtTargets DESTINATION "${CMAKECONFIG_INSTALL_DIR}" FILE KF5PulseAudioQtTargets.cmake NAMESPACE KF5:: ) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/pulseaudioqt_version.h DESTINATION ${KDE_INSTALL_INCLUDEDIR_KF5} COMPONENT Devel ) feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f3d52d7..f3694ea 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,80 +1,74 @@ -include_directories(${PULSEAUDIO_INCLUDE_DIR} ${GLIB2_INCLUDE_DIR} ${GCONF_INCLUDE_DIRS} - ${GOBJECT_INCLUDE_DIRS}) +include_directories(${PULSEAUDIO_INCLUDE_DIR} ${GLIB2_INCLUDE_DIR}) set(cpp_SRCS card.cpp client.cpp context.cpp device.cpp maps.cpp maps_dptr.cpp operation.cpp port.cpp profile.cpp pulseaudio.cpp pulseobject.cpp sink.cpp sinkinput.cpp - modulemanager.cpp - gconfitem.cpp source.cpp sourceoutput.cpp stream.cpp volumeobject.cpp debug.cpp server.cpp streamrestore.cpp module.cpp ) add_library(KF5PulseAudioQt SHARED ${cpp_SRCS}) target_link_libraries(KF5PulseAudioQt PUBLIC Qt5::Core PRIVATE Qt5::Gui Qt5::DBus ${PULSEAUDIO_LIBRARY} ${PULSEAUDIO_MAINLOOP_LIBRARY} - ${GCONF_LDFLAGS} - ${GOBJECT_LDFLAGS} ${CANBERRA_LIBRARIES} ) target_include_directories(KF5PulseAudioQt INTERFACE "$" ) set_target_properties(KF5PulseAudioQt PROPERTIES VERSION ${PULSEAUDIOQT_VERSION_STRING} SOVERSION ${PULSEAUDIOQT_SOVERSION} EXPORT_NAME PulseAudioQt ) ecm_generate_headers(PulseAudioQt_HEADERS HEADER_NAMES Card Client Context Device Module - ModuleManager Port Profile PulseAudio PulseObject Server Sink SinkInput Source SourceOutput StreamRestore VolumeObject REQUIRED_HEADERS PulseAudioQt_HEADERS ) generate_export_header(KF5PulseAudioQt BASE_NAME KF5PulseAudioQt) install(TARGETS KF5PulseAudioQt EXPORT KF5PulseAudioQtTargets ${KF5_INSTALL_TARGETS_DEFAULT_ARGS}) install(FILES ${PulseAudioQt_HEADERS} ${CMAKE_CURRENT_BINARY_DIR}/kf5pulseaudioqt_export.h DESTINATION ${KDE_INSTALL_INCLUDEDIR_KF5}/KF5PulseAudioQt/PulseAudioQt COMPONENT Devel ) diff --git a/src/gconfitem.cpp b/src/gconfitem.cpp deleted file mode 100644 index bbb06ce..0000000 --- a/src/gconfitem.cpp +++ /dev/null @@ -1,335 +0,0 @@ -/* - * Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). - * All rights reserved. - * Copyright (C) 2016 David Edmundson - * - * Contact: Marius Vollmer - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * version 2.1 as published by the Free Software Foundation. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA - * - */ - -#include -#include -#include -#include -#include - -#include "gconfitem.h" - -#include -#include -#include - -struct GConfItemPrivate -{ - QString root; - QVariant value; - guint notify_id; - - static void notify_trampoline(GConfClient*, guint, GConfEntry *, gpointer); -}; - -#define withClient(c) for(GConfClient *c = (gconf_client_get_default()); c; g_object_unref(c), c=NULL) - -static QByteArray convertKey(QString key) -{ - if (key.startsWith('/')) { - return key.toUtf8(); - } else { - qWarning() << "Using dot-separated key names with GConfItem is deprecated."; - qWarning() << "Please use" << '/' + key.replace('.', '/') << "instead of" << key; - return '/' + key.replace('.', '/').toUtf8(); - } -} - -static QString convertKey(const char *key) -{ - return QString::fromUtf8(key); -} - -static QVariant convertValue(GConfValue *src) -{ - if (!src) { - return QVariant(); - } else { - switch (src->type) { - case GCONF_VALUE_INVALID: - return QVariant(QVariant::Invalid); - case GCONF_VALUE_BOOL: - return QVariant((bool)gconf_value_get_bool(src)); - case GCONF_VALUE_INT: - return QVariant(gconf_value_get_int(src)); - case GCONF_VALUE_FLOAT: - return QVariant(gconf_value_get_float(src)); - case GCONF_VALUE_STRING: - return QVariant(QString::fromUtf8(gconf_value_get_string(src))); - case GCONF_VALUE_LIST: - switch (gconf_value_get_list_type(src)) { - case GCONF_VALUE_STRING: - { - QStringList result; - for (GSList *elts = gconf_value_get_list(src); elts; elts = elts->next) - result.append(QString::fromUtf8(gconf_value_get_string((GConfValue *)elts->data))); - return QVariant(result); - } - default: - { - QList result; - for (GSList *elts = gconf_value_get_list(src); elts; elts = elts->next) - result.append(convertValue((GConfValue *)elts->data)); - return QVariant(result); - } - } - case GCONF_VALUE_SCHEMA: - default: - return QVariant(); - } - } -} - -static GConfValue *convertString(const QString &str) -{ - GConfValue *v = gconf_value_new (GCONF_VALUE_STRING); - gconf_value_set_string (v, str.toUtf8().data()); - return v; -} - -static GConfValueType primitiveType (const QVariant &elt) -{ - switch(elt.type()) { - case QVariant::String: - return GCONF_VALUE_STRING; - case QVariant::Int: - return GCONF_VALUE_INT; - case QVariant::Double: - return GCONF_VALUE_FLOAT; - case QVariant::Bool: - return GCONF_VALUE_BOOL; - default: - return GCONF_VALUE_INVALID; - } -} - -static GConfValueType uniformType(const QList &list) -{ - GConfValueType result = GCONF_VALUE_INVALID; - - Q_FOREACH (const QVariant &elt, list) { - GConfValueType elt_type = primitiveType (elt); - - if (elt_type == GCONF_VALUE_INVALID) - return GCONF_VALUE_INVALID; - - if (result == GCONF_VALUE_INVALID) - result = elt_type; - else if (result != elt_type) - return GCONF_VALUE_INVALID; - } - - if (result == GCONF_VALUE_INVALID) - return GCONF_VALUE_STRING; // empty list. - else - return result; -} - -static int convertValue(const QVariant &src, GConfValue **valp) -{ - GConfValue *v; - - switch(src.type()) { - case QVariant::Invalid: - v = NULL; - break; - case QVariant::Bool: - v = gconf_value_new (GCONF_VALUE_BOOL); - gconf_value_set_bool (v, src.toBool()); - break; - case QVariant::Int: - v = gconf_value_new (GCONF_VALUE_INT); - gconf_value_set_int (v, src.toInt()); - break; - case QVariant::Double: - v = gconf_value_new (GCONF_VALUE_FLOAT); - gconf_value_set_float (v, src.toDouble()); - break; - case QVariant::String: - v = convertString(src.toString()); - break; - case QVariant::StringList: - { - GSList *elts = NULL; - v = gconf_value_new(GCONF_VALUE_LIST); - gconf_value_set_list_type(v, GCONF_VALUE_STRING); - Q_FOREACH (const QString &str, src.toStringList()) - elts = g_slist_prepend(elts, convertString(str)); - gconf_value_set_list_nocopy(v, g_slist_reverse(elts)); - break; - } - case QVariant::List: - { - GConfValueType elt_type = uniformType(src.toList()); - if (elt_type == GCONF_VALUE_INVALID) - v = NULL; - else - { - GSList *elts = NULL; - v = gconf_value_new(GCONF_VALUE_LIST); - gconf_value_set_list_type(v, elt_type); - Q_FOREACH (const QVariant &elt, src.toList()) - { - GConfValue *val = NULL; - convertValue(elt, &val); // guaranteed to succeed. - elts = g_slist_prepend(elts, val); - } - gconf_value_set_list_nocopy(v, g_slist_reverse(elts)); - } - break; - } - default: - return 0; - } - - *valp = v; - return 1; -} - -void GConfItemPrivate::notify_trampoline (GConfClient*, - guint, - GConfEntry *entry, - gpointer data) -{ - GConfItem *item = (GConfItem *)data; - - item->update_value (true, entry->key, convertValue(entry->value)); -} - -void GConfItem::update_value (bool emit_signal, const QString& key, const QVariant& value) -{ - QVariant new_value; - - if (emit_signal) { - subtreeChanged(key, value); - } -} - -QString GConfItem::root() const -{ - return priv->root; -} - -QVariant GConfItem::value(const QString &subKey) const -{ - QVariant new_value; - withClient(client) { - GError *error = NULL; - QByteArray k = convertKey(priv->root + '/' + subKey); - GConfValue *v = gconf_client_get(client, k.data(), &error); - - if (error) { - qWarning() << error->message; - g_error_free (error); - new_value = QVariant(); - } else { - new_value = convertValue(v); - if (v) - gconf_value_free(v); - } - } - return new_value; -} - -void GConfItem::set(const QString &subKey, const QVariant &val) -{ - withClient(client) { - QByteArray k = convertKey(priv->root + '/' + subKey); - GConfValue *v; - if (convertValue(val, &v)) { - GError *error = NULL; - - if (v) { - gconf_client_set(client, k.data(), v, &error); - gconf_value_free(v); - } else { - gconf_client_unset(client, k.data(), &error); - } - - if (error) { - qWarning() << error->message; - g_error_free(error); - } - } else { - qWarning() << "Can't store a" << val.typeName(); - } - } -} - -QList GConfItem::listDirs() const -{ - QList children; - - withClient(client) { - QByteArray k = convertKey(priv->root); - GSList *dirs = gconf_client_all_dirs(client, k.data(), NULL); - for (GSList *d = dirs; d; d = d->next) { - children.append(convertKey((char *)d->data)); - g_free (d->data); - } - g_slist_free (dirs); - } - - return children; -} - -QList GConfItem::listEntries() const -{ - QList children; - - withClient(client) { - QByteArray k = convertKey(priv->root); - GSList *entries = gconf_client_all_entries(client, k.data(), NULL); - for (GSList *e = entries; e; e = e->next) { - children.append(convertKey(((GConfEntry *)e->data)->key)); - gconf_entry_free ((GConfEntry *)e->data); - } - g_slist_free (entries); - } - - return children; -} - -GConfItem::GConfItem(const QString &key, QObject *parent) - : QObject (parent), - priv(new GConfItemPrivate) -{ - priv->root = key; - withClient(client) { - QByteArray k = convertKey(priv->root); - gconf_client_add_dir (client, k.data(), GCONF_CLIENT_PRELOAD_ONELEVEL, NULL); - priv->notify_id = gconf_client_notify_add (client, k.data(), - GConfItemPrivate::notify_trampoline, this, - NULL, NULL); - } -} - -GConfItem::~GConfItem() -{ - withClient(client) { - QByteArray k = convertKey(priv->root); - gconf_client_notify_remove (client, priv->notify_id); - gconf_client_remove_dir (client, k.data(), NULL); - } - delete priv; -} diff --git a/src/gconfitem.h b/src/gconfitem.h deleted file mode 100644 index 1685a6a..0000000 --- a/src/gconfitem.h +++ /dev/null @@ -1,134 +0,0 @@ -/* - * Copyright (C) 2009 Nokia Corporation. - * Copyright (C) 2016 David Edmundson - * - * Contact: Marius Vollmer - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * version 2.1 as published by the Free Software Foundation. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA - * - */ - -#ifndef GCONFITEM_H -#define GCONFITEM_H - -#include -#include -#include - -/*! - - \brief GConfItem is a simple C++ wrapper for GConf. - - Creating a GConfItem instance gives you access to a single GConf - key. You can get and set its value, and connect to its - valueChanged() signal to be notified about changes. - - The value of a GConf key is returned to you as a QVariant, and you - pass in a QVariant when setting the value. GConfItem converts - between a QVariant and GConf values as needed, and according to the - following rules: - - - A QVariant of type QVariant::Invalid denotes an unset GConf key. - - - QVariant::Int, QVariant::Double, QVariant::Bool are converted to - and from the obvious equivalents. - - - QVariant::String is converted to/from a GConf string and always - uses the UTF-8 encoding. No other encoding is supported. - - - QVariant::StringList is converted to a list of UTF-8 strings. - - - QVariant::List (which denotes a QList) is converted - to/from a GConf list. All elements of such a list must have the - same type, and that type must be one of QVariant::Int, - QVariant::Double, QVariant::Bool, or QVariant::String. (A list of - strings is returned as a QVariant::StringList, however, when you - get it back.) - - - Any other QVariant or GConf value is essentially ignored. - - - This is fored by Dave from libqtgconf to really reduce the amount of QObjects needed - to manipulate various items in a tree. - - - \warning GConfItem is as thread-safe as GConf. - -*/ - - -class GConfItem : public QObject -{ - Q_OBJECT - - public: - /*! Initializes a GConfItem to access the GConf key denoted by - \a key. Key names should follow the normal GConf conventions - like "/myapp/settings/first". - - \param key The name of the key. - \param parent Parent object - */ - explicit GConfItem(const QString &keyRoot, QObject *parent = 0); - - /*! Finalizes a GConfItem. - */ - virtual ~GConfItem(); - - /*! Returns the root of this item, as given to the constructor. - */ - QString root() const; - - /*! Returns the current value of this item, as a QVariant. - * subkey is realtive to the provided root. - */ - QVariant value(const QString &subKey) const; - - /*! Returns the current value of this item, as a QVariant. If - * there is no value for this item, return \a def instead. - - */ - void set(const QString &subKey, const QVariant &val); - - /*! Return a list of the directories below this item. The - returned strings are absolute key names like - "/myapp/settings". - - A directory is a key that has children. The same key might - also have a value, but that is confusing and best avoided. - */ - QList listDirs() const; - - /*! Return a list of entries below this item. The returned - strings are absolute key names like "/myapp/settings/first". - - A entry is a key that has a value. The same key might also - have children, but that is confusing and is best avoided. - */ - QList listEntries() const; - - Q_SIGNALS: - /*! Emitted when some value in subtree of this item changes - */ - - void subtreeChanged(const QString& key, const QVariant& value); - - private: - friend struct GConfItemPrivate; - struct GConfItemPrivate *priv; - - void update_value(bool emit_signal, const QString& key, const QVariant& value); -}; - -#endif // GCONFITEM_H diff --git a/src/modulemanager.cpp b/src/modulemanager.cpp deleted file mode 100644 index 84a7c92..0000000 --- a/src/modulemanager.cpp +++ /dev/null @@ -1,139 +0,0 @@ -/* - Copyright 2016 David Edmundson - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - - -#include "modulemanager.h" -#include "module.h" -#include "context_p.h" - -#define PA_GCONF_ROOT "/system/pulseaudio" -#define PA_GCONF_PATH_MODULES PA_GCONF_ROOT"/modules" - -#include "gconfitem.h" - -#include - -namespace PulseAudioQt -{ - -class GConfModule : public GConfItem -{ - Q_OBJECT -public: - GConfModule(const QString &configName, const QString &moduleName, QObject *parent); - bool isEnabled() const; - void setEnabled(bool enabled, const QVariant &args=QVariant()); -private: - QString m_moduleName; -}; - -GConfModule::GConfModule(const QString &configName, const QString &moduleName, QObject *parent) : - GConfItem(QStringLiteral(PA_GCONF_PATH_MODULES"/") + configName, parent), - m_moduleName(moduleName) -{ -} - -bool GConfModule::isEnabled() const -{ - return value(QStringLiteral("enabled")).toBool(); -} - -void GConfModule::setEnabled(bool enabled, const QVariant &args) -{ - set(QStringLiteral("locked"), true); - - if (enabled) { - set(QStringLiteral("name0"), m_moduleName); - set(QStringLiteral("args0"), args); - set(QStringLiteral("enabled"), true); - } else { - set(QStringLiteral("enabled"), false); - } - set(QStringLiteral("locked"), false); -} - - -ModuleManager::ModuleManager(QObject *parent) : - QObject(parent), - m_combineSinks(new GConfModule(QStringLiteral("combine"), QStringLiteral("module-combine"), this)), - m_switchOnConnect(new GConfModule(QStringLiteral("switch-on-connect"), QStringLiteral("module-switch-on-connect"), this)), - m_deviceManager(new GConfModule(QStringLiteral("device-manager"), QStringLiteral("module-device-manager"), this)) -{ - connect(m_combineSinks, &GConfItem::subtreeChanged, this, &ModuleManager::combineSinksChanged); - connect(m_switchOnConnect, &GConfItem::subtreeChanged, this, &ModuleManager::switchOnConnectChanged); - connect(m_deviceManager, &GConfItem::subtreeChanged, this, &ModuleManager::switchOnConnectChanged); - - QTimer *updateModulesTimer = new QTimer(this); - updateModulesTimer->setInterval(500); - updateModulesTimer->setSingleShot(true); - connect(updateModulesTimer, &QTimer::timeout, this, &ModuleManager::updateLoadedModules); - connect(&Context::instance()->d->m_modules, &MapBaseQObject::added, updateModulesTimer, static_cast(&QTimer::start)); - connect(&Context::instance()->d->m_modules, &MapBaseQObject::removed, updateModulesTimer, static_cast(&QTimer::start)); - updateLoadedModules(); -} - -ModuleManager::~ModuleManager() -{ -}; - -bool ModuleManager::combineSinks() const -{ - return m_combineSinks->isEnabled(); -} - -void ModuleManager::setCombineSinks(bool combineSinks) -{ - m_combineSinks->setEnabled(combineSinks); -} - -bool ModuleManager::switchOnConnect() const -{ - //switch on connect and device-manager do the same task. Only one should be enabled - - //Note on the first run m_deviceManager will appear to be disabled even though it's actually running - //because there is no gconf entry, however m_switchOnConnect will only exist if set by Plasma PA - //hence only check this entry - return m_switchOnConnect->isEnabled() ; -} - -void ModuleManager::setSwitchOnConnect(bool switchOnConnect) -{ - m_deviceManager->setEnabled(!switchOnConnect); - m_switchOnConnect->setEnabled(switchOnConnect); -} - -QStringList ModuleManager::loadedModules() const -{ - return m_loadedModules; -} - -void ModuleManager::updateLoadedModules() -{ - m_loadedModules.clear(); - const auto modules = Context::instance()->d->m_modules.data(); - for (Module *module : modules) { - m_loadedModules.append(module->name()); - } - Q_EMIT loadedModulesChanged(); -} - -} // namespace PulseAudioQt - -#include "modulemanager.moc" diff --git a/src/modulemanager.h b/src/modulemanager.h deleted file mode 100644 index 1af0419..0000000 --- a/src/modulemanager.h +++ /dev/null @@ -1,70 +0,0 @@ -/* - Copyright 2016 David Edmundson - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#ifndef MODULEMANAGER_H -#define MODULEMANAGER_H - -#include - -#include -#include "kf5pulseaudioqt_export.h" - -#include "context.h" -// Properties need fully qualified classes even with pointers. -#include "client.h" - -class GConfItem; - -namespace PulseAudioQt -{ -class GConfModule; - -class KF5PULSEAUDIOQT_EXPORT ModuleManager : public QObject -{ - Q_OBJECT - Q_PROPERTY(bool combineSinks READ combineSinks WRITE setCombineSinks NOTIFY combineSinksChanged) - Q_PROPERTY(bool switchOnConnect READ switchOnConnect WRITE setSwitchOnConnect NOTIFY switchOnConnectChanged) - Q_PROPERTY(QStringList loadedModules READ loadedModules NOTIFY loadedModulesChanged) -public: - ModuleManager(QObject *parent = nullptr); - ~ModuleManager(); - bool combineSinks() const; - void setCombineSinks(bool combineSinks); - bool switchOnConnect() const; - void setSwitchOnConnect(bool switchOnConnect); - QStringList loadedModules() const; - -Q_SIGNALS: - void combineSinksChanged(); - void switchOnConnectChanged(); - void loadedModulesChanged(); - -private: - void updateLoadedModules(); - - GConfModule *m_combineSinks; - GConfModule *m_switchOnConnect; - GConfModule *m_deviceManager; - QStringList m_loadedModules; -}; - -} // PulseAudioQt - -#endif // STREAM_H