Esempio n. 1
0
void StylesPlugin::setStyles()
{
    QStyle *style = NULL;
#if QT_VERSION >= 300
    if (*getStyle())
        style = QStyleFactory::create(getStyle());
#else
if (*getStyle()){
    string s = getStyle();
    if (s == "windows"){
        style = new QWindowsStyle;
    }else if (s == "motif"){
        style = new QMotifStyle;
    }else if (s == "cde"){
        style = new QCDEStyle;
    }else if (s == "motifplus"){
        style = new QMotifPlusStyle;
    }else if (s == "platinum"){
        style = new QPlatinumStyle;
    }else if (s == "sgi"){
        style = new QSGIStyle;
#ifdef WIN32
    }else{
        bool bOK = true;
        if (s == "xpstyle"){
            HINSTANCE hLib = LoadLibraryA("UxTheme.dll");
            if (hLib){
                FreeLibrary(hLib);
            }else{
                bOK = false;
            }
        }
        if (bOK){
            string dll = "plugins\\styles\\";
            dll += s;
            dll += ".dll";
            HINSTANCE hLib = LoadLibraryA(app_file(dll.c_str()).c_str());
            if (hLib){
                StyleInfo*  (*getStyleInfo)() = NULL;
                (DWORD&)getStyleInfo = (DWORD)GetProcAddress(hLib,"GetStyleInfo");
                if (getStyleInfo){
                    StyleInfo *info = getStyleInfo();
                    if (info && info->create)
                        style = info->create();
                }
            }
        }
#endif
    }
}
#endif
    if (style){
        QApplication::setStyle(style);
        if (!getSystemColors())
            setColors();
    }else{
        setStyle(NULL);
    }
}
Esempio n. 2
0
int main(int argc, char *argv[])
{
    int res = 1;
#ifdef WIN32
    HANDLE hMutex = CreateMutexA(NULL, FALSE, "SIM_Mutex");
#endif
    QApplication::setColorSpec( QApplication::ManyColor );
    qInstallMsgHandler(simMessageOutput);
    KAboutData aboutData(PACKAGE,
                         I18N_NOOP("SIM"),
                         _VERSION,
                         I18N_NOOP("Multiprotcol instant messenger"),
                         KAboutData::License_GPL,
                         "Copyright (C) 2002-2004, Vladimir Shutoff",
                         0,
                         "http://sim-icq.sourceforge.net/",
                         "*****@*****.**");
    aboutData.addAuthor("Vladimir Shutoff",I18N_NOOP("Maintainer"),"*****@*****.**");
    aboutData.addAuthor("Christian Ehrlicher",I18N_NOOP("Developer"),"*****@*****.**");
    setAboutData(&aboutData);
#ifndef WIN32
    int _argc = 0;
    char **_argv = new char*[argc + 1];
    _argv[_argc++] = argv[0];
    char **to = argv + 1;
    // check all parameters and sort them
    // _argc/v: parameter for KUnqiueApplication
    //  argc/v: plugin parameter
    for (char **p = argv + 1; *p; ++p){
        char *arg = *p;
        // check if "-" or "--"
        if (arg[0] != '-') {
            *(to++) = *p;
            continue;
        }
        arg++;
        if (arg[0] == '-')
            arg++;
        // if they are parameters with variable params we need
        // to skip the next param
        bool bSkip = false;
        const char **q;
        // check for qt or kde - parameters
        for (q = qt_args; *q; ++q){
            unsigned len = strlen(*q);
            bSkip = false;
            // variable parameter?
            if ((*q)[len-1] == ':'){
                len--;
                bSkip = true;
            }
            // copy them for KUnqiueApplication-args
            if ((strlen(arg) == len) && !memcmp(arg, *q, len))
                break;
        }
        // dunno know what to do here
        if (*q){
            _argv[_argc++] = *p;
            argc--;
            if (bSkip){
                ++p;
                if (*p == NULL) break;
                _argv[_argc++] = *p;
                argc--;
            }
        }else{
            *(to++) = *p;
        }
    }
    *to = NULL;
    _argv[_argc] = NULL;
#ifdef USE_KDE
    KCmdLineArgs::init( _argc, _argv, &aboutData );
    KCmdLineOptions options[] =
        {
            { 0, 0, 0 }
        };
    KCmdLineArgs::addCmdLineOptions( options );
    KUniqueApplication::addCmdLineOptions();
    if (!KUniqueApplication::start())
        exit(-1);
    SimApp app;
#else
    SimApp app(_argc, _argv);
#endif
#ifndef QT_MACOSX_VERSION
    old_errhandler = XSetErrorHandler(x_errhandler);
#endif
#else
	for (int i = 0; i < argc; i++){
		string arg = argv[i];
		if ((arg[0] == '/') || (arg[0] == '-'))
			arg = arg.substr(1);
		if ((arg == "reinstall") || (arg == "showicons") || (arg == "hideicons"))
			return 0;
	}
    SimApp app(argc, argv);
    StyleInfo*  (*getStyleInfo)() = NULL;
    HINSTANCE hLib = LoadLibraryA("UxTheme.dll");
    if (hLib != NULL)
        hLib = LoadLibraryA(app_file("plugins\\styles\\xpstyle.dll").c_str());
    if (hLib != NULL)
        (DWORD&)getStyleInfo = (DWORD)GetProcAddress(hLib,"GetStyleInfo");
    if (getStyleInfo){
        StyleInfo *info = getStyleInfo();
        if (info)
            qApp->setStyle(info->create());
    }
#endif
    PluginManager p(argc, argv);
    if (p.isLoaded())
        res = app.exec();
#ifdef WIN32
    CloseHandle(hMutex);
#endif
    return res;
};