-rw-r--r-- | core/applets/volumeapplet/opie-volumeapplet.control | 2 | ||||
-rw-r--r-- | core/applets/volumeapplet/volume.cpp | 258 | ||||
-rw-r--r-- | core/applets/volumeapplet/volume.h | 24 |
3 files changed, 214 insertions, 70 deletions
diff --git a/core/applets/volumeapplet/opie-volumeapplet.control b/core/applets/volumeapplet/opie-volumeapplet.control index a65cf6d..a2c0363 100644 --- a/core/applets/volumeapplet/opie-volumeapplet.control +++ b/core/applets/volumeapplet/opie-volumeapplet.control | |||
@@ -1,9 +1,9 @@ | |||
1 | Files: plugins/applets/libvolumeapplet.so* | 1 | Files: plugins/applets/libvolumeapplet.so* |
2 | Priority: optional | 2 | Priority: optional |
3 | Section: opie/taskbar | 3 | Section: opie/taskbar |
4 | Maintainer: Warwick Allison <warwick@trolltech.com> | 4 | Maintainer: Warwick Allison <warwick@trolltech.com> |
5 | Architecture: arm | 5 | Architecture: arm |
6 | Version: $QPE_VERSION-$SUB_VERSION | 6 | Version: $QPE_VERSION-$SUB_VERSION.1 |
7 | Depends: opie-base ($QPE_VERSION) | 7 | Depends: opie-base ($QPE_VERSION) |
8 | Description: Volume applet | 8 | Description: Volume applet |
9 | Volume applet for the Opie environment taskbar. | 9 | Volume applet for the Opie environment taskbar. |
diff --git a/core/applets/volumeapplet/volume.cpp b/core/applets/volumeapplet/volume.cpp index 35dbf22..445cc8b 100644 --- a/core/applets/volumeapplet/volume.cpp +++ b/core/applets/volumeapplet/volume.cpp | |||
@@ -4,196 +4,322 @@ | |||
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #include "volume.h" | 21 | #include "volume.h" |
22 | 22 | ||
23 | #include <qpe/resource.h> | 23 | #include <qpe/resource.h> |
24 | #include <qpe/qpeapplication.h> | 24 | #include <qpe/qpeapplication.h> |
25 | #include <qpe/config.h> | 25 | #include <qpe/config.h> |
26 | #if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) | 26 | #if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) |
27 | #include <qpe/qcopenvelope_qws.h> | 27 | #include <qpe/qcopenvelope_qws.h> |
28 | #endif | 28 | #endif |
29 | 29 | ||
30 | #include <qpainter.h> | 30 | #include <qpainter.h> |
31 | #include <qcheckbox.h> | 31 | #include <qcheckbox.h> |
32 | #include <qslider.h> | 32 | #include <qslider.h> |
33 | #include <qlayout.h> | 33 | #include <qlayout.h> |
34 | #include <qframe.h> | 34 | #include <qframe.h> |
35 | #include <qpixmap.h> | 35 | #include <qpixmap.h> |
36 | #include <qlabel.h> | ||
36 | 37 | ||
37 | 38 | VolumeControl::VolumeControl( bool showMic, QWidget *parent, const char *name ) | |
38 | VolumeControl::VolumeControl( QWidget *parent, const char *name ) | ||
39 | : QFrame( parent, name, WDestructiveClose | WStyle_StaysOnTop | WType_Popup ) | 39 | : QFrame( parent, name, WDestructiveClose | WStyle_StaysOnTop | WType_Popup ) |
40 | { | 40 | { |
41 | setFrameStyle( QFrame::PopupPanel | QFrame::Raised ); | 41 | setFrameStyle( QFrame::PopupPanel | QFrame::Raised ); |
42 | 42 | createView(showMic); | |
43 | QVBoxLayout *vbox = new QVBoxLayout( this ); | 43 | } |
44 | slider = new QSlider( this ); | 44 | |
45 | muteBox = new QCheckBox( tr("Mute"), this ); | 45 | void VolumeControl::createView(bool showMic) |
46 | slider->setRange( 0, 100 ); | 46 | { |
47 | slider->setTickmarks( QSlider::Both ); | 47 | Config cfg("Sound"); |
48 | slider->setTickInterval( 20 ); | 48 | cfg.setGroup("System"); |
49 | slider->setFocusPolicy( QWidget::NoFocus ); | 49 | |
50 | muteBox->setFocusPolicy( QWidget::NoFocus ); | 50 | QVBoxLayout *vbox = new QVBoxLayout( this ); |
51 | vbox->setMargin( 6 ); | 51 | QHBoxLayout *hbox = NULL; |
52 | vbox->setSpacing( 3 ); | 52 | |
53 | vbox->addWidget( slider, 0, Qt::AlignVCenter | Qt::AlignHCenter ); | 53 | slider = new QSlider( this ); |
54 | vbox->addWidget( muteBox ); | 54 | slider->setRange( 0, 100 ); |
55 | setFixedHeight( 100 ); | 55 | slider->setTickmarks( QSlider::Both ); |
56 | setFixedWidth( sizeHint().width() ); | 56 | slider->setTickInterval( 20 ); |
57 | setFocusPolicy(QWidget::NoFocus); | 57 | slider->setFocusPolicy( QWidget::NoFocus ); |
58 | slider->setValue(cfg.readNumEntry("Volume")); | ||
59 | |||
60 | QVBoxLayout *sbox = new QVBoxLayout(this); | ||
61 | sbox->setMargin( 3 ); | ||
62 | sbox->setSpacing( 3 ); | ||
63 | sbox->addWidget( new QLabel("Vol", this) , 0, Qt::AlignVCenter | Qt::AlignHCenter ); | ||
64 | sbox->addWidget( slider, 0, Qt::AlignVCenter | Qt::AlignHCenter ); | ||
65 | |||
66 | if (showMic == TRUE) | ||
67 | { | ||
68 | mic = new QSlider(this); | ||
69 | mic->setRange( 0, 100 ); | ||
70 | mic->setTickmarks( QSlider::Both ); | ||
71 | mic->setTickInterval( 20 ); | ||
72 | mic->setFocusPolicy( QWidget::NoFocus ); | ||
73 | mic->setValue(cfg.readNumEntry("Mic")); | ||
74 | |||
75 | QVBoxLayout *mbox = new QVBoxLayout(this); | ||
76 | mbox->setMargin( 3 ); | ||
77 | mbox->setSpacing( 3 ); | ||
78 | mbox->addWidget( new QLabel("Mic", this) , 0, Qt::AlignVCenter | Qt::AlignHCenter ); | ||
79 | mbox->addWidget( mic, 0, Qt::AlignVCenter | Qt::AlignHCenter ); | ||
80 | |||
81 | hbox = new QHBoxLayout( this ); | ||
82 | hbox->setMargin( 3 ); | ||
83 | hbox->setSpacing( 3 ); | ||
84 | hbox->addLayout( sbox, 1); | ||
85 | hbox->addLayout( mbox, 1); | ||
86 | } | ||
87 | |||
88 | muteBox = new QCheckBox( tr("Mute"), this ); | ||
89 | muteBox->setFocusPolicy( QWidget::NoFocus ); | ||
90 | |||
91 | vbox->setMargin( 3 ); | ||
92 | vbox->setSpacing( 0 ); | ||
93 | if (showMic == TRUE) | ||
94 | vbox->addLayout( hbox, 1 ); | ||
95 | else | ||
96 | vbox->addLayout( sbox, 1); | ||
97 | vbox->addWidget( muteBox, 0, Qt::AlignVCenter | Qt::AlignHCenter ); | ||
98 | |||
99 | setFixedHeight( 120 ); | ||
100 | setFixedWidth( sizeHint().width() ); | ||
101 | setFocusPolicy(QWidget::NoFocus); | ||
58 | } | 102 | } |
59 | 103 | ||
60 | void VolumeControl::keyPressEvent( QKeyEvent *e) | 104 | void VolumeControl::keyPressEvent( QKeyEvent *e) |
61 | { | 105 | { |
62 | switch(e->key()) { | 106 | switch(e->key()) |
107 | { | ||
63 | case Key_Up: | 108 | case Key_Up: |
64 | slider->subtractStep(); | 109 | slider->subtractStep(); |
65 | break; | 110 | break; |
66 | case Key_Down: | 111 | case Key_Down: |
67 | slider->addStep(); | 112 | slider->addStep(); |
68 | break; | 113 | break; |
69 | case Key_Space: | 114 | case Key_Space: |
70 | muteBox->toggle(); | 115 | muteBox->toggle(); |
71 | break; | 116 | break; |
72 | case Key_Escape: | 117 | case Key_Escape: |
73 | close(); | 118 | close(); |
74 | break; | 119 | break; |
75 | } | 120 | } |
76 | } | 121 | } |
77 | 122 | ||
78 | //=========================================================================== | 123 | //=========================================================================== |
79 | 124 | ||
80 | VolumeApplet::VolumeApplet( QWidget *parent, const char *name ) | 125 | VolumeApplet::VolumeApplet( QWidget *parent, const char *name ) |
81 | : QWidget( parent, name ) | 126 | : QWidget( parent, name ) |
82 | { | 127 | { |
83 | setFixedHeight( 18 ); | 128 | Config cfg("Sound"); |
84 | setFixedWidth( 14 ); | 129 | cfg.setGroup("System"); |
85 | volumePixmap = Resource::loadPixmap( "volume" ); | 130 | |
86 | muted = FALSE; // ### read from pref | 131 | setFixedHeight( 18 ); |
87 | volumePercent = 50; // ### read from pref | 132 | setFixedWidth( 14 ); |
88 | connect( qApp, SIGNAL( volumeChanged(bool) ), this, SLOT( volumeChanged(bool) ) ); | 133 | |
89 | writeSystemVolume(); | 134 | volumePixmap = Resource::loadPixmap( "volume" ); |
135 | |||
136 | volumePercent = cfg.readNumEntry("Volume",50); | ||
137 | micPercent = cfg.readNumEntry("Mic", 50); | ||
138 | muted = FALSE; // ### read from pref | ||
139 | micMuted = FALSE; // ### read from pref | ||
140 | |||
141 | advancedTimer = new QTimer(this); | ||
142 | |||
143 | connect( qApp, SIGNAL( volumeChanged(bool) ), this, SLOT( volumeChanged(bool) ) ); | ||
144 | connect( qApp, SIGNAL( micChanged(bool) ), this, SLOT ( micChanged(bool) ) ); | ||
145 | connect( advancedTimer, SIGNAL( timeout() ),this, SLOT( advVolControl()) ); | ||
146 | |||
147 | writeSystemVolume(); | ||
148 | writeSystemMic(); | ||
90 | } | 149 | } |
91 | 150 | ||
92 | VolumeApplet::~VolumeApplet() | 151 | VolumeApplet::~VolumeApplet() |
93 | { | 152 | { |
94 | } | 153 | } |
95 | 154 | ||
96 | void VolumeApplet::mousePressEvent( QMouseEvent *) | 155 | void VolumeApplet::keyPressEvent ( QKeyEvent * e ) |
156 | { | ||
157 | QString s; | ||
158 | s.setNum(e->key()); | ||
159 | qWarning(s); | ||
160 | } | ||
161 | void VolumeApplet::mousePressEvent( QMouseEvent * ) | ||
162 | { | ||
163 | advancedTimer->start( 750, TRUE ); | ||
164 | } | ||
165 | |||
166 | void VolumeApplet::mouseReleaseEvent( QMouseEvent * ) | ||
97 | { | 167 | { |
98 | // Create a small volume control window to adjust the volume with | 168 | showVolControl(FALSE); |
99 | VolumeControl *vc = new VolumeControl; | 169 | } |
100 | vc->slider->setValue( 100 - volumePercent ); | 170 | |
101 | vc->muteBox->setChecked( muted ); | 171 | void VolumeApplet::advVolControl() |
102 | connect( vc->slider, SIGNAL( valueChanged( int ) ), this, SLOT( sliderMoved( int ) ) ); | 172 | { |
103 | connect( vc->muteBox, SIGNAL( toggled( bool ) ), this, SLOT( mute( bool ) ) ); | 173 | showVolControl(TRUE); |
104 | QPoint curPos = mapToGlobal( rect().topLeft() ); | 174 | } |
105 | vc->move( curPos.x()-(vc->sizeHint().width()-width())/2, curPos.y() - 100 ); | 175 | |
106 | vc->show(); | 176 | void VolumeApplet::showVolControl(bool showMic) |
177 | { | ||
178 | Config cfg("Sound"); | ||
179 | cfg.setGroup("System"); | ||
180 | volumePercent = cfg.readNumEntry("Volume",50); | ||
181 | micPercent = cfg.readNumEntry("Mic", 50); | ||
182 | |||
183 | // Create a small volume control window to adjust the volume with | ||
184 | VolumeControl *vc = new VolumeControl(showMic); | ||
185 | vc->slider->setValue( 100 - volumePercent ); | ||
186 | if (showMic) | ||
187 | { | ||
188 | vc->mic->setValue( 100 - micPercent ); | ||
189 | connect( vc->mic, SIGNAL( valueChanged( int ) ), this, SLOT( micMoved( int ) ) ); | ||
190 | } | ||
191 | |||
192 | vc->muteBox->setChecked( muted ); | ||
193 | connect( vc->slider, SIGNAL( valueChanged( int ) ), this, SLOT( sliderMoved( int ) ) ); | ||
194 | connect( vc->muteBox, SIGNAL( toggled( bool ) ), this, SLOT( mute( bool ) ) ); | ||
195 | QPoint curPos = mapToGlobal( rect().topLeft() ); | ||
196 | vc->move( curPos.x()-(vc->sizeHint().width()-width())/2, curPos.y() - 120 ); | ||
197 | vc->show(); | ||
198 | |||
199 | advancedTimer->stop(); | ||
107 | } | 200 | } |
108 | 201 | ||
109 | void VolumeApplet::volumeChanged( bool nowMuted ) | 202 | void VolumeApplet::volumeChanged( bool nowMuted ) |
110 | { | 203 | { |
111 | int previousVolume = volumePercent; | 204 | int previousVolume = volumePercent; |
112 | 205 | ||
113 | if ( !nowMuted ) | 206 | if ( !nowMuted ) |
114 | readSystemVolume(); | 207 | readSystemVolume(); |
115 | 208 | ||
116 | // Handle case where muting it toggled | 209 | // Handle case where muting it toggled |
117 | if ( muted != nowMuted ) { | 210 | if ( muted != nowMuted ) { |
118 | muted = nowMuted; | 211 | muted = nowMuted; |
119 | repaint( TRUE ); | 212 | repaint( TRUE ); |
120 | return; | 213 | return; |
121 | } | 214 | } |
122 | 215 | ||
123 | // Avoid over repainting | 216 | // Avoid over repainting |
124 | if ( previousVolume != volumePercent ) | 217 | if ( previousVolume != volumePercent ) |
125 | repaint( 2, height() - 3, width() - 4, 2, FALSE ); | 218 | repaint( 2, height() - 3, width() - 4, 2, FALSE ); |
126 | } | 219 | } |
127 | 220 | ||
221 | void VolumeApplet::micChanged( bool nowMuted ) | ||
222 | { | ||
223 | if (!nowMuted) | ||
224 | readSystemMic(); | ||
225 | micMuted = nowMuted; | ||
226 | } | ||
128 | 227 | ||
129 | void VolumeApplet::mute( bool toggled ) | 228 | void VolumeApplet::mute( bool toggled ) |
130 | { | 229 | { |
131 | muted = toggled; | 230 | muted = toggled; |
231 | |||
132 | // clear if removing mute | 232 | // clear if removing mute |
133 | repaint( !toggled ); | 233 | repaint( !toggled ); |
134 | writeSystemVolume(); | 234 | writeSystemVolume(); |
135 | } | 235 | } |
136 | 236 | ||
137 | 237 | ||
138 | void VolumeApplet::sliderMoved( int percent ) | 238 | void VolumeApplet::sliderMoved( int percent ) |
139 | { | 239 | { |
140 | setVolume( 100 - percent ); | 240 | setVolume( 100 - percent ); |
141 | } | 241 | } |
142 | 242 | ||
243 | void VolumeApplet::micMoved( int percent ) | ||
244 | { | ||
245 | setMic( 100 - percent ); | ||
246 | } | ||
143 | 247 | ||
144 | void VolumeApplet::readSystemVolume() | 248 | void VolumeApplet::readSystemVolume() |
145 | { | 249 | { |
146 | Config cfg("Sound"); | 250 | Config cfg("Sound"); |
147 | cfg.setGroup("System"); | 251 | cfg.setGroup("System"); |
148 | volumePercent = cfg.readNumEntry("Volume"); | 252 | volumePercent = cfg.readNumEntry("Volume"); |
149 | } | 253 | } |
150 | 254 | ||
255 | void VolumeApplet::readSystemMic() | ||
256 | { | ||
257 | Config cfg("Sound"); | ||
258 | cfg.setGroup("System"); | ||
259 | micPercent = cfg.readNumEntry("Mic"); | ||
260 | } | ||
151 | 261 | ||
152 | void VolumeApplet::setVolume( int percent ) | 262 | void VolumeApplet::setVolume( int percent ) |
153 | { | 263 | { |
154 | // clamp volume percent to be between 0 and 100 | 264 | // clamp volume percent to be between 0 and 100 |
155 | volumePercent = (percent < 0) ? 0 : ((percent > 100) ? 100 : percent); | 265 | volumePercent = (percent < 0) ? 0 : ((percent > 100) ? 100 : percent); |
156 | // repaint just the little volume rectangle | 266 | // repaint just the little volume rectangle |
157 | repaint( 2, height() - 3, width() - 4, 2, FALSE ); | 267 | repaint( 2, height() - 3, width() - 4, 2, FALSE ); |
158 | writeSystemVolume(); | 268 | writeSystemVolume(); |
159 | } | 269 | } |
160 | 270 | ||
271 | void VolumeApplet::setMic( int percent ) | ||
272 | { | ||
273 | // clamp volume percent to be between 0 and 100 | ||
274 | micPercent = (percent < 0) ? 0 : ((percent > 100) ? 100 : percent); | ||
275 | writeSystemMic(); | ||
276 | } | ||
161 | 277 | ||
162 | void VolumeApplet::writeSystemVolume() | 278 | void VolumeApplet::writeSystemVolume() |
163 | { | 279 | { |
164 | { | 280 | { |
165 | Config cfg("Sound"); | 281 | Config cfg("Sound"); |
166 | cfg.setGroup("System"); | 282 | cfg.setGroup("System"); |
167 | cfg.writeEntry("Volume",volumePercent); | 283 | cfg.writeEntry("Volume",volumePercent); |
168 | } | 284 | } |
169 | #if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) | 285 | #if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) |
170 | // Send notification that the volume has changed | 286 | // Send notification that the volume has changed |
171 | QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << muted; | 287 | QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << muted; |
172 | #endif | 288 | #endif |
173 | } | 289 | } |
174 | 290 | ||
291 | void VolumeApplet::writeSystemMic() | ||
292 | { | ||
293 | { | ||
294 | Config cfg("Sound"); | ||
295 | cfg.setGroup("System"); | ||
296 | cfg.writeEntry("Mic",micPercent); | ||
297 | } | ||
298 | #if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) | ||
299 | // Send notification that the volume has changed | ||
300 | QCopEnvelope( "QPE/System", "micChange(bool)" ) << micMuted; | ||
301 | #endif | ||
302 | } | ||
175 | 303 | ||
176 | void VolumeApplet::paintEvent( QPaintEvent* ) | 304 | void VolumeApplet::paintEvent( QPaintEvent* ) |
177 | { | 305 | { |
178 | QPainter p(this); | 306 | QPainter p(this); |
179 | 307 | ||
180 | if (volumePixmap.isNull()) | 308 | if (volumePixmap.isNull()) |
181 | volumePixmap = Resource::loadPixmap( "volume" ); | 309 | volumePixmap = Resource::loadPixmap( "volume" ); |
182 | p.drawPixmap( 0, 1, volumePixmap ); | 310 | p.drawPixmap( 0, 1, volumePixmap ); |
183 | p.setPen( darkGray ); | 311 | p.setPen( darkGray ); |
184 | p.drawRect( 1, height() - 4, width() - 2, 4 ); | 312 | p.drawRect( 1, height() - 4, width() - 2, 4 ); |
185 | 313 | ||
186 | int pixelsWide = volumePercent * (width() - 4) / 100; | 314 | int pixelsWide = volumePercent * (width() - 4) / 100; |
187 | p.fillRect( 2, height() - 3, pixelsWide, 2, red ); | 315 | p.fillRect( 2, height() - 3, pixelsWide, 2, red ); |
188 | p.fillRect( pixelsWide + 2, height() - 3, width() - 4 - pixelsWide, 2, lightGray ); | 316 | p.fillRect( pixelsWide + 2, height() - 3, width() - 4 - pixelsWide, 2, lightGray ); |
189 | 317 | ||
190 | if ( muted ) { | 318 | if ( muted ) { |
191 | p.setPen( red ); | 319 | p.setPen( red ); |
192 | p.drawLine( 1, 2, width() - 2, height() - 5 ); | 320 | p.drawLine( 1, 2, width() - 2, height() - 5 ); |
193 | p.drawLine( 1, 3, width() - 2, height() - 4 ); | 321 | p.drawLine( 1, 3, width() - 2, height() - 4 ); |
194 | p.drawLine( width() - 2, 2, 1, height() - 5 ); | 322 | p.drawLine( width() - 2, 2, 1, height() - 5 ); |
195 | p.drawLine( width() - 2, 3, 1, height() - 4 ); | 323 | p.drawLine( width() - 2, 3, 1, height() - 4 ); |
196 | } | 324 | } |
197 | } | 325 | } |
198 | |||
199 | |||
diff --git a/core/applets/volumeapplet/volume.h b/core/applets/volumeapplet/volume.h index 5704cad..cb0be72 100644 --- a/core/applets/volumeapplet/volume.h +++ b/core/applets/volumeapplet/volume.h | |||
@@ -1,75 +1,93 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #ifndef __VOLUME_APPLET_H__ | 20 | #ifndef __VOLUME_APPLET_H__ |
21 | #define __VOLUME_APPLET_H__ | 21 | #define __VOLUME_APPLET_H__ |
22 | 22 | ||
23 | 23 | ||
24 | #include <qwidget.h> | 24 | #include <qwidget.h> |
25 | #include <qframe.h> | 25 | #include <qframe.h> |
26 | #include <qpixmap.h> | 26 | #include <qpixmap.h> |
27 | #include <qguardedptr.h> | 27 | #include <qguardedptr.h> |
28 | #include <qtimer.h> | ||
28 | 29 | ||
29 | class QSlider; | 30 | class QSlider; |
30 | class QCheckBox; | 31 | class QCheckBox; |
31 | 32 | ||
32 | class VolumeControl : public QFrame | 33 | class VolumeControl : public QFrame |
33 | { | 34 | { |
34 | Q_OBJECT | 35 | Q_OBJECT |
35 | public: | 36 | public: |
36 | VolumeControl( QWidget *parent=0, const char *name=0 ); | 37 | VolumeControl( bool showMic=FALSE, QWidget *parent=0, const char *name=0 ); |
37 | 38 | ||
38 | public: | 39 | public: |
39 | QSlider *slider; | 40 | QSlider *slider; |
41 | QSlider *mic; | ||
40 | QCheckBox *muteBox; | 42 | QCheckBox *muteBox; |
41 | 43 | ||
42 | private: | 44 | private: |
43 | void keyPressEvent( QKeyEvent * ); | 45 | void keyPressEvent( QKeyEvent * ); |
46 | void createView(bool showMic = FALSE); | ||
44 | }; | 47 | }; |
45 | 48 | ||
46 | class VolumeApplet : public QWidget | 49 | class VolumeApplet : public QWidget |
47 | { | 50 | { |
48 | Q_OBJECT | 51 | Q_OBJECT |
49 | public: | 52 | public: |
50 | VolumeApplet( QWidget *parent = 0, const char *name=0 ); | 53 | VolumeApplet( QWidget *parent = 0, const char *name=0 ); |
51 | ~VolumeApplet(); | 54 | ~VolumeApplet(); |
52 | bool isMute( ) { return muted; } | 55 | bool isMute( ) { return muted; } |
53 | int percent( ) { return volumePercent; } | 56 | int percent( ) { return volumePercent; } |
54 | 57 | ||
55 | public slots: | 58 | public slots: |
56 | void volumeChanged( bool muted ); | 59 | void volumeChanged( bool muted ); |
60 | void micChanged( bool muted ); | ||
61 | |||
57 | void setVolume( int percent ); | 62 | void setVolume( int percent ); |
63 | void setMic( int percent ); | ||
64 | |||
58 | void sliderMoved( int percent ); | 65 | void sliderMoved( int percent ); |
66 | void micMoved( int percent ); | ||
59 | void mute( bool ); | 67 | void mute( bool ); |
60 | 68 | ||
69 | void showVolControl(bool showMic = FALSE); | ||
70 | void advVolControl(); | ||
71 | |||
61 | private: | 72 | private: |
62 | void readSystemVolume(); | 73 | void readSystemVolume(); |
74 | void readSystemMic(); | ||
75 | |||
63 | void writeSystemVolume(); | 76 | void writeSystemVolume(); |
77 | void writeSystemMic(); | ||
78 | |||
79 | void keyPressEvent ( QKeyEvent * e ); | ||
64 | void mousePressEvent( QMouseEvent * ); | 80 | void mousePressEvent( QMouseEvent * ); |
81 | void mouseReleaseEvent( QMouseEvent *); | ||
65 | void paintEvent( QPaintEvent* ); | 82 | void paintEvent( QPaintEvent* ); |
66 | 83 | ||
67 | private: | 84 | private: |
68 | int volumePercent; | 85 | int volumePercent, micPercent; |
69 | bool muted; | 86 | bool muted, micMuted; |
70 | QPixmap volumePixmap; | 87 | QPixmap volumePixmap; |
88 | QTimer *advancedTimer; | ||
71 | }; | 89 | }; |
72 | 90 | ||
73 | 91 | ||
74 | #endif // __VOLUME_APPLET_H__ | 92 | #endif // __VOLUME_APPLET_H__ |
75 | 93 | ||