2
// * KMix -- KDE's full featured mini mixer
5
// * Copyright (C) 2004 Christian Esken <esken@kde.org>
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.
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.
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.
22
//#include <qcursor.h>
24
//#include <QMouseEvent>
26
//#include <qslider.h>
28
//#include <klocale.h>
29
//#include <kconfig.h>
30
//#include <kaction.h>
32
//#include <kglobalaccel.h>
34
//#include <ktoggleaction.h>
35
//#include <kactioncollection.h>
37
//#include "mdwswitch.h"
38
//#include "core/mixer.h"
39
//#include "viewbase.h"
40
//#include "verticaltext.h"
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).
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)
53
// // create actions (on _mdwActions, see MixDeviceWidget)
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()));
66
// KAction *a = _mdwActions->addAction( "Toggle switch" );
67
// a->setText( i18n( "Toggle Switch" ) );
68
// connect(a, SIGNAL(triggered(bool) ), SLOT( toggleSwitch() ));
70
// // The accel keys are loaded in KMixerWidget::loadConfig, see kmixtoolbox.cpp
72
// installEventFilter( this ); // filter for popup
75
//MDWSwitch::~MDWSwitch()
80
//void MDWSwitch::createWidgets()
82
// if ( _orientation == Qt::Vertical ) {
83
// _layout = new QVBoxLayout( this );
84
// _layout->setAlignment(Qt::AlignHCenter);
87
// _layout = new QHBoxLayout( this );
88
// _layout->setAlignment(Qt::AlignVCenter);
90
// this->setToolTip( m_mixdevice->readableName() );
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" );
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() );
105
// _layout->addWidget( _switchLED );
106
// _layout->addSpacing( 2 );
107
// _layout->addWidget( _labelV );
109
// _switchLED->installEventFilter( this );
110
// _labelV->installEventFilter( this );
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" );
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" ));
124
// _layout->addWidget( _switchLED );
125
// _layout->addSpacing( 1 );
126
// _layout->addWidget( _label );
127
// _switchLED->installEventFilter( this );
128
// _label->installEventFilter( this );
130
// connect( _switchLED, SIGNAL(stateChanged(bool)), this, SLOT(toggleSwitch()) );
131
// _layout->addSpacing( 4 );
134
//void MDWSwitch::update()
136
// if ( _switchLED != 0 ) {
137
// _switchLED->blockSignals( true );
138
// if( m_mixdevice->captureVolume().hasSwitch() )
139
// _switchLED->setState( m_mixdevice->isRecSource() ? KLed::On : KLed::Off );
141
// _switchLED->setState( m_mixdevice->isMuted() ? KLed::Off : KLed::On );
143
// _switchLED->blockSignals( false );
147
//void MDWSwitch::setBackgroundRole(QPalette::ColorRole m)
149
// if ( _label != 0 ){
150
// _label->setBackgroundRole(m);
152
// if ( _labelV != 0 ){
153
// _labelV->setBackgroundRole(m);
155
// _switchLED->setBackgroundRole(m);
156
// MixDeviceWidget::setBackgroundRole(m);
159
//void MDWSwitch::showContextMenu()
164
// KMenu *menu = m_view->getPopup();
166
// QPoint pos = QCursor::pos();
167
// menu->popup( pos );
171
//QSizePolicy MDWSwitch::sizePolicy() const
173
// if ( _orientation == Qt::Vertical ) {
174
// return QSizePolicy( QSizePolicy::Fixed, QSizePolicy::MinimumExpanding );
177
// return QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::Fixed );
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.
185
//void MDWSwitch::toggleSwitch() {
186
// if( m_mixdevice->captureVolume().hasSwitch() )
187
// setSwitch( !m_mixdevice->isRecSource() );
189
// setSwitch( !m_mixdevice->isMuted() );
192
//void MDWSwitch::setSwitch(bool value)
194
// if ( m_mixdevice->playbackVolume().hasSwitch() ) {
195
// if ( m_mixdevice->captureVolume().hasSwitch() ) {
196
// m_mixdevice->mixer()->setRecordSource( m_mixdevice->id(), value );
199
// m_mixdevice->setMuted( value );
200
// m_mixdevice->mixer()->commitVolumeChange( m_mixdevice );
205
//void MDWSwitch::setDisabled()
207
// setDisabled( true );
210
//void MDWSwitch::setDisabled( bool value ) {
211
// if ( m_disabled!=value)
213
// value ? hide() : show();
214
// m_disabled = value;
219
// * An event filter for the various QWidgets. We watch for Mouse press Events, so
220
// * that we can popup the context menu.
222
//bool MDWSwitch::eventFilter( QObject* obj, QEvent* e )
224
// if (e->type() == QEvent::MouseButtonPress) {
225
// QMouseEvent *qme = static_cast<QMouseEvent*>(e);
226
// if (qme->button() == Qt::RightButton) {
227
// showContextMenu();
231
// return QWidget::eventFilter(obj,e);
234
//#include "mdwswitch.moc"