-rw-r--r-- | x11/libqpe-x11/qpe/qpeapplication.cpp | 20 | ||||
-rw-r--r-- | x11/libqpe-x11/qpe/qpeapplication.h | 6 | ||||
-rw-r--r-- | x11/libqpe-x11/qt/qwindowsystem_qws.h | 3 |
3 files changed, 22 insertions, 7 deletions
diff --git a/x11/libqpe-x11/qpe/qpeapplication.cpp b/x11/libqpe-x11/qpe/qpeapplication.cpp index 73e7ce4..c49f3ad 100644 --- a/x11/libqpe-x11/qpe/qpeapplication.cpp +++ b/x11/libqpe-x11/qpe/qpeapplication.cpp @@ -370,147 +370,152 @@ QString QPEApplication::qpeDir() { return QString( "../" ); } QString QPEApplication::documentDir() { const char* base = getenv( "HOME"); if ( base ) return QString( base ) + "/Documents"; return QString( "../Documents" ); } void QPEApplication::applyStyle() { Config config( "qpe" ); config.setGroup( "Appearance" ); // Widget style QString style = config.readEntry( "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 ); // Font QString ff = config.readEntry( "FontFamily", font().family() ); int fs = config.readNumEntry( "FontSize", font().pointSize() ); setFont( QFont(ff, fs) ); } int QPEApplication::defaultRotation() { return 0; } -void QPEApplication::setDefaultRotation(int r ) { +void QPEApplication::setDefaultRotation(int) { } void QPEApplication::grabKeyboard() { QPEApplication::Private * d = ( ( QPEApplication* ) qApp ) ->d; if ( qApp->type() == QApplication::GuiServer ) d->kbgrabber = 0; else { QCopEnvelope e( "QPE/System", "grabKeyboard(QString)" ); e << d->appName; d->kbgrabber = 2; // me } } void QPEApplication::ungrabKeyboard() { QPEApplication::Private * d = ( ( QPEApplication* ) qApp ) ->d; if ( d->kbgrabber == 2 ) { QCopEnvelope e( "QPE/System", "grabKeyboard(QString)" ); e << QString::null; d->kbregrab = FALSE; d->kbgrabber = 0; } } void QPEApplication::showMainWidget( QWidget* wid, bool b) { d->show(wid, b ); } void QPEApplication::showMainDocumentWidget( QWidget* mw, bool m) { if ( mw && argc() == 2 ) Global::setDocument( mw, QString::fromUtf8(argv()[1] ) ); d->show(mw, m ); } void QPEApplication::showDialog( QDialog* d, bool nomax ) { + showWidget( d, nomax ); +} +int QPEApplication::execDialog( QDialog* d, bool nomax) { + showDialog(d,nomax); + return d->exec(); +} + +void QPEApplication::showWidget( QWidget* d, bool nomax ) { QSize sh = d->sizeHint(); int w = QMAX(sh.width(),d->width()); int h = QMAX(sh.height(),d->height()); if ( !nomax && ( w > qApp->desktop()->width()*3/4 || h > qApp->desktop()->height()*3/4 ) ) { d->showMaximized(); } else { d->resize(w,h); d->show(); } } -int QPEApplication::execDialog( QDialog* d, bool nomax) { - showDialog(d,nomax); - return d->exec(); -} + void QPEApplication::setKeepRunning() { if ( qApp && qApp->inherits( "QPEApplication" ) ) { QPEApplication * qpeApp = ( QPEApplication* ) qApp; qpeApp->d->keep_running = TRUE; } } bool QPEApplication::keepRunning()const { return d->keep_running; } bool QPEApplication::keyboardGrabbed()const { return d->kbgrabber; } int QPEApplication::exec() { /* now send the QCOP stuff gotten from the file */ d->sendQCopQ(); if ( d->keep_running ) { qWarning("going to exec"); int a = QApplication::exec(); qWarning("left"); return a; } { QCopEnvelope e( "QPE/System", "closing(QString)" ); e << d->appName; } qWarning("processing events!"); processEvents(); return 0; } void QPEApplication::internalSetStyle( const QString& ) { } void QPEApplication::systemMessage( const QCString& chan, const QByteArray& ) { qWarning("QPEApplication::systemMessage( %s )", chan.data() ); } void QPEApplication::pidMessage( const QCString& msg, const QByteArray& ) { if ( msg == "flush()" ) { emit flush(); QCopEnvelope e( "QPE/Desktop", "flushDone(QString)" ); e << d->appName; }else if ( msg == "reload()" ) { emit reload(); } } void QPEApplication::timerEvent( QTimerEvent* e ) { @@ -712,85 +717,90 @@ void QPEApplication::prepareForTermination( bool willrestart ) // QWidget *d = QApplication::desktop(); QImage img = Resource::loadImage( "launcher/new_wait" ); QPixmap pix; pix.convertFromImage( img.smoothScale( 1 * img.width(), 1 * img.height() ) ); QLabel *lblWait = new QLabel( 0, "wait hack!", QWidget::WStyle_Customize | QWidget::WStyle_NoBorder | QWidget::WStyle_Tool ); lblWait->setPixmap( pix ); lblWait->setAlignment( QWidget::AlignCenter ); lblWait->show(); lblWait->showMaximized(); } #ifndef SINGLE_APP { QCopEnvelope envelope( "QPE/System", "forceQuit()" ); } processEvents(); // ensure the message goes out. sleep( 1 ); // You have 1 second to comply. #endif } int QPEApplication::x11ClientMessage(QWidget* w, XEvent* event, bool b ) { qWarning("X11 ClientMessage %d %d", event->type, ClientMessage); if ( event->type == ClientMessage ) { if ( (event->xclient.message_type == d->wm_protocols) && (event->xclient.data.l[0] == d->wm_context_accept ) ) { qWarning("accepted!!!"); /* * I'm not sure if we should use activeWidget * or activeModalWidget * a QDialog could be not modal too */ if ( w->inherits("QDialog" ) ) { qWarning("inherits QDialog!!!"); QDialog* dia = (QDialog*)w; /* * call it directly or via QTimer::singleShot? */ QTimer::singleShot(0, dia, SLOT(accept() ) ); return 0; } } } return QApplication::x11ClientMessage(w, event, b ); } #define KeyPress XKeyPress #define KeyRelease XKeyRelease #if defined(OPIE_NEW_MALLOC) +#define likely(x) x // 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 ) { + if ( likely(p) ) free( p ); } void operator delete[]( void* p, size_t /*size*/ ) { + if ( likely(p) ) free( p ); } void operator delete( void* p ) { + if ( likely(p) ) free( p ); } void operator delete( void* p, size_t /*size*/ ) { + if ( likely(p) ) free( p ); } #endif diff --git a/x11/libqpe-x11/qpe/qpeapplication.h b/x11/libqpe-x11/qpe/qpeapplication.h index b1fc074..5521998 100644 --- a/x11/libqpe-x11/qpe/qpeapplication.h +++ b/x11/libqpe-x11/qpe/qpeapplication.h @@ -1,97 +1,99 @@ #ifndef OPIE_QPE_APPLICATION_H #define OPIE_QPE_APPLICATION_H /** * LGPLed */ #include <qapplication.h> #include <qevent.h> - -#include <qpe/timestring.h> +#include <qtopia/timestring.h> +#include <unistd.h> +#include <stdlib.h> class QCopChannel; class QPEApplication : public QApplication { Q_OBJECT public: QPEApplication(int& argc, char** argv, Type=GuiClient ); ~QPEApplication(); static QString qpeDir(); static QString documentDir(); void applyStyle(); static int defaultRotation(); static void setDefaultRotation( int r ); static void grabKeyboard(); static void ungrabKeyboard(); enum StylusMode { LeftOnly, RightOnHold }; static void setStylusOperation( QWidget*, StylusMode ); static StylusMode stylusOperation( QWidget* ); enum InputMethodHint { Normal, AlwaysOff, AlwaysOn }; static void setInputMethodHint( QWidget*, InputMethodHint ); static InputMethodHint inputMethodHint( QWidget* ); void showMainWidget( QWidget*, bool nomax = FALSE ); void showMainDocumentWidget( QWidget*, bool nomax = FALSE ); static void showDialog( QDialog*, bool nomax = FALSE ); static int execDialog( QDialog*, bool nomax = FALSE ); + static void showWidget( QWidget*, bool nomax = FALSE ); static void setKeepRunning(); bool keepRunning()const; bool keyboardGrabbed()const; int exec(); // QWS bits enum screenSaverHint { Disable = 0, DisableLightOff = 1, DisableSuspend = 2, Enable = 100 }; /* reimplemented for internal purposes */ int x11ClientMessage( QWidget*, XEvent*, bool ); signals: void clientMoused(); void timeChanged(); void clockChanged( bool pm ); void micChanged( bool muted ); void volumeChanged( bool muted ); void appMessage( const QCString& msg, const QByteArray& data); void weekChanged( bool startOnMonday ); void dateFormatChanged( DateFormat ); void flush(); void reload(); private: void initTranslations(); void internalSetStyle(const QString&); private slots: void hideOrQuit(); void systemMessage( const QCString&, const QByteArray& ); void pidMessage( const QCString&, const QByteArray& ); void removeSenderFromStylusDict(); protected: virtual void restart(); virtual void shutdown(); void prepareForTermination(bool willrestart); bool eventFilter( QObject*, QEvent* ); void timerEvent( QTimerEvent* ); void raiseAppropriateWindow(); virtual void tryQuit(); private: diff --git a/x11/libqpe-x11/qt/qwindowsystem_qws.h b/x11/libqpe-x11/qt/qwindowsystem_qws.h index 88902c8..42470cd 100644 --- a/x11/libqpe-x11/qt/qwindowsystem_qws.h +++ b/x11/libqpe-x11/qt/qwindowsystem_qws.h @@ -1,37 +1,40 @@ #ifndef OPIE_QWINDOWSYSTEM_H #define OPIE_QWINDOWSYSTEM_H #include <qimage.h> class QWSScreenSaver; class QWSServer { public: QWSServer(){} ~QWSServer(){} static void sendKeyEvent(int, int, int, bool, bool ) { } struct KeyboardFilter { + bool filter(int,int,int,bool,bool) { + return false; + } }; static void setKeyboardFilter( KeyboardFilter* ) { } static void setScreenSaver( QWSScreenSaver* ) { } static void setScreenSaverInterval( int ) { } static void setScreenSaverIntervals( int[] ) { } static void screenSaverActivate( bool ) { } static void setDesktopBackground( const QImage& ) { } }; struct QWSScreenSaver { }; #endif |