diff --git a/retroshare-gui/src/gui/settings/rsharesettings.cpp b/retroshare-gui/src/gui/settings/rsharesettings.cpp index a9e830921..38473ab76 100644 --- a/retroshare-gui/src/gui/settings/rsharesettings.cpp +++ b/retroshare-gui/src/gui/settings/rsharesettings.cpp @@ -76,9 +76,9 @@ // the one and only global settings object RshareSettings *Settings = NULL; -/*static*/ void RshareSettings::Create () +/*static*/ void RshareSettings::Create(bool forceCreateNew) { - if (Settings && Settings->m_bValid == false) { + if (Settings && (forceCreateNew || Settings->m_bValid == false)) { // recreate with correct path delete (Settings); Settings = NULL; diff --git a/retroshare-gui/src/gui/settings/rsharesettings.h b/retroshare-gui/src/gui/settings/rsharesettings.h index 01278e11f..82c235e93 100644 --- a/retroshare-gui/src/gui/settings/rsharesettings.h +++ b/retroshare-gui/src/gui/settings/rsharesettings.h @@ -86,7 +86,7 @@ public: public: /* create settings object */ - static void Create (); + static void Create(bool forceCreateNew = false); /** Gets the currently preferred language code for RShare. */ QString getLanguageCode(); diff --git a/retroshare-gui/src/lang/languagesupport.cpp b/retroshare-gui/src/lang/languagesupport.cpp index d6e30515f..175c17577 100644 --- a/retroshare-gui/src/lang/languagesupport.cpp +++ b/retroshare-gui/src/lang/languagesupport.cpp @@ -123,6 +123,15 @@ LanguageSupport::translate(const QString &languageCode) { if (!isValidLanguageCode(languageCode)) return false; + + static QTranslator *retroshareTranslator = NULL; + if (retroshareTranslator) { + // remove the previous translator, is needed, when switching to en + QApplication::removeTranslator(retroshareTranslator); + delete(retroshareTranslator); + retroshareTranslator = NULL; + } + if (languageCode == "en") return true; @@ -144,7 +153,7 @@ LanguageSupport::translate(const QString &languageCode) } /* Install a translator for RetroShare's UI widgets */ - QTranslator *retroshareTranslator = new QTranslator(rApp); + retroshareTranslator = new QTranslator(rApp); Q_CHECK_PTR(retroshareTranslator); if (retroshareTranslator->load(":/lang/retroshare_" + languageCode + ".qm")) { @@ -152,5 +161,6 @@ LanguageSupport::translate(const QString &languageCode) return true; } delete retroshareTranslator; + retroshareTranslator = NULL; return false; } diff --git a/retroshare-gui/src/main.cpp b/retroshare-gui/src/main.cpp index 0782254be..1617010de 100644 --- a/retroshare-gui/src/main.cpp +++ b/retroshare-gui/src/main.cpp @@ -212,14 +212,16 @@ int main(int argc, char *argv[]) return 1; } + /* recreate global settings object, now with correct path */ + RshareSettings::Create(true); + Rshare::resetLanguageAndStyle(); + splashScreen.showMessage(rshare.translate("SplashScreen", "Load configuration"), Qt::AlignHCenter | Qt::AlignBottom); rsicontrol->StartupRetroShare(); splashScreen.showMessage(rshare.translate("SplashScreen", "Create interface"), Qt::AlignHCenter | Qt::AlignBottom); - /* recreate global settings object, now with correct path */ - RshareSettings::Create (); RsharePeerSettings::Create(); #ifdef MINIMAL_RSGUI @@ -272,9 +274,7 @@ int main(int argc, char *argv[]) QObject::connect(notify,SIGNAL(filesPostModChanged(bool)) ,w->sharedfilesDialog ,SLOT(postModDirectories(bool) )) ; QObject::connect(notify,SIGNAL(filesPostModChanged(bool)) ,w ,SLOT(postModDirectories(bool) )) ; QObject::connect(notify,SIGNAL(transfersChanged()) ,w->transfersDialog ,SLOT(insertTransfers() )) ; - QObject::connect(notify,SIGNAL(friendsChanged()) ,w->friendsDialog ,SLOT(insertPeers() )) ; QObject::connect(notify,SIGNAL(publicChatChanged(int)) ,w->friendsDialog ,SLOT(publicChatChanged(int) )); - QObject::connect(notify,SIGNAL(groupsChanged(int)) ,w->friendsDialog ,SLOT(groupsChanged(int) )); QObject::connect(notify,SIGNAL(privateChatChanged(int, int)) ,w ,SLOT(privateChatChanged(int, int) )); QObject::connect(notify,SIGNAL(neighboursChanged()) ,w->networkDialog ,SLOT(insertConnect() )) ; QObject::connect(notify,SIGNAL(messagesChanged()) ,w->messagesDialog ,SLOT(insertMessages() )) ; @@ -291,8 +291,6 @@ int main(int argc, char *argv[]) QObject::connect(notify,SIGNAL(discInfoChanged()) ,w->networkDialog,SLOT(updateNewDiscoveryInfo()),Qt::QueuedConnection) ; QObject::connect(notify,SIGNAL(errorOccurred(int,int,const QString&)),w,SLOT(displayErrorMessage(int,int,const QString&))) ; - QObject::connect(w->friendsDialog,SIGNAL(friendsUpdated()),w->networkDialog,SLOT(insertConnect())) ; - w->installGroupChatNotifier(); /* only show window, if not startMinimized */ diff --git a/retroshare-gui/src/rshare.cpp b/retroshare-gui/src/rshare.cpp index 58a1c30a3..8622fa70e 100644 --- a/retroshare-gui/src/rshare.cpp +++ b/retroshare-gui/src/rshare.cpp @@ -122,14 +122,7 @@ Rshare::Rshare(QStringList args, int &argc, char **argv, QString dir) /** Initialize support for language translations. */ //LanguageSupport::initialize(); - /** Translate the GUI to the appropriate language. */ - setLanguage(_args.value(ARG_LANGUAGE)); - - /** Set the GUI style appropriately. */ - setStyle(_args.value(ARG_GUISTYLE)); - - /** Set the GUI stylesheet appropriately. */ - setSheet(_args.value(ARG_GUISTYLESHEET)); + resetLanguageAndStyle(); /* Switch off auto shutdown */ setQuitOnLastWindowClosed ( false ); @@ -355,6 +348,18 @@ Rshare::setSheet(QString sheet) } +void Rshare::resetLanguageAndStyle() +{ + /** Translate the GUI to the appropriate language. */ + setLanguage(_args.value(ARG_LANGUAGE)); + + /** Set the GUI style appropriately. */ + setStyle(_args.value(ARG_GUISTYLE)); + + /** Set the GUI stylesheet appropriately. */ + setSheet(_args.value(ARG_GUISTYLESHEET)); +} + /** Returns the directory RetroShare uses for its data files. */ QString Rshare::dataDirectory() diff --git a/retroshare-gui/src/rshare.h b/retroshare-gui/src/rshare.h index bedf3c4be..9299b96be 100644 --- a/retroshare-gui/src/rshare.h +++ b/retroshare-gui/src/rshare.h @@ -78,6 +78,12 @@ public: /** Sets the current GUI stylesheet. */ static bool setSheet(QString sheet = QString()); + /** + * Update Language, Style and StyleSheet. + * First args are cheked for a style then the settings. + */ + static void resetLanguageAndStyle(); + /** Returns the current language. */ static QString language() { return _language; }