author | zecke <zecke> | 2003-10-07 13:03:51 (UTC) |
---|---|---|
committer | zecke <zecke> | 2003-10-07 13:03:51 (UTC) |
commit | 2ffa87f9e7f7f5c3db3f18880aa1040e870b2ba7 (patch) (side-by-side diff) | |
tree | 05d7a3b407325fe71dce9ea23b817decd0403ea4 | |
parent | 75f35445e9f3ec2f730f779d67f4189296bd9c5e (diff) | |
download | opie-2ffa87f9e7f7f5c3db3f18880aa1040e870b2ba7.zip opie-2ffa87f9e7f7f5c3db3f18880aa1040e870b2ba7.tar.gz opie-2ffa87f9e7f7f5c3db3f18880aa1040e870b2ba7.tar.bz2 |
use OPIE_NEW_MALLOC as well
-rw-r--r-- | x11/libqpe-x11/qpe/qpeapplication.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/x11/libqpe-x11/qpe/qpeapplication.cpp b/x11/libqpe-x11/qpe/qpeapplication.cpp index eb01e50..0a98481 100644 --- a/x11/libqpe-x11/qpe/qpeapplication.cpp +++ b/x11/libqpe-x11/qpe/qpeapplication.cpp @@ -374,422 +374,422 @@ QString QPEApplication::documentDir() { 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::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 ) { 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 ) { if ( e->timerId() == d->presstimer && d->presswidget ) { // Right pressed postEvent( d->presswidget, new QMouseEvent( QEvent::MouseButtonPress, d->presspos, RightButton, LeftButton ) ); killTimer( d->presstimer ); d->presstimer = 0; } } // InputMethods Hints namespace { static QPtrDict<void>* inputMethodDict = 0; static void createInputMethodDict(){ if ( !inputMethodDict ) inputMethodDict = new QPtrDict<void>; } static QPtrDict<void>* stylusDict = 0; static void createDict() { if ( !stylusDict ) stylusDict = new QPtrDict<void>; } }; void QPEApplication::setInputMethodHint( QWidget* w, InputMethodHint mode ) { createInputMethodDict(); if ( mode == Normal ) { inputMethodDict->remove ( w ); }else { inputMethodDict->insert( w, ( void* ) mode ); } } QPEApplication::InputMethodHint QPEApplication::inputMethodHint( QWidget* w) { if ( inputMethodDict && w ) return ( InputMethodHint ) ( int ) inputMethodDict->find( w ); return Normal; } void QPEApplication::removeSenderFromStylusDict() { stylusDict->remove( ( void* ) sender() ); if ( d->presswidget == sender() ) d->presswidget = 0; } void QPEApplication::setStylusOperation( QWidget* w, StylusMode mode) { createDict(); if ( mode == LeftOnly ) { stylusDict->remove ( w ); w->removeEventFilter( qApp ); }else { stylusDict->insert( w, ( void* ) mode ); connect( w, SIGNAL( destroyed() ), qApp, SLOT( removeSenderFromStylusDict() ) ); w->installEventFilter( qApp ); } } QPEApplication::StylusMode QPEApplication::stylusOperation( QWidget* w) { if ( stylusDict ) return ( StylusMode ) ( int ) stylusDict->find( w ); return LeftOnly; } // eventFilter...... bool QPEApplication::eventFilter( QObject* o, QEvent* e ) { /* * We want our WM to show Ok and a X button * on dialogs * our part is to set the _NET_WM_CONTEXT_ACCEPT * propery * and then wait for a client message -zecke * on show we will add the prop */ if (o->inherits("QDialog") && e->type() == QEvent::Show ) { QDialog* dialog = (QDialog*)o; Atom wm_prot[45]; int n = 0; wm_prot[n++] = d->wm_delete_window; wm_prot[n++] = d->wm_take_focus; wm_prot[n++] = d->wm_context_accept; if ( dialog->testWFlags( WStyle_ContextHelp ) ) wm_prot[n++] = d->wm_context_help; XSetWMProtocols( qt_xdisplay(), dialog->winId(), wm_prot, n ); return TRUE; // should be save } if ( stylusDict && e->type() >= QEvent::MouseButtonPress && e->type() <= QEvent::MouseMove ) { QMouseEvent * me = ( QMouseEvent* ) e; StylusMode mode = (StylusMode)(int)stylusDict->find(o); switch (mode) { case RightOnHold: switch ( me->type() ) { case QEvent::MouseButtonPress: if ( me->button() == LeftButton ) { d->presstimer = startTimer(500); // #### pref. d->presswidget = (QWidget*)o; d->presspos = me->pos(); d->rightpressed = FALSE; } break; case QEvent::MouseMove: if (d->presstimer && (me->pos() - d->presspos).manhattanLength() > 8) { killTimer(d->presstimer); d->presstimer = 0; } break; case QEvent::MouseButtonRelease: if ( me->button() == LeftButton ) { if ( d->presstimer ) { killTimer(d->presstimer); d->presstimer = 0; } if ( d->rightpressed && d->presswidget ) { // Right released postEvent( d->presswidget, new QMouseEvent( QEvent::MouseButtonRelease, me->pos(), RightButton, LeftButton + RightButton ) ); // Left released, off-widget postEvent( d->presswidget, new QMouseEvent( QEvent::MouseMove, QPoint( -1, -1), LeftButton, LeftButton ) ); postEvent( d->presswidget, new QMouseEvent( QEvent::MouseButtonRelease, QPoint( -1, -1), LeftButton, LeftButton ) ); d->rightpressed = FALSE; return TRUE; // don't send the real Left release } } break; default: break; } break; default: ; } } else if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { QKeyEvent *ke = (QKeyEvent *)e; if ( ke->key() == Key_Enter ) { if ( o->isA( "QRadioButton" ) || o->isA( "QCheckBox" ) ) { postEvent( o, new QKeyEvent( e->type(), Key_Space, ' ', ke->state(), " ", ke->isAutoRepeat(), ke->count() ) ); return TRUE; } } } return FALSE; } // Quit stuff void QPEApplication::restart() { } void QPEApplication::shutdown() { } void QPEApplication::tryQuit() { qWarning("TryQuit!!"); if ( activeModalWidget() || strcmp( argv() [ 0 ], "embeddedkonsole" ) == 0 ) return ; // Inside modal loop or konsole. Too hard to save state. { QCopEnvelope e( "QPE/System", "closing(QString)" ); e << d->appName; } processEvents(); quit(); } void QPEApplication::hideOrQuit() { qWarning("hide or close"); processEvents(); qWarning("past processing"); // 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 ) { qWarning("hiding"); QCopEnvelope e("QPE/System", "fastAppHiding(QString)" ); e << d->appName; d->qpe_main_widget->hide(); } else quit(); } /*! \internal */ void QPEApplication::prepareForTermination( bool willrestart ) { if ( willrestart ) { // Draw a big wait icon, the image can be altered in later revisions // 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(QT_QWS_IPAQ) || defined(QT_QWS_SL5XXX) +#if defined(OPIE_NEW_MALLOC) // 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 |