[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdemultimedia/kmix
From: Christian Esken <esken () kde ! org>
Date: 2011-07-21 23:15:22
Message-ID: 20110721231522.4A636AC86E () svn ! kde ! org
[Download RAW message or body]
SVN commit 1242598 by esken:
Make views support multiple Mixer instances.
M +1 -1 apps/kmix.cpp
M +16 -2 backends/mixer_mpris2.cpp
M +9 -0 core/mixdevice.cpp
M +7 -1 core/mixdevice.h
M +41 -11 gui/viewbase.cpp
M +4 -2 gui/viewbase.h
M +6 -37 gui/viewdockareapopup.cpp
M +0 -3 gui/viewdockareapopup.h
--- trunk/KDE/kdemultimedia/kmix/apps/kmix.cpp #1242597:1242598
@@ -1159,7 +1159,7 @@
ViewBase* view = kmw->currentView();
QAction* action = actionCollection()->action( "toggle_channels_currentview" \
); if (view && action)
- action->setVisible( !view->getMixer()->isDynamic() );
+ action->setVisible( !view->isDynamic() );
}
}
--- trunk/KDE/kdemultimedia/kmix/backends/mixer_mpris2.cpp #1242597:1242598
@@ -38,6 +38,7 @@
if ( m_devnum != 0 )
return Mixer::ERR_OPEN;
+ _mixer->setDynamic();
run();
return 0;
}
@@ -210,8 +211,21 @@
qDebug() << "REPLY " << result2.type() << ": " << readableName;
- MixDevice* md = new MixDevice(_mixer, id, readableName, MixDevice::VOLUME);
- Volume* vol = new Volume( 100, 0, true, false);
+ MixDevice::ChannelType ct = MixDevice::APPLICATION_STREAM;
+ if (id.startsWith("amarok")) {
+ ct = MixDevice::APPLICATION_AMAROK;
+ }
+ else if (id.startsWith("banshee")) {
+ ct = MixDevice::APPLICATION_BANSHEE;
+ }
+ else if (id.startsWith("xmms")) {
+ ct = MixDevice::APPLICATION_XMM2;
+ }
+
+ MixDevice* md = new MixDevice(_mixer, id, readableName, ct);
+ // MPRIS2 doesn't support an actual mute switch. Mute is defined as volume = 0.0
+ // Thus we won't add the playback switch
+ Volume* vol = new Volume( 100, 0, false, false);
vol->addVolumeChannel(VolumeChannel(Volume::LEFT));
vol->addVolumeChannel(VolumeChannel(Volume::RIGHT));
md->addMediaPlayControl();
--- trunk/KDE/kdemultimedia/kmix/core/mixdevice.cpp #1242597:1242598
@@ -78,6 +78,15 @@
return "mixer-microphone-front";
case MixDevice::KMIX_COMPOSITE:
return "mixer-line";
+ case MixDevice::APPLICATION_AMAROK:
+ return "amarok";
+ case MixDevice::APPLICATION_BANSHEE:
+ return "media-player-banshee";
+ case MixDevice::APPLICATION_XMM2:
+ return "xmms";
+ case MixDevice::APPLICATION_STREAM:
+ return "mixer-pcm";
+
}
return "mixer-front";
}
--- trunk/KDE/kdemultimedia/kmix/core/mixdevice.h #1242597:1242598
@@ -84,7 +84,13 @@
MICROPHONE_BOOST,
MICROPHONE_FRONT_BOOST,
MICROPHONE_FRONT,
- KMIX_COMPOSITE
+ KMIX_COMPOSITE,
+
+ APPLICATION_STREAM,
+ // Some specific applications
+ APPLICATION_AMAROK,
+ APPLICATION_BANSHEE,
+ APPLICATION_XMM2,
};
enum SwitchType { OnOff, Mute, Capture, Activator };
--- trunk/KDE/kdemultimedia/kmix/gui/viewbase.cpp #1242597:1242598
@@ -74,13 +74,13 @@
}
}
}
- if ( !_mixer->isDynamic() ) {
+ if ( !isDynamic() ) {
QAction *action = _localActionColletion->addAction("toggle_channels");
action->setText(i18n("&Channels"));
connect(action, SIGNAL(triggered(bool) ), SLOT(configureView()));
}
- connect ( _mixer, SIGNAL(controlChanged()), this, SLOT(refreshVolumeLevels()) );
- connect ( _mixer, SIGNAL(controlsReconfigured(const QString&)), this, \
SLOT(controlsReconfigured(const QString&)) ); +/* connect ( _mixer, \
SIGNAL(controlChanged()), this, SLOT(refreshVolumeLevels()) ); + connect ( _mixer, \
SIGNAL(controlsReconfigured(const QString&)), this, SLOT(controlsReconfigured(const \
QString&)) );*/ }
ViewBase::~ViewBase() {
@@ -98,7 +98,7 @@
bool ViewBase::isValid() const
{
- return ( _mixSet->count() > 0 || _mixer->isDynamic() );
+ return ( _mixSet->count() > 0 || isDynamic() );
}
void ViewBase::setIcons (bool on) { KMixToolBox::setIcons (_mdws, on ); }
@@ -122,8 +122,18 @@
}
// allow view to "polish" itself
constructionFinished();
+
+ kDebug() << "CONNECT ViewBase count " << _mixers.size();
+ foreach ( Mixer* mixer, _mixers )
+ {
+ kDebug(67100) << "CONNECT ViewBase controlschanged" << mixer->id();
+ connect ( mixer, SIGNAL(controlChanged()), this, SLOT(refreshVolumeLevels()) );
+ connect ( mixer, SIGNAL(controlsReconfigured(const QString&)), this, \
SLOT(controlsReconfigured(const QString&)) ); }
+
+}
+
/**
* Rebuild the View from the (existing) Profile.
*/
@@ -199,6 +209,7 @@
void ViewBase::controlsReconfigured( const QString& mixer_ID )
{
+ // TODO Search _mixers for the correct Mixer*. After that, remove _mixer instance \
variable if ( _mixer->id() == mixer_ID )
{
kDebug(67100) << "ViewBase::controlsReconfigured() " << mixer_ID << " is \
being redrawn (mixset contains: " << _mixSet->count() << ")"; @@ -216,15 +227,26 @@
{
// is virtual
}
-
-Mixer* ViewBase::getMixer()
+/**
+ * Check all Mixer instances of this view.
+ * If at least on is dynamic, return true.
+ * Please note that usually there is only one Mixer instance per View.
+ * The only exception as of today (June 2011) is the Tray Popup, which
+ * can contain controls from e.g. ALSA and MPRIS2 backends.
+ */
+bool ViewBase::isDynamic() const
{
- return _mixer;
+ foreach (Mixer* mixer , _mixers )
+ {
+ if ( mixer->isDynamic() )
+ return true;
}
+ return false;
+}
void ViewBase::setMixSet()
{
- if ( _mixer->isDynamic() ) {
+ if ( isDynamic() ) {
// We need to delete the current MixDeviceWidgets so we can redraw them
while (!_mdws.isEmpty()) {
@@ -237,7 +259,15 @@
_mixSet->clear();
}
_setMixSet();
+
+ _mixers.clear();
+ foreach ( MixDevice* md, *_mixSet )
+ {
+ kDebug() << "VVV Add to " << md->mixer()->id();
+// MixDeviceWidget* mdw = qobject_cast<MixDeviceWidget*>(qw);
+ _mixers.insert(md->mixer());
}
+}
/**
@@ -246,7 +276,7 @@
*/
void ViewBase::configureView() {
- Q_ASSERT( !_mixer->isDynamic() );
+ Q_ASSERT( !isDynamic() );
DialogViewConfiguration* dvc = new DialogViewConfiguration(0, *this);
dvc->show();
@@ -272,7 +302,7 @@
static char guiComplexity[3][20] = { "simple", "extended", "all" };
// Certain bits are not saved for dynamic mixers (e.g. PulseAudio)
- bool dynamic = _mixer->isDynamic();
+ bool dynamic = isDynamic();
for ( int tries = 0; tries < 3; tries++ )
{
@@ -357,7 +387,7 @@
kDebug(67100) << "KMixToolBox::saveView() grp=" << grp;
// Certain bits are not saved for dynamic mixers (e.g. PulseAudio)
- bool dynamic = _mixer->isDynamic();
+ bool dynamic = isDynamic();
for (int i=0; i < view->_mdws.count(); ++i ){
QWidget *qmdw = view->_mdws[i];
--- trunk/KDE/kdemultimedia/kmix/gui/viewbase.h #1242597:1242598
@@ -22,8 +22,9 @@
#define ViewBase_h
// QT
+#include <QSet>
#include <QWidget>
-#include <qlist.h>
+#include <QList>
// KDE
#include <KActionCollection>
@@ -89,7 +90,7 @@
void setMixSet();
- Mixer* getMixer();
+ bool isDynamic() const;
/**
* Creates a suitable representation for the given MixDevice.
@@ -128,6 +129,7 @@
protected:
MixSet *_mixSet;
Mixer *_mixer;
+ QSet<Mixer*> _mixers; // this might deprecate _mixer in the future. Currently \
only in use by ViewDockAreaPopup KMenu *_popMenu;
KActionCollection* _actions; // -<- applciations wide action collection
--- trunk/KDE/kdemultimedia/kmix/gui/viewdockareapopup.cpp #1242597:1242598
@@ -67,18 +67,7 @@
QApplication::sendEvent( mdw, e);
}
-MixDevice* ViewDockAreaPopup::dockDevice()
-{
- MixDeviceWidget* mdw = 0;
- if ( !_mdws.isEmpty() )
- mdw = (MixDeviceWidget*)_mdws.first();
- if ( mdw != 0 )
- return mdw->mixDevice();
- return (MixDevice*)(0);
-}
-
-
void ViewDockAreaPopup::showContextMenu()
{
// no right-button-menu on "dock area popup"
@@ -90,6 +79,7 @@
{
// kDebug(67100) << "ViewDockAreaPopup::setMixSet()\n";
+ // -- remove controls
if ( _mixer->isDynamic() ) {
// Our _layoutMDW now should only contain spacer widgets from the \
QSpacerItem's in add() below.
// We need to trash those too otherwise all sliders gradually migrate away \
from the edge :p @@ -158,38 +148,17 @@
pb->setObjectName( QLatin1String("MixerPanel" ));
connect ( pb, SIGNAL( clicked() ), SLOT( showPanelSlot() ) );
_layoutMDW->addWidget( pb, sliderColumn+1, 0, 1, 1 );
-/*
-QWidget* mdw = 0;
- if ( !_mdws.isEmpty() )
- mdw = _mdws.first();
-
- if ( mdw != 0 ) {
- mdw->move(0,0);
- mdw->show();
- }*/
}
void ViewDockAreaPopup::refreshVolumeLevels() {
- // kDebug(67100) << "ViewDockAreaPopup::refreshVolumeLevels()\n";
- QWidget* mdw = 0;
- if ( !_mdws.isEmpty() )
- mdw = _mdws.first();
-
- if ( mdw == 0 ) {
- kError(67100) << "ViewDockAreaPopup::refreshVolumeLevels(): mdw == 0\n";
- // sanity check (normally the lists are set up correctly)
+ foreach ( QWidget* qw, _mdws )
+ {
+ kDebug() << "rvl: " << qw;
+ MixDeviceWidget* mdw = qobject_cast<MixDeviceWidget*>(qw);
+ if ( mdw != 0 ) mdw->update();
}
- else {
- if ( mdw->inherits("MDWSlider")) { // sanity check
- static_cast<MDWSlider*>(mdw)->update();
}
- else {
- kError(67100) << "ViewDockAreaPopup::refreshVolumeLevels(): mdw is not \
slider\n";
- // no slider. Cannot happen in theory => skip it
- }
- }
-}
void ViewDockAreaPopup::showPanelSlot() {
kDebug() << "Check when this is called";
--- trunk/KDE/kdemultimedia/kmix/gui/viewdockareapopup.h #1242597:1242598
@@ -36,15 +36,12 @@
public:
ViewDockAreaPopup(QWidget* parent, const char* name, Mixer* mixer, \
ViewBase::ViewFlags vflags, GUIProfile *guiprof, KMixWindow *dockW); \
~ViewDockAreaPopup();
- MixDevice* dockDevice();
virtual QWidget* add(MixDevice *mdw);
virtual void constructionFinished();
virtual void refreshVolumeLevels();
virtual void showContextMenu();
- //QSize sizeHint() const;
-
protected:
KMixWindow *_dock;
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic