diff options
author | Ken Moore <moorekou@gmail.com> | 2015-07-21 16:18:56 -0400 |
---|---|---|
committer | Ken Moore <moorekou@gmail.com> | 2015-07-21 16:18:56 -0400 |
commit | 9563e097f85d862aa3647e2d4ede759fd6048df1 (patch) | |
tree | 9d3728ffbe2075861a7fe4fb5bb05588be19a616 /lumina-desktop | |
parent | Change a bit more of the localization/translation mechanisms: Now it is possi... (diff) | |
download | lumina-9563e097f85d862aa3647e2d4ede759fd6048df1.tar.gz lumina-9563e097f85d862aa3647e2d4ede759fd6048df1.tar.bz2 lumina-9563e097f85d862aa3647e2d4ede759fd6048df1.zip |
Finish cleaning up the new localization configuration settings in libLumina, and put a combobox in the system dashboard plugin which allows the user to (temporarily) change their session locale.
Still need to finish up the active re-translation of the desktop session though.
Diffstat (limited to 'lumina-desktop')
-rw-r--r-- | lumina-desktop/LSession.cpp | 20 | ||||
-rw-r--r-- | lumina-desktop/LSession.h | 3 | ||||
-rw-r--r-- | lumina-desktop/main.cpp | 4 | ||||
-rw-r--r-- | lumina-desktop/panel-plugins/systemdashboard/SysMenuQuick.cpp | 32 | ||||
-rw-r--r-- | lumina-desktop/panel-plugins/systemdashboard/SysMenuQuick.h | 3 | ||||
-rw-r--r-- | lumina-desktop/panel-plugins/systemdashboard/SysMenuQuick.ui | 74 |
6 files changed, 96 insertions, 40 deletions
diff --git a/lumina-desktop/LSession.cpp b/lumina-desktop/LSession.cpp index a0424667..b2219072 100644 --- a/lumina-desktop/LSession.cpp +++ b/lumina-desktop/LSession.cpp @@ -90,6 +90,19 @@ void LSession::setupSession(){ QSettings::setPath(QSettings::NativeFormat, QSettings::UserScope, QDir::homePath()+"/.lumina"); sessionsettings = new QSettings("LuminaDE", "sessionsettings"); DPlugSettings = new QSettings("pluginsettings","desktopsettings"); + //Load the proper translation files + if(sessionsettings->value("ForceInitialLocale",false).toBool()){ + //Some system locale override it in place - change the env first + LUtils::setLocaleEnv( sessionsettings->value("InitLocale/LANG","").toString(), \ + sessionsettings->value("InitLocale/LC_MESSAGES","").toString(), \ + sessionsettings->value("InitLocale/LC_TIME","").toString(), \ + sessionsettings->value("InitLocale/LC_NUMERIC","").toString(), \ + sessionsettings->value("InitLocale/LC_MONETARY","").toString(), \ + sessionsettings->value("InitLocale/LC_COLLATE","").toString(), \ + sessionsettings->value("InitLocale/LC_CTYPE","").toString() ); + } + currTranslator = LUtils::LoadTranslation(this, "lumina-desktop"); +//use the system settings //Setup the user's lumina settings directory as necessary splash.showScreen("user"); if(DEBUG){ qDebug() << " - Init User Files:" << timer->elapsed();} @@ -554,6 +567,13 @@ QSettings* LSession::DesktopPluginSettings(){ return DPlugSettings; } +//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); + emit LocaleChanged(); +} + void LSession::systemWindow(){ if(sysWindow==0){ sysWindow = new SystemWindow(); } else{ sysWindow->updateWindow(); } diff --git a/lumina-desktop/LSession.h b/lumina-desktop/LSession.h index b7e6de63..6a73b04a 100644 --- a/lumina-desktop/LSession.h +++ b/lumina-desktop/LSession.h @@ -84,6 +84,9 @@ public: QSettings* sessionSettings(); QSettings* DesktopPluginSettings(); + //Temporarily change the session locale (nothing saved between sessions) + void switchLocale(QString localeCode); + //Play System Audio void playAudioFile(QString filepath); //Window Adjustment Routine (due to Fluxbox not respecting _NET_WM_STRUT) diff --git a/lumina-desktop/main.cpp b/lumina-desktop/main.cpp index 4873751a..4bcde4f8 100644 --- a/lumina-desktop/main.cpp +++ b/lumina-desktop/main.cpp @@ -84,8 +84,8 @@ int main(int argc, char ** argv) qInstallMessageHandler(MessageOutput); if(DEBUG){ qDebug() << "Theme Init:" << timer->elapsed(); } LuminaThemeEngine theme(&a); - if(DEBUG){ qDebug() << "Load Locale:" << timer->elapsed(); } - LUtils::LoadTranslation(&a, "lumina-desktop"); + //if(DEBUG){ qDebug() << "Load Locale:" << timer->elapsed(); } + //LUtils::LoadTranslation(&a, "lumina-desktop"); if(DEBUG){ qDebug() << "Session Setup:" << timer->elapsed(); } a.setupSession(); diff --git a/lumina-desktop/panel-plugins/systemdashboard/SysMenuQuick.cpp b/lumina-desktop/panel-plugins/systemdashboard/SysMenuQuick.cpp index 0cf053fa..0e5867c2 100644 --- a/lumina-desktop/panel-plugins/systemdashboard/SysMenuQuick.cpp +++ b/lumina-desktop/panel-plugins/systemdashboard/SysMenuQuick.cpp @@ -16,8 +16,9 @@ LSysMenuQuick::LSysMenuQuick(QWidget *parent) : QWidget(parent), ui(new Ui::LSys brighttimer->setSingleShot(true); brighttimer->setInterval(50); //50ms delay in setting the new value //Now reset the initial saved settings (this is handles by the LOS/session now - 4/22/15) + firstrun = true; UpdateMenu(); //do this once before all the signals/slots are connected below - + firstrun = false; //Now setup the connections connect(ui->slider_volume, SIGNAL(valueChanged(int)), this, SLOT(volSliderChanged()) ); connect(ui->slider_brightness, SIGNAL(valueChanged(int)), this, SLOT(brightSliderChanged()) ); @@ -26,6 +27,7 @@ LSysMenuQuick::LSysMenuQuick(QWidget *parent) : QWidget(parent), ui(new Ui::LSys connect(ui->tool_logout, SIGNAL(clicked()), this, SLOT(startLogout()) ); connect(ui->tool_vol_mixer, SIGNAL(clicked()), this, SLOT(startMixer()) ); connect(brighttimer, SIGNAL(timeout()), this, SLOT(setCurrentBrightness()) ); + connect(ui->combo_locale, SIGNAL(currentIndexChanged(int)), this, SLOT(changeLocale()) ); //And setup the default icons ui->label_bright_icon->setPixmap( LXDG::findIcon("preferences-system-power-management","").pixmap(ui->label_bright_icon->maximumSize()) ); ui->tool_wk_prev->setIcon( LXDG::findIcon("go-previous-view","")); @@ -66,8 +68,27 @@ void LSysMenuQuick::UpdateMenu(){ ui->label_bright_text->setText(txt); if(ui->slider_brightness->value()!=val){ ui->slider_brightness->setValue(val); } } + + //Do any one-time checks + if(firstrun){ + hasBat = LOS::hasBattery(); //No need to check this more than once - will not change in the middle of a session + //Current Locale + QStringList locales = LUtils::knownLocales(); + ui->combo_locale->clear(); + 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 + 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 + } + } + ui->group_locale->setVisible(locales.length() > 1); + } + //Battery Status - if(LOS::hasBattery()){ + if(hasBat){ ui->group_battery->setVisible(true); val = LOS::batteryCharge(); if(LOS::batteryIsCharging()){ @@ -178,3 +199,10 @@ void LSysMenuQuick::startLogout(){ emit CloseMenu(); LSession::handle()->systemWindow(); } + +void LSysMenuQuick::changeLocale(){ + //Get the currently selected Locale + QString locale = ui->combo_locale->currentData().toString(); + emit CloseMenu(); + LSession::handle()->switchLocale(locale); +}
\ No newline at end of file diff --git a/lumina-desktop/panel-plugins/systemdashboard/SysMenuQuick.h b/lumina-desktop/panel-plugins/systemdashboard/SysMenuQuick.h index a9580cce..a300b5b1 100644 --- a/lumina-desktop/panel-plugins/systemdashboard/SysMenuQuick.h +++ b/lumina-desktop/panel-plugins/systemdashboard/SysMenuQuick.h @@ -32,7 +32,7 @@ public: private: Ui::LSysMenuQuick *ui; QTimer *brighttimer; - + bool firstrun, hasBat; QString getRemainingTime(); //battery time left private slots: @@ -43,6 +43,7 @@ private slots: void nextWorkspace(); void prevWorkspace(); void startLogout(); + void changeLocale(); signals: diff --git a/lumina-desktop/panel-plugins/systemdashboard/SysMenuQuick.ui b/lumina-desktop/panel-plugins/systemdashboard/SysMenuQuick.ui index 8f58cae9..67e83a45 100644 --- a/lumina-desktop/panel-plugins/systemdashboard/SysMenuQuick.ui +++ b/lumina-desktop/panel-plugins/systemdashboard/SysMenuQuick.ui @@ -6,8 +6,8 @@ <rect> <x>0</x> <y>0</y> - <width>169</width> - <height>240</height> + <width>171</width> + <height>317</height> </rect> </property> <property name="windowTitle"> @@ -336,56 +336,60 @@ font: bold; </widget> </item> <item> - <widget class="QGroupBox" name="groupBox"> - <property name="styleSheet"> - <string notr="true">QGroupBox{ border: none; }</string> - </property> + <widget class="QGroupBox" name="group_locale"> <property name="title"> - <string/> - </property> - <property name="flat"> - <bool>true</bool> + <string>Locale</string> </property> - <layout class="QHBoxLayout" name="horizontalLayout_5"> + <layout class="QVBoxLayout" name="verticalLayout_2"> + <property name="spacing"> + <number>2</number> + </property> <property name="leftMargin"> - <number>1</number> + <number>2</number> </property> <property name="topMargin"> <number>2</number> </property> <property name="rightMargin"> - <number>1</number> + <number>2</number> </property> <property name="bottomMargin"> <number>2</number> </property> <item> - <widget class="QToolButton" name="tool_logout"> - <property name="font"> - <font> - <pointsize>9</pointsize> - </font> - </property> - <property name="text"> - <string>Log Out</string> - </property> - <property name="iconSize"> - <size> - <width>22</width> - <height>22</height> - </size> - </property> - <property name="toolButtonStyle"> - <enum>Qt::ToolButtonTextBesideIcon</enum> - </property> - <property name="autoRaise"> - <bool>false</bool> - </property> - </widget> + <widget class="QComboBox" name="combo_locale"/> </item> </layout> </widget> </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout_6"> + <item> + <widget class="QToolButton" name="tool_logout"> + <property name="font"> + <font> + <pointsize>9</pointsize> + </font> + </property> + <property name="text"> + <string>Log Out</string> + </property> + <property name="iconSize"> + <size> + <width>22</width> + <height>22</height> + </size> + </property> + <property name="toolButtonStyle"> + <enum>Qt::ToolButtonTextBesideIcon</enum> + </property> + <property name="autoRaise"> + <bool>false</bool> + </property> + </widget> + </item> + </layout> + </item> </layout> </widget> <resources/> |