[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdebase/runtime/phonon/kcm
From:       Colin Guthrie <kde () colin ! guthr ! ie>
Date:       2010-07-26 8:34:32
Message-ID: 20100726083432.86A8FAC86A () svn ! kde ! org
[Download RAW message or body]

SVN commit 1154776 by cguthrie:

phonon: Add a GUI to configure and control the sound setup.

This GUI is only available if PulseAudio is used, but it allows you to
configure Stereo vs. 5.1 Surround vs. Digital/IEC958 configuration
of your hardware.

The GUI also is able to send test sounds to your speakers.
It uses libcanberra for this (which is a pretty common counterpart
to a PulseAudio system). The sounds used are part of the Free Desktop
sound theme (i.e. the fallback sound theme - the hicolor of sounds).

This commit should work fine when PulseAudio development headers are not
installed and should work fine at runtime when PulseAudio is not in use
(i.e. it fails gracefully). The tab itself is not presented when
either of those two conditions are met.

See http://colin.guthr.ie/2010/07/speaker-setup-now-or-forever-hold-your-peace/

 M  +21 -2     CMakeLists.txt  
 M  +27 -4     main.cpp  
 M  +14 -0     main.h  
 AM            speakersetup.cpp   [License: GPL (v2)]
 AM            speakersetup.h   [License: GPL (v2)]
 A             speakersetup.ui  
 AM            testspeakerwidget.cpp   [License: GPL (v2)]
 AM            testspeakerwidget.h   [License: GPL (v2)]


--- trunk/KDE/kdebase/runtime/phonon/kcm/CMakeLists.txt #1154775:1154776
@@ -1,3 +1,11 @@
+set(PULSEAUDIO_MINIMUM_VERSION "0.9.16")
+macro_optional_find_package(PulseAudio)
+macro_log_feature(PULSEAUDIO_FOUND "PulseAudio" "PulseAudio Audio Server" \
"http://www.pulseaudio.org/" FALSE "0.9.16" "libpulse is needed for speaker setup \
GUI") +find_package(GLIB2)
+
+pkg_check_modules(CANBERRA libcanberra)
+macro_log_feature(CANBERRA_FOUND "libcanberra" "libcanberra audio library" \
"http://0pointer.de/lennart/projects/libcanberra/" FALSE "" "libcanberra is needed \
for speaker setup GUI") +
 add_subdirectory(xine)
 
 set(kcmphonon_SRCS main.cpp devicepreference.cpp backendselection.cpp)
@@ -2,6 +10,17 @@
 kde4_add_ui_files(kcmphonon_SRCS devicepreference.ui backendselection.ui)
+set(kcmphonon_LIBS ${KDE4_PHONON_LIBS} ${KDE4_KCMUTILS_LIBS} ${KDE4_KIO_LIBS})
 
+if(GLIB2_FOUND AND PULSEAUDIO_FOUND AND CANBERRA_FOUND)
+  add_definitions(-DHAVE_PULSEAUDIO)
+
+  set(kcmphonon_SRCS ${kcmphonon_SRCS} speakersetup.cpp testspeakerwidget.cpp)
+  kde4_add_ui_files(kcmphonon_SRCS speakersetup.ui)
+
+  include_directories(${GLIB2_INCLUDE_DIR} ${PULSEAUDIO_INCLUDE_DIR} \
${CANBERRA_INCLUDE_DIRS}) +
+  set(kcmphonon_LIBS ${kcmphonon_LIBS} ${GLIB2_LIBRARIES} ${PULSEAUDIO_LIBRARY} \
${PULSEAUDIO_MAINLOOP_LIBRARY} ${CANBERRA_LIBRARIES}) +endif(GLIB2_FOUND AND \
PULSEAUDIO_FOUND AND CANBERRA_FOUND) +
 kde4_add_plugin(kcm_phonon ${kcmphonon_SRCS})
-target_link_libraries(kcm_phonon ${KDE4_PHONON_LIBS} ${KDE4_KCMUTILS_LIBS}
-   ${KDE4_KIO_LIBS})
+target_link_libraries(kcm_phonon ${kcmphonon_LIBS})
 
--- trunk/KDE/kdebase/runtime/phonon/kcm/main.cpp #1154775:1154776
@@ -1,5 +1,6 @@
 /*  This file is part of the KDE project
     Copyright (C) 2006-2007 Matthias Kretz <kretz@kde.org>
+    Copyright (C) 2010 Colin Guthrie <cguthrie@mandriva.org>
 
     This program is free software; you can redistribute it and/or
     modify it under the terms of the GNU Library General Public
@@ -28,6 +29,10 @@
 #include "devicepreference.h"
 #include "backendselection.h"
 
+#ifdef HAVE_PULSEAUDIO
+#  include "speakersetup.h"
+#endif
+
 K_PLUGIN_FACTORY(PhononKcmFactory, registerPlugin<PhononKcm>();)
 K_EXPORT_PLUGIN(PhononKcmFactory("kcm_phonon"))
 
@@ -39,23 +44,33 @@
             KDE_VERSION_STRING, KLocalizedString(), KAboutData::License_GPL,
             ki18n("Copyright 2006 Matthias Kretz"));
     about->addAuthor(ki18n("Matthias Kretz"), KLocalizedString(), "kretz@kde.org");
+    about->addAuthor(ki18n("Colin Guthrie"), KLocalizedString(), \
"cguthrie@mandriva.org");  setAboutData(about);
 
     setLayout(new QHBoxLayout);
     layout()->setMargin(0);
     layout()->setSpacing(0);
 
-    KTabWidget *tabs = new KTabWidget(this);
-    layout()->addWidget(tabs);
+    m_tabs = new KTabWidget(this);
+    layout()->addWidget(m_tabs);
 
     m_devicePreferenceWidget = new DevicePreference(this);
-    tabs->addTab(m_devicePreferenceWidget, i18n("Device Preference"));
+    m_tabs->addTab(m_devicePreferenceWidget, i18n("Device Preference"));
     m_backendSelection = new BackendSelection(this);
-    tabs->addTab(m_backendSelection, i18n("Backend"));
+    m_tabs->addTab(m_backendSelection, i18n("Backend"));
+
     load();
     connect(m_backendSelection, SIGNAL(changed()), SLOT(changed()));
     connect(m_devicePreferenceWidget, SIGNAL(changed()), SLOT(changed()));
+
     setButtons( KCModule::Default|KCModule::Apply|KCModule::Help );
+
+#ifdef HAVE_PULSEAUDIO
+    m_speakerSetup = new SpeakerSetup(this);
+    m_speakerSetup->setVisible(false);
+    connect(m_speakerSetup, SIGNAL(ready()), SLOT(speakerSetupReady()));
+    connect(m_speakerSetup, SIGNAL(changed()), SLOT(changed()));
+#endif
 }
 
 void PhononKcm::load()
@@ -76,5 +91,13 @@
     m_backendSelection->defaults();
 }
 
+#ifdef HAVE_PULSEAUDIO
+void PhononKcm::speakerSetupReady()
+{
+  m_tabs->insertTab(1, m_speakerSetup, i18n("Speaker Setup"));
+  emit changed();
+}
+#endif
+
 #include "main.moc"
 // vim: ts=4
--- trunk/KDE/kdebase/runtime/phonon/kcm/main.h #1154775:1154776
@@ -25,6 +25,11 @@
 class DevicePreference;
 class BackendSelection;
 
+#ifdef HAVE_PULSEAUDIO
+class SpeakerSetup;
+#endif
+class KTabWidget;
+
 class PhononKcm : public KCModule
 {
     Q_OBJECT
@@ -35,9 +40,18 @@
         void save();
         void defaults();
 
+#ifdef HAVE_PULSEAUDIO
+    private Q_SLOTS:
+        void speakerSetupReady();
+#endif
+
     private:
+        KTabWidget* m_tabs;
         DevicePreference *m_devicePreferenceWidget;
         BackendSelection *m_backendSelection;
+#ifdef HAVE_PULSEAUDIO
+        SpeakerSetup* m_speakerSetup;
+#endif
 };
 
 #endif // MAIN_H


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic