mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-31 18:36:24 -05:00
fixed issue of loading the correct instance of RetroShare.conf when switching locations (Patch from AsamK #3423256)
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@4637 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
7a98e83df1
commit
6989a40312
@ -76,9 +76,9 @@
|
|||||||
// the one and only global settings object
|
// the one and only global settings object
|
||||||
RshareSettings *Settings = NULL;
|
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
|
// recreate with correct path
|
||||||
delete (Settings);
|
delete (Settings);
|
||||||
Settings = NULL;
|
Settings = NULL;
|
||||||
|
@ -86,7 +86,7 @@ public:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
/* create settings object */
|
/* create settings object */
|
||||||
static void Create ();
|
static void Create(bool forceCreateNew = false);
|
||||||
|
|
||||||
/** Gets the currently preferred language code for RShare. */
|
/** Gets the currently preferred language code for RShare. */
|
||||||
QString getLanguageCode();
|
QString getLanguageCode();
|
||||||
|
@ -123,6 +123,15 @@ LanguageSupport::translate(const QString &languageCode)
|
|||||||
{
|
{
|
||||||
if (!isValidLanguageCode(languageCode))
|
if (!isValidLanguageCode(languageCode))
|
||||||
return false;
|
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")
|
if (languageCode == "en")
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
@ -144,7 +153,7 @@ LanguageSupport::translate(const QString &languageCode)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Install a translator for RetroShare's UI widgets */
|
/* Install a translator for RetroShare's UI widgets */
|
||||||
QTranslator *retroshareTranslator = new QTranslator(rApp);
|
retroshareTranslator = new QTranslator(rApp);
|
||||||
Q_CHECK_PTR(retroshareTranslator);
|
Q_CHECK_PTR(retroshareTranslator);
|
||||||
|
|
||||||
if (retroshareTranslator->load(":/lang/retroshare_" + languageCode + ".qm")) {
|
if (retroshareTranslator->load(":/lang/retroshare_" + languageCode + ".qm")) {
|
||||||
@ -152,5 +161,6 @@ LanguageSupport::translate(const QString &languageCode)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
delete retroshareTranslator;
|
delete retroshareTranslator;
|
||||||
|
retroshareTranslator = NULL;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -212,14 +212,16 @@ int main(int argc, char *argv[])
|
|||||||
return 1;
|
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);
|
splashScreen.showMessage(rshare.translate("SplashScreen", "Load configuration"), Qt::AlignHCenter | Qt::AlignBottom);
|
||||||
|
|
||||||
rsicontrol->StartupRetroShare();
|
rsicontrol->StartupRetroShare();
|
||||||
|
|
||||||
splashScreen.showMessage(rshare.translate("SplashScreen", "Create interface"), Qt::AlignHCenter | Qt::AlignBottom);
|
splashScreen.showMessage(rshare.translate("SplashScreen", "Create interface"), Qt::AlignHCenter | Qt::AlignBottom);
|
||||||
|
|
||||||
/* recreate global settings object, now with correct path */
|
|
||||||
RshareSettings::Create ();
|
|
||||||
RsharePeerSettings::Create();
|
RsharePeerSettings::Create();
|
||||||
|
|
||||||
#ifdef MINIMAL_RSGUI
|
#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->sharedfilesDialog ,SLOT(postModDirectories(bool) )) ;
|
||||||
QObject::connect(notify,SIGNAL(filesPostModChanged(bool)) ,w ,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(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(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(privateChatChanged(int, int)) ,w ,SLOT(privateChatChanged(int, int) ));
|
||||||
QObject::connect(notify,SIGNAL(neighboursChanged()) ,w->networkDialog ,SLOT(insertConnect() )) ;
|
QObject::connect(notify,SIGNAL(neighboursChanged()) ,w->networkDialog ,SLOT(insertConnect() )) ;
|
||||||
QObject::connect(notify,SIGNAL(messagesChanged()) ,w->messagesDialog ,SLOT(insertMessages() )) ;
|
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(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(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();
|
w->installGroupChatNotifier();
|
||||||
|
|
||||||
/* only show window, if not startMinimized */
|
/* only show window, if not startMinimized */
|
||||||
|
@ -122,14 +122,7 @@ Rshare::Rshare(QStringList args, int &argc, char **argv, QString dir)
|
|||||||
/** Initialize support for language translations. */
|
/** Initialize support for language translations. */
|
||||||
//LanguageSupport::initialize();
|
//LanguageSupport::initialize();
|
||||||
|
|
||||||
/** Translate the GUI to the appropriate language. */
|
resetLanguageAndStyle();
|
||||||
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));
|
|
||||||
|
|
||||||
/* Switch off auto shutdown */
|
/* Switch off auto shutdown */
|
||||||
setQuitOnLastWindowClosed ( false );
|
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. */
|
/** Returns the directory RetroShare uses for its data files. */
|
||||||
QString
|
QString
|
||||||
Rshare::dataDirectory()
|
Rshare::dataDirectory()
|
||||||
|
@ -78,6 +78,12 @@ public:
|
|||||||
/** Sets the current GUI stylesheet. */
|
/** Sets the current GUI stylesheet. */
|
||||||
static bool setSheet(QString sheet = QString());
|
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. */
|
/** Returns the current language. */
|
||||||
static QString language() { return _language; }
|
static QString language() { return _language; }
|
||||||
|
Loading…
Reference in New Issue
Block a user