-rw-r--r-- | core/applets/volumeapplet/volume.cpp | 1 | ||||
-rw-r--r-- | core/applets/volumeapplet/volumeappletimpl.cpp | 10 |
2 files changed, 7 insertions, 4 deletions
diff --git a/core/applets/volumeapplet/volume.cpp b/core/applets/volumeapplet/volume.cpp index e8921f0..069f8ab 100644 --- a/core/applets/volumeapplet/volume.cpp +++ b/core/applets/volumeapplet/volume.cpp | |||
@@ -1,432 +1,433 @@ | |||
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 | 20 | ||
21 | 21 | ||
22 | #include "volume.h" | 22 | #include "volume.h" |
23 | 23 | ||
24 | #include <qpe/resource.h> | 24 | #include <qpe/resource.h> |
25 | #include <qpe/qpeapplication.h> | 25 | #include <qpe/qpeapplication.h> |
26 | #include <qpe/config.h> | 26 | #include <qpe/config.h> |
27 | #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) |
28 | #include <qpe/qcopenvelope_qws.h> | 28 | #include <qpe/qcopenvelope_qws.h> |
29 | #endif | 29 | #endif |
30 | 30 | ||
31 | #include <qpainter.h> | 31 | #include <qpainter.h> |
32 | #include <qcheckbox.h> | 32 | #include <qcheckbox.h> |
33 | #include <qslider.h> | 33 | #include <qslider.h> |
34 | #include <qlayout.h> | 34 | #include <qlayout.h> |
35 | #include <qframe.h> | 35 | #include <qframe.h> |
36 | #include <qpixmap.h> | 36 | #include <qpixmap.h> |
37 | #include <qlabel.h> | 37 | #include <qlabel.h> |
38 | 38 | ||
39 | #include <qpushbutton.h> | 39 | #include <qpushbutton.h> |
40 | #include <qtimer.h> | 40 | #include <qtimer.h> |
41 | 41 | ||
42 | #define RATE_TIMER_INTERVAL 100 | 42 | #define RATE_TIMER_INTERVAL 100 |
43 | // 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 |
44 | // 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. |
45 | 45 | ||
46 | VolumeControl::VolumeControl( bool showMic, QWidget *parent, const char *name ) | 46 | VolumeControl::VolumeControl( bool showMic, QWidget *parent, const char *name ) |
47 | : QFrame( parent, name, WDestructiveClose | WStyle_StaysOnTop | WType_Popup ) | 47 | : QFrame( parent, name, WDestructiveClose | WStyle_StaysOnTop | WType_Popup ) |
48 | { | 48 | { |
49 | QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << TRUE; //mute | ||
49 | setFrameStyle( QFrame::PopupPanel | QFrame::Raised ); | 50 | setFrameStyle( QFrame::PopupPanel | QFrame::Raised ); |
50 | createView(showMic); | 51 | createView(showMic); |
51 | } | 52 | } |
52 | 53 | ||
53 | void VolumeControl::createView(bool showMic) | 54 | void VolumeControl::createView(bool showMic) |
54 | { | 55 | { |
55 | Config cfg("qpe"); | 56 | Config cfg("qpe"); |
56 | cfg.setGroup("Volume"); | 57 | cfg.setGroup("Volume"); |
57 | //showMic = TRUE; | 58 | //showMic = TRUE; |
58 | QHBoxLayout *hboxLayout = new QHBoxLayout(this); | 59 | QHBoxLayout *hboxLayout = new QHBoxLayout(this); |
59 | hboxLayout->setMargin( 3 ); | 60 | hboxLayout->setMargin( 3 ); |
60 | hboxLayout->setSpacing( 0); | 61 | hboxLayout->setSpacing( 0); |
61 | 62 | ||
62 | QVBoxLayout *vboxButtons = new QVBoxLayout(this); | 63 | QVBoxLayout *vboxButtons = new QVBoxLayout(this); |
63 | upButton = new QPushButton( this ); | 64 | upButton = new QPushButton( this ); |
64 | upButton->setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Expanding ) ); | 65 | upButton->setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Expanding ) ); |
65 | upButton->setPixmap( Resource::loadPixmap( "up" ) ); | 66 | upButton->setPixmap( Resource::loadPixmap( "up" ) ); |
66 | downButton = new QPushButton( this ); | 67 | downButton = new QPushButton( this ); |
67 | downButton->setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Expanding ) ); | 68 | downButton->setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Expanding ) ); |
68 | downButton->setPixmap( Resource::loadPixmap( "down" ) ); | 69 | downButton->setPixmap( Resource::loadPixmap( "down" ) ); |
69 | vboxButtons->setSpacing( 2 ); | 70 | vboxButtons->setSpacing( 2 ); |
70 | 71 | ||
71 | upButton->setFixedHeight(26); | 72 | upButton->setFixedHeight(26); |
72 | downButton->setFixedHeight(26); | 73 | downButton->setFixedHeight(26); |
73 | 74 | ||
74 | vboxButtons->addWidget( upButton ); | 75 | vboxButtons->addWidget( upButton ); |
75 | vboxButtons->addWidget( downButton ); | 76 | vboxButtons->addWidget( downButton ); |
76 | 77 | ||
77 | QVBoxLayout *vbox = new QVBoxLayout( this ); | 78 | QVBoxLayout *vbox = new QVBoxLayout( this ); |
78 | QHBoxLayout *hbox = NULL; | 79 | QHBoxLayout *hbox = NULL; |
79 | 80 | ||
80 | slider = new QSlider( this ); | 81 | slider = new QSlider( this ); |
81 | slider->setRange( 0, 100 ); | 82 | slider->setRange( 0, 100 ); |
82 | slider->setTickmarks( QSlider::Both ); | 83 | slider->setTickmarks( QSlider::Both ); |
83 | slider->setTickInterval( 20 ); | 84 | slider->setTickInterval( 20 ); |
84 | slider->setFocusPolicy( QWidget::NoFocus ); | 85 | slider->setFocusPolicy( QWidget::NoFocus ); |
85 | slider->setValue(cfg.readNumEntry("VolumePercent")); | 86 | slider->setValue(cfg.readNumEntry("VolumePercent")); |
86 | 87 | ||
87 | QVBoxLayout *sbox = new QVBoxLayout(this); | 88 | QVBoxLayout *sbox = new QVBoxLayout(this); |
88 | sbox->setMargin( 3 ); | 89 | sbox->setMargin( 3 ); |
89 | sbox->setSpacing( 3 ); | 90 | sbox->setSpacing( 3 ); |
90 | sbox->addWidget( new QLabel("Vol", this) , 0, Qt::AlignVCenter | Qt::AlignHCenter ); | 91 | sbox->addWidget( new QLabel("Vol", this) , 0, Qt::AlignVCenter | Qt::AlignHCenter ); |
91 | sbox->addWidget( slider, 0, Qt::AlignVCenter | Qt::AlignHCenter ); | 92 | sbox->addWidget( slider, 0, Qt::AlignVCenter | Qt::AlignHCenter ); |
92 | 93 | ||
93 | // if (showMic == TRUE) { | 94 | // if (showMic == TRUE) { |
94 | mic = new QSlider(this); | 95 | mic = new QSlider(this); |
95 | mic->setRange( 0, 100 ); | 96 | mic->setRange( 0, 100 ); |
96 | mic->setTickmarks( QSlider::Both ); | 97 | mic->setTickmarks( QSlider::Both ); |
97 | mic->setTickInterval( 20 ); | 98 | mic->setTickInterval( 20 ); |
98 | mic->setFocusPolicy( QWidget::NoFocus ); | 99 | mic->setFocusPolicy( QWidget::NoFocus ); |
99 | mic->setValue(cfg.readNumEntry("Mic")); | 100 | mic->setValue(cfg.readNumEntry("Mic")); |
100 | 101 | ||
101 | QVBoxLayout *mbox = new QVBoxLayout(this); | 102 | QVBoxLayout *mbox = new QVBoxLayout(this); |
102 | mbox->setMargin( 3 ); | 103 | mbox->setMargin( 3 ); |
103 | mbox->setSpacing( 3 ); | 104 | mbox->setSpacing( 3 ); |
104 | mbox->addWidget( new QLabel("Mic", this) , 0, Qt::AlignVCenter | Qt::AlignHCenter ); | 105 | mbox->addWidget( new QLabel("Mic", this) , 0, Qt::AlignVCenter | Qt::AlignHCenter ); |
105 | mbox->addWidget( mic, 0, Qt::AlignVCenter | Qt::AlignHCenter ); | 106 | mbox->addWidget( mic, 0, Qt::AlignVCenter | Qt::AlignHCenter ); |
106 | 107 | ||
107 | hbox = new QHBoxLayout( this ); | 108 | hbox = new QHBoxLayout( this ); |
108 | hbox->setMargin( 3 ); | 109 | hbox->setMargin( 3 ); |
109 | hbox->setSpacing( 3 ); | 110 | hbox->setSpacing( 3 ); |
110 | hbox->addLayout( sbox, 1); | 111 | hbox->addLayout( sbox, 1); |
111 | hbox->addLayout( mbox, 1); | 112 | hbox->addLayout( mbox, 1); |
112 | // } | 113 | // } |
113 | 114 | ||
114 | muteBox = new QCheckBox( tr("Mute"), this ); | 115 | muteBox = new QCheckBox( tr("Mute"), this ); |
115 | muteBox->setFocusPolicy( QWidget::NoFocus ); | 116 | muteBox->setFocusPolicy( QWidget::NoFocus ); |
116 | 117 | ||
117 | QVBoxLayout *klbox = new QVBoxLayout(this); | 118 | QVBoxLayout *klbox = new QVBoxLayout(this); |
118 | 119 | ||
119 | QLabel *Label1; | 120 | QLabel *Label1; |
120 | Label1 = new QLabel( this, "Label1" ); | 121 | Label1 = new QLabel( this, "Label1" ); |
121 | Label1->setText( tr( "Enable Sounds for:" )); | 122 | Label1->setText( tr( "Enable Sounds for:" )); |
122 | 123 | ||
123 | alarmSound = new QCheckBox( tr("Alarm Sound"), this ); | 124 | alarmSound = new QCheckBox( tr("Alarm Sound"), this ); |
124 | alarmSound->setFocusPolicy( QWidget::NoFocus ); | 125 | alarmSound->setFocusPolicy( QWidget::NoFocus ); |
125 | 126 | ||
126 | keyclicks = new QCheckBox( tr("Key Clicks"), this ); | 127 | keyclicks = new QCheckBox( tr("Key Clicks"), this ); |
127 | keyclicks->setFocusPolicy( QWidget::NoFocus ); | 128 | keyclicks->setFocusPolicy( QWidget::NoFocus ); |
128 | 129 | ||
129 | screentaps = new QCheckBox( tr("Screen taps"), this ); | 130 | screentaps = new QCheckBox( tr("Screen taps"), this ); |
130 | screentaps->setFocusPolicy( QWidget::NoFocus ); | 131 | screentaps->setFocusPolicy( QWidget::NoFocus ); |
131 | 132 | ||
132 | 133 | ||
133 | keyclicks->setChecked( cfg.readBoolEntry("KeySound",0)); | 134 | keyclicks->setChecked( cfg.readBoolEntry("KeySound",0)); |
134 | screentaps->setChecked( cfg.readBoolEntry("TouchSound",0)); | 135 | screentaps->setChecked( cfg.readBoolEntry("TouchSound",0)); |
135 | alarmSound->setChecked( cfg.readBoolEntry("AlarmSound",1)); | 136 | alarmSound->setChecked( cfg.readBoolEntry("AlarmSound",1)); |
136 | 137 | ||
137 | klbox->setMargin( 3 ); | 138 | klbox->setMargin( 3 ); |
138 | klbox->setSpacing( 0 ); | 139 | klbox->setSpacing( 0 ); |
139 | klbox->addWidget( Label1, 1); | 140 | klbox->addWidget( Label1, 1); |
140 | klbox->addWidget( alarmSound, 1); | 141 | klbox->addWidget( alarmSound, 1); |
141 | klbox->addWidget( keyclicks, 1); | 142 | klbox->addWidget( keyclicks, 1); |
142 | klbox->addWidget( screentaps, 1); | 143 | klbox->addWidget( screentaps, 1); |
143 | vbox->setMargin( 3 ); | 144 | vbox->setMargin( 3 ); |
144 | vbox->setSpacing( 0 ); | 145 | vbox->setSpacing( 0 ); |
145 | // if (showMic == TRUE) | 146 | // if (showMic == TRUE) |
146 | vbox->addLayout( hbox, 1 ); | 147 | vbox->addLayout( hbox, 1 ); |
147 | // else | 148 | // else |
148 | // vbox->addLayout( sbox, 1); | 149 | // vbox->addLayout( sbox, 1); |
149 | vbox->addWidget( muteBox, 0, Qt::AlignVCenter | Qt::AlignHCenter ); | 150 | vbox->addWidget( muteBox, 0, Qt::AlignVCenter | Qt::AlignHCenter ); |
150 | 151 | ||
151 | hboxLayout->addLayout( vboxButtons ); | 152 | hboxLayout->addLayout( vboxButtons ); |
152 | hboxLayout->addLayout( vbox); | 153 | hboxLayout->addLayout( vbox); |
153 | hboxLayout->addLayout( klbox); | 154 | hboxLayout->addLayout( klbox); |
154 | 155 | ||
155 | 156 | ||
156 | setFixedHeight( 120); | 157 | setFixedHeight( 120); |
157 | // setFixedWidth( sizeHint().width() ); | 158 | // setFixedWidth( sizeHint().width() ); |
158 | setFocusPolicy(QWidget::NoFocus); | 159 | setFocusPolicy(QWidget::NoFocus); |
159 | connect( upButton, SIGNAL( pressed() ), this, SLOT( ButtonChanged() ) ); | 160 | connect( upButton, SIGNAL( pressed() ), this, SLOT( ButtonChanged() ) ); |
160 | connect( upButton, SIGNAL( released() ), this, SLOT( ButtonChanged() ) ); | 161 | connect( upButton, SIGNAL( released() ), this, SLOT( ButtonChanged() ) ); |
161 | connect( downButton, SIGNAL( pressed() ), this, SLOT( ButtonChanged() ) ); | 162 | connect( downButton, SIGNAL( pressed() ), this, SLOT( ButtonChanged() ) ); |
162 | connect( downButton, SIGNAL( released() ), this, SLOT( ButtonChanged() ) ); | 163 | connect( downButton, SIGNAL( released() ), this, SLOT( ButtonChanged() ) ); |
163 | 164 | ||
164 | rateTimer = new QTimer(this); | 165 | rateTimer = new QTimer(this); |
165 | connect( rateTimer, SIGNAL( timeout() ), this, SLOT( rateTimerDone() ) ); | 166 | connect( rateTimer, SIGNAL( timeout() ), this, SLOT( rateTimerDone() ) ); |
166 | } | 167 | } |
167 | 168 | ||
168 | void VolumeControl::keyPressEvent( QKeyEvent *e) | 169 | void VolumeControl::keyPressEvent( QKeyEvent *e) |
169 | { | 170 | { |
170 | switch(e->key()) | 171 | switch(e->key()) |
171 | { | 172 | { |
172 | case Key_Up: | 173 | case Key_Up: |
173 | slider->subtractStep(); | 174 | slider->subtractStep(); |
174 | break; | 175 | break; |
175 | case Key_Down: | 176 | case Key_Down: |
176 | slider->addStep(); | 177 | slider->addStep(); |
177 | break; | 178 | break; |
178 | case Key_Space: | 179 | case Key_Space: |
179 | muteBox->toggle(); | 180 | muteBox->toggle(); |
180 | break; | 181 | break; |
181 | case Key_Escape: | 182 | case Key_Escape: |
182 | close(); | 183 | close(); |
183 | break; | 184 | break; |
184 | } | 185 | } |
185 | } | 186 | } |
186 | 187 | ||
187 | void VolumeControl::ButtonChanged() | 188 | void VolumeControl::ButtonChanged() |
188 | { | 189 | { |
189 | if ( upButton->isDown() || downButton->isDown() ) | 190 | if ( upButton->isDown() || downButton->isDown() ) |
190 | { | 191 | { |
191 | rateTimerDone(); // Call it one time manually, otherwise it wont get | 192 | rateTimerDone(); // Call it one time manually, otherwise it wont get |
192 | // called at all when a button is pressed for a time | 193 | // called at all when a button is pressed for a time |
193 | // shorter than RATE_TIMER_INTERVAL. | 194 | // shorter than RATE_TIMER_INTERVAL. |
194 | rateTimer->start( RATE_TIMER_INTERVAL, false ); | 195 | rateTimer->start( RATE_TIMER_INTERVAL, false ); |
195 | } | 196 | } |
196 | else | 197 | else |
197 | rateTimer->stop(); | 198 | rateTimer->stop(); |
198 | } | 199 | } |
199 | 200 | ||
200 | void VolumeControl::rateTimerDone() | 201 | void VolumeControl::rateTimerDone() |
201 | { | 202 | { |
202 | if ( upButton->isDown() ) | 203 | if ( upButton->isDown() ) |
203 | slider->setValue( slider->value() - 2 ); | 204 | slider->setValue( slider->value() - 2 ); |
204 | else // downButton->isDown() | 205 | else // downButton->isDown() |
205 | slider->setValue( slider->value() + 2 ); | 206 | slider->setValue( slider->value() + 2 ); |
206 | } | 207 | } |
207 | 208 | ||
208 | //=========================================================================== | 209 | //=========================================================================== |
209 | 210 | ||
210 | VolumeApplet::VolumeApplet( QWidget *parent, const char *name ) | 211 | VolumeApplet::VolumeApplet( QWidget *parent, const char *name ) |
211 | : QWidget( parent, name ) | 212 | : QWidget( parent, name ) |
212 | { | 213 | { |
213 | Config cfg("qpe"); | 214 | Config cfg("qpe"); |
214 | cfg.setGroup("Volume"); | 215 | cfg.setGroup("Volume"); |
215 | 216 | ||
216 | setFixedHeight( 18 ); | 217 | setFixedHeight( 18 ); |
217 | setFixedWidth( 14 ); | 218 | setFixedWidth( 14 ); |
218 | 219 | ||
219 | volumePixmap = Resource::loadPixmap( "volume" ); | 220 | volumePixmap = Resource::loadPixmap( "volume" ); |
220 | 221 | ||
221 | volumePercent = cfg.readNumEntry("VolumePercent",50); | 222 | volumePercent = cfg.readNumEntry("VolumePercent",50); |
222 | micPercent = cfg.readNumEntry("Mic", 50); | 223 | micPercent = cfg.readNumEntry("Mic", 50); |
223 | muted = FALSE; // ### read from pref | 224 | muted = FALSE; // ### read from pref |
224 | micMuted = FALSE; // ### read from pref | 225 | micMuted = FALSE; // ### read from pref |
225 | 226 | ||
226 | advancedTimer = new QTimer(this); | 227 | advancedTimer = new QTimer(this); |
227 | 228 | ||
228 | connect( qApp, SIGNAL( volumeChanged(bool) ), this, SLOT( volumeChanged(bool) ) ); | 229 | connect( qApp, SIGNAL( volumeChanged(bool) ), this, SLOT( volumeChanged(bool) ) ); |
229 | connect( qApp, SIGNAL( micChanged(bool) ), this, SLOT ( micChanged(bool) ) ); | 230 | connect( qApp, SIGNAL( micChanged(bool) ), this, SLOT ( micChanged(bool) ) ); |
230 | connect( advancedTimer, SIGNAL( timeout() ),this, SLOT( advVolControl()) ); | 231 | connect( advancedTimer, SIGNAL( timeout() ),this, SLOT( advVolControl()) ); |
231 | 232 | ||
232 | writeSystemVolume(); | 233 | writeSystemVolume(); |
233 | writeSystemMic(); | 234 | writeSystemMic(); |
234 | } | 235 | } |
235 | 236 | ||
236 | VolumeApplet::~VolumeApplet() | 237 | VolumeApplet::~VolumeApplet() |
237 | { | 238 | { |
238 | } | 239 | } |
239 | 240 | ||
240 | void VolumeApplet::keyPressEvent ( QKeyEvent * e ) | 241 | void VolumeApplet::keyPressEvent ( QKeyEvent * e ) |
241 | { | 242 | { |
242 | QString s; | 243 | QString s; |
243 | s.setNum(e->key()); | 244 | s.setNum(e->key()); |
244 | qWarning(s); | 245 | qWarning(s); |
245 | } | 246 | } |
246 | void VolumeApplet::mousePressEvent( QMouseEvent * ) | 247 | void VolumeApplet::mousePressEvent( QMouseEvent * ) |
247 | { | 248 | { |
248 | advancedTimer->start( 750, TRUE ); | 249 | advancedTimer->start( 750, TRUE ); |
249 | } | 250 | } |
250 | 251 | ||
251 | void VolumeApplet::mouseReleaseEvent( QMouseEvent * ) | 252 | void VolumeApplet::mouseReleaseEvent( QMouseEvent * ) |
252 | { | 253 | { |
253 | showVolControl(FALSE); | 254 | showVolControl(FALSE); |
254 | } | 255 | } |
255 | 256 | ||
256 | void VolumeApplet::advVolControl() | 257 | void VolumeApplet::advVolControl() |
257 | { | 258 | { |
258 | showVolControl(TRUE); | 259 | showVolControl(TRUE); |
259 | } | 260 | } |
260 | 261 | ||
261 | void VolumeApplet::showVolControl(bool showMic) | 262 | void VolumeApplet::showVolControl(bool showMic) |
262 | { | 263 | { |
263 | Config cfg("qpe"); | 264 | Config cfg("qpe"); |
264 | cfg.setGroup("Volume"); | 265 | cfg.setGroup("Volume"); |
265 | volumePercent = cfg.readNumEntry("VolumePercent",50); | 266 | volumePercent = cfg.readNumEntry("VolumePercent",50); |
266 | micPercent = cfg.readNumEntry("Mic", 50); | 267 | micPercent = cfg.readNumEntry("Mic", 50); |
267 | 268 | ||
268 | // Create a small volume control window to adjust the volume with | 269 | // Create a small volume control window to adjust the volume with |
269 | VolumeControl *vc = new VolumeControl(showMic); | 270 | VolumeControl *vc = new VolumeControl(showMic); |
270 | vc->slider->setValue( 100 - volumePercent ); | 271 | vc->slider->setValue( 100 - volumePercent ); |
271 | // if (showMic) | 272 | // if (showMic) |
272 | // { | 273 | // { |
273 | vc->mic->setValue( 100 - micPercent ); | 274 | vc->mic->setValue( 100 - micPercent ); |
274 | connect( vc->mic, SIGNAL( valueChanged( int ) ), this, SLOT( micMoved( int ) ) ); | 275 | connect( vc->mic, SIGNAL( valueChanged( int ) ), this, SLOT( micMoved( int ) ) ); |
275 | // } | 276 | // } |
276 | 277 | ||
277 | vc->muteBox->setChecked( muted ); | 278 | vc->muteBox->setChecked( muted ); |
278 | connect( vc->slider, SIGNAL( valueChanged( int ) ), this, SLOT( sliderMoved( int ) ) ); | 279 | connect( vc->slider, SIGNAL( valueChanged( int ) ), this, SLOT( sliderMoved( int ) ) ); |
279 | connect( vc->muteBox, SIGNAL( toggled( bool ) ), this, SLOT( mute( bool ) ) ); | 280 | connect( vc->muteBox, SIGNAL( toggled( bool ) ), this, SLOT( mute( bool ) ) ); |
280 | 281 | ||
281 | Config config("qpe"); | 282 | Config config("qpe"); |
282 | config.setGroup("Volume"); | 283 | config.setGroup("Volume"); |
283 | 284 | ||
284 | vc->keyclicks->setChecked( config.readBoolEntry("KeySound",0)); | 285 | vc->keyclicks->setChecked( config.readBoolEntry("KeySound",0)); |
285 | vc->screentaps->setChecked( config.readBoolEntry("TouchSound",0)); | 286 | vc->screentaps->setChecked( config.readBoolEntry("TouchSound",0)); |
286 | vc->alarmSound->setChecked( config.readBoolEntry("AlarmSound",1)); | 287 | vc->alarmSound->setChecked( config.readBoolEntry("AlarmSound",1)); |
287 | 288 | ||
288 | connect( vc->alarmSound, SIGNAL(toggled(bool)), this, SLOT( alarmSoundCheckToggled(bool))); | 289 | connect( vc->alarmSound, SIGNAL(toggled(bool)), this, SLOT( alarmSoundCheckToggled(bool))); |
289 | connect( vc->keyclicks, SIGNAL(toggled(bool)), this, SLOT( keyclicksCheckToggled(bool))); | 290 | connect( vc->keyclicks, SIGNAL(toggled(bool)), this, SLOT( keyclicksCheckToggled(bool))); |
290 | connect( vc->screentaps, SIGNAL(toggled(bool)), this, SLOT( screentapsCheckToggled(bool))); | 291 | connect( vc->screentaps, SIGNAL(toggled(bool)), this, SLOT( screentapsCheckToggled(bool))); |
291 | 292 | ||
292 | QPoint curPos = mapToGlobal( rect().topLeft() ); | 293 | QPoint curPos = mapToGlobal( rect().topLeft() ); |
293 | vc->move( curPos.x()-(vc->sizeHint().width()/2+50), curPos.y() - 120 ); | 294 | vc->move( curPos.x()-(vc->sizeHint().width()/2+50), curPos.y() - 120 ); |
294 | vc->show(); | 295 | vc->show(); |
295 | 296 | ||
296 | advancedTimer->stop(); | 297 | advancedTimer->stop(); |
297 | } | 298 | } |
298 | 299 | ||
299 | void VolumeApplet::volumeChanged( bool nowMuted ) | 300 | void VolumeApplet::volumeChanged( bool nowMuted ) |
300 | { | 301 | { |
301 | int previousVolume = volumePercent; | 302 | int previousVolume = volumePercent; |
302 | 303 | ||
303 | if ( !nowMuted ) | 304 | if ( !nowMuted ) |
304 | readSystemVolume(); | 305 | readSystemVolume(); |
305 | 306 | ||
306 | // Handle case where muting it toggled | 307 | // Handle case where muting it toggled |
307 | if ( muted != nowMuted ) { | 308 | if ( muted != nowMuted ) { |
308 | muted = nowMuted; | 309 | muted = nowMuted; |
309 | repaint( TRUE ); | 310 | repaint( TRUE ); |
310 | return; | 311 | return; |
311 | } | 312 | } |
312 | 313 | ||
313 | // Avoid over repainting | 314 | // Avoid over repainting |
314 | if ( previousVolume != volumePercent ) | 315 | if ( previousVolume != volumePercent ) |
315 | repaint( 2, height() - 3, width() - 4, 2, FALSE ); | 316 | repaint( 2, height() - 3, width() - 4, 2, FALSE ); |
316 | } | 317 | } |
317 | 318 | ||
318 | void VolumeApplet::micChanged( bool nowMuted ) | 319 | void VolumeApplet::micChanged( bool nowMuted ) |
319 | { | 320 | { |
320 | if (!nowMuted) | 321 | if (!nowMuted) |
321 | readSystemMic(); | 322 | readSystemMic(); |
322 | micMuted = nowMuted; | 323 | micMuted = nowMuted; |
323 | } | 324 | } |
324 | 325 | ||
325 | void VolumeApplet::mute( bool toggled ) | 326 | void VolumeApplet::mute( bool toggled ) |
326 | { | 327 | { |
327 | muted = toggled; | 328 | muted = toggled; |
328 | 329 | ||
329 | // clear if removing mute | 330 | // clear if removing mute |
330 | repaint( !toggled ); | 331 | repaint( !toggled ); |
331 | writeSystemVolume(); | 332 | writeSystemVolume(); |
332 | } | 333 | } |
333 | 334 | ||
334 | 335 | ||
335 | void VolumeApplet::sliderMoved( int percent ) | 336 | void VolumeApplet::sliderMoved( int percent ) |
336 | { | 337 | { |
337 | setVolume( 100 - percent ); | 338 | setVolume( 100 - percent ); |
338 | } | 339 | } |
339 | 340 | ||
340 | void VolumeApplet::micMoved( int percent ) | 341 | void VolumeApplet::micMoved( int percent ) |
341 | { | 342 | { |
342 | setMic( 100 - percent ); | 343 | setMic( 100 - percent ); |
343 | } | 344 | } |
344 | 345 | ||
345 | void VolumeApplet::readSystemVolume() | 346 | void VolumeApplet::readSystemVolume() |
346 | { | 347 | { |
347 | Config cfg("qpe"); | 348 | Config cfg("qpe"); |
348 | cfg.setGroup("Volume"); | 349 | cfg.setGroup("Volume"); |
349 | volumePercent = cfg.readNumEntry("VolumePercent"); | 350 | volumePercent = cfg.readNumEntry("VolumePercent"); |
350 | } | 351 | } |
351 | 352 | ||
352 | void VolumeApplet::readSystemMic() | 353 | void VolumeApplet::readSystemMic() |
353 | { | 354 | { |
354 | Config cfg("qpe"); | 355 | Config cfg("qpe"); |
355 | cfg.setGroup("Volume"); | 356 | cfg.setGroup("Volume"); |
356 | micPercent = cfg.readNumEntry("Mic"); | 357 | micPercent = cfg.readNumEntry("Mic"); |
357 | } | 358 | } |
358 | 359 | ||
359 | void VolumeApplet::setVolume( int percent ) | 360 | void VolumeApplet::setVolume( int percent ) |
360 | { | 361 | { |
361 | // clamp volume percent to be between 0 and 100 | 362 | // clamp volume percent to be between 0 and 100 |
362 | volumePercent = (percent < 0) ? 0 : ((percent > 100) ? 100 : percent); | 363 | volumePercent = (percent < 0) ? 0 : ((percent > 100) ? 100 : percent); |
363 | // repaint just the little volume rectangle | 364 | // repaint just the little volume rectangle |
364 | repaint( 2, height() - 3, width() - 4, 2, FALSE ); | 365 | repaint( 2, height() - 3, width() - 4, 2, FALSE ); |
365 | writeSystemVolume(); | 366 | writeSystemVolume(); |
366 | } | 367 | } |
367 | 368 | ||
368 | void VolumeApplet::setMic( int percent ) | 369 | void VolumeApplet::setMic( int percent ) |
369 | { | 370 | { |
370 | // clamp volume percent to be between 0 and 100 | 371 | // clamp volume percent to be between 0 and 100 |
371 | micPercent = (percent < 0) ? 0 : ((percent > 100) ? 100 : percent); | 372 | micPercent = (percent < 0) ? 0 : ((percent > 100) ? 100 : percent); |
372 | writeSystemMic(); | 373 | writeSystemMic(); |
373 | } | 374 | } |
374 | 375 | ||
375 | void VolumeApplet::writeSystemVolume() | 376 | void VolumeApplet::writeSystemVolume() |
376 | { | 377 | { |
377 | { | 378 | { |
378 | Config cfg("qpe"); | 379 | Config cfg("qpe"); |
379 | cfg.setGroup("Volume"); | 380 | cfg.setGroup("Volume"); |
380 | cfg.writeEntry("VolumePercent",volumePercent); | 381 | cfg.writeEntry("VolumePercent",volumePercent); |
381 | } | 382 | } |
382 | #if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) | 383 | #if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) |
383 | // Send notification that the volume has changed | 384 | // Send notification that the volume has changed |
384 | QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << muted; | 385 | QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << muted; |
385 | #endif | 386 | #endif |
386 | } | 387 | } |
387 | 388 | ||
388 | void VolumeApplet::writeSystemMic() | 389 | void VolumeApplet::writeSystemMic() |
389 | { | 390 | { |
390 | { | 391 | { |
391 | Config cfg("qpe"); | 392 | Config cfg("qpe"); |
392 | cfg.setGroup("Volume"); | 393 | cfg.setGroup("Volume"); |
393 | cfg.writeEntry("Mic",micPercent); | 394 | cfg.writeEntry("Mic",micPercent); |
394 | } | 395 | } |
395 | #if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) | 396 | #if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) |
396 | // Send notification that the volume has changed | 397 | // Send notification that the volume has changed |
397 | QCopEnvelope( "QPE/System", "micChange(bool)" ) << micMuted; | 398 | QCopEnvelope( "QPE/System", "micChange(bool)" ) << micMuted; |
398 | #endif | 399 | #endif |
399 | } | 400 | } |
400 | 401 | ||
401 | void VolumeApplet::paintEvent( QPaintEvent* ) | 402 | void VolumeApplet::paintEvent( QPaintEvent* ) |
402 | { | 403 | { |
403 | QPainter p(this); | 404 | QPainter p(this); |
404 | 405 | ||
405 | if (volumePixmap.isNull()) | 406 | if (volumePixmap.isNull()) |
406 | volumePixmap = Resource::loadPixmap( "volume" ); | 407 | volumePixmap = Resource::loadPixmap( "volume" ); |
407 | p.drawPixmap( 0, 1, volumePixmap ); | 408 | p.drawPixmap( 0, 1, volumePixmap ); |
408 | p.setPen( darkGray ); | 409 | p.setPen( darkGray ); |
409 | p.drawRect( 1, height() - 4, width() - 2, 4 ); | 410 | p.drawRect( 1, height() - 4, width() - 2, 4 ); |
410 | 411 | ||
411 | int pixelsWide = volumePercent * (width() - 4) / 100; | 412 | int pixelsWide = volumePercent * (width() - 4) / 100; |
412 | p.fillRect( 2, height() - 3, pixelsWide, 2, red ); | 413 | p.fillRect( 2, height() - 3, pixelsWide, 2, red ); |
413 | p.fillRect( pixelsWide + 2, height() - 3, width() - 4 - pixelsWide, 2, lightGray ); | 414 | p.fillRect( pixelsWide + 2, height() - 3, width() - 4 - pixelsWide, 2, lightGray ); |
414 | 415 | ||
415 | if ( muted ) { | 416 | if ( muted ) { |
416 | p.setPen( red ); | 417 | p.setPen( red ); |
417 | p.drawLine( 1, 2, width() - 2, height() - 5 ); | 418 | p.drawLine( 1, 2, width() - 2, height() - 5 ); |
418 | p.drawLine( 1, 3, width() - 2, height() - 4 ); | 419 | p.drawLine( 1, 3, width() - 2, height() - 4 ); |
419 | p.drawLine( width() - 2, 2, 1, height() - 5 ); | 420 | p.drawLine( width() - 2, 2, 1, height() - 5 ); |
420 | p.drawLine( width() - 2, 3, 1, height() - 4 ); | 421 | p.drawLine( width() - 2, 3, 1, height() - 4 ); |
421 | } | 422 | } |
422 | } | 423 | } |
423 | 424 | ||
424 | void VolumeApplet::screentapsCheckToggled(bool b) { | 425 | void VolumeApplet::screentapsCheckToggled(bool b) { |
425 | Config cfg("qpe"); | 426 | Config cfg("qpe"); |
426 | cfg.setGroup("Volume"); | 427 | cfg.setGroup("Volume"); |
427 | cfg.writeEntry("TouchSound",b ); | 428 | cfg.writeEntry("TouchSound",b ); |
428 | cfg.write(); | 429 | cfg.write(); |
429 | } | 430 | } |
430 | 431 | ||
431 | void VolumeApplet::keyclicksCheckToggled(bool b) { | 432 | void VolumeApplet::keyclicksCheckToggled(bool b) { |
432 | Config cfg("qpe"); | 433 | Config cfg("qpe"); |
diff --git a/core/applets/volumeapplet/volumeappletimpl.cpp b/core/applets/volumeapplet/volumeappletimpl.cpp index 676ab61..fb2b79f 100644 --- a/core/applets/volumeapplet/volumeappletimpl.cpp +++ b/core/applets/volumeapplet/volumeappletimpl.cpp | |||
@@ -1,64 +1,66 @@ | |||
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 | #include "volume.h" | 20 | #include "volume.h" |
21 | #include "volumeappletimpl.h" | 21 | #include "volumeappletimpl.h" |
22 | #include <qpe/qcopenvelope_qws.h> | ||
22 | 23 | ||
23 | 24 | ||
24 | VolumeAppletImpl::VolumeAppletImpl() | 25 | VolumeAppletImpl::VolumeAppletImpl() |
25 | : volume(0), ref(0) | 26 | : volume(0), ref(0) |
26 | { | 27 | { |
27 | } | 28 | } |
28 | 29 | ||
29 | VolumeAppletImpl::~VolumeAppletImpl() | 30 | VolumeAppletImpl::~VolumeAppletImpl() |
30 | { | 31 | { |
31 | delete volume; | 32 | delete volume; |
32 | } | 33 | } |
33 | 34 | ||
34 | QWidget *VolumeAppletImpl::applet( QWidget *parent ) | 35 | QWidget *VolumeAppletImpl::applet( QWidget *parent ) |
35 | { | 36 | { |
36 | if ( !volume ) | 37 | if ( !volume ) |
37 | volume = new VolumeApplet( parent ); | 38 | volume = new VolumeApplet( parent ); |
39 | QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << TRUE; //mute | ||
38 | return volume; | 40 | return volume; |
39 | } | 41 | } |
40 | 42 | ||
41 | int VolumeAppletImpl::position() const | 43 | int VolumeAppletImpl::position() const |
42 | { | 44 | { |
43 | return 6; | 45 | return 6; |
44 | } | 46 | } |
45 | 47 | ||
46 | QRESULT VolumeAppletImpl::queryInterface( const QUuid &uuid, QUnknownInterface **iface ) | 48 | QRESULT VolumeAppletImpl::queryInterface( const QUuid &uuid, QUnknownInterface **iface ) |
47 | { | 49 | { |
48 | *iface = 0; | 50 | *iface = 0; |
49 | if ( uuid == IID_QUnknown ) | 51 | if ( uuid == IID_QUnknown ) |
50 | *iface = this; | 52 | *iface = this; |
51 | else if ( uuid == IID_TaskbarApplet ) | 53 | else if ( uuid == IID_TaskbarApplet ) |
52 | *iface = this; | 54 | *iface = this; |
53 | 55 | ||
54 | if ( *iface ) | 56 | if ( *iface ) |
55 | (*iface)->addRef(); | 57 | (*iface)->addRef(); |
56 | return QS_OK; | 58 | return QS_OK; |
57 | } | 59 | } |
58 | 60 | ||
59 | Q_EXPORT_INTERFACE() | 61 | Q_EXPORT_INTERFACE() |
60 | { | 62 | { |
61 | Q_CREATE_INSTANCE( VolumeAppletImpl ) | 63 | Q_CREATE_INSTANCE( VolumeAppletImpl ) |
62 | } | 64 | } |
63 | 65 | ||
64 | 66 | ||