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