diff options
author | Ken Moore <ken@pcbsd.org> | 2015-01-02 07:56:52 -0500 |
---|---|---|
committer | Ken Moore <ken@pcbsd.org> | 2015-01-02 07:56:52 -0500 |
commit | a34c589d0a8733ca0869384b83515631774dd4f4 (patch) | |
tree | eed78607771938c0b8b072d15ef9f8bf9cca6132 | |
parent | Large update of XLib -> XCB usage (diff) | |
download | lumina-a34c589d0a8733ca0869384b83515631774dd4f4.tar.gz lumina-a34c589d0a8733ca0869384b83515631774dd4f4.tar.bz2 lumina-a34c589d0a8733ca0869384b83515631774dd4f4.zip |
Make sure that the system encoding is loaded with QTextCodec before doing any command-line argument parsing.
-rw-r--r-- | libLumina/LuminaSingleApplication.cpp | 7 | ||||
-rw-r--r-- | libLumina/LuminaSingleApplication.h | 4 | ||||
-rw-r--r-- | libLumina/LuminaUtils.cpp | 26 | ||||
-rw-r--r-- | lumina-open/main.cpp | 2 |
4 files changed, 23 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()) ); } diff --git a/lumina-open/main.cpp b/lumina-open/main.cpp index a508ca4d..7ce59e63 100644 --- a/lumina-open/main.cpp +++ b/lumina-open/main.cpp @@ -134,6 +134,8 @@ QString cmdFromUser(int argc, char **argv, QString inFile, QString extension, QS void getCMD(int argc, char ** argv, QString& binary, QString& args, QString& path){ //Get the input file + //Make sure to load the proper system encoding first + LUtils::LoadTranslation(0,""); //bypass application modification QString inFile; bool showDLG = false; //flag to bypass any default application setting if(argc > 1){ |