author | llornkcor <llornkcor> | 2002-04-07 00:46:35 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-04-07 00:46:35 (UTC) |
commit | e237c0758206c34f96c11870e033412b89e37463 (patch) (unidiff) | |
tree | ff61337aafa002a494a134cb61daaeda10aa0a44 /core | |
parent | 014a5c29fc8a1b2e6bc2ec550134163bea86443c (diff) | |
download | opie-e237c0758206c34f96c11870e033412b89e37463.zip opie-e237c0758206c34f96c11870e033412b89e37463.tar.gz opie-e237c0758206c34f96c11870e033412b89e37463.tar.bz2 |
re-commit buttons
-rw-r--r-- | core/applets/volumeapplet/volume.cpp | 176 | ||||
-rw-r--r-- | core/applets/volumeapplet/volume.h | 45 |
2 files changed, 185 insertions, 36 deletions
diff --git a/core/applets/volumeapplet/volume.cpp b/core/applets/volumeapplet/volume.cpp index ee9eab3..344f86f 100644 --- a/core/applets/volumeapplet/volume.cpp +++ b/core/applets/volumeapplet/volume.cpp | |||
@@ -1,107 +1,152 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of the 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 | |||
21 | #include "volume.h" | 22 | #include "volume.h" |
22 | 23 | ||
23 | #include <qpe/resource.h> | 24 | #include <qpe/resource.h> |
24 | #include <qpe/qpeapplication.h> | 25 | #include <qpe/qpeapplication.h> |
25 | #include <qpe/config.h> | 26 | #include <qpe/config.h> |
26 | #if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) | 27 | #if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) |
27 | #include <qpe/qcopenvelope_qws.h> | 28 | #include <qpe/qcopenvelope_qws.h> |
28 | #endif | 29 | #endif |
29 | 30 | ||
30 | #include <qpainter.h> | 31 | #include <qpainter.h> |
31 | #include <qcheckbox.h> | 32 | #include <qcheckbox.h> |
32 | #include <qslider.h> | 33 | #include <qslider.h> |
33 | #include <qlayout.h> | 34 | #include <qlayout.h> |
34 | #include <qframe.h> | 35 | #include <qframe.h> |
35 | #include <qpixmap.h> | 36 | #include <qpixmap.h> |
37 | #include <qlabel.h> | ||
38 | |||
36 | #include <qpushbutton.h> | 39 | #include <qpushbutton.h> |
37 | #include <qtimer.h> | 40 | #include <qtimer.h> |
38 | 41 | ||
39 | #define RATE_TIMER_INTERVAL 100 | 42 | #define RATE_TIMER_INTERVAL 100 |
40 | // Ten times per second is fine (RATE_TIMER_INTERVAL 100). A shorter time | 43 | // Ten times per second is fine (RATE_TIMER_INTERVAL 100). A shorter time |
41 | // results in "hanging" buttons on the iPAQ due to quite high CPU consumption. | 44 | // results in "hanging" buttons on the iPAQ due to quite high CPU consumption. |
42 | 45 | ||
43 | VolumeControl::VolumeControl( QWidget *parent, const char *name ) | 46 | VolumeControl::VolumeControl( bool showMic, QWidget *parent, const char *name ) |
44 | : QFrame( parent, name, WDestructiveClose | WStyle_StaysOnTop | WType_Popup ) | 47 | : QFrame( parent, name, WDestructiveClose | WStyle_StaysOnTop | WType_Popup ) |
45 | { | 48 | { |
46 | setFrameStyle( QFrame::PopupPanel | QFrame::Raised ); | 49 | setFrameStyle( QFrame::PopupPanel | QFrame::Raised ); |
50 | createView(showMic); | ||
51 | } | ||
52 | |||
53 | void VolumeControl::createView(bool showMic) | ||
54 | { | ||
55 | Config cfg("Sound"); | ||
56 | cfg.setGroup("System"); | ||
57 | //showMic = TRUE; | ||
58 | QHBoxLayout *hboxLayout = new QHBoxLayout(this); | ||
59 | hboxLayout->setMargin( 3 ); | ||
60 | hboxLayout->setSpacing( 0); | ||
47 | 61 | ||
48 | QVBoxLayout *vboxButtons = new QVBoxLayout; | 62 | QVBoxLayout *vboxButtons = new QVBoxLayout(this); |
49 | upButton = new QPushButton( this ); | 63 | upButton = new QPushButton( this ); |
50 | upButton->setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Expanding ) ); | 64 | upButton->setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Expanding ) ); |
51 | upButton->setPixmap( Resource::loadPixmap( "up" ) ); | 65 | upButton->setPixmap( Resource::loadPixmap( "up" ) ); |
52 | downButton = new QPushButton( this ); | 66 | downButton = new QPushButton( this ); |
53 | downButton->setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Expanding ) ); | 67 | downButton->setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Expanding ) ); |
54 | downButton->setPixmap( Resource::loadPixmap( "down" ) ); | 68 | downButton->setPixmap( Resource::loadPixmap( "down" ) ); |
55 | vboxButtons->setSpacing( 2 ); | 69 | vboxButtons->setSpacing( 2 ); |
70 | |||
56 | vboxButtons->addWidget( upButton ); | 71 | vboxButtons->addWidget( upButton ); |
57 | vboxButtons->addWidget( downButton ); | 72 | vboxButtons->addWidget( downButton ); |
58 | 73 | ||
59 | QHBoxLayout *hbox = new QHBoxLayout; | 74 | QVBoxLayout *vbox = new QVBoxLayout( this ); |
75 | QHBoxLayout *hbox = NULL; | ||
76 | |||
60 | slider = new QSlider( this ); | 77 | slider = new QSlider( this ); |
61 | slider->setRange( 0, 100 ); | 78 | slider->setRange( 0, 100 ); |
62 | slider->setTickmarks( QSlider::Both ); | 79 | slider->setTickmarks( QSlider::Both ); |
63 | slider->setTickInterval( 20 ); | 80 | slider->setTickInterval( 20 ); |
64 | slider->setFocusPolicy( QWidget::NoFocus ); | 81 | slider->setFocusPolicy( QWidget::NoFocus ); |
65 | hbox->setSpacing( 4 ); | 82 | slider->setValue(cfg.readNumEntry("Volume")); |
66 | hbox->addWidget( slider ); | 83 | |
67 | hbox->addLayout( vboxButtons ); | 84 | QVBoxLayout *sbox = new QVBoxLayout(this); |
85 | sbox->setMargin( 3 ); | ||
86 | sbox->setSpacing( 3 ); | ||
87 | sbox->addWidget( new QLabel("Vol", this) , 0, Qt::AlignVCenter | Qt::AlignHCenter ); | ||
88 | sbox->addWidget( slider, 0, Qt::AlignVCenter | Qt::AlignHCenter ); | ||
89 | |||
90 | if (showMic == TRUE) { | ||
91 | mic = new QSlider(this); | ||
92 | mic->setRange( 0, 100 ); | ||
93 | mic->setTickmarks( QSlider::Both ); | ||
94 | mic->setTickInterval( 20 ); | ||
95 | mic->setFocusPolicy( QWidget::NoFocus ); | ||
96 | mic->setValue(cfg.readNumEntry("Mic")); | ||
97 | |||
98 | QVBoxLayout *mbox = new QVBoxLayout(this); | ||
99 | mbox->setMargin( 3 ); | ||
100 | mbox->setSpacing( 3 ); | ||
101 | mbox->addWidget( new QLabel("Mic", this) , 0, Qt::AlignVCenter | Qt::AlignHCenter ); | ||
102 | mbox->addWidget( mic, 0, Qt::AlignVCenter | Qt::AlignHCenter ); | ||
103 | |||
104 | hbox = new QHBoxLayout( this ); | ||
105 | hbox->setMargin( 3 ); | ||
106 | hbox->setSpacing( 3 ); | ||
107 | hbox->addLayout( sbox, 1); | ||
108 | hbox->addLayout( mbox, 1); | ||
109 | } | ||
68 | 110 | ||
69 | QVBoxLayout *vbox = new QVBoxLayout( this ); | ||
70 | QFrame *separator = new QFrame( this ); | ||
71 | separator->setFrameStyle( QFrame::HLine | QFrame::Sunken ); | ||
72 | muteBox = new QCheckBox( tr("Mute"), this ); | 111 | muteBox = new QCheckBox( tr("Mute"), this ); |
73 | muteBox->setFocusPolicy( QWidget::NoFocus ); | 112 | muteBox->setFocusPolicy( QWidget::NoFocus ); |
74 | vbox->setSpacing( 4 ); | 113 | |
75 | vbox->setMargin( 6 ); | 114 | vbox->setMargin( 3 ); |
76 | vbox->addLayout( hbox ); | 115 | vbox->setSpacing( 0 ); |
77 | vbox->addWidget( separator ); | 116 | if (showMic == TRUE) |
117 | vbox->addLayout( hbox, 1 ); | ||
118 | else | ||
119 | vbox->addLayout( sbox, 1); | ||
78 | vbox->addWidget( muteBox, 0, Qt::AlignVCenter | Qt::AlignHCenter ); | 120 | vbox->addWidget( muteBox, 0, Qt::AlignVCenter | Qt::AlignHCenter ); |
79 | 121 | ||
80 | setFixedHeight( 100 ); | 122 | hboxLayout->addLayout( vboxButtons ); |
123 | hboxLayout->addLayout(vbox); | ||
124 | |||
125 | setFixedHeight( 120 ); | ||
81 | setFixedWidth( sizeHint().width() ); | 126 | setFixedWidth( sizeHint().width() ); |
82 | setFocusPolicy(QWidget::NoFocus); | 127 | setFocusPolicy(QWidget::NoFocus); |
83 | |||
84 | connect( upButton, SIGNAL( pressed() ), this, SLOT( ButtonChanged() ) ); | 128 | connect( upButton, SIGNAL( pressed() ), this, SLOT( ButtonChanged() ) ); |
85 | connect( upButton, SIGNAL( released() ), this, SLOT( ButtonChanged() ) ); | 129 | connect( upButton, SIGNAL( released() ), this, SLOT( ButtonChanged() ) ); |
86 | connect( downButton, SIGNAL( pressed() ), this, SLOT( ButtonChanged() ) ); | 130 | connect( downButton, SIGNAL( pressed() ), this, SLOT( ButtonChanged() ) ); |
87 | connect( downButton, SIGNAL( released() ), this, SLOT( ButtonChanged() ) ); | 131 | connect( downButton, SIGNAL( released() ), this, SLOT( ButtonChanged() ) ); |
88 | 132 | ||
89 | rateTimer = new QTimer(this); | 133 | rateTimer = new QTimer(this); |
90 | connect( rateTimer, SIGNAL( timeout() ), this, SLOT( rateTimerDone() ) ); | 134 | connect( rateTimer, SIGNAL( timeout() ), this, SLOT( rateTimerDone() ) ); |
91 | } | 135 | } |
92 | 136 | ||
93 | void VolumeControl::keyPressEvent( QKeyEvent *e) | 137 | void VolumeControl::keyPressEvent( QKeyEvent *e) |
94 | { | 138 | { |
95 | switch(e->key()) { | 139 | switch(e->key()) |
140 | { | ||
96 | case Key_Up: | 141 | case Key_Up: |
97 | slider->subtractStep(); | 142 | slider->subtractStep(); |
98 | break; | 143 | break; |
99 | case Key_Down: | 144 | case Key_Down: |
100 | slider->addStep(); | 145 | slider->addStep(); |
101 | break; | 146 | break; |
102 | case Key_Space: | 147 | case Key_Space: |
103 | muteBox->toggle(); | 148 | muteBox->toggle(); |
104 | break; | 149 | break; |
105 | case Key_Escape: | 150 | case Key_Escape: |
106 | close(); | 151 | close(); |
107 | break; | 152 | break; |
@@ -125,111 +170,200 @@ void VolumeControl::rateTimerDone() | |||
125 | { | 170 | { |
126 | if ( upButton->isDown() ) | 171 | if ( upButton->isDown() ) |
127 | slider->setValue( slider->value() - 2 ); | 172 | slider->setValue( slider->value() - 2 ); |
128 | else // downButton->isDown() | 173 | else // downButton->isDown() |
129 | slider->setValue( slider->value() + 2 ); | 174 | slider->setValue( slider->value() + 2 ); |
130 | } | 175 | } |
131 | 176 | ||
132 | //=========================================================================== | 177 | //=========================================================================== |
133 | 178 | ||
134 | VolumeApplet::VolumeApplet( QWidget *parent, const char *name ) | 179 | VolumeApplet::VolumeApplet( QWidget *parent, const char *name ) |
135 | : QWidget( parent, name ) | 180 | : QWidget( parent, name ) |
136 | { | 181 | { |
182 | Config cfg("Sound"); | ||
183 | cfg.setGroup("System"); | ||
184 | |||
137 | setFixedHeight( 18 ); | 185 | setFixedHeight( 18 ); |
138 | setFixedWidth( 14 ); | 186 | setFixedWidth( 14 ); |
187 | |||
139 | volumePixmap = Resource::loadPixmap( "volume" ); | 188 | volumePixmap = Resource::loadPixmap( "volume" ); |
189 | |||
190 | volumePercent = cfg.readNumEntry("Volume",50); | ||
191 | micPercent = cfg.readNumEntry("Mic", 50); | ||
140 | muted = FALSE; // ### read from pref | 192 | muted = FALSE; // ### read from pref |
141 | volumePercent = 50; // ### read from pref | 193 | micMuted = FALSE; // ### read from pref |
194 | |||
195 | advancedTimer = new QTimer(this); | ||
196 | |||
142 | connect( qApp, SIGNAL( volumeChanged(bool) ), this, SLOT( volumeChanged(bool) ) ); | 197 | connect( qApp, SIGNAL( volumeChanged(bool) ), this, SLOT( volumeChanged(bool) ) ); |
198 | connect( qApp, SIGNAL( micChanged(bool) ), this, SLOT ( micChanged(bool) ) ); | ||
199 | connect( advancedTimer, SIGNAL( timeout() ),this, SLOT( advVolControl()) ); | ||
200 | |||
143 | writeSystemVolume(); | 201 | writeSystemVolume(); |
202 | writeSystemMic(); | ||
144 | } | 203 | } |
145 | 204 | ||
146 | VolumeApplet::~VolumeApplet() | 205 | VolumeApplet::~VolumeApplet() |
147 | { | 206 | { |
148 | } | 207 | } |
149 | 208 | ||
209 | void VolumeApplet::keyPressEvent ( QKeyEvent * e ) | ||
210 | { | ||
211 | QString s; | ||
212 | s.setNum(e->key()); | ||
213 | qWarning(s); | ||
214 | } | ||
150 | void VolumeApplet::mousePressEvent( QMouseEvent *) | 215 | void VolumeApplet::mousePressEvent( QMouseEvent *) |
151 | { | 216 | { |
217 | advancedTimer->start( 750, TRUE ); | ||
218 | } | ||
219 | |||
220 | void VolumeApplet::mouseReleaseEvent( QMouseEvent * ) | ||
221 | { | ||
222 | showVolControl(FALSE); | ||
223 | } | ||
224 | |||
225 | void VolumeApplet::advVolControl() | ||
226 | { | ||
227 | showVolControl(TRUE); | ||
228 | } | ||
229 | |||
230 | void VolumeApplet::showVolControl(bool showMic) | ||
231 | { | ||
232 | Config cfg("Sound"); | ||
233 | cfg.setGroup("System"); | ||
234 | volumePercent = cfg.readNumEntry("Volume",50); | ||
235 | micPercent = cfg.readNumEntry("Mic", 50); | ||
236 | |||
152 | // Create a small volume control window to adjust the volume with | 237 | // Create a small volume control window to adjust the volume with |
153 | VolumeControl *vc = new VolumeControl; | 238 | VolumeControl *vc = new VolumeControl(showMic); |
154 | vc->slider->setValue( 100 - volumePercent ); | 239 | vc->slider->setValue( 100 - volumePercent ); |
240 | if (showMic) | ||
241 | { | ||
242 | vc->mic->setValue( 100 - micPercent ); | ||
243 | connect( vc->mic, SIGNAL( valueChanged( int ) ), this, SLOT( micMoved( int ) ) ); | ||
244 | } | ||
245 | |||
155 | vc->muteBox->setChecked( muted ); | 246 | vc->muteBox->setChecked( muted ); |
156 | connect( vc->slider, SIGNAL( valueChanged( int ) ), this, SLOT( sliderMoved( int ) ) ); | 247 | connect( vc->slider, SIGNAL( valueChanged( int ) ), this, SLOT( sliderMoved( int ) ) ); |
157 | connect( vc->muteBox, SIGNAL( toggled( bool ) ), this, SLOT( mute( bool ) ) ); | 248 | connect( vc->muteBox, SIGNAL( toggled( bool ) ), this, SLOT( mute( bool ) ) ); |
158 | QPoint curPos = mapToGlobal( rect().topLeft() ); | 249 | QPoint curPos = mapToGlobal( rect().topLeft() ); |
159 | vc->move( curPos.x()-(vc->sizeHint().width()-width())/2, curPos.y() - 100 ); | 250 | vc->move( curPos.x()-(vc->sizeHint().width()-width())/2, curPos.y() - 120 ); |
160 | vc->show(); | 251 | vc->show(); |
252 | |||
253 | advancedTimer->stop(); | ||
161 | } | 254 | } |
162 | 255 | ||
163 | void VolumeApplet::volumeChanged( bool nowMuted ) | 256 | void VolumeApplet::volumeChanged( bool nowMuted ) |
164 | { | 257 | { |
165 | int previousVolume = volumePercent; | 258 | int previousVolume = volumePercent; |
166 | 259 | ||
167 | if ( !nowMuted ) | 260 | if ( !nowMuted ) |
168 | readSystemVolume(); | 261 | readSystemVolume(); |
169 | 262 | ||
170 | // Handle case where muting it toggled | 263 | // Handle case where muting it toggled |
171 | if ( muted != nowMuted ) { | 264 | if ( muted != nowMuted ) { |
172 | muted = nowMuted; | 265 | muted = nowMuted; |
173 | repaint( TRUE ); | 266 | repaint( TRUE ); |
174 | return; | 267 | return; |
175 | } | 268 | } |
176 | 269 | ||
177 | // Avoid over repainting | 270 | // Avoid over repainting |
178 | if ( previousVolume != volumePercent ) | 271 | if ( previousVolume != volumePercent ) |
179 | repaint( 2, height() - 3, width() - 4, 2, FALSE ); | 272 | repaint( 2, height() - 3, width() - 4, 2, FALSE ); |
180 | } | 273 | } |
181 | 274 | ||
275 | void VolumeApplet::micChanged( bool nowMuted ) | ||
276 | { | ||
277 | if (!nowMuted) | ||
278 | readSystemMic(); | ||
279 | micMuted = nowMuted; | ||
280 | } | ||
281 | |||
182 | void VolumeApplet::mute( bool toggled ) | 282 | void VolumeApplet::mute( bool toggled ) |
183 | { | 283 | { |
184 | muted = toggled; | 284 | muted = toggled; |
285 | |||
185 | // clear if removing mute | 286 | // clear if removing mute |
186 | repaint( !toggled ); | 287 | repaint( !toggled ); |
187 | writeSystemVolume(); | 288 | writeSystemVolume(); |
188 | } | 289 | } |
189 | 290 | ||
291 | |||
190 | void VolumeApplet::sliderMoved( int percent ) | 292 | void VolumeApplet::sliderMoved( int percent ) |
191 | { | 293 | { |
192 | setVolume( 100 - percent ); | 294 | setVolume( 100 - percent ); |
193 | } | 295 | } |
194 | 296 | ||
297 | void VolumeApplet::micMoved( int percent ) | ||
298 | { | ||
299 | setMic( 100 - percent ); | ||
300 | } | ||
301 | |||
195 | void VolumeApplet::readSystemVolume() | 302 | void VolumeApplet::readSystemVolume() |
196 | { | 303 | { |
197 | Config cfg("Sound"); | 304 | Config cfg("Sound"); |
198 | cfg.setGroup("System"); | 305 | cfg.setGroup("System"); |
199 | volumePercent = cfg.readNumEntry("Volume"); | 306 | volumePercent = cfg.readNumEntry("Volume"); |
200 | } | 307 | } |
201 | 308 | ||
309 | void VolumeApplet::readSystemMic() | ||
310 | { | ||
311 | Config cfg("Sound"); | ||
312 | cfg.setGroup("System"); | ||
313 | micPercent = cfg.readNumEntry("Mic"); | ||
314 | } | ||
315 | |||
202 | void VolumeApplet::setVolume( int percent ) | 316 | void VolumeApplet::setVolume( int percent ) |
203 | { | 317 | { |
204 | // clamp volume percent to be between 0 and 100 | 318 | // clamp volume percent to be between 0 and 100 |
205 | volumePercent = (percent < 0) ? 0 : ((percent > 100) ? 100 : percent); | 319 | volumePercent = (percent < 0) ? 0 : ((percent > 100) ? 100 : percent); |
206 | // repaint just the little volume rectangle | 320 | // repaint just the little volume rectangle |
207 | repaint( 2, height() - 3, width() - 4, 2, FALSE ); | 321 | repaint( 2, height() - 3, width() - 4, 2, FALSE ); |
208 | writeSystemVolume(); | 322 | writeSystemVolume(); |
209 | } | 323 | } |
210 | 324 | ||
325 | void VolumeApplet::setMic( int percent ) | ||
326 | { | ||
327 | // clamp volume percent to be between 0 and 100 | ||
328 | micPercent = (percent < 0) ? 0 : ((percent > 100) ? 100 : percent); | ||
329 | writeSystemMic(); | ||
330 | } | ||
331 | |||
211 | void VolumeApplet::writeSystemVolume() | 332 | void VolumeApplet::writeSystemVolume() |
212 | { | 333 | { |
213 | { | 334 | { |
214 | Config cfg("Sound"); | 335 | Config cfg("Sound"); |
215 | cfg.setGroup("System"); | 336 | cfg.setGroup("System"); |
216 | cfg.writeEntry("Volume",volumePercent); | 337 | cfg.writeEntry("Volume",volumePercent); |
217 | } | 338 | } |
218 | #if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) | 339 | #if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) |
219 | // Send notification that the volume has changed | 340 | // Send notification that the volume has changed |
220 | QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << muted; | 341 | QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << muted; |
221 | #endif | 342 | #endif |
222 | } | 343 | } |
223 | 344 | ||
345 | void VolumeApplet::writeSystemMic() | ||
346 | { | ||
347 | { | ||
348 | Config cfg("Sound"); | ||
349 | cfg.setGroup("System"); | ||
350 | cfg.writeEntry("Mic",micPercent); | ||
351 | } | ||
352 | #if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) | ||
353 | // Send notification that the volume has changed | ||
354 | QCopEnvelope( "QPE/System", "micChange(bool)" ) << micMuted; | ||
355 | #endif | ||
356 | } | ||
357 | |||
224 | void VolumeApplet::paintEvent( QPaintEvent* ) | 358 | void VolumeApplet::paintEvent( QPaintEvent* ) |
225 | { | 359 | { |
226 | QPainter p(this); | 360 | QPainter p(this); |
227 | 361 | ||
228 | if (volumePixmap.isNull()) | 362 | if (volumePixmap.isNull()) |
229 | volumePixmap = Resource::loadPixmap( "volume" ); | 363 | volumePixmap = Resource::loadPixmap( "volume" ); |
230 | p.drawPixmap( 0, 1, volumePixmap ); | 364 | p.drawPixmap( 0, 1, volumePixmap ); |
231 | p.setPen( darkGray ); | 365 | p.setPen( darkGray ); |
232 | p.drawRect( 1, height() - 4, width() - 2, 4 ); | 366 | p.drawRect( 1, height() - 4, width() - 2, 4 ); |
233 | 367 | ||
234 | int pixelsWide = volumePercent * (width() - 4) / 100; | 368 | int pixelsWide = volumePercent * (width() - 4) / 100; |
235 | p.fillRect( 2, height() - 3, pixelsWide, 2, red ); | 369 | p.fillRect( 2, height() - 3, pixelsWide, 2, red ); |
diff --git a/core/applets/volumeapplet/volume.h b/core/applets/volumeapplet/volume.h index a982f53..9fc12d8 100644 --- a/core/applets/volumeapplet/volume.h +++ b/core/applets/volumeapplet/volume.h | |||
@@ -1,85 +1,100 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of the 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 | #ifndef __VOLUME_APPLET_H__ | 21 | #ifndef __VOLUME_APPLET_H__ |
21 | #define __VOLUME_APPLET_H__ | 22 | #define __VOLUME_APPLET_H__ |
22 | 23 | ||
23 | 24 | ||
24 | #include <qwidget.h> | 25 | #include <qwidget.h> |
25 | #include <qframe.h> | 26 | #include <qframe.h> |
26 | #include <qpixmap.h> | 27 | #include <qpixmap.h> |
27 | #include <qguardedptr.h> | 28 | #include <qguardedptr.h> |
29 | #include <qtimer.h> | ||
28 | 30 | ||
29 | class QSlider; | 31 | class QSlider; |
30 | class QCheckBox; | 32 | class QCheckBox; |
31 | class QPushButton; | ||
32 | class QTimer; | ||
33 | 33 | ||
34 | class VolumeControl : public QFrame | 34 | class VolumeControl : public QFrame |
35 | { | 35 | { |
36 | Q_OBJECT | 36 | Q_OBJECT |
37 | public: | 37 | public: |
38 | VolumeControl( QWidget *parent=0, const char *name=0 ); | 38 | VolumeControl( bool showMic=FALSE, QWidget *parent=0, const char *name=0 ); |
39 | 39 | ||
40 | public: | 40 | public: |
41 | QSlider *slider; | 41 | QSlider *slider; |
42 | QSlider *mic; | ||
42 | QCheckBox *muteBox; | 43 | QCheckBox *muteBox; |
43 | 44 | ||
44 | private: | 45 | private: |
45 | void keyPressEvent( QKeyEvent * ); | 46 | QPushButton *upButton; |
47 | QPushButton *downButton; | ||
48 | QTimer *rateTimer; | ||
46 | 49 | ||
50 | void keyPressEvent( QKeyEvent * ); | ||
51 | void createView(bool showMic = FALSE); | ||
47 | private slots: | 52 | private slots: |
48 | void ButtonChanged(); | 53 | void ButtonChanged(); |
49 | void rateTimerDone(); | 54 | void rateTimerDone(); |
50 | 55 | ||
51 | private: | ||
52 | QPushButton *upButton; | ||
53 | QPushButton *downButton; | ||
54 | QTimer *rateTimer; | ||
55 | }; | 56 | }; |
56 | 57 | ||
57 | class VolumeApplet : public QWidget | 58 | class VolumeApplet : public QWidget |
58 | { | 59 | { |
59 | Q_OBJECT | 60 | Q_OBJECT |
60 | public: | 61 | public: |
61 | VolumeApplet( QWidget *parent = 0, const char *name=0 ); | 62 | VolumeApplet( QWidget *parent = 0, const char *name=0 ); |
62 | ~VolumeApplet(); | 63 | ~VolumeApplet(); |
63 | bool isMute( ) { return muted; } | 64 | bool isMute( ) { return muted; } |
64 | int percent( ) { return volumePercent; } | 65 | int percent( ) { return volumePercent; } |
65 | 66 | ||
66 | public slots: | 67 | public slots: |
67 | void volumeChanged( bool muted ); | 68 | void volumeChanged( bool muted ); |
68 | void setVolume( int percent ); | 69 | void micChanged( bool muted ); |
69 | void sliderMoved( int percent ); | 70 | void sliderMoved( int percent ); |
70 | void mute( bool ); | 71 | void mute( bool ); |
71 | 72 | ||
73 | void micMoved( int percent ); | ||
74 | void setVolume( int percent ); | ||
75 | void setMic( int percent ); | ||
76 | |||
77 | void showVolControl(bool showMic = FALSE); | ||
78 | void advVolControl(); | ||
79 | |||
72 | private: | 80 | private: |
81 | int volumePercent, micPercent; | ||
82 | bool muted, micMuted; | ||
83 | QPixmap volumePixmap; | ||
84 | QTimer *advancedTimer; | ||
85 | |||
73 | void readSystemVolume(); | 86 | void readSystemVolume(); |
74 | void writeSystemVolume(); | 87 | void writeSystemVolume(); |
75 | void mousePressEvent( QMouseEvent * ); | 88 | void mousePressEvent( QMouseEvent * ); |
76 | void paintEvent( QPaintEvent* ); | 89 | void paintEvent( QPaintEvent* ); |
77 | 90 | ||
78 | private: | 91 | void readSystemMic(); |
79 | int volumePercent; | 92 | void keyPressEvent ( QKeyEvent * e ); |
80 | bool muted; | 93 | void mouseReleaseEvent( QMouseEvent *); |
81 | QPixmap volumePixmap; | 94 | void writeSystemMic(); |
95 | |||
82 | }; | 96 | }; |
83 | 97 | ||
84 | 98 | ||
85 | #endif // __VOLUME_APPLET_H__ | 99 | #endif // __VOLUME_APPLET_H__ |
100 | |||