author | sandman <sandman> | 2002-06-29 00:25:26 (UTC) |
---|---|---|
committer | sandman <sandman> | 2002-06-29 00:25:26 (UTC) |
commit | 971f94ceb114149efbf8d90b607d25dcbd358435 (patch) (side-by-side diff) | |
tree | df106209331f0e8a8c79c839ccfb4a8a8c7ac97c /library/qpeapplication.cpp | |
parent | 0552cd7f5762939ccdf05b9bf4fdae9b3e79b0a5 (diff) | |
download | opie-971f94ceb114149efbf8d90b607d25dcbd358435.zip opie-971f94ceb114149efbf8d90b607d25dcbd358435.tar.gz opie-971f94ceb114149efbf8d90b607d25dcbd358435.tar.bz2 |
Modified my "liquid only hack" - appearance now scans plugins/styles for
external styles and qpeapplication tries to load them
-rw-r--r-- | library/qpeapplication.cpp | 61 |
1 files changed, 45 insertions, 16 deletions
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp index 76d62ef..6e2db7c 100644 --- a/library/qpeapplication.cpp +++ b/library/qpeapplication.cpp @@ -73,4 +73,7 @@ #include <qmotifplusstyle.h> #include "lightstyle.h" + +#include <qpe/qlibrary.h> +#include <dlfcn.h> #endif #include "global.h" @@ -102,5 +105,4 @@ #include <stdlib.h> -#include <dlfcn.h> // for Liquid HACK class QPEApplicationData { @@ -1329,21 +1331,48 @@ void QPEApplication::internalSetStyle( const QString &style ) // 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 ( !lib ) { - QString path = QPEApplication::qpeDir() + "/plugins/styles/" + "libliquid.so"; - lib = ::dlopen ( path. local8Bit ( ), RTLD_NOW | RTLD_GLOBAL ); - } - if ( lib ) { - void *sym = ::dlsym ( lib, "allocate" ); + 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"; - if ( sym ) - sty = ((QStyle * (*) ( )) sym ) ( ); - } - if ( sty ) - setStyle ( sty ); + // 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 ) { + //QStyle * (*fpa) ( ) = (QStyle * (*) ( )) lib-> resolve ( "allocate" ); + QStyle * (*fpa) ( ) = (QStyle * (*) ( )) ::dlsym ( lib, "allocate" ); + + 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 |