~ubuntu-branches/ubuntu/maverick/kdemultimedia/maverick-proposed

« back to all changes in this revision

Viewing changes to kmix/viewbase.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Thomas
  • Date: 2010-05-25 08:30:50 UTC
  • mfrom: (1.2.43 upstream)
  • Revision ID: james.westby@ubuntu.com-20100525083050-8o3otjqjwsnzjb6h
Tags: 4:4.4.80-0ubuntu1
* New upstream beta release:
  - Bump kde-sc-dev-latest to 4.4.80
  - Update various .install files
  - Refresh all patches
  - Add build-depends on libswscale-dev, libavcodec-dev, and libavformat-dev
    for new video thumbnailer backends
  - Add a new ffmpegthumbs package for the new video thumbnailer
* Switch to source format 3.0 (quilt):
  - Bump debhelper build-depend version to 7.3.16 or greater

Show diffs side-by-side

added added

removed removed

Lines of Context:
39
39
#include "kmixtoolbox.h"
40
40
#include "mixdevicewidget.h"
41
41
#include "mixer.h"
 
42
#include "mixertoolbox.h"
42
43
 
43
44
 
44
45
ViewBase::ViewBase(QWidget* parent, const char* id, Mixer* mixer, Qt::WFlags f, ViewBase::ViewFlags vflags, GUIProfile *guiprof, KActionCollection *actionColletion)
76
77
   action->setText(i18n("&Channels"));
77
78
   connect(action, SIGNAL(triggered(bool) ), SLOT(configureView()));
78
79
   connect ( _mixer, SIGNAL(controlChanged()), this, SLOT(refreshVolumeLevels()) );
 
80
   connect ( _mixer, SIGNAL(controlsReconfigured(const QString&)), this, SLOT(controlsReconfigured(const QString&)) );
79
81
}
80
82
 
81
83
ViewBase::~ViewBase() {
101
103
 
102
104
bool ViewBase::isValid() const
103
105
{
104
 
   return (_mixSet->count() > 0 );
 
106
   return ( _mixSet->count() > 0 || _mixer->dynamic() );
105
107
}
106
108
 
107
109
void ViewBase::setIcons (bool on) { KMixToolBox::setIcons (_mdws, on ); }
122
124
    {
123
125
        MixDevice *mixDevice;
124
126
        mixDevice = (*_mixSet)[i];
125
 
        QWidget* mdw = add(mixDevice);
126
 
        _mdws.append(mdw);
 
127
        QWidget* mdw = add(mixDevice);
 
128
        _mdws.append(mdw);
127
129
    }
128
130
    // allow view to "polish" itself
129
131
    constructionFinished();
203
205
    _popMenu->popup( pos );
204
206
}
205
207
 
 
208
void ViewBase::controlsReconfigured( const QString& mixer_ID )
 
209
{
 
210
    if ( _mixer->id() == mixer_ID )
 
211
    {
 
212
        kDebug(67100) << "ViewBase::controlsReconfigured() " << mixer_ID << " is being redrawn (mixset contains: " << _mixSet->count() << ")";
 
213
        setMixSet();
 
214
        kDebug(67100) << "ViewBase::controlsReconfigured() " << mixer_ID << ": Recreating widgets (mixset contains: " << _mixSet->count() << ")";
 
215
        createDeviceWidgets();
 
216
 
 
217
        // We've done the low level stuff our selves but let elements
 
218
        // above know what has happened so they can reload config etc.
 
219
        emit redrawMixer(mixer_ID);
 
220
    }
 
221
}
206
222
 
207
223
void ViewBase::refreshVolumeLevels()
208
224
{
209
225
    // is virtual
210
226
}
211
227
 
212
 
Mixer* ViewBase::getMixer() {
 
228
Mixer* ViewBase::getMixer()
 
229
{
213
230
    return _mixer;
214
231
}
215
232
 
 
233
void ViewBase::setMixSet()
 
234
{
 
235
    if ( _mixer->dynamic()) {
 
236
 
 
237
        // Check the guiprofile... if it is not the fallback GUIProfile, then
 
238
        // make sure that we add a specific entry for any devices not present.
 
239
        if ( 0 != _guiprof && MixerToolBox::instance()->fallbackProfile(_mixer) != _guiprof ) {
 
240
            kDebug(67100) << "Dynamic mixer " << _mixer->id() << " is NOT using Fallback GUIProfile. Checking to see if new controls are present";
 
241
 
 
242
            QList<QString> new_mix_devices;
 
243
            MixSet ms = _mixer->getMixSet();
 
244
            for (int i=0; i < ms.count(); ++i)
 
245
                new_mix_devices.append("^" + ms[i]->id() + "$");
 
246
            std::vector<ProfControl*>::const_iterator itEnd = _guiprof->_controls.end();
 
247
            for ( std::vector<ProfControl*>::const_iterator it = _guiprof->_controls.begin(); it != itEnd; ++it)
 
248
                new_mix_devices.removeAll((*it)->id);
 
249
 
 
250
            if ( new_mix_devices.count() > 0 ) {
 
251
                kDebug(67100) << "Found " << new_mix_devices.count() << " new controls. Adding to GUIProfile";
 
252
                while ( new_mix_devices.count() > 0 ) {
 
253
                    ProfControl* ctl = new ProfControl();
 
254
                    ctl->id = new_mix_devices.takeAt(0);
 
255
                    ctl->subcontrols = ".*";
 
256
                    ctl->tab = _guiprof->_tabs[0]->name; // Use the first tab... not ideal but should work most of the time;
 
257
                    ctl->show = "simple";
 
258
                    _guiprof->_controls.push_back(ctl);
 
259
                }
 
260
                QString profileName;
 
261
                profileName =  _mixer->id() + "." + id();
 
262
                _guiprof->writeProfile(profileName);
 
263
            }
 
264
        }
 
265
 
 
266
        // We need to delete the current MixDeviceWidgets so we can redraw them
 
267
        while (!_mdws.isEmpty()) {
 
268
            QWidget* mdw = _mdws.last();
 
269
            _mdws.pop_back();
 
270
            delete mdw;
 
271
        }
 
272
 
 
273
        // Clean up our _mixSet so we can reapply our GUIProfile
 
274
        _mixSet->clear();
 
275
    }
 
276
    _setMixSet();
 
277
}
 
278
 
 
279
 
216
280
/**
217
281
 * Open the View configuration dialog. The user can select which channels he wants
218
282
 * to see and which not.