-rw-r--r-- | library/qpeapplication.cpp | 55 |
1 files changed, 42 insertions, 13 deletions
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp index 76d62ef..6e2db7c 100644 --- a/library/qpeapplication.cpp +++ b/library/qpeapplication.cpp @@ -69,12 +69,15 @@ #else #include <qplatinumstyle.h> #include <qwindowsstyle.h> #include <qmotifstyle.h> #include <qmotifplusstyle.h> #include "lightstyle.h" + +#include <qpe/qlibrary.h> +#include <dlfcn.h> #endif #include "global.h" #include "resource.h" #if QT_VERSION <= 230 && defined(QT_NO_CODECS) #include "qutfcodec.h" #endif @@ -98,13 +101,12 @@ #include <linux/fb.h> #include <sys/types.h> #include <sys/stat.h> #endif #include <stdlib.h> -#include <dlfcn.h> // for Liquid HACK 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), @@ -1325,29 +1327,56 @@ void QPEApplication::internalSetStyle( const QString &style ) else if ( style == "MotifPlus" ) { setStyle( new QMotifPlusStyle ); } #endif // HACK for Qt2 only - else if ( style == "Liquid" ) { - static void *lib = 0; - QStyle *sty = 0; + else { + // style == "Liquid Style (libliquid.so)" (or "Windows XP (libxp.so)" + int p2 = style. findRev ( ']' ); + int p1 = style. findRev ( '[' ); + QString style2; + + if (( p1 > 0 ) && ( p2 > 0 ) && (( p1 + 1 ) < p2 )) + style2 = "lib" + style. mid ( p1 + 1, p2 - p1 - 1 ). lower ( ) + ".so"; + else + style2 = "lib" + style. lower ( ) + ".so"; + + // static QLibrary *currentlib = 0; + static void *currentlib = 0; + + QString path = QPEApplication::qpeDir ( ) + "/plugins/styles/" + style2; + + do { // try/catch simulation + // QLibrary *lib = new QLibrary ( path, QLibrary::Immediately ); + void *lib = ::dlopen ( path. local8Bit ( ), RTLD_NOW | RTLD_GLOBAL ); - if ( !lib ) { - QString path = QPEApplication::qpeDir() + "/plugins/styles/" + "libliquid.so"; - lib = ::dlopen ( path. local8Bit ( ), RTLD_NOW | RTLD_GLOBAL ); - } if ( lib ) { - void *sym = ::dlsym ( lib, "allocate" ); + //QStyle * (*fpa) ( ) = (QStyle * (*) ( )) lib-> resolve ( "allocate" ); + QStyle * (*fpa) ( ) = (QStyle * (*) ( )) ::dlsym ( lib, "allocate" ); - if ( sym ) - sty = ((QStyle * (*) ( )) sym ) ( ); - } - if ( sty ) + if ( fpa ) { + QStyle *sty = ( *fpa ) ( ); + + if ( sty ) { setStyle ( sty ); + + if ( currentlib ) { + //delete currentlib; + ::dlclose ( currentlib ); + } + currentlib = lib; + + break; + } + } + //delete lib; + ::dlclose ( lib ); + } + } while ( false ); } // HACK for Qt2 only #endif } /*! |