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 TARGET = inputpanel
DEFINES += PLUGIN_PATH=$$clean_path( $$QSK_OUT_ROOT/plugins )
SOURCES += \ SOURCES += \
main.cpp main.cpp

View File

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

View File

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