#include "qtkde.h" #include #include #include #include #include #include #include #include #include extern Time qt_x_time; static QString convertFileFilter( const QString& filter ) { if( filter.isEmpty()) return filter; QString f2 = filter; f2.replace( '\n', ";;" ); // Qt says separator is ";;", but it also silently accepts newline f2.replace( '/', "\\/" ); // escape /'s for KFileDialog QStringList items = QStringList::split( ";;", f2 ); QRegExp reg( "\\((.*)\\)" ); for( QStringList::Iterator it = items.begin(); it != items.end(); ++it ) { if( reg.search( *it )) *it = reg.cap( 1 ) + '|' + *it; } return items.join( "\n" ); } static QString convertBackFileFilter( const QString& filter ) { if( filter.isEmpty()) return filter; QStringList items = QStringList::split( "\n", filter ); for( QStringList::Iterator it = items.begin(); it != items.end(); ++it ) { int pos = (*it).find( '|' ); if( pos >= 0 ) (*it) = (*it).mid( pos + 1 ); } return items.join( ";;" ); } static DCOPClient* dcopClient() { DCOPClient* dcop = DCOPClient::mainClient(); if( dcop == NULL ) { static DCOPClient* dcop_private; if( dcop_private == NULL ) { dcop_private = new DCOPClient; dcop_private->attach(); } dcop = dcop_private; } static bool prepared = false; if( !prepared ) { assert( qApp != NULL ); // TODO prepared = true; dcop->bindToApp(); if( !qApp->inherits( "KApplication" )) // KApp takes care of input blocking { static qtkde_EventLoop* loop = new qtkde_EventLoop; QObject::connect( dcop, SIGNAL( blockUserInput( bool )), loop, SLOT( block( bool ))); } } return dcop; } // defined in qapplication_x11.cpp typedef int (*QX11EventFilter) (XEvent*); extern QX11EventFilter qt_set_x11_event_filter (QX11EventFilter filter); static QX11EventFilter old_filter; static int input_filter( XEvent* e ) { switch( e->type ) { case ButtonPress: case ButtonRelease: case KeyPress: case KeyRelease: case MotionNotify: case EnterNotify: case LeaveNotify: return true; default: break; } if( old_filter != NULL ) return old_filter( e ); return false; } void qtkde_EventLoop::block( bool b ) { if( b ) old_filter = qt_set_x11_event_filter( input_filter ); else qt_set_x11_event_filter( old_filter ); } // duped in kded module static QString getHostname() { char hostname[ 256 ]; if( gethostname( hostname, 255 ) == 0 ) { hostname[ 255 ] = '\0'; return hostname; } return ""; } #include "qtkde_functions.cpp" #include "qtkde.moc"