initializing QT_PLUGIN_PATH before main

This commit is contained in:
Uwe Rathmann 2019-03-17 17:13:32 +01:00
parent 9a294227a4
commit 727787abaf
3 changed files with 26 additions and 28 deletions

View File

@ -2,7 +2,5 @@ include( $${PWD}/../playground.pri )
TARGET = inputpanel
DEFINES += PLUGIN_PATH=$$clean_path( $$QSK_OUT_ROOT/plugins )
SOURCES += \
main.cpp

View File

@ -22,9 +22,6 @@
#include <QFontMetricsF>
#include <QGuiApplication>
#define STRINGIFY( x ) #x
#define STRING( x ) STRINGIFY( x )
static inline QString nativeLocaleString( const QLocale& locale )
{
switch ( locale.language() )
@ -287,10 +284,7 @@ int main( int argc, char* argv[] )
QskObjectCounter counter( true );
#endif
#if 1
qputenv( "QT_IM_MODULE", "skinny" );
qputenv( "QT_PLUGIN_PATH", STRING( PLUGIN_PATH ) );
#endif
QGuiApplication app( argc, argv );

View File

@ -3,41 +3,46 @@
* This file may be used under the terms of the 3-clause BSD License
*****************************************************************************/
#if defined( ENSURE_SKINS )
#include <QskSkinManager.h>
#include <squiek/QskSquiekSkinFactory.h>
#include <material/QskMaterialSkinFactory.h>
#include <iostream>
#endif
#if defined( PLUGIN_PATH )
#include <QCoreApplication>
#include <QByteArray>
#include <QDir>
#define STRINGIFY(x) #x
#define STRING(x) STRINGIFY(x)
#endif
static void initPlugins()
static int initPluginPath()
{
#if defined( PLUGIN_PATH )
const char env[] = "QT_PLUGIN_PATH";
QByteArray value = qgetenv( env );
if ( !value.isEmpty() && QChar( value[ value.size() - 1 ] ) != QDir::listSeparator() )
value += QDir::listSeparator();
if ( !value.isEmpty() )
{
if ( QChar( value.at( value.size() - 1 ) ) != QDir::listSeparator() )
value += QDir::listSeparator();
}
value += STRING( PLUGIN_PATH );
qputenv( "QT_PLUGIN_PATH", value );
#endif
qputenv( env, value );
return 0;
}
// some plugins are loaded before entering QCoreApplication
static bool pluginPath = initPluginPath();
#endif // PLUGIN_PATH
#if defined( ENSURE_SKINS )
#include <QskSkinManager.h>
#include <squiek/QskSquiekSkinFactory.h>
#include <material/QskMaterialSkinFactory.h>
#include <QCoreApplication>
#include <iostream>
static void initSkins()
{
if ( qskSkinManager->skinNames().isEmpty() )
{
using namespace std;
@ -52,7 +57,8 @@ static void initPlugins()
cout << "Couldn't find skin plugins, adding some manually." << endl;
}
#endif
}
Q_COREAPP_STARTUP_FUNCTION( initPlugins )
Q_COREAPP_STARTUP_FUNCTION( initSkins )
#endif // ENSURE_SKINS