diff options
Diffstat (limited to 'libLumina')
-rw-r--r-- | libLumina/LuminaSingleApplication.cpp | 7 | ||||
-rw-r--r-- | libLumina/LuminaSingleApplication.h | 4 | ||||
-rw-r--r-- | libLumina/LuminaUtils.cpp | 26 |
3 files changed, 21 insertions, 16 deletions
diff --git a/libLumina/LuminaSingleApplication.cpp b/libLumina/LuminaSingleApplication.cpp index 32883036..2b3689d8 100644 --- a/libLumina/LuminaSingleApplication.cpp +++ b/libLumina/LuminaSingleApplication.cpp @@ -12,11 +12,14 @@ #include <unistd.h> //for getlogin() -LSingleApplication::LSingleApplication(int &argc, char **argv) : QApplication(argc, argv){ +LSingleApplication::LSingleApplication(int &argc, char **argv, QString appname) : QApplication(argc, argv){ + //Load the proper translation systems + LUtils::LoadTranslation(this, appname); //Initialize a couple convenience internal variables cfile = QDir::tempPath()+"/.LSingleApp-%1-%2"; QString username = QString(getlogin()); - QString appname = this->applicationName(); + //For locking the process use the official process name - not the user input (no masking) + appname = this->applicationName(); //Obscure the user/app in the filename (TO DO) //qDebug() << username << appname; //bool junk; diff --git a/libLumina/LuminaSingleApplication.h b/libLumina/LuminaSingleApplication.h index ba342327..44f282cb 100644 --- a/libLumina/LuminaSingleApplication.h +++ b/libLumina/LuminaSingleApplication.h @@ -26,10 +26,12 @@ #include <LuminaUtils.h> +//NOTE: This application type will automatically load the proper translation file(s) +// if the application name is set properly class LSingleApplication : public QApplication{ Q_OBJECT public: - LSingleApplication(int &argc, char **argv); + LSingleApplication(int &argc, char **argv, QString appname); ~LSingleApplication(); bool isPrimaryProcess(); diff --git a/libLumina/LuminaUtils.cpp b/libLumina/LuminaUtils.cpp index 83bf8c1c..c0d260dd 100644 --- a/libLumina/LuminaUtils.cpp +++ b/libLumina/LuminaUtils.cpp @@ -120,20 +120,20 @@ void LUtils::LoadTranslation(QApplication *app, QString appname){ if(langCode =="C" || langCode=="POSIX" || langCode.isEmpty()){ langEnc = "System"; //use the Qt system encoding } - qDebug() << "Loading Locale:" << appname << langCode << langEnc; - - //Setup the translator - /*if(CurTranslator != 0){ - //A Translator already loaded: unload it before loading the new one - app->removeTranslator(CurTranslator); - }*/ - QTranslator *CurTranslator = new QTranslator(); - //Use the shortened locale code if specific code does not have a corresponding file - if(!QFile::exists(LOS::LuminaShare()+"i18n/"+appname+"_" + langCode + ".qm") ){ - langCode.truncate( langCode.indexOf("_") ); + if(app !=0){ + qDebug() << "Loading Locale:" << appname << langCode << langEnc; + //Setup the translator + QTranslator *CurTranslator = new QTranslator(); + //Use the shortened locale code if specific code does not have a corresponding file + if(!QFile::exists(LOS::LuminaShare()+"i18n/"+appname+"_" + langCode + ".qm") ){ + langCode.truncate( langCode.indexOf("_") ); + } + CurTranslator->load( appname+QString("_") + langCode, LOS::LuminaShare()+"i18n/" ); + app->installTranslator( CurTranslator ); + }else{ + //Only going to set the encoding since no application given + qDebug() << "Loading System Encoding:" << langEnc; } - CurTranslator->load( appname+QString("_") + langCode, LOS::LuminaShare()+"i18n/" ); - app->installTranslator( CurTranslator ); //Load current encoding for this locale QTextCodec::setCodecForLocale( QTextCodec::codecForName(langEnc.toUtf8()) ); } |