summaryrefslogtreecommitdiff
path: root/library/qpeapplication.cpp
Side-by-side diff
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:
QStringList::Iterator it;
for ( it = list.begin(); it != list.end(); ++it ) {
ImageCodecInterface *iface = 0;
QLibrary *lib = new QLibrary( path + "/" + *it );
if ( lib->queryInterface( IID_QtopiaImageCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) {
QStringList formats = iface->keys();
for (QStringList::ConstIterator i = formats.begin(); i != formats.end(); ++i) {
(void)iface->installIOHandler(*i);
// ### it exists now; need to remember if we can delete it
}
}
else {
lib->unload();
delete lib;
}
}
}
QString styleName;
QString decorationName;
};
class ResourceMimeFactory : public QMimeSourceFactory
{
public:
- ResourceMimeFactory()
+ ResourceMimeFactory() : resImage( 0 )
{
setFilePath( Global::helpPath() );
setExtensionType( "html", "text/html;charset=UTF-8" );
}
+ ~ResourceMimeFactory() {
+ delete resImage;
+ }
const QMimeSource* data( const QString& abs_name ) const
{
const QMimeSource * r = QMimeSourceFactory::data( abs_name );
if ( !r ) {
int sl = abs_name.length();
do {
sl = abs_name.findRev( '/', sl - 1 );
QString name = sl >= 0 ? abs_name.mid( sl + 1 ) : abs_name;
int dot = name.findRev( '.' );
if ( dot >= 0 )
name = name.left( dot );
QImage img = Resource::loadImage( name );
- if ( !img.isNull() )
- r = new QImageDrag( img );
+ if ( !img.isNull() ) {
+ delete resImage;
+ resImage = new QImageDrag( img );
+ r = resImage;
+ }
}
while ( !r && sl > 0 );
}
return r;
}
+private:
+ mutable QImageDrag *resImage;
};
static int muted = 0;
static int micMuted = 0;
static void setVolume( int t = 0, int percent = -1 )
{
switch ( t ) {
case 0: {
Config cfg( "qpe" );
cfg.setGroup( "Volume" );
if ( percent < 0 )
percent = cfg.readNumEntry( "VolumePercent", 50 );
int fd = 0;
if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) {
int vol = muted ? 0 : percent;
// set both channels to same volume
vol |= vol << 8;
ioctl( fd, MIXER_WRITE( 0 ), &vol );
::close( fd );
}
}
break;
}
@@ -962,78 +970,78 @@ void QPEApplication::setDefaultRotation( int r )
/*!
\internal
*/
void QPEApplication::applyStyle()
{
Config config( "qpe" );
config.setGroup( "Appearance" );
#if QT_VERSION > 233
// don't block ourselves ...
Opie::force_appearance = 0;
static QString appname = Opie::binaryName ( );
QStringList ex = config. readListEntry ( "NoStyle", ';' );
int nostyle = 0;
for ( QStringList::Iterator it = ex. begin ( ); it != ex. end ( ); ++it ) {
if ( QRegExp (( *it ). mid ( 1 ), false, true ). find ( appname, 0 ) >= 0 ) {
nostyle = ( *it ). left ( 1 ). toInt ( 0, 32 );
break;
}
}
// Widget style
- QString style = config.readEntry( "Style", "Light" );
+ QString style = config.readEntry( "Style", "FlatStyle" );
// don't set a custom style
if ( nostyle & Opie::Force_Style )
- style = "Light";
+ style = "FlatStyle";
internalSetStyle ( style );
- // Colors
- QColor bgcolor( config.readEntry( "Background", "#E5E1D5" ) );
- QColor btncolor( config.readEntry( "Button", "#D6CDBB" ) );
+ // Colors - from /etc/colors/Liquid.scheme
+ QColor bgcolor( config.readEntry( "Background", "#E0E0E0" ) );
+ QColor btncolor( config.readEntry( "Button", "#96c8fa" ) );
QPalette pal( btncolor, bgcolor );
- QString color = config.readEntry( "Highlight", "#800000" );
+ QString color = config.readEntry( "Highlight", "#73adef" );
pal.setColor( QColorGroup::Highlight, QColor( color ) );
color = config.readEntry( "HighlightedText", "#FFFFFF" );
pal.setColor( QColorGroup::HighlightedText, QColor( color ) );
color = config.readEntry( "Text", "#000000" );
pal.setColor( QColorGroup::Text, QColor( color ) );
color = config.readEntry( "ButtonText", "#000000" );
pal.setColor( QPalette::Active, QColorGroup::ButtonText, QColor( color ) );
color = config.readEntry( "Base", "#FFFFFF" );
pal.setColor( QColorGroup::Base, QColor( color ) );
pal.setColor( QPalette::Disabled, QColorGroup::Text,
pal.color( QPalette::Active, QColorGroup::Background ).dark() );
setPalette( pal, TRUE );
// Window Decoration
- QString dec = config.readEntry( "Decoration", "Qtopia" );
+ QString dec = config.readEntry( "Decoration", "Flat" );
// don't set a custom deco
if ( nostyle & Opie::Force_Decoration )
dec = "";
//qDebug ( "Setting Deco: %s -- old %s (%d)", dec.latin1(), d-> decorationName.latin1(), nostyle);
if ( dec != d->decorationName ) {
qwsSetDecoration( new QPEDecoration( dec ) );
d->decorationName = dec;
}
// Font
QString ff = config.readEntry( "FontFamily", font().family() );
int fs = config.readNumEntry( "FontSize", font().pointSize() );
// don't set a custom font
if ( nostyle & Opie::Force_Font ) {
ff = "Vera";
fs = 10;
}
setFont ( QFont ( ff, fs ), true );
@@ -1277,60 +1285,66 @@ void QPEApplication::pidMessage( const QCString& msg, const QByteArray& data)
raiseAppropriateWindow();
// Tell the system we're still chugging along...
QCopEnvelope e("QPE/System", "appRaised(QString)");
e << d->appName;
}
else if ( msg == "flush()" ) {
emit flush();
// we need to tell the desktop
QCopEnvelope e( "QPE/Desktop", "flushDone(QString)" );
e << d->appName;
}
else if ( msg == "reload()" ) {
emit reload();
}
else if ( msg == "setDocument(QString)" ) {
d->keep_running = TRUE;
QDataStream stream( data, IO_ReadOnly );
QString doc;
stream >> doc;
QWidget *mw = mainWidget();
if ( !mw )
mw = d->qpe_main_widget;
if ( mw )
Global::setDocument( mw, doc );
+ } else {
+ bool p = d->keep_running;
+ d->keep_running = FALSE;
+ emit appMessage( msg, data);
+ if ( d->keep_running ) {
+ d->notbusysent = FALSE;
+ raiseAppropriateWindow();
+ if ( !p ) {
+ // Tell the system we're still chugging along...
+#ifndef QT_NO_COP
+ QCopEnvelope e("QPE/System", "appRaised(QString)");
+ e << d->appName;
+#endif
+ }
+ }
+ if ( p )
+ d->keep_running = p;
}
- else if ( msg == "nextView()" ) {
- qDebug("got nextView()");
- /*
- if ( raiseAppropriateWindow() )
- */
- emit appMessage( msg, data);
- }
- else {
- emit appMessage( msg, data);
- }
-
#endif
}
/*!
Sets widget \a mw as the mainWidget() and shows it. For small windows,
consider passing TRUE for \a nomaximize rather than the default FALSE.
\sa showMainDocumentWidget()
*/
void QPEApplication::showMainWidget( QWidget* mw, bool nomaximize )
{
d->show(mw, nomaximize );
}
/*!
Sets widget \a mw as the mainWidget() and shows it. For small windows,
consider passing TRUE for \a nomaximize rather than the default FALSE.
This calls designates the application as
a \link docwidget.html document-oriented\endlink application.
The \a mw widget \e must have this slot: setDocument(const QString&).