summaryrefslogtreecommitdiff
path: root/library/qpeapplication.cpp
Unidiff
Diffstat (limited to 'library/qpeapplication.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--library/qpeapplication.cpp56
1 files changed, 35 insertions, 21 deletions
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp
index 619b4cb..4e08a1f 100644
--- a/library/qpeapplication.cpp
+++ b/library/qpeapplication.cpp
@@ -249,73 +249,81 @@ public:
249 QStringList::Iterator it; 249 QStringList::Iterator it;
250 for ( it = list.begin(); it != list.end(); ++it ) { 250 for ( it = list.begin(); it != list.end(); ++it ) {
251 ImageCodecInterface *iface = 0; 251 ImageCodecInterface *iface = 0;
252 QLibrary *lib = new QLibrary( path + "/" + *it ); 252 QLibrary *lib = new QLibrary( path + "/" + *it );
253 if ( lib->queryInterface( IID_QtopiaImageCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { 253 if ( lib->queryInterface( IID_QtopiaImageCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) {
254 QStringList formats = iface->keys(); 254 QStringList formats = iface->keys();
255 for (QStringList::ConstIterator i = formats.begin(); i != formats.end(); ++i) { 255 for (QStringList::ConstIterator i = formats.begin(); i != formats.end(); ++i) {
256 (void)iface->installIOHandler(*i); 256 (void)iface->installIOHandler(*i);
257 // ### it exists now; need to remember if we can delete it 257 // ### it exists now; need to remember if we can delete it
258 } 258 }
259 } 259 }
260 else { 260 else {
261 lib->unload(); 261 lib->unload();
262 delete lib; 262 delete lib;
263 } 263 }
264 } 264 }
265 } 265 }
266 QString styleName; 266 QString styleName;
267 QString decorationName; 267 QString decorationName;
268}; 268};
269 269
270class ResourceMimeFactory : public QMimeSourceFactory 270class ResourceMimeFactory : public QMimeSourceFactory
271{ 271{
272public: 272public:
273 ResourceMimeFactory() 273 ResourceMimeFactory() : resImage( 0 )
274 { 274 {
275 setFilePath( Global::helpPath() ); 275 setFilePath( Global::helpPath() );
276 setExtensionType( "html", "text/html;charset=UTF-8" ); 276 setExtensionType( "html", "text/html;charset=UTF-8" );
277 } 277 }
278 ~ResourceMimeFactory() {
279 delete resImage;
280 }
278 281
279 const QMimeSource* data( const QString& abs_name ) const 282 const QMimeSource* data( const QString& abs_name ) const
280 { 283 {
281 const QMimeSource * r = QMimeSourceFactory::data( abs_name ); 284 const QMimeSource * r = QMimeSourceFactory::data( abs_name );
282 if ( !r ) { 285 if ( !r ) {
283 int sl = abs_name.length(); 286 int sl = abs_name.length();
284 do { 287 do {
285 sl = abs_name.findRev( '/', sl - 1 ); 288 sl = abs_name.findRev( '/', sl - 1 );
286 QString name = sl >= 0 ? abs_name.mid( sl + 1 ) : abs_name; 289 QString name = sl >= 0 ? abs_name.mid( sl + 1 ) : abs_name;
287 int dot = name.findRev( '.' ); 290 int dot = name.findRev( '.' );
288 if ( dot >= 0 ) 291 if ( dot >= 0 )
289 name = name.left( dot ); 292 name = name.left( dot );
290 QImage img = Resource::loadImage( name ); 293 QImage img = Resource::loadImage( name );
291 if ( !img.isNull() ) 294 if ( !img.isNull() ) {
292 r = new QImageDrag( img ); 295 delete resImage;
296 resImage = new QImageDrag( img );
297 r = resImage;
298 }
293 } 299 }
294 while ( !r && sl > 0 ); 300 while ( !r && sl > 0 );
295 } 301 }
296 return r; 302 return r;
297 } 303 }
304private:
305 mutable QImageDrag *resImage;
298}; 306};
299 307
300static int muted = 0; 308static int muted = 0;
301static int micMuted = 0; 309static int micMuted = 0;
302 310
303static void setVolume( int t = 0, int percent = -1 ) 311static void setVolume( int t = 0, int percent = -1 )
304{ 312{
305 switch ( t ) { 313 switch ( t ) {
306 case 0: { 314 case 0: {
307 Config cfg( "qpe" ); 315 Config cfg( "qpe" );
308 cfg.setGroup( "Volume" ); 316 cfg.setGroup( "Volume" );
309 if ( percent < 0 ) 317 if ( percent < 0 )
310 percent = cfg.readNumEntry( "VolumePercent", 50 ); 318 percent = cfg.readNumEntry( "VolumePercent", 50 );
311 int fd = 0; 319 int fd = 0;
312 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { 320 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) {
313 int vol = muted ? 0 : percent; 321 int vol = muted ? 0 : percent;
314 // set both channels to same volume 322 // set both channels to same volume
315 vol |= vol << 8; 323 vol |= vol << 8;
316 ioctl( fd, MIXER_WRITE( 0 ), &vol ); 324 ioctl( fd, MIXER_WRITE( 0 ), &vol );
317 ::close( fd ); 325 ::close( fd );
318 } 326 }
319 } 327 }
320 break; 328 break;
321 } 329 }
@@ -962,78 +970,78 @@ void QPEApplication::setDefaultRotation( int r )
962/*! 970/*!
963 \internal 971 \internal
964*/ 972*/
965void QPEApplication::applyStyle() 973void QPEApplication::applyStyle()
966{ 974{
967 Config config( "qpe" ); 975 Config config( "qpe" );
968 config.setGroup( "Appearance" ); 976 config.setGroup( "Appearance" );
969 977
970 #if QT_VERSION > 233 978 #if QT_VERSION > 233
971 // don't block ourselves ... 979 // don't block ourselves ...
972 Opie::force_appearance = 0; 980 Opie::force_appearance = 0;
973 981
974 static QString appname = Opie::binaryName ( ); 982 static QString appname = Opie::binaryName ( );
975 983
976 QStringList ex = config. readListEntry ( "NoStyle", ';' ); 984 QStringList ex = config. readListEntry ( "NoStyle", ';' );
977 int nostyle = 0; 985 int nostyle = 0;
978 for ( QStringList::Iterator it = ex. begin ( ); it != ex. end ( ); ++it ) { 986 for ( QStringList::Iterator it = ex. begin ( ); it != ex. end ( ); ++it ) {
979 if ( QRegExp (( *it ). mid ( 1 ), false, true ). find ( appname, 0 ) >= 0 ) { 987 if ( QRegExp (( *it ). mid ( 1 ), false, true ). find ( appname, 0 ) >= 0 ) {
980 nostyle = ( *it ). left ( 1 ). toInt ( 0, 32 ); 988 nostyle = ( *it ). left ( 1 ). toInt ( 0, 32 );
981 break; 989 break;
982 } 990 }
983 } 991 }
984 992
985 // Widget style 993 // Widget style
986 QString style = config.readEntry( "Style", "Light" ); 994 QString style = config.readEntry( "Style", "FlatStyle" );
987 995
988 // don't set a custom style 996 // don't set a custom style
989 if ( nostyle & Opie::Force_Style ) 997 if ( nostyle & Opie::Force_Style )
990 style = "Light"; 998 style = "FlatStyle";
991 999
992 internalSetStyle ( style ); 1000 internalSetStyle ( style );
993 1001
994 // Colors 1002 // Colors - from /etc/colors/Liquid.scheme
995 QColor bgcolor( config.readEntry( "Background", "#E5E1D5" ) ); 1003 QColor bgcolor( config.readEntry( "Background", "#E0E0E0" ) );
996 QColor btncolor( config.readEntry( "Button", "#D6CDBB" ) ); 1004 QColor btncolor( config.readEntry( "Button", "#96c8fa" ) );
997 QPalette pal( btncolor, bgcolor ); 1005 QPalette pal( btncolor, bgcolor );
998 QString color = config.readEntry( "Highlight", "#800000" ); 1006 QString color = config.readEntry( "Highlight", "#73adef" );
999 pal.setColor( QColorGroup::Highlight, QColor( color ) ); 1007 pal.setColor( QColorGroup::Highlight, QColor( color ) );
1000 color = config.readEntry( "HighlightedText", "#FFFFFF" ); 1008 color = config.readEntry( "HighlightedText", "#FFFFFF" );
1001 pal.setColor( QColorGroup::HighlightedText, QColor( color ) ); 1009 pal.setColor( QColorGroup::HighlightedText, QColor( color ) );
1002 color = config.readEntry( "Text", "#000000" ); 1010 color = config.readEntry( "Text", "#000000" );
1003 pal.setColor( QColorGroup::Text, QColor( color ) ); 1011 pal.setColor( QColorGroup::Text, QColor( color ) );
1004 color = config.readEntry( "ButtonText", "#000000" ); 1012 color = config.readEntry( "ButtonText", "#000000" );
1005 pal.setColor( QPalette::Active, QColorGroup::ButtonText, QColor( color ) ); 1013 pal.setColor( QPalette::Active, QColorGroup::ButtonText, QColor( color ) );
1006 color = config.readEntry( "Base", "#FFFFFF" ); 1014 color = config.readEntry( "Base", "#FFFFFF" );
1007 pal.setColor( QColorGroup::Base, QColor( color ) ); 1015 pal.setColor( QColorGroup::Base, QColor( color ) );
1008 1016
1009 pal.setColor( QPalette::Disabled, QColorGroup::Text, 1017 pal.setColor( QPalette::Disabled, QColorGroup::Text,
1010 pal.color( QPalette::Active, QColorGroup::Background ).dark() ); 1018 pal.color( QPalette::Active, QColorGroup::Background ).dark() );
1011 1019
1012 setPalette( pal, TRUE ); 1020 setPalette( pal, TRUE );
1013 1021
1014 // Window Decoration 1022 // Window Decoration
1015 QString dec = config.readEntry( "Decoration", "Qtopia" ); 1023 QString dec = config.readEntry( "Decoration", "Flat" );
1016 1024
1017 // don't set a custom deco 1025 // don't set a custom deco
1018 if ( nostyle & Opie::Force_Decoration ) 1026 if ( nostyle & Opie::Force_Decoration )
1019 dec = ""; 1027 dec = "";
1020 1028
1021 //qDebug ( "Setting Deco: %s -- old %s (%d)", dec.latin1(), d-> decorationName.latin1(), nostyle); 1029 //qDebug ( "Setting Deco: %s -- old %s (%d)", dec.latin1(), d-> decorationName.latin1(), nostyle);
1022 1030
1023 if ( dec != d->decorationName ) { 1031 if ( dec != d->decorationName ) {
1024 qwsSetDecoration( new QPEDecoration( dec ) ); 1032 qwsSetDecoration( new QPEDecoration( dec ) );
1025 d->decorationName = dec; 1033 d->decorationName = dec;
1026 } 1034 }
1027 1035
1028 // Font 1036 // Font
1029 QString ff = config.readEntry( "FontFamily", font().family() ); 1037 QString ff = config.readEntry( "FontFamily", font().family() );
1030 int fs = config.readNumEntry( "FontSize", font().pointSize() ); 1038 int fs = config.readNumEntry( "FontSize", font().pointSize() );
1031 1039
1032 // don't set a custom font 1040 // don't set a custom font
1033 if ( nostyle & Opie::Force_Font ) { 1041 if ( nostyle & Opie::Force_Font ) {
1034 ff = "Vera"; 1042 ff = "Vera";
1035 fs = 10; 1043 fs = 10;
1036 } 1044 }
1037 1045
1038 setFont ( QFont ( ff, fs ), true ); 1046 setFont ( QFont ( ff, fs ), true );
1039 1047
@@ -1277,60 +1285,66 @@ void QPEApplication::pidMessage( const QCString& msg, const QByteArray& data)
1277 raiseAppropriateWindow(); 1285 raiseAppropriateWindow();
1278 // Tell the system we're still chugging along... 1286 // Tell the system we're still chugging along...
1279 QCopEnvelope e("QPE/System", "appRaised(QString)"); 1287 QCopEnvelope e("QPE/System", "appRaised(QString)");
1280 e << d->appName; 1288 e << d->appName;
1281 } 1289 }
1282 else if ( msg == "flush()" ) { 1290 else if ( msg == "flush()" ) {
1283 emit flush(); 1291 emit flush();
1284 // we need to tell the desktop 1292 // we need to tell the desktop
1285 QCopEnvelope e( "QPE/Desktop", "flushDone(QString)" ); 1293 QCopEnvelope e( "QPE/Desktop", "flushDone(QString)" );
1286 e << d->appName; 1294 e << d->appName;
1287 } 1295 }
1288 else if ( msg == "reload()" ) { 1296 else if ( msg == "reload()" ) {
1289 emit reload(); 1297 emit reload();
1290 } 1298 }
1291 else if ( msg == "setDocument(QString)" ) { 1299 else if ( msg == "setDocument(QString)" ) {
1292 d->keep_running = TRUE; 1300 d->keep_running = TRUE;
1293 QDataStream stream( data, IO_ReadOnly ); 1301 QDataStream stream( data, IO_ReadOnly );
1294 QString doc; 1302 QString doc;
1295 stream >> doc; 1303 stream >> doc;
1296 QWidget *mw = mainWidget(); 1304 QWidget *mw = mainWidget();
1297 if ( !mw ) 1305 if ( !mw )
1298 mw = d->qpe_main_widget; 1306 mw = d->qpe_main_widget;
1299 if ( mw ) 1307 if ( mw )
1300 Global::setDocument( mw, doc ); 1308 Global::setDocument( mw, doc );
1309 } else {
1310 bool p = d->keep_running;
1311 d->keep_running = FALSE;
1312 emit appMessage( msg, data);
1313 if ( d->keep_running ) {
1314 d->notbusysent = FALSE;
1315 raiseAppropriateWindow();
1316 if ( !p ) {
1317 // Tell the system we're still chugging along...
1318#ifndef QT_NO_COP
1319 QCopEnvelope e("QPE/System", "appRaised(QString)");
1320 e << d->appName;
1321#endif
1322 }
1323 }
1324 if ( p )
1325 d->keep_running = p;
1301 } 1326 }
1302 else if ( msg == "nextView()" ) {
1303 qDebug("got nextView()");
1304 /*
1305 if ( raiseAppropriateWindow() )
1306 */
1307 emit appMessage( msg, data);
1308 }
1309 else {
1310 emit appMessage( msg, data);
1311 }
1312
1313#endif 1327#endif
1314} 1328}
1315 1329
1316 1330
1317/*! 1331/*!
1318 Sets widget \a mw as the mainWidget() and shows it. For small windows, 1332 Sets widget \a mw as the mainWidget() and shows it. For small windows,
1319 consider passing TRUE for \a nomaximize rather than the default FALSE. 1333 consider passing TRUE for \a nomaximize rather than the default FALSE.
1320 1334
1321 \sa showMainDocumentWidget() 1335 \sa showMainDocumentWidget()
1322*/ 1336*/
1323void QPEApplication::showMainWidget( QWidget* mw, bool nomaximize ) 1337void QPEApplication::showMainWidget( QWidget* mw, bool nomaximize )
1324{ 1338{
1325 d->show(mw, nomaximize ); 1339 d->show(mw, nomaximize );
1326} 1340}
1327 1341
1328/*! 1342/*!
1329 Sets widget \a mw as the mainWidget() and shows it. For small windows, 1343 Sets widget \a mw as the mainWidget() and shows it. For small windows,
1330 consider passing TRUE for \a nomaximize rather than the default FALSE. 1344 consider passing TRUE for \a nomaximize rather than the default FALSE.
1331 1345
1332 This calls designates the application as 1346 This calls designates the application as
1333 a \link docwidget.html document-oriented\endlink application. 1347 a \link docwidget.html document-oriented\endlink application.
1334 1348
1335 The \a mw widget \e must have this slot: setDocument(const QString&). 1349 The \a mw widget \e must have this slot: setDocument(const QString&).
1336 1350