Diffstat (limited to 'core/applets/volumeapplet/volume.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/applets/volumeapplet/volume.cpp | 168 |
1 files changed, 116 insertions, 52 deletions
diff --git a/core/applets/volumeapplet/volume.cpp b/core/applets/volumeapplet/volume.cpp index e393f0f..e8921f0 100644 --- a/core/applets/volumeapplet/volume.cpp +++ b/core/applets/volumeapplet/volume.cpp | |||
@@ -52,8 +52,8 @@ VolumeControl::VolumeControl( bool showMic, QWidget *parent, const char *name ) | |||
52 | 52 | ||
53 | void VolumeControl::createView(bool showMic) | 53 | void VolumeControl::createView(bool showMic) |
54 | { | 54 | { |
55 | Config cfg("Sound"); | 55 | Config cfg("qpe"); |
56 | cfg.setGroup("System"); | 56 | cfg.setGroup("Volume"); |
57 | //showMic = TRUE; | 57 | //showMic = TRUE; |
58 | QHBoxLayout *hboxLayout = new QHBoxLayout(this); | 58 | QHBoxLayout *hboxLayout = new QHBoxLayout(this); |
59 | hboxLayout->setMargin( 3 ); | 59 | hboxLayout->setMargin( 3 ); |
@@ -67,6 +67,9 @@ void VolumeControl::createView(bool showMic) | |||
67 | downButton->setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Expanding ) ); | 67 | downButton->setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Expanding ) ); |
68 | downButton->setPixmap( Resource::loadPixmap( "down" ) ); | 68 | downButton->setPixmap( Resource::loadPixmap( "down" ) ); |
69 | vboxButtons->setSpacing( 2 ); | 69 | vboxButtons->setSpacing( 2 ); |
70 | |||
71 | upButton->setFixedHeight(26); | ||
72 | downButton->setFixedHeight(26); | ||
70 | 73 | ||
71 | vboxButtons->addWidget( upButton ); | 74 | vboxButtons->addWidget( upButton ); |
72 | vboxButtons->addWidget( downButton ); | 75 | vboxButtons->addWidget( downButton ); |
@@ -79,7 +82,7 @@ void VolumeControl::createView(bool showMic) | |||
79 | slider->setTickmarks( QSlider::Both ); | 82 | slider->setTickmarks( QSlider::Both ); |
80 | slider->setTickInterval( 20 ); | 83 | slider->setTickInterval( 20 ); |
81 | slider->setFocusPolicy( QWidget::NoFocus ); | 84 | slider->setFocusPolicy( QWidget::NoFocus ); |
82 | slider->setValue(cfg.readNumEntry("Volume")); | 85 | slider->setValue(cfg.readNumEntry("VolumePercent")); |
83 | 86 | ||
84 | QVBoxLayout *sbox = new QVBoxLayout(this); | 87 | QVBoxLayout *sbox = new QVBoxLayout(this); |
85 | sbox->setMargin( 3 ); | 88 | sbox->setMargin( 3 ); |
@@ -87,43 +90,71 @@ void VolumeControl::createView(bool showMic) | |||
87 | sbox->addWidget( new QLabel("Vol", this) , 0, Qt::AlignVCenter | Qt::AlignHCenter ); | 90 | sbox->addWidget( new QLabel("Vol", this) , 0, Qt::AlignVCenter | Qt::AlignHCenter ); |
88 | sbox->addWidget( slider, 0, Qt::AlignVCenter | Qt::AlignHCenter ); | 91 | sbox->addWidget( slider, 0, Qt::AlignVCenter | Qt::AlignHCenter ); |
89 | 92 | ||
90 | if (showMic == TRUE) { | 93 | // if (showMic == TRUE) { |
91 | mic = new QSlider(this); | 94 | mic = new QSlider(this); |
92 | mic->setRange( 0, 100 ); | 95 | mic->setRange( 0, 100 ); |
93 | mic->setTickmarks( QSlider::Both ); | 96 | mic->setTickmarks( QSlider::Both ); |
94 | mic->setTickInterval( 20 ); | 97 | mic->setTickInterval( 20 ); |
95 | mic->setFocusPolicy( QWidget::NoFocus ); | 98 | mic->setFocusPolicy( QWidget::NoFocus ); |
96 | mic->setValue(cfg.readNumEntry("Mic")); | 99 | mic->setValue(cfg.readNumEntry("Mic")); |
97 | 100 | ||
98 | QVBoxLayout *mbox = new QVBoxLayout(this); | 101 | QVBoxLayout *mbox = new QVBoxLayout(this); |
99 | mbox->setMargin( 3 ); | 102 | mbox->setMargin( 3 ); |
100 | mbox->setSpacing( 3 ); | 103 | mbox->setSpacing( 3 ); |
101 | mbox->addWidget( new QLabel("Mic", this) , 0, Qt::AlignVCenter | Qt::AlignHCenter ); | 104 | mbox->addWidget( new QLabel("Mic", this) , 0, Qt::AlignVCenter | Qt::AlignHCenter ); |
102 | mbox->addWidget( mic, 0, Qt::AlignVCenter | Qt::AlignHCenter ); | 105 | mbox->addWidget( mic, 0, Qt::AlignVCenter | Qt::AlignHCenter ); |
103 | 106 | ||
104 | hbox = new QHBoxLayout( this ); | 107 | hbox = new QHBoxLayout( this ); |
105 | hbox->setMargin( 3 ); | 108 | hbox->setMargin( 3 ); |
106 | hbox->setSpacing( 3 ); | 109 | hbox->setSpacing( 3 ); |
107 | hbox->addLayout( sbox, 1); | 110 | hbox->addLayout( sbox, 1); |
108 | hbox->addLayout( mbox, 1); | 111 | hbox->addLayout( mbox, 1); |
109 | } | 112 | // } |
110 | 113 | ||
111 | muteBox = new QCheckBox( tr("Mute"), this ); | 114 | muteBox = new QCheckBox( tr("Mute"), this ); |
112 | muteBox->setFocusPolicy( QWidget::NoFocus ); | 115 | muteBox->setFocusPolicy( QWidget::NoFocus ); |
113 | 116 | ||
117 | QVBoxLayout *klbox = new QVBoxLayout(this); | ||
118 | |||
119 | QLabel *Label1; | ||
120 | Label1 = new QLabel( this, "Label1" ); | ||
121 | Label1->setText( tr( "Enable Sounds for:" )); | ||
122 | |||
123 | alarmSound = new QCheckBox( tr("Alarm Sound"), this ); | ||
124 | alarmSound->setFocusPolicy( QWidget::NoFocus ); | ||
125 | |||
126 | keyclicks = new QCheckBox( tr("Key Clicks"), this ); | ||
127 | keyclicks->setFocusPolicy( QWidget::NoFocus ); | ||
128 | |||
129 | screentaps = new QCheckBox( tr("Screen taps"), this ); | ||
130 | screentaps->setFocusPolicy( QWidget::NoFocus ); | ||
131 | |||
132 | |||
133 | keyclicks->setChecked( cfg.readBoolEntry("KeySound",0)); | ||
134 | screentaps->setChecked( cfg.readBoolEntry("TouchSound",0)); | ||
135 | alarmSound->setChecked( cfg.readBoolEntry("AlarmSound",1)); | ||
136 | |||
137 | klbox->setMargin( 3 ); | ||
138 | klbox->setSpacing( 0 ); | ||
139 | klbox->addWidget( Label1, 1); | ||
140 | klbox->addWidget( alarmSound, 1); | ||
141 | klbox->addWidget( keyclicks, 1); | ||
142 | klbox->addWidget( screentaps, 1); | ||
114 | vbox->setMargin( 3 ); | 143 | vbox->setMargin( 3 ); |
115 | vbox->setSpacing( 0 ); | 144 | vbox->setSpacing( 0 ); |
116 | if (showMic == TRUE) | 145 | // if (showMic == TRUE) |
117 | vbox->addLayout( hbox, 1 ); | 146 | vbox->addLayout( hbox, 1 ); |
118 | else | 147 | // else |
119 | vbox->addLayout( sbox, 1); | 148 | // vbox->addLayout( sbox, 1); |
120 | vbox->addWidget( muteBox, 0, Qt::AlignVCenter | Qt::AlignHCenter ); | 149 | vbox->addWidget( muteBox, 0, Qt::AlignVCenter | Qt::AlignHCenter ); |
121 | 150 | ||
122 | hboxLayout->addLayout( vboxButtons ); | 151 | hboxLayout->addLayout( vboxButtons ); |
123 | hboxLayout->addLayout(vbox); | 152 | hboxLayout->addLayout( vbox); |
153 | hboxLayout->addLayout( klbox); | ||
124 | 154 | ||
125 | setFixedHeight( 120 ); | 155 | |
126 | setFixedWidth( sizeHint().width() ); | 156 | setFixedHeight( 120); |
157 | // setFixedWidth( sizeHint().width() ); | ||
127 | setFocusPolicy(QWidget::NoFocus); | 158 | setFocusPolicy(QWidget::NoFocus); |
128 | connect( upButton, SIGNAL( pressed() ), this, SLOT( ButtonChanged() ) ); | 159 | connect( upButton, SIGNAL( pressed() ), this, SLOT( ButtonChanged() ) ); |
129 | connect( upButton, SIGNAL( released() ), this, SLOT( ButtonChanged() ) ); | 160 | connect( upButton, SIGNAL( released() ), this, SLOT( ButtonChanged() ) ); |
@@ -179,15 +210,15 @@ void VolumeControl::rateTimerDone() | |||
179 | VolumeApplet::VolumeApplet( QWidget *parent, const char *name ) | 210 | VolumeApplet::VolumeApplet( QWidget *parent, const char *name ) |
180 | : QWidget( parent, name ) | 211 | : QWidget( parent, name ) |
181 | { | 212 | { |
182 | Config cfg("Sound"); | 213 | Config cfg("qpe"); |
183 | cfg.setGroup("System"); | 214 | cfg.setGroup("Volume"); |
184 | 215 | ||
185 | setFixedHeight( 18 ); | 216 | setFixedHeight( 18 ); |
186 | setFixedWidth( 14 ); | 217 | setFixedWidth( 14 ); |
187 | 218 | ||
188 | volumePixmap = Resource::loadPixmap( "volume" ); | 219 | volumePixmap = Resource::loadPixmap( "volume" ); |
189 | 220 | ||
190 | volumePercent = cfg.readNumEntry("Volume",50); | 221 | volumePercent = cfg.readNumEntry("VolumePercent",50); |
191 | micPercent = cfg.readNumEntry("Mic", 50); | 222 | micPercent = cfg.readNumEntry("Mic", 50); |
192 | muted = FALSE; // ### read from pref | 223 | muted = FALSE; // ### read from pref |
193 | micMuted = FALSE; // ### read from pref | 224 | micMuted = FALSE; // ### read from pref |
@@ -229,26 +260,37 @@ void VolumeApplet::advVolControl() | |||
229 | 260 | ||
230 | void VolumeApplet::showVolControl(bool showMic) | 261 | void VolumeApplet::showVolControl(bool showMic) |
231 | { | 262 | { |
232 | Config cfg("Sound"); | 263 | Config cfg("qpe"); |
233 | cfg.setGroup("System"); | 264 | cfg.setGroup("Volume"); |
234 | volumePercent = cfg.readNumEntry("Volume",50); | 265 | volumePercent = cfg.readNumEntry("VolumePercent",50); |
235 | micPercent = cfg.readNumEntry("Mic", 50); | 266 | micPercent = cfg.readNumEntry("Mic", 50); |
236 | QString show = cfg.readEntry("ShowMic", "FALSE"); | 267 | |
237 | if(show == "TRUE") showMic = TRUE; | ||
238 | // Create a small volume control window to adjust the volume with | 268 | // Create a small volume control window to adjust the volume with |
239 | VolumeControl *vc = new VolumeControl(showMic); | 269 | VolumeControl *vc = new VolumeControl(showMic); |
240 | vc->slider->setValue( 100 - volumePercent ); | 270 | vc->slider->setValue( 100 - volumePercent ); |
241 | if (showMic) | 271 | // if (showMic) |
242 | { | 272 | // { |
243 | vc->mic->setValue( 100 - micPercent ); | 273 | vc->mic->setValue( 100 - micPercent ); |
244 | connect( vc->mic, SIGNAL( valueChanged( int ) ), this, SLOT( micMoved( int ) ) ); | 274 | connect( vc->mic, SIGNAL( valueChanged( int ) ), this, SLOT( micMoved( int ) ) ); |
245 | } | 275 | // } |
246 | 276 | ||
247 | vc->muteBox->setChecked( muted ); | 277 | vc->muteBox->setChecked( muted ); |
248 | connect( vc->slider, SIGNAL( valueChanged( int ) ), this, SLOT( sliderMoved( int ) ) ); | 278 | connect( vc->slider, SIGNAL( valueChanged( int ) ), this, SLOT( sliderMoved( int ) ) ); |
249 | connect( vc->muteBox, SIGNAL( toggled( bool ) ), this, SLOT( mute( bool ) ) ); | 279 | connect( vc->muteBox, SIGNAL( toggled( bool ) ), this, SLOT( mute( bool ) ) ); |
280 | |||
281 | Config config("qpe"); | ||
282 | config.setGroup("Volume"); | ||
283 | |||
284 | vc->keyclicks->setChecked( config.readBoolEntry("KeySound",0)); | ||
285 | vc->screentaps->setChecked( config.readBoolEntry("TouchSound",0)); | ||
286 | vc->alarmSound->setChecked( config.readBoolEntry("AlarmSound",1)); | ||
287 | |||
288 | connect( vc->alarmSound, SIGNAL(toggled(bool)), this, SLOT( alarmSoundCheckToggled(bool))); | ||
289 | connect( vc->keyclicks, SIGNAL(toggled(bool)), this, SLOT( keyclicksCheckToggled(bool))); | ||
290 | connect( vc->screentaps, SIGNAL(toggled(bool)), this, SLOT( screentapsCheckToggled(bool))); | ||
291 | |||
250 | QPoint curPos = mapToGlobal( rect().topLeft() ); | 292 | QPoint curPos = mapToGlobal( rect().topLeft() ); |
251 | vc->move( curPos.x()-(vc->sizeHint().width()-width())/2, curPos.y() - 120 ); | 293 | vc->move( curPos.x()-(vc->sizeHint().width()/2+50), curPos.y() - 120 ); |
252 | vc->show(); | 294 | vc->show(); |
253 | 295 | ||
254 | advancedTimer->stop(); | 296 | advancedTimer->stop(); |
@@ -302,15 +344,15 @@ void VolumeApplet::micMoved( int percent ) | |||
302 | 344 | ||
303 | void VolumeApplet::readSystemVolume() | 345 | void VolumeApplet::readSystemVolume() |
304 | { | 346 | { |
305 | Config cfg("Sound"); | 347 | Config cfg("qpe"); |
306 | cfg.setGroup("System"); | 348 | cfg.setGroup("Volume"); |
307 | volumePercent = cfg.readNumEntry("Volume"); | 349 | volumePercent = cfg.readNumEntry("VolumePercent"); |
308 | } | 350 | } |
309 | 351 | ||
310 | void VolumeApplet::readSystemMic() | 352 | void VolumeApplet::readSystemMic() |
311 | { | 353 | { |
312 | Config cfg("Sound"); | 354 | Config cfg("qpe"); |
313 | cfg.setGroup("System"); | 355 | cfg.setGroup("Volume"); |
314 | micPercent = cfg.readNumEntry("Mic"); | 356 | micPercent = cfg.readNumEntry("Mic"); |
315 | } | 357 | } |
316 | 358 | ||
@@ -333,9 +375,9 @@ void VolumeApplet::setMic( int percent ) | |||
333 | void VolumeApplet::writeSystemVolume() | 375 | void VolumeApplet::writeSystemVolume() |
334 | { | 376 | { |
335 | { | 377 | { |
336 | Config cfg("Sound"); | 378 | Config cfg("qpe"); |
337 | cfg.setGroup("System"); | 379 | cfg.setGroup("Volume"); |
338 | cfg.writeEntry("Volume",volumePercent); | 380 | cfg.writeEntry("VolumePercent",volumePercent); |
339 | } | 381 | } |
340 | #if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) | 382 | #if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) |
341 | // Send notification that the volume has changed | 383 | // Send notification that the volume has changed |
@@ -346,8 +388,8 @@ void VolumeApplet::writeSystemVolume() | |||
346 | void VolumeApplet::writeSystemMic() | 388 | void VolumeApplet::writeSystemMic() |
347 | { | 389 | { |
348 | { | 390 | { |
349 | Config cfg("Sound"); | 391 | Config cfg("qpe"); |
350 | cfg.setGroup("System"); | 392 | cfg.setGroup("Volume"); |
351 | cfg.writeEntry("Mic",micPercent); | 393 | cfg.writeEntry("Mic",micPercent); |
352 | } | 394 | } |
353 | #if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) | 395 | #if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) |
@@ -378,3 +420,25 @@ void VolumeApplet::paintEvent( QPaintEvent* ) | |||
378 | p.drawLine( width() - 2, 3, 1, height() - 4 ); | 420 | p.drawLine( width() - 2, 3, 1, height() - 4 ); |
379 | } | 421 | } |
380 | } | 422 | } |
423 | |||
424 | void VolumeApplet::screentapsCheckToggled(bool b) { | ||
425 | Config cfg("qpe"); | ||
426 | cfg.setGroup("Volume"); | ||
427 | cfg.writeEntry("TouchSound",b ); | ||
428 | cfg.write(); | ||
429 | } | ||
430 | |||
431 | void VolumeApplet::keyclicksCheckToggled(bool b) { | ||
432 | Config cfg("qpe"); | ||
433 | cfg.setGroup("Volume"); | ||
434 | cfg.writeEntry("KeySound",b); | ||
435 | cfg.write(); | ||
436 | } | ||
437 | |||
438 | void VolumeApplet::alarmSoundCheckToggled(bool b) { | ||
439 | Config cfg("qpe"); | ||
440 | cfg.setGroup("Volume"); | ||
441 | cfg.writeEntry("AlarmSound",b); | ||
442 | cfg.write(); | ||
443 | } | ||
444 | |||