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

« back to all changes in this revision

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