~ubuntu-branches/ubuntu/natty/kdemultimedia/natty-proposed

« back to all changes in this revision

Viewing changes to kmix/gui/mdwswitch.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Debian Qt/KDE Maintainers
  • Date: 2011-05-26 02:41:36 UTC
  • mfrom: (0.2.3 upstream)
  • mto: This revision was merged to the branch mainline in revision 108.
  • Revision ID: james.westby@ubuntu.com-20110526024136-jjwsigfy402jhupm
Tags: upstream-4.6.3
ImportĀ upstreamĀ versionĀ 4.6.3

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 <qcursor.h>
 
23
//#include <QLabel>
 
24
//#include <QMouseEvent>
 
25
//#include <QObject>
 
26
//#include <qslider.h>
 
27
//
 
28
//#include <klocale.h>
 
29
//#include <kconfig.h>
 
30
//#include <kaction.h>
 
31
//#include <kmenu.h>
 
32
//#include <kglobalaccel.h>
 
33
//#include <kdebug.h>
 
34
//#include <ktoggleaction.h>
 
35
//#include <kactioncollection.h>
 
36
//
 
37
//#include "mdwswitch.h"
 
38
//#include "core/mixer.h"
 
39
//#include "viewbase.h"
 
40
//#include "verticaltext.h"
 
41
//
 
42
///**
 
43
// * Class that represents a single Switch
 
44
// * The orientation (horizontal, vertical) can be configured and whether it should
 
45
// * be "small"  (uses KSmallSlider instead of QSlider then).
 
46
// */
 
47
//MDWSwitch::MDWSwitch(MixDevice* md,
 
48
//                     bool small, Qt::Orientation orientation,
 
49
//                     QWidget* parent, ViewBase* mw) :
 
50
//    MixDeviceWidget(md,small,orientation,parent,mw),
 
51
//    _label(0) , _labelV(0) , _switchLED(0), _layout(0)
 
52
//{
 
53
//    // create actions (on _mdwActions, see MixDeviceWidget)
 
54
//
 
55
//    // KStandardAction::showMenubar() is in MixDeviceWidget now
 
56
//    KToggleAction *action = _mdwActions->add<KToggleAction>( "hide" );
 
57
//    action->setText( i18n("&Hide") );
 
58
//    connect(action, SIGNAL(triggered(bool) ), SLOT(setDisabled()));
 
59
//    KAction *b = _mdwActions->addAction( "keys" );
 
60
//    b->setText( i18n("C&onfigure Shortcuts...") );
 
61
//    connect(b, SIGNAL(triggered(bool) ), SLOT(defineKeys()));
 
62
//
 
63
//    // create widgets
 
64
//    createWidgets();
 
65
//
 
66
//    KAction *a = _mdwActions->addAction( "Toggle switch" );
 
67
//    a->setText( i18n( "Toggle Switch" ) );
 
68
//    connect(a, SIGNAL(triggered(bool) ), SLOT( toggleSwitch() ));
 
69
//
 
70
//    // The accel keys are loaded in KMixerWidget::loadConfig, see kmixtoolbox.cpp
 
71
//
 
72
//    installEventFilter( this ); // filter for popup
 
73
//}
 
74
//
 
75
//MDWSwitch::~MDWSwitch()
 
76
//{
 
77
//}
 
78
//
 
79
//
 
80
//void MDWSwitch::createWidgets()
 
81
//{
 
82
//   if ( _orientation == Qt::Vertical ) {
 
83
//      _layout = new QVBoxLayout( this );
 
84
//      _layout->setAlignment(Qt::AlignHCenter);
 
85
//   }
 
86
//   else {
 
87
//      _layout = new QHBoxLayout( this );
 
88
//      _layout->setAlignment(Qt::AlignVCenter);
 
89
//   }
 
90
//   this->setToolTip( m_mixdevice->readableName() );
 
91
//
 
92
//
 
93
//   _layout->addSpacing( 4 );
 
94
//   // --- LEDS --------------------------
 
95
//   if ( _orientation == Qt::Vertical ) {
 
96
//      if( m_mixdevice->captureVolume().hasSwitch() )
 
97
//         _switchLED = new QCheckBox( Qt::red,
 
98
//               m_mixdevice->isRecSource()?KLed::On:KLed::Off,
 
99
//               KLed::Sunken, KLed::Circular, this, "RecordLED" );
 
100
//      else
 
101
//         _switchLED = new QCheckBox( Qt::yellow, KLed::On, KLed::Sunken, KLed::Circular, this, "SwitchLED" );
 
102
//         _switchLED->setFixedSize(16,16);
 
103
//         _labelV = new VerticalText( this, m_mixdevice->readableName().toUtf8().data() );
 
104
//
 
105
//         _layout->addWidget( _switchLED );
 
106
//         _layout->addSpacing( 2 );
 
107
//         _layout->addWidget( _labelV );
 
108
//
 
109
//         _switchLED->installEventFilter( this );
 
110
//         _labelV->installEventFilter( this );
 
111
//      }
 
112
//      else
 
113
//      {
 
114
//      if( m_mixdevice->captureVolume().hasSwitch() )
 
115
//         _switchLED = new QCheckBox( Qt::red,
 
116
//               m_mixdevice->isRecSource()?KLed::On:KLed::Off,
 
117
//               KLed::Sunken, KLed::Circular, this, "RecordLED" );
 
118
//      else
 
119
//         _switchLED = new QCheckBox( Qt::yellow, KLed::On, KLed::Sunken, KLed::Circular, this, "SwitchLED" );
 
120
//         _switchLED->setFixedSize(16,16);
 
121
//         _label  = new QLabel(m_mixdevice->readableName(), this );
 
122
//         _label->setObjectName( QLatin1String("SwitchName" ));
 
123
//
 
124
//         _layout->addWidget( _switchLED );
 
125
//         _layout->addSpacing( 1 );
 
126
//         _layout->addWidget( _label );
 
127
//         _switchLED->installEventFilter( this );
 
128
//         _label->installEventFilter( this );
 
129
//      }
 
130
//      connect( _switchLED, SIGNAL(stateChanged(bool)), this, SLOT(toggleSwitch()) );
 
131
//      _layout->addSpacing( 4 );
 
132
//}
 
133
//
 
134
//void MDWSwitch::update()
 
135
//{
 
136
//   if ( _switchLED != 0 ) {
 
137
//      _switchLED->blockSignals( true );
 
138
//      if( m_mixdevice->captureVolume().hasSwitch() )
 
139
//         _switchLED->setState( m_mixdevice->isRecSource() ? KLed::On : KLed::Off );
 
140
//      else
 
141
//         _switchLED->setState( m_mixdevice->isMuted() ? KLed::Off : KLed::On );
 
142
//
 
143
//      _switchLED->blockSignals( false );
 
144
//   }
 
145
//}
 
146
//
 
147
//void MDWSwitch::setBackgroundRole(QPalette::ColorRole m)
 
148
//{
 
149
//   if ( _label != 0 ){
 
150
//      _label->setBackgroundRole(m);
 
151
//   }
 
152
//   if ( _labelV != 0 ){
 
153
//      _labelV->setBackgroundRole(m);
 
154
//   }
 
155
//   _switchLED->setBackgroundRole(m);
 
156
//   MixDeviceWidget::setBackgroundRole(m);
 
157
//}
 
158
//
 
159
//void MDWSwitch::showContextMenu()
 
160
//{
 
161
//   if( m_view == 0 )
 
162
//   return;
 
163
//
 
164
//    KMenu *menu = m_view->getPopup();
 
165
//
 
166
//    QPoint pos = QCursor::pos();
 
167
//    menu->popup( pos );
 
168
//}
 
169
//
 
170
//
 
171
//QSizePolicy MDWSwitch::sizePolicy() const
 
172
//{
 
173
//    if ( _orientation == Qt::Vertical ) {
 
174
//        return QSizePolicy(  QSizePolicy::Fixed, QSizePolicy::MinimumExpanding );
 
175
//    }
 
176
//    else {
 
177
//        return QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::Fixed );
 
178
//    }
 
179
//}
 
180
//
 
181
///**
 
182
//   This slot is called, when a user has clicked the mute button. Also it is called by any other
 
183
//    associated KAction like the context menu.
 
184
//*/
 
185
//void MDWSwitch::toggleSwitch() {
 
186
//   if( m_mixdevice->captureVolume().hasSwitch() )
 
187
//      setSwitch( !m_mixdevice->isRecSource() );
 
188
//   else
 
189
//      setSwitch( !m_mixdevice->isMuted() );
 
190
//}
 
191
//
 
192
//void MDWSwitch::setSwitch(bool value)
 
193
//{
 
194
//   if (  m_mixdevice->playbackVolume().hasSwitch() ) {
 
195
//      if ( m_mixdevice->captureVolume().hasSwitch() ) {
 
196
//         m_mixdevice->mixer()->setRecordSource( m_mixdevice->id(), value );
 
197
//      }
 
198
//      else {
 
199
//         m_mixdevice->setMuted( value );
 
200
//         m_mixdevice->mixer()->commitVolumeChange( m_mixdevice );
 
201
//      }
 
202
//   }
 
203
//}
 
204
//
 
205
//void MDWSwitch::setDisabled()
 
206
//{
 
207
//   setDisabled( true );
 
208
//}
 
209
//
 
210
//void MDWSwitch::setDisabled( bool value ) {
 
211
//   if ( m_disabled!=value)
 
212
//   {
 
213
//      value ? hide() : show();
 
214
//      m_disabled = value;
 
215
//   }
 
216
//}
 
217
//
 
218
///**
 
219
// * An event filter for the various QWidgets. We watch for Mouse press Events, so
 
220
// * that we can popup the context menu.
 
221
// */
 
222
//bool MDWSwitch::eventFilter( QObject* obj, QEvent* e )
 
223
//{
 
224
//   if (e->type() == QEvent::MouseButtonPress) {
 
225
//      QMouseEvent *qme = static_cast<QMouseEvent*>(e);
 
226
//      if (qme->button() == Qt::RightButton) {
 
227
//            showContextMenu();
 
228
//            return true;
 
229
//      }
 
230
//   }
 
231
//   return QWidget::eventFilter(obj,e);
 
232
//}
 
233
//
 
234
//#include "mdwswitch.moc"