~ubuntu-branches/ubuntu/quantal/kmix/quantal-proposed

« back to all changes in this revision

Viewing changes to gui/kmixtoolbox.cpp

  • Committer: Package Import Robot
  • Author(s): Felix Geyer
  • Date: 2012-06-14 17:19:54 UTC
  • Revision ID: package-import@ubuntu.com-20120614171954-8rg4l5uswtln8kh1
Tags: upstream-4.8.90+repack
ImportĀ upstreamĀ versionĀ 4.8.90+repack

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * KMix -- KDE's full featured mini mixer
 
3
 *
 
4
 *
 
5
 * Copyright (C) 2004 Christian Esken <esken@kde.org>
 
6
 *
 
7
 * This program is free software; you can redistribute it and/or
 
8
 * modify it under the terms of the GNU Library General Public
 
9
 * License as published by the Free Software Foundation; either
 
10
 * version 2 of the License, or (at your option) any later version.
 
11
 *
 
12
 * This program is distributed in the hope that it will be useful,
 
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
15
 * Library General Public License for more details.
 
16
 *
 
17
 * You should have received a copy of the GNU Library General Public
 
18
 * License along with this program; if not, write to the Free
 
19
 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
20
 */
 
21
 
 
22
#include "gui/kmixtoolbox.h"
 
23
 
 
24
#include <QWidget>
 
25
#include <QString>
 
26
 
 
27
//#include <kdebug.h>
 
28
#include <kglobalaccel.h>
 
29
#include <klocale.h>
 
30
#include <knotification.h>
 
31
 
 
32
#include "gui/guiprofile.h"
 
33
#include "mdwslider.h"
 
34
#include "gui/mixdevicewidget.h"
 
35
#include "core/mixdevice.h"
 
36
#include "core/mixer.h"
 
37
#include "viewbase.h"
 
38
 
 
39
// TODO KMixToolbox is rather superfluous today, as there is no "KMix Applet" any more, and it was probably always bad style.
 
40
//      I only have to think what to do with KMixToolBox::notification()
 
41
 
 
42
/***********************************************************************************
 
43
 KMixToolbox contains several GUI relevant methods that are shared between the 
 
44
 KMix Main Program, and the KMix Applet.
 
45
 kmixctrl - as not non-GUI application - does NOT link to KMixToolBox.
 
46
 
 
47
 This means: Shared GUI stuff goes into the KMixToolBox class , non-GUI stuff goes
 
48
 into the MixerToolBox class.
 
49
 ***********************************************************************************/
 
50
void KMixToolBox::setIcons(QList<QWidget *> &mdws, bool on ) {
 
51
   for (int i=0; i < mdws.count(); ++i ){
 
52
      QWidget *mdw = mdws[i];
 
53
      if ( mdw->inherits("MixDeviceWidget") ) { // -<- play safe here
 
54
         static_cast<MixDeviceWidget*>(mdw)->setIcons( on );
 
55
      }
 
56
   }
 
57
}
 
58
 
 
59
void KMixToolBox::setLabels(QList<QWidget *> &mdws, bool on ) {
 
60
   for (int i=0; i < mdws.count(); ++i ){
 
61
      QWidget *mdw = mdws[i];
 
62
      if ( mdw->inherits("MixDeviceWidget") ) { // -<- play safe here
 
63
         static_cast<MixDeviceWidget*>(mdw)->setLabeled( on );
 
64
      }
 
65
   }
 
66
}
 
67
 
 
68
void KMixToolBox::setTicks(QList<QWidget *> &mdws, bool on ) {
 
69
   for (int i=0; i < mdws.count(); ++i ){
 
70
      QWidget *mdw = mdws[i];
 
71
      if ( mdw->inherits("MixDeviceWidget") ) { // -<- play safe here
 
72
         static_cast<MixDeviceWidget*>(mdw)->setTicks( on );
 
73
      }
 
74
   }
 
75
}
 
76
 
 
77
void KMixToolBox::notification(const char *notificationName, const QString &text,
 
78
                                const QStringList &actions, QObject *receiver,
 
79
                                const char *actionSlot)
 
80
{
 
81
    KNotification *notification = new KNotification(notificationName);
 
82
    //notification->setComponentData(componentData());
 
83
    notification->setText(text);
 
84
    //notification->setPixmap(...);
 
85
    notification->addContext(QLatin1String("Application"), KGlobal::mainComponent().componentName());
 
86
    if (!actions.isEmpty() && receiver && actionSlot) {
 
87
        notification->setActions(actions);
 
88
        QObject::connect(notification, SIGNAL(activated(uint)), receiver, actionSlot);
 
89
    }
 
90
    notification->sendEvent();
 
91
}