diff options
author | Ken Moore <moorekou@gmail.com> | 2015-12-01 16:44:32 -0500 |
---|---|---|
committer | Ken Moore <moorekou@gmail.com> | 2015-12-01 16:44:32 -0500 |
commit | 2f521da9aa36926f5dc451a82ab68fd98d04aefd (patch) | |
tree | 77ded8c753cf87708d341880e8e38325a622b8c9 | |
parent | Add a link to the Lumina IRC channel in the lumina-info utility, and also cre... (diff) | |
download | lumina-2f521da9aa36926f5dc451a82ab68fd98d04aefd.tar.gz lumina-2f521da9aa36926f5dc451a82ab68fd98d04aefd.tar.bz2 lumina-2f521da9aa36926f5dc451a82ab68fd98d04aefd.zip |
Fix up the loading of locales through the StartMenu/Session. Now it will properly make the locale changes *if* it could properly load the locale (ensuring consistency between system/session).
-rw-r--r-- | libLumina/LuminaSingleApplication.cpp | 2 | ||||
-rw-r--r-- | libLumina/LuminaUtils.cpp | 8 | ||||
-rw-r--r-- | libLumina/LuminaUtils.h | 1 | ||||
-rw-r--r-- | libLumina/LuminaXDG.cpp | 2 | ||||
-rw-r--r-- | lumina-desktop/LSession.cpp | 4 | ||||
-rw-r--r-- | lumina-desktop/panel-plugins/appmenu/LAppMenuPlugin.cpp | 2 | ||||
-rw-r--r-- | lumina-desktop/panel-plugins/systemdashboard/SysMenuQuick.cpp | 2 | ||||
-rw-r--r-- | lumina-desktop/panel-plugins/systemstart/StartMenu.cpp | 9 |
8 files changed, 22 insertions, 8 deletions
diff --git a/libLumina/LuminaSingleApplication.cpp b/libLumina/LuminaSingleApplication.cpp index d349d57a..30507b5e 100644 --- a/libLumina/LuminaSingleApplication.cpp +++ b/libLumina/LuminaSingleApplication.cpp @@ -15,7 +15,7 @@ LSingleApplication::LSingleApplication(int &argc, char **argv, QString appname) : QApplication(argc, argv){ //Load the proper translation systems - cTrans = LUtils::LoadTranslation(this, appname); //save the translator for later + if(appname!="lumina-desktop"){ cTrans = LUtils::LoadTranslation(this, appname); }//save the translator for later //Initialize a couple convenience internal variables cfile = QDir::tempPath()+"/.LSingleApp-%1-%2-%3"; QString username = QString(getlogin()); diff --git a/libLumina/LuminaUtils.cpp b/libLumina/LuminaUtils.cpp index 0e836748..cad7f817 100644 --- a/libLumina/LuminaUtils.cpp +++ b/libLumina/LuminaUtils.cpp @@ -326,6 +326,14 @@ void LUtils::setLocaleEnv(QString lang, QString msg, QString time, QString num,Q } } +QString LUtils::currentLocale(){ + QString curr = getenv("LC_ALL");// = QLocale::system(); + if(curr.isEmpty()){ curr = getenv("LANG"); } + if(curr.isEmpty()){ curr = "en_US"; } + curr = curr.section(".",0,0); //remove any encodings off the end + return curr; +} + double LUtils::DisplaySizeToBytes(QString num){ //qDebug() << "Convert Num to Bytes:" << num; num = num.toLower().simplified(); diff --git a/libLumina/LuminaUtils.h b/libLumina/LuminaUtils.h index 90b07962..7b35b09d 100644 --- a/libLumina/LuminaUtils.h +++ b/libLumina/LuminaUtils.h @@ -63,6 +63,7 @@ public: //Other localization shortcuts static QStringList knownLocales(); //Note: This only lists locales known to Lumina (so the i18n files need to be installed) static void setLocaleEnv(QString lang, QString msg="", QString time="", QString num="" ,QString money="",QString collate="", QString ctype=""); + static QString currentLocale(); //Number format conversions static double DisplaySizeToBytes(QString num); //Turn a display size (like 50M or 50KB) into a double for calculations (bytes) diff --git a/libLumina/LuminaXDG.cpp b/libLumina/LuminaXDG.cpp index b3905aa9..c46a96a8 100644 --- a/libLumina/LuminaXDG.cpp +++ b/libLumina/LuminaXDG.cpp @@ -626,7 +626,7 @@ QIcon LXDG::findIcon(QString iconName, QString fallback){ if(version>=1.1){ ico.addFile(srch[i]+":"+iconName+".svg"); //could be loaded/parsed successfully }else{ - qDebug() << "Old SVG Version file:" << iconName+".svg Theme:" << srch[i]; + //qDebug() << "Old SVG Version file:" << iconName+".svg Theme:" << srch[i]; //qDebug() << "SVGInfo:" << svginfo; } }else{ diff --git a/lumina-desktop/LSession.cpp b/lumina-desktop/LSession.cpp index e92dc5a4..12d5b831 100644 --- a/lumina-desktop/LSession.cpp +++ b/lumina-desktop/LSession.cpp @@ -689,8 +689,10 @@ WId LSession::activeWindow(){ //Temporarily change the session locale (nothing saved between sessions) void LSession::switchLocale(QString localeCode){ - LUtils::setLocaleEnv(localeCode); //will set everything to this locale (no custom settings) currTranslator = LUtils::LoadTranslation(this, "lumina-desktop", localeCode, currTranslator); + if(currTranslator!=0 || localeCode=="en_US"){ + LUtils::setLocaleEnv(localeCode); //will set everything to this locale (no custom settings) + } emit LocaleChanged(); } diff --git a/lumina-desktop/panel-plugins/appmenu/LAppMenuPlugin.cpp b/lumina-desktop/panel-plugins/appmenu/LAppMenuPlugin.cpp index 5e8dc7ac..318d03fa 100644 --- a/lumina-desktop/panel-plugins/appmenu/LAppMenuPlugin.cpp +++ b/lumina-desktop/panel-plugins/appmenu/LAppMenuPlugin.cpp @@ -21,7 +21,7 @@ LAppMenuPlugin::LAppMenuPlugin(QWidget *parent, QString id, bool horizontal) : L connect(mainmenu, SIGNAL(aboutToHide()), this, SIGNAL(MenuClosed())); connect(mainmenu, SIGNAL(triggered(QAction*)), this, SLOT(LaunchItem(QAction*)) ); - connect(LSession::handle()->applicationMenu(), SIGNAL(AppMenuUpdated()), this, SIGNAL(UpdateMenu())); + connect(LSession::handle()->applicationMenu(), SIGNAL(AppMenuUpdated()), this, SLOT(UpdateMenu())); QTimer::singleShot(0,this, SLOT(OrientationChange())); //Update icons/sizes QTimer::singleShot(0,this, SLOT(UpdateMenu()) ); } diff --git a/lumina-desktop/panel-plugins/systemdashboard/SysMenuQuick.cpp b/lumina-desktop/panel-plugins/systemdashboard/SysMenuQuick.cpp index 8ce01c06..534b1b41 100644 --- a/lumina-desktop/panel-plugins/systemdashboard/SysMenuQuick.cpp +++ b/lumina-desktop/panel-plugins/systemdashboard/SysMenuQuick.cpp @@ -79,7 +79,7 @@ void LSysMenuQuick::UpdateMenu(){ QLocale curr; for(int i=0; i<locales.length(); i++){ QLocale loc(locales[i]); - ui->combo_locale->addItem(loc.nativeLanguageName(), locales[i]); //Make the display text prettier later + ui->combo_locale->addItem(loc.nativeLanguageName()+" ("+locales[i]+")", locales[i]); //Make the display text prettier later if(locales[i] == curr.name() || locales[i] == curr.name().section("_",0,0) ){ //Current Locale ui->combo_locale->setCurrentIndex(ui->combo_locale->count()-1); //the last item in the list right now diff --git a/lumina-desktop/panel-plugins/systemstart/StartMenu.cpp b/lumina-desktop/panel-plugins/systemstart/StartMenu.cpp index 043cbba0..c817b1a3 100644 --- a/lumina-desktop/panel-plugins/systemstart/StartMenu.cpp +++ b/lumina-desktop/panel-plugins/systemstart/StartMenu.cpp @@ -99,11 +99,13 @@ void StartMenu::UpdateAll(){ QStringList locales = LUtils::knownLocales(); ui->stackedWidget->setCurrentWidget(ui->page_main); //need to ensure the settings page is not active ui->combo_locale->clear(); - QLocale curr; + QString curr = LUtils::currentLocale(); + qDebug() << "Update Locales:" << locales; + qDebug() << "Current Locale:" << curr; for(int i=0; i<locales.length(); i++){ QLocale loc(locales[i]); - ui->combo_locale->addItem(loc.nativeLanguageName(), locales[i]); //Make the display text prettier later - if(locales[i] == curr.name() || locales[i] == curr.name().section("_",0,0) ){ + ui->combo_locale->addItem(loc.nativeLanguageName() +" ("+locales[i]+")", locales[i]); //Make the display text prettier later + if(locales[i] == curr || locales[i] == curr.section("_",0,0) ){ //Current Locale ui->combo_locale->setCurrentIndex(ui->combo_locale->count()-1); //the last item in the list right now } @@ -553,6 +555,7 @@ void StartMenu::on_combo_locale_currentIndexChanged(int){ if(ui->stackedWidget->currentWidget()!=ui->page_settings){ return; } QString locale = ui->combo_locale->currentData().toString(); emit CloseMenu(); + LSession::processEvents(); LSession::handle()->switchLocale(locale); } |