-rw-r--r-- | library/qpeapplication.cpp | 40 |
1 files changed, 14 insertions, 26 deletions
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp index 7cbda92..4c93111 100644 --- a/library/qpeapplication.cpp +++ b/library/qpeapplication.cpp @@ -41,96 +41,98 @@ #include <qpalette.h> #include <qbuffer.h> #include <qptrdict.h> #include <qregexp.h> #include <qdir.h> #include <qlabel.h> #include <qdialog.h> #include <qdragobject.h> #include <qtextcodec.h> #include <qevent.h> #include <qtooltip.h> #include <qsignal.h> #include "qpeapplication.h" #include "qpestyle.h" #include "styleinterface.h" #if QT_VERSION >= 300 #include <qstylefactory.h> #else #include <qplatinumstyle.h> #include <qwindowsstyle.h> #include <qmotifstyle.h> #include <qmotifplusstyle.h> #include "lightstyle.h" #include <qpe/qlibrary.h> #endif #include "global.h" #include "resource.h" #if QT_VERSION <= 230 && defined(QT_NO_CODECS) #include "qutfcodec.h" #endif #include "config.h" #include "network.h" #ifdef QWS #include "fontmanager.h" #endif #include "alarmserver.h" #include "applnk.h" #include "qpemenubar.h" #include "textcodecinterface.h" #include "imagecodecinterface.h" #include <unistd.h> #include <sys/file.h> #include <sys/ioctl.h> #include <sys/soundcard.h> +#include "qt_override_p.h" + class QPEApplicationData { public: QPEApplicationData() : presstimer( 0 ), presswidget( 0 ), rightpressed( FALSE ), kbgrabber( 0 ), kbregrab( FALSE ), notbusysent( FALSE ), preloaded( FALSE ), forceshow( FALSE ), nomaximize( FALSE ), qpe_main_widget( 0 ), keep_running( TRUE ) { qcopq.setAutoDelete( TRUE ); } int presstimer; QWidget* presswidget; QPoint presspos; bool rightpressed : 1; // AEH why not use uint foobar :1; if it's tt style -zecke int kbgrabber; bool kbregrab : 1; bool notbusysent : 1; QString appName; struct QCopRec { QCopRec( const QCString &ch, const QCString &msg, const QByteArray &d ) : channel( ch ), message( msg ), data( d ) { } QCString channel; QCString message; QByteArray data; }; bool preloaded : 1; bool forceshow : 1; bool nomaximize : 1; QWidget* qpe_main_widget; bool keep_running : 1; QList<QCopRec> qcopq; void enqueueQCop( const QCString &ch, const QCString &msg, const QByteArray &data ) { @@ -854,195 +856,177 @@ QString QPEApplication::documentDir() static int deforient = -1; /*! \internal */ int QPEApplication::defaultRotation() { if ( deforient < 0 ) { QString d = getenv( "QWS_DISPLAY" ); if ( d.contains( "Rot90" ) ) { deforient = 90; } else if ( d.contains( "Rot180" ) ) { deforient = 180; } else if ( d.contains( "Rot270" ) ) { deforient = 270; } else { deforient = 0; } } return deforient; } /*! \internal */ void QPEApplication::setDefaultRotation( int r ) { if ( qApp->type() == GuiServer ) { deforient = r; setenv( "QWS_DISPLAY", QString( "Transformed:Rot%1:0" ).arg( r ).latin1(), 1 ); Config config("qpe"); config.setGroup( "Rotation" ); config.writeEntry( "Screen", getenv("QWS_DISPLAY") ); } else { #ifndef QT_NO_COP { QCopEnvelope e( "QPE/System", "setDefaultRotation(int)" ); e << r; } #endif } } -// exported to libpreload.so -int opie_block_style = 0; /*! \internal */ void QPEApplication::applyStyle() { Config config( "qpe" ); config.setGroup( "Appearance" ); // don't block ourselves ... - opie_block_style = 0; - - - static QString appname; - - if ( appname. isNull ( )) { - char src [32]; - char dst [PATH_MAX + 1]; - ::sprintf ( src, "/proc/%d/exe", ::getpid ( )); - int l = ::readlink ( src, dst, PATH_MAX ); - if ( l > 0 ) { - dst [l] = 0; - const char *b = ::strrchr ( dst, '/' ); - appname = ( b ? b + 1 : dst ); - } - else - appname = ""; - } - + 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" ); // don't set a custom style - if ( nostyle & 0x01 ) + if ( nostyle & Opie::Force_Style ) style = "Light"; internalSetStyle ( style ); // Colors QColor bgcolor( config.readEntry( "Background", "#E5E1D5" ) ); QColor btncolor( config.readEntry( "Button", "#D6CDBB" ) ); QPalette pal( btncolor, bgcolor ); QString color = config.readEntry( "Highlight", "#800000" ); 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" ); // don't set a custom deco - if ( nostyle & 0x04 ) + 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 & 0x02 ) { + if ( nostyle & Opie::Force_Font ) { ff = "Helvetica"; fs = 10; } setFont ( QFont ( ff, fs ), true ); // revert to global blocking policy ... - opie_block_style = config. readBoolEntry ( "ForceStyle", false ) ? 0xff : 0x00; - opie_block_style -= nostyle; + Opie::force_appearance = config. readBoolEntry ( "ForceStyle", false ) ? Opie::Force_All : Opie::Force_None; + Opie::force_appearance &= ~nostyle; } void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data ) { #ifdef Q_WS_QWS QDataStream stream( data, IO_ReadOnly ); if ( msg == "applyStyle()" ) { applyStyle(); } else if ( msg == "setDefaultRotation(int)" ) { if ( type() == GuiServer ) { int r; stream >> r; setDefaultRotation( r ); } } else if ( msg == "shutdown()" ) { if ( type() == GuiServer ) shutdown(); } else if ( msg == "quit()" ) { if ( type() != GuiServer ) tryQuit(); } else if ( msg == "forceQuit()" ) { if ( type() != GuiServer ) quit(); } else if ( msg == "restart()" ) { if ( type() == GuiServer ) restart(); } else if ( msg == "grabKeyboard(QString)" ) { QString who; stream >> who; if ( who.isEmpty() ) d->kbgrabber = 0; else if ( who != d->appName ) d->kbgrabber = 1; else d->kbgrabber = 2; } else if ( msg == "language(QString)" ) { if ( type() == GuiServer ) { QString l; stream >> l; QString cl = getenv( "LANG" ); if ( cl != l ) { @@ -1648,96 +1632,100 @@ int QPEApplication::exec() } /*! \internal External request for application to quit. Quits if possible without loosing state. */ void QPEApplication::tryQuit() { if ( activeModalWidget() || strcmp( argv() [ 0 ], "embeddedkonsole" ) == 0 ) return ; // Inside modal loop or konsole. Too hard to save state. #ifndef QT_NO_COP { QCopEnvelope e( "QPE/System", "closing(QString)" ); e << d->appName; } #endif processEvents(); quit(); } /*! \internal User initiated quit. Makes the window 'Go Away'. If preloaded this means hiding the window. If not it means quitting the application. As this is user initiated we don't need to check state. */ void QPEApplication::hideOrQuit() { processEvents(); // If we are a preloaded application we don't actually quit, so emit // a System message indicating we're quasi-closing. if ( d->preloaded && d->qpe_main_widget ) #ifndef QT_NO_COP { QCopEnvelope e("QPE/System", "fastAppHiding(QString)" ); e << d->appName; d->qpe_main_widget->hide(); } #endif else quit(); } + +// These 6 stubs below need 1.5K in the binary and besides that - +// we are not using ancient toolchains anymore - sandman + #if defined(QT_QWS_IPAQ) || defined(QT_QWS_SHARP) // The libraries with the skiff package (and possibly others) have // completely useless implementations of builtin new and delete that // use about 50% of your CPU. Here we revert to the simple libc // functions. void* operator new[]( size_t size ) { return malloc( size ); } void* operator new( size_t size ) { return malloc( size ); } void operator delete[]( void* p ) { free( p ); } void operator delete[]( void* p, size_t /*size*/ ) { free( p ); } void operator delete( void* p ) { free( p ); } void operator delete( void* p, size_t /*size*/ ) { free( p ); } #endif #if ( QT_VERSION <= 230 ) && !defined(SINGLE_APP) #include <qwidgetlist.h> #ifdef QWS #include <qgfx_qws.h> extern QRect qt_maxWindowRect; void qt_setMaxWindowRect(const QRect& r ) { qt_maxWindowRect = qt_screen->mapFromDevice( r, qt_screen->mapToDevice( QSize( qt_screen->width(), qt_screen->height() ) ) ); |