-rw-r--r-- | x11/libqpe-x11/qpe/qpeapplication.cpp | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/x11/libqpe-x11/qpe/qpeapplication.cpp b/x11/libqpe-x11/qpe/qpeapplication.cpp index 0a98481..0fce355 100644 --- a/x11/libqpe-x11/qpe/qpeapplication.cpp +++ b/x11/libqpe-x11/qpe/qpeapplication.cpp @@ -1,277 +1,278 @@ #define QTOPIA_INTERNAL_LANGLIST #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <sys/file.h> #include <qdir.h> #include <qdialog.h> #include <qdragobject.h> #include <qevent.h> #include <qlabel.h> #include <qlist.h> #include <qtextstream.h> #include <qtextcodec.h> #include <qpalette.h> #include <qptrdict.h> #include <qregexp.h> #include <qtimer.h> +#include <qpe/custom.h> #include <qpe/alarmserver.h> #include <qpe/applnk.h> #include <qpe/qpemenubar.h> #include <qpe/textcodecinterface.h> #include <qpe/imagecodecinterface.h> #include <qpe/qlibrary.h> #include <qpe/qpestyle.h> #include <qpe/styleinterface.h> #include <qpe/global.h> #include <qpe/resource.h> #include <qpe/config.h> #include <qpe/network.h> #include <qpe/qpeapplication.h> #include <qpe/timestring.h> #include <qpe/qcopenvelope_qws.h> #include <X11/Xlib.h> #include <X11/Xutil.h> const int XKeyPress = KeyPress; const int XKeyRelease = KeyRelease; #undef KeyPress #undef KeyRelease namespace { struct QCopRec{ QCopRec( const QCString& ch, const QCString& msg, const QByteArray& ar ) : channel(ch), message(msg), data(ar) { } QCString channel; QCString message; QByteArray data; }; }; class QPEApplication::Private { public: Private(); ~Private(); void enqueueQCop( const QCString& ch, const QCString& msg, const QByteArray& ); void sendQCopQ(); static void show_mx(QWidget* mw, bool nomaximize ); void show( QWidget* mw, bool nomax ); void loadTextCodecs(); void loadImageCodecs(); int kbgrabber; int presstimer; bool rightpressed : 1; bool kbregrab : 1; bool notbusysent : 1; bool preloaded : 1; bool forceshow : 1; bool nomaximize : 1; bool keep_running : 1; QWidget* presswidget; QPoint presspos; QWidget* qpe_main_widget; QString appName; QString styleName; QString decorationName; Atom wm_delete_window; Atom wm_take_focus; Atom wm_context_help; Atom wm_context_accept; Atom wm_protocols; private: QList<QCopRec> qcopq; }; QPEApplication::Private::~Private() { } QPEApplication::Private::Private() : kbgrabber(0 ), presstimer(0 ), rightpressed( FALSE ), kbregrab( FALSE ), notbusysent( FALSE ), preloaded( FALSE ), forceshow( FALSE ), nomaximize( FALSE ), keep_running( TRUE ), presswidget( 0 ), qpe_main_widget(0 ) { qcopq.setAutoDelete( TRUE ); } void QPEApplication::Private::enqueueQCop( const QCString& chan, const QCString& msg, const QByteArray& ar ) { qcopq.append( new QCopRec(chan, msg, ar ) ); } void QPEApplication::Private::sendQCopQ() { QCopRec* r; for ( r = qcopq.first(); r; r = qcopq.next() ) { QCopChannel::sendLocally( r->channel, r->message, r->data ); } qcopq.clear(); } void QPEApplication::Private::show_mx(QWidget* mw, bool nomaximize ) { if (mw->layout() && mw->inherits("QDialog") ) { QPEApplication::showDialog( (QDialog*)mw, nomaximize ); }else { if (!nomaximize ) mw->showMaximized(); else mw->show(); } } void QPEApplication::Private::show( QWidget* mw, bool nomax ) { nomaximize = nomax; qpe_main_widget = mw; sendQCopQ(); if ( preloaded ) { if (forceshow ) show_mx(mw, nomax ); }else if ( keep_running ) show_mx( mw, nomax ); } void QPEApplication::Private::loadTextCodecs() { QString path = QPEApplication::qpeDir() + "/plugins/textcodecs"; QDir dir( path, "lib*.so" ); QStringList list = dir.entryList(); QStringList::Iterator it; for ( it = list.begin(); it != list.end(); ++it ) { TextCodecInterface *iface = 0; QLibrary *lib = new QLibrary( path + "/" + *it ); if ( lib->queryInterface( IID_QtopiaTextCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { QValueList<int> mibs = iface->mibEnums(); for (QValueList<int>::ConstIterator i = mibs.begin(); i != mibs.end(); ++i) { (void)iface->createForMib(*i); // ### it exists now; need to remember if we can delete it } } else { lib->unload(); delete lib; } } } void QPEApplication::Private::loadImageCodecs() { QString path = QPEApplication::qpeDir() + "/plugins/imagecodecs"; QDir dir( path, "lib*.so" ); QStringList list = dir.entryList(); 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; } } } // The Help System hook namespace { class ResourceMimeFactory : public QMimeSourceFactory { public: ResourceMimeFactory(); ~ResourceMimeFactory(); const QMimeSource* data( const QString& abs_name )const; }; ResourceMimeFactory::ResourceMimeFactory() { setFilePath( Global::helpPath() ); setExtensionType( "html", "text/html;charset=UTF-8" ); } ResourceMimeFactory::~ResourceMimeFactory() { } const QMimeSource* ResourceMimeFactory::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 ); } while ( !r && sl > 0 ); } return r; }; }; // QPEApplication QPEApplication::~QPEApplication() { qWarning("~QPEApplication"); ungrabKeyboard(); qWarning("UngrabKeyboard"); // delete m_sys; // delete m_pid; delete d; } QPEApplication::QPEApplication(int &arg, char** argv, Type t) : QApplication( arg, argv, t ) { d = new Private; d->loadTextCodecs(); d->loadImageCodecs(); // Init X-Atom Atom *atoms[5]; Atom atoms_re[5]; char* names[5]; int n = 0; atoms[n] = &d->wm_delete_window; names[n++] = "WM_DELETE_WINDOW"; atoms[n] = &d->wm_take_focus; names[n++] = "WM_TAKE_FOCUS"; atoms[n] = &d->wm_context_help; names[n++] = "_NET_WM_CONTEXT_HELP"; atoms[n] = &d->wm_context_accept; names[n++] = "_NET_WM_CONTEXT_ACCEPT"; atoms[n] = &d->wm_protocols; names[n++] = "WM_PROTOCOLS"; XInternAtoms( qt_xdisplay(), names, n, FALSE, atoms_re); // now copy the values over to the properties for (int i = 0; i < n; i++ ) *atoms[i] = atoms_re[i]; // done with X11 Stuff int dw = desktop()->width(); if ( dw < 200 ) { setFont( QFont( "helvetica", 8 ) ); AppLnk::setSmallIconSize( 10 ); AppLnk::setBigIconSize( 28 ); }else if ( dw > 600 ) { setFont( QFont( "helvetica", 12 ) ); AppLnk::setSmallIconSize( 24 ); AppLnk::setBigIconSize( 48 ); }else if ( dw > 200 ) { setFont( QFont( "helvetica", 10 ) ); AppLnk::setSmallIconSize( 16 ); AppLnk::setBigIconSize( 32 ); } |