summaryrefslogtreecommitdiff
authorharlekin <harlekin>2002-12-13 19:37:59 (UTC)
committer harlekin <harlekin>2002-12-13 19:37:59 (UTC)
commite348262d418e3a133d13d039ed23da4625726f9d (patch) (unidiff)
tree36cdf26700d424b06b6c37b86e5f1e07bc233b88
parent11ccc2e5341677cd54037a1f9cfb04831feed0f9 (diff)
downloadopie-e348262d418e3a133d13d039ed23da4625726f9d.zip
opie-e348262d418e3a133d13d039ed23da4625726f9d.tar.gz
opie-e348262d418e3a133d13d039ed23da4625726f9d.tar.bz2
added Bass and Treble handling - next stop should be odevice
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--library/qpeapplication.cpp61
1 files changed, 61 insertions, 0 deletions
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp
index c41dd06..852671a 100644
--- a/library/qpeapplication.cpp
+++ b/library/qpeapplication.cpp
@@ -309,48 +309,90 @@ static void setVolume( int t = 0, int percent = -1 )
309 } 309 }
310} 310}
311 311
312static void setMic( int t = 0, int percent = -1 ) 312static void setMic( int t = 0, int percent = -1 )
313{ 313{
314 switch ( t ) { 314 switch ( t ) {
315 case 0: { 315 case 0: {
316 Config cfg( "qpe" ); 316 Config cfg( "qpe" );
317 cfg.setGroup( "Volume" ); 317 cfg.setGroup( "Volume" );
318 if ( percent < 0 ) 318 if ( percent < 0 )
319 percent = cfg.readNumEntry( "Mic", 50 ); 319 percent = cfg.readNumEntry( "Mic", 50 );
320 320
321 int fd = 0; 321 int fd = 0;
322 int mic = micMuted ? 0 : percent; 322 int mic = micMuted ? 0 : percent;
323 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { 323 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) {
324 ioctl( fd, MIXER_WRITE( SOUND_MIXER_MIC ), &mic ); 324 ioctl( fd, MIXER_WRITE( SOUND_MIXER_MIC ), &mic );
325 ::close( fd ); 325 ::close( fd );
326 } 326 }
327 } 327 }
328 break; 328 break;
329 } 329 }
330} 330}
331 331
332 332
333static void setBass( int t = 0, int percent = -1 )
334{
335 switch ( t ) {
336 case 0: {
337 Config cfg( "qpe" );
338 cfg.setGroup( "Volume" );
339 if ( percent < 0 )
340 percent = cfg.readNumEntry( "BassPercent", 50 );
341
342 int fd = 0;
343 int bass = percent;
344 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) {
345 ioctl( fd, MIXER_WRITE( SOUND_MIXER_BASS ), &bass );
346 ::close( fd );
347 }
348 }
349 break;
350 }
351}
352
353
354static void setTreble( int t = 0, int percent = -1 )
355{
356 switch ( t ) {
357 case 0: {
358 Config cfg( "qpe" );
359 cfg.setGroup( "Volume" );
360 if ( percent < 0 )
361 percent = cfg.readNumEntry( "TreblePercent", 50 );
362
363 int fd = 0;
364 int treble = percent;
365 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) {
366 ioctl( fd, MIXER_WRITE( SOUND_MIXER_TREBLE ), &treble );
367 ::close( fd );
368 }
369 }
370 break;
371 }
372}
373
374
333/*! 375/*!
334 \class QPEApplication qpeapplication.h 376 \class QPEApplication qpeapplication.h
335 \brief The QPEApplication class implements various system services 377 \brief The QPEApplication class implements various system services
336 that are available to all Qtopia applications. 378 that are available to all Qtopia applications.
337 379
338 Simply by using QPEApplication instead of QApplication, a standard Qt 380 Simply by using QPEApplication instead of QApplication, a standard Qt
339 application becomes a Qtopia application. It automatically follows 381 application becomes a Qtopia application. It automatically follows
340 style changes, quits and raises, and in the 382 style changes, quits and raises, and in the
341 case of \link docwidget.html document-oriented\endlink applications, 383 case of \link docwidget.html document-oriented\endlink applications,
342 changes the currently displayed document in response to the environment. 384 changes the currently displayed document in response to the environment.
343 385
344 To create a \link docwidget.html document-oriented\endlink 386 To create a \link docwidget.html document-oriented\endlink
345 application use showMainDocumentWidget(); to create a 387 application use showMainDocumentWidget(); to create a
346 non-document-oriented application use showMainWidget(). The 388 non-document-oriented application use showMainWidget(). The
347 keepRunning() function indicates whether the application will 389 keepRunning() function indicates whether the application will
348 continue running after it's processed the last \link qcop.html 390 continue running after it's processed the last \link qcop.html
349 QCop\endlink message. This can be changed using setKeepRunning(). 391 QCop\endlink message. This can be changed using setKeepRunning().
350 392
351 A variety of signals are emitted when certain events occur, for 393 A variety of signals are emitted when certain events occur, for
352 example, timeChanged(), clockChanged(), weekChanged(), 394 example, timeChanged(), clockChanged(), weekChanged(),
353 dateFormatChanged() and volumeChanged(). If the application receives 395 dateFormatChanged() and volumeChanged(). If the application receives
354 a \link qcop.html QCop\endlink message on the application's 396 a \link qcop.html QCop\endlink message on the application's
355 QPE/Application/\e{appname} channel, the appMessage() signal is 397 QPE/Application/\e{appname} channel, the appMessage() signal is
356 emitted. There are also flush() and reload() signals, which 398 emitted. There are also flush() and reload() signals, which
@@ -1095,48 +1137,67 @@ void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data
1095 emit dateFormatChanged( tmp ); 1137 emit dateFormatChanged( tmp );
1096 } 1138 }
1097 else if ( msg == "setVolume(int,int)" ) { 1139 else if ( msg == "setVolume(int,int)" ) {
1098 int t, v; 1140 int t, v;
1099 stream >> t >> v; 1141 stream >> t >> v;
1100 setVolume( t, v ); 1142 setVolume( t, v );
1101 emit volumeChanged( muted ); 1143 emit volumeChanged( muted );
1102 } 1144 }
1103 else if ( msg == "volumeChange(bool)" ) { 1145 else if ( msg == "volumeChange(bool)" ) {
1104 stream >> muted; 1146 stream >> muted;
1105 setVolume(); 1147 setVolume();
1106 emit volumeChanged( muted ); 1148 emit volumeChanged( muted );
1107 } 1149 }
1108 else if ( msg == "setMic(int,int)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> 1150 else if ( msg == "setMic(int,int)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com>
1109 int t, v; 1151 int t, v;
1110 stream >> t >> v; 1152 stream >> t >> v;
1111 setMic( t, v ); 1153 setMic( t, v );
1112 emit micChanged( micMuted ); 1154 emit micChanged( micMuted );
1113 } 1155 }
1114 else if ( msg == "micChange(bool)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> 1156 else if ( msg == "micChange(bool)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com>
1115 stream >> micMuted; 1157 stream >> micMuted;
1116 setMic(); 1158 setMic();
1117 emit micChanged( micMuted ); 1159 emit micChanged( micMuted );
1118 } 1160 }
1161 else if ( msg == "setBass(int,int)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org>
1162 int t, v;
1163 stream >> t >> v;
1164 setBass( t, v );
1165 }
1166 else if ( msg == "bassChange(bool)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org>
1167 setBass();
1168 }
1169 else if ( msg == "setTreble(int,int)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org>
1170 int t, v;
1171 stream >> t >> v;
1172 setTreble( t, v );
1173 }
1174 else if ( msg == "trebleChange(bool)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org>
1175 setTreble();
1176 }
1177
1178
1179
1119#endif 1180#endif
1120} 1181}
1121 1182
1122/*! 1183/*!
1123 \internal 1184 \internal
1124*/ 1185*/
1125bool QPEApplication::raiseAppropriateWindow() 1186bool QPEApplication::raiseAppropriateWindow()
1126{ 1187{
1127 bool r = FALSE; 1188 bool r = FALSE;
1128 // ########## raise()ing main window should raise and set active 1189 // ########## raise()ing main window should raise and set active
1129 // ########## it and then all childen. This belongs in Qt/Embedded 1190 // ########## it and then all childen. This belongs in Qt/Embedded
1130 QWidget *top = d->qpe_main_widget; 1191 QWidget *top = d->qpe_main_widget;
1131 if ( !top ) 1192 if ( !top )
1132 top = mainWidget(); 1193 top = mainWidget();
1133 if ( top && d->keep_running ) { 1194 if ( top && d->keep_running ) {
1134 if ( top->isVisible() ) 1195 if ( top->isVisible() )
1135 r = TRUE; 1196 r = TRUE;
1136 else if (d->preloaded) { 1197 else if (d->preloaded) {
1137 // We are preloaded and not visible.. pretend we just started.. 1198 // We are preloaded and not visible.. pretend we just started..
1138 QCopEnvelope e("QPE/System", "fastAppShowing(QString)"); 1199 QCopEnvelope e("QPE/System", "fastAppShowing(QString)");
1139 e << d->appName; 1200 e << d->appName;
1140 } 1201 }
1141 1202
1142 d->show_mx(top, d->nomaximize); 1203 d->show_mx(top, d->nomaximize);